homegraph 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +305 -268
  3. package/dist/bin/command-supervision.d.ts.map +1 -1
  4. package/dist/bin/command-supervision.js +7 -4
  5. package/dist/bin/command-supervision.js.map +1 -1
  6. package/dist/bin/homegraph.js +304 -81
  7. package/dist/bin/homegraph.js.map +1 -1
  8. package/dist/context/index.d.ts.map +1 -1
  9. package/dist/context/index.js +32 -11
  10. package/dist/context/index.js.map +1 -1
  11. package/dist/db/index.d.ts +143 -1
  12. package/dist/db/index.d.ts.map +1 -1
  13. package/dist/db/index.js +305 -28
  14. package/dist/db/index.js.map +1 -1
  15. package/dist/db/migrations.js +37 -37
  16. package/dist/db/queries.d.ts +43 -4
  17. package/dist/db/queries.d.ts.map +1 -1
  18. package/dist/db/queries.js +294 -170
  19. package/dist/db/queries.js.map +1 -1
  20. package/dist/db/schema.sql +203 -203
  21. package/dist/db/sqlite-adapter.d.ts +24 -17
  22. package/dist/db/sqlite-adapter.d.ts.map +1 -1
  23. package/dist/db/sqlite-adapter.js +292 -36
  24. package/dist/db/sqlite-adapter.js.map +1 -1
  25. package/dist/db/wal-valve.d.ts +15 -2
  26. package/dist/db/wal-valve.d.ts.map +1 -1
  27. package/dist/db/wal-valve.js +88 -6
  28. package/dist/db/wal-valve.js.map +1 -1
  29. package/dist/directory.js +5 -5
  30. package/dist/extraction/arkts-batch-worker.js +3 -2
  31. package/dist/extraction/arkts-batch-worker.js.map +1 -1
  32. package/dist/extraction/default-ignore.d.ts +39 -0
  33. package/dist/extraction/default-ignore.d.ts.map +1 -0
  34. package/dist/extraction/default-ignore.js +221 -0
  35. package/dist/extraction/default-ignore.js.map +1 -0
  36. package/dist/extraction/index.d.ts +9 -10
  37. package/dist/extraction/index.d.ts.map +1 -1
  38. package/dist/extraction/index.js +227 -323
  39. package/dist/extraction/index.js.map +1 -1
  40. package/dist/extraction/languages/arkts-viewtree.d.ts +2 -4
  41. package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -1
  42. package/dist/extraction/languages/arkts-viewtree.js +6 -21
  43. package/dist/extraction/languages/arkts-viewtree.js.map +1 -1
  44. package/dist/extraction/languages/arkts.d.ts +100 -6
  45. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  46. package/dist/extraction/languages/arkts.js +1777 -173
  47. package/dist/extraction/languages/arkts.js.map +1 -1
  48. package/dist/extraction/store-worker.d.ts +20 -0
  49. package/dist/extraction/store-worker.d.ts.map +1 -0
  50. package/dist/extraction/store-worker.js +102 -0
  51. package/dist/extraction/store-worker.js.map +1 -0
  52. package/dist/extraction/store-writer.d.ts +48 -0
  53. package/dist/extraction/store-writer.d.ts.map +1 -0
  54. package/dist/extraction/store-writer.js +167 -0
  55. package/dist/extraction/store-writer.js.map +1 -0
  56. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  57. package/dist/extraction/tree-sitter.js +47 -0
  58. package/dist/extraction/tree-sitter.js.map +1 -1
  59. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  60. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  61. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  62. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  63. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  64. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  65. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  66. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  67. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  68. package/dist/extraction/wasm-runtime-flags.d.ts +14 -4
  69. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
  70. package/dist/extraction/wasm-runtime-flags.js +55 -7
  71. package/dist/extraction/wasm-runtime-flags.js.map +1 -1
  72. package/dist/index.d.ts +16 -5
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +135 -97
  75. package/dist/index.js.map +1 -1
  76. package/dist/installer/instructions-template.js +9 -9
  77. package/dist/mcp/liveness-watchdog.d.ts +18 -0
  78. package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  79. package/dist/mcp/liveness-watchdog.js +185 -73
  80. package/dist/mcp/liveness-watchdog.js.map +1 -1
  81. package/dist/mcp/query-worker.d.ts +2 -2
  82. package/dist/mcp/query-worker.js +2 -2
  83. package/dist/mcp/server-instructions.js +47 -47
  84. package/dist/mcp/tools.d.ts.map +1 -1
  85. package/dist/mcp/tools.js +42 -26
  86. package/dist/mcp/tools.js.map +1 -1
  87. package/dist/reasoning/reasoner.js +32 -32
  88. package/dist/resolution/callback-synthesizer.d.ts +52 -16
  89. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  90. package/dist/resolution/callback-synthesizer.js +234 -180
  91. package/dist/resolution/callback-synthesizer.js.map +1 -1
  92. package/dist/resolution/cooperative-yield.d.ts +10 -2
  93. package/dist/resolution/cooperative-yield.d.ts.map +1 -1
  94. package/dist/resolution/cooperative-yield.js +6 -4
  95. package/dist/resolution/cooperative-yield.js.map +1 -1
  96. package/dist/resolution/frameworks/go.d.ts.map +1 -1
  97. package/dist/resolution/frameworks/go.js +29 -6
  98. package/dist/resolution/frameworks/go.js.map +1 -1
  99. package/dist/resolution/import-resolver.d.ts +2 -3
  100. package/dist/resolution/import-resolver.d.ts.map +1 -1
  101. package/dist/resolution/import-resolver.js +166 -7
  102. package/dist/resolution/import-resolver.js.map +1 -1
  103. package/dist/resolution/index.d.ts +87 -2
  104. package/dist/resolution/index.d.ts.map +1 -1
  105. package/dist/resolution/index.js +739 -131
  106. package/dist/resolution/index.js.map +1 -1
  107. package/dist/resolution/memory-budget.d.ts +48 -0
  108. package/dist/resolution/memory-budget.d.ts.map +1 -0
  109. package/dist/resolution/memory-budget.js +162 -0
  110. package/dist/resolution/memory-budget.js.map +1 -0
  111. package/dist/resolution/name-matcher.d.ts +12 -1
  112. package/dist/resolution/name-matcher.d.ts.map +1 -1
  113. package/dist/resolution/name-matcher.js +439 -97
  114. package/dist/resolution/name-matcher.js.map +1 -1
  115. package/dist/resolution/resolver-pool.d.ts +106 -0
  116. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  117. package/dist/resolution/resolver-pool.js +344 -0
  118. package/dist/resolution/resolver-pool.js.map +1 -0
  119. package/dist/resolution/resolver-worker.d.ts +17 -0
  120. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  121. package/dist/resolution/resolver-worker.js +141 -0
  122. package/dist/resolution/resolver-worker.js.map +1 -0
  123. package/dist/resolution/types.d.ts +3 -0
  124. package/dist/resolution/types.d.ts.map +1 -1
  125. package/dist/spec/build/diff-parser.d.ts +55 -0
  126. package/dist/spec/build/diff-parser.d.ts.map +1 -0
  127. package/dist/spec/build/diff-parser.js +205 -0
  128. package/dist/spec/build/diff-parser.js.map +1 -0
  129. package/dist/spec/build/pipeline.d.ts +54 -0
  130. package/dist/spec/build/pipeline.d.ts.map +1 -0
  131. package/dist/spec/build/pipeline.js +170 -0
  132. package/dist/spec/build/pipeline.js.map +1 -0
  133. package/dist/spec/build/scan.d.ts +48 -0
  134. package/dist/spec/build/scan.d.ts.map +1 -0
  135. package/dist/spec/build/scan.js +89 -0
  136. package/dist/spec/build/scan.js.map +1 -0
  137. package/dist/spec/build/scope-resolver.d.ts +50 -0
  138. package/dist/spec/build/scope-resolver.d.ts.map +1 -0
  139. package/dist/spec/build/scope-resolver.js +105 -0
  140. package/dist/spec/build/scope-resolver.js.map +1 -0
  141. package/dist/spec/build/spec-extractor.d.ts +74 -0
  142. package/dist/spec/build/spec-extractor.d.ts.map +1 -0
  143. package/dist/spec/build/spec-extractor.js +344 -0
  144. package/dist/spec/build/spec-extractor.js.map +1 -0
  145. package/dist/spec/config.d.ts +35 -1
  146. package/dist/spec/config.d.ts.map +1 -1
  147. package/dist/spec/config.js +30 -5
  148. package/dist/spec/config.js.map +1 -1
  149. package/dist/spec/db/commit-node.js +4 -4
  150. package/dist/spec/db/fragment-node.js +10 -10
  151. package/dist/spec/db/fts.d.ts.map +1 -1
  152. package/dist/spec/db/fts.js +27 -58
  153. package/dist/spec/db/fts.js.map +1 -1
  154. package/dist/spec/db/index.d.ts +5 -3
  155. package/dist/spec/db/index.d.ts.map +1 -1
  156. package/dist/spec/db/index.js +16 -1
  157. package/dist/spec/db/index.js.map +1 -1
  158. package/dist/spec/db/persist.d.ts +45 -0
  159. package/dist/spec/db/persist.d.ts.map +1 -0
  160. package/dist/spec/db/persist.js +66 -0
  161. package/dist/spec/db/persist.js.map +1 -0
  162. package/dist/spec/db/relations.d.ts +80 -1
  163. package/dist/spec/db/relations.d.ts.map +1 -1
  164. package/dist/spec/db/relations.js +218 -47
  165. package/dist/spec/db/relations.js.map +1 -1
  166. package/dist/spec/db/schema.d.ts +4 -0
  167. package/dist/spec/db/schema.d.ts.map +1 -1
  168. package/dist/spec/db/schema.js +10 -6
  169. package/dist/spec/db/schema.js.map +1 -1
  170. package/dist/spec/db/schema.sql +121 -117
  171. package/dist/spec/db/spec-node.d.ts +5 -0
  172. package/dist/spec/db/spec-node.d.ts.map +1 -1
  173. package/dist/spec/db/spec-node.js +15 -9
  174. package/dist/spec/db/spec-node.js.map +1 -1
  175. package/dist/spec/db/sql-utils.d.ts +11 -0
  176. package/dist/spec/db/sql-utils.d.ts.map +1 -0
  177. package/dist/spec/db/sql-utils.js +19 -0
  178. package/dist/spec/db/sql-utils.js.map +1 -0
  179. package/dist/spec/evolve/cluster-context.d.ts +30 -0
  180. package/dist/spec/evolve/cluster-context.d.ts.map +1 -0
  181. package/dist/spec/evolve/cluster-context.js +78 -0
  182. package/dist/spec/evolve/cluster-context.js.map +1 -0
  183. package/dist/spec/evolve/commit-spec-analyzer.d.ts +51 -0
  184. package/dist/spec/evolve/commit-spec-analyzer.d.ts.map +1 -0
  185. package/dist/spec/evolve/commit-spec-analyzer.js +88 -0
  186. package/dist/spec/evolve/commit-spec-analyzer.js.map +1 -0
  187. package/dist/spec/evolve/commit-spec-persister.d.ts +53 -0
  188. package/dist/spec/evolve/commit-spec-persister.d.ts.map +1 -0
  189. package/dist/spec/evolve/commit-spec-persister.js +93 -0
  190. package/dist/spec/evolve/commit-spec-persister.js.map +1 -0
  191. package/dist/spec/evolve/impact-locator.d.ts +23 -7
  192. package/dist/spec/evolve/impact-locator.d.ts.map +1 -1
  193. package/dist/spec/evolve/impact-locator.js +58 -14
  194. package/dist/spec/evolve/impact-locator.js.map +1 -1
  195. package/dist/spec/evolve/pipeline.d.ts +62 -25
  196. package/dist/spec/evolve/pipeline.d.ts.map +1 -1
  197. package/dist/spec/evolve/pipeline.js +436 -457
  198. package/dist/spec/evolve/pipeline.js.map +1 -1
  199. package/dist/spec/evolve/spec-rewriter.d.ts +13 -13
  200. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -1
  201. package/dist/spec/evolve/spec-rewriter.js +45 -45
  202. package/dist/spec/evolve/spec-rewriter.js.map +1 -1
  203. package/dist/spec/git/commits.d.ts +85 -0
  204. package/dist/spec/git/commits.d.ts.map +1 -0
  205. package/dist/spec/git/commits.js +218 -0
  206. package/dist/spec/git/commits.js.map +1 -0
  207. package/dist/spec/git/exec.d.ts +13 -0
  208. package/dist/spec/git/exec.d.ts.map +1 -0
  209. package/dist/spec/git/exec.js +19 -0
  210. package/dist/spec/git/exec.js.map +1 -0
  211. package/dist/spec/git/index.d.ts +9 -0
  212. package/dist/spec/git/index.d.ts.map +1 -0
  213. package/dist/spec/git/index.js +22 -0
  214. package/dist/spec/git/index.js.map +1 -0
  215. package/dist/spec/graph/index.d.ts +8 -0
  216. package/dist/spec/graph/index.d.ts.map +1 -0
  217. package/dist/spec/graph/index.js +17 -0
  218. package/dist/spec/graph/index.js.map +1 -0
  219. package/dist/spec/graph/queries.d.ts +6 -35
  220. package/dist/spec/graph/queries.d.ts.map +1 -1
  221. package/dist/spec/graph/queries.js +71 -248
  222. package/dist/spec/graph/queries.js.map +1 -1
  223. package/dist/spec/llm/agent-client.d.ts +59 -0
  224. package/dist/spec/llm/agent-client.d.ts.map +1 -0
  225. package/dist/spec/llm/agent-client.js +213 -0
  226. package/dist/spec/llm/agent-client.js.map +1 -0
  227. package/dist/spec/llm/agents/claude-code.d.ts +32 -0
  228. package/dist/spec/llm/agents/claude-code.d.ts.map +1 -0
  229. package/dist/spec/llm/agents/claude-code.js +125 -0
  230. package/dist/spec/llm/agents/claude-code.js.map +1 -0
  231. package/dist/spec/llm/agents/codex.d.ts +32 -0
  232. package/dist/spec/llm/agents/codex.d.ts.map +1 -0
  233. package/dist/spec/llm/agents/codex.js +145 -0
  234. package/dist/spec/llm/agents/codex.js.map +1 -0
  235. package/dist/spec/llm/agents/detect-utils.d.ts +28 -0
  236. package/dist/spec/llm/agents/detect-utils.d.ts.map +1 -0
  237. package/dist/spec/llm/agents/detect-utils.js +91 -0
  238. package/dist/spec/llm/agents/detect-utils.js.map +1 -0
  239. package/dist/spec/llm/agents/deveco-code.d.ts +33 -0
  240. package/dist/spec/llm/agents/deveco-code.d.ts.map +1 -0
  241. package/dist/spec/llm/agents/deveco-code.js +165 -0
  242. package/dist/spec/llm/agents/deveco-code.js.map +1 -0
  243. package/dist/spec/llm/agents/index.d.ts +31 -0
  244. package/dist/spec/llm/agents/index.d.ts.map +1 -0
  245. package/dist/spec/llm/agents/index.js +65 -0
  246. package/dist/spec/llm/agents/index.js.map +1 -0
  247. package/dist/spec/llm/agents/types.d.ts +76 -0
  248. package/dist/spec/llm/agents/types.d.ts.map +1 -0
  249. package/dist/spec/llm/agents/types.js +15 -0
  250. package/dist/spec/llm/agents/types.js.map +1 -0
  251. package/dist/spec/llm/client.d.ts +31 -11
  252. package/dist/spec/llm/client.d.ts.map +1 -1
  253. package/dist/spec/llm/client.js +143 -81
  254. package/dist/spec/llm/client.js.map +1 -1
  255. package/dist/spec/llm/factory.d.ts +41 -0
  256. package/dist/spec/llm/factory.d.ts.map +1 -0
  257. package/dist/spec/llm/factory.js +80 -0
  258. package/dist/spec/llm/factory.js.map +1 -0
  259. package/dist/spec/llm/prompts.d.ts +24 -8
  260. package/dist/spec/llm/prompts.d.ts.map +1 -1
  261. package/dist/spec/llm/prompts.js +112 -62
  262. package/dist/spec/llm/prompts.js.map +1 -1
  263. package/dist/spec/llm/retry.d.ts +53 -0
  264. package/dist/spec/llm/retry.d.ts.map +1 -0
  265. package/dist/spec/llm/retry.js +153 -0
  266. package/dist/spec/llm/retry.js.map +1 -0
  267. package/dist/spec/mine/clustering/features.d.ts +38 -0
  268. package/dist/spec/mine/clustering/features.d.ts.map +1 -0
  269. package/dist/spec/mine/clustering/features.js +108 -0
  270. package/dist/spec/mine/clustering/features.js.map +1 -0
  271. package/dist/spec/mine/clustering/index.d.ts +62 -0
  272. package/dist/spec/mine/clustering/index.d.ts.map +1 -0
  273. package/dist/spec/mine/clustering/index.js +259 -0
  274. package/dist/spec/mine/clustering/index.js.map +1 -0
  275. package/dist/spec/mine/clustering/leiden.d.ts +61 -0
  276. package/dist/spec/mine/clustering/leiden.d.ts.map +1 -0
  277. package/dist/spec/mine/clustering/leiden.js +489 -0
  278. package/dist/spec/mine/clustering/leiden.js.map +1 -0
  279. package/dist/spec/mine/clustering/text-similarity.d.ts +22 -0
  280. package/dist/spec/mine/clustering/text-similarity.d.ts.map +1 -0
  281. package/dist/spec/mine/clustering/text-similarity.js +98 -0
  282. package/dist/spec/mine/clustering/text-similarity.js.map +1 -0
  283. package/dist/spec/mine/generator.d.ts +54 -0
  284. package/dist/spec/mine/generator.d.ts.map +1 -0
  285. package/dist/spec/mine/generator.js +267 -0
  286. package/dist/spec/mine/generator.js.map +1 -0
  287. package/dist/spec/mine/persist.d.ts +37 -0
  288. package/dist/spec/mine/persist.d.ts.map +1 -0
  289. package/dist/spec/mine/persist.js +170 -0
  290. package/dist/spec/mine/persist.js.map +1 -0
  291. package/dist/spec/mine/pipeline.d.ts +41 -0
  292. package/dist/spec/mine/pipeline.d.ts.map +1 -0
  293. package/dist/spec/mine/pipeline.js +236 -0
  294. package/dist/spec/mine/pipeline.js.map +1 -0
  295. package/dist/spec/mine/scanner.d.ts +59 -0
  296. package/dist/spec/mine/scanner.d.ts.map +1 -0
  297. package/dist/spec/mine/scanner.js +383 -0
  298. package/dist/spec/mine/scanner.js.map +1 -0
  299. package/dist/spec/types.d.ts +32 -0
  300. package/dist/spec/types.d.ts.map +1 -1
  301. package/dist/spec/ui/index.d.ts +9 -0
  302. package/dist/spec/ui/index.d.ts.map +1 -0
  303. package/dist/spec/ui/index.js +16 -0
  304. package/dist/spec/ui/index.js.map +1 -0
  305. package/dist/spec/ui/progress-handler.d.ts +33 -0
  306. package/dist/spec/ui/progress-handler.d.ts.map +1 -0
  307. package/dist/spec/ui/progress-handler.js +132 -0
  308. package/dist/spec/ui/progress-handler.js.map +1 -0
  309. package/dist/spec/ui/progress.d.ts +24 -0
  310. package/dist/spec/ui/progress.d.ts.map +1 -0
  311. package/dist/spec/ui/progress.js +13 -0
  312. package/dist/spec/ui/progress.js.map +1 -0
  313. package/dist/spec/utils/fs.d.ts +45 -0
  314. package/dist/spec/utils/fs.d.ts.map +1 -0
  315. package/dist/spec/utils/fs.js +163 -0
  316. package/dist/spec/utils/fs.js.map +1 -0
  317. package/dist/spec/utils/index.d.ts +12 -0
  318. package/dist/spec/utils/index.d.ts.map +1 -0
  319. package/dist/spec/utils/index.js +26 -0
  320. package/dist/spec/utils/index.js.map +1 -0
  321. package/dist/spec/utils/meta.d.ts +32 -0
  322. package/dist/spec/utils/meta.d.ts.map +1 -0
  323. package/dist/spec/utils/meta.js +122 -0
  324. package/dist/spec/utils/meta.js.map +1 -0
  325. package/dist/spec/utils/truncate.d.ts +86 -0
  326. package/dist/spec/utils/truncate.d.ts.map +1 -0
  327. package/dist/spec/utils/truncate.js +172 -0
  328. package/dist/spec/utils/truncate.js.map +1 -0
  329. package/dist/sync/watcher.d.ts +25 -1
  330. package/dist/sync/watcher.d.ts.map +1 -1
  331. package/dist/sync/watcher.js +76 -3
  332. package/dist/sync/watcher.js.map +1 -1
  333. package/dist/telemetry/index.js +3 -3
  334. package/dist/telemetry/index.js.map +1 -1
  335. package/dist/types.d.ts +3 -0
  336. package/dist/types.d.ts.map +1 -1
  337. package/package.json +62 -58
  338. package/scripts/_tmp-cfwk-resolve.log +0 -0
  339. package/scripts/_tmp-cfwk-sig.log +0 -0
  340. package/scripts/_tmp-cfwk-vt.log +0 -0
  341. package/scripts/add-lang/bench.sh +60 -60
  342. package/scripts/add-lang/check-grammar.mjs +75 -75
  343. package/scripts/add-lang/dump-ast.mjs +103 -103
  344. package/scripts/add-lang/verify-extraction.mjs +70 -70
  345. package/scripts/agent-eval/ab-adoption.sh +91 -91
  346. package/scripts/agent-eval/ab-hook.sh +86 -86
  347. package/scripts/agent-eval/ab-impl.sh +78 -78
  348. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
  349. package/scripts/agent-eval/ab-sufficiency.sh +78 -78
  350. package/scripts/agent-eval/arms-F.sh +21 -21
  351. package/scripts/agent-eval/arms-matrix.sh +37 -37
  352. package/scripts/agent-eval/audit.sh +68 -68
  353. package/scripts/agent-eval/bench-readme.sh +28 -28
  354. package/scripts/agent-eval/bench-why-repo.sh +22 -22
  355. package/scripts/agent-eval/block-read-hook.sh +19 -19
  356. package/scripts/agent-eval/hook-settings.json +15 -15
  357. package/scripts/agent-eval/itrun.sh +120 -120
  358. package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
  359. package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
  360. package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
  361. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
  362. package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
  363. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
  364. package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
  365. package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
  366. package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
  367. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
  368. package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
  369. package/scripts/agent-eval/offload-eval-setup.sh +24 -24
  370. package/scripts/agent-eval/offload-eval-styles.sh +71 -71
  371. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
  372. package/scripts/agent-eval/offload-eval.md +76 -76
  373. package/scripts/agent-eval/parse-arms.mjs +116 -116
  374. package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
  375. package/scripts/agent-eval/parse-run.mjs +45 -45
  376. package/scripts/agent-eval/parse-session.mjs +93 -93
  377. package/scripts/agent-eval/probe-context.mjs +21 -21
  378. package/scripts/agent-eval/probe-explore.mjs +40 -40
  379. package/scripts/agent-eval/probe-node.mjs +20 -20
  380. package/scripts/agent-eval/probe-sweep.mjs +119 -119
  381. package/scripts/agent-eval/probe-trace.mjs +20 -20
  382. package/scripts/agent-eval/redirect-read-hook.sh +38 -38
  383. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -119
  384. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -125
  385. package/scripts/agent-eval/run-agent.sh +34 -34
  386. package/scripts/agent-eval/run-all.sh +75 -75
  387. package/scripts/agent-eval/run-arms.sh +56 -56
  388. package/scripts/agent-eval/seq-matrix.mjs +137 -137
  389. package/scripts/bench-arkts-init-rss.log +0 -0
  390. package/scripts/build-bundle.sh +123 -123
  391. package/scripts/exp_boundary_eval/README.md +247 -247
  392. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
  393. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-38.pyc +0 -0
  394. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
  395. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-38.pyc +0 -0
  396. package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-38.pyc +0 -0
  397. package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-310.pyc +0 -0
  398. package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-38.pyc +0 -0
  399. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
  400. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-38.pyc +0 -0
  401. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
  402. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-38.pyc +0 -0
  403. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
  404. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-38.pyc +0 -0
  405. package/scripts/exp_boundary_eval/__pycache__/win_mcp_launcher.cpython-38.pyc +0 -0
  406. package/scripts/exp_boundary_eval/_test_mcp_chain.py +78 -78
  407. package/scripts/exp_boundary_eval/_test_stdin.py +8 -8
  408. package/scripts/exp_boundary_eval/_utils.py +1116 -1116
  409. package/scripts/exp_boundary_eval/analyze.py +1313 -1313
  410. package/scripts/exp_boundary_eval/deveco_arm.py +519 -519
  411. package/scripts/exp_boundary_eval/run_all.py +378 -378
  412. package/scripts/exp_boundary_eval/run_one.py +165 -165
  413. package/scripts/exp_boundary_eval/run_session.py +158 -158
  414. package/scripts/exp_boundary_eval/setup.py +120 -120
  415. package/scripts/exp_boundary_eval/win_mcp_launcher.py +73 -73
  416. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +36 -36
  417. package/scripts/exp_boundary_eval/win_node_launcher.py +24 -24
  418. package/scripts/extract-release-notes.mjs +130 -130
  419. package/scripts/local-install.sh +41 -41
  420. package/scripts/npm-sdk.js +75 -75
  421. package/scripts/npm-shim.js +275 -275
  422. package/scripts/ohos-sdk-publish.mjs +133 -133
  423. package/scripts/pack-npm.sh +119 -119
  424. package/scripts/prepare-release.mjs +270 -270
  425. package/scripts/probe-arkts-mem-why-run.log +0 -0
  426. package/scripts/probe-banner-livecard-ir.log +0 -0
  427. package/scripts/probe-cfwk-ast.stderr.log +0 -0
  428. package/scripts/probe-cfwk-ast.stdout.log +0 -0
  429. package/scripts/probe-cfwk-attr-shape.log +0 -0
  430. package/scripts/probe-cfwk-cfgdump.stderr.log +0 -0
  431. package/scripts/probe-cfwk-cfgdump.stdout.log +0 -0
  432. package/scripts/probe-cfwk-cvc.stderr.log +0 -0
  433. package/scripts/probe-cfwk-cvc.stdout.log +0 -0
  434. package/scripts/probe-cfwk-diag2.log +0 -0
  435. package/scripts/probe-cfwk-diag3.log +0 -0
  436. package/scripts/probe-cfwk-fedbg.stderr.log +0 -0
  437. package/scripts/probe-cfwk-fedbg.stdout.log +0 -0
  438. package/scripts/probe-cfwk-fileresult.log +0 -0
  439. package/scripts/probe-cfwk-fix.stderr.log +0 -0
  440. package/scripts/probe-cfwk-fix.stdout.log +0 -0
  441. package/scripts/probe-cfwk-fix2.stderr.log +0 -0
  442. package/scripts/probe-cfwk-fix2.stdout.log +0 -0
  443. package/scripts/probe-cfwk-fix3.stderr.log +0 -0
  444. package/scripts/probe-cfwk-fix3.stdout.log +0 -0
  445. package/scripts/probe-cfwk-foreach.log +0 -0
  446. package/scripts/probe-cfwk-getmethod-throw.log +0 -0
  447. package/scripts/probe-cfwk-hg-extract.log +0 -0
  448. package/scripts/probe-cfwk-pr1003-noprior.stderr.log +0 -0
  449. package/scripts/probe-cfwk-pr1003-noprior.stdout.log +0 -0
  450. package/scripts/probe-cfwk-pr1003.stderr.log +0 -0
  451. package/scripts/probe-cfwk-pr1003.stdout.log +0 -0
  452. package/scripts/probe-cfwk-preroot-noprior.stderr.log +0 -0
  453. package/scripts/probe-cfwk-preroot-noprior.stdout.log +0 -0
  454. package/scripts/probe-cfwk-preroot-prior.stderr.log +0 -0
  455. package/scripts/probe-cfwk-preroot-prior.stdout.log +0 -0
  456. package/scripts/probe-cfwk-preroot-skipstate.stderr.log +0 -0
  457. package/scripts/probe-cfwk-preroot-skipstate.stdout.log +0 -0
  458. package/scripts/probe-cfwk-resolve-sim.log +0 -0
  459. package/scripts/probe-cfwk-tree-shape.log +0 -0
  460. package/scripts/probe-cfwk-walk-abort.log +0 -0
  461. package/scripts/probe-cfwk.log +0 -0
  462. package/scripts/probe-force-index.log +0 -0
  463. package/scripts/probe-no-force-index.log +0 -0
  464. package/scripts/probe-samefile-ir.stderr.log +0 -0
  465. package/scripts/probe-samefile-ir.stdout.log +224 -0
  466. package/scripts/probe-sdk-vs-project.log +0 -0
  467. package/scripts/probe-viewtree-downgrade.log +0 -0
  468. package/dist/arkts/ohos-api-index.d.ts +0 -15
  469. package/dist/arkts/ohos-api-index.d.ts.map +0 -1
  470. package/dist/arkts/ohos-api-index.js +0 -190
  471. package/dist/arkts/ohos-api-index.js.map +0 -1
  472. package/dist/arkts/ohos-sdk-input.d.ts +0 -36
  473. package/dist/arkts/ohos-sdk-input.d.ts.map +0 -1
  474. package/dist/arkts/ohos-sdk-input.js +0 -214
  475. package/dist/arkts/ohos-sdk-input.js.map +0 -1
  476. package/dist/extraction/languages/arkts-state-decorators.d.ts +0 -13
  477. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +0 -1
  478. package/dist/extraction/languages/arkts-state-decorators.js +0 -26
  479. package/dist/extraction/languages/arkts-state-decorators.js.map +0 -1
  480. package/dist/extraction/languages/ohos-api-consumer.d.ts +0 -34
  481. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +0 -1
  482. package/dist/extraction/languages/ohos-api-consumer.js +0 -283
  483. package/dist/extraction/languages/ohos-api-consumer.js.map +0 -1
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ /**
3
+ * Unified diff parser — converts `git diff` output into structured code
4
+ * fragments.
5
+ *
6
+ * Replaces `commit4spec/reverse_engineer/change_analyzer.py`. Parses
7
+ * unified diff output and extracts file-level change information (change
8
+ * type, line range, diff text).
9
+ *
10
+ * @module spec/build/diff-parser
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.analyzeCommitDiff = analyzeCommitDiff;
14
+ exports.listChangedFiles = listChangedFiles;
15
+ exports.parseDiff = parseDiff;
16
+ const git_1 = require("../git");
17
+ // ---------------------------------------------------------------------------
18
+ // analyzeCommitDiff
19
+ // ---------------------------------------------------------------------------
20
+ /**
21
+ * Retrieve and parse the diff for a single commit.
22
+ *
23
+ * 1. Call `getCommitDiff(repoPath, commitHash)` to get raw diff text.
24
+ * 2. Parse the diff into structured `DiffFragment` objects.
25
+ * 3. Return the fragments.
26
+ *
27
+ * Returns an empty array when the diff cannot be retrieved or is empty.
28
+ */
29
+ function analyzeCommitDiff(repoPath, commitHash, preFetchedDiff) {
30
+ const diff = preFetchedDiff ?? (0, git_1.getCommitDiff)(repoPath, commitHash);
31
+ if (!diff) {
32
+ return [];
33
+ }
34
+ return parseDiff(diff);
35
+ }
36
+ // ---------------------------------------------------------------------------
37
+ // listChangedFiles
38
+ // ---------------------------------------------------------------------------
39
+ /**
40
+ * Parse changed file paths from a unified diff string.
41
+ *
42
+ * Matches `--- a/path` and `+++ b/path` headers to identify files,
43
+ * skipping `/dev/null`. Returns a list of unique changed file paths.
44
+ *
45
+ * Both headers are needed:
46
+ * - `+++ b/` captures added and modified files. For deletions the line is
47
+ * `+++ /dev/null`, which is skipped.
48
+ * - `--- a/` captures deleted files. For additions the line is
49
+ * `--- /dev/null`, which is skipped.
50
+ */
51
+ function listChangedFiles(diff) {
52
+ const files = new Set();
53
+ const lines = diff.split('\n');
54
+ for (const line of lines) {
55
+ let match = /^\+\+\+ b\/(.+)$/.exec(line);
56
+ if (match) {
57
+ const fp = match[1];
58
+ if (fp !== '/dev/null') {
59
+ files.add(fp);
60
+ }
61
+ continue;
62
+ }
63
+ match = /^--- a\/(.+)$/.exec(line);
64
+ if (match) {
65
+ const fp = match[1];
66
+ if (fp !== '/dev/null') {
67
+ files.add(fp);
68
+ }
69
+ }
70
+ }
71
+ return Array.from(files);
72
+ }
73
+ // ---------------------------------------------------------------------------
74
+ // parseDiff
75
+ // ---------------------------------------------------------------------------
76
+ /**
77
+ * State-machine parser for unified diff format.
78
+ *
79
+ * Walks through the diff line-by-line, tracking the current file, change
80
+ * type, and line-number range. Accumulates lines into a buffer and emits a
81
+ * `DiffFragment` each time a new `diff --git` section begins (or when the
82
+ * input is exhausted).
83
+ */
84
+ function parseDiff(diff) {
85
+ const lines = diff.split('\n');
86
+ // ---- state ----
87
+ const fragments = [];
88
+ let buf = [];
89
+ let currentFilePath = null;
90
+ let currentChangeType = 'MODIFY';
91
+ let currentStartLine = 0;
92
+ let currentEndLine = 0;
93
+ let inHunk = false;
94
+ // ---- flush helper ----
95
+ const _flush = () => {
96
+ if (buf.length === 0 || currentFilePath === null) {
97
+ buf = [];
98
+ return;
99
+ }
100
+ // DELETE files have no lines in the new version — use [0, 0].
101
+ let startLine;
102
+ let endLine;
103
+ if (currentChangeType === 'DELETE') {
104
+ startLine = 0;
105
+ endLine = 0;
106
+ }
107
+ else {
108
+ // When no hunk was ever encountered, default startLine to 1.
109
+ startLine = currentStartLine === 0 ? 1 : currentStartLine;
110
+ endLine = currentEndLine;
111
+ }
112
+ fragments.push({
113
+ filePath: currentFilePath,
114
+ changeType: currentChangeType,
115
+ startLine,
116
+ endLine,
117
+ codeDiff: buf.join('\n'),
118
+ });
119
+ buf = [];
120
+ };
121
+ // ---- line-by-line parser ----
122
+ for (const line of lines) {
123
+ // Rule 1 — new file section: flush the previous file.
124
+ if (line.startsWith('diff --git ')) {
125
+ _flush();
126
+ buf = [line];
127
+ currentFilePath = null;
128
+ currentChangeType = 'MODIFY';
129
+ currentStartLine = 0;
130
+ currentEndLine = 0;
131
+ inHunk = false;
132
+ continue;
133
+ }
134
+ // Rule 2 — new file mode → change type is ADD.
135
+ if (line.startsWith('new file mode ')) {
136
+ currentChangeType = 'ADD';
137
+ buf.push(line);
138
+ continue;
139
+ }
140
+ // Rule 3 — deleted file mode → change type is DELETE.
141
+ if (line.startsWith('deleted file mode ')) {
142
+ currentChangeType = 'DELETE';
143
+ buf.push(line);
144
+ continue;
145
+ }
146
+ // Rule 4 — file path lines (--- a/path or +++ b/path).
147
+ if (line.startsWith('--- a/') || line.startsWith('+++ b/')) {
148
+ const isPlus = line.startsWith('+++ b/');
149
+ // Extract the path, skipping `/dev/null`.
150
+ let pathPart = '';
151
+ if (isPlus) {
152
+ pathPart = line.slice(6); // '+++ b/'.length
153
+ }
154
+ else {
155
+ pathPart = line.slice(6); // '--- a/'.length
156
+ }
157
+ if (pathPart !== '/dev/null') {
158
+ currentFilePath = pathPart;
159
+ }
160
+ buf.push(line);
161
+ continue;
162
+ }
163
+ // Rule 5 — hunk header: @@ -oldStart[,oldCount] +newStart[,newCount] @@
164
+ const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
165
+ if (hunkMatch) {
166
+ const newStart = parseInt(hunkMatch[1], 10);
167
+ if (currentStartLine === 0) {
168
+ currentStartLine = newStart;
169
+ }
170
+ currentEndLine = newStart;
171
+ inHunk = true;
172
+ buf.push(line);
173
+ continue;
174
+ }
175
+ // Rule 6 — added lines (start with '+', but not '+++').
176
+ if (line.startsWith('+') && !line.startsWith('+++')) {
177
+ if (inHunk) {
178
+ currentEndLine++;
179
+ }
180
+ buf.push(line);
181
+ continue;
182
+ }
183
+ // Rule 7 — removed lines (start with '-', but not '---').
184
+ if (line.startsWith('-') && !line.startsWith('---')) {
185
+ buf.push(line);
186
+ continue;
187
+ }
188
+ // Rule 8 — context lines (start with a space).
189
+ if (line.startsWith(' ')) {
190
+ if (inHunk) {
191
+ currentEndLine++;
192
+ }
193
+ buf.push(line);
194
+ continue;
195
+ }
196
+ // Rule 9 — all other lines (e.g. `rename from` / `rename to`,
197
+ // `similarity index`, `Binary files differ`, `\ No newline at end of
198
+ // file`, blank lines between sections, etc.).
199
+ buf.push(line);
200
+ }
201
+ // Flush the final file.
202
+ _flush();
203
+ return fragments;
204
+ }
205
+ //# sourceMappingURL=diff-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-parser.js","sourceRoot":"","sources":["../../../src/spec/build/diff-parser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;YACf,SAAS;QACX,CAAC;QAED,8DAA8D;QAC9D,qEAAqE;QACrE,8CAA8C;QAC9C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,wBAAwB;IACxB,MAAM,EAAE,CAAC;IAET,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Build pipeline orchestrator — main entry point for building spec
3
+ * knowledge from Git history.
4
+ *
5
+ * Replaces `commit4spec/reverse_engineer/pipeline.py`. Discovers spec↔commit
6
+ * pairs via `scan()`, persists them into the SQLite knowledge graph, and
7
+ * writes a `.homegraph/commit4spec/meta.json` anchor so the self-evolve pipeline can
8
+ * pick up where build left off.
9
+ *
10
+ * @module spec/build/pipeline
11
+ */
12
+ import { SqliteDatabase } from '../../db/sqlite-adapter';
13
+ import type { ProgressCallback } from '../ui';
14
+ export interface BuildResult {
15
+ specsFound: number;
16
+ commitsFound: number;
17
+ fragmentsFound: number;
18
+ relationsCreated: number;
19
+ totalEntries: number;
20
+ skippedEntries: Array<{
21
+ specId: string;
22
+ reason: string;
23
+ }>;
24
+ upToDate?: boolean;
25
+ }
26
+ /**
27
+ * Run the full build pipeline.
28
+ *
29
+ * Steps (ported from `pipeline.py:49-151`):
30
+ *
31
+ * 1. Initialise the spec knowledge-graph schema in the database.
32
+ * 2. Discover all specs on disk (for the `totalEntries` count).
33
+ * 3. Scan the repository for spec↔commit pairs.
34
+ * 4. Sort pairs by commit timestamp ascending so that `INSERT OR REPLACE`
35
+ * gives the most-recent commit the final word for each spec node.
36
+ * 5. Process each pair:
37
+ * - Insert a SpecNode (once per specId; deduplicated by commit timestamp).
38
+ * - Insert a CommitNode (once per commit hash).
39
+ * - Insert a SUMMARIZED_FROM relation.
40
+ * - Parse the commit diff into code fragments and persist them.
41
+ * 6. Build a list of specs discovered on disk but never matched to a commit.
42
+ * 7. Write `.homegraph/commit4spec/meta.json`.
43
+ * 8. Return the `BuildResult` with all counts.
44
+ *
45
+ * Edge cases:
46
+ * - Empty pairs → zero counts, write meta anyway, return result.
47
+ * - Pair with commit metadata but no spec metadata → commit and fragments
48
+ * are still persisted; SpecNode and spec_commit_relation are skipped.
49
+ * - Pair with spec metadata but no commit metadata → entire pair is skipped.
50
+ * - Same spec in multiple pairs → only counted once in `specsFound`, but
51
+ * every commit relation is created.
52
+ */
53
+ export declare function runBuildPipeline(repoPath: string, specStoragePath: string, db: SqliteDatabase, onProgress?: ProgressCallback): BuildResult;
54
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/spec/build/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAWzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAM9C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,cAAc,EAClB,UAAU,CAAC,EAAE,gBAAgB,GAC5B,WAAW,CAoIb"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ /**
3
+ * Build pipeline orchestrator — main entry point for building spec
4
+ * knowledge from Git history.
5
+ *
6
+ * Replaces `commit4spec/reverse_engineer/pipeline.py`. Discovers spec↔commit
7
+ * pairs via `scan()`, persists them into the SQLite knowledge graph, and
8
+ * writes a `.homegraph/commit4spec/meta.json` anchor so the self-evolve pipeline can
9
+ * pick up where build left off.
10
+ *
11
+ * @module spec/build/pipeline
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.runBuildPipeline = runBuildPipeline;
15
+ const config_1 = require("../config");
16
+ const utils_1 = require("../utils");
17
+ const schema_1 = require("../db/schema");
18
+ const commit_node_1 = require("../db/commit-node");
19
+ const relations_1 = require("../db/relations");
20
+ const persist_1 = require("../db/persist");
21
+ const scan_1 = require("./scan");
22
+ const git_1 = require("../git");
23
+ const diff_parser_1 = require("./diff-parser");
24
+ const errors_1 = require("../../errors");
25
+ // ---------------------------------------------------------------------------
26
+ // runBuildPipeline
27
+ // ---------------------------------------------------------------------------
28
+ /**
29
+ * Run the full build pipeline.
30
+ *
31
+ * Steps (ported from `pipeline.py:49-151`):
32
+ *
33
+ * 1. Initialise the spec knowledge-graph schema in the database.
34
+ * 2. Discover all specs on disk (for the `totalEntries` count).
35
+ * 3. Scan the repository for spec↔commit pairs.
36
+ * 4. Sort pairs by commit timestamp ascending so that `INSERT OR REPLACE`
37
+ * gives the most-recent commit the final word for each spec node.
38
+ * 5. Process each pair:
39
+ * - Insert a SpecNode (once per specId; deduplicated by commit timestamp).
40
+ * - Insert a CommitNode (once per commit hash).
41
+ * - Insert a SUMMARIZED_FROM relation.
42
+ * - Parse the commit diff into code fragments and persist them.
43
+ * 6. Build a list of specs discovered on disk but never matched to a commit.
44
+ * 7. Write `.homegraph/commit4spec/meta.json`.
45
+ * 8. Return the `BuildResult` with all counts.
46
+ *
47
+ * Edge cases:
48
+ * - Empty pairs → zero counts, write meta anyway, return result.
49
+ * - Pair with commit metadata but no spec metadata → commit and fragments
50
+ * are still persisted; SpecNode and spec_commit_relation are skipped.
51
+ * - Pair with spec metadata but no commit metadata → entire pair is skipped.
52
+ * - Same spec in multiple pairs → only counted once in `specsFound`, but
53
+ * every commit relation is created.
54
+ */
55
+ function runBuildPipeline(repoPath, specStoragePath, db, onProgress) {
56
+ // Pre-check: if meta.json exists and HEAD hasn't changed since the last
57
+ // build, the knowledge graph is already current — skip the full rebuild.
58
+ const existingMeta = (0, utils_1.readMeta)(repoPath);
59
+ if (existingMeta?.currentCommitID) {
60
+ const headHash = (0, git_1.getHeadHash)(repoPath);
61
+ if (headHash && headHash === existingMeta.currentCommitID) {
62
+ (0, errors_1.logDebug)('Skipping spec build: knowledge graph is up to date', {
63
+ currentCommitID: existingMeta.currentCommitID,
64
+ });
65
+ return {
66
+ specsFound: 0,
67
+ commitsFound: 0,
68
+ fragmentsFound: 0,
69
+ relationsCreated: 0,
70
+ totalEntries: (0, utils_1.discoverSpecs)(specStoragePath).length,
71
+ skippedEntries: [],
72
+ upToDate: true,
73
+ };
74
+ }
75
+ }
76
+ // ---- Step 1: init schema ----
77
+ (0, schema_1.initSpecSchema)(db);
78
+ // ---- Step 2: discover specs (for totalEntries) ----
79
+ const allEntries = (0, utils_1.discoverSpecs)(specStoragePath);
80
+ const totalEntries = allEntries.length;
81
+ // ---- Step 3: scan for pairs ----
82
+ const pairs = (0, scan_1.scan)(repoPath, specStoragePath, (0, config_1.loadSpecConfig)(repoPath), onProgress);
83
+ // ---- Step 4: sort by commit timestamp ascending (oldest first) ----
84
+ // INSERT OR REPLACE is used for SpecNode — when the same spec appears
85
+ // in multiple pairs, the LAST write (most-recent commit) naturally wins.
86
+ pairs.sort((a, b) => {
87
+ const aTs = a.commitMetadata?.timestamp ?? 0;
88
+ const bTs = b.commitMetadata?.timestamp ?? 0;
89
+ return aTs - bTs;
90
+ });
91
+ // ---- Step 5: process pairs ----
92
+ const writtenSpecIds = new Set();
93
+ const seenCommitHashes = new Set();
94
+ let specsFound = 0;
95
+ let commitsFound = 0;
96
+ let fragmentsFound = 0;
97
+ let relationsCreated = 0;
98
+ const pairsTotal = pairs.length;
99
+ let pairsCurrent = 0;
100
+ for (const pair of pairs) {
101
+ pairsCurrent++;
102
+ onProgress?.({
103
+ phase: 'persisting',
104
+ current: pairsCurrent,
105
+ total: pairsTotal,
106
+ message: `${pair.specId} @ ${pair.commitHash.slice(0, 7)}`,
107
+ });
108
+ // Skip if no commit metadata (no data to insert).
109
+ const cm = pair.commitMetadata;
110
+ if (!cm) {
111
+ continue;
112
+ }
113
+ const sm = pair.specMetadata;
114
+ // Insert SpecNode if spec metadata is present.
115
+ // INSERT OR REPLACE lets the most-recent commit (last in ascending
116
+ // order) overwrite the timestamp. We still track writtenSpecIds to
117
+ // correctly count distinct specs (not overwrites).
118
+ if (sm) {
119
+ (0, errors_1.logDebug)('Processing pair: inserting SpecNode', {
120
+ specId: sm.specId,
121
+ title: sm.title,
122
+ });
123
+ (0, persist_1.upsertSpecFromMetadata)(db, sm, cm.timestamp);
124
+ if (!writtenSpecIds.has(pair.specId)) {
125
+ writtenSpecIds.add(pair.specId);
126
+ specsFound++;
127
+ }
128
+ }
129
+ // Insert CommitNode if not yet seen.
130
+ if (!seenCommitHashes.has(cm.hash)) {
131
+ (0, commit_node_1.insertCommitNode)(db, {
132
+ hash: cm.hash,
133
+ message: cm.message,
134
+ author: cm.author,
135
+ timestamp: cm.timestamp,
136
+ });
137
+ seenCommitHashes.add(cm.hash);
138
+ commitsFound++;
139
+ }
140
+ // Insert spec_commit_relation (only when spec metadata exists).
141
+ if (sm) {
142
+ (0, relations_1.insertSpecCommitRelation)(db, pair.specId, cm.hash, 'SUMMARIZED_FROM');
143
+ relationsCreated++;
144
+ }
145
+ // ---- Analyze diff and insert fragments ----
146
+ const preFetchedDiff = (0, git_1.getCommitDiff)(repoPath, cm.hash);
147
+ const fragments = (0, diff_parser_1.analyzeCommitDiff)(repoPath, cm.hash, preFetchedDiff);
148
+ const persisted = (0, persist_1.persistCommitFragments)(db, cm.hash, fragments);
149
+ fragmentsFound += persisted.fragmentsInserted;
150
+ relationsCreated += persisted.relationsCreated;
151
+ }
152
+ // ---- Step 6: build skipped entries ----
153
+ const skippedEntries = allEntries
154
+ .filter((e) => !writtenSpecIds.has(e.specId))
155
+ .map((e) => ({ specId: e.specId, reason: 'No matching commits found' }));
156
+ // ---- Step 7: write meta ----
157
+ const headHash = (0, git_1.getHeadHash)(repoPath) ?? undefined;
158
+ (0, utils_1.writeMeta)(repoPath, specStoragePath, headHash);
159
+ onProgress?.({ phase: 'done', current: 0, total: 0 });
160
+ // ---- Step 8: return result ----
161
+ return {
162
+ specsFound,
163
+ commitsFound,
164
+ fragmentsFound,
165
+ relationsCreated,
166
+ totalEntries,
167
+ skippedEntries,
168
+ };
169
+ }
170
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/spec/build/pipeline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA4DH,4CAyIC;AAlMD,sCAA2C;AAC3C,oCAA8D;AAC9D,yCAA8C;AAC9C,mDAAqD;AACrD,+CAA2D;AAC3D,2CAA+E;AAC/E,iCAA8B;AAC9B,gCAAoD;AACpD,+CAAkD;AAClD,yCAAwC;AAiBxC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,eAAuB,EACvB,EAAkB,EAClB,UAA6B;IAE7B,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,YAAY,GAAG,IAAA,gBAAQ,EAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,YAAY,EAAE,eAAe,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,IAAA,iBAAW,EAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,QAAQ,IAAI,QAAQ,KAAK,YAAY,CAAC,eAAe,EAAE,CAAC;YAC1D,IAAA,iBAAQ,EAAC,oDAAoD,EAAE;gBAC7D,eAAe,EAAE,YAAY,CAAC,eAAe;aAC9C,CAAC,CAAC;YACH,OAAO;gBACL,UA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AE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAEtD,kCAAkC;IAClC,OAAO;QACL,UAAU;QACV,YAAY;QACZ,cAAc;QACd,gBAAgB;QAChB,YAAY;QACZ,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Spec↔commit pairing — discovers which commits reference which specs via
3
+ * conventional-commit scope extraction.
4
+ *
5
+ * Replaces `commit4spec/reverse_engineer/git_scanner.py`'s `scan()` (Strategy
6
+ * A). Shared by the build pipeline and the evolve pipeline's incremental
7
+ * commit analyzer.
8
+ *
9
+ * @module spec/build/scan
10
+ */
11
+ import { SpecConfig } from '../config';
12
+ import { CommitInfo } from '../git';
13
+ import type { ProgressCallback } from '../ui';
14
+ import { SpecMetadata } from './spec-extractor';
15
+ export interface SpecCommitPair {
16
+ specId: string;
17
+ commitHash: string;
18
+ specMetadata: SpecMetadata | null;
19
+ commitMetadata: CommitInfo | null;
20
+ }
21
+ /** Result of matching a single commit message against the on-disk specs. */
22
+ export interface SpecMatch {
23
+ /** Resolved spec ID, or null when the commit scope matched nothing. */
24
+ specId: string | null;
25
+ /** Extracted spec metadata (null when the spec doc could not be read). */
26
+ metadata: SpecMetadata | null;
27
+ }
28
+ /**
29
+ * Match a single commit message to an on-disk spec: resolve the
30
+ * conventional-commit scope to a spec ID, then extract that spec's metadata.
31
+ *
32
+ * This is the shared per-commit matching step used by both {@link scan}
33
+ * (build) and the evolve pipeline's incremental analyzer.
34
+ */
35
+ export declare function matchCommitToSpec(message: string, specIds: Set<string>, specStoragePath: string, config: SpecConfig): SpecMatch;
36
+ /**
37
+ * Main scanning function — discovers spec↔commit pairs from commit history.
38
+ *
39
+ * Iterates every commit in the repo, extracts a conventional-commit scope from
40
+ * its message, normalizes it, and checks whether the resulting spec ID exists
41
+ * on disk. When a match is found the pair is recorded with full spec and
42
+ * commit metadata.
43
+ *
44
+ * Duplicates (identical specId + commitHash) are de-duplicated via a
45
+ * `Map` keyed on `"${specId}|${commitHash}"`.
46
+ */
47
+ export declare function scan(repoPath: string, specStoragePath: string, config: SpecConfig, onProgress?: ProgressCallback): SpecCommitPair[];
48
+ //# sourceMappingURL=scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../src/spec/build/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAiB,MAAM,QAAQ,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOrE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,cAAc,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B;AAMD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,UAAU,GACjB,SAAS,CASX;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,UAAU,EAClB,UAAU,CAAC,EAAE,gBAAgB,GAC5B,cAAc,EAAE,CA0ClB"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ /**
3
+ * Spec↔commit pairing — discovers which commits reference which specs via
4
+ * conventional-commit scope extraction.
5
+ *
6
+ * Replaces `commit4spec/reverse_engineer/git_scanner.py`'s `scan()` (Strategy
7
+ * A). Shared by the build pipeline and the evolve pipeline's incremental
8
+ * commit analyzer.
9
+ *
10
+ * @module spec/build/scan
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.matchCommitToSpec = matchCommitToSpec;
14
+ exports.scan = scan;
15
+ const git_1 = require("../git");
16
+ const utils_1 = require("../utils");
17
+ const scope_resolver_1 = require("./scope-resolver");
18
+ const spec_extractor_1 = require("./spec-extractor");
19
+ const errors_1 = require("../../errors");
20
+ // ---------------------------------------------------------------------------
21
+ // matchCommitToSpec
22
+ // ---------------------------------------------------------------------------
23
+ /**
24
+ * Match a single commit message to an on-disk spec: resolve the
25
+ * conventional-commit scope to a spec ID, then extract that spec's metadata.
26
+ *
27
+ * This is the shared per-commit matching step used by both {@link scan}
28
+ * (build) and the evolve pipeline's incremental analyzer.
29
+ */
30
+ function matchCommitToSpec(message, specIds, specStoragePath, config) {
31
+ const specId = (0, scope_resolver_1.resolveScopeToSpec)(message, specIds, config);
32
+ if (!specId) {
33
+ return { specId: null, metadata: null };
34
+ }
35
+ return {
36
+ specId,
37
+ metadata: (0, spec_extractor_1.extractSpecMetadata)(specStoragePath, specId, config),
38
+ };
39
+ }
40
+ // ---------------------------------------------------------------------------
41
+ // scan
42
+ // ---------------------------------------------------------------------------
43
+ /**
44
+ * Main scanning function — discovers spec↔commit pairs from commit history.
45
+ *
46
+ * Iterates every commit in the repo, extracts a conventional-commit scope from
47
+ * its message, normalizes it, and checks whether the resulting spec ID exists
48
+ * on disk. When a match is found the pair is recorded with full spec and
49
+ * commit metadata.
50
+ *
51
+ * Duplicates (identical specId + commitHash) are de-duplicated via a
52
+ * `Map` keyed on `"${specId}|${commitHash}"`.
53
+ */
54
+ function scan(repoPath, specStoragePath, config, onProgress) {
55
+ const pairs = new Map();
56
+ // Hoist the directory read out of the per-commit loop.
57
+ const specIds = new Set((0, utils_1.discoverSpecs)(specStoragePath).map((e) => e.specId));
58
+ const commits = (0, git_1.getAllCommits)(repoPath);
59
+ const total = commits.length;
60
+ let current = 0;
61
+ for (const commit of commits) {
62
+ current++;
63
+ onProgress?.({
64
+ phase: 'scanning',
65
+ current,
66
+ total,
67
+ message: `${commit.hash.slice(0, 7)} ${commit.message.slice(0, 30)}`,
68
+ });
69
+ const { specId, metadata } = matchCommitToSpec(commit.message, specIds, specStoragePath, config);
70
+ if (!specId) {
71
+ (0, errors_1.logDebug)('scan: no scope match', {
72
+ commitHash: commit.hash.slice(0, 7),
73
+ message: commit.message,
74
+ });
75
+ continue;
76
+ }
77
+ const key = `${specId}|${commit.hash}`;
78
+ if (!pairs.has(key)) {
79
+ pairs.set(key, {
80
+ specId,
81
+ commitHash: commit.hash,
82
+ specMetadata: metadata,
83
+ commitMetadata: commit,
84
+ });
85
+ }
86
+ }
87
+ return Array.from(pairs.values());
88
+ }
89
+ //# sourceMappingURL=scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../src/spec/build/scan.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAwCH,8CAcC;AAiBD,oBA+CC;AAnHD,gCAAmD;AACnD,oCAAyC;AAEzC,qDAAsD;AACtD,qDAAqE;AACrE,yCAAwC;AAqBxC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,OAAe,EACf,OAAoB,EACpB,eAAuB,EACvB,MAAkB;IAElB,MAAM,MAAM,GAAG,IAAA,mCAAkB,EAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAA,oCAAmB,EAAC,eAA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AS;QACX,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACb,MAAM;gBACN,UAAU,EAAE,MAAM,CAAC,IAAI;gBACvB,YAAY,EAAE,QAAQ;gBACtB,cAAc,EAAE,MAAM;aACvB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Commit message scope parsing and resolution.
3
+ *
4
+ * Replaces `commit4spec/reverse_engineer/scope_resolver.py`.
5
+ * Extracts conventional-commit scopes, normalizes them, and resolves them to
6
+ * spec IDs found on disk.
7
+ *
8
+ * @module spec/build/scope-resolver
9
+ */
10
+ import { SpecConfig } from '../config';
11
+ /**
12
+ * Extract a scope from a commit message using the configured regex.
13
+ *
14
+ * Only searches the **first line** of the commit message. Returns the
15
+ * contents of the first capture group (the scope), or `null` when there is
16
+ * no match or the regex has no capture group.
17
+ */
18
+ export declare function extractScope(message: string, scopeRegex: string): string | null;
19
+ /**
20
+ * Normalize a scope string.
21
+ *
22
+ * Steps applied in order:
23
+ *
24
+ * 1. **Strip prefixes** — for each prefix in `stripPrefixes`, if `scope`
25
+ * starts with it, remove it and stop (only the first matching prefix is
26
+ * stripped).
27
+ * 2. **Lowercase** — if `lowercase` is `true`, convert to lower case.
28
+ * 3. **Pad spec number** — if `padSpecNumber` is `true`, match the pattern
29
+ * `/^spec(\d+)$/i` and zero-pad the numeric portion to 2 digits
30
+ * (e.g. `spec3` → `spec03`).
31
+ */
32
+ export declare function normalizeScope(scope: string, config: {
33
+ stripPrefixes: string[];
34
+ lowercase: boolean;
35
+ padSpecNumber: boolean;
36
+ }): string;
37
+ /**
38
+ * Extract a scope from a commit message, normalize it, then check whether the
39
+ * resulting spec ID exists among the known on-disk spec IDs.
40
+ *
41
+ * @param message - Commit message (only the first line is searched).
42
+ * @param specIds - Known spec IDs (from `discoverSpecs`, hoisted by the
43
+ * caller so scanning N commits does not re-read the directory N times).
44
+ * @param config - Spec configuration (commitScope section).
45
+ *
46
+ * Returns the normalized spec ID when the scope resolves to an existing spec,
47
+ * otherwise `null`.
48
+ */
49
+ export declare function resolveScopeToSpec(message: string, specIds: Set<string>, config: SpecConfig): string | null;
50
+ //# sourceMappingURL=scope-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-resolver.d.ts","sourceRoot":"","sources":["../../../src/spec/build/scope-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAOvC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkB/E;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE;IAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAC9E,MAAM,CAyBR;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,MAAM,EAAE,UAAU,GACjB,MAAM,GAAG,IAAI,CASf"}