fix(agent): refuse an empty --working-dir instead of spawning in cwd

`codeman agent spawn --working-dir "$WT"` with WT empty (a failed
`git worktree add`, say) resolved '' to the caller's cwd and started an
editing worker in the caller's own checkout. An empty or
whitespace-only --working-dir now refuses with exit 4 before any
request.

The emitJson comment names the directory-spawn exception to "the
envelope's data": `{ sessionId, workingDir, created: true, ready }`.

Tests: unit (`''`, spaces, tab: exit 4, no calls) and through the real
argument parser and HTTP transport (nothing sent, exit 4).

Docs: README, api-reference, wiki, SKILL.md (plugin mirror synced) and
the changeset note the refusal.
This commit is contained in:
Aamer Akhter committed 2026-10-25 09:03:15 -04:00
1 parent c5ffea0ed2
commit b26234d6c6
8 files changed
+39 -11

No files matched your search

+2 -1
View File
@@ -57,7 +57,8 @@ codeman agent rm "$SID" # any session except t
- **`spawn [case]`** uses the current directory when no case is supplied. Use
`codeman agent spawn --working-dir /path/to/project --mode codex` for another existing
local directory. A case and `--working-dir` cannot be combined, and an empty case
name (`spawn "$CASE"` with `CASE` unset) is refused rather than read as "no case".
name (`spawn "$CASE"` with `CASE` unset) is refused rather than read as "no case",
as is an empty `--working-dir` (exit 4, before any request), so it never falls back to cwd.
Explicit case names retain quick-start behavior (creating a scratch case if missing).
A directory launch is `POST /api/v1/sessions` followed by
`POST /api/v1/sessions/:id/interactive` (or `/shell`); it preserves the project and