@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.
Files changed (309) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/application/agent/execution-store.d.ts +55 -0
  4. package/dist/application/agent/execution-store.d.ts.map +1 -0
  5. package/dist/application/agent/execution-store.js +91 -0
  6. package/dist/application/agent/execution-store.js.map +1 -0
  7. package/dist/application/agent/gateway.d.ts +74 -0
  8. package/dist/application/agent/gateway.d.ts.map +1 -0
  9. package/dist/application/agent/gateway.js +580 -0
  10. package/dist/application/agent/gateway.js.map +1 -0
  11. package/dist/application/agent/index.d.ts +6 -0
  12. package/dist/application/agent/index.d.ts.map +1 -0
  13. package/dist/application/agent/index.js +18 -0
  14. package/dist/application/agent/index.js.map +1 -0
  15. package/dist/application/agent/orchestrator.d.ts +76 -0
  16. package/dist/application/agent/orchestrator.d.ts.map +1 -0
  17. package/dist/application/agent/orchestrator.js +422 -0
  18. package/dist/application/agent/orchestrator.js.map +1 -0
  19. package/dist/application/agent/providers/claude-code/claude-argv.d.ts +15 -0
  20. package/dist/application/agent/providers/claude-code/claude-argv.d.ts.map +1 -0
  21. package/dist/application/agent/providers/claude-code/claude-argv.js +98 -0
  22. package/dist/application/agent/providers/claude-code/claude-argv.js.map +1 -0
  23. package/dist/application/agent/providers/claude-code/index.d.ts +7 -0
  24. package/dist/application/agent/providers/claude-code/index.d.ts.map +1 -0
  25. package/dist/application/agent/providers/claude-code/index.js +13 -0
  26. package/dist/application/agent/providers/claude-code/index.js.map +1 -0
  27. package/dist/application/agent/providers/claude-code/mod-parity.d.ts +15 -0
  28. package/dist/application/agent/providers/claude-code/mod-parity.d.ts.map +1 -0
  29. package/dist/application/agent/providers/claude-code/mod-parity.js +41 -0
  30. package/dist/application/agent/providers/claude-code/mod-parity.js.map +1 -0
  31. package/dist/application/agent/providers/claude-code/permission-config.d.ts +59 -0
  32. package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -0
  33. package/dist/application/agent/providers/claude-code/permission-config.js +189 -0
  34. package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -0
  35. package/dist/application/agent/providers/claude-code/provider.d.ts +38 -0
  36. package/dist/application/agent/providers/claude-code/provider.d.ts.map +1 -0
  37. package/dist/application/agent/providers/claude-code/provider.js +577 -0
  38. package/dist/application/agent/providers/claude-code/provider.js.map +1 -0
  39. package/dist/application/agent/providers/claude-code/resume-store.d.ts +25 -0
  40. package/dist/application/agent/providers/claude-code/resume-store.d.ts.map +1 -0
  41. package/dist/application/agent/providers/claude-code/resume-store.js +120 -0
  42. package/dist/application/agent/providers/claude-code/resume-store.js.map +1 -0
  43. package/dist/application/agent/providers/claude-code/stream-parser.d.ts +50 -0
  44. package/dist/application/agent/providers/claude-code/stream-parser.d.ts.map +1 -0
  45. package/dist/application/agent/providers/claude-code/stream-parser.js +129 -0
  46. package/dist/application/agent/providers/claude-code/stream-parser.js.map +1 -0
  47. package/dist/application/agent/test-fixture.d.ts +15 -0
  48. package/dist/application/agent/test-fixture.d.ts.map +1 -0
  49. package/dist/application/agent/test-fixture.js +93 -0
  50. package/dist/application/agent/test-fixture.js.map +1 -0
  51. package/dist/application/agent/workspace.d.ts +24 -0
  52. package/dist/application/agent/workspace.d.ts.map +1 -0
  53. package/dist/application/agent/workspace.js +139 -0
  54. package/dist/application/agent/workspace.js.map +1 -0
  55. package/dist/application/dispatcher.d.ts +13 -0
  56. package/dist/application/dispatcher.d.ts.map +1 -0
  57. package/dist/application/dispatcher.js +116 -0
  58. package/dist/application/dispatcher.js.map +1 -0
  59. package/dist/application/index.d.ts +5 -0
  60. package/dist/application/index.d.ts.map +1 -0
  61. package/dist/application/index.js +6 -0
  62. package/dist/application/index.js.map +1 -0
  63. package/dist/application/registry.d.ts +8 -0
  64. package/dist/application/registry.d.ts.map +1 -0
  65. package/dist/application/registry.js +17 -0
  66. package/dist/application/registry.js.map +1 -0
  67. package/dist/application/version.d.ts +2 -0
  68. package/dist/application/version.d.ts.map +1 -0
  69. package/dist/application/version.js +7 -0
  70. package/dist/application/version.js.map +1 -0
  71. package/dist/commands/attach-exclude.d.ts +8 -0
  72. package/dist/commands/attach-exclude.d.ts.map +1 -0
  73. package/dist/commands/attach-exclude.js +48 -0
  74. package/dist/commands/attach-exclude.js.map +1 -0
  75. package/dist/commands/attach-git.d.ts +11 -0
  76. package/dist/commands/attach-git.d.ts.map +1 -0
  77. package/dist/commands/attach-git.js +40 -0
  78. package/dist/commands/attach-git.js.map +1 -0
  79. package/dist/commands/attach-store.d.ts +10 -0
  80. package/dist/commands/attach-store.d.ts.map +1 -0
  81. package/dist/commands/attach-store.js +107 -0
  82. package/dist/commands/attach-store.js.map +1 -0
  83. package/dist/commands/attach.d.ts +8 -0
  84. package/dist/commands/attach.d.ts.map +1 -0
  85. package/dist/commands/attach.js +124 -0
  86. package/dist/commands/attach.js.map +1 -0
  87. package/dist/commands/doctor.d.ts +3 -0
  88. package/dist/commands/doctor.d.ts.map +1 -0
  89. package/dist/commands/doctor.js +68 -0
  90. package/dist/commands/doctor.js.map +1 -0
  91. package/dist/commands/elicit.d.ts +3 -0
  92. package/dist/commands/elicit.d.ts.map +1 -0
  93. package/dist/commands/elicit.js +163 -0
  94. package/dist/commands/elicit.js.map +1 -0
  95. package/dist/commands/evolve.d.ts +3 -0
  96. package/dist/commands/evolve.d.ts.map +1 -0
  97. package/dist/commands/evolve.js +165 -0
  98. package/dist/commands/evolve.js.map +1 -0
  99. package/dist/commands/feature.d.ts +13 -0
  100. package/dist/commands/feature.d.ts.map +1 -0
  101. package/dist/commands/feature.js +326 -0
  102. package/dist/commands/feature.js.map +1 -0
  103. package/dist/commands/fix.d.ts +4 -0
  104. package/dist/commands/fix.d.ts.map +1 -0
  105. package/dist/commands/fix.js +53 -0
  106. package/dist/commands/fix.js.map +1 -0
  107. package/dist/commands/help.d.ts +4 -0
  108. package/dist/commands/help.d.ts.map +1 -0
  109. package/dist/commands/help.js +32 -0
  110. package/dist/commands/help.js.map +1 -0
  111. package/dist/commands/host-apply.d.ts +12 -0
  112. package/dist/commands/host-apply.d.ts.map +1 -0
  113. package/dist/commands/host-apply.js +43 -0
  114. package/dist/commands/host-apply.js.map +1 -0
  115. package/dist/commands/host.d.ts +3 -0
  116. package/dist/commands/host.d.ts.map +1 -0
  117. package/dist/commands/host.js +107 -0
  118. package/dist/commands/host.js.map +1 -0
  119. package/dist/commands/index.d.ts +25 -0
  120. package/dist/commands/index.d.ts.map +1 -0
  121. package/dist/commands/index.js +26 -0
  122. package/dist/commands/index.js.map +1 -0
  123. package/dist/commands/init.d.ts +3 -0
  124. package/dist/commands/init.d.ts.map +1 -0
  125. package/dist/commands/init.js +92 -0
  126. package/dist/commands/init.js.map +1 -0
  127. package/dist/commands/inspect.d.ts +3 -0
  128. package/dist/commands/inspect.d.ts.map +1 -0
  129. package/dist/commands/inspect.js +64 -0
  130. package/dist/commands/inspect.js.map +1 -0
  131. package/dist/commands/install.d.ts +3 -0
  132. package/dist/commands/install.d.ts.map +1 -0
  133. package/dist/commands/install.js +337 -0
  134. package/dist/commands/install.js.map +1 -0
  135. package/dist/commands/journal.d.ts +3 -0
  136. package/dist/commands/journal.d.ts.map +1 -0
  137. package/dist/commands/journal.js +107 -0
  138. package/dist/commands/journal.js.map +1 -0
  139. package/dist/commands/memory.d.ts +3 -0
  140. package/dist/commands/memory.d.ts.map +1 -0
  141. package/dist/commands/memory.js +85 -0
  142. package/dist/commands/memory.js.map +1 -0
  143. package/dist/commands/new.d.ts +3 -0
  144. package/dist/commands/new.d.ts.map +1 -0
  145. package/dist/commands/new.js +68 -0
  146. package/dist/commands/new.js.map +1 -0
  147. package/dist/commands/next.d.ts +3 -0
  148. package/dist/commands/next.d.ts.map +1 -0
  149. package/dist/commands/next.js +107 -0
  150. package/dist/commands/next.js.map +1 -0
  151. package/dist/commands/optimize.d.ts +3 -0
  152. package/dist/commands/optimize.d.ts.map +1 -0
  153. package/dist/commands/optimize.js +28 -0
  154. package/dist/commands/optimize.js.map +1 -0
  155. package/dist/commands/plugin-linker.d.ts +43 -0
  156. package/dist/commands/plugin-linker.d.ts.map +1 -0
  157. package/dist/commands/plugin-linker.js +216 -0
  158. package/dist/commands/plugin-linker.js.map +1 -0
  159. package/dist/commands/refactor.d.ts +3 -0
  160. package/dist/commands/refactor.d.ts.map +1 -0
  161. package/dist/commands/refactor.js +32 -0
  162. package/dist/commands/refactor.js.map +1 -0
  163. package/dist/commands/skills-install-commit.d.ts +34 -0
  164. package/dist/commands/skills-install-commit.d.ts.map +1 -0
  165. package/dist/commands/skills-install-commit.js +113 -0
  166. package/dist/commands/skills-install-commit.js.map +1 -0
  167. package/dist/commands/skills-install-manifest.d.ts +35 -0
  168. package/dist/commands/skills-install-manifest.d.ts.map +1 -0
  169. package/dist/commands/skills-install-manifest.js +89 -0
  170. package/dist/commands/skills-install-manifest.js.map +1 -0
  171. package/dist/commands/skills-install-report.d.ts +12 -0
  172. package/dist/commands/skills-install-report.d.ts.map +1 -0
  173. package/dist/commands/skills-install-report.js +44 -0
  174. package/dist/commands/skills-install-report.js.map +1 -0
  175. package/dist/commands/skills-install-secure.d.ts +14 -0
  176. package/dist/commands/skills-install-secure.d.ts.map +1 -0
  177. package/dist/commands/skills-install-secure.js +96 -0
  178. package/dist/commands/skills-install-secure.js.map +1 -0
  179. package/dist/commands/skills-install.d.ts +15 -0
  180. package/dist/commands/skills-install.d.ts.map +1 -0
  181. package/dist/commands/skills-install.js +182 -0
  182. package/dist/commands/skills-install.js.map +1 -0
  183. package/dist/commands/skills.d.ts +3 -0
  184. package/dist/commands/skills.d.ts.map +1 -0
  185. package/dist/commands/skills.js +217 -0
  186. package/dist/commands/skills.js.map +1 -0
  187. package/dist/commands/types.d.ts +19 -0
  188. package/dist/commands/types.d.ts.map +1 -0
  189. package/dist/commands/types.js +7 -0
  190. package/dist/commands/types.js.map +1 -0
  191. package/dist/commands/uninstall.d.ts +3 -0
  192. package/dist/commands/uninstall.d.ts.map +1 -0
  193. package/dist/commands/uninstall.js +113 -0
  194. package/dist/commands/uninstall.js.map +1 -0
  195. package/dist/commands/validate-plan.d.ts +3 -0
  196. package/dist/commands/validate-plan.d.ts.map +1 -0
  197. package/dist/commands/validate-plan.js +62 -0
  198. package/dist/commands/validate-plan.js.map +1 -0
  199. package/dist/commands/validate-spec.d.ts +3 -0
  200. package/dist/commands/validate-spec.d.ts.map +1 -0
  201. package/dist/commands/validate-spec.js +62 -0
  202. package/dist/commands/validate-spec.js.map +1 -0
  203. package/dist/commands/verify.d.ts +3 -0
  204. package/dist/commands/verify.d.ts.map +1 -0
  205. package/dist/commands/verify.js +103 -0
  206. package/dist/commands/verify.js.map +1 -0
  207. package/dist/commands/version.d.ts +3 -0
  208. package/dist/commands/version.d.ts.map +1 -0
  209. package/dist/commands/version.js +12 -0
  210. package/dist/commands/version.js.map +1 -0
  211. package/dist/index.d.ts +3 -0
  212. package/dist/index.d.ts.map +1 -0
  213. package/dist/index.js +27 -0
  214. package/dist/index.js.map +1 -0
  215. package/dist/output/formatter.d.ts +2 -0
  216. package/dist/output/formatter.d.ts.map +1 -0
  217. package/dist/output/formatter.js +10 -0
  218. package/dist/output/formatter.js.map +1 -0
  219. package/dist/output/index.d.ts +2 -0
  220. package/dist/output/index.d.ts.map +1 -0
  221. package/dist/output/index.js +3 -0
  222. package/dist/output/index.js.map +1 -0
  223. package/package.json +37 -3
  224. package/src/application/agent/execution-store.ts +163 -0
  225. package/src/application/agent/gateway.test.ts +529 -0
  226. package/src/application/agent/gateway.ts +744 -0
  227. package/src/application/agent/index.ts +18 -0
  228. package/src/application/agent/orchestrator.test.ts +341 -0
  229. package/src/application/agent/orchestrator.ts +629 -0
  230. package/src/application/agent/providers/claude-code/claude-argv.ts +119 -0
  231. package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +139 -0
  232. package/src/application/agent/providers/claude-code/fixtures/fake-claude.mjs +125 -0
  233. package/src/application/agent/providers/claude-code/index.ts +28 -0
  234. package/src/application/agent/providers/claude-code/mod-parity.ts +50 -0
  235. package/src/application/agent/providers/claude-code/permission-config.test.ts +221 -0
  236. package/src/application/agent/providers/claude-code/permission-config.ts +242 -0
  237. package/src/application/agent/providers/claude-code/provider.test.ts +378 -0
  238. package/src/application/agent/providers/claude-code/provider.ts +717 -0
  239. package/src/application/agent/providers/claude-code/resume-store.test.ts +161 -0
  240. package/src/application/agent/providers/claude-code/resume-store.ts +157 -0
  241. package/src/application/agent/providers/claude-code/stream-parser.ts +166 -0
  242. package/src/application/agent/test-fixture.ts +131 -0
  243. package/src/application/agent/workspace.test.ts +104 -0
  244. package/src/application/agent/workspace.ts +156 -0
  245. package/src/application/dispatcher.test.ts +108 -0
  246. package/src/application/dispatcher.ts +106 -0
  247. package/src/application/index.ts +5 -0
  248. package/src/application/registry.ts +24 -0
  249. package/src/application/version.ts +7 -0
  250. package/src/commands/attach-exclude.ts +50 -0
  251. package/src/commands/attach-git.ts +50 -0
  252. package/src/commands/attach-store.ts +107 -0
  253. package/src/commands/attach.test.ts +192 -0
  254. package/src/commands/attach.ts +143 -0
  255. package/src/commands/clse.test.ts +181 -0
  256. package/src/commands/doctor.test.ts +29 -0
  257. package/src/commands/doctor.ts +78 -0
  258. package/src/commands/elicit.test.ts +111 -0
  259. package/src/commands/elicit.ts +188 -0
  260. package/src/commands/evolve.ts +209 -0
  261. package/src/commands/feature.test.ts +323 -0
  262. package/src/commands/feature.ts +405 -0
  263. package/src/commands/fix.test.ts +118 -0
  264. package/src/commands/fix.ts +58 -0
  265. package/src/commands/help.test.ts +33 -0
  266. package/src/commands/help.ts +35 -0
  267. package/src/commands/host-apply.ts +61 -0
  268. package/src/commands/host.test.ts +120 -0
  269. package/src/commands/host.ts +125 -0
  270. package/src/commands/index.ts +25 -0
  271. package/src/commands/init.test.ts +87 -0
  272. package/src/commands/init.ts +110 -0
  273. package/src/commands/inspect.test.ts +57 -0
  274. package/src/commands/inspect.ts +73 -0
  275. package/src/commands/install.test.ts +92 -0
  276. package/src/commands/install.ts +389 -0
  277. package/src/commands/journal.ts +118 -0
  278. package/src/commands/memory.ts +96 -0
  279. package/src/commands/new.test.ts +44 -0
  280. package/src/commands/new.ts +77 -0
  281. package/src/commands/next.test.ts +241 -0
  282. package/src/commands/next.ts +124 -0
  283. package/src/commands/optimize.ts +30 -0
  284. package/src/commands/plugin-linker.test.ts +219 -0
  285. package/src/commands/plugin-linker.ts +244 -0
  286. package/src/commands/refactor.ts +34 -0
  287. package/src/commands/skills-install-commit.ts +149 -0
  288. package/src/commands/skills-install-manifest.ts +124 -0
  289. package/src/commands/skills-install-report.ts +60 -0
  290. package/src/commands/skills-install-secure.ts +113 -0
  291. package/src/commands/skills-install.ts +245 -0
  292. package/src/commands/skills.test.ts +449 -0
  293. package/src/commands/skills.ts +247 -0
  294. package/src/commands/stack-commands.test.ts +67 -0
  295. package/src/commands/tier-c-conformance.test.ts +194 -0
  296. package/src/commands/types.ts +26 -0
  297. package/src/commands/uninstall.test.ts +122 -0
  298. package/src/commands/uninstall.ts +116 -0
  299. package/src/commands/validate-plan.test.ts +107 -0
  300. package/src/commands/validate-plan.ts +67 -0
  301. package/src/commands/validate-spec.test.ts +59 -0
  302. package/src/commands/validate-spec.ts +68 -0
  303. package/src/commands/verify.test.ts +117 -0
  304. package/src/commands/verify.ts +112 -0
  305. package/src/commands/version.test.ts +11 -0
  306. package/src/commands/version.ts +14 -0
  307. package/src/index.ts +30 -0
  308. package/src/output/formatter.ts +10 -0
  309. package/src/output/index.ts +2 -0
@@ -0,0 +1,326 @@
1
+ // packages/cli/src/commands/feature.ts
2
+ //
3
+ // `kit feature <feature-id> [action] [task-id] [--dry-run] [--json]`.
4
+ //
5
+ // Phase driver for the TDD feature workflow (ADR-0018). The agent writes
6
+ // tests and implementations between invocations; the kit verifies,
7
+ // records evidence, and blocks completion without a complete
8
+ // Red -> Green -> Refactor chain per task.
9
+ //
10
+ // `kit feature <id> run` is Mode 1 (kit-orchestrated, ADR-0019): the kit
11
+ // drives the SAME TDD state machine through a configured agent provider
12
+ // in an isolated git worktree. Providers are injected at construction
13
+ // (createFeatureCommand({ agentProviders })); since PR4 the shipped CLI
14
+ // registers claude-code by DEFAULT — and gates on its healthCheck: when
15
+ // the claude CLI is missing or misconfigured, `run` fails blocked
16
+ // (exit 3) with an honest message, never a silent manual-workflow
17
+ // fallback (ADR-0019 §1, ADR-0020 §4).
18
+ import path from 'node:path';
19
+ import { finalizeFeatureRun, getFeatureRunState, runTddPhase, startFeatureRun, } from '@agentic-sdlc-kit/core';
20
+ import { AgentGateway, ClaudeCodeProvider, runFeatureOrchestration, } from '../application/agent/index.js';
21
+ const PHASES = ['red', 'green', 'refactor'];
22
+ function isPhase(action) {
23
+ return PHASES.includes(action);
24
+ }
25
+ function fail(ctx, message) {
26
+ ctx.stderr(`kit feature: ${message}\n`);
27
+ return { exitCode: 1, message };
28
+ }
29
+ function blocked(ctx, message) {
30
+ ctx.stderr(`kit feature: ${message}\n`);
31
+ return { exitCode: 3, message };
32
+ }
33
+ /**
34
+ * Resolve the journal actor (ADR-0021 §3). The kit cannot infer agent
35
+ * vs. human at the CLI boundary — a host DECLARES itself via `--host
36
+ * <id>` or the KIT_HOST environment variable, and the journal records
37
+ * the declaration. Undeclared invocations are recorded honestly as
38
+ * humans, not guessed to be agents.
39
+ */
40
+ function resolveActor(argv) {
41
+ const fromFlag = parseFlagValue(argv, '--host');
42
+ const host = fromFlag ?? (process.env['KIT_HOST'] && process.env['KIT_HOST'].length > 0
43
+ ? process.env['KIT_HOST']
44
+ : undefined);
45
+ return host !== undefined ? { kind: 'agent', host } : { kind: 'human' };
46
+ }
47
+ export function createFeatureCommand(opts = {}) {
48
+ return {
49
+ name: 'feature',
50
+ summary: 'Drive the TDD feature workflow (spec -> plan -> red/green/refactor -> verify) or orchestrate it through an agent provider (run).',
51
+ async run(ctx) {
52
+ if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
53
+ ctx.stdout(formatHelp());
54
+ return { exitCode: 0 };
55
+ }
56
+ const positional = ctx.argv.filter((a) => !a.startsWith('-'));
57
+ const featureId = positional[0];
58
+ if (!featureId) {
59
+ return fail(ctx, 'missing required feature identifier (e.g. FEATURE-001)');
60
+ }
61
+ const isJson = ctx.argv.includes('--json');
62
+ const action = positional[1] ?? 'auto';
63
+ const root = path.resolve(ctx.cwd, '.');
64
+ const actor = resolveActor(ctx.argv);
65
+ if (isPhase(action)) {
66
+ return runPhase(ctx, root, featureId, action, positional[2], isJson, actor);
67
+ }
68
+ switch (action) {
69
+ case 'start':
70
+ return runStart(ctx, root, featureId, isJson, actor);
71
+ case 'status':
72
+ return runStatus(ctx, root, featureId, isJson);
73
+ case 'verify':
74
+ return runVerify(ctx, root, featureId, isJson, ctx.argv.includes('--dry-run'), actor);
75
+ case 'run':
76
+ return runOrchestrated(ctx, root, featureId, isJson, opts);
77
+ case 'auto': {
78
+ const state = await getFeatureRunState(root, featureId);
79
+ return state.ok
80
+ ? runStatus(ctx, root, featureId, isJson)
81
+ : runStart(ctx, root, featureId, isJson, actor);
82
+ }
83
+ default:
84
+ return fail(ctx, `unknown action '${action}' (expected start|red|green|refactor|status|verify|run)`);
85
+ }
86
+ },
87
+ };
88
+ }
89
+ export const featureCommand = createFeatureCommand();
90
+ async function runStart(ctx, root, featureId, isJson, actor) {
91
+ const res = await startFeatureRun({ featureId, projectRoot: root, actor });
92
+ if (!res.ok)
93
+ return fail(ctx, res.error.message);
94
+ if (isJson) {
95
+ ctx.stdout(JSON.stringify(res.value, null, 2) + '\n');
96
+ return { exitCode: 0 };
97
+ }
98
+ const taskIds = Object.keys(res.value.tasks);
99
+ const first = taskIds[0] ?? 'none';
100
+ ctx.stdout([
101
+ `TDD run started for ${featureId} (${taskIds.length} task(s)).`,
102
+ `Next: write the failing test for ${first}, then run:`,
103
+ ` kit feature ${featureId} red ${first}`,
104
+ '',
105
+ ].join('\n'));
106
+ return { exitCode: 0 };
107
+ }
108
+ async function runPhase(ctx, root, featureId, phase, taskId, isJson, actor) {
109
+ if (!taskId)
110
+ return fail(ctx, `phase '${phase}' requires a task id (see \`kit feature ${featureId} status\`)`);
111
+ const res = await runTddPhase({ featureId, projectRoot: root, taskId, phase, actor });
112
+ if (!res.ok)
113
+ return fail(ctx, res.error.message);
114
+ if (isJson) {
115
+ ctx.stdout(JSON.stringify(res.value, null, 2) + '\n');
116
+ return { exitCode: 0 };
117
+ }
118
+ ctx.stdout(formatPhaseMessage(featureId, taskId, phase));
119
+ return { exitCode: 0 };
120
+ }
121
+ function formatPhaseMessage(featureId, taskId, phase) {
122
+ if (phase === 'red') {
123
+ return [
124
+ `${taskId} red recorded: verification failed as expected.`,
125
+ `Next: implement ${taskId} minimally, then run:`,
126
+ ` kit feature ${featureId} green ${taskId}`,
127
+ '',
128
+ ].join('\n');
129
+ }
130
+ if (phase === 'green') {
131
+ return [
132
+ `${taskId} green recorded: verification passed.`,
133
+ `Next: refactor ${taskId} if needed, then run:`,
134
+ ` kit feature ${featureId} refactor ${taskId}`,
135
+ '',
136
+ ].join('\n');
137
+ }
138
+ return [
139
+ `${taskId} completed (red -> green -> refactor recorded).`,
140
+ 'Continue with the next task, or run `verify` when all tasks are done:',
141
+ ` kit feature ${featureId} verify`,
142
+ '',
143
+ ].join('\n');
144
+ }
145
+ async function runStatus(ctx, root, featureId, isJson) {
146
+ const res = await getFeatureRunState(root, featureId);
147
+ if (!res.ok)
148
+ return fail(ctx, res.error.message);
149
+ if (isJson) {
150
+ ctx.stdout(JSON.stringify(res.value, null, 2) + '\n');
151
+ return { exitCode: 0 };
152
+ }
153
+ const lines = [`Feature run ${featureId}:`];
154
+ for (const task of Object.values(res.value.tasks)) {
155
+ lines.push(` ${task.taskId}: ${task.phase} (${task.records.length} record(s))`);
156
+ }
157
+ const pending = Object.values(res.value.tasks).find((t) => t.phase !== 'completed');
158
+ if (pending) {
159
+ lines.push(`Next action: kit feature ${featureId} ${pending.phase} ${pending.taskId}`);
160
+ }
161
+ else {
162
+ lines.push(`All tasks complete. Next action: kit feature ${featureId} verify`);
163
+ }
164
+ ctx.stdout(lines.join('\n') + '\n');
165
+ return { exitCode: 0 };
166
+ }
167
+ async function runVerify(ctx, root, featureId, isJson, dryRun, actor) {
168
+ const res = await finalizeFeatureRun({ featureId, projectRoot: root, dryRun, actor });
169
+ if (!res.ok)
170
+ return fail(ctx, res.error.message);
171
+ if (isJson) {
172
+ ctx.stdout(JSON.stringify(res.value, null, 2) + '\n');
173
+ }
174
+ else {
175
+ ctx.stdout(formatSummary(res.value));
176
+ }
177
+ return { exitCode: res.value.status === 'passed' ? 0 : 1 };
178
+ }
179
+ /**
180
+ * Mode 1 (ADR-0019): orchestrate the whole feature through a configured
181
+ * agent provider. Providers come from the command's construction options;
182
+ * since PR4 the shipped CLI registers claude-code by default and gates on
183
+ * its healthCheck — an unavailable runtime is a blocked run (exit 3) with
184
+ * an honest message, never a silent manual-workflow fallback.
185
+ */
186
+ async function runOrchestrated(ctx, root, featureId, isJson, opts) {
187
+ const providerFlag = parseFlagValue(ctx.argv, '--provider') ?? 'claude-code';
188
+ const maxDurationMs = parseFlagValue(ctx.argv, '--max-duration-ms');
189
+ // PR4: the shipped CLI registers claude-code against the resolved root
190
+ // (the provider roots its encrypted resume store there). Explicitly
191
+ // injected providers override the default entirely.
192
+ const providers = opts.agentProviders ?? [new ClaudeCodeProvider({ projectRoot: root })];
193
+ const gateway = new AgentGateway({
194
+ providers,
195
+ projectRoot: root,
196
+ });
197
+ // Health gate: a REGISTERED provider whose runtime is unavailable is a
198
+ // blocked run (exit 3) with an honest message — never a spawn that
199
+ // would flake into a silent manual-workflow fallback (ADR-0020 §4).
200
+ if (gateway.hasProvider(providerFlag)) {
201
+ const provider = providers.find((p) => p.id === providerFlag);
202
+ const health = await provider?.healthCheck();
203
+ if (provider && health && !health.available) {
204
+ return blocked(ctx, `AGENT_PROVIDER_UNAVAILABLE: provider '${providerFlag}' is registered but its ` +
205
+ `runtime is unavailable: ${health.message ?? 'no detail'}. Mode 1 execution will ` +
206
+ `not fall back to pretending a manual workflow completed — install the ` +
207
+ `provider runtime or drive the phases yourself with red/green/refactor.`);
208
+ }
209
+ }
210
+ const controller = new AbortController();
211
+ const onSigint = () => controller.abort();
212
+ process.once('SIGINT', onSigint);
213
+ try {
214
+ const res = await runFeatureOrchestration({
215
+ projectRoot: root,
216
+ featureId,
217
+ gateway,
218
+ providerId: providerFlag,
219
+ ...(maxDurationMs !== undefined && Number.isFinite(Number(maxDurationMs))
220
+ ? { maxDurationMs: Math.max(1, Math.floor(Number(maxDurationMs))) }
221
+ : {}),
222
+ signal: controller.signal,
223
+ ...(isJson ? {} : { onProgress: (line) => ctx.stdout(line) }),
224
+ });
225
+ if (!res.ok) {
226
+ if (res.error.code === 'AGENT_PROVIDER_NOT_CONFIGURED')
227
+ return blocked(ctx, res.error.message);
228
+ return fail(ctx, res.error.message);
229
+ }
230
+ const report = res.value;
231
+ if (isJson) {
232
+ ctx.stdout(JSON.stringify(report, null, 2) + '\n');
233
+ }
234
+ else {
235
+ ctx.stdout(formatOrchestrationReport(report));
236
+ }
237
+ if (report.status === 'completed')
238
+ return { exitCode: 0 };
239
+ if (report.status === 'needs_approval')
240
+ return blocked(ctx, report.message);
241
+ return { exitCode: 1, message: report.message };
242
+ }
243
+ finally {
244
+ process.removeListener('SIGINT', onSigint);
245
+ }
246
+ }
247
+ function parseFlagValue(argv, flag) {
248
+ const i = argv.indexOf(flag);
249
+ if (i === -1)
250
+ return undefined;
251
+ const value = argv[i + 1];
252
+ if (!value || value.startsWith('-'))
253
+ return undefined;
254
+ return value;
255
+ }
256
+ function formatOrchestrationReport(report) {
257
+ const lines = [
258
+ `Feature Orchestration: ${report.featureId} (run ${report.runId}, provider ${report.providerId})`,
259
+ `Status: ${report.status.toUpperCase()}`,
260
+ `Workspace: ${report.worktreePath} (branch ${report.workspace.branch ?? 'n/a'})`,
261
+ ];
262
+ for (const t of report.tasks) {
263
+ lines.push(` ${t.taskId}: ${t.completed ? 'completed' : `stopped at ${t.phase}`} (${t.records} evidence record(s))`);
264
+ }
265
+ lines.push(`Executions: ${report.executions.length} agent execution(s)`);
266
+ for (const e of report.executions) {
267
+ lines.push(` ${e.executionId}: ${e.outcome}`);
268
+ }
269
+ if (report.verification) {
270
+ lines.push(`Final verification: ${report.verification.status.toUpperCase()} (${report.verification.checks.length} checks)`);
271
+ }
272
+ lines.push(report.message);
273
+ return lines.join('\n') + '\n';
274
+ }
275
+ function formatSummary(report) {
276
+ const evidence = report.tddEvidence
277
+ .map((t) => `${t.taskId} [${t.records.map((r) => `${r.phase}:${r.status}`).join(' ')}]`)
278
+ .join('; ');
279
+ const lines = [
280
+ `Feature Workflow: ${report.featureId} (${report.spec.title})`,
281
+ `Status: ${report.status.toUpperCase()}`,
282
+ `Tasks Executed: ${report.tasksExecuted.length} tasks (${report.tasksExecuted.join(', ')})`,
283
+ `TDD Evidence: ${evidence}`,
284
+ `Verification: ${report.verification.status.toUpperCase()} (${report.verification.checks.length} checks)`,
285
+ `Total Duration: ${report.durationMs}ms`,
286
+ ];
287
+ return lines.join('\n') + '\n';
288
+ }
289
+ function formatHelp() {
290
+ return [
291
+ 'Usage: kit feature <feature-id> [action] [task-id] [--dry-run] [--json]',
292
+ ' kit feature <feature-id> run [--provider <id>] [--max-duration-ms <n>] [--json]',
293
+ '',
294
+ 'Drive the TDD feature workflow phase by phase, or orchestrate it end-to-end',
295
+ 'through an agent provider. The kit verifies, records evidence, and blocks',
296
+ 'completion until every task has a complete Red -> Green -> Refactor evidence chain.',
297
+ '',
298
+ 'Actions:',
299
+ ' start validate spec/plan and initialize the run state',
300
+ ' red <task-id> run verification: it MUST fail (test targets new behavior)',
301
+ ' green <task-id> run verification: it MUST pass (after implementing)',
302
+ ' refactor <task-id> run verification: it MUST pass (behavior preserved)',
303
+ ' status show run state and the next action',
304
+ ' verify audit the evidence chain and run final verification',
305
+ ' run Mode 1: orchestrate all phases through an agent provider',
306
+ ' in an isolated git worktree (ADR-0019)',
307
+ ' (none) start if no run exists, otherwise show status',
308
+ '',
309
+ 'Options:',
310
+ ' --dry-run (verify only) simulate the final verification',
311
+ ' --provider <id> (run only) agent provider to orchestrate through (default: claude-code)',
312
+ ' --max-duration-ms N (run only) per-execution duration budget',
313
+ ' --host <id> declare the invoking host for the execution journal',
314
+ ' (ADR-0021; also read from KIT_HOST)',
315
+ ' --json output machine-readable run state or report',
316
+ ' --help Show this message',
317
+ '',
318
+ 'Exit codes:',
319
+ ' 0 action succeeded / feature completed',
320
+ ' 1 verification or orchestration failed',
321
+ ' 3 blocked: no agent provider configured (AGENT_PROVIDER_NOT_CONFIGURED)',
322
+ ' or the run is waiting for a required approval',
323
+ '',
324
+ ].join('\n');
325
+ }
326
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/commands/feature.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,yEAAyE;AACzE,mEAAmE;AACnE,6DAA6D;AAC7D,2CAA2C;AAC3C,EAAE;AACF,yEAAyE;AACzE,wEAAwE;AACxE,sEAAsE;AACtE,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;AAClE,kEAAkE;AAClE,uCAAuC;AAEvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,eAAe,GAEhB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,GAExB,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAGrD,SAAS,OAAO,CAAC,MAAc;IAC7B,OAAQ,MAA4B,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,IAAI,CAAC,GAAmB,EAAE,OAAe;IAChD,GAAG,CAAC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S,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG;QAC/D,sBAAsB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE;QACnD,sBAAsB,MAAM,CAAC,aAAa,CAAC,MAAM,WAAW,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC9F,sBAAsB,QAAQ,EAAE;QAChC,sBAAsB,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,UAAU;QAC9G,sBAAsB,MAAM,CAAC,UAAU,IAAI;KAC5C,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,SAAS,UAAU;IACjB,OAAO;QACL,yEAAyE;QACzE,wFAAwF;QACxF,EAAE;QACF,6EAA6E;QAC7E,2EAA2E;QAC3E,qFAAqF;QACrF,EAAE;QACF,UAAU;QACV,wEAAwE;QACxE,mFAAmF;QACnF,4EAA4E;QAC5E,4EAA4E;QAC5E,2DAA2D;QAC3D,4EAA4E;QAC5E,iFAAiF;QACjF,+DAA+D;QAC/D,sEAAsE;QACtE,EAAE;QACF,UAAU;QACV,sEAAsE;QACtE,gGAAgG;QAChG,iEAAiE;QACjE,4EAA4E;QAC5E,4DAA4D;QAC5D,oEAAoE;QACpE,0CAA0C;QAC1C,EAAE;QACF,aAAa;QACb,2CAA2C;QAC3C,2CAA2C;QAC3C,4EAA4E;QAC5E,oDAAoD;QACpD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from './types.js';
2
+ export declare function createFixCommand(engine?: Command): Command;
3
+ export declare const fixCommand: Command;
4
+ //# sourceMappingURL=fix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.d.ts","sourceRoot":"","sources":["../../src/commands/fix.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAEzE,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,OAAwB,GAAG,OAAO,CAkB1E;AAED,eAAO,MAAM,UAAU,EAAE,OAA4B,CAAC"}
@@ -0,0 +1,53 @@
1
+ // packages/cli/src/commands/fix.ts
2
+ //
3
+ // `kit fix <issue-id> [action] [task-id] [options]`.
4
+ //
5
+ // A defect is driven through the SAME evidence-gated engine as a feature
6
+ // (`kit feature`): the regression test must fail as an ASSERTION (Red) before
7
+ // the correction is accepted (Green), then the suite must stay green
8
+ // (Refactor), with a hash-chained journal and `kit next` guidance.
9
+ //
10
+ // This command used to run the whole-profile verification and report a
11
+ // "confirmed" regression without ever observing a failing test. It no longer
12
+ // carries any workflow of its own: it only delegates, so it cannot assert more
13
+ // than the engine has measured.
14
+ import { featureCommand } from './feature.js';
15
+ export function createFixCommand(engine = featureCommand) {
16
+ return {
17
+ name: 'fix',
18
+ summary: 'Fix a defect through the evidence-gated engine: failing regression test first (Red/Green/Refactor).',
19
+ async run(ctx) {
20
+ if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
21
+ ctx.stdout(formatHelp());
22
+ return { exitCode: 0 };
23
+ }
24
+ const issueId = ctx.argv.find((a) => !a.startsWith('-'));
25
+ if (!issueId) {
26
+ ctx.stderr('kit fix: error: missing required issue identifier (e.g. BUG-001)\n');
27
+ return { exitCode: 1, message: 'Missing issue ID' };
28
+ }
29
+ return engine.run(ctx);
30
+ },
31
+ };
32
+ }
33
+ export const fixCommand = createFixCommand();
34
+ function formatHelp() {
35
+ return [
36
+ 'Usage: kit fix <issue-id> [start|red|green|refactor|status|verify|run] [task-id] [options]',
37
+ '',
38
+ 'Drive a bug fix through the same evidence gates as a feature. The issue id is the',
39
+ 'run id (e.g. BUG-101): author docs/specifications/features/<id>/SPEC.md (expected vs',
40
+ 'actual behavior) and docs/plans/<id>/plan.json, then:',
41
+ '',
42
+ ' kit fix BUG-101 start begin the run (no action: start, or status if it exists)',
43
+ ' kit fix BUG-101 red TASK-001 the regression test must FAIL as an assertion',
44
+ ' kit fix BUG-101 green TASK-001 the smallest correction must pass it',
45
+ ' kit fix BUG-101 refactor TASK-001 the suite must stay green',
46
+ ' kit fix BUG-101 verify audit every chain + whole-profile regression',
47
+ '',
48
+ 'Options are those of `kit feature` (--json, --host <id>, --dry-run, ...).',
49
+ 'Do not combine a behavior fix with a refactor in one run.',
50
+ '',
51
+ ].join('\n');
52
+ }
53
+ //# sourceMappingURL=fix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.js","sourceRoot":"","sources":["../../src/commands/fix.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,qEAAqE;AACrE,mEAAmE;AACnE,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,+EAA+E;AAC/E,gCAAgC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,MAAM,UAAU,gBAAgB,CAAC,SAAkB,cAAc;IAC/D,OAAO;QACL,IAAI,EAAE,KAAK;QACX,OAAO,EACL,qGAAqG;QACvG,KAAK,CAAC,GAAG,CAAC,GAAmB;YAC3B,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3D,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;gBACzB,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;YACzB,CAAC;YACD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YACzD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,GAAG,CAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC;gBACjF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;YACtD,CAAC;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAY,gBAAgB,EAAE,CAAC;AAEtD,SAAS,UAAU;IACjB,OAAO;QACL,4FAA4F;QAC5F,EAAE;QACF,mFAAmF;QACnF,sFAAsF;QACtF,uDAAuD;QACvD,EAAE;QACF,6FAA6F;QAC7F,kFAAkF;QAClF,yEAAyE;QACzE,gEAAgE;QAChE,iFAAiF;QACjF,EAAE;QACF,2EAA2E;QAC3E,2DAA2D;QAC3D,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CommandRegistry } from '../application/registry.js';
2
+ import type { Command } from './types.js';
3
+ export declare function makeHelpCommand(registry: CommandRegistry): Command;
4
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAEzE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CA2BlE"}
@@ -0,0 +1,32 @@
1
+ // packages/cli/src/commands/help.ts
2
+ //
3
+ // `kit --help` / `kit help`. Lists every registered command.
4
+ export function makeHelpCommand(registry) {
5
+ return {
6
+ name: 'help',
7
+ summary: 'Show this help.',
8
+ run(ctx) {
9
+ const lines = [];
10
+ lines.push('kit — Agentic SDLC Kit');
11
+ lines.push('');
12
+ lines.push('USAGE:');
13
+ lines.push(' kit <command> [options]');
14
+ lines.push('');
15
+ lines.push('COMMANDS:');
16
+ const maxName = Math.max(...registry.list().map((c) => c.name.length));
17
+ for (const c of registry.list()) {
18
+ const pad = ' '.repeat(maxName - c.name.length + 2);
19
+ lines.push(` ${c.name}${pad}${c.summary}`);
20
+ }
21
+ lines.push('');
22
+ lines.push('FLAGS:');
23
+ lines.push(' --help, -h Show this help.');
24
+ lines.push(' --version, -v Print the kit version.');
25
+ lines.push('');
26
+ lines.push('Exit codes: 0 success, 1 unknown command, 2 runtime error.');
27
+ ctx.stdout(lines.join('\n'));
28
+ return { exitCode: 0 };
29
+ },
30
+ };
31
+ }
32
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,EAAE;AACF,6DAA6D;AAK7D,MAAM,UAAU,eAAe,CAAC,QAAyB;IACvD,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,iBAAiB;QAC1B,GAAG,CAAC,GAAmB;YACrB,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACvE,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACpD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;YAChD,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;YACvD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;YACzE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7B,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type HostTarget } from '@agentic-sdlc-kit/core';
2
+ export type ApplyAction = 'created' | 'updated' | 'unchanged' | 'refused';
3
+ export interface ApplyResult {
4
+ readonly path: string;
5
+ readonly action: ApplyAction;
6
+ readonly reason?: string;
7
+ }
8
+ export declare function applyTarget(root: string, target: HostTarget, opts: {
9
+ force: boolean;
10
+ dryRun: boolean;
11
+ }): Promise<ApplyResult>;
12
+ //# sourceMappingURL=host-apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-apply.d.ts","sourceRoot":"","sources":["../../src/commands/host-apply.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAE1E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AA+BD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACxC,OAAO,CAAC,WAAW,CAAC,CAUtB"}
@@ -0,0 +1,43 @@
1
+ // packages/cli/src/commands/host-apply.ts
2
+ //
3
+ // Applies planned host-instruction targets to disk. Never overwrites a file
4
+ // the user edited (or one the kit did not write) unless --force is given.
5
+ import { promises as fs } from 'node:fs';
6
+ import path from 'node:path';
7
+ import { inspectManaged, upsertBlock } from '@agentic-sdlc-kit/core';
8
+ async function readOrNull(p) {
9
+ try {
10
+ return await fs.readFile(p, 'utf8');
11
+ }
12
+ catch {
13
+ return null;
14
+ }
15
+ }
16
+ function decideBlock(existing, target) {
17
+ const next = upsertBlock(existing, target.content);
18
+ if (existing === null)
19
+ return { action: 'created', next };
20
+ return next === existing ? { action: 'unchanged' } : { action: 'updated', next };
21
+ }
22
+ function decideFile(existing, target, force) {
23
+ const state = inspectManaged(existing);
24
+ if (state === 'absent')
25
+ return { action: 'created', next: target.content };
26
+ if (existing === target.content)
27
+ return { action: 'unchanged' };
28
+ if (state === 'unmodified' || force)
29
+ return { action: 'updated', next: target.content };
30
+ const why = state === 'modified' ? 'edited since install' : 'not written by the kit';
31
+ return { action: 'refused', reason: `${why}; re-run with --force to replace` };
32
+ }
33
+ export async function applyTarget(root, target, opts) {
34
+ const abs = path.join(root, target.path);
35
+ const existing = await readOrNull(abs);
36
+ const d = target.mode === 'block' ? decideBlock(existing, target) : decideFile(existing, target, opts.force);
37
+ if (d.next !== undefined && !opts.dryRun) {
38
+ await fs.mkdir(path.dirname(abs), { recursive: true });
39
+ await fs.writeFile(abs, d.next, 'utf8');
40
+ }
41
+ return { path: abs, action: d.action, ...(d.reason ? { reason: d.reason } : {}) };
42
+ }
43
+ //# sourceMappingURL=host-apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-apply.js","sourceRoot":"","sources":["../../src/commands/host-apply.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAE1E,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAmB,MAAM,wBAAwB,CAAC;AAUtF,KAAK,UAAU,UAAU,CAAC,CAAS;IACjC,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAQD,SAAS,WAAW,CAAC,QAAuB,EAAE,MAAkB;IAC9D,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC;AAED,SAAS,UAAU,CAAC,QAAuB,EAAE,MAAkB,EAAE,KAAc;IAC7E,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,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AAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACpF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ export declare const hostCommand: Command;
3
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/commands/host.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAgFzE,eAAO,MAAM,WAAW,EAAE,OAkBzB,CAAC"}
@@ -0,0 +1,107 @@
1
+ // packages/cli/src/commands/host.ts
2
+ //
3
+ // `kit host list | install <host|all> [--scope user|project] [--dir <p>]
4
+ // [--home <p>] [--force] [--dry-run] [--json]`
5
+ //
6
+ // Installs the standing agent procedure into each AI host's instruction
7
+ // surface once, so per ticket the user types a single line and the host
8
+ // drives the kit's evidence-gated loop (`kit next --json`) on its own.
9
+ import os from 'node:os';
10
+ import path from 'node:path';
11
+ import { DEFAULT_SCOPE, HOST_IDS, isHostId, planHostTargets, } from '@agentic-sdlc-kit/core';
12
+ import { applyTarget } from './host-apply.js';
13
+ const USAGE = [
14
+ 'Usage: kit host list',
15
+ ' kit host install <host|all> [--scope user|project] [--dir <project>] [--home <dir>]',
16
+ ' [--force] [--dry-run] [--json]',
17
+ '',
18
+ `Hosts: ${HOST_IDS.join(', ')}`,
19
+ 'Default scope: user where the host has a global surface, otherwise project.',
20
+ 'Existing files you edited are never overwritten without --force; shared files',
21
+ '(AGENTS.md, GEMINI.md, CONVENTIONS.md) only get a replaceable managed block.',
22
+ ].join('\n');
23
+ function opt(argv, name) {
24
+ const i = argv.indexOf(name);
25
+ const v = i === -1 ? undefined : argv[i + 1];
26
+ return v && !v.startsWith('-') ? v : undefined;
27
+ }
28
+ function listText() {
29
+ const lines = ['kit host: instruction surfaces', ''];
30
+ for (const host of HOST_IDS) {
31
+ const scope = DEFAULT_SCOPE[host];
32
+ const paths = planHostTargets(host, scope).map((t) => t.path);
33
+ lines.push(` ${host.padEnd(12)} [${scope}] ${paths.join(', ')}`);
34
+ }
35
+ return lines.join('\n');
36
+ }
37
+ function resolvePlans(ctx, which) {
38
+ const explicit = opt(ctx.argv, '--scope');
39
+ if (explicit !== undefined && explicit !== 'user' && explicit !== 'project') {
40
+ return `--scope must be 'user' or 'project' (got '${explicit}')`;
41
+ }
42
+ if (which !== 'all' && !isHostId(which))
43
+ return `unknown host '${which}'`;
44
+ const hosts = which === 'all' ? [...HOST_IDS] : [which];
45
+ const home = path.resolve(opt(ctx.argv, '--home') ?? os.homedir());
46
+ const project = path.resolve(ctx.cwd, opt(ctx.argv, '--dir') ?? '.');
47
+ const plans = [];
48
+ for (const host of hosts) {
49
+ const scope = explicit ?? DEFAULT_SCOPE[host];
50
+ if (!planHostTargets(host, scope)) {
51
+ if (which === 'all')
52
+ continue; // an explicit scope that some hosts lack is not an error for 'all'
53
+ return `${host} has no ${scope}-scope instruction surface`;
54
+ }
55
+ plans.push({ host, scope, root: scope === 'user' ? home : project });
56
+ }
57
+ return plans;
58
+ }
59
+ async function runInstall(ctx, which) {
60
+ const plans = resolvePlans(ctx, which);
61
+ if (typeof plans === 'string') {
62
+ ctx.stderr(`kit host: ${plans}`);
63
+ return { exitCode: 1 };
64
+ }
65
+ const opts = { force: ctx.argv.includes('--force'), dryRun: ctx.argv.includes('--dry-run') };
66
+ const results = [];
67
+ for (const p of plans) {
68
+ for (const t of planHostTargets(p.host, p.scope)) {
69
+ results.push({ host: p.host, scope: p.scope, ...(await applyTarget(p.root, t, opts)) });
70
+ }
71
+ }
72
+ const refused = results.some((r) => r.action === 'refused');
73
+ ctx.stdout(formatResults(results, opts.dryRun, ctx.argv.includes('--json')));
74
+ return { exitCode: refused ? 1 : 0 };
75
+ }
76
+ function formatResults(rs, dry, json) {
77
+ if (json)
78
+ return JSON.stringify({ dryRun: dry, results: rs }, null, 2);
79
+ const lines = rs.map((r) => ` ${r.action.padEnd(9)} ${r.host.padEnd(12)} ${r.path}${r.reason ? ` (${r.reason})` : ''}`);
80
+ return [dry ? 'kit host install (dry run, nothing written)' : 'kit host install', ...lines].join('\n');
81
+ }
82
+ export const hostCommand = {
83
+ name: 'host',
84
+ summary: 'Install the standing agent procedure into AI hosts (claude-code, codex, cursor, agy, gemini, aider).',
85
+ async run(ctx) {
86
+ const positional = ctx.argv.filter((a, i) => !a.startsWith('-') && !isOptValue(ctx.argv, i));
87
+ const [sub, which] = positional;
88
+ if (ctx.argv.includes('--help') || !sub) {
89
+ ctx.stdout(USAGE);
90
+ return { exitCode: sub || ctx.argv.includes('--help') ? 0 : 1 };
91
+ }
92
+ if (sub === 'list') {
93
+ ctx.stdout(listText());
94
+ return { exitCode: 0 };
95
+ }
96
+ if (sub === 'install' && which)
97
+ return runInstall(ctx, which);
98
+ ctx.stderr(`kit host: unknown or incomplete subcommand\n${USAGE}`);
99
+ return { exitCode: 1 };
100
+ },
101
+ };
102
+ /** True when argv[i] is the value of a value-taking flag (so it is not a positional). */
103
+ function isOptValue(argv, i) {
104
+ const prev = argv[i - 1];
105
+ return prev === '--scope' || prev === '--dir' || prev === '--home';
106
+ }
107
+ //# sourceMappingURL=host.js.map