mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 19:29:33 +01:00
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:
1 parent
c5ffea0ed2
commit
b26234d6c6
8 files changed
+39
-11
No files matched your search
@@ -163,6 +163,14 @@ describe('project-preserving agent spawn', () => {
|
||||
expect(await agentSpawn(t.d, { ...base, caseName: '', workingDir: process.cwd() })).toBe(EXIT.refused);
|
||||
expect(t.calls).toEqual([]);
|
||||
});
|
||||
it('an empty or whitespace-only --working-dir is refused before any request, never the caller cwd', async () => {
|
||||
for (const workingDir of ['', ' ', '\t']) {
|
||||
const t = deps([]);
|
||||
expect(await agentSpawn(t.d, { ...base, workingDir })).toBe(EXIT.refused);
|
||||
expect(t.calls).toEqual([]);
|
||||
expect(t.out.join('\n')).toContain('--working-dir is empty');
|
||||
}
|
||||
});
|
||||
it('with ready on claude: create, then /interactive, then wait-output on the created id', async () => {
|
||||
const t = deps([ok({ session: { id: OTHER } }), ok({}), ok({ wait: { matched: true } })]);
|
||||
expect(await agentSpawn(t.d, { ...base, mode: 'claude', ready: true })).toBe(EXIT.ok);
|
||||
@@ -239,6 +247,13 @@ describe('agent spawn through the real argument parser and transport', () => {
|
||||
expect(seen[0]).toMatchObject({ method: 'POST', url: '/api/v1/quick-start', body: { caseName: '' } });
|
||||
expect(exitCode).toBe(EXIT.error);
|
||||
});
|
||||
it('`spawn --working-dir ""` (as `--working-dir "$WT"` with WT unset) sends nothing and exits 4', async () => {
|
||||
for (const value of ['', ' ']) {
|
||||
const { seen, exitCode } = await runSpawn(['--working-dir', value]);
|
||||
expect(seen).toEqual([]);
|
||||
expect(exitCode).toBe(EXIT.refused);
|
||||
}
|
||||
});
|
||||
it('`spawn` with no case argument creates in the caller cwd', async () => {
|
||||
const { seen, exitCode } = await runSpawn([]);
|
||||
expect(seen).toHaveLength(1);
|
||||
|
||||
Reference in new issue
Block a user