Repository navigation
feat(agent): COD-549 launch workers in existing project directories - #708
Conversation
|
Thanks for this, aakhter. This PR lets I ran it against a real in-process server as well as your tests: claude and shell workers land in the given directory with the parent lineage intact and a started pane, no agent-case marker is written, and a CLI that is not installed is refused before any session exists. Typecheck, lint, format and the agent CLI, MCP, skill and plugin tests all pass. A few small things:
Nits:
No need to push again for these: I will apply them on top when I merge, unless you would rather push them yourself first. |
…ment the directory launch
`codeman agent spawn ""` (for example `spawn "$CASE"` with CASE unset)
used to launch a worker in the caller's cwd. Both case checks now test
`caseName !== undefined`, so an empty name reaches quick-start and is
refused by its schema as before.
Drop the `{ id }` fallback on the create answer: `POST /api/sessions`
answers `{ session: { id } }`, and the test fakes now use that shape.
Tests: an empty case name (unit and through the real argument parser
and HTTP transport), the claude `--ready` order create, /interactive,
wait-output on the created id, and a non-JSON failed start (id alone on
stdout, reason on stderr, exit 1).
Docs: the spawn mapping and directory-launch JSON shape in
docs/api-reference.md, the README and wiki `codeman agent` sections, the
cli-agent @fileoverview and the skill reference tables; reflow the new
SKILL.md paragraph (plugin mirror synced); the changeset notes the
local exit-4 refusal of an unknown mode for named cases.
|
Thanks for the review and for testing it against a real server. I pushed all of it (c5ffea0), so there is nothing left for you to apply at merge.
Nits: the changeset now says an unknown Typecheck, lint, format and the agent CLI, MCP, skill and plugin tests (201) all pass. |
|
Thanks for the quick and thorough follow-up, aakhter. With c5ffea0, One small thing is left, the flag version of the empty-case issue:
Nit:
No need to push again for these: I will apply them on top when I merge, unless you would rather push them yourself first. |
`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.
|
Thanks. I pushed both so nothing is left to apply at merge:
Nit: the |
|
Thanks for the second follow-up, aakhter. With b26234d, Both points from the last round landed: an empty or whitespace-only One small thing is left:
Nit:
No need to push again for these: I will apply them on top when I merge, unless you would rather push them yourself first. |
`codeman agent spawn` always sends its directory as an explicit workingDir, so the server cannot apply its no-workingDir rule and installs workspace hooks (and an injected skill) into ~/.claude when the caller's cwd is HOME. A bare spawn whose cwd resolves to the home directory now refuses with exit 4 before any request and names `--working-dir ~`; an explicit `--working-dir ~` is still sent. Paths are compared by realpath, so a symlinked HOME matches, and an unresolvable HOME or cwd falls back to the resolved path without throwing. The directory-spawn --json shape now reads the same in the README, the API reference, the wiki page and the changeset: `ready` when a readiness wait ran, `readinessError` when that call failed, and `startupError` when the start failed. A test pins all four.
|
Thanks, Ark0N. I pushed both items myself as 003398e, so there is nothing for you to apply at merge.
Nit, Same-class sweep: Trade-off: the refusal applies to every mode, not just claude. Skill injection doesn't depend on the mode, and the rule is easier to predict this way. A shell worker in HOME just needs Mutation checks: turning the guard off fails 3 tests. Applying the guard to the explicit flag too fails 2. Replacing realpath with resolve fails the symlink test. Reverting the README clause fails the doc test. Gates: typecheck, lint, format:check, check:frontend-syntax, check:public-assets, check:browser-excludes and the plugin mirror check all pass. Agent CLI, MCP, skill, plugin and session-routes tests: 16 files, 463 tests, all passing. |
|
Thanks for the third follow-up, aakhter. With 003398e, The HOME guard does what the last round asked: the realpath comparison, the explicit One thing needs fixing before merge:
Smaller things:
No need to push again for these: I will apply them on top when I merge, unless you would rather push them yourself first. |
- test/cli-agent-project-spawn.test.ts:345: the doc-sync test no longer reads .changeset/project-worker-directories.md (changeset version deletes it at release); README, API reference and wiki stay. - CLAUDE.md:132 + src/cli-agent.ts @fileoverview (invariant 5): the directory spawn (POST /api/v1/sessions plus /interactive or /shell, no Agent-Origin header, so no marker) and its refusals (empty --working-dir, bare spawn from a HOME cwd); the invariants now name test/cli-agent-project-spawn.test.ts too. - test/cli-agent-project-spawn.test.ts:322: "allows a cwd below HOME" mocks the cwd to <temp HOME>/src/app, so it covers the case the guard must leave alone. - docs/wiki/Driving-Codeman-From-An-Agent.md:59: split the sentence so exit 4 covers only the empty --working-dir; spawn "" reaches quick-start and exits 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and guarded submission Conflicts resolved by keeping both sides: - CLAUDE.md (Agent CLI): #694's opening (an HTTP client, the experimental agent-session-routes behind agentCoordinationEnabled) with #708's clause on the directory spawn and its two refusals. - docs/api-reference.md (codeman agent): #708's spawn paragraph and --json shape, with #694's inspect/stage/submit in the verb list and the guarded endpoints named before "adds no route for the other verbs". - src/cli-agent.ts (@fileoverview): #708's quick-start / directory spawn routes and #694's experimental routes in one endpoint list; the two node:fs/promises imports (#708's realpath+stat, #694's open+stat) merged into one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged in 1.46.0 (https://github.com/Ark0N/Codeman/releases/tag/codeman%401.46.0). Thank you for the HOME guard round; the realpath comparison and the explicit |
codeman agent spawnrequires a case name even when a worker should use an existing project. Allow an omitted case to use the caller's cwd, and add--working-dirfor another existing local directory. Named cases keep their current quick-start behavior.A directory launch creates the session with
POST /api/v1/sessions(workingDirset) and starts it with the mode's start route (POST /api/v1/sessions/:id/interactiveor/shell), keeping parent lineage and the server's ownership checks. Real project directories receive no agent-case marker. A rejected or ambiguous start returns the created session id, one valid JSON document with--json, and an error exit, without retrying.Refused locally with exit 4, before any request:
--mode(named-case spawns included; noted in the changeset)--working-dir, which would otherwise resolve to the cwdspawnwhose cwd is the home directory (realpath compare, so a symlinked HOME matches): it would install Codeman's hooks into~/.claude/settings.local.json, the same reasonPOST /api/sessionsskips workspace hooks without aworkingDir. An explicit--working-dir ~is still allowed.spawn ""(for examplespawn "$CASE"withCASEunset) is a case name, not "use cwd": it reaches quick-start, which refuses it, as on master.Directory-launch
--jsonoutput:{ sessionId, workingDir, created: true }, plusreadywhen a readiness wait ran,readinessErrorwhen that call failed, andstartupErrorwhen the start failed. The same sentence appears indocs/api-reference.md, the README, the wiki page and the changeset, and a test keeps the four in step.Docs: api-reference, README,
docs/wiki/Driving-Codeman-From-An-Agent.md, theskills/codemanverbs and messaging references,SKILL.mdand its synced plugin mirror, thecli-agent.ts@fileoverview, and a minor changeset.Verification:
test/cli-agent-project-spawn.test.tsandtest/cli-agent.test.ts: 111 tests, including the real commander parser and HTTP transport forspawn "",--working-dir ""and a HOME cwd. Each guard was reverted to confirm its tests fail.Paths must exist on the CLI host; normal server path and ownership validation still apply. This contribution is independent of the readiness fix (#709) and the offline-history command (#707).