@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,116 @@
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 { uninstallCommand } from '../commands/uninstall.js';
19
+ import { memoryCommand } from '../commands/memory.js';
20
+ import { evolveCommand } from '../commands/evolve.js';
21
+ import { refactorCommand } from '../commands/refactor.js';
22
+ import { optimizeCommand } from '../commands/optimize.js';
23
+ import { nextCommand } from '../commands/next.js';
24
+ import { journalCommand } from '../commands/journal.js';
25
+ import { skillsCommand } from '../commands/skills.js';
26
+ import { attachCommand } from '../commands/attach.js';
27
+ import { hostCommand } from '../commands/host.js';
28
+ import { createCommandRegistry } from './registry.js';
29
+ import { VERSION } from './version.js';
30
+ export function createDispatcher(opts = {}) {
31
+ const registry = opts.registry ?? createCommandRegistry();
32
+ // Register default commands. Help needs the registry so it is built lazily.
33
+ if (!registry.get('version'))
34
+ registry.register(versionCommand);
35
+ if (!registry.get('doctor'))
36
+ registry.register(doctorCommand);
37
+ if (!registry.get('inspect'))
38
+ registry.register(inspectCommand);
39
+ if (!registry.get('init'))
40
+ registry.register(initCommand);
41
+ if (!registry.get('validate-spec'))
42
+ registry.register(validateSpecCommand);
43
+ if (!registry.get('elicit'))
44
+ registry.register(elicitCommand);
45
+ if (!registry.get('validate-plan'))
46
+ registry.register(validatePlanCommand);
47
+ if (!registry.get('verify'))
48
+ registry.register(verifyCommand);
49
+ if (!registry.get('feature'))
50
+ registry.register(featureCommand);
51
+ if (!registry.get('new'))
52
+ registry.register(newCommand);
53
+ if (!registry.get('fix'))
54
+ registry.register(fixCommand);
55
+ if (!registry.get('install'))
56
+ registry.register(installCommand);
57
+ if (!registry.get('uninstall'))
58
+ registry.register(uninstallCommand);
59
+ if (!registry.get('memory'))
60
+ registry.register(memoryCommand);
61
+ if (!registry.get('evolve'))
62
+ registry.register(evolveCommand);
63
+ if (!registry.get('refactor'))
64
+ registry.register(refactorCommand);
65
+ if (!registry.get('optimize'))
66
+ registry.register(optimizeCommand);
67
+ if (!registry.get('next'))
68
+ registry.register(nextCommand);
69
+ if (!registry.get('journal'))
70
+ registry.register(journalCommand);
71
+ if (!registry.get('skills'))
72
+ registry.register(skillsCommand);
73
+ if (!registry.get('attach'))
74
+ registry.register(attachCommand);
75
+ if (!registry.get('host'))
76
+ registry.register(hostCommand);
77
+ if (!registry.get('help'))
78
+ registry.register(makeHelpCommand(registry));
79
+ return {
80
+ registry,
81
+ async dispatch(ctx) {
82
+ const argv = ctx.argv;
83
+ // --version / -v
84
+ if (argv.includes('--version') || argv.includes('-v')) {
85
+ return { exitCode: 0, message: VERSION, command: 'version' };
86
+ }
87
+ // --help / -h with no further command, OR no args at all
88
+ if (argv.length === 0 || argv.includes('--help') || argv.includes('-h')) {
89
+ const help = registry.get('help');
90
+ if (!help)
91
+ return { exitCode: 1, command: 'help', message: 'help command missing' };
92
+ const r = await help.run(ctx);
93
+ return { ...r, command: 'help' };
94
+ }
95
+ // First non-flag argument is the command name.
96
+ const first = argv.find((a) => !a.startsWith('-'));
97
+ if (!first) {
98
+ const help = registry.get('help');
99
+ if (help) {
100
+ const r = await help.run(ctx);
101
+ return { ...r, command: 'help' };
102
+ }
103
+ return { exitCode: 1, message: 'no command' };
104
+ }
105
+ const cmd = registry.get(first);
106
+ if (!cmd) {
107
+ ctx.stderr(`kit: unknown command '${first}'\nRun 'kit --help' for usage.\n`);
108
+ return { exitCode: 1, command: first, message: 'unknown command' };
109
+ }
110
+ const rest = argv.filter((a) => a !== first);
111
+ const r = await cmd.run({ ...ctx, argv: rest });
112
+ return { ...r, command: first };
113
+ },
114
+ };
115
+ }
116
+ //# sourceMappingURL=dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src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C,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YACnD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAClC,IAAI,IAAI,EAAE,CAAC;oBACT,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAC9B,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;gBACnC,CAAC;gBACD,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,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,5 @@
1
+ export * from './version.js';
2
+ export * from './registry.js';
3
+ export * from './dispatcher.js';
4
+ export * from './agent/index.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -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,6 @@
1
+ // packages/cli/src/application/index.ts
2
+ export * from './version.js';
3
+ export * from './registry.js';
4
+ export * from './dispatcher.js';
5
+ export * from './agent/index.js';
6
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export declare const VERSION = "0.9.1";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -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.9.1';
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,8 @@
1
+ export declare const BLOCK_BEGIN = "# >>> kit-attach managed block >>>";
2
+ export declare const BLOCK_END = "# <<< kit-attach managed block <<<";
3
+ export declare function stripBlock(text: string): string;
4
+ export declare function withBlock(text: string, paths: readonly string[]): string;
5
+ export declare function writeBlock(file: string, paths: readonly string[]): Promise<void>;
6
+ export declare function removeBlock(file: string): Promise<void>;
7
+ export declare function hasBlock(file: string): Promise<boolean>;
8
+ //# sourceMappingURL=attach-exclude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-exclude.d.ts","sourceRoot":"","sources":["../../src/commands/attach-exclude.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,uCAAuC,CAAC;AAChE,eAAO,MAAM,SAAS,uCAAuC,CAAC;AAE9D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAIxE;AAUD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7D"}
@@ -0,0 +1,48 @@
1
+ // packages/cli/src/commands/attach-exclude.ts
2
+ //
3
+ // Managed block inside `.git/info/exclude`. Patterns carry NO trailing slash:
4
+ // a slash-suffixed gitignore pattern matches directories only and git treats
5
+ // a symlink as a file, so the symlinked (global) mode would leak.
6
+ import { promises as fs } from 'node:fs';
7
+ import path from 'node:path';
8
+ export const BLOCK_BEGIN = '# >>> kit-attach managed block >>>';
9
+ export const BLOCK_END = '# <<< kit-attach managed block <<<';
10
+ export function stripBlock(text) {
11
+ const out = [];
12
+ let skip = false;
13
+ for (const line of text.split('\n')) {
14
+ if (line === BLOCK_BEGIN)
15
+ skip = true;
16
+ if (!skip)
17
+ out.push(line);
18
+ if (line === BLOCK_END)
19
+ skip = false;
20
+ }
21
+ return out.join('\n');
22
+ }
23
+ export function withBlock(text, paths) {
24
+ const base = stripBlock(text).replace(/\n*$/, '');
25
+ const block = [BLOCK_BEGIN, ...paths, BLOCK_END].join('\n');
26
+ return (base ? base + '\n' : '') + block + '\n';
27
+ }
28
+ async function readOrEmpty(file) {
29
+ try {
30
+ return await fs.readFile(file, 'utf8');
31
+ }
32
+ catch {
33
+ return '';
34
+ }
35
+ }
36
+ export async function writeBlock(file, paths) {
37
+ await fs.mkdir(path.dirname(file), { recursive: true });
38
+ await fs.writeFile(file, withBlock(await readOrEmpty(file), paths));
39
+ }
40
+ export async function removeBlock(file) {
41
+ const text = await readOrEmpty(file);
42
+ if (text.includes(BLOCK_BEGIN))
43
+ await fs.writeFile(file, stripBlock(text));
44
+ }
45
+ export async function hasBlock(file) {
46
+ return (await readOrEmpty(file)).includes(BLOCK_BEGIN);
47
+ }
48
+ //# sourceMappingURL=attach-exclude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-exclude.js","sourceRoot":"","sources":["../../src/commands/attach-exclude.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,kEAAkE;AAElE,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,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,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,OAAO,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface RepoInfo {
2
+ /** Working-tree root of the repository (or linked worktree). */
3
+ root: string;
4
+ /** Shared git dir: where `info/exclude` must live so linked worktrees agree. */
5
+ commonDir: string;
6
+ }
7
+ export declare function resolveRepo(cwd: string): RepoInfo | null;
8
+ export declare function hasTrackedFiles(root: string, rel: string): boolean;
9
+ export declare function isIgnored(root: string, rel: string): boolean;
10
+ export declare function statusLeaks(root: string, rels: readonly string[]): string[];
11
+ //# sourceMappingURL=attach-git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-git.d.ts","sourceRoot":"","sources":["../../src/commands/attach-git.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAUD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAQxD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAO5D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAG3E"}
@@ -0,0 +1,40 @@
1
+ // packages/cli/src/commands/attach-git.ts
2
+ //
3
+ // Thin git helpers for `kit attach`. All calls use argument arrays (never a
4
+ // shell string) so paths with spaces or metacharacters cannot be injected.
5
+ import { execFileSync } from 'node:child_process';
6
+ import path from 'node:path';
7
+ function git(cwd, args) {
8
+ return execFileSync('git', [...args], {
9
+ cwd,
10
+ encoding: 'utf8',
11
+ stdio: ['ignore', 'pipe', 'pipe'],
12
+ });
13
+ }
14
+ export function resolveRepo(cwd) {
15
+ try {
16
+ const root = git(cwd, ['rev-parse', '--show-toplevel']).trim();
17
+ const common = git(root, ['rev-parse', '--git-common-dir']).trim();
18
+ return { root, commonDir: path.resolve(root, common) };
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ export function hasTrackedFiles(root, rel) {
25
+ return git(root, ['ls-files', '--', rel]).trim().length > 0;
26
+ }
27
+ export function isIgnored(root, rel) {
28
+ try {
29
+ git(root, ['check-ignore', '-q', '--', rel]);
30
+ return true;
31
+ }
32
+ catch {
33
+ return false; // exit 1 = not ignored
34
+ }
35
+ }
36
+ export function statusLeaks(root, rels) {
37
+ const out = git(root, ['status', '--porcelain', '--', ...rels]);
38
+ return out.split('\n').filter((l) => l.length > 0);
39
+ }
40
+ //# sourceMappingURL=attach-git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-git.js","sourceRoot":"","sources":["../../src/commands/attach-git.ts"],"names":[],"mappings":"AAAA,0CAA0C;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AAO,KAAK,CAAC,CAAC,uBAAuB;IACvC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAuB;IAC/D,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const MANAGED_PATHS: readonly string[];
2
+ export declare class AttachError extends Error {
3
+ }
4
+ export declare function storeDirFor(root: string, env?: NodeJS.ProcessEnv): string;
5
+ export declare const storeBase: (storeDir: string) => string;
6
+ export declare function attachLocal(root: string): Promise<void>;
7
+ export declare function attachGlobal(root: string, storeDir: string, adopt: boolean): Promise<void>;
8
+ export declare function detachLinks(root: string, base: string): Promise<string[]>;
9
+ export declare function describePath(root: string, rel: string): Promise<string>;
10
+ //# sourceMappingURL=attach-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-store.d.ts","sourceRoot":"","sources":["../../src/commands/attach-store.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAK1C,CAAC;AAEF,qBAAa,WAAY,SAAQ,KAAK;CAAG;AAEzC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAItF;AAED,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,MAAgC,CAAC;AAU9E,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ7D;AA8BD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIhG;AAWD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAW/E;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM7E"}
@@ -0,0 +1,107 @@
1
+ // packages/cli/src/commands/attach-store.ts
2
+ //
3
+ // Filesystem operations for `kit attach local|global|detach`.
4
+ import { createHash } from 'node:crypto';
5
+ import { promises as fs } from 'node:fs';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ export const MANAGED_PATHS = [
9
+ '.ai-kit',
10
+ '.claude',
11
+ 'docs/specifications',
12
+ 'docs/plans',
13
+ ];
14
+ export class AttachError extends Error {
15
+ }
16
+ export function storeDirFor(root, env = process.env) {
17
+ const base = env['KIT_ATTACH_HOME'] ?? path.join(os.homedir(), '.agentic-sdlc', 'projects');
18
+ const hash = createHash('sha256').update(root).digest('hex').slice(0, 8);
19
+ return path.join(base, `${path.basename(root)}-${hash}`);
20
+ }
21
+ export const storeBase = (storeDir) => path.dirname(storeDir);
22
+ async function lstatOrNull(p) {
23
+ try {
24
+ return await fs.lstat(p);
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ export async function attachLocal(root) {
31
+ for (const rel of MANAGED_PATHS) {
32
+ const abs = path.join(root, rel);
33
+ if ((await lstatOrNull(abs))?.isSymbolicLink()) {
34
+ throw new AttachError(`'${rel}' is a symlink; run 'kit attach detach' before switching modes`);
35
+ }
36
+ await fs.mkdir(abs, { recursive: true });
37
+ }
38
+ }
39
+ async function linkOne(root, storeDir, rel, adopt) {
40
+ const abs = path.join(root, rel);
41
+ const target = path.join(storeDir, rel);
42
+ await fs.mkdir(target, { recursive: true });
43
+ await fs.mkdir(path.dirname(abs), { recursive: true });
44
+ const st = await lstatOrNull(abs);
45
+ if (st?.isSymbolicLink()) {
46
+ if ((await fs.readlink(abs)) !== target) {
47
+ throw new AttachError(`'${rel}' points elsewhere; refusing to touch it`);
48
+ }
49
+ return;
50
+ }
51
+ if (st)
52
+ await migrateExisting(abs, target, rel, adopt);
53
+ await fs.symlink(target, abs, 'dir');
54
+ }
55
+ async function migrateExisting(abs, target, rel, adopt) {
56
+ const st = await fs.lstat(abs);
57
+ if (!st.isDirectory())
58
+ throw new AttachError(`'${rel}' exists and is not a directory`);
59
+ if ((await fs.readdir(abs)).length > 0) {
60
+ if (!adopt) {
61
+ throw new AttachError(`'${rel}' has content; re-run with --adopt to migrate it into the store`);
62
+ }
63
+ await fs.cp(abs, target, { recursive: true });
64
+ }
65
+ await fs.rm(abs, { recursive: true, force: true });
66
+ }
67
+ export async function attachGlobal(root, storeDir, adopt) {
68
+ // Preflight so a refusal on a later path cannot leave a half-attached repo.
69
+ for (const rel of MANAGED_PATHS)
70
+ await preflight(path.join(root, rel), rel, adopt);
71
+ for (const rel of MANAGED_PATHS)
72
+ await linkOne(root, storeDir, rel, adopt);
73
+ }
74
+ async function preflight(abs, rel, adopt) {
75
+ const st = await lstatOrNull(abs);
76
+ if (!st || st.isSymbolicLink())
77
+ return;
78
+ if (!st.isDirectory())
79
+ throw new AttachError(`'${rel}' exists and is not a directory`);
80
+ if (!adopt && (await fs.readdir(abs)).length > 0) {
81
+ throw new AttachError(`'${rel}' has content; re-run with --adopt to migrate it into the store`);
82
+ }
83
+ }
84
+ export async function detachLinks(root, base) {
85
+ const removed = [];
86
+ for (const rel of MANAGED_PATHS) {
87
+ const abs = path.join(root, rel);
88
+ if (!(await lstatOrNull(abs))?.isSymbolicLink())
89
+ continue;
90
+ const dest = await fs.readlink(abs);
91
+ if (!dest.startsWith(base + path.sep))
92
+ continue; // not ours
93
+ await fs.unlink(abs);
94
+ removed.push(rel);
95
+ }
96
+ return removed;
97
+ }
98
+ export async function describePath(root, rel) {
99
+ const abs = path.join(root, rel);
100
+ const st = await lstatOrNull(abs);
101
+ if (!st)
102
+ return `${rel} (absent)`;
103
+ if (st.isSymbolicLink())
104
+ return `${rel} -> ${await fs.readlink(abs)} (global)`;
105
+ return `${rel} (local dir)`;
106
+ }
107
+ //# sourceMappingURL=attach-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach-store.js","sourceRoot":"","sources":["../../src/commands/attach-store.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,8DAA8D;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAc,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,SAAS;IACT,SAAS;IACT,qBAAqB;IACrB,YAAY;CACb,CAAC;AAEF,MAAM,OAAO,WAAY,SAAQ,KAAK;CAAG;AAEzC,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC5E,MAAM,IAAI,GAAG,GAAG,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5F,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ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C,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,GAAW;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE;QAAE,OAAO,GAAG,GAAG,WAAW,CAAC;IAClC,IAAI,EAAE,CAAC,cAAc,EAAE;QAAE,OAAO,GAAG,GAAG,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;IAC/E,OAAO,GAAG,GAAG,cAAc,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Command } from './types.js';
2
+ /** Returns report lines; `leaked` is true when any managed path is visible to git. */
3
+ export declare function verifyInvisible(root: string): {
4
+ lines: string[];
5
+ leaked: boolean;
6
+ };
7
+ export declare const attachCommand: Command;
8
+ //# sourceMappingURL=attach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../src/commands/attach.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAazE,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAWlF;AAwDD,eAAO,MAAM,aAAa,EAAE,OA4B3B,CAAC"}
@@ -0,0 +1,124 @@
1
+ // packages/cli/src/commands/attach.ts
2
+ //
3
+ // `kit attach <local|global|status|detach> [--adopt]`
4
+ //
5
+ // Provisions the kit's working paths (.ai-kit, .claude, docs/specifications,
6
+ // docs/plans) WITHOUT touching tracked files, and proves git-invisibility
7
+ // before reporting success (fail closed).
8
+ // local real directories, hidden via .git/info/exclude
9
+ // global symlinks into $KIT_ATTACH_HOME/<repo>-<hash>/ (default
10
+ // ~/.agentic-sdlc/projects)
11
+ //
12
+ // Mode 1 (`kit feature <id> run`) needs committed artifacts and therefore
13
+ // cannot be used while attached; Mode 2 / `kit next` is unaffected.
14
+ import path from 'node:path';
15
+ import { hasTrackedFiles, isIgnored, resolveRepo, statusLeaks, } from './attach-git.js';
16
+ import { hasBlock, removeBlock, writeBlock } from './attach-exclude.js';
17
+ import { AttachError, MANAGED_PATHS, attachGlobal, attachLocal, describePath, detachLinks, storeBase, storeDirFor, } from './attach-store.js';
18
+ const USAGE = [
19
+ 'Usage: kit attach <local|global|status|detach> [--adopt]',
20
+ ' local real dirs in the repo, hidden via .git/info/exclude',
21
+ ' global symlinks into $KIT_ATTACH_HOME/<repo>-<hash>/',
22
+ ' status show mode per path and prove git invisibility',
23
+ ' detach remove exclude block; remove global symlinks (store data kept)',
24
+ ' --adopt global only: migrate existing UNTRACKED content into the store',
25
+ ].join('\n');
26
+ const excludeFile = (repo) => path.join(repo.commonDir, 'info', 'exclude');
27
+ /** Returns report lines; `leaked` is true when any managed path is visible to git. */
28
+ export function verifyInvisible(root) {
29
+ const lines = [];
30
+ let leaked = false;
31
+ for (const rel of MANAGED_PATHS) {
32
+ const ignored = isIgnored(root, rel);
33
+ lines.push(` ${ignored ? 'ignored: ' : 'NOT IGNORED:'} ${rel}`);
34
+ if (!ignored)
35
+ leaked = true;
36
+ }
37
+ const leaks = statusLeaks(root, MANAGED_PATHS);
38
+ for (const l of leaks)
39
+ lines.push(` git status LEAK: ${l}`);
40
+ return { lines, leaked: leaked || leaks.length > 0 };
41
+ }
42
+ function assertUntracked(root) {
43
+ for (const rel of MANAGED_PATHS) {
44
+ if (hasTrackedFiles(root, rel)) {
45
+ throw new AttachError(`REFUSED: '${rel}' contains tracked files. Untrack first (git rm -r --cached '${rel}').`);
46
+ }
47
+ }
48
+ }
49
+ function proof(root, header) {
50
+ const v = verifyInvisible(root);
51
+ if (v.leaked) {
52
+ const text = [...v.lines, 'verification failed: managed paths are visible to git'].join('\n');
53
+ return { exitCode: 1, text };
54
+ }
55
+ return { exitCode: 0, text: [header, ...v.lines, ' git status: clean for all managed paths.'].join('\n') };
56
+ }
57
+ async function runMode(mode, repo, adopt) {
58
+ assertUntracked(repo.root);
59
+ const store = storeDirFor(repo.root);
60
+ if (mode === 'local')
61
+ await attachLocal(repo.root);
62
+ else
63
+ await attachGlobal(repo.root, store, adopt);
64
+ await writeBlock(excludeFile(repo), MANAGED_PATHS);
65
+ return mode === 'local' ? `Attached (local). Exclude: ${excludeFile(repo)}` : `Attached (global). Store: ${store}`;
66
+ }
67
+ async function runStatus(repo) {
68
+ const lines = [`repo: ${repo.root}`, `store: ${storeDirFor(repo.root)}`];
69
+ for (const rel of MANAGED_PATHS)
70
+ lines.push(` ${await describePath(repo.root, rel)}`);
71
+ const present = await hasBlock(excludeFile(repo));
72
+ lines.push(`exclude block: ${present ? 'present' : 'absent'}`);
73
+ const v = verifyInvisible(repo.root);
74
+ lines.push(...v.lines);
75
+ return { exitCode: v.leaked ? 1 : 0, text: lines.join('\n') };
76
+ }
77
+ async function runDetach(repo) {
78
+ await removeBlock(excludeFile(repo));
79
+ const removed = await detachLinks(repo.root, storeBase(storeDirFor(repo.root)));
80
+ const lines = removed.map((r) => ` removed symlink: ${r} (data kept in store)`);
81
+ lines.push('Detached. Local directories (if any) left untouched.');
82
+ return lines.join('\n');
83
+ }
84
+ async function execute(sub, repo, adopt) {
85
+ if (sub === 'status')
86
+ return runStatus(repo);
87
+ if (sub === 'detach')
88
+ return { exitCode: 0, text: await runDetach(repo) };
89
+ if (adopt && sub !== 'global')
90
+ throw new AttachError("--adopt is only valid with 'global'");
91
+ const header = await runMode(sub, repo, adopt);
92
+ return proof(repo.root, header);
93
+ }
94
+ export const attachCommand = {
95
+ name: 'attach',
96
+ summary: 'Attach kit working paths to a repo without tracking them (local|global).',
97
+ async run(ctx) {
98
+ const positional = ctx.argv.filter((a) => !a.startsWith('-'));
99
+ const sub = positional[0];
100
+ if (ctx.argv.includes('--help') || !sub) {
101
+ ctx.stdout(USAGE);
102
+ return { exitCode: sub || ctx.argv.includes('--help') ? 0 : 1 };
103
+ }
104
+ if (!['local', 'global', 'status', 'detach'].includes(sub)) {
105
+ ctx.stderr(`kit attach: unknown subcommand '${sub}'\n${USAGE}`);
106
+ return { exitCode: 1 };
107
+ }
108
+ const repo = resolveRepo(ctx.cwd);
109
+ if (!repo) {
110
+ ctx.stderr('kit attach: not inside a git repository');
111
+ return { exitCode: 1 };
112
+ }
113
+ try {
114
+ const r = await execute(sub, repo, ctx.argv.includes('--adopt'));
115
+ (r.exitCode === 0 ? ctx.stdout : ctx.stderr)(r.text);
116
+ return { exitCode: r.exitCode };
117
+ }
118
+ catch (e) {
119
+ ctx.stderr(`kit attach: ${e instanceof Error ? e.message : String(e)}`);
120
+ return { exitCode: 1 };
121
+ }
122
+ },
123
+ };
124
+ //# sourceMappingURL=attach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.js","sourceRoot":"","sources":["../../src/commands/attach.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,0CAA0C;AAC1C,2DAA2D;AAC3D,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,0EAA0E;AAC1E,oEAAoE;AAEpE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,SAAS,EACT,WAAW,EACX,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,GACZ,MAAM,mBAAmB,C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,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC;QACD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,GAAG,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;YACtD,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACxE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from './types.js';
2
+ export declare const doctorCommand: Command;
3
+ //# sourceMappingURL=doctor.d.ts.map
@@ -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"}