@agentic-sdlc-kit/cli 0.9.1 → 1.1.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.
Files changed (149) hide show
  1. package/dist/application/agent/orchestrator.d.ts.map +1 -1
  2. package/dist/application/agent/orchestrator.js +4 -3
  3. package/dist/application/agent/orchestrator.js.map +1 -1
  4. package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -1
  5. package/dist/application/agent/providers/claude-code/permission-config.js +8 -2
  6. package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -1
  7. package/dist/application/agent-tools/dispatch.d.ts +12 -0
  8. package/dist/application/agent-tools/dispatch.d.ts.map +1 -0
  9. package/dist/application/agent-tools/dispatch.js +189 -0
  10. package/dist/application/agent-tools/dispatch.js.map +1 -0
  11. package/dist/application/agent-tools/mcp-server.d.ts +10 -0
  12. package/dist/application/agent-tools/mcp-server.d.ts.map +1 -0
  13. package/dist/application/agent-tools/mcp-server.js +100 -0
  14. package/dist/application/agent-tools/mcp-server.js.map +1 -0
  15. package/dist/application/bench/harness.d.ts +5 -0
  16. package/dist/application/bench/harness.d.ts.map +1 -0
  17. package/dist/application/bench/harness.js +82 -0
  18. package/dist/application/bench/harness.js.map +1 -0
  19. package/dist/application/dispatcher.d.ts.map +1 -1
  20. package/dist/application/dispatcher.js +24 -0
  21. package/dist/application/dispatcher.js.map +1 -1
  22. package/dist/application/rule-adapters/ast-grep.d.ts +3 -0
  23. package/dist/application/rule-adapters/ast-grep.d.ts.map +1 -0
  24. package/dist/application/rule-adapters/ast-grep.js +112 -0
  25. package/dist/application/rule-adapters/ast-grep.js.map +1 -0
  26. package/dist/application/rule-adapters/index.d.ts +3 -0
  27. package/dist/application/rule-adapters/index.d.ts.map +1 -0
  28. package/dist/application/rule-adapters/index.js +15 -0
  29. package/dist/application/rule-adapters/index.js.map +1 -0
  30. package/dist/application/rule-adapters/linter.d.ts +31 -0
  31. package/dist/application/rule-adapters/linter.d.ts.map +1 -0
  32. package/dist/application/rule-adapters/linter.js +242 -0
  33. package/dist/application/rule-adapters/linter.js.map +1 -0
  34. package/dist/application/rule-adapters/process.d.ts +10 -0
  35. package/dist/application/rule-adapters/process.d.ts.map +1 -0
  36. package/dist/application/rule-adapters/process.js +38 -0
  37. package/dist/application/rule-adapters/process.js.map +1 -0
  38. package/dist/application/version.d.ts +1 -1
  39. package/dist/application/version.d.ts.map +1 -1
  40. package/dist/application/version.js +7 -4
  41. package/dist/application/version.js.map +1 -1
  42. package/dist/commands/bench.d.ts +3 -0
  43. package/dist/commands/bench.d.ts.map +1 -0
  44. package/dist/commands/bench.js +75 -0
  45. package/dist/commands/bench.js.map +1 -0
  46. package/dist/commands/context.d.ts +3 -0
  47. package/dist/commands/context.d.ts.map +1 -0
  48. package/dist/commands/context.js +56 -0
  49. package/dist/commands/context.js.map +1 -0
  50. package/dist/commands/doctor.d.ts.map +1 -1
  51. package/dist/commands/doctor.js +38 -0
  52. package/dist/commands/doctor.js.map +1 -1
  53. package/dist/commands/feature.d.ts.map +1 -1
  54. package/dist/commands/feature.js +48 -6
  55. package/dist/commands/feature.js.map +1 -1
  56. package/dist/commands/index.d.ts +8 -0
  57. package/dist/commands/index.d.ts.map +1 -1
  58. package/dist/commands/index.js +8 -0
  59. package/dist/commands/index.js.map +1 -1
  60. package/dist/commands/install.d.ts.map +1 -1
  61. package/dist/commands/install.js +7 -4
  62. package/dist/commands/install.js.map +1 -1
  63. package/dist/commands/knowledge.d.ts +3 -0
  64. package/dist/commands/knowledge.d.ts.map +1 -0
  65. package/dist/commands/knowledge.js +59 -0
  66. package/dist/commands/knowledge.js.map +1 -0
  67. package/dist/commands/learning.d.ts +3 -0
  68. package/dist/commands/learning.d.ts.map +1 -0
  69. package/dist/commands/learning.js +126 -0
  70. package/dist/commands/learning.js.map +1 -0
  71. package/dist/commands/mcp.d.ts +3 -0
  72. package/dist/commands/mcp.d.ts.map +1 -0
  73. package/dist/commands/mcp.js +26 -0
  74. package/dist/commands/mcp.js.map +1 -0
  75. package/dist/commands/next.d.ts.map +1 -1
  76. package/dist/commands/next.js +3 -1
  77. package/dist/commands/next.js.map +1 -1
  78. package/dist/commands/onboard.d.ts +5 -0
  79. package/dist/commands/onboard.d.ts.map +1 -0
  80. package/dist/commands/onboard.js +137 -0
  81. package/dist/commands/onboard.js.map +1 -0
  82. package/dist/commands/routing.d.ts +3 -0
  83. package/dist/commands/routing.d.ts.map +1 -0
  84. package/dist/commands/routing.js +107 -0
  85. package/dist/commands/routing.js.map +1 -0
  86. package/dist/commands/rules-format.d.ts +4 -0
  87. package/dist/commands/rules-format.d.ts.map +1 -0
  88. package/dist/commands/rules-format.js +16 -0
  89. package/dist/commands/rules-format.js.map +1 -0
  90. package/dist/commands/rules.d.ts +3 -0
  91. package/dist/commands/rules.d.ts.map +1 -0
  92. package/dist/commands/rules.js +270 -0
  93. package/dist/commands/rules.js.map +1 -0
  94. package/dist/commands/verify.d.ts.map +1 -1
  95. package/dist/commands/verify.js +78 -6
  96. package/dist/commands/verify.js.map +1 -1
  97. package/package.json +11 -5
  98. package/src/application/agent/orchestrator.test.ts +39 -0
  99. package/src/application/agent/orchestrator.ts +6 -0
  100. package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +1 -1
  101. package/src/application/agent/providers/claude-code/permission-config.test.ts +4 -4
  102. package/src/application/agent/providers/claude-code/permission-config.ts +8 -2
  103. package/src/application/agent/providers/claude-code/provider.test.ts +2 -2
  104. package/src/application/agent-tools/dispatch.test.ts +160 -0
  105. package/src/application/agent-tools/dispatch.ts +227 -0
  106. package/src/application/agent-tools/mcp-server.test.ts +86 -0
  107. package/src/application/agent-tools/mcp-server.ts +126 -0
  108. package/src/application/bench/harness.ts +95 -0
  109. package/src/application/dispatcher.test.ts +4 -3
  110. package/src/application/dispatcher.ts +16 -0
  111. package/src/application/rule-adapters/adapters.test.ts +224 -0
  112. package/src/application/rule-adapters/ast-grep.ts +126 -0
  113. package/src/application/rule-adapters/index.ts +16 -0
  114. package/src/application/rule-adapters/linter-paths.test.ts +95 -0
  115. package/src/application/rule-adapters/linter.ts +263 -0
  116. package/src/application/rule-adapters/process.ts +48 -0
  117. package/src/application/version.ts +9 -4
  118. package/src/commands/bench.test.ts +136 -0
  119. package/src/commands/bench.ts +74 -0
  120. package/src/commands/context.test.ts +47 -0
  121. package/src/commands/context.ts +59 -0
  122. package/src/commands/doctor-isolation.test.ts +76 -0
  123. package/src/commands/doctor.test.ts +2 -1
  124. package/src/commands/doctor.ts +36 -0
  125. package/src/commands/evolve.test.ts +153 -0
  126. package/src/commands/feature.test.ts +36 -4
  127. package/src/commands/feature.ts +71 -8
  128. package/src/commands/index.ts +8 -0
  129. package/src/commands/install.ts +7 -4
  130. package/src/commands/journal.test.ts +150 -0
  131. package/src/commands/knowledge.test.ts +39 -0
  132. package/src/commands/knowledge.ts +63 -0
  133. package/src/commands/learning.test.ts +104 -0
  134. package/src/commands/learning.ts +134 -0
  135. package/src/commands/mcp.ts +30 -0
  136. package/src/commands/memory.test.ts +146 -0
  137. package/src/commands/next.ts +3 -1
  138. package/src/commands/onboard.test.ts +83 -0
  139. package/src/commands/onboard.ts +146 -0
  140. package/src/commands/optimize.test.ts +53 -0
  141. package/src/commands/refactor.test.ts +57 -0
  142. package/src/commands/routing.test.ts +64 -0
  143. package/src/commands/routing.ts +107 -0
  144. package/src/commands/rules-format.ts +22 -0
  145. package/src/commands/rules.test.ts +153 -0
  146. package/src/commands/rules.ts +286 -0
  147. package/src/commands/verify.test.ts +115 -0
  148. package/src/commands/verify.ts +95 -7
  149. 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('kit 0.9.1');
24
+ expect(text).toContain(`kit ${VERSION}`);
24
25
  expect(text).toContain('node');
25
26
  expect(text).toContain('pnpm');
26
27
  expect(text).toContain('workspace');
@@ -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 {
@@ -0,0 +1,153 @@
1
+ // packages/cli/src/commands/evolve.test.ts
2
+ //
3
+ // CLI-layer tests for `kit evolve` (M31-M33): honest no-experience
4
+ // reporting (exit 1), the full no-benchmark pipeline over seeded
5
+ // experiences (distill → hypothesize → not-run verdicts → withheld
6
+ // metrics), --dry-run, and the --json surface.
7
+ //
8
+ // Seeded experiences use the real on-disk contract the command reads
9
+ // (.ai-kit/state/experiences.json); recurring failures on one stack
10
+ // produce one distilled lesson and one hypothesis whose Evolution Lab
11
+ // benchmark reports notImplemented — surfaced as verdict 'not-run',
12
+ // never as completed work (ADR-0018).
13
+ import { promises as fs } from 'node:fs';
14
+ import os from 'node:os';
15
+ import path from 'node:path';
16
+ import type { ExperienceRecord } from '@agentic-sdlc-kit/contracts';
17
+ import { describe, expect, it } from 'vitest';
18
+ import { evolveCommand } from './evolve.js';
19
+ import type { CommandContext } from './types.js';
20
+
21
+ const makeCtx = (
22
+ argv: string[],
23
+ cwd: string,
24
+ ): CommandContext & { out: string[]; err: string[] } => {
25
+ const out: string[] = [];
26
+ const err: string[] = [];
27
+ return {
28
+ argv,
29
+ cwd,
30
+ stdout: (s) => void out.push(s),
31
+ stderr: (s) => void err.push(s),
32
+ out,
33
+ err,
34
+ };
35
+ };
36
+
37
+ function failureRecord(id: string): ExperienceRecord {
38
+ return {
39
+ id,
40
+ workflowId: 'feature',
41
+ featureId: 'FEATURE-001',
42
+ stack: 'node-typescript',
43
+ outcome: 'failure',
44
+ phases: [
45
+ { name: 'specification', status: 'passed', durationMs: 100 },
46
+ { name: 'implementation', status: 'failed', durationMs: 500 },
47
+ { name: 'verification', status: 'passed', durationMs: 200 },
48
+ ],
49
+ failureSummary: 'TASK-001: AssertionError: expected marker to exist',
50
+ timestamp: '2026-01-01T00:00:00.000Z',
51
+ };
52
+ }
53
+
54
+ async function seedExperiences(root: string, records: readonly ExperienceRecord[]): Promise<void> {
55
+ const target = path.join(root, '.ai-kit', 'state', 'experiences.json');
56
+ await fs.mkdir(path.dirname(target), { recursive: true });
57
+ await fs.writeFile(target, JSON.stringify({ schemaVersion: 1, records }, null, 2) + '\n', 'utf8');
58
+ }
59
+
60
+ async function tmpRoot(): Promise<string> {
61
+ return fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-evolve-'));
62
+ }
63
+
64
+ describe('kit evolve', () => {
65
+ it('shows usage with --help and exits 0', async () => {
66
+ const ctx = makeCtx(['--help'], await tmpRoot());
67
+ const result = await evolveCommand.run(ctx);
68
+ expect(result.exitCode).toBe(0);
69
+ expect(ctx.out.join('')).toContain('Usage: kit evolve [--dry-run] [--json]');
70
+ });
71
+
72
+ it('fails honestly (exit 1) when no experiences have been accumulated', async () => {
73
+ const ctx = makeCtx([], await tmpRoot());
74
+ const result = await evolveCommand.run(ctx);
75
+ expect(result.exitCode).toBe(1);
76
+ expect(result.message).toBe('no experiences to distill');
77
+ const text = ctx.out.join('');
78
+ expect(text).toContain('no experience records found');
79
+ expect(text).toContain('kit feature');
80
+ });
81
+
82
+ it('reports the no-experience state as JSON with --json', async () => {
83
+ const ctx = makeCtx(['--json'], await tmpRoot());
84
+ const result = await evolveCommand.run(ctx);
85
+ expect(result.exitCode).toBe(1);
86
+ const payload = JSON.parse(ctx.out.join('')) as { error: string };
87
+ expect(payload.error).toBe('no-experiences');
88
+ });
89
+
90
+ it('distills lessons from recurring failures and reports the lab honestly as NOT RUN', async () => {
91
+ const root = await tmpRoot();
92
+ // Three independent failures on the same stack and phase → one
93
+ // distilled lesson with confidence 0.8 (>= 0.7) → one hypothesis.
94
+ await seedExperiences(root, [
95
+ failureRecord('EXP-001'),
96
+ failureRecord('EXP-002'),
97
+ failureRecord('EXP-003'),
98
+ ]);
99
+ const ctx = makeCtx([], root);
100
+ const result = await evolveCommand.run(ctx);
101
+ expect(result.exitCode).toBe(0);
102
+ const text = ctx.out.join('');
103
+ expect(text).toContain('Experiences Loaded: 3');
104
+ expect(text).toContain('Distilled Lessons: 1');
105
+ expect(text).toContain('Hypotheses: 1');
106
+ expect(text).toContain('Evolution Lab: NOT RUN (benchmark environment unavailable)');
107
+ expect(text).toContain('Metrics: withheld (no executed benchmarks)');
108
+ });
109
+
110
+ it('emits the machine-readable report with --json', async () => {
111
+ const root = await tmpRoot();
112
+ await seedExperiences(root, [
113
+ failureRecord('EXP-001'),
114
+ failureRecord('EXP-002'),
115
+ failureRecord('EXP-003'),
116
+ ]);
117
+ const ctx = makeCtx(['--json', '--dry-run'], root);
118
+ const result = await evolveCommand.run(ctx);
119
+ expect(result.exitCode).toBe(0);
120
+ const payload = JSON.parse(ctx.out.join('')) as {
121
+ experiencesLoaded: number;
122
+ distilledLessons: number;
123
+ hypothesesGenerated: number;
124
+ benchmarksExecuted: number;
125
+ benchmarksNotRun: number;
126
+ metrics: null | Record<string, unknown>;
127
+ };
128
+ expect(payload.experiencesLoaded).toBe(3);
129
+ expect(payload.distilledLessons).toBe(1);
130
+ expect(payload.hypothesesGenerated).toBe(1);
131
+ expect(payload.benchmarksExecuted).toBe(0);
132
+ expect(payload.benchmarksNotRun).toBe(1);
133
+ expect(payload.metrics).toBeNull();
134
+ });
135
+
136
+ it('persists distilled lessons to .ai-kit/state/memory.json', async () => {
137
+ const root = await tmpRoot();
138
+ await seedExperiences(root, [
139
+ failureRecord('EXP-001'),
140
+ failureRecord('EXP-002'),
141
+ failureRecord('EXP-003'),
142
+ ]);
143
+ const result = await evolveCommand.run(makeCtx(['--dry-run'], root));
144
+ expect(result.exitCode).toBe(0);
145
+ const memoryFile = path.join(root, '.ai-kit', 'state', 'memory.json');
146
+ const stored = JSON.parse(await fs.readFile(memoryFile, 'utf8')) as {
147
+ entries: Array<{ id: string; type: string; domain: string }>;
148
+ };
149
+ expect(stored.entries).toHaveLength(1);
150
+ expect(stored.entries[0]?.type).toBe('semantic');
151
+ expect(stored.entries[0]?.domain).toBe('node-typescript');
152
+ });
153
+ });
@@ -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
+ });
@@ -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 = fromFlag ?? (process.env['KIT_HOST'] && process.env['KIT_HOST'].length > 0
63
- ? process.env['KIT_HOST']
64
- : undefined);
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) return fail(ctx, `phase '${phase}' requires a task id (see \`kit feature ${featureId} status\`)`);
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
- opts.agentProviders ?? [new ClaudeCodeProvider({ projectRoot: root })];
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') return blocked(ctx, res.error.message);
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)',
@@ -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';
@@ -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: '0.9.1',
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: '0.9.1',
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 ? 'kit install: SUCCESS' : 'kit install: COMPLETED WITH PROBLEMS (see plugin status below)',
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
- 'plugin\'s TypeScript hooks module (hooks/register.ts) directly, so they',
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:',