@vpxa/kb 0.1.13 → 0.1.16

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 (490) hide show
  1. package/README.md +65 -12
  2. package/package.json +14 -7
  3. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -21
  4. package/packages/analyzers/dist/blast-radius-analyzer.js +5 -12
  5. package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -28
  6. package/packages/analyzers/dist/dependency-analyzer.js +6 -9
  7. package/packages/analyzers/dist/diagram-generator.d.ts +12 -9
  8. package/packages/analyzers/dist/diagram-generator.js +2 -4
  9. package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -36
  10. package/packages/analyzers/dist/entry-point-analyzer.js +4 -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 +34 -26
  14. package/packages/analyzers/dist/knowledge-producer.js +17 -15
  15. package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -11
  16. package/packages/analyzers/dist/pattern-analyzer.js +2 -5
  17. package/packages/analyzers/dist/regex-call-graph.d.ts +6 -13
  18. package/packages/analyzers/dist/regex-call-graph.js +1 -1
  19. package/packages/analyzers/dist/structure-analyzer.d.ts +13 -10
  20. package/packages/analyzers/dist/structure-analyzer.js +2 -4
  21. package/packages/analyzers/dist/symbol-analyzer.d.ts +13 -9
  22. package/packages/analyzers/dist/symbol-analyzer.js +9 -13
  23. package/packages/analyzers/dist/ts-call-graph.d.ts +16 -14
  24. package/packages/analyzers/dist/ts-call-graph.js +1 -1
  25. package/packages/analyzers/dist/types.d.ts +82 -80
  26. package/packages/analyzers/dist/types.js +1 -0
  27. package/packages/chunker/dist/call-graph-extractor.d.ts +15 -12
  28. package/packages/chunker/dist/call-graph-extractor.js +1 -1
  29. package/packages/chunker/dist/chunker-factory.d.ts +16 -4
  30. package/packages/chunker/dist/chunker-factory.js +1 -1
  31. package/packages/chunker/dist/chunker.interface.d.ts +8 -5
  32. package/packages/chunker/dist/chunker.interface.js +1 -0
  33. package/packages/chunker/dist/code-chunker.d.ts +16 -13
  34. package/packages/chunker/dist/code-chunker.js +11 -14
  35. package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
  36. package/packages/chunker/dist/extractors/call-extractor.js +1 -0
  37. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
  38. package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
  39. package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
  40. package/packages/chunker/dist/extractors/import-extractor.js +1 -0
  41. package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
  42. package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
  43. package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
  44. package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
  45. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
  46. package/packages/chunker/dist/extractors/symbol-extractor.js +1 -0
  47. package/packages/chunker/dist/extractors/types.d.ts +36 -0
  48. package/packages/chunker/dist/extractors/types.js +1 -0
  49. package/packages/chunker/dist/generic-chunker.d.ts +14 -11
  50. package/packages/chunker/dist/generic-chunker.js +5 -5
  51. package/packages/chunker/dist/index.d.ts +19 -8
  52. package/packages/chunker/dist/index.js +1 -1
  53. package/packages/chunker/dist/markdown-chunker.d.ts +16 -13
  54. package/packages/chunker/dist/markdown-chunker.js +3 -10
  55. package/packages/chunker/dist/wasm/languages.d.ts +18 -0
  56. package/packages/chunker/dist/wasm/languages.js +1 -0
  57. package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
  58. package/packages/chunker/dist/wasm/query-executor.js +1 -0
  59. package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
  60. package/packages/chunker/dist/wasm/runtime.js +1 -0
  61. package/packages/chunker/dist/wasm/types.d.ts +84 -0
  62. package/packages/chunker/dist/wasm/types.js +1 -0
  63. package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
  64. package/packages/chunker/dist/wasm-chunker.js +6 -0
  65. package/packages/chunker/src/queries/go/calls.scm +11 -0
  66. package/packages/chunker/src/queries/go/entry-points.scm +20 -0
  67. package/packages/chunker/src/queries/go/imports.scm +6 -0
  68. package/packages/chunker/src/queries/go/patterns.scm +25 -0
  69. package/packages/chunker/src/queries/go/symbols.scm +26 -0
  70. package/packages/chunker/src/queries/java/calls.scm +10 -0
  71. package/packages/chunker/src/queries/java/entry-points.scm +27 -0
  72. package/packages/chunker/src/queries/java/imports.scm +11 -0
  73. package/packages/chunker/src/queries/java/patterns.scm +27 -0
  74. package/packages/chunker/src/queries/java/symbols.scm +28 -0
  75. package/packages/chunker/src/queries/javascript/calls.scm +21 -0
  76. package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
  77. package/packages/chunker/src/queries/javascript/imports.scm +32 -0
  78. package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
  79. package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
  80. package/packages/chunker/src/queries/python/calls.scm +11 -0
  81. package/packages/chunker/src/queries/python/entry-points.scm +21 -0
  82. package/packages/chunker/src/queries/python/imports.scm +14 -0
  83. package/packages/chunker/src/queries/python/patterns.scm +25 -0
  84. package/packages/chunker/src/queries/python/symbols.scm +17 -0
  85. package/packages/chunker/src/queries/rust/calls.scm +20 -0
  86. package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
  87. package/packages/chunker/src/queries/rust/imports.scm +26 -0
  88. package/packages/chunker/src/queries/rust/patterns.scm +18 -0
  89. package/packages/chunker/src/queries/rust/symbols.scm +73 -0
  90. package/packages/chunker/src/queries/typescript/calls.scm +21 -0
  91. package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
  92. package/packages/chunker/src/queries/typescript/imports.scm +35 -0
  93. package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
  94. package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
  95. package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
  96. package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
  97. package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
  98. package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
  99. package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
  100. package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
  101. package/packages/chunker/wasm/tree-sitter.wasm +0 -0
  102. package/packages/cli/dist/commands/analyze.d.ts +6 -3
  103. package/packages/cli/dist/commands/analyze.js +2 -3
  104. package/packages/cli/dist/commands/context-cmds.d.ts +6 -3
  105. package/packages/cli/dist/commands/context-cmds.js +1 -1
  106. package/packages/cli/dist/commands/environment.d.ts +6 -3
  107. package/packages/cli/dist/commands/environment.js +1 -2
  108. package/packages/cli/dist/commands/execution.d.ts +6 -3
  109. package/packages/cli/dist/commands/execution.js +1 -1
  110. package/packages/cli/dist/commands/graph.d.ts +6 -3
  111. package/packages/cli/dist/commands/graph.js +5 -6
  112. package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
  113. package/packages/cli/dist/commands/init/adapters.js +1 -0
  114. package/packages/cli/dist/commands/init/config.d.ts +10 -0
  115. package/packages/cli/dist/commands/init/config.js +3 -0
  116. package/packages/cli/dist/commands/init/constants.d.ts +18 -0
  117. package/packages/cli/dist/commands/init/constants.js +1 -0
  118. package/packages/cli/dist/commands/init/curated.d.ts +7 -0
  119. package/packages/cli/dist/commands/init/curated.js +1 -0
  120. package/packages/cli/dist/commands/init/global.d.ts +34 -0
  121. package/packages/cli/dist/commands/init/global.js +5 -0
  122. package/packages/cli/dist/commands/init/index.d.ts +28 -0
  123. package/packages/cli/dist/commands/init/index.js +5 -0
  124. package/packages/cli/dist/commands/init/scaffold.d.ts +23 -0
  125. package/packages/cli/dist/commands/init/scaffold.js +1 -0
  126. package/packages/cli/dist/commands/init/templates.d.ts +9 -0
  127. package/packages/cli/dist/commands/init/templates.js +165 -0
  128. package/packages/cli/dist/commands/knowledge.d.ts +6 -3
  129. package/packages/cli/dist/commands/knowledge.js +1 -1
  130. package/packages/cli/dist/commands/search.d.ts +6 -3
  131. package/packages/cli/dist/commands/search.js +1 -8
  132. package/packages/cli/dist/commands/system.d.ts +6 -3
  133. package/packages/cli/dist/commands/system.js +4 -7
  134. package/packages/cli/dist/commands/workspace.d.ts +6 -3
  135. package/packages/cli/dist/commands/workspace.js +1 -2
  136. package/packages/cli/dist/context.d.ts +7 -5
  137. package/packages/cli/dist/context.js +1 -1
  138. package/packages/cli/dist/helpers.d.ts +51 -48
  139. package/packages/cli/dist/helpers.js +5 -5
  140. package/packages/cli/dist/index.d.ts +4 -2
  141. package/packages/cli/dist/index.js +2 -2
  142. package/packages/cli/dist/kb-init.d.ts +48 -51
  143. package/packages/cli/dist/kb-init.js +1 -1
  144. package/packages/cli/dist/types.d.ts +8 -6
  145. package/packages/cli/dist/types.js +1 -0
  146. package/packages/core/dist/constants.d.ts +58 -34
  147. package/packages/core/dist/constants.js +1 -1
  148. package/packages/core/dist/content-detector.d.ts +8 -8
  149. package/packages/core/dist/content-detector.js +1 -1
  150. package/packages/core/dist/errors.d.ts +15 -13
  151. package/packages/core/dist/errors.js +1 -1
  152. package/packages/core/dist/global-registry.d.ts +62 -0
  153. package/packages/core/dist/global-registry.js +1 -0
  154. package/packages/core/dist/index.d.ts +7 -6
  155. package/packages/core/dist/index.js +1 -1
  156. package/packages/core/dist/logger.d.ts +19 -8
  157. package/packages/core/dist/logger.js +1 -1
  158. package/packages/core/dist/types.d.ts +107 -92
  159. package/packages/core/dist/types.js +1 -0
  160. package/packages/embeddings/dist/embedder.interface.d.ts +22 -20
  161. package/packages/embeddings/dist/embedder.interface.js +1 -0
  162. package/packages/embeddings/dist/index.d.ts +3 -3
  163. package/packages/embeddings/dist/index.js +1 -1
  164. package/packages/embeddings/dist/onnx-embedder.d.ts +21 -23
  165. package/packages/embeddings/dist/onnx-embedder.js +1 -1
  166. package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
  167. package/packages/enterprise-bridge/dist/cache.js +1 -0
  168. package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
  169. package/packages/enterprise-bridge/dist/er-client.js +1 -0
  170. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
  171. package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
  172. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  173. package/packages/enterprise-bridge/dist/index.js +1 -0
  174. package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
  175. package/packages/enterprise-bridge/dist/policy-store.js +1 -0
  176. package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
  177. package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
  178. package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
  179. package/packages/enterprise-bridge/dist/result-merger.js +1 -0
  180. package/packages/enterprise-bridge/dist/types.d.ts +81 -0
  181. package/packages/enterprise-bridge/dist/types.js +1 -0
  182. package/packages/indexer/dist/file-hasher.d.ts +5 -3
  183. package/packages/indexer/dist/file-hasher.js +1 -1
  184. package/packages/indexer/dist/filesystem-crawler.d.ts +23 -21
  185. package/packages/indexer/dist/filesystem-crawler.js +1 -1
  186. package/packages/indexer/dist/graph-extractor.d.ts +9 -13
  187. package/packages/indexer/dist/graph-extractor.js +1 -1
  188. package/packages/indexer/dist/incremental-indexer.d.ts +49 -44
  189. package/packages/indexer/dist/incremental-indexer.js +1 -1
  190. package/packages/indexer/dist/index.d.ts +5 -5
  191. package/packages/indexer/dist/index.js +1 -1
  192. package/packages/server/dist/api.d.ts +3 -8
  193. package/packages/server/dist/api.js +1 -1
  194. package/packages/server/dist/config.d.ts +6 -3
  195. package/packages/server/dist/config.js +1 -1
  196. package/packages/server/dist/cross-workspace.d.ts +43 -0
  197. package/packages/server/dist/cross-workspace.js +1 -0
  198. package/packages/server/dist/curated-manager.d.ts +80 -78
  199. package/packages/server/dist/curated-manager.js +5 -10
  200. package/packages/server/dist/index.d.ts +1 -2
  201. package/packages/server/dist/index.js +1 -1
  202. package/packages/server/dist/replay-interceptor.d.ts +6 -7
  203. package/packages/server/dist/replay-interceptor.js +1 -1
  204. package/packages/server/dist/resources/resources.d.ts +7 -4
  205. package/packages/server/dist/resources/resources.js +2 -2
  206. package/packages/server/dist/server.d.ts +37 -25
  207. package/packages/server/dist/server.js +1 -1
  208. package/packages/server/dist/tools/analyze.tools.d.ts +14 -11
  209. package/packages/server/dist/tools/analyze.tools.js +1 -3
  210. package/packages/server/dist/tools/audit.tool.d.ts +8 -5
  211. package/packages/server/dist/tools/audit.tool.js +1 -4
  212. package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
  213. package/packages/server/dist/tools/bridge.tools.js +15 -0
  214. package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
  215. package/packages/server/dist/tools/evolution.tools.js +5 -0
  216. package/packages/server/dist/tools/forge.tools.d.ts +13 -12
  217. package/packages/server/dist/tools/forge.tools.js +10 -13
  218. package/packages/server/dist/tools/forget.tool.d.ts +7 -4
  219. package/packages/server/dist/tools/forget.tool.js +1 -7
  220. package/packages/server/dist/tools/graph.tool.d.ts +7 -4
  221. package/packages/server/dist/tools/graph.tool.js +4 -5
  222. package/packages/server/dist/tools/list.tool.d.ts +7 -4
  223. package/packages/server/dist/tools/list.tool.js +2 -8
  224. package/packages/server/dist/tools/lookup.tool.d.ts +7 -4
  225. package/packages/server/dist/tools/lookup.tool.js +2 -9
  226. package/packages/server/dist/tools/onboard.tool.d.ts +8 -5
  227. package/packages/server/dist/tools/onboard.tool.js +2 -2
  228. package/packages/server/dist/tools/policy.tools.d.ts +7 -0
  229. package/packages/server/dist/tools/policy.tools.js +2 -0
  230. package/packages/server/dist/tools/produce.tool.d.ts +6 -3
  231. package/packages/server/dist/tools/produce.tool.js +2 -2
  232. package/packages/server/dist/tools/read.tool.d.ts +7 -4
  233. package/packages/server/dist/tools/read.tool.js +2 -6
  234. package/packages/server/dist/tools/reindex.tool.d.ts +10 -7
  235. package/packages/server/dist/tools/reindex.tool.js +3 -2
  236. package/packages/server/dist/tools/remember.tool.d.ts +8 -4
  237. package/packages/server/dist/tools/remember.tool.js +3 -5
  238. package/packages/server/dist/tools/replay.tool.d.ts +6 -3
  239. package/packages/server/dist/tools/replay.tool.js +2 -6
  240. package/packages/server/dist/tools/search.tool.d.ts +10 -5
  241. package/packages/server/dist/tools/search.tool.js +6 -22
  242. package/packages/server/dist/tools/status.tool.d.ts +12 -4
  243. package/packages/server/dist/tools/status.tool.js +2 -3
  244. package/packages/server/dist/tools/toolkit.tools.d.ts +36 -35
  245. package/packages/server/dist/tools/toolkit.tools.js +20 -24
  246. package/packages/server/dist/tools/update.tool.d.ts +7 -4
  247. package/packages/server/dist/tools/update.tool.js +1 -6
  248. package/packages/server/dist/tools/utility.tools.d.ts +15 -15
  249. package/packages/server/dist/tools/utility.tools.js +10 -23
  250. package/packages/server/dist/version-check.d.ts +5 -2
  251. package/packages/server/dist/version-check.js +1 -1
  252. package/packages/store/dist/graph-store.interface.d.ts +89 -87
  253. package/packages/store/dist/graph-store.interface.js +1 -0
  254. package/packages/store/dist/index.d.ts +6 -6
  255. package/packages/store/dist/index.js +1 -1
  256. package/packages/store/dist/lance-store.d.ts +37 -31
  257. package/packages/store/dist/lance-store.js +1 -1
  258. package/packages/store/dist/sqlite-graph-store.d.ts +43 -47
  259. package/packages/store/dist/sqlite-graph-store.js +13 -13
  260. package/packages/store/dist/store-factory.d.ts +11 -8
  261. package/packages/store/dist/store-factory.js +1 -1
  262. package/packages/store/dist/store.interface.d.ts +47 -47
  263. package/packages/store/dist/store.interface.js +1 -0
  264. package/packages/tools/dist/audit.d.ts +61 -62
  265. package/packages/tools/dist/audit.js +4 -5
  266. package/packages/tools/dist/batch.d.ts +20 -18
  267. package/packages/tools/dist/batch.js +1 -1
  268. package/packages/tools/dist/changelog.d.ts +29 -27
  269. package/packages/tools/dist/changelog.js +2 -2
  270. package/packages/tools/dist/check.d.ts +42 -39
  271. package/packages/tools/dist/check.js +2 -2
  272. package/packages/tools/dist/checkpoint.d.ts +17 -15
  273. package/packages/tools/dist/checkpoint.js +1 -2
  274. package/packages/tools/dist/codemod.d.ts +35 -33
  275. package/packages/tools/dist/codemod.js +2 -2
  276. package/packages/tools/dist/compact.d.ts +34 -38
  277. package/packages/tools/dist/compact.js +2 -2
  278. package/packages/tools/dist/data-transform.d.ts +10 -8
  279. package/packages/tools/dist/data-transform.js +1 -1
  280. package/packages/tools/dist/dead-symbols.d.ts +29 -26
  281. package/packages/tools/dist/dead-symbols.js +2 -2
  282. package/packages/tools/dist/delegate.d.ts +26 -24
  283. package/packages/tools/dist/delegate.js +1 -5
  284. package/packages/tools/dist/diff-parse.d.ts +24 -22
  285. package/packages/tools/dist/diff-parse.js +3 -3
  286. package/packages/tools/dist/digest.d.ts +43 -46
  287. package/packages/tools/dist/digest.js +4 -5
  288. package/packages/tools/dist/dogfood-log.d.ts +49 -0
  289. package/packages/tools/dist/dogfood-log.js +2 -0
  290. package/packages/tools/dist/encode.d.ts +11 -9
  291. package/packages/tools/dist/encode.js +1 -1
  292. package/packages/tools/dist/env-info.d.ts +25 -23
  293. package/packages/tools/dist/env-info.js +1 -1
  294. package/packages/tools/dist/eval.d.ts +13 -11
  295. package/packages/tools/dist/eval.js +2 -3
  296. package/packages/tools/dist/evidence-map.d.ts +64 -62
  297. package/packages/tools/dist/evidence-map.js +2 -3
  298. package/packages/tools/dist/file-cache.d.ts +41 -0
  299. package/packages/tools/dist/file-cache.js +3 -0
  300. package/packages/tools/dist/file-summary.d.ts +50 -30
  301. package/packages/tools/dist/file-summary.js +2 -2
  302. package/packages/tools/dist/file-walk.d.ts +6 -4
  303. package/packages/tools/dist/file-walk.js +1 -1
  304. package/packages/tools/dist/find-examples.d.ts +26 -22
  305. package/packages/tools/dist/find-examples.js +3 -3
  306. package/packages/tools/dist/find.d.ts +39 -41
  307. package/packages/tools/dist/find.js +1 -1
  308. package/packages/tools/dist/forge-classify.d.ts +35 -39
  309. package/packages/tools/dist/forge-classify.js +2 -2
  310. package/packages/tools/dist/forge-ground.d.ts +58 -61
  311. package/packages/tools/dist/forge-ground.js +1 -1
  312. package/packages/tools/dist/git-context.d.ts +22 -20
  313. package/packages/tools/dist/git-context.js +3 -3
  314. package/packages/tools/dist/graph-query.d.ts +75 -79
  315. package/packages/tools/dist/graph-query.js +1 -1
  316. package/packages/tools/dist/guide.d.ts +14 -12
  317. package/packages/tools/dist/guide.js +1 -1
  318. package/packages/tools/dist/health.d.ts +13 -11
  319. package/packages/tools/dist/health.js +2 -2
  320. package/packages/tools/dist/http-request.d.ts +20 -18
  321. package/packages/tools/dist/http-request.js +1 -1
  322. package/packages/tools/dist/index.d.ts +55 -53
  323. package/packages/tools/dist/index.js +1 -1
  324. package/packages/tools/dist/lane.d.ts +28 -26
  325. package/packages/tools/dist/lane.js +6 -7
  326. package/packages/tools/dist/measure.d.ts +34 -30
  327. package/packages/tools/dist/measure.js +2 -2
  328. package/packages/tools/dist/onboard.d.ts +29 -27
  329. package/packages/tools/dist/onboard.js +17 -41
  330. package/packages/tools/dist/parse-output.d.ts +48 -46
  331. package/packages/tools/dist/parse-output.js +2 -2
  332. package/packages/tools/dist/path-resolver.d.ts +4 -2
  333. package/packages/tools/dist/path-resolver.js +1 -1
  334. package/packages/tools/dist/process-manager.d.ts +18 -16
  335. package/packages/tools/dist/process-manager.js +1 -1
  336. package/packages/tools/dist/queue.d.ts +28 -26
  337. package/packages/tools/dist/queue.js +1 -2
  338. package/packages/tools/dist/regex-test.d.ts +26 -24
  339. package/packages/tools/dist/regex-test.js +1 -1
  340. package/packages/tools/dist/rename.d.ts +28 -26
  341. package/packages/tools/dist/rename.js +2 -2
  342. package/packages/tools/dist/replay.d.ts +33 -31
  343. package/packages/tools/dist/replay.js +4 -6
  344. package/packages/tools/dist/response-envelope.d.ts +32 -30
  345. package/packages/tools/dist/response-envelope.js +1 -1
  346. package/packages/tools/dist/schema-validate.d.ts +15 -13
  347. package/packages/tools/dist/schema-validate.js +1 -1
  348. package/packages/tools/dist/scope-map.d.ts +45 -48
  349. package/packages/tools/dist/scope-map.js +1 -1
  350. package/packages/tools/dist/snippet.d.ts +26 -25
  351. package/packages/tools/dist/snippet.js +1 -1
  352. package/packages/tools/dist/stash.d.ts +13 -11
  353. package/packages/tools/dist/stash.js +1 -2
  354. package/packages/tools/dist/stratum-card.d.ts +27 -28
  355. package/packages/tools/dist/stratum-card.js +3 -5
  356. package/packages/tools/dist/symbol.d.ts +31 -26
  357. package/packages/tools/dist/symbol.js +3 -3
  358. package/packages/tools/dist/test-run.d.ts +19 -16
  359. package/packages/tools/dist/test-run.js +2 -2
  360. package/packages/tools/dist/text-utils.d.ts +6 -4
  361. package/packages/tools/dist/text-utils.js +2 -2
  362. package/packages/tools/dist/time-utils.d.ts +15 -13
  363. package/packages/tools/dist/time-utils.js +1 -1
  364. package/packages/tools/dist/trace.d.ts +26 -21
  365. package/packages/tools/dist/trace.js +2 -2
  366. package/packages/tools/dist/truncation.d.ts +6 -4
  367. package/packages/tools/dist/truncation.js +6 -13
  368. package/packages/tools/dist/watch.d.ts +28 -26
  369. package/packages/tools/dist/watch.js +1 -1
  370. package/packages/tools/dist/web-fetch.d.ts +35 -33
  371. package/packages/tools/dist/web-fetch.js +6 -12
  372. package/packages/tools/dist/web-search.d.ts +16 -14
  373. package/packages/tools/dist/web-search.js +1 -1
  374. package/packages/tools/dist/workset.d.ts +19 -17
  375. package/packages/tools/dist/workset.js +1 -2
  376. package/packages/tui/dist/App-CYLNJLr6.js +2 -0
  377. package/packages/tui/dist/App.d.ts +11 -6
  378. package/packages/tui/dist/App.js +1 -450
  379. package/packages/tui/dist/CuratedPanel-sYdZAICX.js +2 -0
  380. package/packages/tui/dist/LogPanel-DtMnoyXT.js +3 -0
  381. package/packages/tui/dist/SearchPanel-DREo6zgt.js +2 -0
  382. package/packages/tui/dist/StatusPanel-2ex8fLOO.js +2 -0
  383. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  384. package/packages/tui/dist/devtools-DUyj952l.js +7 -0
  385. package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +28 -0
  386. package/packages/tui/dist/index-B9VpfVPP.d.ts +13 -0
  387. package/packages/tui/dist/index.d.ts +3 -19
  388. package/packages/tui/dist/index.js +1 -476
  389. package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +316 -0
  390. package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -6
  391. package/packages/tui/dist/panels/CuratedPanel.js +1 -371
  392. package/packages/tui/dist/panels/LogPanel.d.ts +7 -3
  393. package/packages/tui/dist/panels/LogPanel.js +1 -449
  394. package/packages/tui/dist/panels/SearchPanel.d.ts +14 -8
  395. package/packages/tui/dist/panels/SearchPanel.js +1 -372
  396. package/packages/tui/dist/panels/StatusPanel.d.ts +11 -6
  397. package/packages/tui/dist/panels/StatusPanel.js +1 -371
  398. package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +150 -0
  399. package/scaffold/adapters/claude-code.mjs +20 -0
  400. package/scaffold/adapters/copilot.mjs +320 -0
  401. package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  402. package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +21 -0
  403. package/scaffold/copilot/agents/Documenter.agent.md +42 -0
  404. package/scaffold/copilot/agents/Orchestrator.agent.md +104 -0
  405. package/scaffold/copilot/agents/Planner.agent.md +54 -0
  406. package/scaffold/copilot/agents/Refactor.agent.md +36 -0
  407. package/scaffold/copilot/agents/Researcher-Alpha.agent.md +20 -0
  408. package/scaffold/copilot/agents/Researcher-Beta.agent.md +20 -0
  409. package/scaffold/copilot/agents/Researcher-Delta.agent.md +20 -0
  410. package/scaffold/copilot/agents/Researcher-Gamma.agent.md +20 -0
  411. package/scaffold/definitions/agents.mjs +165 -0
  412. package/scaffold/definitions/bodies.mjs +292 -0
  413. package/scaffold/definitions/hooks.mjs +43 -0
  414. package/scaffold/definitions/models.mjs +56 -0
  415. package/scaffold/definitions/plugins.mjs +24 -0
  416. package/scaffold/definitions/prompts.mjs +145 -0
  417. package/scaffold/definitions/protocols.mjs +322 -0
  418. package/scaffold/definitions/tools.mjs +176 -0
  419. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  420. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
  421. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
  422. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
  423. package/scaffold/general/agents/Debugger.agent.md +31 -0
  424. package/scaffold/general/agents/Documenter.agent.md +42 -0
  425. package/scaffold/general/agents/Explorer.agent.md +50 -0
  426. package/scaffold/general/agents/Frontend.agent.md +29 -0
  427. package/scaffold/general/agents/Implementer.agent.md +31 -0
  428. package/scaffold/general/agents/Orchestrator.agent.md +104 -0
  429. package/scaffold/general/agents/Planner.agent.md +55 -0
  430. package/scaffold/general/agents/README.md +57 -0
  431. package/scaffold/general/agents/Refactor.agent.md +36 -0
  432. package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
  433. package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
  434. package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
  435. package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
  436. package/scaffold/general/agents/Security.agent.md +42 -0
  437. package/scaffold/general/agents/_shared/adr-protocol.md +91 -0
  438. package/scaffold/general/agents/_shared/architect-reviewer-base.md +50 -0
  439. package/scaffold/general/agents/_shared/code-agent-base.md +88 -0
  440. package/scaffold/general/agents/_shared/code-reviewer-base.md +54 -0
  441. package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
  442. package/scaffold/general/agents/_shared/forge-protocol.md +46 -0
  443. package/scaffold/general/agents/_shared/researcher-base.md +61 -0
  444. package/scaffold/general/agents/templates/adr-template.md +27 -0
  445. package/scaffold/general/agents/templates/execution-state.md +25 -0
  446. package/scaffold/general/prompts/ask.prompt.md +20 -0
  447. package/scaffold/general/prompts/debug.prompt.md +25 -0
  448. package/scaffold/general/prompts/design.prompt.md +22 -0
  449. package/scaffold/general/prompts/implement.prompt.md +26 -0
  450. package/scaffold/general/prompts/plan.prompt.md +24 -0
  451. package/scaffold/general/prompts/review.prompt.md +31 -0
  452. package/scaffold/generate.mjs +74 -0
  453. package/skills/adr-skill/SKILL.md +329 -0
  454. package/skills/adr-skill/assets/templates/adr-madr.md +89 -0
  455. package/skills/adr-skill/assets/templates/adr-readme.md +20 -0
  456. package/skills/adr-skill/assets/templates/adr-simple.md +46 -0
  457. package/skills/adr-skill/references/adr-conventions.md +95 -0
  458. package/skills/adr-skill/references/examples.md +193 -0
  459. package/skills/adr-skill/references/review-checklist.md +77 -0
  460. package/skills/adr-skill/references/template-variants.md +52 -0
  461. package/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
  462. package/skills/adr-skill/scripts/new_adr.js +391 -0
  463. package/skills/adr-skill/scripts/set_adr_status.js +169 -0
  464. package/skills/brainstorming/SKILL.md +259 -0
  465. package/skills/brainstorming/scripts/frame-template.html +365 -0
  466. package/skills/brainstorming/scripts/helper.js +216 -0
  467. package/skills/brainstorming/scripts/server.cjs +9 -0
  468. package/skills/brainstorming/scripts/server.src.cjs +249 -0
  469. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  470. package/skills/brainstorming/visual-companion.md +430 -0
  471. package/skills/c4-architecture/SKILL.md +295 -0
  472. package/skills/c4-architecture/references/advanced-patterns.md +552 -0
  473. package/skills/c4-architecture/references/c4-syntax.md +492 -0
  474. package/skills/c4-architecture/references/common-mistakes.md +437 -0
  475. package/skills/knowledge-base/SKILL.md +100 -10
  476. package/skills/lesson-learned/SKILL.md +105 -0
  477. package/skills/lesson-learned/references/anti-patterns.md +55 -0
  478. package/skills/lesson-learned/references/se-principles.md +109 -0
  479. package/skills/requirements-clarity/SKILL.md +324 -0
  480. package/skills/session-handoff/SKILL.md +189 -0
  481. package/skills/session-handoff/references/handoff-template.md +139 -0
  482. package/skills/session-handoff/references/resume-checklist.md +80 -0
  483. package/skills/session-handoff/scripts/check_staleness.js +269 -0
  484. package/skills/session-handoff/scripts/create_handoff.js +299 -0
  485. package/skills/session-handoff/scripts/list_handoffs.js +113 -0
  486. package/skills/session-handoff/scripts/validate_handoff.js +241 -0
  487. package/packages/chunker/dist/treesitter-chunker.d.ts +0 -47
  488. package/packages/chunker/dist/treesitter-chunker.js +0 -8
  489. package/packages/cli/dist/commands/init.d.ts +0 -10
  490. package/packages/cli/dist/commands/init.js +0 -308
@@ -0,0 +1,299 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Smart scaffold generator for handoff documents.
4
+ *
5
+ * Creates a new handoff document with auto-detected metadata:
6
+ * - Current timestamp
7
+ * - Project path
8
+ * - Git branch (if available)
9
+ * - Recent git log
10
+ * - Modified/staged files
11
+ * - Handoff chain linking
12
+ *
13
+ * Usage:
14
+ * node create_handoff.js [task-slug]
15
+ * node create_handoff.js "implementing-auth"
16
+ * node create_handoff.js "auth-part-2" --continues-from 2024-01-15-auth.md
17
+ * node create_handoff.js # auto-generates slug from timestamp
18
+ */
19
+
20
+ const fs = require('node:fs');
21
+ const path = require('node:path');
22
+ const { execSync } = require('node:child_process');
23
+
24
+ function _die(msg) {
25
+ process.stderr.write(`${msg}\n`);
26
+ process.exit(1);
27
+ }
28
+
29
+ function runCmd(cmd, cwd) {
30
+ try {
31
+ return { ok: true, out: execSync(cmd, { cwd, timeout: 10_000, encoding: 'utf-8' }).trim() };
32
+ } catch {
33
+ return { ok: false, out: '' };
34
+ }
35
+ }
36
+
37
+ function getGitInfo(projectPath) {
38
+ const info = {
39
+ isGitRepo: false,
40
+ branch: null,
41
+ recentCommits: [],
42
+ modifiedFiles: [],
43
+ stagedFiles: [],
44
+ };
45
+
46
+ if (!runCmd('git rev-parse --git-dir', projectPath).ok) return info;
47
+ info.isGitRepo = true;
48
+
49
+ const { ok: bOk, out: branch } = runCmd('git branch --show-current', projectPath);
50
+ if (bOk && branch) info.branch = branch;
51
+
52
+ const { ok: lOk, out: log } = runCmd('git log --oneline -5 --no-decorate', projectPath);
53
+ if (lOk && log) info.recentCommits = log.split('\n');
54
+
55
+ const { ok: mOk, out: modified } = runCmd('git diff --name-only', projectPath);
56
+ if (mOk && modified) info.modifiedFiles = modified.split('\n');
57
+
58
+ const { ok: sOk, out: staged } = runCmd('git diff --name-only --cached', projectPath);
59
+ if (sOk && staged) info.stagedFiles = staged.split('\n');
60
+
61
+ return info;
62
+ }
63
+
64
+ function findPreviousHandoffs(projectPath) {
65
+ const dir = path.join(projectPath, '.handoffs');
66
+ if (!fs.existsSync(dir)) return [];
67
+
68
+ const handoffs = [];
69
+ for (const name of fs.readdirSync(dir)) {
70
+ if (!name.endsWith('.md')) continue;
71
+ const fp = path.join(dir, name);
72
+
73
+ let title = name;
74
+ try {
75
+ const content = fs.readFileSync(fp, 'utf-8');
76
+ const m = content.match(/^#\s+(?:Handoff:\s*)?(.+)$/m);
77
+ if (m) title = m[1].trim();
78
+ } catch {
79
+ /* ignore */
80
+ }
81
+
82
+ let date = null;
83
+ const dm = name.match(/^(\d{4}-\d{2}-\d{2})-(\d{6})/);
84
+ if (dm) {
85
+ try {
86
+ date = new Date(`${dm[1]}T${dm[2].slice(0, 2)}:${dm[2].slice(2, 4)}:${dm[2].slice(4, 6)}`);
87
+ } catch {
88
+ /* ignore */
89
+ }
90
+ }
91
+
92
+ handoffs.push({ filename: name, path: fp, title, date });
93
+ }
94
+
95
+ handoffs.sort((a, b) => (b.date || 0) - (a.date || 0));
96
+ return handoffs;
97
+ }
98
+
99
+ function getPreviousHandoffInfo(projectPath, continuesFrom) {
100
+ const handoffs = findPreviousHandoffs(projectPath);
101
+
102
+ if (continuesFrom) {
103
+ const found = handoffs.find((h) => h.filename.includes(continuesFrom));
104
+ return found
105
+ ? { exists: true, filename: found.filename, title: found.title }
106
+ : { exists: false, filename: continuesFrom, title: 'Not found' };
107
+ }
108
+
109
+ if (handoffs.length > 0) {
110
+ return {
111
+ exists: true,
112
+ filename: handoffs[0].filename,
113
+ title: handoffs[0].title,
114
+ suggested: true,
115
+ };
116
+ }
117
+
118
+ return { exists: false };
119
+ }
120
+
121
+ function sanitizeSlug(slug) {
122
+ return slug
123
+ .toLowerCase()
124
+ .replace(/[\s_]/g, '-')
125
+ .replace(/[^a-z0-9-]/g, '');
126
+ }
127
+
128
+ function generateHandoff(projectPath, slug, continuesFrom) {
129
+ const now = new Date();
130
+ const timestamp = now.toISOString().replace('T', ' ').slice(0, 19);
131
+ const fileTs = `${now.toISOString().slice(0, 10)}-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
132
+
133
+ if (!slug) slug = 'handoff';
134
+ slug = sanitizeSlug(slug);
135
+ const filename = `${fileTs}-${slug}.md`;
136
+
137
+ const handoffsDir = path.join(projectPath, '.handoffs');
138
+ fs.mkdirSync(handoffsDir, { recursive: true });
139
+ const filepath = path.join(handoffsDir, filename);
140
+
141
+ const git = getGitInfo(projectPath);
142
+ const prev = getPreviousHandoffInfo(projectPath, continuesFrom);
143
+
144
+ const branchLine = git.branch || '[not a git repo or detached HEAD]';
145
+
146
+ const commitsSection =
147
+ git.recentCommits.length > 0
148
+ ? git.recentCommits.map((c) => ` - ${c}`).join('\n')
149
+ : ' - [no recent commits or not a git repo]';
150
+
151
+ const allModified = [...new Set([...git.modifiedFiles, ...git.stagedFiles])];
152
+ let modifiedSection;
153
+ if (allModified.length > 0) {
154
+ modifiedSection = allModified
155
+ .slice(0, 10)
156
+ .map((f) => `| ${f} | [describe changes] | [why changed] |`)
157
+ .join('\n');
158
+ if (allModified.length > 10)
159
+ modifiedSection += `\n| ... and ${allModified.length - 10} more files | | |`;
160
+ } else {
161
+ modifiedSection = '| [no modified files detected] | | |';
162
+ }
163
+
164
+ let chainSection;
165
+ if (prev.exists) {
166
+ chainSection = `## Handoff Chain
167
+
168
+ - **Continues from**: [${prev.filename}](./${prev.filename})
169
+ - Previous title: ${prev.title || 'Unknown'}
170
+ - **Supersedes**: [list any older handoffs this replaces, or "None"]
171
+
172
+ > Review the previous handoff for full context before filling this one.`;
173
+ } else {
174
+ chainSection = `## Handoff Chain
175
+
176
+ - **Continues from**: None (fresh start)
177
+ - **Supersedes**: None
178
+
179
+ > This is the first handoff for this task.`;
180
+ }
181
+
182
+ const content = `# Handoff: [TASK_TITLE - replace this]
183
+
184
+ ## Session Metadata
185
+ - Created: ${timestamp}
186
+ - Project: ${projectPath}
187
+ - Branch: ${branchLine}
188
+ - Session duration: [estimate how long you worked]
189
+
190
+ ### Recent Commits (for context)
191
+ ${commitsSection}
192
+
193
+ ${chainSection}
194
+
195
+ ## Current State Summary
196
+
197
+ [TODO: Write one paragraph describing what was being worked on, current status, and where things left off]
198
+
199
+ ## Codebase Understanding
200
+
201
+ ### Architecture Overview
202
+
203
+ [TODO: Document key architectural insights discovered during this session]
204
+
205
+ ### Critical Files
206
+
207
+ | File | Purpose | Relevance |
208
+ |------|---------|-----------|
209
+ | [TODO: Add critical files] | | |
210
+
211
+ ### Key Patterns Discovered
212
+
213
+ [TODO: Document important patterns, conventions, or idioms found in this codebase]
214
+
215
+ ## Work Completed
216
+
217
+ ### Tasks Finished
218
+
219
+ - [ ] [TODO: List completed tasks]
220
+
221
+ ### Files Modified
222
+
223
+ | File | Changes | Rationale |
224
+ |------|---------|-----------|
225
+ ${modifiedSection}
226
+
227
+ ### Decisions Made
228
+
229
+ | Decision | Options Considered | Rationale |
230
+ |----------|-------------------|-----------|
231
+ | [TODO: Document key decisions] | | |
232
+
233
+ ## Pending Work
234
+
235
+ ### Immediate Next Steps
236
+
237
+ 1. [TODO: Most critical next action]
238
+ 2. [TODO: Second priority]
239
+ 3. [TODO: Third priority]
240
+
241
+ ### Blockers/Open Questions
242
+
243
+ - [ ] [TODO: List blockers or open questions]
244
+
245
+ ### Deferred Items
246
+
247
+ - [TODO: Items deferred and why]
248
+
249
+ ## Context for Resuming Agent
250
+
251
+ ### Important Context
252
+
253
+ [TODO: Critical information the next agent MUST know]
254
+
255
+ ### Assumptions Made
256
+
257
+ [TODO: List assumptions that might not be obvious]
258
+
259
+ ### Potential Gotchas
260
+
261
+ [TODO: Things that could trip up the next agent]
262
+
263
+ ## Environment State
264
+
265
+ [TODO: Required env vars, running processes, DB state]
266
+
267
+ ## Related Resources
268
+
269
+ [TODO: Links to docs, PRs, issues, Slack threads]
270
+ `;
271
+
272
+ fs.writeFileSync(filepath, content, 'utf-8');
273
+ return { filepath, filename };
274
+ }
275
+
276
+ // --- Main ---
277
+ const args = process.argv.slice(2);
278
+ if (args.includes('--help') || args.includes('-h')) {
279
+ console.log('Usage: node create_handoff.js [task-slug] [--continues-from <previous>]');
280
+ console.log(' node create_handoff.js "implementing-auth"');
281
+ console.log(' node create_handoff.js "auth-part-2" --continues-from 2024-01-15-auth.md');
282
+ process.exit(0);
283
+ }
284
+
285
+ let slug = null;
286
+ let continuesFrom = null;
287
+ for (let i = 0; i < args.length; i++) {
288
+ if (args[i] === '--continues-from' && i + 1 < args.length) {
289
+ continuesFrom = args[++i];
290
+ } else if (!args[i].startsWith('-')) {
291
+ slug = args[i];
292
+ }
293
+ }
294
+
295
+ const cwd = process.cwd();
296
+ const { filepath } = generateHandoff(cwd, slug, continuesFrom);
297
+ console.log(`Created handoff: ${filepath}`);
298
+ console.log(`\nNext: Open the file and fill in all [TODO: ...] sections.`);
299
+ console.log(`Then validate: node scripts/validate_handoff.js ${filepath}`);
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * List available handoff documents in the current project.
4
+ *
5
+ * Searches for handoff documents in .handoffs/ and displays:
6
+ * - Filename with date
7
+ * - Title extracted from document
8
+ * - Status (complete / in progress / needs work)
9
+ *
10
+ * Usage:
11
+ * node list_handoffs.js # List handoffs in current project
12
+ * node list_handoffs.js /path # List handoffs in specified path
13
+ */
14
+
15
+ const fs = require('node:fs');
16
+ const path = require('node:path');
17
+
18
+ function extractTitle(filepath) {
19
+ try {
20
+ const content = fs.readFileSync(filepath, 'utf-8');
21
+ const m = content.match(/^#\s+(?:Handoff:\s*)?(.+)$/m);
22
+ if (m) {
23
+ const title = m[1].trim();
24
+ if (title.startsWith('[') && title.endsWith(']')) return '[Untitled - needs completion]';
25
+ return title.length > 50 ? `${title.slice(0, 50)}...` : title;
26
+ }
27
+ } catch {
28
+ /* ignore */
29
+ }
30
+ return '[Unable to read title]';
31
+ }
32
+
33
+ function checkCompletion(filepath) {
34
+ try {
35
+ const content = fs.readFileSync(filepath, 'utf-8');
36
+ const count = (content.match(/\[TODO:/g) || []).length;
37
+ if (count === 0) return 'Complete';
38
+ if (count <= 3) return `In Progress (${count} TODOs)`;
39
+ return `Needs Work (${count} TODOs)`;
40
+ } catch {
41
+ return 'Unknown';
42
+ }
43
+ }
44
+
45
+ function parseDateFromFilename(filename) {
46
+ const m = filename.match(/^(\d{4}-\d{2}-\d{2})-(\d{6})/);
47
+ if (m) {
48
+ try {
49
+ return new Date(`${m[1]}T${m[2].slice(0, 2)}:${m[2].slice(2, 4)}:${m[2].slice(4, 6)}`);
50
+ } catch {
51
+ /* ignore */
52
+ }
53
+ }
54
+ return null;
55
+ }
56
+
57
+ function listHandoffs(projectPath) {
58
+ const dir = path.join(projectPath, '.handoffs');
59
+ if (!fs.existsSync(dir)) return [];
60
+
61
+ const handoffs = [];
62
+ for (const name of fs.readdirSync(dir)) {
63
+ if (!name.endsWith('.md')) continue;
64
+ const fp = path.join(dir, name);
65
+ const stat = fs.statSync(fp);
66
+
67
+ handoffs.push({
68
+ path: fp,
69
+ filename: name,
70
+ title: extractTitle(fp),
71
+ status: checkCompletion(fp),
72
+ date: parseDateFromFilename(name),
73
+ size: stat.size,
74
+ });
75
+ }
76
+
77
+ handoffs.sort((a, b) => (b.date || 0) - (a.date || 0));
78
+ return handoffs;
79
+ }
80
+
81
+ function formatDate(dt) {
82
+ if (!dt) return 'Unknown date';
83
+ return dt.toISOString().replace('T', ' ').slice(0, 16);
84
+ }
85
+
86
+ // --- Main ---
87
+ const args = process.argv.slice(2);
88
+ if (args.includes('--help') || args.includes('-h')) {
89
+ console.log('Usage: node list_handoffs.js [project-path]');
90
+ process.exit(0);
91
+ }
92
+
93
+ const projectPath = args[0] || process.cwd();
94
+ const handoffs = listHandoffs(projectPath);
95
+
96
+ if (handoffs.length === 0) {
97
+ console.log('No handoff documents found.');
98
+ console.log(`Looked in: ${path.join(projectPath, '.handoffs')}`);
99
+ console.log('\nCreate one with: node scripts/create_handoff.js [task-slug]');
100
+ process.exit(0);
101
+ }
102
+
103
+ console.log(`\nFound ${handoffs.length} handoff(s) in ${projectPath}:\n`);
104
+ console.log(`${'Date'.padEnd(18)} ${'Status'.padEnd(25)} Title`);
105
+ console.log(`${'-'.repeat(18)} ${'-'.repeat(25)} ${'-'.repeat(40)}`);
106
+
107
+ for (const h of handoffs) {
108
+ console.log(`${formatDate(h.date).padEnd(18)} ${h.status.padEnd(25)} ${h.title}`);
109
+ }
110
+
111
+ if (args.includes('--json')) {
112
+ console.log(`\n${JSON.stringify(handoffs, null, 2)}`);
113
+ }
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Validate a handoff document for completeness and quality.
4
+ *
5
+ * Checks:
6
+ * - No TODO placeholders remaining
7
+ * - Required sections present and populated
8
+ * - No potential secrets detected
9
+ * - Referenced files exist
10
+ * - Quality scoring (0-100)
11
+ *
12
+ * Usage:
13
+ * node validate_handoff.js <handoff-file>
14
+ * node validate_handoff.js .handoffs/2024-01-15-143022-auth.md
15
+ */
16
+
17
+ const fs = require('node:fs');
18
+ const path = require('node:path');
19
+
20
+ // Secret detection patterns
21
+ const SECRET_PATTERNS = [
22
+ [/["']?[a-zA-Z_]*api[_-]?key["']?\s*[:=]\s*["'][^"']{10,}["']/gi, 'API key'],
23
+ [/["']?[a-zA-Z_]*password["']?\s*[:=]\s*["'][^"']+["']/gi, 'Password'],
24
+ [/["']?[a-zA-Z_]*secret["']?\s*[:=]\s*["'][^"']{10,}["']/gi, 'Secret'],
25
+ [/["']?[a-zA-Z_]*token["']?\s*[:=]\s*["'][^"']{20,}["']/gi, 'Token'],
26
+ [/["']?[a-zA-Z_]*private[_-]?key["']?\s*[:=]/gi, 'Private key'],
27
+ [/-----BEGIN [A-Z]+ PRIVATE KEY-----/g, 'PEM private key'],
28
+ [/mongodb(\+srv)?:\/\/[^/\s]+:[^@\s]+@/gi, 'MongoDB connection string with password'],
29
+ [/postgres:\/\/[^/\s]+:[^@\s]+@/gi, 'PostgreSQL connection string with password'],
30
+ [/mysql:\/\/[^/\s]+:[^@\s]+@/gi, 'MySQL connection string with password'],
31
+ [/Bearer\s+[a-zA-Z0-9_\-.]+/g, 'Bearer token'],
32
+ [/ghp_[a-zA-Z0-9]{36}/g, 'GitHub personal access token'],
33
+ [/sk-[a-zA-Z0-9]{48}/g, 'OpenAI API key'],
34
+ [/xox[baprs]-[a-zA-Z0-9-]+/g, 'Slack token'],
35
+ ];
36
+
37
+ const REQUIRED_SECTIONS = ['Current State Summary', 'Important Context', 'Immediate Next Steps'];
38
+ const RECOMMENDED_SECTIONS = [
39
+ 'Architecture Overview',
40
+ 'Critical Files',
41
+ 'Files Modified',
42
+ 'Decisions Made',
43
+ 'Assumptions Made',
44
+ 'Potential Gotchas',
45
+ ];
46
+
47
+ function checkTodos(content) {
48
+ const todos = content.match(/\[TODO:[^\]]*\]/g) || [];
49
+ return { clear: todos.length === 0, todos };
50
+ }
51
+
52
+ function checkRequiredSections(content) {
53
+ const missing = [];
54
+ for (const section of REQUIRED_SECTIONS) {
55
+ const pattern = new RegExp(
56
+ `(?:^|\\n)##?\\s*${section.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`,
57
+ 'i',
58
+ );
59
+ const match = pattern.exec(content);
60
+ if (!match) {
61
+ missing.push(`${section} (missing)`);
62
+ } else {
63
+ const start = match.index + match[0].length;
64
+ const nextSection = content.slice(start).search(/\n##?\s+/);
65
+ const end = nextSection >= 0 ? start + nextSection : content.length;
66
+ const sectionContent = content.slice(start, end).trim();
67
+ if (sectionContent.length < 50 || sectionContent.includes('[TODO')) {
68
+ missing.push(`${section} (incomplete)`);
69
+ }
70
+ }
71
+ }
72
+ return { complete: missing.length === 0, missing };
73
+ }
74
+
75
+ function checkRecommendedSections(content) {
76
+ const missing = [];
77
+ for (const section of RECOMMENDED_SECTIONS) {
78
+ const pattern = new RegExp(
79
+ `(?:^|\\n)##?\\s*${section.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`,
80
+ 'i',
81
+ );
82
+ if (!pattern.test(content)) missing.push(section);
83
+ }
84
+ return missing;
85
+ }
86
+
87
+ function scanForSecrets(content) {
88
+ const findings = [];
89
+ for (const [pattern, description] of SECRET_PATTERNS) {
90
+ const matches = content.match(pattern);
91
+ if (matches) findings.push({ description, count: matches.length });
92
+ }
93
+ return findings;
94
+ }
95
+
96
+ function checkFileReferences(content, basePath) {
97
+ const patterns = [
98
+ /\|\s*([a-zA-Z0-9_\-./]+\.[a-zA-Z]+)\s*\|/g,
99
+ /`([a-zA-Z0-9_\-./]+\.[a-zA-Z]+(?::\d+)?)`/g,
100
+ /(?:^|\s)([a-zA-Z0-9_\-./]+\.[a-zA-Z]+:\d+)/gm,
101
+ ];
102
+
103
+ const foundFiles = new Set();
104
+ for (const pattern of patterns) {
105
+ for (const m of content.matchAll(pattern)) {
106
+ const filepath = m[1].split(':')[0];
107
+ if (filepath && !filepath.startsWith('http') && filepath.includes('/')) {
108
+ foundFiles.add(filepath);
109
+ }
110
+ }
111
+ }
112
+
113
+ const existing = [];
114
+ const missing = [];
115
+ for (const f of foundFiles) {
116
+ if (fs.existsSync(path.join(basePath, f))) existing.push(f);
117
+ else missing.push(f);
118
+ }
119
+ return { existing, missing };
120
+ }
121
+
122
+ function calculateScore(todosClear, reqComplete, missingReq, missingRec, secrets, filesMissing) {
123
+ let score = 100;
124
+
125
+ if (!todosClear) score -= 30;
126
+ if (!reqComplete) score -= 10 * missingReq.length;
127
+ if (secrets.length > 0) score -= 20;
128
+ if (filesMissing.length > 0) score -= 5 * Math.min(filesMissing.length, 4);
129
+ score -= 2 * missingRec.length;
130
+
131
+ score = Math.max(0, score);
132
+
133
+ let rating;
134
+ if (score >= 90) rating = 'Excellent - Ready for handoff';
135
+ else if (score >= 70) rating = 'Good - Minor improvements suggested';
136
+ else if (score >= 50) rating = 'Fair - Needs attention before handoff';
137
+ else rating = 'Poor - Significant work needed';
138
+
139
+ return { score, rating };
140
+ }
141
+
142
+ function validateHandoff(filepath) {
143
+ if (!fs.existsSync(filepath)) return { error: `File not found: ${filepath}` };
144
+
145
+ const content = fs.readFileSync(filepath, 'utf-8');
146
+ const basePath = path.resolve(path.dirname(filepath), '..'); // Up from .handoffs/
147
+
148
+ const { clear: todosClear, todos } = checkTodos(content);
149
+ const { complete: reqComplete, missing: missingReq } = checkRequiredSections(content);
150
+ const missingRec = checkRecommendedSections(content);
151
+ const secrets = scanForSecrets(content);
152
+ const { existing: existingFiles, missing: missingFiles } = checkFileReferences(content, basePath);
153
+
154
+ const { score, rating } = calculateScore(
155
+ todosClear,
156
+ reqComplete,
157
+ missingReq,
158
+ missingRec,
159
+ secrets,
160
+ missingFiles,
161
+ );
162
+
163
+ return {
164
+ filepath,
165
+ score,
166
+ rating,
167
+ todosClear,
168
+ remainingTodos: todos.slice(0, 5),
169
+ todoCount: todos.length,
170
+ requiredComplete: reqComplete,
171
+ missingRequired: missingReq,
172
+ missingRecommended: missingRec,
173
+ secretsFound: secrets,
174
+ filesVerified: existingFiles.length,
175
+ filesMissing: missingFiles.slice(0, 5),
176
+ };
177
+ }
178
+
179
+ function printReport(result) {
180
+ if (result.error) {
181
+ console.log(`Error: ${result.error}`);
182
+ return;
183
+ }
184
+
185
+ console.log(`\n${'='.repeat(60)}`);
186
+ console.log('Handoff Validation Report');
187
+ console.log('='.repeat(60));
188
+ console.log(`File: ${result.filepath}`);
189
+ console.log(`\nQuality Score: ${result.score}/100 - ${result.rating}`);
190
+ console.log('='.repeat(60));
191
+
192
+ if (result.todosClear) {
193
+ console.log('\n[PASS] No TODO placeholders remaining');
194
+ } else {
195
+ console.log(`\n[FAIL] ${result.todoCount} TODO placeholders found:`);
196
+ for (const t of result.remainingTodos) console.log(` - ${t.slice(0, 50)}...`);
197
+ }
198
+
199
+ if (result.requiredComplete) {
200
+ console.log('\n[PASS] All required sections complete');
201
+ } else {
202
+ console.log('\n[FAIL] Missing/incomplete required sections:');
203
+ for (const s of result.missingRequired) console.log(` - ${s}`);
204
+ }
205
+
206
+ if (result.secretsFound.length === 0) {
207
+ console.log('\n[PASS] No potential secrets detected');
208
+ } else {
209
+ console.log('\n[WARN] Potential secrets detected:');
210
+ for (const s of result.secretsFound)
211
+ console.log(` - ${s.description} (${s.count} match(es))`);
212
+ }
213
+
214
+ console.log(
215
+ `\n[INFO] File references: ${result.filesVerified} verified, ${result.filesMissing.length} missing`,
216
+ );
217
+ if (result.filesMissing.length > 0) {
218
+ for (const f of result.filesMissing) console.log(` - ${f}`);
219
+ }
220
+
221
+ if (result.missingRecommended.length > 0) {
222
+ console.log('\n[INFO] Missing recommended sections:');
223
+ for (const s of result.missingRecommended) console.log(` - ${s}`);
224
+ }
225
+ }
226
+
227
+ // --- Main ---
228
+ const args = process.argv.slice(2);
229
+ if (args.includes('--help') || args.includes('-h') || args.length === 0) {
230
+ console.log('Usage: node validate_handoff.js <handoff-file>');
231
+ console.log(' node validate_handoff.js .handoffs/2024-01-15-143022-auth.md');
232
+ process.exit(args.length === 0 ? 1 : 0);
233
+ }
234
+
235
+ if (args.includes('--json')) {
236
+ const result = validateHandoff(args.find((a) => !a.startsWith('-')));
237
+ console.log(JSON.stringify(result, null, 2));
238
+ } else {
239
+ const result = validateHandoff(args[0]);
240
+ printReport(result);
241
+ }
@@ -1,47 +0,0 @@
1
- /**
2
- * Tree-sitter AST-based code chunker.
3
- *
4
- * Uses native tree-sitter bindings for precise declaration boundary detection.
5
- * Falls back gracefully to regex-based CodeChunker if tree-sitter or grammars
6
- * are not installed (they are optional dependencies).
7
- */
8
- import type { ChunkMetadata, RawChunk } from '@kb/core';
9
- import type { IChunker } from './chunker.interface.js';
10
- /**
11
- * Singleton runtime that loads tree-sitter parser + language grammars once.
12
- * Call `TreeSitterRuntime.initialize()` at startup; if it returns null,
13
- * tree-sitter is not available and the factory will fall back to CodeChunker.
14
- */
15
- export declare class TreeSitterRuntime {
16
- private static instance;
17
- private parser;
18
- private languages;
19
- static initialize(): Promise<TreeSitterRuntime | null>;
20
- static get(): TreeSitterRuntime | null;
21
- private init;
22
- /** Parse source code with the grammar for the given file extension. */
23
- parse(content: string, ext: string): any | null;
24
- /** Check if a grammar is loaded for the given file extension. */
25
- hasLanguage(ext: string): boolean;
26
- }
27
- /**
28
- * Initialize the tree-sitter runtime. Call once at startup.
29
- * Returns true if tree-sitter is available, false otherwise.
30
- */
31
- export declare function initializeTreeSitter(): Promise<boolean>;
32
- /**
33
- * AST-based code chunker that uses tree-sitter for precise declaration
34
- * boundary detection. Produces cleaner chunks than the regex-based CodeChunker.
35
- */
36
- export declare class TreeSitterChunker implements IChunker {
37
- private readonly maxChunkSize;
38
- private readonly runtime;
39
- private readonly regexFallback;
40
- constructor(runtime: TreeSitterRuntime, options?: {
41
- maxChunkSize?: number;
42
- });
43
- chunk(content: string, metadata: ChunkMetadata): RawChunk[];
44
- private chunkFromAst;
45
- private splitByLines;
46
- }
47
- //# sourceMappingURL=treesitter-chunker.d.ts.map