@agentic-sdlc-kit/cli 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/application/agent/execution-store.d.ts +55 -0
- package/dist/application/agent/execution-store.d.ts.map +1 -0
- package/dist/application/agent/execution-store.js +90 -0
- package/dist/application/agent/execution-store.js.map +1 -0
- package/dist/application/agent/gateway.d.ts +74 -0
- package/dist/application/agent/gateway.d.ts.map +1 -0
- package/dist/application/agent/gateway.js +580 -0
- package/dist/application/agent/gateway.js.map +1 -0
- package/dist/application/agent/index.d.ts +6 -0
- package/dist/application/agent/index.d.ts.map +1 -0
- package/dist/application/agent/index.js +18 -0
- package/dist/application/agent/index.js.map +1 -0
- package/dist/application/agent/orchestrator.d.ts +76 -0
- package/dist/application/agent/orchestrator.d.ts.map +1 -0
- package/dist/application/agent/orchestrator.js +422 -0
- package/dist/application/agent/orchestrator.js.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js +98 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js.map +1 -0
- package/dist/application/agent/providers/claude-code/index.d.ts +7 -0
- package/dist/application/agent/providers/claude-code/index.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/index.js +13 -0
- package/dist/application/agent/providers/claude-code/index.js.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js +41 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts +59 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.js +189 -0
- package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts +38 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.js +577 -0
- package/dist/application/agent/providers/claude-code/provider.js.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts +25 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.js +120 -0
- package/dist/application/agent/providers/claude-code/resume-store.js.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts +50 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js +129 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js.map +1 -0
- package/dist/application/agent/test-fixture.d.ts +15 -0
- package/dist/application/agent/test-fixture.d.ts.map +1 -0
- package/dist/application/agent/test-fixture.js +93 -0
- package/dist/application/agent/test-fixture.js.map +1 -0
- package/dist/application/agent/workspace.d.ts +24 -0
- package/dist/application/agent/workspace.d.ts.map +1 -0
- package/dist/application/agent/workspace.js +139 -0
- package/dist/application/agent/workspace.js.map +1 -0
- package/dist/application/dispatcher.d.ts +13 -0
- package/dist/application/dispatcher.d.ts.map +1 -0
- package/dist/application/dispatcher.js +104 -0
- package/dist/application/dispatcher.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/registry.d.ts +8 -0
- package/dist/application/registry.d.ts.map +1 -0
- package/dist/application/registry.js +17 -0
- package/dist/application/registry.js.map +1 -0
- package/dist/application/version.d.ts +2 -0
- package/dist/application/version.d.ts.map +1 -0
- package/dist/application/version.js +7 -0
- package/dist/application/version.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +68 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/elicit.d.ts +3 -0
- package/dist/commands/elicit.d.ts.map +1 -0
- package/dist/commands/elicit.js +163 -0
- package/dist/commands/elicit.js.map +1 -0
- package/dist/commands/evolve.d.ts +3 -0
- package/dist/commands/evolve.d.ts.map +1 -0
- package/dist/commands/evolve.js +165 -0
- package/dist/commands/evolve.js.map +1 -0
- package/dist/commands/feature.d.ts +13 -0
- package/dist/commands/feature.d.ts.map +1 -0
- package/dist/commands/feature.js +326 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/fix.d.ts +3 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +61 -0
- package/dist/commands/fix.js.map +1 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +32 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +21 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +90 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +64 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +329 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/journal.d.ts +3 -0
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/journal.js +107 -0
- package/dist/commands/journal.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +85 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +68 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/next.d.ts +3 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +107 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/optimize.d.ts +3 -0
- package/dist/commands/optimize.d.ts.map +1 -0
- package/dist/commands/optimize.js +28 -0
- package/dist/commands/optimize.js.map +1 -0
- package/dist/commands/plugin-linker.d.ts +34 -0
- package/dist/commands/plugin-linker.d.ts.map +1 -0
- package/dist/commands/plugin-linker.js +177 -0
- package/dist/commands/plugin-linker.js.map +1 -0
- package/dist/commands/refactor.d.ts +3 -0
- package/dist/commands/refactor.d.ts.map +1 -0
- package/dist/commands/refactor.js +32 -0
- package/dist/commands/refactor.js.map +1 -0
- package/dist/commands/types.d.ts +19 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/validate-plan.d.ts +3 -0
- package/dist/commands/validate-plan.d.ts.map +1 -0
- package/dist/commands/validate-plan.js +62 -0
- package/dist/commands/validate-plan.js.map +1 -0
- package/dist/commands/validate-spec.d.ts +3 -0
- package/dist/commands/validate-spec.d.ts.map +1 -0
- package/dist/commands/validate-spec.js +62 -0
- package/dist/commands/validate-spec.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +103 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +12 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/output/formatter.d.ts +2 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +10 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/index.d.ts +2 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +3 -0
- package/dist/output/index.js.map +1 -0
- package/package.json +37 -3
- package/src/application/agent/execution-store.ts +162 -0
- package/src/application/agent/gateway.test.ts +529 -0
- package/src/application/agent/gateway.ts +744 -0
- package/src/application/agent/index.ts +18 -0
- package/src/application/agent/orchestrator.test.ts +341 -0
- package/src/application/agent/orchestrator.ts +628 -0
- package/src/application/agent/providers/claude-code/claude-argv.ts +119 -0
- package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +139 -0
- package/src/application/agent/providers/claude-code/fixtures/fake-claude.mjs +125 -0
- package/src/application/agent/providers/claude-code/index.ts +28 -0
- package/src/application/agent/providers/claude-code/mod-parity.ts +50 -0
- package/src/application/agent/providers/claude-code/permission-config.test.ts +221 -0
- package/src/application/agent/providers/claude-code/permission-config.ts +242 -0
- package/src/application/agent/providers/claude-code/provider.test.ts +378 -0
- package/src/application/agent/providers/claude-code/provider.ts +717 -0
- package/src/application/agent/providers/claude-code/resume-store.test.ts +161 -0
- package/src/application/agent/providers/claude-code/resume-store.ts +157 -0
- package/src/application/agent/providers/claude-code/stream-parser.ts +166 -0
- package/src/application/agent/test-fixture.ts +131 -0
- package/src/application/agent/workspace.test.ts +104 -0
- package/src/application/agent/workspace.ts +156 -0
- package/src/application/dispatcher.test.ts +89 -0
- package/src/application/dispatcher.ts +98 -0
- package/src/application/index.ts +5 -0
- package/src/application/registry.ts +24 -0
- package/src/application/version.ts +7 -0
- package/src/commands/clse.test.ts +181 -0
- package/src/commands/doctor.test.ts +29 -0
- package/src/commands/doctor.ts +78 -0
- package/src/commands/elicit.test.ts +111 -0
- package/src/commands/elicit.ts +188 -0
- package/src/commands/evolve.ts +209 -0
- package/src/commands/feature.test.ts +323 -0
- package/src/commands/feature.ts +405 -0
- package/src/commands/fix.test.ts +36 -0
- package/src/commands/fix.ts +69 -0
- package/src/commands/help.test.ts +33 -0
- package/src/commands/help.ts +35 -0
- package/src/commands/index.ts +21 -0
- package/src/commands/init.test.ts +65 -0
- package/src/commands/init.ts +103 -0
- package/src/commands/inspect.test.ts +57 -0
- package/src/commands/inspect.ts +73 -0
- package/src/commands/install.test.ts +61 -0
- package/src/commands/install.ts +375 -0
- package/src/commands/journal.ts +118 -0
- package/src/commands/memory.ts +96 -0
- package/src/commands/new.test.ts +44 -0
- package/src/commands/new.ts +77 -0
- package/src/commands/next.test.ts +241 -0
- package/src/commands/next.ts +124 -0
- package/src/commands/optimize.ts +30 -0
- package/src/commands/plugin-linker.test.ts +139 -0
- package/src/commands/plugin-linker.ts +196 -0
- package/src/commands/refactor.ts +34 -0
- package/src/commands/stack-commands.test.ts +67 -0
- package/src/commands/tier-c-conformance.test.ts +194 -0
- package/src/commands/types.ts +26 -0
- package/src/commands/validate-plan.test.ts +107 -0
- package/src/commands/validate-plan.ts +67 -0
- package/src/commands/validate-spec.test.ts +59 -0
- package/src/commands/validate-spec.ts +68 -0
- package/src/commands/verify.test.ts +117 -0
- package/src/commands/verify.ts +112 -0
- package/src/commands/version.test.ts +11 -0
- package/src/commands/version.ts +14 -0
- package/src/index.ts +30 -0
- package/src/output/formatter.ts +10 -0
- package/src/output/index.ts +2 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// packages/cli/src/application/dispatcher.ts
|
|
2
|
+
//
|
|
3
|
+
// Resolves the first non-flag argument to a registered command and runs it.
|
|
4
|
+
// Handles --help, --version, and unknown commands.
|
|
5
|
+
import { makeHelpCommand } from '../commands/help.js';
|
|
6
|
+
import { versionCommand } from '../commands/version.js';
|
|
7
|
+
import { doctorCommand } from '../commands/doctor.js';
|
|
8
|
+
import { inspectCommand } from '../commands/inspect.js';
|
|
9
|
+
import { initCommand } from '../commands/init.js';
|
|
10
|
+
import { validateSpecCommand } from '../commands/validate-spec.js';
|
|
11
|
+
import { elicitCommand } from '../commands/elicit.js';
|
|
12
|
+
import { validatePlanCommand } from '../commands/validate-plan.js';
|
|
13
|
+
import { verifyCommand } from '../commands/verify.js';
|
|
14
|
+
import { featureCommand } from '../commands/feature.js';
|
|
15
|
+
import { newCommand } from '../commands/new.js';
|
|
16
|
+
import { fixCommand } from '../commands/fix.js';
|
|
17
|
+
import { installCommand } from '../commands/install.js';
|
|
18
|
+
import { memoryCommand } from '../commands/memory.js';
|
|
19
|
+
import { evolveCommand } from '../commands/evolve.js';
|
|
20
|
+
import { refactorCommand } from '../commands/refactor.js';
|
|
21
|
+
import { optimizeCommand } from '../commands/optimize.js';
|
|
22
|
+
import { nextCommand } from '../commands/next.js';
|
|
23
|
+
import { journalCommand } from '../commands/journal.js';
|
|
24
|
+
import { createCommandRegistry } from './registry.js';
|
|
25
|
+
import { VERSION } from './version.js';
|
|
26
|
+
export function createDispatcher(opts = {}) {
|
|
27
|
+
const registry = opts.registry ?? createCommandRegistry();
|
|
28
|
+
// Register default commands. Help needs the registry so it is built lazily.
|
|
29
|
+
if (!registry.get('version'))
|
|
30
|
+
registry.register(versionCommand);
|
|
31
|
+
if (!registry.get('doctor'))
|
|
32
|
+
registry.register(doctorCommand);
|
|
33
|
+
if (!registry.get('inspect'))
|
|
34
|
+
registry.register(inspectCommand);
|
|
35
|
+
if (!registry.get('init'))
|
|
36
|
+
registry.register(initCommand);
|
|
37
|
+
if (!registry.get('validate-spec'))
|
|
38
|
+
registry.register(validateSpecCommand);
|
|
39
|
+
if (!registry.get('elicit'))
|
|
40
|
+
registry.register(elicitCommand);
|
|
41
|
+
if (!registry.get('validate-plan'))
|
|
42
|
+
registry.register(validatePlanCommand);
|
|
43
|
+
if (!registry.get('verify'))
|
|
44
|
+
registry.register(verifyCommand);
|
|
45
|
+
if (!registry.get('feature'))
|
|
46
|
+
registry.register(featureCommand);
|
|
47
|
+
if (!registry.get('new'))
|
|
48
|
+
registry.register(newCommand);
|
|
49
|
+
if (!registry.get('fix'))
|
|
50
|
+
registry.register(fixCommand);
|
|
51
|
+
if (!registry.get('install'))
|
|
52
|
+
registry.register(installCommand);
|
|
53
|
+
if (!registry.get('memory'))
|
|
54
|
+
registry.register(memoryCommand);
|
|
55
|
+
if (!registry.get('evolve'))
|
|
56
|
+
registry.register(evolveCommand);
|
|
57
|
+
if (!registry.get('refactor'))
|
|
58
|
+
registry.register(refactorCommand);
|
|
59
|
+
if (!registry.get('optimize'))
|
|
60
|
+
registry.register(optimizeCommand);
|
|
61
|
+
if (!registry.get('next'))
|
|
62
|
+
registry.register(nextCommand);
|
|
63
|
+
if (!registry.get('journal'))
|
|
64
|
+
registry.register(journalCommand);
|
|
65
|
+
if (!registry.get('help'))
|
|
66
|
+
registry.register(makeHelpCommand(registry));
|
|
67
|
+
return {
|
|
68
|
+
registry,
|
|
69
|
+
async dispatch(ctx) {
|
|
70
|
+
const argv = ctx.argv;
|
|
71
|
+
// --version / -v
|
|
72
|
+
if (argv.includes('--version') || argv.includes('-v')) {
|
|
73
|
+
return { exitCode: 0, message: VERSION, command: 'version' };
|
|
74
|
+
}
|
|
75
|
+
// --help / -h with no further command, OR no args at all
|
|
76
|
+
if (argv.length === 0 || argv.includes('--help') || argv.includes('-h')) {
|
|
77
|
+
const help = registry.get('help');
|
|
78
|
+
if (!help)
|
|
79
|
+
return { exitCode: 1, command: 'help', message: 'help command missing' };
|
|
80
|
+
const r = await help.run(ctx);
|
|
81
|
+
return { ...r, command: 'help' };
|
|
82
|
+
}
|
|
83
|
+
// First non-flag argument is the command name.
|
|
84
|
+
const first = argv.find((a) => !a.startsWith('-'));
|
|
85
|
+
if (!first) {
|
|
86
|
+
const help = registry.get('help');
|
|
87
|
+
if (help) {
|
|
88
|
+
const r = await help.run(ctx);
|
|
89
|
+
return { ...r, command: 'help' };
|
|
90
|
+
}
|
|
91
|
+
return { exitCode: 1, message: 'no command' };
|
|
92
|
+
}
|
|
93
|
+
const cmd = registry.get(first);
|
|
94
|
+
if (!cmd) {
|
|
95
|
+
ctx.stderr(`kit: unknown command '${first}'\nRun 'kit --help' for usage.\n`);
|
|
96
|
+
return { exitCode: 1, command: first, message: 'unknown command' };
|
|
97
|
+
}
|
|
98
|
+
const rest = argv.filter((a) => a !== first);
|
|
99
|
+
const r = await cmd.run({ ...ctx, argv: rest });
|
|
100
|
+
return { ...r, command: first };
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/application/dispatcher.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,4EAA4E;AAC5E,mDAAmD;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE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,YAAY,EAAE,CAAC;YAChD,CAAC;YACD,MAAM,GAAG,GAAwB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACrD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,GAAG,CAAC,MAAM,CAAC,yBAAyB,KAAK,kCAAkC,CAAC,CAAC;gBAC7E,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;YACrE,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from '../commands/types.js';
|
|
2
|
+
export interface CommandRegistry {
|
|
3
|
+
list(): ReadonlyArray<Command>;
|
|
4
|
+
get(name: string): Command | undefined;
|
|
5
|
+
register(command: Command): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createCommandRegistry(initial?: ReadonlyArray<Command>): CommandRegistry;
|
|
8
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/application/registry.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,aAAa,CAAC,OAAO,CAAM,GAAG,eAAe,CAU3F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// packages/cli/src/application/registry.ts
|
|
2
|
+
//
|
|
3
|
+
// Command registry. The dispatcher uses this to find a command by name.
|
|
4
|
+
// Adding a command = adding one entry here.
|
|
5
|
+
export function createCommandRegistry(initial = []) {
|
|
6
|
+
const commands = new Map();
|
|
7
|
+
for (const c of initial)
|
|
8
|
+
commands.set(c.name, c);
|
|
9
|
+
return {
|
|
10
|
+
list: () => Array.from(commands.values()),
|
|
11
|
+
get: (name) => commands.get(name),
|
|
12
|
+
register: (command) => {
|
|
13
|
+
commands.set(command.name, command);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/application/registry.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,wEAAwE;AACxE,4CAA4C;AAU5C,MAAM,UAAU,qBAAqB,CAAC,UAAkC,EAAE;IACxE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzC,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QACzC,QAAQ,EAAE,CAAC,OAAgB,EAAE,EAAE;YAC7B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/application/version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// packages/cli/src/application/version.ts
|
|
2
|
+
//
|
|
3
|
+
// Single source of truth for the kit version. Sourced from package.json at
|
|
4
|
+
// build time via a build-time constant. In M1 we hard-code to keep the
|
|
5
|
+
// build simple; M16 wires this to a generated file.
|
|
6
|
+
export const VERSION = '0.8.0';
|
|
7
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/application/version.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oDAAoD;AAEpD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAIzE,eAAO,MAAM,aAAa,EAAE,OAyC3B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// packages/cli/src/commands/doctor.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit doctor`. Checks the kit's toolchain and configuration health:
|
|
4
|
+
// - Node version meets the minimum.
|
|
5
|
+
// - pnpm is available.
|
|
6
|
+
// - git is available.
|
|
7
|
+
// - Project profile (.ai-kit/project.yml) status.
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { VERSION } from '../application/version.js';
|
|
11
|
+
const MIN_NODE_MAJOR = 20;
|
|
12
|
+
export const doctorCommand = {
|
|
13
|
+
name: 'doctor',
|
|
14
|
+
summary: 'Check the kit toolchain and configuration health.',
|
|
15
|
+
async run(ctx) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
let healthy = true;
|
|
18
|
+
lines.push(`kit ${VERSION}`);
|
|
19
|
+
lines.push('');
|
|
20
|
+
const nodeVersion = process.versions.node;
|
|
21
|
+
const nodeMajor = Number.parseInt(nodeVersion.split('.')[0] ?? '0', 10);
|
|
22
|
+
const nodeOk = nodeMajor >= MIN_NODE_MAJOR;
|
|
23
|
+
if (!nodeOk)
|
|
24
|
+
healthy = false;
|
|
25
|
+
lines.push(` node ${nodeVersion} ${nodeOk ? '[ok]' : `[FAIL: needs >= ${MIN_NODE_MAJOR}]`}`);
|
|
26
|
+
const pnpmPath = await findExecutable('pnpm');
|
|
27
|
+
const pnpmOk = pnpmPath !== null;
|
|
28
|
+
if (!pnpmOk)
|
|
29
|
+
healthy = false;
|
|
30
|
+
lines.push(` pnpm ${pnpmOk ? 'found' : 'MISSING'} ${pnpmOk ? '[ok]' : '[FAIL]'}`);
|
|
31
|
+
const gitPath = await findExecutable('git');
|
|
32
|
+
const gitOk = gitPath !== null;
|
|
33
|
+
if (!gitOk)
|
|
34
|
+
healthy = false;
|
|
35
|
+
lines.push(` git ${gitOk ? 'found' : 'MISSING'} ${gitOk ? '[ok]' : '[FAIL]'}`);
|
|
36
|
+
// Workspace packages — declared, not built
|
|
37
|
+
lines.push(` workspace contracts, core, cli, testing, claude-code-adapter, mod-sdk [declared]`);
|
|
38
|
+
const profile = await checkProfile(ctx.cwd);
|
|
39
|
+
lines.push(` profile ${profile.msg} [${profile.status}]`);
|
|
40
|
+
lines.push('');
|
|
41
|
+
lines.push(healthy ? 'Status: healthy' : 'Status: issues found');
|
|
42
|
+
ctx.stdout(lines.join('\n') + '\n');
|
|
43
|
+
return { exitCode: healthy ? 0 : 2 };
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
async function findExecutable(name) {
|
|
47
|
+
const { execFileSync } = await import('node:child_process');
|
|
48
|
+
try {
|
|
49
|
+
execFileSync(name, ['--version'], { stdio: 'ignore' });
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function checkProfile(cwd) {
|
|
57
|
+
const configPath = path.join(cwd, '.ai-kit', 'project.yml');
|
|
58
|
+
try {
|
|
59
|
+
const stat = await fs.stat(configPath);
|
|
60
|
+
if (stat.isFile())
|
|
61
|
+
return { msg: '.ai-kit/project.yml present', status: 'ok' };
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// profile does not exist yet
|
|
65
|
+
}
|
|
66
|
+
return { msg: "no profile (run 'kit init')", status: 'info' };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,qEAAqE;AACrE,sCAAsC;AACtC,yBAAyB;AACzB,wBAAwB;AACxB,oDAAoD;AAEpD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,C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;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,GAAW;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC5D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC,MAAM,EAAE;YAAE,OAAO,EAAE,GAAG,EAAE,6BAA6B,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,6BAA6B;IAC/B,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicit.d.ts","sourceRoot":"","sources":["../../src/commands/elicit.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AA+JzE,eAAO,MAAM,aAAa,EAAE,OAI3B,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// packages/cli/src/commands/elicit.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit elicit <FEATURE-ID> [--stack <a,b>] [--answers <file.json>] [--check] [--json]`
|
|
4
|
+
//
|
|
5
|
+
// Requirements elicitation. Interactive on a TTY: asks each unanswered question
|
|
6
|
+
// and saves after every answer. Non-interactive (--answers, or no TTY) never
|
|
7
|
+
// guesses: an unanswered blocking question fails the run. --check reports the
|
|
8
|
+
// gate without asking anything.
|
|
9
|
+
import { promises as fs } from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import readline from 'node:readline/promises';
|
|
12
|
+
import { applicableQuestions, emptyRecord, gateStatus, QUESTION_BANK, recordAnswer, unanswered, } from '@agentic-sdlc-kit/core';
|
|
13
|
+
const FEATURE_ID = /^[A-Za-z][A-Za-z0-9-]{1,63}$/;
|
|
14
|
+
const KNOWN_STACKS = new Set(['ruby', 'ruby-rails', 'node-typescript', 'react-typescript', 'python', 'go']);
|
|
15
|
+
const VALUE_FLAGS = new Set(['--stack', '--answers']);
|
|
16
|
+
/** First argument that is neither a flag nor the value of a value-taking flag. */
|
|
17
|
+
function firstPositional(argv) {
|
|
18
|
+
for (let i = 0; i < argv.length; i++) {
|
|
19
|
+
const a = argv[i];
|
|
20
|
+
if (VALUE_FLAGS.has(a)) {
|
|
21
|
+
i += 1;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!a.startsWith('-'))
|
|
25
|
+
return a;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function flagValue(argv, flag) {
|
|
30
|
+
const i = argv.indexOf(flag);
|
|
31
|
+
return i === -1 ? undefined : argv[i + 1];
|
|
32
|
+
}
|
|
33
|
+
/** Stacks from --stack, else the `stack:` list in .ai-kit/project.yml. */
|
|
34
|
+
async function resolveStacks(ctx) {
|
|
35
|
+
const flag = flagValue(ctx.argv, '--stack');
|
|
36
|
+
let names = [];
|
|
37
|
+
if (flag !== undefined) {
|
|
38
|
+
names = flag.split(',').map((s) => s.trim()).filter(Boolean);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const raw = await fs.readFile(path.join(ctx.cwd, '.ai-kit', 'project.yml'), 'utf8').catch(() => '');
|
|
42
|
+
names = [...raw.matchAll(/^\s*-\s+([a-z-]+)\s*$/gm)].map((m) => m[1]);
|
|
43
|
+
}
|
|
44
|
+
const unknown = names.filter((n) => !KNOWN_STACKS.has(n));
|
|
45
|
+
return { stacks: names.filter((n) => KNOWN_STACKS.has(n)), unknown };
|
|
46
|
+
}
|
|
47
|
+
async function loadRecord(file, featureId) {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(await fs.readFile(file, 'utf8'));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return emptyRecord(featureId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function saveRecord(file, record) {
|
|
56
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
57
|
+
await fs.writeFile(file, JSON.stringify(record, null, 2) + '\n', 'utf8');
|
|
58
|
+
}
|
|
59
|
+
/** Answers file: { "<questionId>": "value" } or { "<questionId>": { value, source } }. */
|
|
60
|
+
function parseAnswersFile(raw) {
|
|
61
|
+
const obj = JSON.parse(raw);
|
|
62
|
+
return Object.entries(obj).map(([id, v]) => {
|
|
63
|
+
if (typeof v === 'string')
|
|
64
|
+
return { id, value: v, source: 'user' };
|
|
65
|
+
const entry = v;
|
|
66
|
+
return {
|
|
67
|
+
id,
|
|
68
|
+
value: String(entry.value ?? ''),
|
|
69
|
+
source: entry.source === 'assumption' ? 'assumption' : 'user',
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function formatQuestion(q) {
|
|
74
|
+
const opts = q.options.length > 0 ? ` [${q.options.join(' | ')}]` : '';
|
|
75
|
+
const tag = q.blocking ? 'BLOCKING' : 'optional';
|
|
76
|
+
return `\n${q.id} (${tag}): ${q.prompt}${opts}\n why: ${q.why}`;
|
|
77
|
+
}
|
|
78
|
+
async function interactive(questions, file, record, ctx) {
|
|
79
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
80
|
+
let current = record;
|
|
81
|
+
try {
|
|
82
|
+
for (const q of questions) {
|
|
83
|
+
ctx.stdout(formatQuestion(q) + '\n');
|
|
84
|
+
const answer = (await rl.question('> ')).trim();
|
|
85
|
+
if (answer === '' || answer.toLowerCase() === 'skip') {
|
|
86
|
+
if (q.blocking)
|
|
87
|
+
ctx.stdout(' blocking question; it stays open until answered\n');
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const res = recordAnswer(current, QUESTION_BANK, q.id, answer, 'user', new Date());
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
ctx.stdout(` not accepted: ${JSON.stringify(res.error)}\n`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
current = res.record;
|
|
96
|
+
await saveRecord(file, current);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
rl.close();
|
|
101
|
+
}
|
|
102
|
+
return current;
|
|
103
|
+
}
|
|
104
|
+
function report(ctx, featureId, file, applicable, record, json) {
|
|
105
|
+
const gate = gateStatus(applicable, record);
|
|
106
|
+
if (json) {
|
|
107
|
+
ctx.stdout(JSON.stringify({ featureId, record: file, gate, answered: record.answers.length }, null, 2) + '\n');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
ctx.stdout(`elicitation ${featureId}: ${record.answers.length} answered; gate ${gate.open ? 'OPEN' : 'CLOSED'}\n`);
|
|
111
|
+
for (const id of gate.missingBlocking)
|
|
112
|
+
ctx.stdout(` missing blocking answer: ${id}\n`);
|
|
113
|
+
ctx.stdout(`record: ${file}\n`);
|
|
114
|
+
}
|
|
115
|
+
return gate.open ? 0 : 1;
|
|
116
|
+
}
|
|
117
|
+
async function run(ctx) {
|
|
118
|
+
const positional = firstPositional(ctx.argv);
|
|
119
|
+
if (positional === undefined || !FEATURE_ID.test(positional)) {
|
|
120
|
+
ctx.stderr('kit elicit: a feature id such as FEATURE-001 is required\n');
|
|
121
|
+
return { exitCode: 1, message: 'missing feature id' };
|
|
122
|
+
}
|
|
123
|
+
const { stacks, unknown } = await resolveStacks(ctx);
|
|
124
|
+
if (unknown.length > 0) {
|
|
125
|
+
ctx.stderr(`kit elicit: unknown stack(s): ${unknown.join(', ')}\n`);
|
|
126
|
+
return { exitCode: 1, message: 'unknown stack' };
|
|
127
|
+
}
|
|
128
|
+
const file = path.join(ctx.cwd, 'docs', 'specifications', 'features', positional, 'ELICITATION.json');
|
|
129
|
+
const applicable = applicableQuestions(QUESTION_BANK, stacks);
|
|
130
|
+
let record = await loadRecord(file, positional);
|
|
131
|
+
const json = ctx.argv.includes('--json');
|
|
132
|
+
if (ctx.argv.includes('--check')) {
|
|
133
|
+
return { exitCode: report(ctx, positional, file, applicable, record, json) };
|
|
134
|
+
}
|
|
135
|
+
const answersPath = flagValue(ctx.argv, '--answers');
|
|
136
|
+
if (answersPath !== undefined) {
|
|
137
|
+
const entries = parseAnswersFile(await fs.readFile(path.resolve(ctx.cwd, answersPath), 'utf8'));
|
|
138
|
+
let next = record;
|
|
139
|
+
for (const e of entries) {
|
|
140
|
+
const res = recordAnswer(next, QUESTION_BANK, e.id, e.value, e.source, new Date());
|
|
141
|
+
if (!res.ok) {
|
|
142
|
+
ctx.stderr(`kit elicit: rejected ${e.id}: ${JSON.stringify(res.error)} (nothing saved)\n`);
|
|
143
|
+
return { exitCode: 1, message: 'answer rejected' };
|
|
144
|
+
}
|
|
145
|
+
next = res.record;
|
|
146
|
+
}
|
|
147
|
+
await saveRecord(file, next);
|
|
148
|
+
return { exitCode: report(ctx, positional, file, applicable, next, json) };
|
|
149
|
+
}
|
|
150
|
+
const pending = unanswered(applicable, record);
|
|
151
|
+
if (!process.stdin.isTTY) {
|
|
152
|
+
ctx.stdout(`kit elicit: ${pending.length} question(s) pending; no TTY, so nothing was asked. Use --answers <file.json>.\n`);
|
|
153
|
+
return { exitCode: report(ctx, positional, file, applicable, record, json) };
|
|
154
|
+
}
|
|
155
|
+
record = await interactive(pending, file, record, ctx);
|
|
156
|
+
return { exitCode: report(ctx, positional, file, applicable, record, json) };
|
|
157
|
+
}
|
|
158
|
+
export const elicitCommand = {
|
|
159
|
+
name: 'elicit',
|
|
160
|
+
summary: 'Elicit requirements for a feature: structured blocking questions, saved per answer.',
|
|
161
|
+
run,
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=elicit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicit.js","sourceRoot":"","sources":["../../src/commands/elicit.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,uFAAuF;AACvF,EAAE;AACF,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AAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;IAC/E,CAAC;IACD,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,qFAAqF;IAC9F,GAAG;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evolve.d.ts","sourceRoot":"","sources":["../../src/commands/evolve.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAEzE,eAAO,MAAM,aAAa,EAAE,OAqH3B,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// packages/cli/src/commands/evolve.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit evolve [--dry-run] [--json]`.
|
|
4
|
+
// Executes distillation, improvement hypothesis generation, and Evolution Lab benchmarks (M31-M33).
|
|
5
|
+
//
|
|
6
|
+
// Reads from persisted experience records at .ai-kit/state/experiences.json.
|
|
7
|
+
// If no persisted experiences exist, reports honestly that evolution cannot
|
|
8
|
+
// run without accumulated evidence.
|
|
9
|
+
import { EvolutionLab, HypothesisEngine, KnowledgeDistiller, MemoryStore, PromotionGate, evaluateEvolutionMetrics, ExperienceCollector, } from '@agentic-sdlc-kit/core';
|
|
10
|
+
export const evolveCommand = {
|
|
11
|
+
name: 'evolve',
|
|
12
|
+
summary: 'Run continuous learning distillation, hypothesis generation, and Evolution Lab benchmarks (M31-M33).',
|
|
13
|
+
async run(ctx) {
|
|
14
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
15
|
+
ctx.stdout(formatHelp());
|
|
16
|
+
return { exitCode: 0 };
|
|
17
|
+
}
|
|
18
|
+
const isJson = ctx.argv.includes('--json');
|
|
19
|
+
const isDryRun = ctx.argv.includes('--dry-run');
|
|
20
|
+
// Load persisted experiences from .ai-kit/state/experiences.json.
|
|
21
|
+
// This is the fast-loop output (M28) that the slow loop consumes.
|
|
22
|
+
const collector = new ExperienceCollector();
|
|
23
|
+
const loaded = await collector.loadFromDisk(ctx.cwd);
|
|
24
|
+
if (loaded === 0) {
|
|
25
|
+
const msg = 'kit evolve: no experience records found at .ai-kit/state/experiences.json.\n' +
|
|
26
|
+
'Run workflows first (e.g. `kit feature`) to accumulate experience.\n';
|
|
27
|
+
if (isJson) {
|
|
28
|
+
ctx.stdout(JSON.stringify({ error: 'no-experiences', message: msg.trim() }) + '\n');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
ctx.stdout(msg);
|
|
32
|
+
}
|
|
33
|
+
return { exitCode: 1, message: 'no experiences to distill' };
|
|
34
|
+
}
|
|
35
|
+
const experiences = collector.list();
|
|
36
|
+
// Initialize CLSE pipeline.
|
|
37
|
+
const store = new MemoryStore();
|
|
38
|
+
const distiller = new KnowledgeDistiller();
|
|
39
|
+
const engine = new HypothesisEngine();
|
|
40
|
+
const lab = new EvolutionLab();
|
|
41
|
+
const gate = new PromotionGate();
|
|
42
|
+
// Distill lessons from real persisted experiences.
|
|
43
|
+
const distilled = distiller.distillFromExperiences(experiences);
|
|
44
|
+
// Persist distilled lessons to memory store.
|
|
45
|
+
for (const mem of distilled)
|
|
46
|
+
store.put(mem);
|
|
47
|
+
await store.saveToDisk(ctx.cwd);
|
|
48
|
+
// Generate hypotheses from distilled memories.
|
|
49
|
+
const hypotheses = engine.generateFromMemories(distilled);
|
|
50
|
+
if (hypotheses.length === 0) {
|
|
51
|
+
const msg = `kit evolve: ${experiences.length} experience(s) loaded, ${distilled.length} lesson(s) distilled.\n` +
|
|
52
|
+
'No hypotheses generated — need more recurring failures (≥2 per pattern) to propose improvements.\n';
|
|
53
|
+
if (isJson) {
|
|
54
|
+
ctx.stdout(JSON.stringify({
|
|
55
|
+
experiences: experiences.length,
|
|
56
|
+
distilledLessons: distilled.length,
|
|
57
|
+
hypotheses: 0,
|
|
58
|
+
message: 'insufficient recurring patterns for hypothesis generation',
|
|
59
|
+
}) + '\n');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
ctx.stdout(msg);
|
|
63
|
+
}
|
|
64
|
+
return { exitCode: 0 };
|
|
65
|
+
}
|
|
66
|
+
// Run Evolution Lab benchmarks for each hypothesis.
|
|
67
|
+
// The benchmark runner reports `notImplemented` when the Evolution
|
|
68
|
+
// Lab environment (M32) is unavailable; those experiments come back
|
|
69
|
+
// with verdict 'not-run' and are NEVER reported as completed (ADR-0018).
|
|
70
|
+
const reports = [];
|
|
71
|
+
for (const hyp of hypotheses) {
|
|
72
|
+
const runner = createBenchmarkRunner(ctx.cwd);
|
|
73
|
+
const rep = await lab.runExperiment(hyp, runner);
|
|
74
|
+
reports.push(rep);
|
|
75
|
+
if (!isDryRun && rep.verdict === 'promoted') {
|
|
76
|
+
gate.createRequest(hyp, rep);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Honest metrics: computed ONLY from experiments that actually
|
|
80
|
+
// executed. Not-run benchmarks contribute nothing.
|
|
81
|
+
const executed = reports.filter((r) => r.verdict !== 'not-run');
|
|
82
|
+
const notRun = reports.length - executed.length;
|
|
83
|
+
const metrics = executed.length > 0
|
|
84
|
+
? evaluateEvolutionMetrics({
|
|
85
|
+
heldOutGain: executed.reduce((sum, r) => sum + Math.max(0, r.heldOutGain), 0) / executed.length,
|
|
86
|
+
learningCostTokens: executed.reduce((sum, r) => sum + r.learningCostTokens, 0),
|
|
87
|
+
totalTasks: experiences.length,
|
|
88
|
+
regressions: executed.reduce((sum, r) => sum + r.regressions, 0),
|
|
89
|
+
memoriesRetrieved: distilled.length,
|
|
90
|
+
memoriesApplied: distilled.length,
|
|
91
|
+
})
|
|
92
|
+
: null;
|
|
93
|
+
const output = {
|
|
94
|
+
experiencesLoaded: experiences.length,
|
|
95
|
+
distilledLessons: distilled.length,
|
|
96
|
+
hypothesesGenerated: hypotheses.length,
|
|
97
|
+
benchmarksExecuted: executed.length,
|
|
98
|
+
benchmarksNotRun: notRun,
|
|
99
|
+
experiments: reports,
|
|
100
|
+
metrics,
|
|
101
|
+
};
|
|
102
|
+
if (isJson) {
|
|
103
|
+
ctx.stdout(JSON.stringify(output, null, 2) + '\n');
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
ctx.stdout(formatSummary(output));
|
|
107
|
+
}
|
|
108
|
+
return { exitCode: 0 };
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Create a benchmark runner for the CLI surface. The isolated Evolution
|
|
113
|
+
* Lab environment (M32) is a separate workspace that is not available
|
|
114
|
+
* here, so both evaluations honestly report `notImplemented` — which the
|
|
115
|
+
* lab surfaces as verdict 'not-run' instead of fabricated metrics.
|
|
116
|
+
*/
|
|
117
|
+
function createBenchmarkRunner(_projectRoot) {
|
|
118
|
+
return {
|
|
119
|
+
async evaluateBaseline() {
|
|
120
|
+
return { passRate: 0, tokens: 0, notImplemented: true };
|
|
121
|
+
},
|
|
122
|
+
async evaluateCandidate() {
|
|
123
|
+
return { passRate: 0, tokens: 0, regressions: 0, notImplemented: true };
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function formatSummary(out) {
|
|
128
|
+
// Honest status: if nothing executed, the lab is NOT RUN — never COMPLETED.
|
|
129
|
+
const labStatus = out.benchmarksExecuted === 0
|
|
130
|
+
? 'NOT RUN (benchmark environment unavailable)'
|
|
131
|
+
: `COMPLETED (${out.benchmarksExecuted} of ${out.experiments.length} benchmarks executed)`;
|
|
132
|
+
const lines = [
|
|
133
|
+
`Evolution Lab: ${labStatus}`,
|
|
134
|
+
`Experiences Loaded: ${out.experiencesLoaded}`,
|
|
135
|
+
`Distilled Lessons: ${out.distilledLessons}`,
|
|
136
|
+
`Hypotheses: ${out.hypothesesGenerated}${out.benchmarksNotRun > 0 ? ' (proposals pending benchmark evidence)' : ''}`,
|
|
137
|
+
`Experiments: ${out.benchmarksExecuted} executed, ${out.benchmarksNotRun} not run`,
|
|
138
|
+
];
|
|
139
|
+
if (out.metrics) {
|
|
140
|
+
lines.push(`Held-Out Gain: +${(out.metrics.heldOutGain * 100).toFixed(1)}%`, `Learning Cost: ${out.metrics.learningCost} tokens`, `Efficiency: ${out.metrics.learningEfficiency}`, `Regression Rate: ${out.metrics.regressionRate}`, `Memory Reuse Rate: ${(out.metrics.memoryReuseRate * 100).toFixed(0)}%`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
lines.push('Metrics: withheld (no executed benchmarks)');
|
|
144
|
+
}
|
|
145
|
+
return lines.join('\n') + '\n';
|
|
146
|
+
}
|
|
147
|
+
function formatHelp() {
|
|
148
|
+
return [
|
|
149
|
+
'Usage: kit evolve [--dry-run] [--json]',
|
|
150
|
+
'',
|
|
151
|
+
'Execute the Continuous Learning and Self-Evolution Engine: distill experience,',
|
|
152
|
+
'synthesize improvement hypotheses, run Evolution Lab benchmarks, and propose',
|
|
153
|
+
'controlled Skill upgrades with human approval gates.',
|
|
154
|
+
'',
|
|
155
|
+
'Reads from .ai-kit/state/experiences.json (produced by workflow runs).',
|
|
156
|
+
'Writes to .ai-kit/state/memory.json (distilled lessons).',
|
|
157
|
+
'',
|
|
158
|
+
'Options:',
|
|
159
|
+
' --dry-run Simulate benchmarks without staging promotion requests',
|
|
160
|
+
' --json Output full machine-readable experiment and metrics report',
|
|
161
|
+
' --help Show this message',
|
|
162
|
+
'',
|
|
163
|
+
].join('\n');
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=evolve.js.map
|