@agentic-sdlc-kit/cli 0.0.0-stage → 0.9.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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/application/agent/execution-store.d.ts +55 -0
- package/dist/application/agent/execution-store.d.ts.map +1 -0
- package/dist/application/agent/execution-store.js +91 -0
- package/dist/application/agent/execution-store.js.map +1 -0
- package/dist/application/agent/gateway.d.ts +74 -0
- package/dist/application/agent/gateway.d.ts.map +1 -0
- package/dist/application/agent/gateway.js +580 -0
- package/dist/application/agent/gateway.js.map +1 -0
- package/dist/application/agent/index.d.ts +6 -0
- package/dist/application/agent/index.d.ts.map +1 -0
- package/dist/application/agent/index.js +18 -0
- package/dist/application/agent/index.js.map +1 -0
- package/dist/application/agent/orchestrator.d.ts +76 -0
- package/dist/application/agent/orchestrator.d.ts.map +1 -0
- package/dist/application/agent/orchestrator.js +422 -0
- package/dist/application/agent/orchestrator.js.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js +98 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js.map +1 -0
- package/dist/application/agent/providers/claude-code/index.d.ts +7 -0
- package/dist/application/agent/providers/claude-code/index.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/index.js +13 -0
- package/dist/application/agent/providers/claude-code/index.js.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js +41 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts +59 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.js +189 -0
- package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts +38 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.js +577 -0
- package/dist/application/agent/providers/claude-code/provider.js.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts +25 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.js +120 -0
- package/dist/application/agent/providers/claude-code/resume-store.js.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts +50 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js +129 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js.map +1 -0
- package/dist/application/agent/test-fixture.d.ts +15 -0
- package/dist/application/agent/test-fixture.d.ts.map +1 -0
- package/dist/application/agent/test-fixture.js +93 -0
- package/dist/application/agent/test-fixture.js.map +1 -0
- package/dist/application/agent/workspace.d.ts +24 -0
- package/dist/application/agent/workspace.d.ts.map +1 -0
- package/dist/application/agent/workspace.js +139 -0
- package/dist/application/agent/workspace.js.map +1 -0
- package/dist/application/dispatcher.d.ts +13 -0
- package/dist/application/dispatcher.d.ts.map +1 -0
- package/dist/application/dispatcher.js +116 -0
- package/dist/application/dispatcher.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/registry.d.ts +8 -0
- package/dist/application/registry.d.ts.map +1 -0
- package/dist/application/registry.js +17 -0
- package/dist/application/registry.js.map +1 -0
- package/dist/application/version.d.ts +2 -0
- package/dist/application/version.d.ts.map +1 -0
- package/dist/application/version.js +7 -0
- package/dist/application/version.js.map +1 -0
- package/dist/commands/attach-exclude.d.ts +8 -0
- package/dist/commands/attach-exclude.d.ts.map +1 -0
- package/dist/commands/attach-exclude.js +48 -0
- package/dist/commands/attach-exclude.js.map +1 -0
- package/dist/commands/attach-git.d.ts +11 -0
- package/dist/commands/attach-git.d.ts.map +1 -0
- package/dist/commands/attach-git.js +40 -0
- package/dist/commands/attach-git.js.map +1 -0
- package/dist/commands/attach-store.d.ts +10 -0
- package/dist/commands/attach-store.d.ts.map +1 -0
- package/dist/commands/attach-store.js +107 -0
- package/dist/commands/attach-store.js.map +1 -0
- package/dist/commands/attach.d.ts +8 -0
- package/dist/commands/attach.d.ts.map +1 -0
- package/dist/commands/attach.js +124 -0
- package/dist/commands/attach.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +68 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/elicit.d.ts +3 -0
- package/dist/commands/elicit.d.ts.map +1 -0
- package/dist/commands/elicit.js +163 -0
- package/dist/commands/elicit.js.map +1 -0
- package/dist/commands/evolve.d.ts +3 -0
- package/dist/commands/evolve.d.ts.map +1 -0
- package/dist/commands/evolve.js +165 -0
- package/dist/commands/evolve.js.map +1 -0
- package/dist/commands/feature.d.ts +13 -0
- package/dist/commands/feature.d.ts.map +1 -0
- package/dist/commands/feature.js +326 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/fix.d.ts +4 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +53 -0
- package/dist/commands/fix.js.map +1 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +32 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/host-apply.d.ts +12 -0
- package/dist/commands/host-apply.d.ts.map +1 -0
- package/dist/commands/host-apply.js +43 -0
- package/dist/commands/host-apply.js.map +1 -0
- package/dist/commands/host.d.ts +3 -0
- package/dist/commands/host.d.ts.map +1 -0
- package/dist/commands/host.js +107 -0
- package/dist/commands/host.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +26 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +64 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +337 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/journal.d.ts +3 -0
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/journal.js +107 -0
- package/dist/commands/journal.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +85 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +68 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/next.d.ts +3 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +107 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/optimize.d.ts +3 -0
- package/dist/commands/optimize.d.ts.map +1 -0
- package/dist/commands/optimize.js +28 -0
- package/dist/commands/optimize.js.map +1 -0
- package/dist/commands/plugin-linker.d.ts +43 -0
- package/dist/commands/plugin-linker.d.ts.map +1 -0
- package/dist/commands/plugin-linker.js +216 -0
- package/dist/commands/plugin-linker.js.map +1 -0
- package/dist/commands/refactor.d.ts +3 -0
- package/dist/commands/refactor.d.ts.map +1 -0
- package/dist/commands/refactor.js +32 -0
- package/dist/commands/refactor.js.map +1 -0
- package/dist/commands/skills-install-commit.d.ts +34 -0
- package/dist/commands/skills-install-commit.d.ts.map +1 -0
- package/dist/commands/skills-install-commit.js +113 -0
- package/dist/commands/skills-install-commit.js.map +1 -0
- package/dist/commands/skills-install-manifest.d.ts +35 -0
- package/dist/commands/skills-install-manifest.d.ts.map +1 -0
- package/dist/commands/skills-install-manifest.js +89 -0
- package/dist/commands/skills-install-manifest.js.map +1 -0
- package/dist/commands/skills-install-report.d.ts +12 -0
- package/dist/commands/skills-install-report.d.ts.map +1 -0
- package/dist/commands/skills-install-report.js +44 -0
- package/dist/commands/skills-install-report.js.map +1 -0
- package/dist/commands/skills-install-secure.d.ts +14 -0
- package/dist/commands/skills-install-secure.d.ts.map +1 -0
- package/dist/commands/skills-install-secure.js +96 -0
- package/dist/commands/skills-install-secure.js.map +1 -0
- package/dist/commands/skills-install.d.ts +15 -0
- package/dist/commands/skills-install.d.ts.map +1 -0
- package/dist/commands/skills-install.js +182 -0
- package/dist/commands/skills-install.js.map +1 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +217 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/types.d.ts +19 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/uninstall.d.ts +3 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +113 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/validate-plan.d.ts +3 -0
- package/dist/commands/validate-plan.d.ts.map +1 -0
- package/dist/commands/validate-plan.js +62 -0
- package/dist/commands/validate-plan.js.map +1 -0
- package/dist/commands/validate-spec.d.ts +3 -0
- package/dist/commands/validate-spec.d.ts.map +1 -0
- package/dist/commands/validate-spec.js +62 -0
- package/dist/commands/validate-spec.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +103 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +12 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/output/formatter.d.ts +2 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +10 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/index.d.ts +2 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +3 -0
- package/dist/output/index.js.map +1 -0
- package/package.json +37 -3
- package/src/application/agent/execution-store.ts +163 -0
- package/src/application/agent/gateway.test.ts +529 -0
- package/src/application/agent/gateway.ts +744 -0
- package/src/application/agent/index.ts +18 -0
- package/src/application/agent/orchestrator.test.ts +341 -0
- package/src/application/agent/orchestrator.ts +629 -0
- package/src/application/agent/providers/claude-code/claude-argv.ts +119 -0
- package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +139 -0
- package/src/application/agent/providers/claude-code/fixtures/fake-claude.mjs +125 -0
- package/src/application/agent/providers/claude-code/index.ts +28 -0
- package/src/application/agent/providers/claude-code/mod-parity.ts +50 -0
- package/src/application/agent/providers/claude-code/permission-config.test.ts +221 -0
- package/src/application/agent/providers/claude-code/permission-config.ts +242 -0
- package/src/application/agent/providers/claude-code/provider.test.ts +378 -0
- package/src/application/agent/providers/claude-code/provider.ts +717 -0
- package/src/application/agent/providers/claude-code/resume-store.test.ts +161 -0
- package/src/application/agent/providers/claude-code/resume-store.ts +157 -0
- package/src/application/agent/providers/claude-code/stream-parser.ts +166 -0
- package/src/application/agent/test-fixture.ts +131 -0
- package/src/application/agent/workspace.test.ts +104 -0
- package/src/application/agent/workspace.ts +156 -0
- package/src/application/dispatcher.test.ts +108 -0
- package/src/application/dispatcher.ts +106 -0
- package/src/application/index.ts +5 -0
- package/src/application/registry.ts +24 -0
- package/src/application/version.ts +7 -0
- package/src/commands/attach-exclude.ts +50 -0
- package/src/commands/attach-git.ts +50 -0
- package/src/commands/attach-store.ts +107 -0
- package/src/commands/attach.test.ts +192 -0
- package/src/commands/attach.ts +143 -0
- package/src/commands/clse.test.ts +181 -0
- package/src/commands/doctor.test.ts +29 -0
- package/src/commands/doctor.ts +78 -0
- package/src/commands/elicit.test.ts +111 -0
- package/src/commands/elicit.ts +188 -0
- package/src/commands/evolve.ts +209 -0
- package/src/commands/feature.test.ts +323 -0
- package/src/commands/feature.ts +405 -0
- package/src/commands/fix.test.ts +118 -0
- package/src/commands/fix.ts +58 -0
- package/src/commands/help.test.ts +33 -0
- package/src/commands/help.ts +35 -0
- package/src/commands/host-apply.ts +61 -0
- package/src/commands/host.test.ts +120 -0
- package/src/commands/host.ts +125 -0
- package/src/commands/index.ts +25 -0
- package/src/commands/init.test.ts +87 -0
- package/src/commands/init.ts +110 -0
- package/src/commands/inspect.test.ts +57 -0
- package/src/commands/inspect.ts +73 -0
- package/src/commands/install.test.ts +92 -0
- package/src/commands/install.ts +389 -0
- package/src/commands/journal.ts +118 -0
- package/src/commands/memory.ts +96 -0
- package/src/commands/new.test.ts +44 -0
- package/src/commands/new.ts +77 -0
- package/src/commands/next.test.ts +241 -0
- package/src/commands/next.ts +124 -0
- package/src/commands/optimize.ts +30 -0
- package/src/commands/plugin-linker.test.ts +219 -0
- package/src/commands/plugin-linker.ts +244 -0
- package/src/commands/refactor.ts +34 -0
- package/src/commands/skills-install-commit.ts +149 -0
- package/src/commands/skills-install-manifest.ts +124 -0
- package/src/commands/skills-install-report.ts +60 -0
- package/src/commands/skills-install-secure.ts +113 -0
- package/src/commands/skills-install.ts +245 -0
- package/src/commands/skills.test.ts +449 -0
- package/src/commands/skills.ts +247 -0
- package/src/commands/stack-commands.test.ts +67 -0
- package/src/commands/tier-c-conformance.test.ts +194 -0
- package/src/commands/types.ts +26 -0
- package/src/commands/uninstall.test.ts +122 -0
- package/src/commands/uninstall.ts +116 -0
- package/src/commands/validate-plan.test.ts +107 -0
- package/src/commands/validate-plan.ts +67 -0
- package/src/commands/validate-spec.test.ts +59 -0
- package/src/commands/validate-spec.ts +68 -0
- package/src/commands/verify.test.ts +117 -0
- package/src/commands/verify.ts +112 -0
- package/src/commands/version.test.ts +11 -0
- package/src/commands/version.ts +14 -0
- package/src/index.ts +30 -0
- package/src/output/formatter.ts +10 -0
- package/src/output/index.ts +2 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// packages/cli/src/commands/validate-plan.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit validate-plan [path] [--json]`.
|
|
4
|
+
// Validates an implementation plan against schema, DAG acyclicity, and vertical slices.
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadPlan, type PlanValidationResult } from '@agentic-sdlc-kit/core';
|
|
8
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
9
|
+
|
|
10
|
+
export const validatePlanCommand: Command = {
|
|
11
|
+
name: 'validate-plan',
|
|
12
|
+
summary: 'Validate an implementation plan against schema, DAG acyclicity, and task references.',
|
|
13
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
14
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
15
|
+
ctx.stdout(formatHelp());
|
|
16
|
+
return { exitCode: 0 };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const isJson = ctx.argv.includes('--json');
|
|
20
|
+
const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
|
|
21
|
+
const targetPath = path.resolve(ctx.cwd, targetArg ?? 'docs/plans');
|
|
22
|
+
|
|
23
|
+
const res = await loadPlan(targetPath);
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
if (isJson) {
|
|
26
|
+
ctx.stdout(JSON.stringify({ valid: false, error: res.error }, null, 2) + '\n');
|
|
27
|
+
} else {
|
|
28
|
+
ctx.stderr(`kit validate-plan: FAIL: ${res.error.message}\n`);
|
|
29
|
+
}
|
|
30
|
+
return { exitCode: 1, message: res.error.message };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (isJson) {
|
|
34
|
+
ctx.stdout(JSON.stringify({ valid: true, ...res.value }, null, 2) + '\n');
|
|
35
|
+
} else {
|
|
36
|
+
ctx.stdout(formatSuccessSummary(res.value));
|
|
37
|
+
}
|
|
38
|
+
return { exitCode: 0 };
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function formatSuccessSummary(val: PlanValidationResult): string {
|
|
43
|
+
const { plan, analysis } = val;
|
|
44
|
+
const highRisk = plan.tasks.filter((t) => t.risk === 'high').length;
|
|
45
|
+
const lines: string[] = [
|
|
46
|
+
`kit validate-plan: PASS`,
|
|
47
|
+
`Feature: ${plan.featureId}`,
|
|
48
|
+
`Tasks: ${plan.tasks.length} total (${highRisk} high risk)`,
|
|
49
|
+
`Slices: ${plan.verticalSlices.length} vertical slices`,
|
|
50
|
+
`Execution DAG: ${analysis.executionOrder.join(' -> ')}`,
|
|
51
|
+
];
|
|
52
|
+
return lines.join('\n') + '\n';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatHelp(): string {
|
|
56
|
+
return [
|
|
57
|
+
'Usage: kit validate-plan [path] [--json]',
|
|
58
|
+
'',
|
|
59
|
+
'Validate an implementation plan for schema compliance, task dependency integrity,',
|
|
60
|
+
'and acyclic execution order.',
|
|
61
|
+
'',
|
|
62
|
+
'Options:',
|
|
63
|
+
' --json Output machine-readable validation result',
|
|
64
|
+
' --help Show this message',
|
|
65
|
+
'',
|
|
66
|
+
].join('\n');
|
|
67
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// packages/cli/src/commands/validate-spec.test.ts
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { scaffoldSpecification } from '@agentic-sdlc-kit/core';
|
|
7
|
+
import { validateSpecCommand } from './validate-spec.js';
|
|
8
|
+
import type { CommandContext } from './types.js';
|
|
9
|
+
|
|
10
|
+
const makeCtx = (
|
|
11
|
+
argv: string[],
|
|
12
|
+
cwd: string,
|
|
13
|
+
): CommandContext & { out: string[]; err: string[] } => {
|
|
14
|
+
const out: string[] = [];
|
|
15
|
+
const err: string[] = [];
|
|
16
|
+
return {
|
|
17
|
+
argv,
|
|
18
|
+
cwd,
|
|
19
|
+
stdout: (s) => void out.push(s),
|
|
20
|
+
stderr: (s) => void err.push(s),
|
|
21
|
+
out,
|
|
22
|
+
err,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe('validateSpecCommand', () => {
|
|
27
|
+
it('shows help when --help is passed', async () => {
|
|
28
|
+
const ctx = makeCtx(['--help'], '/');
|
|
29
|
+
const r = await validateSpecCommand.run(ctx);
|
|
30
|
+
expect(r.exitCode).toBe(0);
|
|
31
|
+
expect(ctx.out[0]).toContain('Usage: kit validate-spec');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('validates a scaffolded specification successfully', async () => {
|
|
35
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-spec-'));
|
|
36
|
+
try {
|
|
37
|
+
const featureDir = await scaffoldSpecification({
|
|
38
|
+
id: 'FEATURE-001',
|
|
39
|
+
title: 'Test Feature',
|
|
40
|
+
targetDir: tmp,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const ctx = makeCtx([featureDir], tmp);
|
|
44
|
+
const r = await validateSpecCommand.run(ctx);
|
|
45
|
+
expect(r.exitCode).toBe(0);
|
|
46
|
+
expect(ctx.out[0]).toContain('kit validate-spec: PASS');
|
|
47
|
+
expect(ctx.out[0]).toContain('FEATURE-001');
|
|
48
|
+
} finally {
|
|
49
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('fails when specification file is invalid or missing', async () => {
|
|
54
|
+
const ctx = makeCtx(['/nonexistent/spec/path'], '/');
|
|
55
|
+
const r = await validateSpecCommand.run(ctx);
|
|
56
|
+
expect(r.exitCode).toBe(1);
|
|
57
|
+
expect(ctx.err[0]).toContain('kit validate-spec: FAIL');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// packages/cli/src/commands/validate-spec.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit validate-spec [path] [--json]`.
|
|
4
|
+
// Validates a feature specification against schema, acceptance criteria, and scope rules.
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { loadSpecification } from '@agentic-sdlc-kit/core';
|
|
8
|
+
import type { FeatureSpecification } from '@agentic-sdlc-kit/contracts';
|
|
9
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
10
|
+
|
|
11
|
+
export const validateSpecCommand: Command = {
|
|
12
|
+
name: 'validate-spec',
|
|
13
|
+
summary: 'Validate a feature specification against schema, quality, and risk invariants.',
|
|
14
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
15
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
16
|
+
ctx.stdout(formatHelp());
|
|
17
|
+
return { exitCode: 0 };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isJson = ctx.argv.includes('--json');
|
|
21
|
+
const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
|
|
22
|
+
const targetPath = path.resolve(ctx.cwd, targetArg ?? 'docs/specifications');
|
|
23
|
+
|
|
24
|
+
const res = await loadSpecification(targetPath);
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
if (isJson) {
|
|
27
|
+
ctx.stdout(JSON.stringify({ valid: false, error: res.error }, null, 2) + '\n');
|
|
28
|
+
} else {
|
|
29
|
+
ctx.stderr(`kit validate-spec: FAIL: ${res.error.message}\n`);
|
|
30
|
+
}
|
|
31
|
+
return { exitCode: 1, message: res.error.message };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (isJson) {
|
|
35
|
+
ctx.stdout(JSON.stringify({ valid: true, specification: res.value }, null, 2) + '\n');
|
|
36
|
+
} else {
|
|
37
|
+
ctx.stdout(formatSuccessSummary(res.value));
|
|
38
|
+
}
|
|
39
|
+
return { exitCode: 0 };
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function formatSuccessSummary(spec: FeatureSpecification): string {
|
|
44
|
+
const lines: string[] = [
|
|
45
|
+
`kit validate-spec: PASS`,
|
|
46
|
+
`Feature: ${spec.id} - ${spec.title}`,
|
|
47
|
+
`Scope: ${spec.scope.in.length} in-scope, ${spec.scope.out.length} out-of-scope`,
|
|
48
|
+
`Requirements: ${spec.functionalRequirements.length} functional, ${spec.nonFunctionalRequirements.length} non-functional`,
|
|
49
|
+
`Acceptance: ${spec.acceptanceCriteria.length} criteria defined`,
|
|
50
|
+
`Risks: ${spec.risks.length} analyzed (${spec.risks.filter((r) => r.severity === 'high').length} high)`,
|
|
51
|
+
`Open Questions:${spec.openQuestions.length} (${spec.openQuestions.filter((q) => !q.resolved).length} unresolved)`,
|
|
52
|
+
];
|
|
53
|
+
return lines.join('\n') + '\n';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function formatHelp(): string {
|
|
57
|
+
return [
|
|
58
|
+
'Usage: kit validate-spec [path] [--json]',
|
|
59
|
+
'',
|
|
60
|
+
'Validate a feature specification (SPEC.md or JSON) for structural completeness,',
|
|
61
|
+
'scope boundaries, ID uniqueness, and risk governance.',
|
|
62
|
+
'',
|
|
63
|
+
'Options:',
|
|
64
|
+
' --json Output machine-readable validation result',
|
|
65
|
+
' --help Show this message',
|
|
66
|
+
'',
|
|
67
|
+
].join('\n');
|
|
68
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// packages/cli/src/commands/verify.test.ts
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { serializeProfileYaml } from '@agentic-sdlc-kit/core';
|
|
7
|
+
import type { ProjectProfile } from '@agentic-sdlc-kit/contracts';
|
|
8
|
+
import { verifyCommand } from './verify.js';
|
|
9
|
+
import type { CommandContext } from './types.js';
|
|
10
|
+
|
|
11
|
+
const makeCtx = (
|
|
12
|
+
argv: string[],
|
|
13
|
+
cwd: string,
|
|
14
|
+
): CommandContext & { out: string[]; err: string[] } => {
|
|
15
|
+
const out: string[] = [];
|
|
16
|
+
const err: string[] = [];
|
|
17
|
+
return {
|
|
18
|
+
argv,
|
|
19
|
+
cwd,
|
|
20
|
+
stdout: (s) => void out.push(s),
|
|
21
|
+
stderr: (s) => void err.push(s),
|
|
22
|
+
out,
|
|
23
|
+
err,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('verifyCommand', () => {
|
|
28
|
+
it('shows help when --help is passed', async () => {
|
|
29
|
+
const ctx = makeCtx(['--help'], '/');
|
|
30
|
+
const r = await verifyCommand.run(ctx);
|
|
31
|
+
expect(r.exitCode).toBe(0);
|
|
32
|
+
expect(ctx.out[0]).toContain('Usage: kit verify');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('fails if .ai-kit/project.yml does not exist', async () => {
|
|
36
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-empty-'));
|
|
37
|
+
try {
|
|
38
|
+
const ctx = makeCtx([], tmp);
|
|
39
|
+
const r = await verifyCommand.run(ctx);
|
|
40
|
+
expect(r.exitCode).toBe(1);
|
|
41
|
+
expect(ctx.err[0]).toContain('Profile not found');
|
|
42
|
+
} finally {
|
|
43
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('executes configured verification commands and passes', async () => {
|
|
48
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-pass-'));
|
|
49
|
+
try {
|
|
50
|
+
const aiKitDir = path.join(tmp, '.ai-kit');
|
|
51
|
+
await fs.mkdir(aiKitDir, { recursive: true });
|
|
52
|
+
|
|
53
|
+
const profile: ProjectProfile = {
|
|
54
|
+
schemaVersion: 1,
|
|
55
|
+
name: 'test-cli-app',
|
|
56
|
+
stack: ['node-typescript'],
|
|
57
|
+
commands: {
|
|
58
|
+
test: [['node', '-e', 'process.exit(0)']],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
await fs.writeFile(path.join(aiKitDir, 'project.yml'), serializeProfileYaml(profile), 'utf8');
|
|
62
|
+
|
|
63
|
+
const ctx = makeCtx([], tmp);
|
|
64
|
+
const r = await verifyCommand.run(ctx);
|
|
65
|
+
expect(r.exitCode).toBe(0);
|
|
66
|
+
expect(ctx.out[0]).toContain('Status: PASSED');
|
|
67
|
+
} finally {
|
|
68
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('surfaces schema issues when the profile fails validation (no bare error)', async () => {
|
|
73
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-schema-'));
|
|
74
|
+
try {
|
|
75
|
+
const aiKitDir = path.join(tmp, '.ai-kit');
|
|
76
|
+
await fs.mkdir(aiKitDir, { recursive: true });
|
|
77
|
+
// stack: [] violates the contract (min 1 entry) — the CLI must say
|
|
78
|
+
// WHY, not just "failed schema validation".
|
|
79
|
+
await fs.writeFile(
|
|
80
|
+
path.join(aiKitDir, 'project.yml'),
|
|
81
|
+
['schemaVersion: 1', 'name: "x"', 'stack: []', ''].join('\n'),
|
|
82
|
+
'utf8',
|
|
83
|
+
);
|
|
84
|
+
const ctx = makeCtx([], tmp);
|
|
85
|
+
const r = await verifyCommand.run(ctx);
|
|
86
|
+
expect(r.exitCode).toBe(1);
|
|
87
|
+
expect(ctx.err[0]).toContain('failed schema validation');
|
|
88
|
+
expect(ctx.err[0]).toContain('stack');
|
|
89
|
+
expect(ctx.err[0]).toContain('at least one entry');
|
|
90
|
+
} finally {
|
|
91
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('hints at the expected commands shape when zero checks are configured', async () => {
|
|
96
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'kit-cli-verify-zero-'));
|
|
97
|
+
try {
|
|
98
|
+
const aiKitDir = path.join(tmp, '.ai-kit');
|
|
99
|
+
await fs.mkdir(aiKitDir, { recursive: true });
|
|
100
|
+
const profile: ProjectProfile = {
|
|
101
|
+
schemaVersion: 1,
|
|
102
|
+
name: 'zero-checks-app',
|
|
103
|
+
stack: ['node-typescript'],
|
|
104
|
+
commands: {},
|
|
105
|
+
};
|
|
106
|
+
await fs.writeFile(path.join(aiKitDir, 'project.yml'), serializeProfileYaml(profile), 'utf8');
|
|
107
|
+
|
|
108
|
+
const ctx = makeCtx([], tmp);
|
|
109
|
+
const r = await verifyCommand.run(ctx);
|
|
110
|
+
expect(r.exitCode).toBe(1);
|
|
111
|
+
expect(ctx.out[0]).toContain('(none configured)');
|
|
112
|
+
expect(ctx.out[0]).toContain('commands:');
|
|
113
|
+
} finally {
|
|
114
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// packages/cli/src/commands/verify.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit verify [path] [--dry-run] [--json]`.
|
|
4
|
+
// Deterministic verification runner executing configured test, lint, and typecheck commands.
|
|
5
|
+
|
|
6
|
+
import { promises as fs } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { parseProfileYaml, ProcessVerificationRunner } from '@agentic-sdlc-kit/core';
|
|
9
|
+
import type { VerificationReport } from '@agentic-sdlc-kit/contracts';
|
|
10
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
11
|
+
|
|
12
|
+
export const verifyCommand: Command = {
|
|
13
|
+
name: 'verify',
|
|
14
|
+
summary: 'Execute deterministic verification commands (tests, lint, typecheck, build).',
|
|
15
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
16
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
17
|
+
ctx.stdout(formatHelp());
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const isJson = ctx.argv.includes('--json');
|
|
22
|
+
const isDryRun = ctx.argv.includes('--dry-run');
|
|
23
|
+
const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
|
|
24
|
+
const targetRoot = path.resolve(ctx.cwd, targetArg ?? '.');
|
|
25
|
+
const profilePath = path.join(targetRoot, '.ai-kit', 'project.yml');
|
|
26
|
+
|
|
27
|
+
let yamlContent: string;
|
|
28
|
+
try {
|
|
29
|
+
yamlContent = await fs.readFile(profilePath, 'utf8');
|
|
30
|
+
} catch {
|
|
31
|
+
const msg = `Profile not found at ${profilePath}. Run 'kit init' first.`;
|
|
32
|
+
ctx.stderr(`kit verify: ${msg}\n`);
|
|
33
|
+
return { exitCode: 1, message: msg };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const profileRes = parseProfileYaml(yamlContent);
|
|
37
|
+
if (!profileRes.ok) {
|
|
38
|
+
// Surface the structured issues (e.g. zod paths) when present — a
|
|
39
|
+
// bare "failed schema validation" with no reasons hides the cause.
|
|
40
|
+
const issues = profileRes.error.details?.issues;
|
|
41
|
+
let msg = profileRes.error.message;
|
|
42
|
+
if (Array.isArray(issues) && issues.length > 0) {
|
|
43
|
+
const rendered = issues
|
|
44
|
+
.map((i) => {
|
|
45
|
+
const issue = i as { path?: unknown; message?: unknown };
|
|
46
|
+
const at = typeof issue.path === 'string' && issue.path ? ` at '${issue.path}'` : '';
|
|
47
|
+
return `${at}: ${String(issue.message ?? 'invalid')}`.trim();
|
|
48
|
+
})
|
|
49
|
+
.join('; ');
|
|
50
|
+
msg = `${msg} (${rendered})`;
|
|
51
|
+
}
|
|
52
|
+
ctx.stderr(`kit verify: ${msg}\n`);
|
|
53
|
+
return { exitCode: 1, message: msg };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const runner = new ProcessVerificationRunner();
|
|
57
|
+
const repRes = await runner.run(profileRes.value, { cwd: targetRoot, dryRun: isDryRun });
|
|
58
|
+
if (!repRes.ok) {
|
|
59
|
+
ctx.stderr(`kit verify: runner error: ${repRes.error.message}\n`);
|
|
60
|
+
return { exitCode: 1, message: repRes.error.message };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const report = repRes.value;
|
|
64
|
+
if (isJson) {
|
|
65
|
+
ctx.stdout(JSON.stringify(report, null, 2) + '\n');
|
|
66
|
+
} else {
|
|
67
|
+
ctx.stdout(formatReportSummary(report));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { exitCode: report.status === 'passed' ? 0 : 1 };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function formatReportSummary(report: VerificationReport): string {
|
|
75
|
+
const lines: string[] = [
|
|
76
|
+
`Verification Run: ${report.runId}`,
|
|
77
|
+
`Status: ${report.status.toUpperCase()}`,
|
|
78
|
+
`Checks:`,
|
|
79
|
+
];
|
|
80
|
+
for (const c of report.checks) {
|
|
81
|
+
const dur = c.durationMs !== undefined ? ` (${c.durationMs}ms)` : '';
|
|
82
|
+
const cmdStr = c.command ? ` [${c.command.join(' ')}]` : '';
|
|
83
|
+
lines.push(` - ${c.id.padEnd(12)} ${c.status.toUpperCase()}${dur}${cmdStr}`);
|
|
84
|
+
}
|
|
85
|
+
if (report.checks.length === 0) {
|
|
86
|
+
// Zero checks usually means the profile's commands were not parsed.
|
|
87
|
+
// Surface the likely cause instead of a bare BLOCKED.
|
|
88
|
+
lines.push(' (none configured)');
|
|
89
|
+
lines.push('');
|
|
90
|
+
lines.push(' No verification commands were found. Check that');
|
|
91
|
+
lines.push(' .ai-kit/project.yml has a commands section, e.g.:');
|
|
92
|
+
lines.push(' commands:');
|
|
93
|
+
lines.push(' test:');
|
|
94
|
+
lines.push(" - ['node', '--test']");
|
|
95
|
+
}
|
|
96
|
+
return lines.join('\n') + '\n';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function formatHelp(): string {
|
|
100
|
+
return [
|
|
101
|
+
'Usage: kit verify [path] [--dry-run] [--json]',
|
|
102
|
+
'',
|
|
103
|
+
'Execute deterministic verification checks configured in .ai-kit/project.yml.',
|
|
104
|
+
'Commands run with shell: false and bounded timeouts.',
|
|
105
|
+
'',
|
|
106
|
+
'Options:',
|
|
107
|
+
' --dry-run Mark checks as skipped without executing processes',
|
|
108
|
+
' --json Output full machine-readable VerificationReport',
|
|
109
|
+
' --help Show this message',
|
|
110
|
+
'',
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// packages/cli/src/commands/version.test.ts
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { versionCommand } from './version.js';
|
|
4
|
+
|
|
5
|
+
describe('versionCommand', () => {
|
|
6
|
+
it('returns the version with exit code 0', () => {
|
|
7
|
+
const r = versionCommand.run({ argv: [], cwd: '/', stdout: () => {}, stderr: () => {} });
|
|
8
|
+
expect(r.exitCode).toBe(0);
|
|
9
|
+
expect(r.message).toMatch(/^\d+\.\d+\.\d+$/);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// packages/cli/src/commands/version.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit --version` / `kit version`. Prints the package version.
|
|
4
|
+
|
|
5
|
+
import { VERSION } from '../application/version.js';
|
|
6
|
+
import type { Command, CommandResult } from './types.js';
|
|
7
|
+
|
|
8
|
+
export const versionCommand: Command = {
|
|
9
|
+
name: 'version',
|
|
10
|
+
summary: 'Print the kit version.',
|
|
11
|
+
run(): CommandResult {
|
|
12
|
+
return { exitCode: 0, message: VERSION };
|
|
13
|
+
},
|
|
14
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// packages/cli/src/index.ts
|
|
3
|
+
//
|
|
4
|
+
// `kit` executable entry point. Parses argv, dispatches to a command,
|
|
5
|
+
// prints output, and exits.
|
|
6
|
+
|
|
7
|
+
import { createDispatcher } from './application/dispatcher.js';
|
|
8
|
+
import type { CommandContext } from './commands/types.js';
|
|
9
|
+
|
|
10
|
+
async function main(): Promise<void> {
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
const ctx: CommandContext = {
|
|
13
|
+
argv,
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
stdout: (s: string) => process.stdout.write(s + '\n'),
|
|
16
|
+
stderr: (s: string) => process.stderr.write(s + '\n'),
|
|
17
|
+
};
|
|
18
|
+
const { dispatch } = createDispatcher();
|
|
19
|
+
const result = await dispatch(ctx);
|
|
20
|
+
if (result.message && result.command !== 'help' && result.command !== 'doctor') {
|
|
21
|
+
// help and doctor write their own output; everything else prints the message.
|
|
22
|
+
process.stdout.write(result.message + '\n');
|
|
23
|
+
}
|
|
24
|
+
process.exit(result.exitCode);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main().catch((e) => {
|
|
28
|
+
process.stderr.write(`kit: internal error: ${String(e)}\n`);
|
|
29
|
+
process.exit(2);
|
|
30
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// packages/cli/src/output/formatter.ts
|
|
2
|
+
//
|
|
3
|
+
// Minimal output formatter. M1 keeps this trivial; later milestones add
|
|
4
|
+
// structured JSON output and machine-readable formats.
|
|
5
|
+
|
|
6
|
+
export function formatLine(label: string, value: string, status?: 'ok' | 'fail'): string {
|
|
7
|
+
const tag = status === 'ok' ? '[ok]' : status === 'fail' ? '[FAIL]' : '';
|
|
8
|
+
const pad = ' '.repeat(Math.max(0, 14 - label.length));
|
|
9
|
+
return ` ${label}${pad}${value}${tag ? ` ${tag}` : ''}`;
|
|
10
|
+
}
|