agent-orchestrator/packages/cli/__tests__/lib
Priyanshu Choudhary deaf25a031 fix(cli): Windows platform adapter follow-ups
Three independent Windows correctness fixes bundled with their tests:

* daemon.ts: killExistingDaemon now uses killProcessTree (taskkill /T /F)
  instead of raw process.kill so detached grandchildren of the daemon
  (pty-host, dashboard subprocess) are reached on Windows. POSIX behavior
  is preserved via killProcessTree's process-group fallback.

* startup-preflight.ts: on Windows, when the project config selects
  runtime: tmux, offer to rewrite the line to runtime: process in the
  project YAML instead of prompting "install tmux?". The rewrite is a
  targeted line-replace (not yaml round-trip) so comments and quoting
  are preserved. Decline -> hard exit with manual-fix guidance.

* path-equality: new pathsEqual / canonicalCompareKey helpers used by
  start.ts and resolve-project.ts for "same filesystem entry" checks.
  realpathSync on Windows can return canonical paths whose drive-letter
  case or 8.3-vs-long-name expansion differs from the input even when
  both resolve to the same on-disk entry, which made naive === comparisons
  miss and surface as phantom "register this project?" prompts on
  re-runs of `ao start <path>`. Lowercases on Windows; POSIX is
  unchanged.

Also fixes resolve-project.ts's isLocalPath to recognize Windows path
patterns (drive-letter, UNC, .\, ..\) so `ao start C:\path\to\repo`
takes the path branch instead of being mis-classified as a project id.

Test changes: makeConfig now defaults to runtime: process so tests run
on every platform without tripping the Windows-tmux exit; the one tmux
preflight test pins process.platform = 'linux'. The "kills existing
process" test asserts on killProcessTree instead of process.kill.
On-disk yaml fixtures in start.test.ts switch from runtime: tmux to
runtime: process for the same reason.

New tests: 7 in startup-preflight.test.ts (Windows rewrite, decline
exit, missing configPath exit, comment+quoting preservation, Linux
pass-through), 8 in path-equality.test.ts (drive-letter case, segment
case, POSIX case-sensitivity, realpathSync fallback, ~ expansion),
killProcessTree assertions added to daemon.test.ts.

Verified non-issues during the audit (no code change): ao stop graceful
shutdown gap (the work was already moved into ao stop itself in a prior
refactor; running.json/last-stop/sessions are persisted before the
parent kill, and stale state is self-healing on next read);
better-sqlite3 cross-platform binary (optionalDependencies +
files: ['dist'], no prebuilt .node bundled in any release artifact);
ao-doctor / ao-update PowerShell rewrite (script-runner already
rewrites .sh -> .ps1 on Windows, .ps1 siblings ship in assets/scripts/,
covered by an existing Windows-only test); bun-tmp-janitor leak
(janitor is a no-op on Windows because opencode ships no win32 binary
and Windows refuses to unlink mapped files).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 20:28:16 +05:30
..
bun-tmp-janitor.test.ts Merge origin/main into feat/windows-platform-adapter 2026-04-29 04:37:04 +05:30
daemon.test.ts fix(cli): Windows platform adapter follow-ups 2026-05-04 20:28:16 +05:30
dashboard-rebuild.test.ts fix: clear stale Next.js cache on version upgrade (#1022) 2026-05-01 12:23:51 +05:30
detect-env.test.ts refactor(cli): extract shared repo helpers and support GitLab subgroups 2026-04-15 12:30:32 +05:30
format.test.ts feat: implement CLI with all commands (init, status, spawn, session, send, review-check, dashboard, open) (#6) 2026-02-14 16:14:27 +05:30
lifecycle-service.test.ts fix(cli): supervise lifecycle workers for active projects (#1600) 2026-05-01 15:45:06 +05:30
openclaw-probe.test.ts fix(windows): address review feedback, fix tests, and improve Windows coverage 2026-04-11 14:48:25 +05:30
path-equality.test.ts fix(cli): Windows platform adapter follow-ups 2026-05-04 20:28:16 +05:30
plugins.test.ts feat(plugin): implement kimicode agent plugin (#1390) 2026-05-01 14:11:30 +05:30
preflight.test.ts refactor(spawn): plugin-owned preflight + collapse project resolution (#1622) 2026-05-04 14:03:26 +05:30
prevent-sleep.test.ts fix(power): address PR review feedback for sleep prevention 2026-04-11 21:06:32 +05:30
project-resolution.test.ts fix: detect nested project directories in CLI auto-resolution 2026-04-01 18:28:57 +05:30
project-supervisor.test.ts fix(cli): supervise lifecycle workers for active projects (#1600) 2026-05-01 15:45:06 +05:30
repo-validation.test.ts refactor(cli): extract shared repo helpers and support GitLab subgroups 2026-04-15 12:30:32 +05:30
running-state.test.ts fix: tighten startup lock cleanup 2026-04-20 13:30:07 +05:30
script-runner.test.ts test(cli): port-scan fallback + Windows PowerShell branch coverage 2026-05-03 18:43:32 +05:30
session-utils.test.ts Add multi-project storage, resolution, and project settings support (#1343) 2026-04-21 17:45:55 +05:30
shell.test.ts fix(windows): update @composio imports to @aoagents scope 2026-04-10 02:28:12 +05:30
startup-preflight.test.ts fix(cli): Windows platform adapter follow-ups 2026-05-04 20:28:16 +05:30
update-check.test.ts Merge remote-tracking branch 'origin/main' into feat/windows-platform-adapter 2026-05-01 21:23:49 +05:30