@agentic-sdlc-kit/cli 0.9.1 → 1.0.1
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/dist/application/agent/orchestrator.d.ts.map +1 -1
- package/dist/application/agent/orchestrator.js +4 -3
- package/dist/application/agent/orchestrator.js.map +1 -1
- package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -1
- package/dist/application/agent/providers/claude-code/permission-config.js +8 -2
- package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -1
- package/dist/application/agent-tools/dispatch.d.ts +12 -0
- package/dist/application/agent-tools/dispatch.d.ts.map +1 -0
- package/dist/application/agent-tools/dispatch.js +189 -0
- package/dist/application/agent-tools/dispatch.js.map +1 -0
- package/dist/application/agent-tools/mcp-server.d.ts +10 -0
- package/dist/application/agent-tools/mcp-server.d.ts.map +1 -0
- package/dist/application/agent-tools/mcp-server.js +100 -0
- package/dist/application/agent-tools/mcp-server.js.map +1 -0
- package/dist/application/bench/harness.d.ts +5 -0
- package/dist/application/bench/harness.d.ts.map +1 -0
- package/dist/application/bench/harness.js +82 -0
- package/dist/application/bench/harness.js.map +1 -0
- package/dist/application/dispatcher.d.ts.map +1 -1
- package/dist/application/dispatcher.js +24 -0
- package/dist/application/dispatcher.js.map +1 -1
- package/dist/application/rule-adapters/ast-grep.d.ts +3 -0
- package/dist/application/rule-adapters/ast-grep.d.ts.map +1 -0
- package/dist/application/rule-adapters/ast-grep.js +112 -0
- package/dist/application/rule-adapters/ast-grep.js.map +1 -0
- package/dist/application/rule-adapters/index.d.ts +3 -0
- package/dist/application/rule-adapters/index.d.ts.map +1 -0
- package/dist/application/rule-adapters/index.js +15 -0
- package/dist/application/rule-adapters/index.js.map +1 -0
- package/dist/application/rule-adapters/linter.d.ts +31 -0
- package/dist/application/rule-adapters/linter.d.ts.map +1 -0
- package/dist/application/rule-adapters/linter.js +242 -0
- package/dist/application/rule-adapters/linter.js.map +1 -0
- package/dist/application/rule-adapters/process.d.ts +10 -0
- package/dist/application/rule-adapters/process.d.ts.map +1 -0
- package/dist/application/rule-adapters/process.js +38 -0
- package/dist/application/rule-adapters/process.js.map +1 -0
- package/dist/application/version.d.ts +1 -1
- package/dist/application/version.d.ts.map +1 -1
- package/dist/application/version.js +7 -4
- package/dist/application/version.js.map +1 -1
- package/dist/commands/bench.d.ts +3 -0
- package/dist/commands/bench.d.ts.map +1 -0
- package/dist/commands/bench.js +75 -0
- package/dist/commands/bench.js.map +1 -0
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +56 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +38 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/feature.d.ts.map +1 -1
- package/dist/commands/feature.js +48 -6
- package/dist/commands/feature.js.map +1 -1
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +8 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +7 -4
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/knowledge.d.ts +3 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +59 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/commands/learning.d.ts +3 -0
- package/dist/commands/learning.d.ts.map +1 -0
- package/dist/commands/learning.js +126 -0
- package/dist/commands/learning.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +26 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +3 -1
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/onboard.d.ts +5 -0
- package/dist/commands/onboard.d.ts.map +1 -0
- package/dist/commands/onboard.js +137 -0
- package/dist/commands/onboard.js.map +1 -0
- package/dist/commands/routing.d.ts +3 -0
- package/dist/commands/routing.d.ts.map +1 -0
- package/dist/commands/routing.js +107 -0
- package/dist/commands/routing.js.map +1 -0
- package/dist/commands/rules-format.d.ts +4 -0
- package/dist/commands/rules-format.d.ts.map +1 -0
- package/dist/commands/rules-format.js +16 -0
- package/dist/commands/rules-format.js.map +1 -0
- package/dist/commands/rules.d.ts +3 -0
- package/dist/commands/rules.d.ts.map +1 -0
- package/dist/commands/rules.js +270 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +78 -6
- package/dist/commands/verify.js.map +1 -1
- package/package.json +11 -5
- package/src/application/agent/orchestrator.test.ts +39 -0
- package/src/application/agent/orchestrator.ts +6 -0
- package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +1 -1
- package/src/application/agent/providers/claude-code/permission-config.test.ts +4 -4
- package/src/application/agent/providers/claude-code/permission-config.ts +8 -2
- package/src/application/agent/providers/claude-code/provider.test.ts +2 -2
- package/src/application/agent-tools/dispatch.test.ts +160 -0
- package/src/application/agent-tools/dispatch.ts +227 -0
- package/src/application/agent-tools/mcp-server.test.ts +86 -0
- package/src/application/agent-tools/mcp-server.ts +126 -0
- package/src/application/bench/harness.ts +95 -0
- package/src/application/dispatcher.test.ts +4 -3
- package/src/application/dispatcher.ts +16 -0
- package/src/application/rule-adapters/adapters.test.ts +224 -0
- package/src/application/rule-adapters/ast-grep.ts +126 -0
- package/src/application/rule-adapters/index.ts +16 -0
- package/src/application/rule-adapters/linter-paths.test.ts +95 -0
- package/src/application/rule-adapters/linter.ts +263 -0
- package/src/application/rule-adapters/process.ts +48 -0
- package/src/application/version.ts +9 -4
- package/src/commands/bench.test.ts +136 -0
- package/src/commands/bench.ts +74 -0
- package/src/commands/context.test.ts +47 -0
- package/src/commands/context.ts +59 -0
- package/src/commands/doctor-isolation.test.ts +76 -0
- package/src/commands/doctor.test.ts +2 -1
- package/src/commands/doctor.ts +36 -0
- package/src/commands/feature.test.ts +36 -4
- package/src/commands/feature.ts +71 -8
- package/src/commands/index.ts +8 -0
- package/src/commands/install.ts +7 -4
- package/src/commands/knowledge.test.ts +39 -0
- package/src/commands/knowledge.ts +63 -0
- package/src/commands/learning.test.ts +104 -0
- package/src/commands/learning.ts +134 -0
- package/src/commands/mcp.ts +30 -0
- package/src/commands/next.ts +3 -1
- package/src/commands/onboard.test.ts +83 -0
- package/src/commands/onboard.ts +146 -0
- package/src/commands/routing.test.ts +64 -0
- package/src/commands/routing.ts +107 -0
- package/src/commands/rules-format.ts +22 -0
- package/src/commands/rules.test.ts +153 -0
- package/src/commands/rules.ts +286 -0
- package/src/commands/verify.test.ts +115 -0
- package/src/commands/verify.ts +95 -7
- package/src/commands/version.test.ts +9 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// packages/cli/src/commands/context.test.ts
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
6
|
+
import { contextCommand } from './context.js';
|
|
7
|
+
import type { CommandContext } from './types.js';
|
|
8
|
+
|
|
9
|
+
function ctx(argv: string[], cwd: string): CommandContext & { out: string[]; err: string[] } {
|
|
10
|
+
const out: string[] = [];
|
|
11
|
+
const err: string[] = [];
|
|
12
|
+
return { argv, cwd, stdout: (s) => void out.push(s), stderr: (s) => void err.push(s), out, err };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let root: string;
|
|
16
|
+
beforeEach(async () => {
|
|
17
|
+
root = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-context-'));
|
|
18
|
+
});
|
|
19
|
+
afterEach(async () => {
|
|
20
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('kit context', () => {
|
|
24
|
+
it('prints the human summary and says when no files were given', async () => {
|
|
25
|
+
const c = ctx([], root);
|
|
26
|
+
expect((await contextCommand.run(c)).exitCode).toBe(0);
|
|
27
|
+
const text = c.out.join('');
|
|
28
|
+
expect(text).toContain('Constitution: absent');
|
|
29
|
+
expect(text).toContain('Files: none given');
|
|
30
|
+
expect(text).toContain('not evaluated');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('--json emits a contract-valid context for the given files', async () => {
|
|
34
|
+
const c = ctx(['--json', '--files', 'packages/core/src/a.ts'], root);
|
|
35
|
+
expect((await contextCommand.run(c)).exitCode).toBe(0);
|
|
36
|
+
const parsed = JSON.parse(c.out.join(''));
|
|
37
|
+
expect(parsed.schemaVersion).toBe(1);
|
|
38
|
+
expect(parsed.files).toEqual(['packages/core/src/a.ts']);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('reports an invalid profile as an error, not an empty context', async () => {
|
|
42
|
+
await fs.mkdir(path.join(root, '.ai-kit'), { recursive: true });
|
|
43
|
+
await fs.writeFile(path.join(root, '.ai-kit', 'project.yml'), 'schemaVersion: 1\nbogus: true\n');
|
|
44
|
+
const c = ctx([], root);
|
|
45
|
+
expect((await contextCommand.run(c)).exitCode).toBe(1);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// packages/cli/src/commands/context.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit context [--files a,b] [--stack s,t] [--json]` (platform roadmap Phase 3).
|
|
4
|
+
// Read-only. Prints the task-scoped project context that agentic-mods and other
|
|
5
|
+
// hosts consume. Without --files it reports the project but no task-scoped rules.
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { projectContext } from '@agentic-sdlc-kit/core';
|
|
9
|
+
import type { ProjectContext } from '@agentic-sdlc-kit/contracts';
|
|
10
|
+
import { ProjectContextSchema } from '@agentic-sdlc-kit/contracts';
|
|
11
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
12
|
+
import { constitutionAdapters } from '../application/rule-adapters/index.js';
|
|
13
|
+
|
|
14
|
+
function flagList(argv: readonly string[], name: string): string[] | undefined {
|
|
15
|
+
const i = argv.indexOf(name);
|
|
16
|
+
if (i < 0) return undefined;
|
|
17
|
+
return (argv[i + 1] ?? '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function renderContext(c: ProjectContext): string {
|
|
21
|
+
const gate = c.constitution.gate ?? 'not evaluated';
|
|
22
|
+
const verification = c.verification ? `${c.verification.status} (${c.verification.runId})` : 'none recorded';
|
|
23
|
+
const lines = [
|
|
24
|
+
`Project: ${c.project.name}`,
|
|
25
|
+
`Stacks: ${c.project.stacks.join(', ') || 'none declared'}`,
|
|
26
|
+
`Constitution: ${c.constitution.present ? `${c.constitution.ruleCount} rule(s)` : 'absent'}, required: ${c.constitution.required}, gate: ${gate}`,
|
|
27
|
+
`Last verify: ${verification}`,
|
|
28
|
+
`Files: ${c.files.length > 0 ? c.files.join(', ') : 'none given'}`,
|
|
29
|
+
'',
|
|
30
|
+
`Applicable rules (${c.rules.length}):`,
|
|
31
|
+
...c.rules.map((r) => ` - ${r.id} [${r.mode}] ${r.statement}`),
|
|
32
|
+
`Patterns: ${c.patterns.length} Decision records: ${c.decisions.length}`,
|
|
33
|
+
];
|
|
34
|
+
for (const note of c.notes) lines.push(`note: ${note}`);
|
|
35
|
+
return `${lines.join('\n')}\n`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const contextCommand: Command = {
|
|
39
|
+
name: 'context',
|
|
40
|
+
summary: 'Show task-scoped project context for the given files (read-only).',
|
|
41
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
42
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
43
|
+
ctx.stdout('Usage: kit context [--files a,b] [--stack s,t] [--json]\n');
|
|
44
|
+
return { exitCode: 0 };
|
|
45
|
+
}
|
|
46
|
+
const result = await projectContext(path.resolve(ctx.cwd), {
|
|
47
|
+
files: flagList(ctx.argv, '--files'),
|
|
48
|
+
stacks: flagList(ctx.argv, '--stack'),
|
|
49
|
+
adapters: constitutionAdapters(),
|
|
50
|
+
});
|
|
51
|
+
if (!result.ok) {
|
|
52
|
+
ctx.stderr(`kit context: ${result.error.message}\n`);
|
|
53
|
+
return { exitCode: 1, message: result.error.message };
|
|
54
|
+
}
|
|
55
|
+
const payload = ProjectContextSchema.parse(result.value);
|
|
56
|
+
ctx.stdout(ctx.argv.includes('--json') ? `${JSON.stringify(payload, null, 2)}\n` : renderContext(payload));
|
|
57
|
+
return { exitCode: 0 };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// kit doctor and the execution profile (roadmap Phase 8): a required profile fails when its runtime
|
|
2
|
+
// cannot be reached; a project without a profile is unaffected.
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
7
|
+
import { doctorCommand } from './doctor.js';
|
|
8
|
+
import type { CommandContext } from './types.js';
|
|
9
|
+
|
|
10
|
+
function ctx(cwd: string): CommandContext & { out: string[] } {
|
|
11
|
+
const out: string[] = [];
|
|
12
|
+
return { argv: [], cwd, stdout: (s) => void out.push(s), stderr: () => undefined, out };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DIGEST = 'b'.repeat(64);
|
|
16
|
+
const requiredProfile = (runtime: 'docker' | 'podman') => `schemaVersion: 1
|
|
17
|
+
kind: container
|
|
18
|
+
requireIsolation: true
|
|
19
|
+
container:
|
|
20
|
+
runtime: ${runtime}
|
|
21
|
+
image: registry.example/tools/node@sha256:${DIGEST}
|
|
22
|
+
network: none
|
|
23
|
+
allowedHosts: []
|
|
24
|
+
cpus: 2
|
|
25
|
+
memoryMb: 2048
|
|
26
|
+
timeoutSeconds: 600
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
let root: string;
|
|
30
|
+
let savedPath: string | undefined;
|
|
31
|
+
beforeEach(async () => {
|
|
32
|
+
root = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-doctor-iso-'));
|
|
33
|
+
savedPath = process.env['PATH'];
|
|
34
|
+
});
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
if (savedPath === undefined) delete process.env['PATH'];
|
|
37
|
+
else process.env['PATH'] = savedPath;
|
|
38
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('kit doctor: isolation', () => {
|
|
42
|
+
it('a project with no execution profile is unaffected: host execution, informational only', async () => {
|
|
43
|
+
const c = ctx(root);
|
|
44
|
+
await doctorCommand.run(c);
|
|
45
|
+
expect(c.out.join('')).toContain('no execution profile declared');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('a required profile whose runtime is unreachable fails the doctor and says it will not run on the host', async () => {
|
|
49
|
+
// The probe runs the runtime CLI found on PATH. A real podman on a CI runner can take the whole
|
|
50
|
+
// 15 s probe timeout, so PATH holds only a podman that cannot reach a daemon: the probe fails at
|
|
51
|
+
// once on every machine, and the refusal path is what this test checks.
|
|
52
|
+
const bin = path.join(root, 'bin');
|
|
53
|
+
await fs.mkdir(bin, { recursive: true });
|
|
54
|
+
const podman = path.join(bin, 'podman');
|
|
55
|
+
await fs.writeFile(podman, '#!/bin/sh\necho "Cannot connect to Podman" >&2\nexit 125\n');
|
|
56
|
+
await fs.chmod(podman, 0o755);
|
|
57
|
+
process.env['PATH'] = bin;
|
|
58
|
+
|
|
59
|
+
await fs.mkdir(path.join(root, '.ai-kit'), { recursive: true });
|
|
60
|
+
await fs.writeFile(path.join(root, '.ai-kit', 'execution.yml'), requiredProfile('podman'));
|
|
61
|
+
const c = ctx(root);
|
|
62
|
+
const code = (await doctorCommand.run(c)).exitCode;
|
|
63
|
+
const text = c.out.join('');
|
|
64
|
+
expect(text).toContain('Refusing to run on the host');
|
|
65
|
+
expect(text).toContain('isolation');
|
|
66
|
+
expect(code).not.toBe(0);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('an invalid profile fails the doctor, never a silent weakening', async () => {
|
|
70
|
+
await fs.mkdir(path.join(root, '.ai-kit'), { recursive: true });
|
|
71
|
+
await fs.writeFile(path.join(root, '.ai-kit', 'execution.yml'), requiredProfile('docker').replace(DIGEST, 'latest'));
|
|
72
|
+
const c = ctx(root);
|
|
73
|
+
expect((await doctorCommand.run(c)).exitCode).not.toBe(0);
|
|
74
|
+
expect(c.out.join('')).toContain('execution profile invalid');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// packages/cli/src/commands/doctor.test.ts
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { doctorCommand } from './doctor.js';
|
|
4
|
+
import { VERSION } from '../application/version.js';
|
|
4
5
|
import type { CommandContext } from './types.js';
|
|
5
6
|
|
|
6
7
|
const makeCtx = (): CommandContext & { out: string[] } => {
|
|
@@ -20,7 +21,7 @@ describe('doctorCommand', () => {
|
|
|
20
21
|
const r = await doctorCommand.run(ctx);
|
|
21
22
|
expect(r.exitCode).toBeLessThanOrEqual(2); // 0 if healthy, 2 if not
|
|
22
23
|
const text = ctx.out[0] ?? '';
|
|
23
|
-
expect(text).toContain(
|
|
24
|
+
expect(text).toContain(`kit ${VERSION}`);
|
|
24
25
|
expect(text).toContain('node');
|
|
25
26
|
expect(text).toContain('pnpm');
|
|
26
27
|
expect(text).toContain('workspace');
|
package/src/commands/doctor.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
import { promises as fs } from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
|
+
import { decideExecution, parseExecutionProfile, runtimeProbeArgv, type RuntimeProbe } from '@agentic-sdlc-kit/core';
|
|
12
|
+
import type { ExecutionProfile } from '@agentic-sdlc-kit/contracts';
|
|
11
13
|
import { VERSION } from '../application/version.js';
|
|
12
14
|
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
13
15
|
|
|
@@ -49,6 +51,12 @@ export const doctorCommand: Command = {
|
|
|
49
51
|
const profile = await checkProfile(ctx.cwd);
|
|
50
52
|
lines.push(` profile ${profile.msg} [${profile.status}]`);
|
|
51
53
|
|
|
54
|
+
// Execution isolation (roadmap Phase 8). Only a declared profile is checked: a project without
|
|
55
|
+
// one is unaffected. A profile that requires isolation and cannot get it fails the doctor.
|
|
56
|
+
const execution = await checkExecution(ctx.cwd);
|
|
57
|
+
if (execution.failed) healthy = false;
|
|
58
|
+
lines.push(` isolation ${execution.msg} [${execution.status}]`);
|
|
59
|
+
|
|
52
60
|
lines.push('');
|
|
53
61
|
lines.push(healthy ? 'Status: healthy' : 'Status: issues found');
|
|
54
62
|
ctx.stdout(lines.join('\n') + '\n');
|
|
@@ -56,6 +64,34 @@ export const doctorCommand: Command = {
|
|
|
56
64
|
},
|
|
57
65
|
};
|
|
58
66
|
|
|
67
|
+
async function checkExecution(cwd: string): Promise<{ msg: string; status: 'ok' | 'info' | 'FAIL'; failed: boolean }> {
|
|
68
|
+
let text: string;
|
|
69
|
+
try {
|
|
70
|
+
text = await fs.readFile(path.join(cwd, '.ai-kit', 'execution.yml'), 'utf8');
|
|
71
|
+
} catch {
|
|
72
|
+
return { msg: 'no execution profile declared (host execution)', status: 'info', failed: false };
|
|
73
|
+
}
|
|
74
|
+
const parsed = parseExecutionProfile(text);
|
|
75
|
+
if (!parsed.ok) return { msg: `execution profile invalid: ${parsed.error}`, status: 'FAIL', failed: true };
|
|
76
|
+
const probe = await probeRuntime(parsed.value);
|
|
77
|
+
const decision = decideExecution(parsed.value, probe);
|
|
78
|
+
if (!decision.ok) return { msg: decision.reason, status: 'FAIL', failed: true };
|
|
79
|
+
return { msg: decision.reason, status: 'ok', failed: false };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function probeRuntime(profile: ExecutionProfile): Promise<RuntimeProbe | null> {
|
|
83
|
+
if (profile.kind !== 'container') return null;
|
|
84
|
+
const { execFile } = await import('node:child_process');
|
|
85
|
+
const { promisify } = await import('node:util');
|
|
86
|
+
const argv = runtimeProbeArgv(profile.container.runtime);
|
|
87
|
+
try {
|
|
88
|
+
const { stdout } = await promisify(execFile)(argv[0] as string, argv.slice(1), { timeout: 15_000 });
|
|
89
|
+
return { reachable: stdout.trim().length > 0, detail: `daemon ${stdout.trim() || 'returned no version'}` };
|
|
90
|
+
} catch (cause) {
|
|
91
|
+
return { reachable: false, detail: cause instanceof Error ? cause.message.split('\n')[0] ?? 'probe failed' : 'probe failed' };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
59
95
|
async function findExecutable(name: string): Promise<string | null> {
|
|
60
96
|
const { execFileSync } = await import('node:child_process');
|
|
61
97
|
try {
|
|
@@ -3,10 +3,7 @@ import { promises as fs } from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import {
|
|
7
|
-
scaffoldSpecification,
|
|
8
|
-
serializeProfileYaml,
|
|
9
|
-
} from '@agentic-sdlc-kit/core';
|
|
6
|
+
import { scaffoldSpecification, serializeProfileYaml } from '@agentic-sdlc-kit/core';
|
|
10
7
|
import { MockAgentProvider } from '@agentic-sdlc-kit/testing';
|
|
11
8
|
import type { AgentProvider } from '@agentic-sdlc-kit/contracts';
|
|
12
9
|
import { buildOrchestrationFixture } from '../application/agent/test-fixture.js';
|
|
@@ -321,3 +318,38 @@ describe('featureCommand run (Mode 1, PR3+PR4)', () => {
|
|
|
321
318
|
}
|
|
322
319
|
});
|
|
323
320
|
});
|
|
321
|
+
|
|
322
|
+
describe('featureCommand strength (ADR-0022)', () => {
|
|
323
|
+
it('requires a task id and refuses when the profile has no strength section', async () => {
|
|
324
|
+
const project = await setupProject();
|
|
325
|
+
try {
|
|
326
|
+
// No task id.
|
|
327
|
+
const noTask = makeCtx(['FEATURE-001', 'strength'], project.root);
|
|
328
|
+
const r1 = await featureCommand.run(noTask);
|
|
329
|
+
expect(r1.exitCode).toBe(1);
|
|
330
|
+
expect(noTask.err[0]).toContain('strength requires a task id');
|
|
331
|
+
|
|
332
|
+
// Task id present, but strength not enabled in the profile (opt-in).
|
|
333
|
+
// Complete the chain properly: red (marker absent -> assertion failure),
|
|
334
|
+
// then implement (marker), then green, then refactor.
|
|
335
|
+
await featureCommand.run(makeCtx(['FEATURE-001', 'start'], project.root));
|
|
336
|
+
await featureCommand.run(makeCtx(['FEATURE-001', 'red', 'TASK-001'], project.root));
|
|
337
|
+
await fs.writeFile(project.marker, '');
|
|
338
|
+
await featureCommand.run(makeCtx(['FEATURE-001', 'green', 'TASK-001'], project.root));
|
|
339
|
+
await featureCommand.run(makeCtx(['FEATURE-001', 'refactor', 'TASK-001'], project.root));
|
|
340
|
+
|
|
341
|
+
const ctx = makeCtx(['FEATURE-001', 'strength', 'TASK-001'], project.root);
|
|
342
|
+
const r2 = await featureCommand.run(ctx);
|
|
343
|
+
expect(r2.exitCode).toBe(1);
|
|
344
|
+
expect(ctx.err[0]).toContain('not enabled');
|
|
345
|
+
} finally {
|
|
346
|
+
await fs.rm(project.root, { recursive: true, force: true });
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('mentions the strength action in help output', async () => {
|
|
351
|
+
const ctx = makeCtx(['--help'], '/');
|
|
352
|
+
await featureCommand.run(ctx);
|
|
353
|
+
expect(ctx.out[0]).toContain('strength <task-id>');
|
|
354
|
+
});
|
|
355
|
+
});
|
package/src/commands/feature.ts
CHANGED
|
@@ -20,6 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
import {
|
|
21
21
|
finalizeFeatureRun,
|
|
22
22
|
getFeatureRunState,
|
|
23
|
+
runStrengthPhase,
|
|
23
24
|
runTddPhase,
|
|
24
25
|
startFeatureRun,
|
|
25
26
|
type FeatureRunReport,
|
|
@@ -59,9 +60,11 @@ function blocked(ctx: CommandContext, message: string): CommandResult {
|
|
|
59
60
|
*/
|
|
60
61
|
function resolveActor(argv: ReadonlyArray<string>): JournalActor {
|
|
61
62
|
const fromFlag = parseFlagValue(argv, '--host');
|
|
62
|
-
const host =
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const host =
|
|
64
|
+
fromFlag ??
|
|
65
|
+
(process.env['KIT_HOST'] && process.env['KIT_HOST'].length > 0
|
|
66
|
+
? process.env['KIT_HOST']
|
|
67
|
+
: undefined);
|
|
65
68
|
return host !== undefined ? { kind: 'agent', host } : { kind: 'human' };
|
|
66
69
|
}
|
|
67
70
|
|
|
@@ -104,6 +107,8 @@ export function createFeatureCommand(opts: FeatureCommandOptions = {}): Command
|
|
|
104
107
|
return runStart(ctx, root, featureId, isJson, actor);
|
|
105
108
|
case 'status':
|
|
106
109
|
return runStatus(ctx, root, featureId, isJson);
|
|
110
|
+
case 'strength':
|
|
111
|
+
return runStrength(ctx, root, featureId, positional[2], isJson, actor);
|
|
107
112
|
case 'verify':
|
|
108
113
|
return runVerify(ctx, root, featureId, isJson, ctx.argv.includes('--dry-run'), actor);
|
|
109
114
|
case 'run':
|
|
@@ -117,7 +122,7 @@ export function createFeatureCommand(opts: FeatureCommandOptions = {}): Command
|
|
|
117
122
|
default:
|
|
118
123
|
return fail(
|
|
119
124
|
ctx,
|
|
120
|
-
`unknown action '${action}' (expected start|red|green|refactor|status|verify|run)`,
|
|
125
|
+
`unknown action '${action}' (expected start|red|green|refactor|status|strength|verify|run)`,
|
|
121
126
|
);
|
|
122
127
|
}
|
|
123
128
|
},
|
|
@@ -161,7 +166,11 @@ async function runPhase(
|
|
|
161
166
|
isJson: boolean,
|
|
162
167
|
actor: JournalActor,
|
|
163
168
|
): Promise<CommandResult> {
|
|
164
|
-
if (!taskId)
|
|
169
|
+
if (!taskId)
|
|
170
|
+
return fail(
|
|
171
|
+
ctx,
|
|
172
|
+
`phase '${phase}' requires a task id (see \`kit feature ${featureId} status\`)`,
|
|
173
|
+
);
|
|
165
174
|
const res = await runTddPhase({ featureId, projectRoot: root, taskId, phase, actor });
|
|
166
175
|
if (!res.ok) return fail(ctx, res.error.message);
|
|
167
176
|
if (isJson) {
|
|
@@ -223,6 +232,56 @@ async function runStatus(
|
|
|
223
232
|
return { exitCode: 0 };
|
|
224
233
|
}
|
|
225
234
|
|
|
235
|
+
/**
|
|
236
|
+
* `kit feature <id> strength <task-id>` (ADR-0022): run the optional
|
|
237
|
+
* mutation-score measurement for a completed task and record it as
|
|
238
|
+
* journal + persisted evidence. The gate decision is reported; blocking
|
|
239
|
+
* happens at verify when gateMode is enforce.
|
|
240
|
+
*/
|
|
241
|
+
async function runStrength(
|
|
242
|
+
ctx: CommandContext,
|
|
243
|
+
root: string,
|
|
244
|
+
featureId: string,
|
|
245
|
+
taskId: string | undefined,
|
|
246
|
+
isJson: boolean,
|
|
247
|
+
actor: JournalActor,
|
|
248
|
+
): Promise<CommandResult> {
|
|
249
|
+
if (!taskId) {
|
|
250
|
+
return fail(ctx, `strength requires a task id (see \`kit feature ${featureId} status\`)`);
|
|
251
|
+
}
|
|
252
|
+
const res = await runStrengthPhase({
|
|
253
|
+
featureId,
|
|
254
|
+
projectRoot: root,
|
|
255
|
+
taskId,
|
|
256
|
+
actor,
|
|
257
|
+
});
|
|
258
|
+
if (!res.ok) return fail(ctx, res.error.message);
|
|
259
|
+
if (isJson) {
|
|
260
|
+
ctx.stdout(
|
|
261
|
+
JSON.stringify(
|
|
262
|
+
{ taskId, strength: res.value.evidence, gateBlocked: res.value.blocked },
|
|
263
|
+
null,
|
|
264
|
+
2,
|
|
265
|
+
) + '\n',
|
|
266
|
+
);
|
|
267
|
+
return { exitCode: 0 };
|
|
268
|
+
}
|
|
269
|
+
const e = res.value.evidence;
|
|
270
|
+
const score = e.score !== undefined ? `${e.score}%` : 'n/a';
|
|
271
|
+
ctx.stdout(
|
|
272
|
+
[
|
|
273
|
+
`${taskId} strength ${e.status} (score ${score} vs threshold ${e.threshold}%).`,
|
|
274
|
+
` tool=${e.tool} scope=${e.scope} mutants=${e.mutantsKilled}/${e.mutantsGenerated} killed`,
|
|
275
|
+
` ${e.summary}`,
|
|
276
|
+
res.value.blocked
|
|
277
|
+
? `Strength gate: BLOCKED (enforce) — \`kit feature ${featureId} verify\` will refuse until the suite clears ${e.threshold}%.`
|
|
278
|
+
: `Strength gate: not blocking (warn mode).`,
|
|
279
|
+
'',
|
|
280
|
+
].join('\n'),
|
|
281
|
+
);
|
|
282
|
+
return { exitCode: 0 };
|
|
283
|
+
}
|
|
284
|
+
|
|
226
285
|
async function runVerify(
|
|
227
286
|
ctx: CommandContext,
|
|
228
287
|
root: string,
|
|
@@ -261,8 +320,9 @@ async function runOrchestrated(
|
|
|
261
320
|
// PR4: the shipped CLI registers claude-code against the resolved root
|
|
262
321
|
// (the provider roots its encrypted resume store there). Explicitly
|
|
263
322
|
// injected providers override the default entirely.
|
|
264
|
-
const providers: ReadonlyArray<AgentProvider> =
|
|
265
|
-
|
|
323
|
+
const providers: ReadonlyArray<AgentProvider> = opts.agentProviders ?? [
|
|
324
|
+
new ClaudeCodeProvider({ projectRoot: root }),
|
|
325
|
+
];
|
|
266
326
|
|
|
267
327
|
const gateway = new AgentGateway({
|
|
268
328
|
providers,
|
|
@@ -302,7 +362,8 @@ async function runOrchestrated(
|
|
|
302
362
|
...(isJson ? {} : { onProgress: (line: string) => ctx.stdout(line) }),
|
|
303
363
|
});
|
|
304
364
|
if (!res.ok) {
|
|
305
|
-
if (res.error.code === 'AGENT_PROVIDER_NOT_CONFIGURED')
|
|
365
|
+
if (res.error.code === 'AGENT_PROVIDER_NOT_CONFIGURED')
|
|
366
|
+
return blocked(ctx, res.error.message);
|
|
306
367
|
return fail(ctx, res.error.message);
|
|
307
368
|
}
|
|
308
369
|
const report = res.value;
|
|
@@ -381,6 +442,8 @@ function formatHelp(): string {
|
|
|
381
442
|
' green <task-id> run verification: it MUST pass (after implementing)',
|
|
382
443
|
' refactor <task-id> run verification: it MUST pass (behavior preserved)',
|
|
383
444
|
' status show run state and the next action',
|
|
445
|
+
' strength <task-id> run the optional mutation-score stage for a completed task',
|
|
446
|
+
' (ADR-0022; requires verification.strength.enabled)',
|
|
384
447
|
' verify audit the evidence chain and run final verification',
|
|
385
448
|
' run Mode 1: orchestrate all phases through an agent provider',
|
|
386
449
|
' in an isolated git worktree (ADR-0019)',
|
package/src/commands/index.ts
CHANGED
|
@@ -8,6 +8,9 @@ export * from './init.js';
|
|
|
8
8
|
export * from './validate-spec.js';
|
|
9
9
|
export * from './validate-plan.js';
|
|
10
10
|
export * from './verify.js';
|
|
11
|
+
export * from './rules.js';
|
|
12
|
+
export * from './onboard.js';
|
|
13
|
+
export * from './rules-format.js';
|
|
11
14
|
export * from './feature.js';
|
|
12
15
|
export * from './new.js';
|
|
13
16
|
export * from './fix.js';
|
|
@@ -23,3 +26,8 @@ export * from './journal.js';
|
|
|
23
26
|
export * from './skills.js';
|
|
24
27
|
export * from './attach.js';
|
|
25
28
|
export * from './host.js';
|
|
29
|
+
export * from './context.js';
|
|
30
|
+
export * from './learning.js';
|
|
31
|
+
export * from './bench.js';
|
|
32
|
+
export * from './routing.js';
|
|
33
|
+
export * from './knowledge.js';
|
package/src/commands/install.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { promises as fs } from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { resolveStackPack } from '@agentic-sdlc-kit/core';
|
|
10
|
+
import { VERSION } from '../application/version.js';
|
|
10
11
|
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
11
12
|
import type { OwnershipEntry } from '@agentic-sdlc-kit/contracts';
|
|
12
13
|
import { linkRuntimePlugins, type PluginLinkResult } from './plugin-linker.js';
|
|
@@ -202,7 +203,7 @@ export const installCommand: Command = {
|
|
|
202
203
|
// preserved is false because we did not skip it.
|
|
203
204
|
ownershipEntries.push({
|
|
204
205
|
packageId: 'agentic-sdlc-kit',
|
|
205
|
-
packageVersion:
|
|
206
|
+
packageVersion: VERSION,
|
|
206
207
|
path: op.path,
|
|
207
208
|
sha256: op.sha256,
|
|
208
209
|
installedAt: now,
|
|
@@ -233,7 +234,7 @@ export const installCommand: Command = {
|
|
|
233
234
|
}
|
|
234
235
|
ownershipEntries.push({
|
|
235
236
|
packageId: 'agentic-sdlc-kit',
|
|
236
|
-
packageVersion:
|
|
237
|
+
packageVersion: VERSION,
|
|
237
238
|
path: path.relative(targetRoot, pr.linkPath),
|
|
238
239
|
sha256: pluginHash,
|
|
239
240
|
installedAt: now,
|
|
@@ -328,7 +329,9 @@ interface InstallResult {
|
|
|
328
329
|
|
|
329
330
|
function formatResult(r: InstallResult): string {
|
|
330
331
|
const lines: string[] = [
|
|
331
|
-
r.installed
|
|
332
|
+
r.installed
|
|
333
|
+
? 'kit install: SUCCESS'
|
|
334
|
+
: 'kit install: COMPLETED WITH PROBLEMS (see plugin status below)',
|
|
332
335
|
` Profile: ${r.profile}`,
|
|
333
336
|
` Stack: ${r.stack}`,
|
|
334
337
|
` Written: ${r.writtenFiles.length} file(s)`,
|
|
@@ -375,7 +378,7 @@ function formatHelp(): string {
|
|
|
375
378
|
'The full-sdlc and runtime profiles link the four guard plugins',
|
|
376
379
|
'(sdlc-guard, secret-guard, model-router, run-observer) into',
|
|
377
380
|
'.claude/plugins/. They are Claude Code Mods: Claude Code loads each',
|
|
378
|
-
|
|
381
|
+
"plugin's TypeScript hooks module (hooks/register.ts) directly, so they",
|
|
379
382
|
'work from a fresh clone with no build step (Claude Code v2.1.287+).',
|
|
380
383
|
'',
|
|
381
384
|
'Options:',
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { knowledgeCommand } from './knowledge.js';
|
|
6
|
+
import type { CommandContext } from './types.js';
|
|
7
|
+
|
|
8
|
+
function ctx(argv: string[], cwd: string): CommandContext & { out: string[]; err: string[] } {
|
|
9
|
+
const out: string[] = [];
|
|
10
|
+
const err: string[] = [];
|
|
11
|
+
return { argv, cwd, stdout: (s) => void out.push(s), stderr: (s) => void err.push(s), out, err };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let root: string;
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
root = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-knowledge-'));
|
|
17
|
+
});
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('kit knowledge export', () => {
|
|
23
|
+
it('refuses to run without --dry-run: there is no transport', async () => {
|
|
24
|
+
const c = ctx(['export', '--namespace', 'tooling'], root);
|
|
25
|
+
expect((await knowledgeCommand.run(c)).exitCode).toBe(2);
|
|
26
|
+
expect(c.err.join('')).toContain('only --dry-run exists');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('requires a namespace', async () => {
|
|
30
|
+
expect((await knowledgeCommand.run(ctx(['export', '--dry-run'], root))).exitCode).toBe(2);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('a dry run with no constitution shares nothing and writes nothing', async () => {
|
|
34
|
+
const c = ctx(['export', '--dry-run', '--namespace', 'tooling'], root);
|
|
35
|
+
expect((await knowledgeCommand.run(c)).exitCode).toBe(0);
|
|
36
|
+
expect(c.out.join('')).toContain('nothing written, nothing sent');
|
|
37
|
+
await expect(fs.access(path.join(root, '.ai-kit', 'knowledge'))).rejects.toThrow();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// packages/cli/src/commands/knowledge.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit knowledge export --dry-run --namespace <name> [--json]` (ADR-0027). Shows which rules this
|
|
4
|
+
// repository would share, after the secret scan. Only --dry-run exists: there is no transport, and
|
|
5
|
+
// nothing is pushed or written.
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { knowledgeExportDryRun } from '@agentic-sdlc-kit/core';
|
|
9
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
10
|
+
|
|
11
|
+
const HELP = `Usage: kit knowledge export --dry-run --namespace <name> [--json]
|
|
12
|
+
|
|
13
|
+
Shows the rules this repository would share, after a secret scan. Only rules marked
|
|
14
|
+
shareable: true are considered. Nothing is written and nothing is sent: the transport is not built.
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
function flag(argv: readonly string[], name: string): string | undefined {
|
|
18
|
+
const i = argv.indexOf(name);
|
|
19
|
+
return i >= 0 ? argv[i + 1] : undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const knowledgeCommand: Command = {
|
|
23
|
+
name: 'knowledge',
|
|
24
|
+
summary: 'Show the rules this repository would share, dry run only (ADR-0027).',
|
|
25
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
26
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h') || ctx.argv.length === 0) {
|
|
27
|
+
ctx.stdout(HELP);
|
|
28
|
+
return { exitCode: 0 };
|
|
29
|
+
}
|
|
30
|
+
const sub = ctx.argv.find((a) => !a.startsWith('-'));
|
|
31
|
+
if (sub !== 'export') {
|
|
32
|
+
ctx.stderr(`kit knowledge: unknown subcommand "${sub ?? ''}"\n${HELP}`);
|
|
33
|
+
return { exitCode: 2, message: 'unknown subcommand' };
|
|
34
|
+
}
|
|
35
|
+
if (!ctx.argv.includes('--dry-run')) {
|
|
36
|
+
ctx.stderr('kit knowledge export: only --dry-run exists; the transport is not built (ADR-0027)\n');
|
|
37
|
+
return { exitCode: 2, message: 'dry run required' };
|
|
38
|
+
}
|
|
39
|
+
const namespace = flag(ctx.argv, '--namespace');
|
|
40
|
+
if (namespace === undefined) {
|
|
41
|
+
ctx.stderr('kit knowledge export: --namespace <name> is required\n');
|
|
42
|
+
return { exitCode: 2, message: 'namespace required' };
|
|
43
|
+
}
|
|
44
|
+
const res = await knowledgeExportDryRun(path.resolve(ctx.cwd), namespace);
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
ctx.stderr(`kit knowledge export: ${res.error.message}\n`);
|
|
47
|
+
return { exitCode: 1, message: res.error.message };
|
|
48
|
+
}
|
|
49
|
+
if (ctx.argv.includes('--json')) {
|
|
50
|
+
ctx.stdout(`${JSON.stringify(res.value, null, 2)}\n`);
|
|
51
|
+
return { exitCode: 0 };
|
|
52
|
+
}
|
|
53
|
+
const m = res.value;
|
|
54
|
+
const lines = [
|
|
55
|
+
`Dry run for namespace ${m.namespace}: nothing written, nothing sent.`,
|
|
56
|
+
`Scanned ${m.scanned} rule(s): ${m.shared.length} shareable, ${m.keptLocal} kept local, ${m.refused.length} refused by the secret scan.`,
|
|
57
|
+
...m.shared.map((s) => ` share ${s.id} ${s.title}`),
|
|
58
|
+
...m.refused.map((r) => ` refuse ${r.id} ${r.reason}`),
|
|
59
|
+
];
|
|
60
|
+
ctx.stdout(`${lines.join('\n')}\n`);
|
|
61
|
+
return { exitCode: 0 };
|
|
62
|
+
},
|
|
63
|
+
};
|