@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.
Files changed (144) 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/feature.test.ts +36 -4
  126. package/src/commands/feature.ts +71 -8
  127. package/src/commands/index.ts +8 -0
  128. package/src/commands/install.ts +7 -4
  129. package/src/commands/knowledge.test.ts +39 -0
  130. package/src/commands/knowledge.ts +63 -0
  131. package/src/commands/learning.test.ts +104 -0
  132. package/src/commands/learning.ts +134 -0
  133. package/src/commands/mcp.ts +30 -0
  134. package/src/commands/next.ts +3 -1
  135. package/src/commands/onboard.test.ts +83 -0
  136. package/src/commands/onboard.ts +146 -0
  137. package/src/commands/routing.test.ts +64 -0
  138. package/src/commands/routing.ts +107 -0
  139. package/src/commands/rules-format.ts +22 -0
  140. package/src/commands/rules.test.ts +153 -0
  141. package/src/commands/rules.ts +286 -0
  142. package/src/commands/verify.test.ts +115 -0
  143. package/src/commands/verify.ts +95 -7
  144. package/src/commands/version.test.ts +9 -0
@@ -69,6 +69,89 @@ describe('verifyCommand', () => {
69
69
  }
70
70
  });
71
71
 
72
+ it('records the last verification report under the state directory', async () => {
73
+ const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-record-'));
74
+ try {
75
+ await fs.mkdir(path.join(tmp, '.ai-kit'), { recursive: true });
76
+ const profile: ProjectProfile = {
77
+ schemaVersion: 1,
78
+ name: 'test-cli-app',
79
+ stack: ['node-typescript'],
80
+ commands: { test: [['node', '-e', 'process.exit(0)']] },
81
+ };
82
+ await fs.writeFile(path.join(tmp, '.ai-kit', 'project.yml'), serializeProfileYaml(profile), 'utf8');
83
+ await verifyCommand.run(makeCtx([], tmp));
84
+ const recorded = JSON.parse(
85
+ await fs.readFile(path.join(tmp, '.ai-kit', 'state', 'last-verify.json'), 'utf8'),
86
+ );
87
+ expect(recorded.status).toBe('passed');
88
+ const events = await fs.readFile(
89
+ path.join(tmp, '.ai-kit', 'state', 'learning', 'events.jsonl'),
90
+ 'utf8',
91
+ );
92
+ const learned = JSON.parse(events.trim().split('\n').at(-1) ?? '{}');
93
+ expect(learned.taskType).toBe('verify');
94
+ expect(learned.outcome).toBe('passed');
95
+ } finally {
96
+ await fs.rm(tmp, { recursive: true, force: true });
97
+ }
98
+ });
99
+
100
+ it('fails verification when a blocking constitution rule is violated (ADR-0023)', async () => {
101
+ const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-rules-'));
102
+ try {
103
+ const aiKitDir = path.join(tmp, '.ai-kit');
104
+ await fs.mkdir(path.join(aiKitDir, 'constitution', 'rules'), { recursive: true });
105
+ const profile: ProjectProfile = {
106
+ schemaVersion: 1,
107
+ name: 'test-cli-app',
108
+ stack: ['node-typescript'],
109
+ commands: { test: [['node', '-e', 'process.exit(0)']] },
110
+ };
111
+ await fs.writeFile(path.join(aiKitDir, 'project.yml'), serializeProfileYaml(profile), 'utf8');
112
+ await fs.writeFile(
113
+ path.join(aiKitDir, 'constitution', 'rules', 'ARCH-CORE-001.yml'),
114
+ [
115
+ 'schemaVersion: 1',
116
+ 'id: ARCH-CORE-001',
117
+ 'title: t',
118
+ 'statement: s',
119
+ 'rationale: r',
120
+ 'scope:',
121
+ ' paths:',
122
+ ' - "packages/core/src/**/*.ts"',
123
+ 'status: active',
124
+ 'mode: blocking',
125
+ 'check:',
126
+ ' kind: import-boundary',
127
+ ' from: "@agentic-sdlc-kit/"',
128
+ ' allow:',
129
+ ' - "@agentic-sdlc-kit/contracts"',
130
+ 'source: declared',
131
+ 'confidence: 1',
132
+ 'owner: architecture',
133
+ '',
134
+ ].join('\n'),
135
+ );
136
+ await fs.mkdir(path.join(tmp, 'packages', 'core', 'src'), { recursive: true });
137
+ const source = await fs.readFile(
138
+ new URL('../../../core/src/constitution/fixtures/core-imports-cli.txt', import.meta.url),
139
+ 'utf8',
140
+ );
141
+ await fs.writeFile(path.join(tmp, 'packages', 'core', 'src', 'a.ts'), source, 'utf8');
142
+
143
+ const ctx = makeCtx([], tmp);
144
+ const r = await verifyCommand.run(ctx);
145
+ expect(r.exitCode).toBe(1);
146
+ const text = ctx.out.join('');
147
+ expect(text).toContain('Status: FAILED');
148
+ expect(text).toContain('constitution');
149
+ expect(text).toContain('packages/core/src/a.ts:1');
150
+ } finally {
151
+ await fs.rm(tmp, { recursive: true, force: true });
152
+ }
153
+ });
154
+
72
155
  it('surfaces schema issues when the profile fails validation (no bare error)', async () => {
73
156
  const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-schema-'));
74
157
  try {
@@ -115,3 +198,35 @@ describe('verifyCommand', () => {
115
198
  }
116
199
  });
117
200
  });
201
+
202
+ describe('verifyCommand --strength (ADR-0022)', () => {
203
+ it('fails closed with an honest error for a stack without a mutation adapter', async () => {
204
+ const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-strength-'));
205
+ try {
206
+ const aiKitDir = path.join(tmp, '.ai-kit');
207
+ await fs.mkdir(aiKitDir, { recursive: true });
208
+ const profile: ProjectProfile = {
209
+ schemaVersion: 1,
210
+ name: 'strength-cli-app',
211
+ stack: ['cobol'], // no adapter — must fail honestly, never silently skip
212
+ commands: { test: [['node', '-e', 'process.exit(0)']] },
213
+ };
214
+ await fs.writeFile(path.join(aiKitDir, 'project.yml'), serializeProfileYaml(profile), 'utf8');
215
+
216
+ const ctx = makeCtx(['--strength'], tmp);
217
+ const r = await verifyCommand.run(ctx);
218
+ expect(r.exitCode).toBe(1);
219
+ expect(ctx.err[0]).toContain('not supported');
220
+ expect(ctx.err[0]).toContain('cobol');
221
+ } finally {
222
+ await fs.rm(tmp, { recursive: true, force: true });
223
+ }
224
+ });
225
+
226
+ it('mentions --strength in help output', async () => {
227
+ const ctx = makeCtx(['--help'], '/');
228
+ await verifyCommand.run(ctx);
229
+ expect(ctx.out[0]).toContain('--strength');
230
+ expect(ctx.out[0]).toContain('ADR-0022');
231
+ });
232
+ });
@@ -1,13 +1,30 @@
1
1
  // packages/cli/src/commands/verify.ts
2
2
  //
3
- // `kit verify [path] [--dry-run] [--json]`.
3
+ // `kit verify [path] [--dry-run] [--json] [--strength]`.
4
4
  // Deterministic verification runner executing configured test, lint, and typecheck commands.
5
+ // `--strength` additionally runs the optional mutation-score stage (ADR-0022).
5
6
 
6
7
  import { promises as fs } from 'node:fs';
7
8
  import path from 'node:path';
8
- import { parseProfileYaml, ProcessVerificationRunner } from '@agentic-sdlc-kit/core';
9
- import type { VerificationReport } from '@agentic-sdlc-kit/contracts';
9
+ import {
10
+ applyConstitution,
11
+ evaluateConstitution,
12
+ parseProfileYaml,
13
+ ProcessVerificationRunner,
14
+ appendLearningEvent,
15
+ learningEventFromReport,
16
+ recordLastVerify,
17
+ runStrengthCheck,
18
+ } from '@agentic-sdlc-kit/core';
19
+ import {
20
+ DEFAULT_STRENGTH_SETTINGS,
21
+ evaluateStrengthGate,
22
+ type StrengthEvidence,
23
+ type VerificationReport,
24
+ } from '@agentic-sdlc-kit/contracts';
10
25
  import type { Command, CommandContext, CommandResult } from './types.js';
26
+ import { constitutionAdapters } from '../application/rule-adapters/index.js';
27
+ import { formatRuleResultLine, formatViolationLines } from './rules-format.js';
11
28
 
12
29
  export const verifyCommand: Command = {
13
30
  name: 'verify',
@@ -20,6 +37,7 @@ export const verifyCommand: Command = {
20
37
 
21
38
  const isJson = ctx.argv.includes('--json');
22
39
  const isDryRun = ctx.argv.includes('--dry-run');
40
+ const withStrength = ctx.argv.includes('--strength');
23
41
  const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
24
42
  const targetRoot = path.resolve(ctx.cwd, targetArg ?? '.');
25
43
  const profilePath = path.join(targetRoot, '.ai-kit', 'project.yml');
@@ -60,14 +78,62 @@ export const verifyCommand: Command = {
60
78
  return { exitCode: 1, message: repRes.error.message };
61
79
  }
62
80
 
63
- const report = repRes.value;
81
+ // ADR-0023: the constitution is one more check, plus per-rule detail.
82
+ // A project with no .ai-kit/constitution/rules is unaffected.
83
+ const constitution = await evaluateConstitution({
84
+ projectRoot: targetRoot,
85
+ stacks: profileRes.value.stack,
86
+ adapters: constitutionAdapters(),
87
+ });
88
+ const report = applyConstitution(repRes.value, constitution);
89
+ // The last report is evidence for context and status tools. Failing to
90
+ // record it is a warning: it must not change the verdict of this run.
91
+ const recorded = await recordLastVerify(targetRoot, report);
92
+ if (!recorded.ok) ctx.stderr(`kit verify: warning: ${recorded.error.message}\n`);
93
+ // The same run, as a privacy-safe learning event (ADR-0025 / roadmap Phase 6). Non-fatal.
94
+ const learned = await appendLearningEvent(
95
+ targetRoot,
96
+ learningEventFromReport(report, profileRes.value.stack, new Date()),
97
+ );
98
+ if (!learned.ok) ctx.stderr(`kit verify: warning: ${learned.error.message}\n`);
99
+
100
+ // Optional strength stage (ADR-0022): `--strength` runs the mutation
101
+ // tool under the profile's budget. Disabled-by-default stays honest —
102
+ // the flag also honors an explicit profile `enabled: true` run.
103
+ let strength: StrengthEvidence | undefined;
104
+ let strengthBlocked = false;
105
+ if (withStrength) {
106
+ const settings = profileRes.value.verification?.strength ?? {
107
+ ...DEFAULT_STRENGTH_SETTINGS,
108
+ enabled: true, // explicit flag is the opt-in
109
+ };
110
+ const strengthRes = await runStrengthCheck({
111
+ cwd: targetRoot,
112
+ stack: profileRes.value.stack[0] ?? '',
113
+ settings: { ...settings, enabled: true },
114
+ scopeFiles: [],
115
+ });
116
+ if (!strengthRes.ok) {
117
+ ctx.stderr(`kit verify --strength: ${strengthRes.error.message}\n`);
118
+ return { exitCode: 1, message: strengthRes.error.message };
119
+ }
120
+ strength = strengthRes.value;
121
+ strengthBlocked = evaluateStrengthGate(strength, settings.gateMode).block;
122
+ }
123
+
64
124
  if (isJson) {
65
- ctx.stdout(JSON.stringify(report, null, 2) + '\n');
125
+ const reportJson: Record<string, unknown> = { ...report };
126
+ if (strength !== undefined) {
127
+ reportJson['strength'] = strength;
128
+ }
129
+ ctx.stdout(JSON.stringify(reportJson, null, 2) + '\n');
66
130
  } else {
67
131
  ctx.stdout(formatReportSummary(report));
132
+ if (strength !== undefined) ctx.stdout(formatStrengthSummary(strength));
68
133
  }
69
134
 
70
- return { exitCode: report.status === 'passed' ? 0 : 1 };
135
+ const exitCode = report.status === 'passed' && !strengthBlocked ? 0 : 1;
136
+ return { exitCode };
71
137
  },
72
138
  };
73
139
 
@@ -82,6 +148,13 @@ function formatReportSummary(report: VerificationReport): string {
82
148
  const cmdStr = c.command ? ` [${c.command.join(' ')}]` : '';
83
149
  lines.push(` - ${c.id.padEnd(12)} ${c.status.toUpperCase()}${dur}${cmdStr}`);
84
150
  }
151
+ if (report.rules && report.rules.length > 0) {
152
+ lines.push('Rules:');
153
+ for (const r of report.rules) {
154
+ lines.push(formatRuleResultLine(r));
155
+ lines.push(...formatViolationLines(r));
156
+ }
157
+ }
85
158
  if (report.checks.length === 0) {
86
159
  // Zero checks usually means the profile's commands were not parsed.
87
160
  // Surface the likely cause instead of a bare BLOCKED.
@@ -96,9 +169,21 @@ function formatReportSummary(report: VerificationReport): string {
96
169
  return lines.join('\n') + '\n';
97
170
  }
98
171
 
172
+ function formatStrengthSummary(strength: StrengthEvidence): string {
173
+ const score = strength.score !== undefined ? `${strength.score}%` : 'n/a';
174
+ const lines: string[] = [
175
+ `Strength: ${strength.status.toUpperCase()} (score ${score} vs threshold ${strength.threshold}%)`,
176
+ ` tool=${strength.tool} scope=${strength.scope} mutants=${strength.mutantsKilled}/${strength.mutantsGenerated} killed`,
177
+ ` budget=${strength.budgetMs}ms duration=${strength.durationMs}ms`,
178
+ ` ${strength.summary}`,
179
+ '',
180
+ ];
181
+ return lines.join('\n') + '\n';
182
+ }
183
+
99
184
  function formatHelp(): string {
100
185
  return [
101
- 'Usage: kit verify [path] [--dry-run] [--json]',
186
+ 'Usage: kit verify [path] [--dry-run] [--json] [--strength]',
102
187
  '',
103
188
  'Execute deterministic verification checks configured in .ai-kit/project.yml.',
104
189
  'Commands run with shell: false and bounded timeouts.',
@@ -106,6 +191,9 @@ function formatHelp(): string {
106
191
  'Options:',
107
192
  ' --dry-run Mark checks as skipped without executing processes',
108
193
  ' --json Output full machine-readable VerificationReport',
194
+ ' --strength Additionally run the mutation-score stage (ADR-0022);',
195
+ ' budgeted by verification.strength.budgetMs; exit 1 when',
196
+ ' gateMode enforce and below threshold',
109
197
  ' --help Show this message',
110
198
  '',
111
199
  ].join('\n');
@@ -1,6 +1,8 @@
1
1
  // packages/cli/src/commands/version.test.ts
2
+ import { createRequire } from 'node:module';
2
3
  import { describe, expect, it } from 'vitest';
3
4
  import { versionCommand } from './version.js';
5
+ import { VERSION } from '../application/version.js';
4
6
 
5
7
  describe('versionCommand', () => {
6
8
  it('returns the version with exit code 0', () => {
@@ -8,4 +10,11 @@ describe('versionCommand', () => {
8
10
  expect(r.exitCode).toBe(0);
9
11
  expect(r.message).toMatch(/^\d+\.\d+\.\d+$/);
10
12
  });
13
+
14
+ it('never drifts from the package.json version', () => {
15
+ // Regression pin for the M1 hard-code drift (#88): the CLI must always
16
+ // report whatever version package.json carries.
17
+ const pkg = createRequire(import.meta.url)('../../package.json') as { version: string };
18
+ expect(VERSION).toBe(pkg.version);
19
+ });
11
20
  });