@agentic-sdlc-kit/cli 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/application/agent/execution-store.d.ts +55 -0
- package/dist/application/agent/execution-store.d.ts.map +1 -0
- package/dist/application/agent/execution-store.js +90 -0
- package/dist/application/agent/execution-store.js.map +1 -0
- package/dist/application/agent/gateway.d.ts +74 -0
- package/dist/application/agent/gateway.d.ts.map +1 -0
- package/dist/application/agent/gateway.js +580 -0
- package/dist/application/agent/gateway.js.map +1 -0
- package/dist/application/agent/index.d.ts +6 -0
- package/dist/application/agent/index.d.ts.map +1 -0
- package/dist/application/agent/index.js +18 -0
- package/dist/application/agent/index.js.map +1 -0
- package/dist/application/agent/orchestrator.d.ts +76 -0
- package/dist/application/agent/orchestrator.d.ts.map +1 -0
- package/dist/application/agent/orchestrator.js +422 -0
- package/dist/application/agent/orchestrator.js.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js +98 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js.map +1 -0
- package/dist/application/agent/providers/claude-code/index.d.ts +7 -0
- package/dist/application/agent/providers/claude-code/index.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/index.js +13 -0
- package/dist/application/agent/providers/claude-code/index.js.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js +41 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts +59 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.js +189 -0
- package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts +38 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.js +577 -0
- package/dist/application/agent/providers/claude-code/provider.js.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts +25 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.js +120 -0
- package/dist/application/agent/providers/claude-code/resume-store.js.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts +50 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js +129 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js.map +1 -0
- package/dist/application/agent/test-fixture.d.ts +15 -0
- package/dist/application/agent/test-fixture.d.ts.map +1 -0
- package/dist/application/agent/test-fixture.js +93 -0
- package/dist/application/agent/test-fixture.js.map +1 -0
- package/dist/application/agent/workspace.d.ts +24 -0
- package/dist/application/agent/workspace.d.ts.map +1 -0
- package/dist/application/agent/workspace.js +139 -0
- package/dist/application/agent/workspace.js.map +1 -0
- package/dist/application/dispatcher.d.ts +13 -0
- package/dist/application/dispatcher.d.ts.map +1 -0
- package/dist/application/dispatcher.js +104 -0
- package/dist/application/dispatcher.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/registry.d.ts +8 -0
- package/dist/application/registry.d.ts.map +1 -0
- package/dist/application/registry.js +17 -0
- package/dist/application/registry.js.map +1 -0
- package/dist/application/version.d.ts +2 -0
- package/dist/application/version.d.ts.map +1 -0
- package/dist/application/version.js +7 -0
- package/dist/application/version.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +68 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/elicit.d.ts +3 -0
- package/dist/commands/elicit.d.ts.map +1 -0
- package/dist/commands/elicit.js +163 -0
- package/dist/commands/elicit.js.map +1 -0
- package/dist/commands/evolve.d.ts +3 -0
- package/dist/commands/evolve.d.ts.map +1 -0
- package/dist/commands/evolve.js +165 -0
- package/dist/commands/evolve.js.map +1 -0
- package/dist/commands/feature.d.ts +13 -0
- package/dist/commands/feature.d.ts.map +1 -0
- package/dist/commands/feature.js +326 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/fix.d.ts +3 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +61 -0
- package/dist/commands/fix.js.map +1 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +32 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +21 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +90 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +64 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +329 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/journal.d.ts +3 -0
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/journal.js +107 -0
- package/dist/commands/journal.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +85 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +68 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/next.d.ts +3 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +107 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/optimize.d.ts +3 -0
- package/dist/commands/optimize.d.ts.map +1 -0
- package/dist/commands/optimize.js +28 -0
- package/dist/commands/optimize.js.map +1 -0
- package/dist/commands/plugin-linker.d.ts +34 -0
- package/dist/commands/plugin-linker.d.ts.map +1 -0
- package/dist/commands/plugin-linker.js +177 -0
- package/dist/commands/plugin-linker.js.map +1 -0
- package/dist/commands/refactor.d.ts +3 -0
- package/dist/commands/refactor.d.ts.map +1 -0
- package/dist/commands/refactor.js +32 -0
- package/dist/commands/refactor.js.map +1 -0
- package/dist/commands/types.d.ts +19 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/validate-plan.d.ts +3 -0
- package/dist/commands/validate-plan.d.ts.map +1 -0
- package/dist/commands/validate-plan.js +62 -0
- package/dist/commands/validate-plan.js.map +1 -0
- package/dist/commands/validate-spec.d.ts +3 -0
- package/dist/commands/validate-spec.d.ts.map +1 -0
- package/dist/commands/validate-spec.js +62 -0
- package/dist/commands/validate-spec.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +103 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +12 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/output/formatter.d.ts +2 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +10 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/index.d.ts +2 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +3 -0
- package/dist/output/index.js.map +1 -0
- package/package.json +37 -3
- package/src/application/agent/execution-store.ts +162 -0
- package/src/application/agent/gateway.test.ts +529 -0
- package/src/application/agent/gateway.ts +744 -0
- package/src/application/agent/index.ts +18 -0
- package/src/application/agent/orchestrator.test.ts +341 -0
- package/src/application/agent/orchestrator.ts +628 -0
- package/src/application/agent/providers/claude-code/claude-argv.ts +119 -0
- package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +139 -0
- package/src/application/agent/providers/claude-code/fixtures/fake-claude.mjs +125 -0
- package/src/application/agent/providers/claude-code/index.ts +28 -0
- package/src/application/agent/providers/claude-code/mod-parity.ts +50 -0
- package/src/application/agent/providers/claude-code/permission-config.test.ts +221 -0
- package/src/application/agent/providers/claude-code/permission-config.ts +242 -0
- package/src/application/agent/providers/claude-code/provider.test.ts +378 -0
- package/src/application/agent/providers/claude-code/provider.ts +717 -0
- package/src/application/agent/providers/claude-code/resume-store.test.ts +161 -0
- package/src/application/agent/providers/claude-code/resume-store.ts +157 -0
- package/src/application/agent/providers/claude-code/stream-parser.ts +166 -0
- package/src/application/agent/test-fixture.ts +131 -0
- package/src/application/agent/workspace.test.ts +104 -0
- package/src/application/agent/workspace.ts +156 -0
- package/src/application/dispatcher.test.ts +89 -0
- package/src/application/dispatcher.ts +98 -0
- package/src/application/index.ts +5 -0
- package/src/application/registry.ts +24 -0
- package/src/application/version.ts +7 -0
- package/src/commands/clse.test.ts +181 -0
- package/src/commands/doctor.test.ts +29 -0
- package/src/commands/doctor.ts +78 -0
- package/src/commands/elicit.test.ts +111 -0
- package/src/commands/elicit.ts +188 -0
- package/src/commands/evolve.ts +209 -0
- package/src/commands/feature.test.ts +323 -0
- package/src/commands/feature.ts +405 -0
- package/src/commands/fix.test.ts +36 -0
- package/src/commands/fix.ts +69 -0
- package/src/commands/help.test.ts +33 -0
- package/src/commands/help.ts +35 -0
- package/src/commands/index.ts +21 -0
- package/src/commands/init.test.ts +65 -0
- package/src/commands/init.ts +103 -0
- package/src/commands/inspect.test.ts +57 -0
- package/src/commands/inspect.ts +73 -0
- package/src/commands/install.test.ts +61 -0
- package/src/commands/install.ts +375 -0
- package/src/commands/journal.ts +118 -0
- package/src/commands/memory.ts +96 -0
- package/src/commands/new.test.ts +44 -0
- package/src/commands/new.ts +77 -0
- package/src/commands/next.test.ts +241 -0
- package/src/commands/next.ts +124 -0
- package/src/commands/optimize.ts +30 -0
- package/src/commands/plugin-linker.test.ts +139 -0
- package/src/commands/plugin-linker.ts +196 -0
- package/src/commands/refactor.ts +34 -0
- package/src/commands/stack-commands.test.ts +67 -0
- package/src/commands/tier-c-conformance.test.ts +194 -0
- package/src/commands/types.ts +26 -0
- package/src/commands/validate-plan.test.ts +107 -0
- package/src/commands/validate-plan.ts +67 -0
- package/src/commands/validate-spec.test.ts +59 -0
- package/src/commands/validate-spec.ts +68 -0
- package/src/commands/verify.test.ts +117 -0
- package/src/commands/verify.ts +112 -0
- package/src/commands/version.test.ts +11 -0
- package/src/commands/version.ts +14 -0
- package/src/index.ts +30 -0
- package/src/output/formatter.ts +10 -0
- package/src/output/index.ts +2 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// packages/cli/src/application/agent/providers/claude-code/resume-store.test.ts
|
|
2
|
+
//
|
|
3
|
+
// ADR-0020 §6.8: resume tokens are credentials. These tests prove the
|
|
4
|
+
// cross-process resume store (PR4) keeps that contract:
|
|
5
|
+
// - the token is NEVER present in plaintext in the persisted file;
|
|
6
|
+
// - the ciphertext fails closed on tampering (AES-256-GCM auth);
|
|
7
|
+
// - key + record files carry restrictive permissions;
|
|
8
|
+
// - token verification is constant-time and rejects wrong tokens;
|
|
9
|
+
// - path traversal via executionId is refused.
|
|
10
|
+
|
|
11
|
+
import { promises as fs } from 'node:fs';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
15
|
+
import {
|
|
16
|
+
generateResumeToken,
|
|
17
|
+
loadSessionRecord,
|
|
18
|
+
saveSessionRecord,
|
|
19
|
+
verifyResumeToken,
|
|
20
|
+
} from './resume-store.js';
|
|
21
|
+
|
|
22
|
+
let projectRoot: string;
|
|
23
|
+
|
|
24
|
+
beforeAll(async () => {
|
|
25
|
+
projectRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-resume-store-'));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(async () => {
|
|
29
|
+
await fs.rm(projectRoot, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const EXECUTION_ID = 'exec-RUN-001-TASK-001-red-1';
|
|
33
|
+
|
|
34
|
+
describe('encrypted resume store', () => {
|
|
35
|
+
it('round-trips a session record', async () => {
|
|
36
|
+
const token = generateResumeToken();
|
|
37
|
+
await saveSessionRecord(projectRoot, {
|
|
38
|
+
executionId: EXECUTION_ID,
|
|
39
|
+
providerId: 'claude-code',
|
|
40
|
+
sessionId: 'sess-abc',
|
|
41
|
+
resumeToken: token,
|
|
42
|
+
createdAt: new Date().toISOString(),
|
|
43
|
+
});
|
|
44
|
+
const loaded = await loadSessionRecord(projectRoot, EXECUTION_ID);
|
|
45
|
+
expect(loaded?.sessionId).toBe('sess-abc');
|
|
46
|
+
expect(loaded?.resumeToken).toBe(token);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('never writes the token in plaintext (the file does not contain it)', async () => {
|
|
50
|
+
const token = generateResumeToken();
|
|
51
|
+
await saveSessionRecord(projectRoot, {
|
|
52
|
+
executionId: 'exec-RUN-002-TASK-001-red-1',
|
|
53
|
+
providerId: 'claude-code',
|
|
54
|
+
sessionId: 'sess-plain',
|
|
55
|
+
resumeToken: token,
|
|
56
|
+
createdAt: new Date().toISOString(),
|
|
57
|
+
});
|
|
58
|
+
const raw = await fs.readFile(
|
|
59
|
+
path.join(projectRoot, '.ai-kit', 'state', 'agent-executions', 'exec-RUN-002-TASK-001-red-1.session.enc'),
|
|
60
|
+
'utf8',
|
|
61
|
+
);
|
|
62
|
+
expect(raw).not.toContain(token);
|
|
63
|
+
expect(raw).not.toContain('sess-plain');
|
|
64
|
+
// Envelope shape only: v, iv, tag, ct — all base64 ciphertext parts.
|
|
65
|
+
const parsed = JSON.parse(raw) as Record<string, unknown>;
|
|
66
|
+
expect(Object.keys(parsed).sort()).toEqual(['ct', 'iv', 'tag', 'v']);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('fails closed on ciphertext tampering', async () => {
|
|
70
|
+
const token = generateResumeToken();
|
|
71
|
+
await saveSessionRecord(projectRoot, {
|
|
72
|
+
executionId: 'exec-RUN-003-TASK-001-red-1',
|
|
73
|
+
providerId: 'claude-code',
|
|
74
|
+
sessionId: 'sess-tamper',
|
|
75
|
+
resumeToken: token,
|
|
76
|
+
createdAt: new Date().toISOString(),
|
|
77
|
+
});
|
|
78
|
+
const target = path.join(
|
|
79
|
+
projectRoot,
|
|
80
|
+
'.ai-kit',
|
|
81
|
+
'state',
|
|
82
|
+
'agent-executions',
|
|
83
|
+
'exec-RUN-003-TASK-001-red-1.session.enc',
|
|
84
|
+
);
|
|
85
|
+
const envelope = JSON.parse(await fs.readFile(target, 'utf8')) as { ct: string };
|
|
86
|
+
const bytes = Buffer.from(envelope.ct, 'base64');
|
|
87
|
+
bytes[0] ^= 0xff; // flip one bit
|
|
88
|
+
await fs.writeFile(target, JSON.stringify({ ...envelope, ct: bytes.toString('base64') }));
|
|
89
|
+
await expect(loadSessionRecord(projectRoot, 'exec-RUN-003-TASK-001-red-1')).rejects.toThrow();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('creates the key with restrictive permissions and reuses it', async () => {
|
|
93
|
+
const keyFile = path.join(projectRoot, '.ai-kit', 'keys', 'agent-session.key');
|
|
94
|
+
const stat = await fs.stat(keyFile);
|
|
95
|
+
expect(stat.mode & 0o777).toBe(0o600);
|
|
96
|
+
const before = await fs.readFile(keyFile);
|
|
97
|
+
await saveSessionRecord(projectRoot, {
|
|
98
|
+
executionId: 'exec-RUN-004-TASK-001-red-1',
|
|
99
|
+
providerId: 'claude-code',
|
|
100
|
+
sessionId: 'sess-key',
|
|
101
|
+
resumeToken: generateResumeToken(),
|
|
102
|
+
createdAt: new Date().toISOString(),
|
|
103
|
+
});
|
|
104
|
+
const after = await fs.readFile(keyFile);
|
|
105
|
+
expect(before.equals(after)).toBe(true); // key is stable across saves
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('stores records with mode 0600', async () => {
|
|
109
|
+
const stat = await fs.stat(
|
|
110
|
+
path.join(
|
|
111
|
+
projectRoot,
|
|
112
|
+
'.ai-kit',
|
|
113
|
+
'state',
|
|
114
|
+
'agent-executions',
|
|
115
|
+
'exec-RUN-001-TASK-001-red-1.session.enc',
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
expect(stat.mode & 0o777).toBe(0o600);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('refuses invalid execution ids (path traversal)', async () => {
|
|
122
|
+
await expect(
|
|
123
|
+
saveSessionRecord(projectRoot, {
|
|
124
|
+
executionId: '../../escape',
|
|
125
|
+
providerId: 'claude-code',
|
|
126
|
+
sessionId: 'sess-x',
|
|
127
|
+
resumeToken: 't',
|
|
128
|
+
createdAt: new Date().toISOString(),
|
|
129
|
+
}),
|
|
130
|
+
).rejects.toThrow(/invalid execution id/);
|
|
131
|
+
await expect(loadSessionRecord(projectRoot, '../../escape')).resolves.toBeUndefined();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('returns undefined for a missing record', async () => {
|
|
135
|
+
await expect(loadSessionRecord(projectRoot, 'exec-RUN-999-TASK-001-red-1')).resolves.toBeUndefined();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('verifyResumeToken', () => {
|
|
140
|
+
it('accepts the matching token and rejects everything else', () => {
|
|
141
|
+
const record = {
|
|
142
|
+
executionId: EXECUTION_ID,
|
|
143
|
+
providerId: 'claude-code',
|
|
144
|
+
sessionId: 's',
|
|
145
|
+
resumeToken: generateResumeToken(),
|
|
146
|
+
createdAt: new Date().toISOString(),
|
|
147
|
+
};
|
|
148
|
+
expect(verifyResumeToken(record, record.resumeToken)).toBe(true);
|
|
149
|
+
expect(verifyResumeToken(record, generateResumeToken())).toBe(false);
|
|
150
|
+
expect(verifyResumeToken(record, '')).toBe(false);
|
|
151
|
+
expect(verifyResumeToken(record, record.resumeToken.slice(0, 10))).toBe(false);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('generates opaque url-safe 256-bit credentials', () => {
|
|
155
|
+
const tokens = new Set(Array.from({ length: 32 }, () => generateResumeToken()));
|
|
156
|
+
expect(tokens.size).toBe(32);
|
|
157
|
+
for (const token of tokens) {
|
|
158
|
+
expect(token).toMatch(/^[A-Za-z0-9_-]{40,}$/);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// packages/cli/src/application/agent/providers/claude-code/resume-store.ts
|
|
2
|
+
//
|
|
3
|
+
// Encrypted resume-session store (ADR-0019 PR4 — the cross-process resume
|
|
4
|
+
// item PR3 deferred; ADR-0020 §6.8).
|
|
5
|
+
//
|
|
6
|
+
// RESUME TOKENS ARE CREDENTIALS: they are never logged, never included in
|
|
7
|
+
// events, and NEVER PERSISTED UNENCRYPTED. This store keeps, per execution,
|
|
8
|
+
// the Claude Code session id together with the resume token the provider
|
|
9
|
+
// issued — encrypted at rest with AES-256-GCM under a per-project key file
|
|
10
|
+
// (mode 0600 in a 0700 directory). A second process (the next
|
|
11
|
+
// `kit feature <id> run` invocation) can therefore resume a provider
|
|
12
|
+
// session WITHOUT the token ever existing in plaintext on disk.
|
|
13
|
+
//
|
|
14
|
+
// Honest threat model (documented, not hidden): the key lives on the same
|
|
15
|
+
// machine as the ciphertext, so the store protects against (a) plaintext
|
|
16
|
+
// leakage through the state directory (commits, copies, backups, other
|
|
17
|
+
// users' reads) and (b) accidental exposure of "just a JSON file" — it does
|
|
18
|
+
// NOT protect against a compromised same-user process on the same machine;
|
|
19
|
+
// that class can simply read the key. An OS keychain would narrow that
|
|
20
|
+
// further and remains open as a follow-up; the kit stays zero-dependency
|
|
21
|
+
// (ADR-0007) and this store never weakens the existing in-memory contract:
|
|
22
|
+
// the GATEWAY still holds tokens in memory only.
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
createCipheriv,
|
|
26
|
+
createDecipheriv,
|
|
27
|
+
createHash,
|
|
28
|
+
randomBytes,
|
|
29
|
+
timingSafeEqual,
|
|
30
|
+
} from 'node:crypto';
|
|
31
|
+
import { promises as fs } from 'node:fs';
|
|
32
|
+
import path from 'node:path';
|
|
33
|
+
import { executionStoreDir, validateExecutionId } from '../../execution-store.js';
|
|
34
|
+
|
|
35
|
+
export interface StoredSessionRecord {
|
|
36
|
+
readonly executionId: string;
|
|
37
|
+
readonly providerId: string;
|
|
38
|
+
readonly sessionId: string;
|
|
39
|
+
/** The credential itself — only ever present in memory or encrypted on disk. */
|
|
40
|
+
readonly resumeToken: string;
|
|
41
|
+
readonly createdAt: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Envelope {
|
|
45
|
+
readonly v: 1;
|
|
46
|
+
readonly iv: string;
|
|
47
|
+
readonly tag: string;
|
|
48
|
+
readonly ct: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function keyPath(projectRoot: string): string {
|
|
52
|
+
return path.resolve(projectRoot, '.ai-kit', 'keys', 'agent-session.key');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function recordPath(projectRoot: string, executionId: string): string {
|
|
56
|
+
return path.join(executionStoreDir(projectRoot), `${executionId}.session.enc`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function loadOrCreateKey(projectRoot: string): Promise<Buffer> {
|
|
60
|
+
const target = keyPath(projectRoot);
|
|
61
|
+
try {
|
|
62
|
+
const existing = await fs.readFile(target);
|
|
63
|
+
if (existing.length === 32) return existing;
|
|
64
|
+
// A wrong-length key file is a corrupted security boundary: fail closed.
|
|
65
|
+
throw new Error(
|
|
66
|
+
`agent-session key at ${target} is malformed (${existing.length} bytes, expected 32)`,
|
|
67
|
+
);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
if ((e as NodeJS.ErrnoException).code !== 'ENOENT') throw e;
|
|
70
|
+
const fresh = randomBytes(32);
|
|
71
|
+
await fs.mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
72
|
+
await fs.writeFile(target, fresh, { mode: 0o600 });
|
|
73
|
+
return fresh;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function encrypt(key: Buffer, plaintext: string): Envelope {
|
|
78
|
+
const iv = randomBytes(12);
|
|
79
|
+
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
80
|
+
const ct = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
|
|
81
|
+
return {
|
|
82
|
+
v: 1,
|
|
83
|
+
iv: iv.toString('base64'),
|
|
84
|
+
tag: cipher.getAuthTag().toString('base64'),
|
|
85
|
+
ct: ct.toString('base64'),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function decrypt(key: Buffer, env: Envelope): string {
|
|
90
|
+
const decipher = createDecipheriv('aes-256-gcm', key, Buffer.from(env.iv, 'base64'));
|
|
91
|
+
decipher.setAuthTag(Buffer.from(env.tag, 'base64'));
|
|
92
|
+
return Buffer.concat([decipher.update(Buffer.from(env.ct, 'base64')), decipher.final()]).toString(
|
|
93
|
+
'utf8',
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Persist a session record, encrypted at rest. Refuses invalid execution ids (path traversal). */
|
|
98
|
+
export async function saveSessionRecord(
|
|
99
|
+
projectRoot: string,
|
|
100
|
+
record: StoredSessionRecord,
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
if (!validateExecutionId(record.executionId)) {
|
|
103
|
+
throw new Error(`invalid execution id '${record.executionId}' — refusing to store session record`);
|
|
104
|
+
}
|
|
105
|
+
const key = await loadOrCreateKey(projectRoot);
|
|
106
|
+
const envelope = encrypt(key, JSON.stringify(record));
|
|
107
|
+
const dir = executionStoreDir(projectRoot);
|
|
108
|
+
await fs.mkdir(dir, { recursive: true });
|
|
109
|
+
const target = recordPath(projectRoot, record.executionId);
|
|
110
|
+
const tmp = `${target}.tmp`;
|
|
111
|
+
await fs.writeFile(tmp, JSON.stringify(envelope) + '\n', { mode: 0o600 });
|
|
112
|
+
await fs.rename(tmp, target);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Load a session record. Returns undefined when absent. Fails closed (throws)
|
|
117
|
+
* on tampering — AES-GCM auth failure means the ciphertext or key changed,
|
|
118
|
+
* and a resumed session under an unverified record is unacceptable.
|
|
119
|
+
*/
|
|
120
|
+
export async function loadSessionRecord(
|
|
121
|
+
projectRoot: string,
|
|
122
|
+
executionId: string,
|
|
123
|
+
): Promise<StoredSessionRecord | undefined> {
|
|
124
|
+
if (!validateExecutionId(executionId)) return undefined;
|
|
125
|
+
let raw: string;
|
|
126
|
+
try {
|
|
127
|
+
raw = await fs.readFile(recordPath(projectRoot, executionId), 'utf8');
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if ((e as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
const key = await loadOrCreateKey(projectRoot);
|
|
133
|
+
const env = JSON.parse(raw) as Envelope;
|
|
134
|
+
const record = JSON.parse(decrypt(key, env)) as StoredSessionRecord;
|
|
135
|
+
if (record.executionId !== executionId) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`session record for '${executionId}' carries a mismatched execution id — refusing`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return record;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Constant-time token verification. Hash both sides first so a length
|
|
145
|
+
* difference does not leak through timingSafeEqual's equal-length
|
|
146
|
+
* requirement; a missing token still hashes (fail closed, no early exit).
|
|
147
|
+
*/
|
|
148
|
+
export function verifyResumeToken(record: StoredSessionRecord, presented: string): boolean {
|
|
149
|
+
const a = createHash('sha256').update(record.resumeToken, 'utf8').digest();
|
|
150
|
+
const b = createHash('sha256').update(typeof presented === 'string' ? presented : '', 'utf8').digest();
|
|
151
|
+
return timingSafeEqual(a, b);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Generate an opaque resume credential (256 bits, url-safe). */
|
|
155
|
+
export function generateResumeToken(): string {
|
|
156
|
+
return randomBytes(32).toString('base64url');
|
|
157
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// packages/cli/src/application/agent/providers/claude-code/stream-parser.ts
|
|
2
|
+
//
|
|
3
|
+
// Claude Code stream-json parser (ADR-0019 PR4).
|
|
4
|
+
//
|
|
5
|
+
// Feeds line-by-line: the provider reads the headless CLI's NDJSON stdout
|
|
6
|
+
// and hands each line here. The parser emits normalized OBSERVATIONS (init,
|
|
7
|
+
// text delta, tool use, tool result, final result) and never fabricates
|
|
8
|
+
// anything it did not see: unknown lines are counted and skipped, a missing
|
|
9
|
+
// final result is surfaced as `undefined` so the provider can report an
|
|
10
|
+
// honest `interrupted` instead of inventing a status.
|
|
11
|
+
//
|
|
12
|
+
// Tool-call capability inference uses the SAME mapping table as the
|
|
13
|
+
// permission derivation (permission-config.ts) — an event can only claim
|
|
14
|
+
// the capability that authorized the tool rule (ADR-0020 parity).
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
inferCapabilityFromToolUse,
|
|
18
|
+
type ClaudeCodePermissionConfig,
|
|
19
|
+
} from './permission-config.js';
|
|
20
|
+
|
|
21
|
+
/** What the parser saw on one line. Never re-ordered; emitted in arrival order. */
|
|
22
|
+
export type StreamObservation =
|
|
23
|
+
| { kind: 'init'; sessionId: string }
|
|
24
|
+
| { kind: 'text-delta'; content: string }
|
|
25
|
+
| { kind: 'tool-use'; toolCallId: string; toolName: string; input: unknown }
|
|
26
|
+
| { kind: 'tool-result'; toolCallId: string; status: 'succeeded' | 'failed' | 'denied' }
|
|
27
|
+
| { kind: 'result'; result: ClaudeFinalResult };
|
|
28
|
+
|
|
29
|
+
/** The normalized shape of Claude Code's final `result` object (honest subset). */
|
|
30
|
+
export interface ClaudeFinalResult {
|
|
31
|
+
readonly subtype: string;
|
|
32
|
+
readonly isError: boolean;
|
|
33
|
+
readonly text: string;
|
|
34
|
+
readonly sessionId: string | undefined;
|
|
35
|
+
readonly durationMs: number | undefined;
|
|
36
|
+
readonly numTurns: number | undefined;
|
|
37
|
+
readonly totalCostUsd: number | undefined;
|
|
38
|
+
readonly inputTokens: number | undefined;
|
|
39
|
+
readonly outputTokens: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class ClaudeStreamParser {
|
|
43
|
+
private readonly onObservation: (obs: StreamObservation) => void;
|
|
44
|
+
private sessionAnnounced = false;
|
|
45
|
+
private unknownLines = 0;
|
|
46
|
+
|
|
47
|
+
constructor(onObservation: (obs: StreamObservation) => void) {
|
|
48
|
+
this.onObservation = onObservation;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Feed one stdout line (already trimmed of the newline). */
|
|
52
|
+
consume(line: string): void {
|
|
53
|
+
if (line.length === 0) return;
|
|
54
|
+
let obj: unknown;
|
|
55
|
+
try {
|
|
56
|
+
obj = JSON.parse(line);
|
|
57
|
+
} catch {
|
|
58
|
+
this.unknownLines += 1;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!obj || typeof obj !== 'object') {
|
|
62
|
+
this.unknownLines += 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const rec = obj as Record<string, unknown>;
|
|
66
|
+
|
|
67
|
+
if (rec.type === 'system' && rec.subtype === 'init') {
|
|
68
|
+
const sessionId = typeof rec.session_id === 'string' ? rec.session_id : '';
|
|
69
|
+
if (sessionId) {
|
|
70
|
+
// Emit init once: providers replay it to late subscribers.
|
|
71
|
+
if (!this.sessionAnnounced) {
|
|
72
|
+
this.sessionAnnounced = true;
|
|
73
|
+
this.onObservation({ kind: 'init', sessionId });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (rec.type === 'assistant' || rec.type === 'user') {
|
|
80
|
+
const content = contentBlocks(rec.message);
|
|
81
|
+
if (rec.type === 'assistant') {
|
|
82
|
+
for (const block of content) {
|
|
83
|
+
if (block.type === 'text' && typeof block.text === 'string' && block.text.length > 0) {
|
|
84
|
+
this.onObservation({ kind: 'text-delta', content: block.text });
|
|
85
|
+
}
|
|
86
|
+
if (block.type === 'tool_use') {
|
|
87
|
+
const id = typeof block.id === 'string' ? block.id : '';
|
|
88
|
+
const name = typeof block.name === 'string' ? block.name : '';
|
|
89
|
+
if (id && name) {
|
|
90
|
+
this.onObservation({ kind: 'tool-use', toolCallId: id, toolName: name, input: block.input });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
for (const block of content) {
|
|
96
|
+
if (block.type === 'tool_result') {
|
|
97
|
+
const id = typeof block.tool_use_id === 'string' ? block.tool_use_id : '';
|
|
98
|
+
if (id) {
|
|
99
|
+
this.onObservation({
|
|
100
|
+
kind: 'tool-result',
|
|
101
|
+
toolCallId: id,
|
|
102
|
+
status: toolResultStatus(block),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (rec.type === 'result') {
|
|
112
|
+
this.onObservation({ kind: 'result', result: normalizeFinalResult(rec) });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.unknownLines += 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Honest count of lines the parser could not interpret. */
|
|
120
|
+
unknownLineCount(): number {
|
|
121
|
+
return this.unknownLines;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function contentBlocks(message: unknown): Array<Record<string, unknown>> {
|
|
126
|
+
if (!message || typeof message !== 'object') return [];
|
|
127
|
+
const content = (message as { content?: unknown }).content;
|
|
128
|
+
if (!Array.isArray(content)) return [];
|
|
129
|
+
return content.filter(
|
|
130
|
+
(b): b is Record<string, unknown> => !!b && typeof b === 'object' && typeof (b as { type?: unknown }).type === 'string',
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function toolResultStatus(block: Record<string, unknown>): 'succeeded' | 'failed' | 'denied' {
|
|
135
|
+
if (block.is_error === true) {
|
|
136
|
+
const text = typeof block.content === 'string' ? block.content : JSON.stringify(block.content ?? '');
|
|
137
|
+
if (/permission|not allowed|denied|unauthorized/i.test(text)) return 'denied';
|
|
138
|
+
return 'failed';
|
|
139
|
+
}
|
|
140
|
+
return 'succeeded';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function normalizeFinalResult(rec: Record<string, unknown>): ClaudeFinalResult {
|
|
144
|
+
const usage = (rec.usage && typeof rec.usage === 'object' ? rec.usage : {}) as Record<string, unknown>;
|
|
145
|
+
return {
|
|
146
|
+
subtype: typeof rec.subtype === 'string' ? rec.subtype : '',
|
|
147
|
+
isError: rec.is_error === true,
|
|
148
|
+
text: typeof rec.result === 'string' ? rec.result : '',
|
|
149
|
+
sessionId: typeof rec.session_id === 'string' ? rec.session_id : undefined,
|
|
150
|
+
durationMs: typeof rec.duration_ms === 'number' ? rec.duration_ms : undefined,
|
|
151
|
+
numTurns: typeof rec.num_turns === 'number' ? rec.num_turns : undefined,
|
|
152
|
+
totalCostUsd: typeof rec.total_cost_usd === 'number' ? rec.total_cost_usd : undefined,
|
|
153
|
+
inputTokens: typeof usage.input_tokens === 'number' ? usage.input_tokens : undefined,
|
|
154
|
+
outputTokens: typeof usage.output_tokens === 'number' ? usage.output_tokens : undefined,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Map tool-use observations to the capability that authorized them (may be undefined). */
|
|
159
|
+
export function capabilityOfToolUse(
|
|
160
|
+
obs: Extract<StreamObservation, { kind: 'tool-use' }>,
|
|
161
|
+
): ReturnType<typeof inferCapabilityFromToolUse> {
|
|
162
|
+
return inferCapabilityFromToolUse(obs.toolName, obs.input);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Used by tests to prove the parser never reads the permission config: parity is table-driven. */
|
|
166
|
+
export type { ClaudeCodePermissionConfig };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// packages/cli/src/application/agent/test-fixture.ts
|
|
2
|
+
//
|
|
3
|
+
// Git-backed fixture project for Mode 1 (orchestration) tests, PR3.
|
|
4
|
+
//
|
|
5
|
+
// Mode 1 executes in a git WORKTREE, so the fixture must be a real git
|
|
6
|
+
// repository with everything the workflow needs COMMITTED: the project
|
|
7
|
+
// profile, the specification, the plan, and a per-task verification
|
|
8
|
+
// script. The script fails with a REAL assertion failure until a
|
|
9
|
+
// per-task marker file exists — the orchestration tests' mock provider
|
|
10
|
+
// "implements" a task by creating that marker inside the workspace,
|
|
11
|
+
// exactly where a real provider's edits would land.
|
|
12
|
+
//
|
|
13
|
+
// This file is test support (matched by the architecture gate's test-file
|
|
14
|
+
// rule); it imports only core and node builtins.
|
|
15
|
+
|
|
16
|
+
import { execFile } from 'node:child_process';
|
|
17
|
+
import { promises as fs } from 'node:fs';
|
|
18
|
+
import os from 'node:os';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import { promisify } from 'node:util';
|
|
21
|
+
import { scaffoldSpecification, serializeProfileYaml } from '@agentic-sdlc-kit/core';
|
|
22
|
+
|
|
23
|
+
const exec = promisify(execFile);
|
|
24
|
+
|
|
25
|
+
export interface OrchestrationFixture {
|
|
26
|
+
readonly root: string;
|
|
27
|
+
readonly featureId: 'FEATURE-001';
|
|
28
|
+
readonly taskIds: readonly ['TASK-001', 'TASK-002'];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function git(args: readonly string[], cwd: string): Promise<string> {
|
|
32
|
+
return exec(
|
|
33
|
+
'git',
|
|
34
|
+
['-c', 'user.email=kit@example.com', '-c', 'user.name=kit-test', ...args],
|
|
35
|
+
{ cwd, timeout: 30_000 },
|
|
36
|
+
).then((r) => r.stdout);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Build the committed fixture repository. `check.js TASK-00N` fails with
|
|
41
|
+
* an assertion failure until `.done-TASK-00N` exists NEXT TO IT (it
|
|
42
|
+
* resolves the marker relative to the process cwd, so the same committed
|
|
43
|
+
* script works inside any worktree).
|
|
44
|
+
*/
|
|
45
|
+
export async function buildOrchestrationFixture(): Promise<OrchestrationFixture> {
|
|
46
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-mode1-orchestration-'));
|
|
47
|
+
|
|
48
|
+
await git(['init', '-b', 'main'], root);
|
|
49
|
+
|
|
50
|
+
// Only the RUNTIME directories are ignored; the project profile under
|
|
51
|
+
// .ai-kit/ is project configuration and must be COMMITTED so every
|
|
52
|
+
// worktree checkout has it (the same convention the kit documents).
|
|
53
|
+
// The journal (.ai-kit/journal/) is runtime data like state/ — it is
|
|
54
|
+
// kit bookkeeping, never part of the reviewable agent footprint.
|
|
55
|
+
await fs.writeFile(
|
|
56
|
+
path.join(root, '.gitignore'),
|
|
57
|
+
['.ai-kit/state/', '.ai-kit/journal/', '.ai-kit/worktrees/', 'node_modules/', ''].join('\n'),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
await fs.writeFile(
|
|
61
|
+
path.join(root, 'check.js'),
|
|
62
|
+
[
|
|
63
|
+
'const task = process.argv[2];',
|
|
64
|
+
'if (!task) { console.error("AssertionError: missing task argument"); process.exit(1); }',
|
|
65
|
+
'const fs = require("node:fs");',
|
|
66
|
+
'if (!fs.existsSync(".done-" + task)) {',
|
|
67
|
+
' console.error("AssertionError: expected target for " + task + " to be implemented (marker .done-" + task + " missing)");',
|
|
68
|
+
' process.exit(1);',
|
|
69
|
+
'}',
|
|
70
|
+
'process.exit(0);',
|
|
71
|
+
].join('\n') + '\n',
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
await fs.mkdir(path.join(root, '.ai-kit'), { recursive: true });
|
|
75
|
+
await fs.writeFile(
|
|
76
|
+
path.join(root, '.ai-kit', 'project.yml'),
|
|
77
|
+
serializeProfileYaml({
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
name: 'mode1-fixture-app',
|
|
80
|
+
stack: ['node-typescript'],
|
|
81
|
+
commands: {
|
|
82
|
+
test: [
|
|
83
|
+
['node', 'check.js', 'TASK-001'],
|
|
84
|
+
['node', 'check.js', 'TASK-002'],
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
await scaffoldSpecification({
|
|
91
|
+
id: 'FEATURE-001',
|
|
92
|
+
title: 'Mode 1 Fixture',
|
|
93
|
+
targetDir: path.join(root, 'docs', 'specifications', 'features'),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const planDir = path.join(root, 'docs', 'plans', 'FEATURE-001');
|
|
97
|
+
await fs.mkdir(planDir, { recursive: true });
|
|
98
|
+
const taskIds = ['TASK-001', 'TASK-002'] as const;
|
|
99
|
+
await fs.writeFile(
|
|
100
|
+
path.join(planDir, 'plan.json'),
|
|
101
|
+
JSON.stringify(
|
|
102
|
+
{
|
|
103
|
+
featureId: 'FEATURE-001',
|
|
104
|
+
tasks: taskIds.map((id) => ({
|
|
105
|
+
id,
|
|
106
|
+
description: `Implement ${id} of the Mode 1 fixture`,
|
|
107
|
+
acceptanceCriteria: [`${id} target implemented`, 'no regressions'],
|
|
108
|
+
verification: { command: ['node', 'check.js', id], expectedStatus: 'passed' },
|
|
109
|
+
dependencies: [],
|
|
110
|
+
likelyFiles: [`src/${id.toLowerCase()}.ts`],
|
|
111
|
+
estimatedScope: 's',
|
|
112
|
+
risk: 'low',
|
|
113
|
+
})),
|
|
114
|
+
edges: [],
|
|
115
|
+
verticalSlices: taskIds.map((id) => [id]),
|
|
116
|
+
},
|
|
117
|
+
null,
|
|
118
|
+
2,
|
|
119
|
+
) + '\n',
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
await git(['add', '.'], root);
|
|
123
|
+
await git(['commit', '-m', 'fixture: mode 1 orchestration baseline'], root);
|
|
124
|
+
|
|
125
|
+
return { root, featureId: 'FEATURE-001', taskIds };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The marker path a "green" agent creates for a task inside a workspace. */
|
|
129
|
+
export function markerPath(workspaceRoot: string, taskId: string): string {
|
|
130
|
+
return path.join(workspaceRoot, `.done-${taskId}`);
|
|
131
|
+
}
|