@vpxa/kb 0.1.13 → 0.1.15

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 (383) hide show
  1. package/README.md +8 -2
  2. package/package.json +10 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -20
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +6 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -27
  6. package/packages/analyzers/dist/dependency-analyzer.js +7 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -8
  8. package/packages/analyzers/dist/diagram-generator.js +3 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -35
  10. package/packages/analyzers/dist/entry-point-analyzer.js +5 -6
  11. package/packages/analyzers/dist/index.d.ts +12 -14
  12. package/packages/analyzers/dist/index.js +1 -1
  13. package/packages/analyzers/dist/knowledge-producer.d.ts +29 -25
  14. package/packages/analyzers/dist/knowledge-producer.js +16 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -10
  16. package/packages/analyzers/dist/pattern-analyzer.js +3 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -12
  18. package/packages/analyzers/dist/regex-call-graph.js +2 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -9
  20. package/packages/analyzers/dist/structure-analyzer.js +3 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +12 -8
  22. package/packages/analyzers/dist/symbol-analyzer.js +8 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -13
  24. package/packages/analyzers/dist/ts-call-graph.js +2 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -79
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +13 -10
  28. package/packages/chunker/dist/call-graph-extractor.js +2 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +6 -2
  30. package/packages/chunker/dist/chunker-factory.js +2 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -4
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -12
  34. package/packages/chunker/dist/code-chunker.js +12 -14
  35. package/packages/chunker/dist/generic-chunker.d.ts +14 -10
  36. package/packages/chunker/dist/generic-chunker.js +6 -5
  37. package/packages/chunker/dist/index.d.ts +8 -8
  38. package/packages/chunker/dist/index.js +1 -1
  39. package/packages/chunker/dist/markdown-chunker.d.ts +16 -12
  40. package/packages/chunker/dist/markdown-chunker.js +4 -10
  41. package/packages/chunker/dist/treesitter-chunker.d.ts +28 -31
  42. package/packages/chunker/dist/treesitter-chunker.js +7 -8
  43. package/packages/cli/dist/commands/analyze.d.ts +6 -2
  44. package/packages/cli/dist/commands/analyze.js +3 -3
  45. package/packages/cli/dist/commands/context-cmds.d.ts +6 -2
  46. package/packages/cli/dist/commands/context-cmds.js +2 -1
  47. package/packages/cli/dist/commands/environment.d.ts +6 -2
  48. package/packages/cli/dist/commands/environment.js +2 -2
  49. package/packages/cli/dist/commands/execution.d.ts +6 -2
  50. package/packages/cli/dist/commands/execution.js +2 -1
  51. package/packages/cli/dist/commands/graph.d.ts +6 -2
  52. package/packages/cli/dist/commands/graph.js +6 -6
  53. package/packages/cli/dist/commands/init/adapters.d.ts +27 -0
  54. package/packages/cli/dist/commands/init/adapters.js +2 -0
  55. package/packages/cli/dist/commands/init/config.d.ts +11 -0
  56. package/packages/cli/dist/commands/init/config.js +4 -0
  57. package/packages/cli/dist/commands/init/curated.d.ts +8 -0
  58. package/packages/cli/dist/commands/init/curated.js +2 -0
  59. package/packages/cli/dist/commands/init/index.d.ts +23 -0
  60. package/packages/cli/dist/commands/init/index.js +3 -0
  61. package/packages/cli/dist/commands/init/scaffold.d.ts +24 -0
  62. package/packages/cli/dist/commands/init/scaffold.js +2 -0
  63. package/packages/cli/dist/commands/init/templates.d.ts +10 -0
  64. package/packages/cli/dist/commands/init/templates.js +302 -0
  65. package/packages/cli/dist/commands/init.d.ts +8 -3
  66. package/packages/cli/dist/commands/init.js +120 -123
  67. package/packages/cli/dist/commands/knowledge.d.ts +6 -2
  68. package/packages/cli/dist/commands/knowledge.js +2 -1
  69. package/packages/cli/dist/commands/search.d.ts +6 -2
  70. package/packages/cli/dist/commands/search.js +2 -8
  71. package/packages/cli/dist/commands/system.d.ts +6 -2
  72. package/packages/cli/dist/commands/system.js +5 -7
  73. package/packages/cli/dist/commands/workspace.d.ts +6 -2
  74. package/packages/cli/dist/commands/workspace.js +2 -2
  75. package/packages/cli/dist/context.d.ts +7 -4
  76. package/packages/cli/dist/context.js +2 -1
  77. package/packages/cli/dist/helpers.d.ts +51 -47
  78. package/packages/cli/dist/helpers.js +6 -5
  79. package/packages/cli/dist/index.d.ts +4 -1
  80. package/packages/cli/dist/index.js +3 -2
  81. package/packages/cli/dist/kb-init.d.ts +48 -50
  82. package/packages/cli/dist/kb-init.js +2 -1
  83. package/packages/cli/dist/types.d.ts +8 -5
  84. package/packages/cli/dist/types.js +1 -0
  85. package/packages/core/dist/constants.d.ts +36 -33
  86. package/packages/core/dist/constants.js +2 -1
  87. package/packages/core/dist/content-detector.d.ts +8 -7
  88. package/packages/core/dist/content-detector.js +2 -1
  89. package/packages/core/dist/errors.d.ts +15 -12
  90. package/packages/core/dist/errors.js +2 -1
  91. package/packages/core/dist/index.d.ts +6 -6
  92. package/packages/core/dist/index.js +1 -1
  93. package/packages/core/dist/logger.d.ts +16 -7
  94. package/packages/core/dist/logger.js +2 -1
  95. package/packages/core/dist/types.d.ts +107 -91
  96. package/packages/core/dist/types.js +2 -0
  97. package/packages/embeddings/dist/embedder.interface.d.ts +22 -19
  98. package/packages/embeddings/dist/embedder.interface.js +1 -0
  99. package/packages/embeddings/dist/index.d.ts +3 -3
  100. package/packages/embeddings/dist/index.js +1 -1
  101. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -22
  102. package/packages/embeddings/dist/onnx-embedder.js +2 -1
  103. package/packages/enterprise-bridge/dist/cache.d.ts +29 -0
  104. package/packages/enterprise-bridge/dist/cache.js +2 -0
  105. package/packages/enterprise-bridge/dist/er-client.d.ts +38 -0
  106. package/packages/enterprise-bridge/dist/er-client.js +2 -0
  107. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +63 -0
  108. package/packages/enterprise-bridge/dist/evolution-collector.js +2 -0
  109. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  110. package/packages/enterprise-bridge/dist/index.js +1 -0
  111. package/packages/enterprise-bridge/dist/policy-store.d.ts +46 -0
  112. package/packages/enterprise-bridge/dist/policy-store.js +2 -0
  113. package/packages/enterprise-bridge/dist/push-adapter.d.ts +24 -0
  114. package/packages/enterprise-bridge/dist/push-adapter.js +2 -0
  115. package/packages/enterprise-bridge/dist/result-merger.d.ts +15 -0
  116. package/packages/enterprise-bridge/dist/result-merger.js +2 -0
  117. package/packages/enterprise-bridge/dist/types.d.ts +82 -0
  118. package/packages/enterprise-bridge/dist/types.js +2 -0
  119. package/packages/indexer/dist/file-hasher.d.ts +5 -2
  120. package/packages/indexer/dist/file-hasher.js +2 -1
  121. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -20
  122. package/packages/indexer/dist/filesystem-crawler.js +2 -1
  123. package/packages/indexer/dist/graph-extractor.d.ts +9 -12
  124. package/packages/indexer/dist/graph-extractor.js +2 -1
  125. package/packages/indexer/dist/incremental-indexer.d.ts +49 -43
  126. package/packages/indexer/dist/incremental-indexer.js +2 -1
  127. package/packages/indexer/dist/index.d.ts +5 -5
  128. package/packages/indexer/dist/index.js +1 -1
  129. package/packages/server/dist/api.d.ts +3 -8
  130. package/packages/server/dist/api.js +1 -1
  131. package/packages/server/dist/config.d.ts +6 -2
  132. package/packages/server/dist/config.js +2 -1
  133. package/packages/server/dist/curated-manager.d.ts +79 -76
  134. package/packages/server/dist/curated-manager.js +6 -10
  135. package/packages/server/dist/index.d.ts +1 -2
  136. package/packages/server/dist/index.js +2 -1
  137. package/packages/server/dist/replay-interceptor.d.ts +6 -6
  138. package/packages/server/dist/replay-interceptor.js +2 -1
  139. package/packages/server/dist/resources/resources.d.ts +7 -3
  140. package/packages/server/dist/resources/resources.js +3 -2
  141. package/packages/server/dist/server.d.ts +34 -24
  142. package/packages/server/dist/server.js +2 -1
  143. package/packages/server/dist/tools/analyze.tools.d.ts +14 -10
  144. package/packages/server/dist/tools/analyze.tools.js +2 -3
  145. package/packages/server/dist/tools/audit.tool.d.ts +8 -4
  146. package/packages/server/dist/tools/audit.tool.js +2 -4
  147. package/packages/server/dist/tools/bridge.tools.d.ts +35 -0
  148. package/packages/server/dist/tools/bridge.tools.js +16 -0
  149. package/packages/server/dist/tools/evolution.tools.d.ts +8 -0
  150. package/packages/server/dist/tools/evolution.tools.js +6 -0
  151. package/packages/server/dist/tools/forge.tools.d.ts +13 -11
  152. package/packages/server/dist/tools/forge.tools.js +11 -13
  153. package/packages/server/dist/tools/forget.tool.d.ts +7 -3
  154. package/packages/server/dist/tools/forget.tool.js +2 -7
  155. package/packages/server/dist/tools/graph.tool.d.ts +7 -3
  156. package/packages/server/dist/tools/graph.tool.js +5 -5
  157. package/packages/server/dist/tools/list.tool.d.ts +7 -3
  158. package/packages/server/dist/tools/list.tool.js +3 -8
  159. package/packages/server/dist/tools/lookup.tool.d.ts +7 -3
  160. package/packages/server/dist/tools/lookup.tool.js +3 -9
  161. package/packages/server/dist/tools/onboard.tool.d.ts +8 -4
  162. package/packages/server/dist/tools/onboard.tool.js +3 -2
  163. package/packages/server/dist/tools/policy.tools.d.ts +8 -0
  164. package/packages/server/dist/tools/policy.tools.js +3 -0
  165. package/packages/server/dist/tools/produce.tool.d.ts +6 -2
  166. package/packages/server/dist/tools/produce.tool.js +3 -2
  167. package/packages/server/dist/tools/read.tool.d.ts +7 -3
  168. package/packages/server/dist/tools/read.tool.js +3 -6
  169. package/packages/server/dist/tools/reindex.tool.d.ts +10 -6
  170. package/packages/server/dist/tools/reindex.tool.js +3 -2
  171. package/packages/server/dist/tools/remember.tool.d.ts +8 -3
  172. package/packages/server/dist/tools/remember.tool.js +4 -5
  173. package/packages/server/dist/tools/replay.tool.d.ts +6 -2
  174. package/packages/server/dist/tools/replay.tool.js +3 -6
  175. package/packages/server/dist/tools/search.tool.d.ts +10 -4
  176. package/packages/server/dist/tools/search.tool.js +7 -22
  177. package/packages/server/dist/tools/status.tool.d.ts +7 -3
  178. package/packages/server/dist/tools/status.tool.js +3 -3
  179. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -34
  180. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  181. package/packages/server/dist/tools/update.tool.d.ts +7 -3
  182. package/packages/server/dist/tools/update.tool.js +2 -6
  183. package/packages/server/dist/tools/utility.tools.d.ts +15 -14
  184. package/packages/server/dist/tools/utility.tools.js +11 -23
  185. package/packages/server/dist/version-check.d.ts +5 -1
  186. package/packages/server/dist/version-check.js +2 -1
  187. package/packages/store/dist/graph-store.interface.d.ts +89 -86
  188. package/packages/store/dist/graph-store.interface.js +1 -0
  189. package/packages/store/dist/index.d.ts +6 -6
  190. package/packages/store/dist/index.js +1 -1
  191. package/packages/store/dist/lance-store.d.ts +37 -30
  192. package/packages/store/dist/lance-store.js +2 -1
  193. package/packages/store/dist/sqlite-graph-store.d.ts +43 -46
  194. package/packages/store/dist/sqlite-graph-store.js +14 -13
  195. package/packages/store/dist/store-factory.d.ts +11 -7
  196. package/packages/store/dist/store-factory.js +2 -1
  197. package/packages/store/dist/store.interface.d.ts +47 -46
  198. package/packages/store/dist/store.interface.js +1 -0
  199. package/packages/tools/dist/audit.d.ts +61 -61
  200. package/packages/tools/dist/audit.js +5 -5
  201. package/packages/tools/dist/batch.d.ts +20 -17
  202. package/packages/tools/dist/batch.js +2 -1
  203. package/packages/tools/dist/changelog.d.ts +29 -26
  204. package/packages/tools/dist/changelog.js +3 -2
  205. package/packages/tools/dist/check.d.ts +42 -38
  206. package/packages/tools/dist/check.js +3 -2
  207. package/packages/tools/dist/checkpoint.d.ts +17 -14
  208. package/packages/tools/dist/checkpoint.js +2 -2
  209. package/packages/tools/dist/codemod.d.ts +35 -32
  210. package/packages/tools/dist/codemod.js +3 -2
  211. package/packages/tools/dist/compact.d.ts +34 -37
  212. package/packages/tools/dist/compact.js +3 -2
  213. package/packages/tools/dist/data-transform.d.ts +10 -7
  214. package/packages/tools/dist/data-transform.js +2 -1
  215. package/packages/tools/dist/dead-symbols.d.ts +29 -25
  216. package/packages/tools/dist/dead-symbols.js +3 -2
  217. package/packages/tools/dist/delegate.d.ts +26 -23
  218. package/packages/tools/dist/delegate.js +2 -5
  219. package/packages/tools/dist/diff-parse.d.ts +24 -21
  220. package/packages/tools/dist/diff-parse.js +4 -3
  221. package/packages/tools/dist/digest.d.ts +43 -45
  222. package/packages/tools/dist/digest.js +5 -5
  223. package/packages/tools/dist/encode.d.ts +11 -8
  224. package/packages/tools/dist/encode.js +2 -1
  225. package/packages/tools/dist/env-info.d.ts +25 -22
  226. package/packages/tools/dist/env-info.js +2 -1
  227. package/packages/tools/dist/eval.d.ts +13 -10
  228. package/packages/tools/dist/eval.js +3 -3
  229. package/packages/tools/dist/evidence-map.d.ts +64 -61
  230. package/packages/tools/dist/evidence-map.js +3 -3
  231. package/packages/tools/dist/file-cache.d.ts +42 -0
  232. package/packages/tools/dist/file-cache.js +4 -0
  233. package/packages/tools/dist/file-summary.d.ts +34 -29
  234. package/packages/tools/dist/file-summary.js +3 -2
  235. package/packages/tools/dist/file-walk.d.ts +6 -3
  236. package/packages/tools/dist/file-walk.js +2 -1
  237. package/packages/tools/dist/find-examples.d.ts +26 -21
  238. package/packages/tools/dist/find-examples.js +4 -3
  239. package/packages/tools/dist/find.d.ts +39 -40
  240. package/packages/tools/dist/find.js +2 -1
  241. package/packages/tools/dist/forge-classify.d.ts +35 -38
  242. package/packages/tools/dist/forge-classify.js +3 -2
  243. package/packages/tools/dist/forge-ground.d.ts +58 -60
  244. package/packages/tools/dist/forge-ground.js +2 -1
  245. package/packages/tools/dist/git-context.d.ts +22 -19
  246. package/packages/tools/dist/git-context.js +4 -3
  247. package/packages/tools/dist/graph-query.d.ts +75 -78
  248. package/packages/tools/dist/graph-query.js +2 -1
  249. package/packages/tools/dist/guide.d.ts +14 -11
  250. package/packages/tools/dist/guide.js +2 -1
  251. package/packages/tools/dist/health.d.ts +13 -10
  252. package/packages/tools/dist/health.js +3 -2
  253. package/packages/tools/dist/http-request.d.ts +20 -17
  254. package/packages/tools/dist/http-request.js +2 -1
  255. package/packages/tools/dist/index.d.ts +54 -53
  256. package/packages/tools/dist/index.js +1 -1
  257. package/packages/tools/dist/lane.d.ts +28 -25
  258. package/packages/tools/dist/lane.js +7 -7
  259. package/packages/tools/dist/measure.d.ts +32 -29
  260. package/packages/tools/dist/measure.js +3 -2
  261. package/packages/tools/dist/onboard.d.ts +29 -26
  262. package/packages/tools/dist/onboard.js +18 -41
  263. package/packages/tools/dist/parse-output.d.ts +48 -45
  264. package/packages/tools/dist/parse-output.js +3 -2
  265. package/packages/tools/dist/path-resolver.d.ts +4 -1
  266. package/packages/tools/dist/path-resolver.js +2 -1
  267. package/packages/tools/dist/process-manager.d.ts +18 -15
  268. package/packages/tools/dist/process-manager.js +2 -1
  269. package/packages/tools/dist/queue.d.ts +28 -25
  270. package/packages/tools/dist/queue.js +2 -2
  271. package/packages/tools/dist/regex-test.d.ts +26 -23
  272. package/packages/tools/dist/regex-test.js +2 -1
  273. package/packages/tools/dist/rename.d.ts +28 -25
  274. package/packages/tools/dist/rename.js +3 -2
  275. package/packages/tools/dist/replay.d.ts +32 -29
  276. package/packages/tools/dist/replay.js +5 -6
  277. package/packages/tools/dist/response-envelope.d.ts +32 -29
  278. package/packages/tools/dist/response-envelope.js +2 -1
  279. package/packages/tools/dist/schema-validate.d.ts +15 -12
  280. package/packages/tools/dist/schema-validate.js +2 -1
  281. package/packages/tools/dist/scope-map.d.ts +45 -47
  282. package/packages/tools/dist/scope-map.js +2 -1
  283. package/packages/tools/dist/snippet.d.ts +26 -24
  284. package/packages/tools/dist/snippet.js +2 -1
  285. package/packages/tools/dist/stash.d.ts +13 -10
  286. package/packages/tools/dist/stash.js +2 -2
  287. package/packages/tools/dist/stratum-card.d.ts +27 -27
  288. package/packages/tools/dist/stratum-card.js +4 -5
  289. package/packages/tools/dist/symbol.d.ts +29 -25
  290. package/packages/tools/dist/symbol.js +4 -3
  291. package/packages/tools/dist/test-run.d.ts +19 -15
  292. package/packages/tools/dist/test-run.js +3 -2
  293. package/packages/tools/dist/text-utils.d.ts +6 -3
  294. package/packages/tools/dist/text-utils.js +3 -2
  295. package/packages/tools/dist/time-utils.d.ts +15 -12
  296. package/packages/tools/dist/time-utils.js +2 -1
  297. package/packages/tools/dist/trace.d.ts +24 -20
  298. package/packages/tools/dist/trace.js +3 -2
  299. package/packages/tools/dist/truncation.d.ts +6 -3
  300. package/packages/tools/dist/truncation.js +8 -14
  301. package/packages/tools/dist/watch.d.ts +28 -25
  302. package/packages/tools/dist/watch.js +2 -1
  303. package/packages/tools/dist/web-fetch.d.ts +35 -32
  304. package/packages/tools/dist/web-fetch.js +7 -12
  305. package/packages/tools/dist/web-search.d.ts +16 -13
  306. package/packages/tools/dist/web-search.js +2 -1
  307. package/packages/tools/dist/workset.d.ts +19 -16
  308. package/packages/tools/dist/workset.js +2 -2
  309. package/packages/tui/dist/App-BAlmxCCw.js +3 -0
  310. package/packages/tui/dist/App.d.ts +11 -5
  311. package/packages/tui/dist/App.js +1 -450
  312. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +3 -0
  313. package/packages/tui/dist/LogPanel-DVB8Sv46.js +4 -0
  314. package/packages/tui/dist/SearchPanel-DREo6zgt.js +3 -0
  315. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +3 -0
  316. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  317. package/packages/tui/dist/devtools-DUyj952l.js +8 -0
  318. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +29 -0
  319. package/packages/tui/dist/index-B9VpfVPP.d.ts +14 -0
  320. package/packages/tui/dist/index.d.ts +3 -19
  321. package/packages/tui/dist/index.js +2 -476
  322. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +317 -0
  323. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -5
  324. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  325. package/packages/tui/dist/panels/LogPanel.d.ts +7 -2
  326. package/packages/tui/dist/panels/LogPanel.js +1 -449
  327. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -7
  328. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  329. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -5
  330. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  331. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +151 -0
  332. package/scaffold/adapters/claude-code.mjs +20 -0
  333. package/scaffold/adapters/copilot.mjs +320 -0
  334. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +14 -0
  335. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +14 -0
  336. package/scaffold/copilot/agents/Code-Reviewer-Alpha.agent.md +12 -0
  337. package/scaffold/copilot/agents/Code-Reviewer-Beta.agent.md +12 -0
  338. package/scaffold/copilot/agents/Debugger.agent.md +31 -0
  339. package/scaffold/copilot/agents/Documenter.agent.md +35 -0
  340. package/scaffold/copilot/agents/Explorer.agent.md +50 -0
  341. package/scaffold/copilot/agents/Frontend.agent.md +29 -0
  342. package/scaffold/copilot/agents/Implementer.agent.md +31 -0
  343. package/scaffold/copilot/agents/Orchestrator.agent.md +96 -0
  344. package/scaffold/copilot/agents/Planner.agent.md +45 -0
  345. package/scaffold/copilot/agents/README.md +57 -0
  346. package/scaffold/copilot/agents/Refactor.agent.md +30 -0
  347. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +12 -0
  348. package/scaffold/copilot/agents/Researcher-Beta.agent.md +12 -0
  349. package/scaffold/copilot/agents/Researcher-Delta.agent.md +12 -0
  350. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +12 -0
  351. package/scaffold/copilot/agents/Security.agent.md +42 -0
  352. package/scaffold/copilot/agents/_shared/adr-protocol.md +91 -0
  353. package/scaffold/copilot/agents/_shared/architect-reviewer-base.md +50 -0
  354. package/scaffold/copilot/agents/_shared/code-agent-base.md +70 -0
  355. package/scaffold/copilot/agents/_shared/code-reviewer-base.md +54 -0
  356. package/scaffold/copilot/agents/_shared/decision-protocol.md +27 -0
  357. package/scaffold/copilot/agents/_shared/forge-protocol.md +46 -0
  358. package/scaffold/copilot/agents/_shared/researcher-base.md +61 -0
  359. package/scaffold/copilot/agents/templates/adr-template.md +27 -0
  360. package/scaffold/copilot/agents/templates/execution-state.md +25 -0
  361. package/scaffold/copilot/prompts/ask.prompt.md +20 -0
  362. package/scaffold/copilot/prompts/debug.prompt.md +25 -0
  363. package/scaffold/copilot/prompts/design.prompt.md +22 -0
  364. package/scaffold/copilot/prompts/implement.prompt.md +26 -0
  365. package/scaffold/copilot/prompts/plan.prompt.md +24 -0
  366. package/scaffold/copilot/prompts/review.prompt.md +31 -0
  367. package/scaffold/definitions/agents.mjs +165 -0
  368. package/scaffold/definitions/bodies.mjs +292 -0
  369. package/scaffold/definitions/hooks.mjs +43 -0
  370. package/scaffold/definitions/models.mjs +56 -0
  371. package/scaffold/definitions/plugins.mjs +24 -0
  372. package/scaffold/definitions/prompts.mjs +145 -0
  373. package/scaffold/definitions/protocols.mjs +322 -0
  374. package/scaffold/definitions/tools.mjs +176 -0
  375. package/scaffold/generate.mjs +74 -0
  376. package/skills/brainstorming/SKILL.md +259 -0
  377. package/skills/brainstorming/scripts/frame-template.html +365 -0
  378. package/skills/brainstorming/scripts/helper.js +216 -0
  379. package/skills/brainstorming/scripts/server.cjs +9 -0
  380. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  381. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  382. package/skills/brainstorming/visual-companion.md +430 -0
  383. package/skills/knowledge-base/SKILL.md +22 -9
@@ -1,2 +1,3 @@
1
- import{readFile as S}from"node:fs/promises";async function L(i){const{path:r,previewLines:R=3}=i,u=await S(r,"utf-8"),m=u.split(`
2
- `),j=r.split(".").pop()??"",h=[],e=[],o=[],f=[],y=[],g=[];for(let a=0;a<m.length;a+=1){const t=m[a],n=a+1;if(/^import\s+.+/.test(t)){h.push(t.trim());continue}const l=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(l){o.push({name:l[1],line:n,exported:!0}),e.push(l[1]);continue}const x=t.match(/^(?:async\s+)?function\s+(\w+)/);if(x){o.push({name:x[1],line:n,exported:!1});continue}const c=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(c){const s=!!c[1];o.push({name:c[2],line:n,exported:s}),s&&e.push(c[2]);continue}const b=t.match(/^export\s+const\s+(\w+)\s*=/);if(b){e.push(b[1]);continue}const p=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(p){const s=!!p[1];f.push({name:p[2],line:n,exported:s}),s&&e.push(p[2]);continue}const d=t.match(/^(?:export\s+)?interface\s+(\w+)/);if(d){y.push({name:d[1],line:n});continue}const w=t.match(/^(?:export\s+)?type\s+(\w+)/);if(w){g.push({name:w[1],line:n});continue}const F=t.match(/^export\s+\{(.+)\}/);if(F){const s=F[1].split(",").map(M=>M.trim().split(/\s+as\s+/).pop()?.trim()??"").filter(Boolean);e.push(...s)}}return{path:r,lines:m.length,language:v(j),imports:h,exports:e,functions:o,classes:f,interfaces:y,types:g,estimatedTokens:Math.ceil(u.length/4)}}function v(i){return{ts:"typescript",tsx:"typescript-jsx",js:"javascript",jsx:"javascript-jsx",py:"python",rs:"rust",go:"go",java:"java",rb:"ruby",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",css:"css",html:"html",sh:"shell",bash:"shell"}[i]??i}export{L as fileSummary};
1
+ import{readFile as e}from"node:fs/promises";async function t(t){let{path:r,previewLines:i=3}=t,a=t.content??await e(r,`utf-8`),o=a.split(`
2
+ `),s=r.split(`.`).pop()??``,c=[],l=[],u=[],d=[],f=[],p=[];for(let e=0;e<o.length;e+=1){let t=o[e],n=e+1;if(/^import\s+.+/.test(t)){c.push(t.trim());continue}let r=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(r){u.push({name:r[1],line:n,exported:!0}),l.push(r[1]);continue}let i=t.match(/^(?:async\s+)?function\s+(\w+)/);if(i){u.push({name:i[1],line:n,exported:!1});continue}let a=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(a){let e=!!a[1];u.push({name:a[2],line:n,exported:e}),e&&l.push(a[2]);continue}let s=t.match(/^export\s+const\s+(\w+)\s*=/);if(s){l.push(s[1]);continue}let m=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(m){let e=!!m[1];d.push({name:m[2],line:n,exported:e}),e&&l.push(m[2]);continue}let h=t.match(/^(?:export\s+)?interface\s+(\w+)/);if(h){f.push({name:h[1],line:n});continue}let g=t.match(/^(?:export\s+)?type\s+(\w+)/);if(g){p.push({name:g[1],line:n});continue}let _=t.match(/^export\s+\{(.+)\}/);if(_){let e=_[1].split(`,`).map(e=>e.trim().split(/\s+as\s+/).pop()?.trim()??``).filter(Boolean);l.push(...e)}}return{path:r,lines:o.length,language:n(s),imports:c,exports:l,functions:u,classes:d,interfaces:f,types:p,estimatedTokens:Math.ceil(a.length/4)}}function n(e){return{ts:`typescript`,tsx:`typescript-jsx`,js:`javascript`,jsx:`javascript-jsx`,py:`python`,rs:`rust`,go:`go`,java:`java`,rb:`ruby`,md:`markdown`,json:`json`,yaml:`yaml`,yml:`yaml`,css:`css`,html:`html`,sh:`shell`,bash:`shell`}[e]??e}export{t as fileSummary};
3
+ //# sourceMappingURL=file-summary.js.map
@@ -1,4 +1,7 @@
1
- export declare const DEFAULT_TOOL_EXTENSIONS: string[];
2
- export declare function matchesGlobPattern(path: string, pattern: string): boolean;
3
- export declare function walkFiles(rootPath: string, extensions: string[], exclude: string[]): Promise<string[]>;
1
+ //#region packages/tools/src/file-walk.d.ts
2
+ declare const DEFAULT_TOOL_EXTENSIONS: string[];
3
+ declare function matchesGlobPattern(path: string, pattern: string): boolean;
4
+ declare function walkFiles(rootPath: string, extensions: string[], exclude: string[]): Promise<string[]>;
5
+ //#endregion
6
+ export { DEFAULT_TOOL_EXTENSIONS, matchesGlobPattern, walkFiles };
4
7
  //# sourceMappingURL=file-walk.d.ts.map
@@ -1 +1,2 @@
1
- import{readdir as p,stat as x}from"node:fs/promises";import{extname as E,join as w,relative as L}from"node:path";const D=[".ts",".tsx",".js",".jsx"],b=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out",".kb-state"]);function g(e){return e.replace(/\\/g,"/")}function S(e){return e.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function f(e,i){const n=g(e),t=g(i).trim();if(!t)return!1;const s=S(t).replace(/\*\*/g,"::DOUBLE_STAR::").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/::DOUBLE_STAR::/g,".*");return new RegExp(`^${s}$`).test(n)}function m(e,i,n){return i.some(t=>f(e,t)?!0:n?f(`${e}/`,t):!1)}async function P(e,i,n){const t=[],s=i.map(r=>r.toLowerCase());async function a(r){const c=await p(r);for(const l of c){if(b.has(l))continue;const o=w(r,l),d=await x(o),u=g(L(e,o));if(d.isDirectory()){m(u,n,!0)||await a(o);continue}m(u,n,!1)||s.includes(E(l).toLowerCase())&&t.push(o)}}return await a(e),t.sort((r,c)=>r.localeCompare(c)),t}export{D as DEFAULT_TOOL_EXTENSIONS,f as matchesGlobPattern,P as walkFiles};
1
+ import{readdir as e,stat as t}from"node:fs/promises";import{extname as n,join as r,relative as i}from"node:path";const a=[`.ts`,`.tsx`,`.js`,`.jsx`],o=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`.kb-state`]);function s(e){return e.replace(/\\/g,`/`)}function c(e){return e.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}function l(e,t){let n=s(e),r=s(t).trim();if(!r)return!1;let i=c(r).replace(/\*\*/g,`::DOUBLE_STAR::`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(/::DOUBLE_STAR::/g,`.*`);return RegExp(`^${i}$`).test(n)}function u(e,t,n){return t.some(t=>l(e,t)?!0:n?l(`${e}/`,t):!1)}async function d(a,c,l){let d=[],f=c.map(e=>e.toLowerCase());async function p(c){let m=await e(c);for(let e of m){if(o.has(e))continue;let m=r(c,e),h=await t(m),g=s(i(a,m));if(h.isDirectory()){u(g,l,!0)||await p(m);continue}u(g,l,!1)||f.includes(n(e).toLowerCase())&&d.push(m)}}return await p(a),d.sort((e,t)=>e.localeCompare(t)),d}export{a as DEFAULT_TOOL_EXTENSIONS,l as matchesGlobPattern,d as walkFiles};
2
+ //# sourceMappingURL=file-walk.js.map
@@ -1,25 +1,30 @@
1
- import type { IEmbedder } from '@kb/embeddings';
2
- import type { IKnowledgeStore } from '@kb/store';
3
- export interface FindExamplesOptions {
4
- /** Symbol or pattern to find examples of */
5
- query: string;
6
- /** Max examples to return (default: 5) */
7
- limit?: number;
8
- /** Filter by content type */
9
- contentType?: string;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+ import { ContentType } from "@kb/core";
4
+
5
+ //#region packages/tools/src/find-examples.d.ts
6
+ interface FindExamplesOptions {
7
+ /** Symbol or pattern to find examples of */
8
+ query: string;
9
+ /** Max examples to return (default: 5) */
10
+ limit?: number;
11
+ /** Filter by content type */
12
+ contentType?: ContentType;
10
13
  }
11
- export interface Example {
12
- path: string;
13
- startLine: number;
14
- endLine: number;
15
- content: string;
16
- relevance: number;
17
- context: string;
14
+ interface Example {
15
+ path: string;
16
+ startLine: number;
17
+ endLine: number;
18
+ content: string;
19
+ relevance: number;
20
+ context: string;
18
21
  }
19
- export interface FindExamplesResult {
20
- query: string;
21
- examples: Example[];
22
- totalFound: number;
22
+ interface FindExamplesResult {
23
+ query: string;
24
+ examples: Example[];
25
+ totalFound: number;
23
26
  }
24
- export declare function findExamples(embedder: IEmbedder, store: IKnowledgeStore, options: FindExamplesOptions): Promise<FindExamplesResult>;
27
+ declare function findExamples(embedder: IEmbedder, store: IKnowledgeStore, options: FindExamplesOptions): Promise<FindExamplesResult>;
28
+ //#endregion
29
+ export { Example, FindExamplesOptions, FindExamplesResult, findExamples };
25
30
  //# sourceMappingURL=find-examples.d.ts.map
@@ -1,3 +1,4 @@
1
- async function $(s,l,x){const{query:i,limit:r=5,contentType:u}=x,g=`usage example of ${i}`,f=await s.embed(g),h=await l.search(f,{limit:r*3,contentType:u}),c=new RegExp(`\\b${I(i)}\\b`,"i"),a=h.filter(e=>c.test(e.record.content)),E=a.map(e=>{const t=e.record.content,m=/export\s+(?:async\s+)?(?:function|class|const|interface|type)\s/.test(t),y=/^\s*import\s/m.test(t),p=/(?:^|[\\/])(test|tests|__tests__|spec)(?:[\\/]|$)/i.test(e.record.sourcePath)||/\.(test|spec)\.[jt]sx?$/i.test(e.record.sourcePath);let n=0;m||(n+=.1),y||(n+=.05),p&&(n+=.05);const o=t.split(`
2
- `),d=o.findIndex(F=>c.test(F)),b=Math.max(0,d-2),L=Math.min(o.length,d+5),v=o.slice(b,L).join(`
3
- `);return{path:e.record.sourcePath,startLine:e.record.startLine,endLine:e.record.endLine,content:v||t.slice(0,300),relevance:Math.min(1,e.score+n),context:p?"test":m?"definition":"usage"}}).sort((e,t)=>t.relevance-e.relevance).slice(0,r);return{query:i,examples:E,totalFound:a.length}}function I(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{$ as findExamples};
1
+ async function e(e,n,r){let{query:i,limit:a=5,contentType:o}=r,s=`usage example of ${i}`,c=await e.embed(s),l=await n.search(c,{limit:a*3,contentType:o}),u=RegExp(`\\b${t(i)}\\b`,`i`),d=l.filter(e=>u.test(e.record.content));return{query:i,examples:d.map(e=>{let t=e.record.content,n=/export\s+(?:async\s+)?(?:function|class|const|interface|type)\s/.test(t),r=/^\s*import\s/m.test(t),i=/(?:^|[\\/])(test|tests|__tests__|spec)(?:[\\/]|$)/i.test(e.record.sourcePath)||/\.(test|spec)\.[jt]sx?$/i.test(e.record.sourcePath),a=0;n||(a+=.1),r||(a+=.05),i&&(a+=.05);let o=t.split(`
2
+ `),s=o.findIndex(e=>u.test(e)),c=Math.max(0,s-2),l=Math.min(o.length,s+5),d=o.slice(c,l).join(`
3
+ `);return{path:e.record.sourcePath,startLine:e.record.startLine,endLine:e.record.endLine,content:d||t.slice(0,300),relevance:Math.min(1,e.score+a),context:i?`test`:n?`definition`:`usage`}}).sort((e,t)=>t.relevance-e.relevance).slice(0,a),totalFound:d.length}}function t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}export{e as findExamples};
4
+ //# sourceMappingURL=find-examples.js.map
@@ -1,47 +1,46 @@
1
- /**
2
- * kb_find Federated search across vector similarity, keyword (FTS), and file glob.
3
- *
4
- * Combines multiple search strategies in a single call, deduplicates,
5
- * and returns unified results with source attribution.
6
- */
7
- import type { IEmbedder } from '@kb/embeddings';
8
- import type { IKnowledgeStore } from '@kb/store';
9
- export interface FindOptions {
10
- /** Semantic search query (optional) */
11
- query?: string;
12
- /** File glob pattern (optional) */
13
- glob?: string;
14
- /** Keyword/regex pattern for text search (optional) */
15
- pattern?: string;
16
- /** Max results per strategy (default: 10) */
17
- limit?: number;
18
- /** Filter by content type */
19
- contentType?: string;
20
- /** Working directory for glob resolution (default: cwd) */
21
- cwd?: string;
1
+ import { IEmbedder } from "@kb/embeddings";
2
+ import { IKnowledgeStore } from "@kb/store";
3
+ import { ContentType } from "@kb/core";
4
+
5
+ //#region packages/tools/src/find.d.ts
6
+ interface FindOptions {
7
+ /** Semantic search query (optional) */
8
+ query?: string;
9
+ /** File glob pattern (optional) */
10
+ glob?: string;
11
+ /** Keyword/regex pattern for text search (optional) */
12
+ pattern?: string;
13
+ /** Max results per strategy (default: 10) */
14
+ limit?: number;
15
+ /** Filter by content type */
16
+ contentType?: ContentType;
17
+ /** Working directory for glob resolution (default: cwd) */
18
+ cwd?: string;
22
19
  }
23
- export interface FindResult {
24
- /** File path (relative to cwd) */
25
- path: string;
26
- /** How this result was found */
27
- source: 'vector' | 'keyword' | 'glob' | 'pattern';
28
- /** Relevance score (0-1 for vector/keyword, 1 for glob/pattern matches) */
29
- score: number;
30
- /** Line range if from KB search */
31
- lineRange?: {
32
- start: number;
33
- end: number;
34
- };
35
- /** Content preview */
36
- preview?: string;
20
+ interface FindResult {
21
+ /** File path (relative to cwd) */
22
+ path: string;
23
+ /** How this result was found */
24
+ source: 'vector' | 'keyword' | 'glob' | 'pattern';
25
+ /** Relevance score (0-1 for vector/keyword, 1 for glob/pattern matches) */
26
+ score: number;
27
+ /** Line range if from KB search */
28
+ lineRange?: {
29
+ start: number;
30
+ end: number;
31
+ };
32
+ /** Content preview */
33
+ preview?: string;
37
34
  }
38
- export interface FindResults {
39
- results: FindResult[];
40
- strategies: string[];
41
- totalFound: number;
35
+ interface FindResults {
36
+ results: FindResult[];
37
+ strategies: string[];
38
+ totalFound: number;
42
39
  }
43
40
  /**
44
41
  * Run federated search across multiple strategies.
45
42
  */
46
- export declare function find(embedder: IEmbedder, store: IKnowledgeStore, options: FindOptions): Promise<FindResults>;
43
+ declare function find(embedder: IEmbedder, store: IKnowledgeStore, options: FindOptions): Promise<FindResults>;
44
+ //#endregion
45
+ export { FindOptions, FindResult, FindResults, find };
47
46
  //# sourceMappingURL=find.d.ts.map
@@ -1 +1,2 @@
1
- async function y(f,u,b){const{query:d,glob:h,pattern:l,limit:i=10,contentType:p,cwd:m=process.cwd()}=b,a=[],n=[],o=new Set;if(d){a.push("vector");const s=await f.embed(d),e={limit:i,contentType:p},t=await u.search(s,e);for(const r of t){const c=`${r.record.sourcePath}:${r.record.startLine}`;o.has(c)||(o.add(c),n.push({path:r.record.sourcePath,source:"vector",score:r.score,lineRange:{start:r.record.startLine,end:r.record.endLine},preview:r.record.content.slice(0,200)}))}}if(d){a.push("keyword");try{const s=await u.ftsSearch(d,{limit:i,contentType:p});for(const e of s){const t=`${e.record.sourcePath}:${e.record.startLine}`;o.has(t)||(o.add(t),n.push({path:e.record.sourcePath,source:"keyword",score:e.score,lineRange:{start:e.record.startLine,end:e.record.endLine},preview:e.record.content.slice(0,200)}))}}catch{}}if(h){a.push("glob");try{const{globSync:s}=await import("node:fs"),e=s(h,{cwd:m}),t=new Set(["node_modules",".git","dist","build","coverage",".turbo",".cache","cdk.out",".kb-state",".kb-data"]),r=e.filter(c=>!c.replace(/\\/g,"/").split("/").some(w=>t.has(w)));for(const c of r.slice(0,i)){const g=`glob:${c}`;o.has(g)||(o.add(g),n.push({path:c,source:"glob",score:1}))}}catch{}}if(l){a.push("pattern");try{const s=new RegExp(l,"i"),e=await u.ftsSearch(l,{limit:i*2,contentType:p});for(const t of e)if(s.test(t.record.content)){const r=`${t.record.sourcePath}:${t.record.startLine}`;o.has(r)||(o.add(r),n.push({path:t.record.sourcePath,source:"pattern",score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch{}}return n.sort((s,e)=>e.score-s.score),{results:n.slice(0,i),strategies:a,totalFound:n.length}}export{y as find};
1
+ async function e(e,t,n){let{query:r,glob:i,pattern:a,limit:o=10,contentType:s,cwd:c=process.cwd()}=n,l=[],u=[],d=new Set;if(r){l.push(`vector`);let n=await e.embed(r),i={limit:o,contentType:s},a=await t.search(n,i);for(let e of a){let t=`${e.record.sourcePath}:${e.record.startLine}`;d.has(t)||(d.add(t),u.push({path:e.record.sourcePath,source:`vector`,score:e.score,lineRange:{start:e.record.startLine,end:e.record.endLine},preview:e.record.content.slice(0,200)}))}}if(r){l.push(`keyword`);try{let e=await t.ftsSearch(r,{limit:o,contentType:s});for(let t of e){let e=`${t.record.sourcePath}:${t.record.startLine}`;d.has(e)||(d.add(e),u.push({path:t.record.sourcePath,source:`keyword`,score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch{}}if(i){l.push(`glob`);try{let{globSync:e}=await import(`node:fs`),t=e(i,{cwd:c,withFileTypes:!1}),n=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`.kb-state`,`.kb-data`]),r=t.filter(e=>!e.replace(/\\/g,`/`).split(`/`).some(e=>n.has(e)));for(let e of r.slice(0,o)){let t=`glob:${e}`;d.has(t)||(d.add(t),u.push({path:e,source:`glob`,score:1}))}}catch{}}if(a){l.push(`pattern`);try{let e=new RegExp(a,`i`),n=await t.ftsSearch(a,{limit:o*2,contentType:s});for(let t of n)if(e.test(t.record.content)){let e=`${t.record.sourcePath}:${t.record.startLine}`;d.has(e)||(d.add(e),u.push({path:t.record.sourcePath,source:`pattern`,score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch{}}return u.sort((e,t)=>t.score-e.score),{results:u.slice(0,o),strategies:l,totalFound:u.length}}export{e as find};
2
+ //# sourceMappingURL=find.js.map
@@ -1,44 +1,41 @@
1
- /**
2
- * kb_forge_classify — Automated FORGE tier classification.
3
- *
4
- * Determines Floor/Standard/Critical tier from file analysis.
5
- * Uses path patterns, export scanning, and structural heuristics.
6
- * No LLM needed.
7
- */
8
- import type { ForgeTier } from './evidence-map.js';
9
- export interface ForgeClassifyOptions {
10
- /** Files being modified (absolute or relative paths) */
11
- files: string[];
12
- /** Task description for keyword detection */
13
- task: string;
14
- /** Root path for package boundary detection */
15
- rootPath: string;
1
+ import { ForgeTier } from "./evidence-map.js";
2
+
3
+ //#region packages/tools/src/forge-classify.d.ts
4
+ interface ForgeClassifyOptions {
5
+ /** Files being modified (absolute or relative paths) */
6
+ files: string[];
7
+ /** Task description for keyword detection */
8
+ task: string;
9
+ /** Root path for package boundary detection */
10
+ rootPath: string;
16
11
  }
17
- export interface ClassifyTrigger {
18
- rule: string;
19
- detail: string;
20
- source: 'blast_radius' | 'cross_package' | 'schema_contract' | 'security_auth' | 'task_hint' | 'default';
12
+ interface ClassifyTrigger {
13
+ rule: string;
14
+ detail: string;
15
+ source: 'blast_radius' | 'cross_package' | 'schema_contract' | 'security_auth' | 'task_hint' | 'default';
21
16
  }
22
- export interface TypedUnknownSeed {
23
- description: string;
24
- type: 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
25
- suggestedTool: string;
17
+ interface TypedUnknownSeed {
18
+ description: string;
19
+ type: 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
20
+ suggestedTool: string;
26
21
  }
27
- export interface ForgeClassifyCeremony {
28
- ground: string;
29
- build: string;
30
- break: string;
31
- evidenceMap: string;
32
- gate: string;
22
+ interface ForgeClassifyCeremony {
23
+ ground: string;
24
+ build: string;
25
+ break: string;
26
+ evidenceMap: string;
27
+ gate: string;
33
28
  }
34
- export interface ForgeClassifyResult {
35
- tier: ForgeTier;
36
- triggers: ClassifyTrigger[];
37
- packagesCrossed: string[];
38
- hasSchemaChange: boolean;
39
- hasSecurityPath: boolean;
40
- typedUnknownSeeds: TypedUnknownSeed[];
41
- ceremony: ForgeClassifyCeremony;
29
+ interface ForgeClassifyResult {
30
+ tier: ForgeTier;
31
+ triggers: ClassifyTrigger[];
32
+ packagesCrossed: string[];
33
+ hasSchemaChange: boolean;
34
+ hasSecurityPath: boolean;
35
+ typedUnknownSeeds: TypedUnknownSeed[];
36
+ ceremony: ForgeClassifyCeremony;
42
37
  }
43
- export declare function forgeClassify(options: ForgeClassifyOptions): Promise<ForgeClassifyResult>;
38
+ declare function forgeClassify(options: ForgeClassifyOptions): Promise<ForgeClassifyResult>;
39
+ //#endregion
40
+ export { ClassifyTrigger, ForgeClassifyCeremony, ForgeClassifyOptions, ForgeClassifyResult, TypedUnknownSeed, forgeClassify };
44
41
  //# sourceMappingURL=forge-classify.d.ts.map
@@ -1,2 +1,3 @@
1
- import{existsSync as g,readdirSync as _,readFileSync as S,statSync as k}from"node:fs";import{dirname as m,extname as C,relative as p,resolve as a}from"node:path";import{fileSummary as w}from"./file-summary.js";const E=1e5,x=200,v=new Set([".ts",".tsx",".js",".jsx",".mts",".cts",".mjs",".cjs"]),A=new Set([".git",".kb-data",".kb-state",".turbo",".yarn","build","coverage","dist","node_modules"]),N=/auth|token|permission|acl|encrypt|secret|credential|jwt|oauth|password/i,R=/\b(hash|sign|verify|bcrypt|jwt|decrypt|secret|password)\b/i,P=/auth|security|permission|encrypt|secret|credential/i,F=/types\.ts$|schema\.ts$|contract\.ts$|\.proto$|openapi|swagger|\.graphql$/i,U=/(?:^|\/)(events|contracts|shared)(?:\/|$)/i,$=/export\s+interface\b|export\s+type\b|export\s+const\s+\w*Schema\w*\s*=\s*z\./i,j=/schema|contract|migration|breaking.change|api.change/i,I=/migration|data.?model|multi.?service|breaking|backward.?compat/i,D={floor:{ground:"Parasitic \u2014 read target file only",build:"Implement directly",break:"Skip",evidenceMap:"Not required",gate:"Self-certify"},standard:{ground:"Scope map + blast radius + constraint seed",build:"TDD \u2014 test first, then implement",break:"Error paths + edge cases",evidenceMap:"3-8 critical-path entries",gate:"YIELD/HOLD evaluation"},critical:{ground:"Full scope map + blast radius + trace + patterns + constraint pack",build:"TDD + contract verification + cross-service validation",break:"Error paths + edge cases + security dimensions + data-flow verification",evidenceMap:"Comprehensive \u2014 all critical-path claims with receipts",gate:"Strict YIELD/HOLD/HARD_BLOCK evaluation"}};async function W(t){const s=a(t.rootPath),r=t.task.trim(),e=t.files.map(c=>a(s,c)),n=[];let i=!1,o=!1;for(const c of e){const f=O(c,s),T=b(c);(N.test(f)||R.test(T)||P.test(r))&&(i=!0),(F.test(f)||U.test(f)||j.test(r)||$.test(T)||await M(c))&&(o=!0)}i&&l(n,{rule:"security-path",detail:"Security/auth path, task, or content matched security heuristics",source:"security_auth"}),o&&l(n,{rule:"schema-contract",detail:"Schema or contract path, task, or export shape matched contract heuristics",source:"schema_contract"});const d=H(e,s);d.affectedFiles>5&&l(n,{rule:"blast-radius-importers",detail:`${d.affectedFiles} affected files via direct import scanning`,source:"blast_radius"});const u=[...new Set(e.map(c=>B(c,s)).filter(c=>!!c))].sort();u.length>=2&&l(n,{rule:"cross-package-boundary",detail:`Files span ${u.length} packages: ${u.join(", ")}`,source:"cross_package"}),I.test(r)&&l(n,{rule:"task-hint-critical",detail:"Task description matched migration or compatibility criticality hints",source:"task_hint"});const y=n.length>0?"critical":e.length===1?"floor":"standard";return{tier:y,triggers:n,packagesCrossed:u,hasSchemaChange:o,hasSecurityPath:i,typedUnknownSeeds:q(n),ceremony:D[y]}}function l(t,s){t.some(r=>r.rule===s.rule&&r.source===s.source)||t.push(s)}function O(t,s){const r=a(s,t),e=p(s,r);return(e&&!e.startsWith("..")?e:r).replace(/\\/g,"/")}function h(t){if(!g(t))return!1;try{return k(t).size<=E}catch{return!1}}function b(t){if(!h(t))return"";try{return S(t,"utf-8").split(/\r?\n/).slice(0,x).join(`
2
- `)}catch{return""}}async function M(t){if(!h(t))return!1;try{const s=await w({path:t}),r=new Set(s.exports);return s.interfaces.some(e=>r.has(e.name))||s.types.some(e=>r.has(e.name))}catch{return!1}}function H(t,s){const r=new Set(t.filter(n=>g(n)));if(r.size===0)return{affectedFiles:t.length,importers:[]};const e=new Set;for(const n of L(s)){if(r.has(n)||!h(n))continue;const i=b(n);if(!i)continue;z(i).some(d=>Y(d,n,r))&&e.add(n)}return{affectedFiles:t.length+e.size,importers:[...e].map(n=>p(s,n).replace(/\\/g,"/"))}}function L(t){const s=[];function r(e){let n=[];try{n=_(e)}catch{return}for(const i of n){if(A.has(i))continue;const o=a(e,i);let d;try{d=k(o)}catch{continue}if(d.isDirectory()){r(o);continue}v.has(C(i).toLowerCase())&&s.push(o)}}return r(t),s}function z(t){const s=new Set,r=/(?:from\s+['"]([^'"]+)['"]|import\s+['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\))/g;for(const e of t.matchAll(r)){const n=e[1]??e[2]??e[3];n&&s.add(n)}return[...s]}function Y(t,s,r){if(!t.startsWith("."))return!1;const e=a(m(s),t);return[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.jsx`,`${e}.mts`,`${e}.cts`,`${e}.mjs`,`${e}.cjs`,a(e,"index.ts"),a(e,"index.tsx"),a(e,"index.js"),a(e,"index.jsx")].some(i=>r.has(i))}function q(t){return t.map(s=>{switch(s.source){case"security_auth":return{description:"Verify auth and security assumptions before yielding",type:"contract",suggestedTool:"kb_search"};case"schema_contract":return{description:"Confirm schema and contract compatibility",type:"contract",suggestedTool:"kb_schema_validate"};case"blast_radius":return{description:"Inspect affected importers before delivery",type:"impact",suggestedTool:"kb_blast_radius"};case"cross_package":return{description:"Assess downstream package impact across boundaries",type:"impact",suggestedTool:"kb_blast_radius"};case"task_hint":return{description:"Check established conventions for migrations or compatibility work",type:"convention",suggestedTool:"kb_find"};default:return{description:"No explicit unknown routing required",type:"freshness",suggestedTool:"kb_lookup"}}})}function B(t,s){let r=m(a(s,t));const e=a(s);for(;r.length>=e.length;){const n=a(r,"package.json");if(g(n))try{return JSON.parse(S(n,"utf-8")).name??p(e,r).replace(/\\/g,"/")}catch{return p(e,r).replace(/\\/g,"/")}const i=m(r);if(i===r)break;r=i}}export{W as forgeClassify};
1
+ import{fileSummary as e}from"./file-summary.js";import{dirname as t,extname as n,relative as r,resolve as i}from"node:path";import{existsSync as a,readFileSync as o,readdirSync as s,statSync as c}from"node:fs";const l=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.cts`,`.mjs`,`.cjs`]),u=new Set([`.git`,`.kb-data`,`.kb-state`,`.turbo`,`.yarn`,`build`,`coverage`,`dist`,`node_modules`]),d=/auth|token|permission|acl|encrypt|secret|credential|jwt|oauth|password/i,f=/\b(hash|sign|verify|bcrypt|jwt|decrypt|secret|password)\b/i,p=/auth|security|permission|encrypt|secret|credential/i,m=/types\.ts$|schema\.ts$|contract\.ts$|\.proto$|openapi|swagger|\.graphql$/i,h=/(?:^|\/)(events|contracts|shared)(?:\/|$)/i,g=/export\s+interface\b|export\s+type\b|export\s+const\s+\w*Schema\w*\s*=\s*z\./i,_=/schema|contract|migration|breaking.change|api.change/i,v=/migration|data.?model|multi.?service|breaking|backward.?compat/i,y={floor:{ground:`Parasitic read target file only`,build:`Implement directly`,break:`Skip`,evidenceMap:`Not required`,gate:`Self-certify`},standard:{ground:`Scope map + blast radius + constraint seed`,build:`TDD test first, then implement`,break:`Error paths + edge cases`,evidenceMap:`3-8 critical-path entries`,gate:`YIELD/HOLD evaluation`},critical:{ground:`Full scope map + blast radius + trace + patterns + constraint pack`,build:`TDD + contract verification + cross-service validation`,break:`Error paths + edge cases + security dimensions + data-flow verification`,evidenceMap:`Comprehensive all critical-path claims with receipts`,gate:`Strict YIELD/HOLD/HARD_BLOCK evaluation`}};async function b(e){let t=i(e.rootPath),n=e.task.trim(),r=e.files.map(e=>i(t,e)),a=[],o=!1,s=!1;for(let e of r){let r=S(e,t),i=w(e);(d.test(r)||f.test(i)||p.test(n))&&(o=!0),(m.test(r)||h.test(r)||_.test(n)||g.test(i)||await T(e))&&(s=!0)}o&&x(a,{rule:`security-path`,detail:`Security/auth path, task, or content matched security heuristics`,source:`security_auth`}),s&&x(a,{rule:`schema-contract`,detail:`Schema or contract path, task, or export shape matched contract heuristics`,source:`schema_contract`});let c=E(r,t);c.affectedFiles>5&&x(a,{rule:`blast-radius-importers`,detail:`${c.affectedFiles} affected files via direct import scanning`,source:`blast_radius`});let l=[...new Set(r.map(e=>j(e,t)).filter(e=>!!e))].sort();l.length>=2&&x(a,{rule:`cross-package-boundary`,detail:`Files span ${l.length} packages: ${l.join(`, `)}`,source:`cross_package`}),v.test(n)&&x(a,{rule:`task-hint-critical`,detail:`Task description matched migration or compatibility criticality hints`,source:`task_hint`});let u=a.length>0?`critical`:r.length===1?`floor`:`standard`;return{tier:u,triggers:a,packagesCrossed:l,hasSchemaChange:s,hasSecurityPath:o,typedUnknownSeeds:A(a),ceremony:y[u]}}function x(e,t){e.some(e=>e.rule===t.rule&&e.source===t.source)||e.push(t)}function S(e,t){let n=i(t,e),a=r(t,n);return(a&&!a.startsWith(`..`)?a:n).replace(/\\/g,`/`)}function C(e){if(!a(e))return!1;try{return c(e).size<=1e5}catch{return!1}}function w(e){if(!C(e))return``;try{return o(e,`utf-8`).split(/\r?\n/).slice(0,200).join(`
2
+ `)}catch{return``}}async function T(t){if(!C(t))return!1;try{let n=await e({path:t}),r=new Set(n.exports);return n.interfaces.some(e=>r.has(e.name))||n.types.some(e=>r.has(e.name))}catch{return!1}}function E(e,t){let n=new Set(e.filter(e=>a(e)));if(n.size===0)return{affectedFiles:e.length,importers:[]};let i=new Set;for(let e of D(t)){if(n.has(e)||!C(e))continue;let t=w(e);t&&O(t).some(t=>k(t,e,n))&&i.add(e)}return{affectedFiles:e.length+i.size,importers:[...i].map(e=>r(t,e).replace(/\\/g,`/`))}}function D(e){let t=[];function r(e){let a=[];try{a=s(e)}catch{return}for(let o of a){if(u.has(o))continue;let a=i(e,o),s;try{s=c(a)}catch{continue}if(s.isDirectory()){r(a);continue}l.has(n(o).toLowerCase())&&t.push(a)}}return r(e),t}function O(e){let t=new Set;for(let n of e.matchAll(/(?:from\s+['"]([^'"]+)['"]|import\s+['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\))/g)){let e=n[1]??n[2]??n[3];e&&t.add(e)}return[...t]}function k(e,n,r){if(!e.startsWith(`.`))return!1;let a=i(t(n),e);return[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.jsx`,`${a}.mts`,`${a}.cts`,`${a}.mjs`,`${a}.cjs`,i(a,`index.ts`),i(a,`index.tsx`),i(a,`index.js`),i(a,`index.jsx`)].some(e=>r.has(e))}function A(e){return e.map(e=>{switch(e.source){case`security_auth`:return{description:`Verify auth and security assumptions before yielding`,type:`contract`,suggestedTool:`kb_search`};case`schema_contract`:return{description:`Confirm schema and contract compatibility`,type:`contract`,suggestedTool:`kb_schema_validate`};case`blast_radius`:return{description:`Inspect affected importers before delivery`,type:`impact`,suggestedTool:`kb_blast_radius`};case`cross_package`:return{description:`Assess downstream package impact across boundaries`,type:`impact`,suggestedTool:`kb_blast_radius`};case`task_hint`:return{description:`Check established conventions for migrations or compatibility work`,type:`convention`,suggestedTool:`kb_find`};default:return{description:`No explicit unknown routing required`,type:`freshness`,suggestedTool:`kb_lookup`}}})}function j(e,n){let s=t(i(n,e)),c=i(n);for(;s.length>=c.length;){let e=i(s,`package.json`);if(a(e))try{return JSON.parse(o(e,`utf-8`)).name??r(c,s).replace(/\\/g,`/`)}catch{return r(c,s).replace(/\\/g,`/`)}let n=t(s);if(n===s)break;s=n}}export{b as forgeClassify};
3
+ //# sourceMappingURL=forge-classify.js.map
@@ -1,64 +1,62 @@
1
- /**
2
- * kb_forge_ground FORGE Phase 1 (Ground) batch executor.
3
- *
4
- * Executes the complete Ground phase as a single tool call:
5
- * tier classification scope map → typed unknowns → constraint seed → file summaries.
6
- */
7
- import type { IEmbedder } from '@kb/embeddings';
8
- import type { IKnowledgeStore } from '@kb/store';
9
- import { type ForgeTier } from './evidence-map.js';
10
- import { type ClassifyTrigger, type TypedUnknownSeed } from './forge-classify.js';
11
- import { type ScopeMapResult } from './scope-map.js';
12
- export interface ForgeGroundOptions {
13
- /** Task description */
14
- task: string;
15
- /** Target files being modified (absolute paths) */
16
- files: string[];
17
- /** Root path of the codebase */
18
- rootPath: string;
19
- /** Max constraint entries to load (default: 3) */
20
- maxConstraints?: number;
21
- /** Force a specific tier (skip auto-classify) */
22
- forceTier?: ForgeTier;
23
- /** Task ID for evidence map creation (default: auto-generated from task) */
24
- taskId?: string;
1
+ import { ForgeTier } from "./evidence-map.js";
2
+ import { ClassifyTrigger, TypedUnknownSeed } from "./forge-classify.js";
3
+ import { ScopeMapResult } from "./scope-map.js";
4
+ import { IEmbedder } from "@kb/embeddings";
5
+ import { IKnowledgeStore } from "@kb/store";
6
+
7
+ //#region packages/tools/src/forge-ground.d.ts
8
+ interface ForgeGroundOptions {
9
+ /** Task description */
10
+ task: string;
11
+ /** Target files being modified (absolute paths) */
12
+ files: string[];
13
+ /** Root path of the codebase */
14
+ rootPath: string;
15
+ /** Max constraint entries to load (default: 3) */
16
+ maxConstraints?: number;
17
+ /** Force a specific tier (skip auto-classify) */
18
+ forceTier?: ForgeTier;
19
+ /** Task ID for evidence map creation (default: auto-generated from task) */
20
+ taskId?: string;
25
21
  }
26
- export interface ConstraintRef {
27
- source: string;
28
- snippet: string;
29
- relevance: number;
22
+ interface ConstraintRef {
23
+ source: string;
24
+ snippet: string;
25
+ relevance: number;
30
26
  }
31
- export interface ForgeGroundResult {
32
- /** Computed or forced tier */
33
- tier: ForgeTier;
34
- /** Classification triggers (empty if tier was forced) */
35
- classifyTriggers: ClassifyTrigger[];
36
- /** Scope map (relevant files with focus ranges) — null for Floor tier */
37
- scopeMap: ScopeMapResult | null;
38
- /** Typed Unknown Queue seeds */
39
- typedUnknownSeeds: TypedUnknownSeed[];
40
- /** Constraint seed — relevant KB entries from decisions/patterns */
41
- constraints: ConstraintRef[];
42
- /** File summaries for target files */
43
- fileSummaries: Array<{
44
- path: string;
45
- exports: string[];
46
- functions: string[];
47
- lines: number;
48
- error?: string;
49
- }>;
50
- /** Evidence map task ID (created if Standard or Critical) */
51
- evidenceMapTaskId: string | null;
52
- /** Total estimated tokens for this Ground output */
53
- estimatedTokens: number;
54
- /** Ceremony recommendations for this tier */
55
- ceremony: {
56
- ground: string;
57
- build: string;
58
- break: string;
59
- evidenceMap: string;
60
- gate: string;
61
- };
27
+ interface ForgeGroundResult {
28
+ /** Computed or forced tier */
29
+ tier: ForgeTier;
30
+ /** Classification triggers (empty if tier was forced) */
31
+ classifyTriggers: ClassifyTrigger[];
32
+ /** Scope map (relevant files with focus ranges) — null for Floor tier */
33
+ scopeMap: ScopeMapResult | null;
34
+ /** Typed Unknown Queue seeds */
35
+ typedUnknownSeeds: TypedUnknownSeed[];
36
+ /** Constraint seed — relevant KB entries from decisions/patterns */
37
+ constraints: ConstraintRef[];
38
+ /** File summaries for target files */
39
+ fileSummaries: Array<{
40
+ path: string;
41
+ exports: string[];
42
+ functions: string[];
43
+ lines: number;
44
+ error?: string;
45
+ }>;
46
+ /** Evidence map task ID (created if Standard or Critical) */
47
+ evidenceMapTaskId: string | null;
48
+ /** Total estimated tokens for this Ground output */
49
+ estimatedTokens: number;
50
+ /** Ceremony recommendations for this tier */
51
+ ceremony: {
52
+ ground: string;
53
+ build: string;
54
+ break: string;
55
+ evidenceMap: string;
56
+ gate: string;
57
+ };
62
58
  }
63
- export declare function forgeGround(embedder: IEmbedder, store: IKnowledgeStore, options: ForgeGroundOptions): Promise<ForgeGroundResult>;
59
+ declare function forgeGround(embedder: IEmbedder, store: IKnowledgeStore, options: ForgeGroundOptions): Promise<ForgeGroundResult>;
60
+ //#endregion
61
+ export { ConstraintRef, ForgeGroundOptions, ForgeGroundResult, forgeGround };
64
62
  //# sourceMappingURL=forge-ground.d.ts.map
@@ -1 +1,2 @@
1
- import{evidenceMap as g}from"./evidence-map.js";import{fileSummary as m}from"./file-summary.js";import{forgeClassify as p}from"./forge-classify.js";import{scopeMap as f}from"./scope-map.js";import{estimateTokens as y}from"./text-utils.js";const S=3,c=200,T={floor:{ground:"Parasitic \u2014 read target file only",build:"Implement directly",break:"Skip",evidenceMap:"Not required",gate:"Self-certify"},standard:{ground:"Scope map + blast radius + constraint seed",build:"TDD \u2014 test first, then implement",break:"Error paths + edge cases",evidenceMap:"3-8 critical-path entries",gate:"YIELD/HOLD evaluation"},critical:{ground:"Full scope map + blast radius + trace + patterns + constraint pack",build:"TDD + contract verification + cross-service validation",break:"Error paths + edge cases + security dimensions + data-flow verification",evidenceMap:"Comprehensive \u2014 all critical-path claims with receipts",gate:"Strict YIELD/HOLD/HARD_BLOCK evaluation"}};async function D(e,r,t){const i=t.maxConstraints??S,n=await k(t),s=await F(t.files);if(n.tier==="floor")return u({tier:n.tier,classifyTriggers:n.classifyTriggers,scopeMap:null,typedUnknownSeeds:n.typedUnknownSeeds,constraints:[],fileSummaries:s,evidenceMapTaskId:null,ceremony:n.ceremony});const[a,o,d]=await Promise.all([R(e,r,t.task,n.tier),w(e,r,t.task,i),h(t.rootPath,t.taskId??C(t.task),n.tier)]);return u({tier:n.tier,classifyTriggers:n.classifyTriggers,scopeMap:a,typedUnknownSeeds:n.typedUnknownSeeds,constraints:o,fileSummaries:s,evidenceMapTaskId:d,ceremony:n.ceremony})}async function k(e){if(e.forceTier)return{tier:e.forceTier,classifyTriggers:[],typedUnknownSeeds:[],ceremony:l(e.forceTier)};try{const r=await p({files:e.files,task:e.task,rootPath:e.rootPath});return{tier:r.tier,classifyTriggers:r.triggers,typedUnknownSeeds:r.typedUnknownSeeds,ceremony:r.ceremony}}catch{return{tier:"standard",classifyTriggers:[],typedUnknownSeeds:[],ceremony:l("standard")}}}async function R(e,r,t,i){try{return await f(e,r,{task:t,maxFiles:i==="critical"?20:10})}catch{return null}}async function w(e,r,t,i){try{const n=`decision pattern convention ${t}`,s=typeof e.embedQuery=="function"?await e.embedQuery(n):await e.embed(n);return(await r.search(s,{limit:i,origin:"curated"})).slice(0,i).map(o=>v(o))}catch{return[]}}async function F(e){return Promise.all(e.map(async r=>b(r)))}async function b(e){try{const r=await m({path:e});return M(r)}catch(r){return{path:e,exports:[],functions:[],lines:0,error:r instanceof Error?r.message:"Unable to summarize file"}}}async function h(e,r,t){try{return g({action:"create",taskId:r,tier:t},e),r}catch{return null}}function v(e){return{source:e.record.sourcePath,snippet:I(e.record.content),relevance:e.score}}function I(e){const r=e.replace(/\s+/g," ").trim();return r.length<=c?r:`${r.slice(0,c-3).trimEnd()}...`}function M(e){return{path:e.path,exports:e.exports,functions:e.functions.map(r=>r.name),lines:e.lines}}function l(e){return{...T[e]}}function u(e){return{...e,estimatedTokens:y(JSON.stringify(e))}}function C(e){const r=e.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/).filter(Boolean).slice(0,5).join("-"),t=Date.now().toString(36);return`${r||"task"}-${t}`}export{D as forgeGround};
1
+ import{estimateTokens as e}from"./text-utils.js";import{evidenceMap as t}from"./evidence-map.js";import{fileSummary as n}from"./file-summary.js";import{forgeClassify as r}from"./forge-classify.js";import{scopeMap as i}from"./scope-map.js";const a={floor:{ground:`Parasitic read target file only`,build:`Implement directly`,break:`Skip`,evidenceMap:`Not required`,gate:`Self-certify`},standard:{ground:`Scope map + blast radius + constraint seed`,build:`TDD test first, then implement`,break:`Error paths + edge cases`,evidenceMap:`3-8 critical-path entries`,gate:`YIELD/HOLD evaluation`},critical:{ground:`Full scope map + blast radius + trace + patterns + constraint pack`,build:`TDD + contract verification + cross-service validation`,break:`Error paths + edge cases + security dimensions + data-flow verification`,evidenceMap:`Comprehensive all critical-path claims with receipts`,gate:`Strict YIELD/HOLD/HARD_BLOCK evaluation`}};async function o(e,t,n){let r=n.maxConstraints??3,i=await s(n),a=await u(n.files);if(i.tier===`floor`)return _({tier:i.tier,classifyTriggers:i.classifyTriggers,scopeMap:null,typedUnknownSeeds:i.typedUnknownSeeds,constraints:[],fileSummaries:a,evidenceMapTaskId:null,ceremony:i.ceremony});let[o,d,p]=await Promise.all([c(e,t,n.task,i.tier),l(e,t,n.task,r),f(n.rootPath,n.taskId??v(n.task),i.tier)]);return _({tier:i.tier,classifyTriggers:i.classifyTriggers,scopeMap:o,typedUnknownSeeds:i.typedUnknownSeeds,constraints:d,fileSummaries:a,evidenceMapTaskId:p,ceremony:i.ceremony})}async function s(e){if(e.forceTier)return{tier:e.forceTier,classifyTriggers:[],typedUnknownSeeds:[],ceremony:g(e.forceTier)};try{let t=await r({files:e.files,task:e.task,rootPath:e.rootPath});return{tier:t.tier,classifyTriggers:t.triggers,typedUnknownSeeds:t.typedUnknownSeeds,ceremony:t.ceremony}}catch{return{tier:`standard`,classifyTriggers:[],typedUnknownSeeds:[],ceremony:g(`standard`)}}}async function c(e,t,n,r){try{return await i(e,t,{task:n,maxFiles:r===`critical`?20:10})}catch{return null}}async function l(e,t,n,r){try{let i=`decision pattern convention ${n}`,a=typeof e.embedQuery==`function`?await e.embedQuery(i):await e.embed(i);return(await t.search(a,{limit:r,origin:`curated`})).slice(0,r).map(e=>p(e))}catch{return[]}}async function u(e){return Promise.all(e.map(async e=>d(e)))}async function d(e){try{return h(await n({path:e}))}catch(t){return{path:e,exports:[],functions:[],lines:0,error:t instanceof Error?t.message:`Unable to summarize file`}}}async function f(e,n,r){try{return t({action:`create`,taskId:n,tier:r},e),n}catch{return null}}function p(e){return{source:e.record.sourcePath,snippet:m(e.record.content),relevance:e.score}}function m(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=200?t:`${t.slice(0,197).trimEnd()}...`}function h(e){return{path:e.path,exports:e.exports,functions:e.functions.map(e=>e.name),lines:e.lines}}function g(e){return{...a[e]}}function _(t){return{...t,estimatedTokens:e(JSON.stringify(t))}}function v(e){let t=e.toLowerCase().replace(/[^a-z0-9\s]/g,` `).split(/\s+/).filter(Boolean).slice(0,5).join(`-`),n=Date.now().toString(36);return`${t||`task`}-${n}`}export{o as forgeGround};
2
+ //# sourceMappingURL=forge-ground.js.map
@@ -1,22 +1,25 @@
1
- export interface GitContextOptions {
2
- cwd?: string;
3
- commitCount?: number;
4
- includeDiff?: boolean;
1
+ //#region packages/tools/src/git-context.d.ts
2
+ interface GitContextOptions {
3
+ cwd?: string;
4
+ commitCount?: number;
5
+ includeDiff?: boolean;
5
6
  }
6
- export interface GitContextResult {
7
- branch: string;
8
- status: {
9
- staged: string[];
10
- modified: string[];
11
- untracked: string[];
12
- };
13
- recentCommits: Array<{
14
- hash: string;
15
- message: string;
16
- author: string;
17
- date: string;
18
- }>;
19
- diff?: string;
7
+ interface GitContextResult {
8
+ branch: string;
9
+ status: {
10
+ staged: string[];
11
+ modified: string[];
12
+ untracked: string[];
13
+ };
14
+ recentCommits: Array<{
15
+ hash: string;
16
+ message: string;
17
+ author: string;
18
+ date: string;
19
+ }>;
20
+ diff?: string;
20
21
  }
21
- export declare function gitContext(options?: GitContextOptions): Promise<GitContextResult>;
22
+ declare function gitContext(options?: GitContextOptions): Promise<GitContextResult>;
23
+ //#endregion
24
+ export { GitContextOptions, GitContextResult, gitContext };
22
25
  //# sourceMappingURL=git-context.d.ts.map
@@ -1,3 +1,4 @@
1
- import{execFile as x}from"node:child_process";import{promisify as w}from"node:util";const C=w(x);async function o(n,t){try{const{stdout:a}=await C("git",n,{cwd:t});return a.toString().trim()}catch{return""}}async function R(n={}){const t=n.cwd??process.cwd(),a=n.commitCount??5,[u,g,l,d]=await Promise.all([o(["rev-parse","--abbrev-ref","HEAD"],t),o(["status","--porcelain"],t),o(["log",`--max-count=${a}`,"--format=%h|%s|%an|%ai"],t),n.includeDiff?o(["diff","--stat","--no-color"],t):Promise.resolve("")]),c=[],f=[],m=[];for(const i of g.split(`
2
- `).filter(Boolean)){const s=i[0],e=i[1],r=i.slice(3).trim();s!==" "&&s!=="?"&&c.push(r),(e==="M"||e==="D")&&f.push(r),s==="?"&&m.push(r)}const p=l.split(`
3
- `).filter(Boolean).map(i=>{const[s,e,r,h]=i.split("|");return{hash:s,message:e,author:r,date:h}});return{branch:u||"unknown",status:{staged:c,modified:f,untracked:m},recentCommits:p,diff:d||void 0}}export{R as gitContext};
1
+ import{execFile as e}from"node:child_process";import{promisify as t}from"node:util";const n=t(e);async function r(e,t){try{let{stdout:r}=await n(`git`,e,{cwd:t,timeout:15e3});return r.toString().trim()}catch{return``}}async function i(e={}){let t=e.cwd??process.cwd(),n=e.commitCount??5,[i,a,o,s]=await Promise.all([r([`rev-parse`,`--abbrev-ref`,`HEAD`],t),r([`status`,`--porcelain`],t),r([`log`,`--max-count=${n}`,`--format=%h|%s|%an|%ai`],t),e.includeDiff?r([`diff`,`--stat`,`--no-color`],t):Promise.resolve(``)]),c=[],l=[],u=[];for(let e of a.split(`
2
+ `).filter(Boolean)){let t=e[0],n=e[1],r=e.slice(3).trim();t!==` `&&t!==`?`&&c.push(r),(n===`M`||n===`D`)&&l.push(r),t===`?`&&u.push(r)}let d=o.split(`
3
+ `).filter(Boolean).map(e=>{let[t,n,r,i]=e.split(`|`);return{hash:t,message:n,author:r,date:i}});return{branch:i||`unknown`,status:{staged:c,modified:l,untracked:u},recentCommits:d,diff:s||void 0}}export{i as gitContext};
4
+ //# sourceMappingURL=git-context.js.map