@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,323 @@
|
|
|
1
|
+
// packages/cli/src/commands/feature.test.ts
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
scaffoldSpecification,
|
|
8
|
+
serializeProfileYaml,
|
|
9
|
+
} from '@agentic-sdlc-kit/core';
|
|
10
|
+
import { MockAgentProvider } from '@agentic-sdlc-kit/testing';
|
|
11
|
+
import type { AgentProvider } from '@agentic-sdlc-kit/contracts';
|
|
12
|
+
import { buildOrchestrationFixture } from '../application/agent/test-fixture.js';
|
|
13
|
+
import { createFeatureCommand, featureCommand } from './feature.js';
|
|
14
|
+
import type { CommandContext } from './types.js';
|
|
15
|
+
|
|
16
|
+
const makeCtx = (
|
|
17
|
+
argv: string[],
|
|
18
|
+
cwd: string,
|
|
19
|
+
): CommandContext & { out: string[]; err: string[] } => {
|
|
20
|
+
const out: string[] = [];
|
|
21
|
+
const err: string[] = [];
|
|
22
|
+
return {
|
|
23
|
+
argv,
|
|
24
|
+
cwd,
|
|
25
|
+
stdout: (s) => void out.push(s),
|
|
26
|
+
stderr: (s) => void err.push(s),
|
|
27
|
+
out,
|
|
28
|
+
err,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
async function setupProject(): Promise<{ root: string; marker: string }> {
|
|
33
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-feature-'));
|
|
34
|
+
const marker = path.join(tmp, '.done');
|
|
35
|
+
|
|
36
|
+
await fs.mkdir(path.join(tmp, '.git'), { recursive: true });
|
|
37
|
+
await fs.writeFile(path.join(tmp, '.git', 'HEAD'), 'ref: refs/heads/main\n');
|
|
38
|
+
|
|
39
|
+
// Test command fails with a real assertion-style failure until the agent
|
|
40
|
+
// "implements" (creates the marker). The failure output must look like a
|
|
41
|
+
// test assertion failure: only classification 'assertion' establishes Red.
|
|
42
|
+
const script = path.join(tmp, 'check.js');
|
|
43
|
+
await fs.writeFile(
|
|
44
|
+
script,
|
|
45
|
+
[
|
|
46
|
+
'const fs = require("node:fs");',
|
|
47
|
+
`const marker = ${JSON.stringify(marker)};`,
|
|
48
|
+
'if (!fs.existsSync(marker)) {',
|
|
49
|
+
' console.error("AssertionError: expected marker to exist (target not implemented)");',
|
|
50
|
+
' process.exit(1);',
|
|
51
|
+
'}',
|
|
52
|
+
'process.exit(0);',
|
|
53
|
+
].join('\n'),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const aiKit = path.join(tmp, '.ai-kit');
|
|
57
|
+
await fs.mkdir(aiKit, { recursive: true });
|
|
58
|
+
await fs.writeFile(
|
|
59
|
+
path.join(aiKit, 'project.yml'),
|
|
60
|
+
serializeProfileYaml({
|
|
61
|
+
schemaVersion: 1,
|
|
62
|
+
name: 'cli-feature-app',
|
|
63
|
+
stack: ['node-typescript'],
|
|
64
|
+
commands: { test: [['node', script]] },
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
await scaffoldSpecification({
|
|
69
|
+
id: 'FEATURE-001',
|
|
70
|
+
title: 'RBAC System',
|
|
71
|
+
targetDir: path.join(tmp, 'docs', 'specifications', 'features'),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const planDir = path.join(tmp, 'docs', 'plans', 'FEATURE-001');
|
|
75
|
+
await fs.mkdir(planDir, { recursive: true });
|
|
76
|
+
await fs.writeFile(
|
|
77
|
+
path.join(planDir, 'plan.json'),
|
|
78
|
+
JSON.stringify(
|
|
79
|
+
{
|
|
80
|
+
featureId: 'FEATURE-001',
|
|
81
|
+
tasks: [
|
|
82
|
+
{
|
|
83
|
+
id: 'TASK-001',
|
|
84
|
+
description: 'Implement role models',
|
|
85
|
+
acceptanceCriteria: ['Roles exist'],
|
|
86
|
+
verification: { command: ['node', script], expectedStatus: 'passed' },
|
|
87
|
+
dependencies: [],
|
|
88
|
+
likelyFiles: ['src/roles.ts'],
|
|
89
|
+
estimatedScope: 's',
|
|
90
|
+
risk: 'low',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
edges: [],
|
|
94
|
+
verticalSlices: [['TASK-001']],
|
|
95
|
+
},
|
|
96
|
+
null,
|
|
97
|
+
2,
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return { root: tmp, marker };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
describe('featureCommand', () => {
|
|
105
|
+
it('shows help when --help is passed', async () => {
|
|
106
|
+
const ctx = makeCtx(['--help'], '/');
|
|
107
|
+
const r = await featureCommand.run(ctx);
|
|
108
|
+
expect(r.exitCode).toBe(0);
|
|
109
|
+
expect(ctx.out[0]).toContain('Usage: kit feature');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('fails if feature ID is missing', async () => {
|
|
113
|
+
const ctx = makeCtx([], '/');
|
|
114
|
+
const r = await featureCommand.run(ctx);
|
|
115
|
+
expect(r.exitCode).toBe(1);
|
|
116
|
+
expect(ctx.err[0]).toContain('missing required feature identifier');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('drives the full TDD protocol across invocations', async () => {
|
|
120
|
+
const project = await setupProject();
|
|
121
|
+
try {
|
|
122
|
+
// start
|
|
123
|
+
const startCtx = makeCtx(['FEATURE-001', 'start'], project.root);
|
|
124
|
+
const start = await featureCommand.run(startCtx);
|
|
125
|
+
expect(start.exitCode).toBe(0);
|
|
126
|
+
expect(startCtx.out[0]).toContain('TASK-001');
|
|
127
|
+
expect(startCtx.out[0]).toContain('red');
|
|
128
|
+
|
|
129
|
+
// red: verification must fail before implementation
|
|
130
|
+
const redCtx = makeCtx(['FEATURE-001', 'red', 'TASK-001'], project.root);
|
|
131
|
+
const red = await featureCommand.run(redCtx);
|
|
132
|
+
expect(red.exitCode).toBe(0);
|
|
133
|
+
expect(redCtx.out[0]).toContain('green');
|
|
134
|
+
|
|
135
|
+
// green before implementing: blocked, stays in green phase
|
|
136
|
+
const earlyCtx = makeCtx(['FEATURE-001', 'green', 'TASK-001'], project.root);
|
|
137
|
+
const early = await featureCommand.run(earlyCtx);
|
|
138
|
+
expect(early.exitCode).toBe(1);
|
|
139
|
+
|
|
140
|
+
// agent implements, then green and refactor
|
|
141
|
+
await fs.writeFile(project.marker, '');
|
|
142
|
+
const greenCtx = makeCtx(['FEATURE-001', 'green', 'TASK-001'], project.root);
|
|
143
|
+
const green = await featureCommand.run(greenCtx);
|
|
144
|
+
expect(green.exitCode).toBe(0);
|
|
145
|
+
expect(greenCtx.out[0]).toContain('refactor');
|
|
146
|
+
|
|
147
|
+
const refactorCtx = makeCtx(['FEATURE-001', 'refactor', 'TASK-001'], project.root);
|
|
148
|
+
const refactor = await featureCommand.run(refactorCtx);
|
|
149
|
+
expect(refactor.exitCode).toBe(0);
|
|
150
|
+
expect(refactorCtx.out[0]).toContain('completed');
|
|
151
|
+
|
|
152
|
+
// verify: evidence chain complete
|
|
153
|
+
const verifyCtx = makeCtx(['FEATURE-001', 'verify'], project.root);
|
|
154
|
+
const verify = await featureCommand.run(verifyCtx);
|
|
155
|
+
expect(verify.exitCode).toBe(0);
|
|
156
|
+
expect(verifyCtx.out[0]).toContain('PASSED');
|
|
157
|
+
} finally {
|
|
158
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('rejects phases invoked out of order', async () => {
|
|
163
|
+
const project = await setupProject();
|
|
164
|
+
try {
|
|
165
|
+
await featureCommand.run(makeCtx(['FEATURE-001', 'start'], project.root));
|
|
166
|
+
const ctx = makeCtx(['FEATURE-001', 'green', 'TASK-001'], project.root);
|
|
167
|
+
const r = await featureCommand.run(ctx);
|
|
168
|
+
expect(r.exitCode).toBe(1);
|
|
169
|
+
expect(ctx.err[0]).toContain('Phase mismatch');
|
|
170
|
+
} finally {
|
|
171
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('featureCommand run (Mode 1, PR3+PR4)', () => {
|
|
177
|
+
// A deterministic stand-in for a registered-but-unavailable provider: PR4
|
|
178
|
+
// gates `run` on the provider's healthCheck (exit 3, honest message,
|
|
179
|
+
// never a silent fallback) before anything durable happens.
|
|
180
|
+
const unavailableClaudeCode = (): AgentProvider => ({
|
|
181
|
+
id: 'claude-code',
|
|
182
|
+
async capabilities() {
|
|
183
|
+
return {
|
|
184
|
+
capabilities: ['repository.read', 'repository.write', 'process.test'],
|
|
185
|
+
budgetEnforcement: {
|
|
186
|
+
maxDurationMs: 'gateway-enforced',
|
|
187
|
+
maxToolCalls: 'gateway-enforced',
|
|
188
|
+
maxInputTokens: 'best-effort',
|
|
189
|
+
maxOutputTokens: 'best-effort',
|
|
190
|
+
maxTotalTokens: 'best-effort',
|
|
191
|
+
maxEstimatedCost: 'best-effort',
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
async healthCheck() {
|
|
196
|
+
return { available: false, message: 'stub: claude CLI not installed on this machine' };
|
|
197
|
+
},
|
|
198
|
+
async start() {
|
|
199
|
+
throw new Error('unavailable provider must never be started');
|
|
200
|
+
},
|
|
201
|
+
async resume() {
|
|
202
|
+
throw new Error('unavailable provider must never be resumed');
|
|
203
|
+
},
|
|
204
|
+
async cancel() {},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('is blocked (exit 3) when the default claude-code provider is unavailable — AGENT_PROVIDER_UNAVAILABLE, never a silent fallback', async () => {
|
|
208
|
+
const project = await setupProject();
|
|
209
|
+
try {
|
|
210
|
+
const command = createFeatureCommand({ agentProviders: [unavailableClaudeCode()] });
|
|
211
|
+
const ctx = makeCtx(['FEATURE-001', 'run'], project.root);
|
|
212
|
+
const r = await command.run(ctx);
|
|
213
|
+
expect(r.exitCode).toBe(3);
|
|
214
|
+
expect(ctx.err[0]).toContain('AGENT_PROVIDER_UNAVAILABLE');
|
|
215
|
+
expect(ctx.err[0]).toContain('claude-code');
|
|
216
|
+
expect(ctx.err[0]).toContain('will not fall back');
|
|
217
|
+
} finally {
|
|
218
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('is blocked (exit 3) when --provider names an unregistered provider', async () => {
|
|
223
|
+
const project = await setupProject();
|
|
224
|
+
try {
|
|
225
|
+
// The shipped default registers claude-code (PR4); 'codex' is not it.
|
|
226
|
+
const ctx = makeCtx(['FEATURE-001', 'run', '--provider', 'codex'], project.root);
|
|
227
|
+
const r = await featureCommand.run(ctx);
|
|
228
|
+
expect(r.exitCode).toBe(3);
|
|
229
|
+
expect(ctx.err[0]).toContain('No agent provider');
|
|
230
|
+
} finally {
|
|
231
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('is blocked (exit 3) for `run` in a build that registers NO providers (PR3 contract preserved)', async () => {
|
|
236
|
+
const project = await setupProject();
|
|
237
|
+
try {
|
|
238
|
+
const command = createFeatureCommand({ agentProviders: [] });
|
|
239
|
+
const ctx = makeCtx(['FEATURE-001', 'run'], project.root);
|
|
240
|
+
const r = await command.run(ctx);
|
|
241
|
+
expect(r.exitCode).toBe(3);
|
|
242
|
+
expect(ctx.err[0]).toContain("No agent provider 'claude-code' is configured");
|
|
243
|
+
expect(ctx.err[0]).toContain('will not fall back');
|
|
244
|
+
} finally {
|
|
245
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('orchestrates the full lifecycle through an injected mock provider and exits 0', async () => {
|
|
250
|
+
const fixture = await buildOrchestrationFixture();
|
|
251
|
+
try {
|
|
252
|
+
const command = createFeatureCommand({
|
|
253
|
+
agentProviders: [
|
|
254
|
+
new MockAgentProvider({
|
|
255
|
+
performWork: async (request) => {
|
|
256
|
+
if (request.instructions.includes('Phase: green')) {
|
|
257
|
+
await fs.writeFile(
|
|
258
|
+
path.join(request.workspace.rootPath, `.done-${request.taskId}`),
|
|
259
|
+
'implemented\n',
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
}),
|
|
264
|
+
],
|
|
265
|
+
});
|
|
266
|
+
const ctx = makeCtx(['FEATURE-001', 'run', '--provider', 'mock'], fixture.root);
|
|
267
|
+
const r = await command.run(ctx);
|
|
268
|
+
expect(r.exitCode).toBe(0);
|
|
269
|
+
const joined = ctx.out.join('\n');
|
|
270
|
+
expect(joined).toContain('Mode 1 run RUN-001');
|
|
271
|
+
expect(joined).toContain('TASK-001 red: evidence accepted');
|
|
272
|
+
expect(joined).toContain('Feature Orchestration: FEATURE-001');
|
|
273
|
+
expect(joined).toContain('COMPLETED');
|
|
274
|
+
} finally {
|
|
275
|
+
await fs.rm(fixture.root, { recursive: true, force: true });
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('reports a lying agent with exit 1 (the evidence gate rejects)', async () => {
|
|
280
|
+
const fixture = await buildOrchestrationFixture();
|
|
281
|
+
try {
|
|
282
|
+
const command = createFeatureCommand({
|
|
283
|
+
agentProviders: [new MockAgentProvider()],
|
|
284
|
+
});
|
|
285
|
+
const ctx = makeCtx(['FEATURE-001', 'run', '--provider', 'mock'], fixture.root);
|
|
286
|
+
const r = await command.run(ctx);
|
|
287
|
+
expect(r.exitCode).toBe(1);
|
|
288
|
+
expect(ctx.out.join('\n')).toContain('PHASE_GATE_REJECTED');
|
|
289
|
+
} finally {
|
|
290
|
+
await fs.rm(fixture.root, { recursive: true, force: true });
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('emits machine-readable report JSON with --json', async () => {
|
|
295
|
+
const fixture = await buildOrchestrationFixture();
|
|
296
|
+
try {
|
|
297
|
+
const command = createFeatureCommand({
|
|
298
|
+
agentProviders: [
|
|
299
|
+
new MockAgentProvider({
|
|
300
|
+
performWork: async (request) => {
|
|
301
|
+
if (request.instructions.includes('Phase: green')) {
|
|
302
|
+
await fs.writeFile(
|
|
303
|
+
path.join(request.workspace.rootPath, `.done-${request.taskId}`),
|
|
304
|
+
'implemented\n',
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
}),
|
|
309
|
+
],
|
|
310
|
+
});
|
|
311
|
+
const ctx = makeCtx(['FEATURE-001', 'run', '--provider', 'mock', '--json'], fixture.root);
|
|
312
|
+
const r = await command.run(ctx);
|
|
313
|
+
expect(r.exitCode).toBe(0);
|
|
314
|
+
const report = JSON.parse(ctx.out[ctx.out.length - 1]);
|
|
315
|
+
expect(report.status).toBe('completed');
|
|
316
|
+
expect(report.runId).toBe('RUN-001');
|
|
317
|
+
expect(report.executions).toHaveLength(6);
|
|
318
|
+
expect(report.workspace.branch).toBe('kit/RUN-001');
|
|
319
|
+
} finally {
|
|
320
|
+
await fs.rm(fixture.root, { recursive: true, force: true });
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|