homegraph 1.5.1 → 1.5.2

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 (258) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +305 -305
  3. package/dist/bin/homegraph.js +9 -9
  4. package/dist/db/index.js +36 -36
  5. package/dist/db/migrations.js +37 -37
  6. package/dist/db/queries.js +156 -156
  7. package/dist/db/schema.sql +203 -203
  8. package/dist/directory.js +5 -5
  9. package/dist/extraction/index.d.ts +1 -1
  10. package/dist/extraction/index.d.ts.map +1 -1
  11. package/dist/extraction/index.js +54 -43
  12. package/dist/extraction/index.js.map +1 -1
  13. package/dist/extraction/languages/arkts.d.ts +53 -6
  14. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  15. package/dist/extraction/languages/arkts.js +565 -65
  16. package/dist/extraction/languages/arkts.js.map +1 -1
  17. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  18. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  19. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  20. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  21. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  22. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  23. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  24. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  25. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +3 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/installer/instructions-template.js +9 -9
  30. package/dist/mcp/diff-impact.d.ts +131 -0
  31. package/dist/mcp/diff-impact.d.ts.map +1 -0
  32. package/dist/mcp/diff-impact.js +385 -0
  33. package/dist/mcp/diff-impact.js.map +1 -0
  34. package/dist/mcp/liveness-watchdog.js +51 -51
  35. package/dist/mcp/server-instructions.d.ts +1 -1
  36. package/dist/mcp/server-instructions.d.ts.map +1 -1
  37. package/dist/mcp/server-instructions.js +49 -47
  38. package/dist/mcp/server-instructions.js.map +1 -1
  39. package/dist/mcp/tools.d.ts +21 -5
  40. package/dist/mcp/tools.d.ts.map +1 -1
  41. package/dist/mcp/tools.js +305 -55
  42. package/dist/mcp/tools.js.map +1 -1
  43. package/dist/resolution/callback-synthesizer.d.ts +2 -1
  44. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  45. package/dist/resolution/callback-synthesizer.js +153 -53
  46. package/dist/resolution/callback-synthesizer.js.map +1 -1
  47. package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -1
  48. package/dist/resolution/frameworks/arkts-entry.js +20 -9
  49. package/dist/resolution/frameworks/arkts-entry.js.map +1 -1
  50. package/dist/resolution/index.d.ts.map +1 -1
  51. package/dist/resolution/index.js +1 -1
  52. package/dist/resolution/index.js.map +1 -1
  53. package/dist/resolution/memory-budget.d.ts +33 -0
  54. package/dist/resolution/memory-budget.d.ts.map +1 -1
  55. package/dist/resolution/memory-budget.js +58 -0
  56. package/dist/resolution/memory-budget.js.map +1 -1
  57. package/dist/resolution/resolver-pool.d.ts +2 -0
  58. package/dist/resolution/resolver-pool.d.ts.map +1 -1
  59. package/dist/resolution/resolver-pool.js +4 -0
  60. package/dist/resolution/resolver-pool.js.map +1 -1
  61. package/dist/spec/db/commit-node.js +4 -4
  62. package/dist/spec/db/fragment-node.js +10 -10
  63. package/dist/spec/db/fts.js +8 -8
  64. package/dist/spec/db/relations.js +88 -88
  65. package/dist/spec/db/schema.js +6 -6
  66. package/dist/spec/db/schema.sql +121 -121
  67. package/dist/spec/db/spec-node.js +4 -4
  68. package/dist/spec/llm/prompts.js +53 -53
  69. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  70. package/dist/ui/shimmer-progress.js +4 -1
  71. package/dist/ui/shimmer-progress.js.map +1 -1
  72. package/package.json +61 -62
  73. package/dist/extraction/languages/arkts-viewtree.d.ts +0 -22
  74. package/dist/extraction/languages/arkts-viewtree.d.ts.map +0 -1
  75. package/dist/extraction/languages/arkts-viewtree.js +0 -133
  76. package/dist/extraction/languages/arkts-viewtree.js.map +0 -1
  77. package/dist/reasoning/config.d.ts +0 -45
  78. package/dist/reasoning/config.d.ts.map +0 -1
  79. package/dist/reasoning/config.js +0 -171
  80. package/dist/reasoning/config.js.map +0 -1
  81. package/dist/reasoning/credentials.d.ts +0 -5
  82. package/dist/reasoning/credentials.d.ts.map +0 -1
  83. package/dist/reasoning/credentials.js +0 -83
  84. package/dist/reasoning/credentials.js.map +0 -1
  85. package/dist/reasoning/login.d.ts +0 -21
  86. package/dist/reasoning/login.d.ts.map +0 -1
  87. package/dist/reasoning/login.js +0 -85
  88. package/dist/reasoning/login.js.map +0 -1
  89. package/dist/reasoning/reasoner.d.ts +0 -43
  90. package/dist/reasoning/reasoner.d.ts.map +0 -1
  91. package/dist/reasoning/reasoner.js +0 -308
  92. package/dist/reasoning/reasoner.js.map +0 -1
  93. package/dist/spec/evolve/llm-client.d.ts +0 -50
  94. package/dist/spec/evolve/llm-client.d.ts.map +0 -1
  95. package/dist/spec/evolve/llm-client.js +0 -176
  96. package/dist/spec/evolve/llm-client.js.map +0 -1
  97. package/dist/spec/evolve/logic-checker.d.ts +0 -12
  98. package/dist/spec/evolve/logic-checker.d.ts.map +0 -1
  99. package/dist/spec/evolve/logic-checker.js +0 -24
  100. package/dist/spec/evolve/logic-checker.js.map +0 -1
  101. package/dist/spec/llm/index.d.ts +0 -3
  102. package/dist/spec/llm/index.d.ts.map +0 -1
  103. package/dist/spec/llm/index.js +0 -11
  104. package/dist/spec/llm/index.js.map +0 -1
  105. package/dist/spec/mining/diff-parser.d.ts +0 -33
  106. package/dist/spec/mining/diff-parser.d.ts.map +0 -1
  107. package/dist/spec/mining/diff-parser.js +0 -166
  108. package/dist/spec/mining/diff-parser.js.map +0 -1
  109. package/dist/spec/mining/git-scanner.d.ts +0 -103
  110. package/dist/spec/mining/git-scanner.d.ts.map +0 -1
  111. package/dist/spec/mining/git-scanner.js +0 -307
  112. package/dist/spec/mining/git-scanner.js.map +0 -1
  113. package/dist/spec/mining/pipeline.d.ts +0 -53
  114. package/dist/spec/mining/pipeline.d.ts.map +0 -1
  115. package/dist/spec/mining/pipeline.js +0 -178
  116. package/dist/spec/mining/pipeline.js.map +0 -1
  117. package/dist/spec/mining/scope-resolver.d.ts +0 -45
  118. package/dist/spec/mining/scope-resolver.d.ts.map +0 -1
  119. package/dist/spec/mining/scope-resolver.js +0 -103
  120. package/dist/spec/mining/scope-resolver.js.map +0 -1
  121. package/dist/spec/mining/spec-extractor.d.ts +0 -69
  122. package/dist/spec/mining/spec-extractor.d.ts.map +0 -1
  123. package/dist/spec/mining/spec-extractor.js +0 -369
  124. package/dist/spec/mining/spec-extractor.js.map +0 -1
  125. package/dist/spec/utils.d.ts +0 -167
  126. package/dist/spec/utils.d.ts.map +0 -1
  127. package/dist/spec/utils.js +0 -463
  128. package/dist/spec/utils.js.map +0 -1
  129. package/scripts/_tmp-cfwk-resolve.log +0 -0
  130. package/scripts/_tmp-cfwk-sig.log +0 -0
  131. package/scripts/_tmp-cfwk-vt.log +0 -0
  132. package/scripts/add-lang/bench.sh +0 -60
  133. package/scripts/add-lang/check-grammar.mjs +0 -75
  134. package/scripts/add-lang/dump-ast.mjs +0 -103
  135. package/scripts/add-lang/verify-extraction.mjs +0 -70
  136. package/scripts/agent-eval/ab-adoption.sh +0 -91
  137. package/scripts/agent-eval/ab-hook.sh +0 -86
  138. package/scripts/agent-eval/ab-impl.sh +0 -78
  139. package/scripts/agent-eval/ab-new-vs-baseline.sh +0 -102
  140. package/scripts/agent-eval/ab-sufficiency.sh +0 -78
  141. package/scripts/agent-eval/arms-F.sh +0 -21
  142. package/scripts/agent-eval/arms-matrix.sh +0 -37
  143. package/scripts/agent-eval/audit.sh +0 -68
  144. package/scripts/agent-eval/bench-readme.sh +0 -28
  145. package/scripts/agent-eval/bench-why-repo.sh +0 -22
  146. package/scripts/agent-eval/block-read-hook.sh +0 -19
  147. package/scripts/agent-eval/hook-settings.json +0 -15
  148. package/scripts/agent-eval/itrun.sh +0 -120
  149. package/scripts/agent-eval/offload-eval-3arm.sh +0 -72
  150. package/scripts/agent-eval/offload-eval-cost.mjs +0 -133
  151. package/scripts/agent-eval/offload-eval-effort.mjs +0 -108
  152. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +0 -25
  153. package/scripts/agent-eval/offload-eval-frontload.sh +0 -47
  154. package/scripts/agent-eval/offload-eval-ground-truth.json +0 -18
  155. package/scripts/agent-eval/offload-eval-hook.mjs +0 -84
  156. package/scripts/agent-eval/offload-eval-judge.mjs +0 -103
  157. package/scripts/agent-eval/offload-eval-matrix.sh +0 -20
  158. package/scripts/agent-eval/offload-eval-metrics.mjs +0 -94
  159. package/scripts/agent-eval/offload-eval-refs1.sh +0 -50
  160. package/scripts/agent-eval/offload-eval-setup.sh +0 -24
  161. package/scripts/agent-eval/offload-eval-styles.sh +0 -72
  162. package/scripts/agent-eval/offload-eval-summarize.mjs +0 -68
  163. package/scripts/agent-eval/offload-eval.md +0 -76
  164. package/scripts/agent-eval/parse-arms.mjs +0 -116
  165. package/scripts/agent-eval/parse-bench-readme.mjs +0 -84
  166. package/scripts/agent-eval/parse-run.mjs +0 -45
  167. package/scripts/agent-eval/parse-session.mjs +0 -93
  168. package/scripts/agent-eval/probe-context.mjs +0 -21
  169. package/scripts/agent-eval/probe-explore.mjs +0 -40
  170. package/scripts/agent-eval/probe-node.mjs +0 -20
  171. package/scripts/agent-eval/probe-sweep.mjs +0 -119
  172. package/scripts/agent-eval/probe-trace.mjs +0 -20
  173. package/scripts/agent-eval/redirect-read-hook.sh +0 -38
  174. package/scripts/agent-eval/repro-concurrent-explore.mjs +0 -119
  175. package/scripts/agent-eval/repro-daemon-clients.mjs +0 -125
  176. package/scripts/agent-eval/run-agent.sh +0 -34
  177. package/scripts/agent-eval/run-all.sh +0 -75
  178. package/scripts/agent-eval/run-arms.sh +0 -56
  179. package/scripts/agent-eval/seq-matrix.mjs +0 -137
  180. package/scripts/bench-arkts-init-rss.log +0 -0
  181. package/scripts/build-bundle.sh +0 -123
  182. package/scripts/exp_boundary_eval/README.md +0 -247
  183. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
  184. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-38.pyc +0 -0
  185. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
  186. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-38.pyc +0 -0
  187. package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-38.pyc +0 -0
  188. package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-310.pyc +0 -0
  189. package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-38.pyc +0 -0
  190. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
  191. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-38.pyc +0 -0
  192. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
  193. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-38.pyc +0 -0
  194. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
  195. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-38.pyc +0 -0
  196. package/scripts/exp_boundary_eval/__pycache__/win_mcp_launcher.cpython-38.pyc +0 -0
  197. package/scripts/exp_boundary_eval/_test_mcp_chain.py +0 -78
  198. package/scripts/exp_boundary_eval/_test_stdin.py +0 -8
  199. package/scripts/exp_boundary_eval/_utils.py +0 -1116
  200. package/scripts/exp_boundary_eval/analyze.py +0 -1313
  201. package/scripts/exp_boundary_eval/deveco_arm.py +0 -519
  202. package/scripts/exp_boundary_eval/run_all.py +0 -378
  203. package/scripts/exp_boundary_eval/run_one.py +0 -165
  204. package/scripts/exp_boundary_eval/run_session.py +0 -158
  205. package/scripts/exp_boundary_eval/setup.py +0 -120
  206. package/scripts/exp_boundary_eval/win_mcp_launcher.py +0 -73
  207. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +0 -36
  208. package/scripts/exp_boundary_eval/win_node_launcher.py +0 -24
  209. package/scripts/extract-release-notes.mjs +0 -130
  210. package/scripts/local-install.sh +0 -41
  211. package/scripts/npm-sdk.js +0 -75
  212. package/scripts/npm-shim.js +0 -275
  213. package/scripts/ohos-sdk-publish.mjs +0 -133
  214. package/scripts/pack-npm.sh +0 -119
  215. package/scripts/prepare-release.mjs +0 -270
  216. package/scripts/probe-arkts-mem-why-run.log +0 -0
  217. package/scripts/probe-banner-livecard-ir.log +0 -0
  218. package/scripts/probe-cfwk-ast.stderr.log +0 -0
  219. package/scripts/probe-cfwk-ast.stdout.log +0 -0
  220. package/scripts/probe-cfwk-attr-shape.log +0 -0
  221. package/scripts/probe-cfwk-cfgdump.stderr.log +0 -0
  222. package/scripts/probe-cfwk-cfgdump.stdout.log +0 -0
  223. package/scripts/probe-cfwk-cvc.stderr.log +0 -0
  224. package/scripts/probe-cfwk-cvc.stdout.log +0 -0
  225. package/scripts/probe-cfwk-diag2.log +0 -0
  226. package/scripts/probe-cfwk-diag3.log +0 -0
  227. package/scripts/probe-cfwk-fedbg.stderr.log +0 -0
  228. package/scripts/probe-cfwk-fedbg.stdout.log +0 -0
  229. package/scripts/probe-cfwk-fileresult.log +0 -0
  230. package/scripts/probe-cfwk-fix.stderr.log +0 -0
  231. package/scripts/probe-cfwk-fix.stdout.log +0 -0
  232. package/scripts/probe-cfwk-fix2.stderr.log +0 -0
  233. package/scripts/probe-cfwk-fix2.stdout.log +0 -0
  234. package/scripts/probe-cfwk-fix3.stderr.log +0 -0
  235. package/scripts/probe-cfwk-fix3.stdout.log +0 -0
  236. package/scripts/probe-cfwk-foreach.log +0 -0
  237. package/scripts/probe-cfwk-getmethod-throw.log +0 -0
  238. package/scripts/probe-cfwk-hg-extract.log +0 -0
  239. package/scripts/probe-cfwk-pr1003-noprior.stderr.log +0 -0
  240. package/scripts/probe-cfwk-pr1003-noprior.stdout.log +0 -0
  241. package/scripts/probe-cfwk-pr1003.stderr.log +0 -0
  242. package/scripts/probe-cfwk-pr1003.stdout.log +0 -0
  243. package/scripts/probe-cfwk-preroot-noprior.stderr.log +0 -0
  244. package/scripts/probe-cfwk-preroot-noprior.stdout.log +0 -0
  245. package/scripts/probe-cfwk-preroot-prior.stderr.log +0 -0
  246. package/scripts/probe-cfwk-preroot-prior.stdout.log +0 -0
  247. package/scripts/probe-cfwk-preroot-skipstate.stderr.log +0 -0
  248. package/scripts/probe-cfwk-preroot-skipstate.stdout.log +0 -0
  249. package/scripts/probe-cfwk-resolve-sim.log +0 -0
  250. package/scripts/probe-cfwk-tree-shape.log +0 -0
  251. package/scripts/probe-cfwk-walk-abort.log +0 -0
  252. package/scripts/probe-cfwk.log +0 -0
  253. package/scripts/probe-force-index.log +0 -0
  254. package/scripts/probe-no-force-index.log +0 -0
  255. package/scripts/probe-samefile-ir.stderr.log +0 -0
  256. package/scripts/probe-samefile-ir.stdout.log +0 -224
  257. package/scripts/probe-sdk-vs-project.log +0 -0
  258. package/scripts/probe-viewtree-downgrade.log +0 -0
@@ -1,33 +0,0 @@
1
- /**
2
- * Unified diff parser — converts `git diff` output into structured code
3
- * fragments.
4
- *
5
- * Replaces `commit4spec/reverse_engineer/change_analyzer.py`. Parses
6
- * unified diff output and extracts file-level change information (change
7
- * type, line range, diff text).
8
- *
9
- * @module spec/mining/diff-parser
10
- */
11
- export interface DiffFragment {
12
- /** Path of the changed file (no `a/` / `b/` prefix). */
13
- filePath: string;
14
- /** Kind of change: added, modified, or deleted. */
15
- changeType: 'ADD' | 'MODIFY' | 'DELETE';
16
- /** First new-line number in this diff fragment (1-based). */
17
- startLine: number;
18
- /** Last new-line number covered by this fragment (1-based). */
19
- endLine: number;
20
- /** Raw unified diff text for this file. */
21
- codeDiff: string;
22
- }
23
- /**
24
- * Retrieve and parse the diff for a single commit.
25
- *
26
- * 1. Call `getCommitDiff(repoPath, commitHash)` to get raw diff text.
27
- * 2. Parse the diff into structured `DiffFragment` objects.
28
- * 3. Return the fragments.
29
- *
30
- * Returns an empty array when the diff cannot be retrieved or is empty.
31
- */
32
- export declare function analyzeCommitDiff(repoPath: string, commitHash: string, preFetchedDiff?: string): DiffFragment[];
33
- //# sourceMappingURL=diff-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff-parser.d.ts","sourceRoot":"","sources":["../../../src/spec/mining/diff-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,YAAY,EAAE,CAMhB"}
@@ -1,166 +0,0 @@
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/mining/diff-parser
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.analyzeCommitDiff = analyzeCommitDiff;
14
- const git_scanner_1 = require("./git-scanner");
15
- // ---------------------------------------------------------------------------
16
- // analyzeCommitDiff
17
- // ---------------------------------------------------------------------------
18
- /**
19
- * Retrieve and parse the diff for a single commit.
20
- *
21
- * 1. Call `getCommitDiff(repoPath, commitHash)` to get raw diff text.
22
- * 2. Parse the diff into structured `DiffFragment` objects.
23
- * 3. Return the fragments.
24
- *
25
- * Returns an empty array when the diff cannot be retrieved or is empty.
26
- */
27
- function analyzeCommitDiff(repoPath, commitHash, preFetchedDiff) {
28
- const diff = preFetchedDiff ?? (0, git_scanner_1.getCommitDiff)(repoPath, commitHash);
29
- if (!diff) {
30
- return [];
31
- }
32
- return _parseDiff(diff);
33
- }
34
- // ---------------------------------------------------------------------------
35
- // _parseDiff
36
- // ---------------------------------------------------------------------------
37
- /**
38
- * State-machine parser for unified diff format.
39
- *
40
- * Walks through the diff line-by-line, tracking the current file, change
41
- * type, and line-number range. Accumulates lines into a buffer and emits a
42
- * `DiffFragment` each time a new `diff --git` section begins (or when the
43
- * input is exhausted).
44
- */
45
- function _parseDiff(diff) {
46
- const lines = diff.split('\n');
47
- // ---- state ----
48
- const fragments = [];
49
- let buf = [];
50
- let currentFilePath = null;
51
- let currentChangeType = 'MODIFY';
52
- let currentStartLine = 0;
53
- let currentEndLine = 0;
54
- let inHunk = false;
55
- // ---- flush helper ----
56
- const _flush = () => {
57
- if (buf.length === 0 || currentFilePath === null) {
58
- buf = [];
59
- return;
60
- }
61
- // DELETE files have no lines in the new version — use [0, 0].
62
- let startLine;
63
- let endLine;
64
- if (currentChangeType === 'DELETE') {
65
- startLine = 0;
66
- endLine = 0;
67
- }
68
- else {
69
- // When no hunk was ever encountered, default startLine to 1.
70
- startLine = currentStartLine === 0 ? 1 : currentStartLine;
71
- endLine = currentEndLine;
72
- }
73
- fragments.push({
74
- filePath: currentFilePath,
75
- changeType: currentChangeType,
76
- startLine,
77
- endLine,
78
- codeDiff: buf.join('\n'),
79
- });
80
- buf = [];
81
- };
82
- // ---- line-by-line parser ----
83
- for (const line of lines) {
84
- // Rule 1 — new file section: flush the previous file.
85
- if (line.startsWith('diff --git ')) {
86
- _flush();
87
- buf = [line];
88
- currentFilePath = null;
89
- currentChangeType = 'MODIFY';
90
- currentStartLine = 0;
91
- currentEndLine = 0;
92
- inHunk = false;
93
- continue;
94
- }
95
- // Rule 2 — new file mode → change type is ADD.
96
- if (line.startsWith('new file mode ')) {
97
- currentChangeType = 'ADD';
98
- buf.push(line);
99
- continue;
100
- }
101
- // Rule 3 — deleted file mode → change type is DELETE.
102
- if (line.startsWith('deleted file mode ')) {
103
- currentChangeType = 'DELETE';
104
- buf.push(line);
105
- continue;
106
- }
107
- // Rule 4 — file path lines (--- a/path or +++ b/path).
108
- if (line.startsWith('--- a/') || line.startsWith('+++ b/')) {
109
- const isPlus = line.startsWith('+++ b/');
110
- // Extract the path, skipping `/dev/null`.
111
- let pathPart = '';
112
- if (isPlus) {
113
- pathPart = line.slice(6); // '+++ b/'.length
114
- }
115
- else {
116
- pathPart = line.slice(6); // '--- a/'.length
117
- }
118
- if (pathPart !== '/dev/null') {
119
- currentFilePath = pathPart;
120
- }
121
- buf.push(line);
122
- continue;
123
- }
124
- // Rule 5 — hunk header: @@ -oldStart[,oldCount] +newStart[,newCount] @@
125
- const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
126
- if (hunkMatch) {
127
- const newStart = parseInt(hunkMatch[1], 10);
128
- if (currentStartLine === 0) {
129
- currentStartLine = newStart;
130
- }
131
- currentEndLine = newStart;
132
- inHunk = true;
133
- buf.push(line);
134
- continue;
135
- }
136
- // Rule 6 — added lines (start with '+', but not '+++').
137
- if (line.startsWith('+') && !line.startsWith('+++')) {
138
- if (inHunk) {
139
- currentEndLine++;
140
- }
141
- buf.push(line);
142
- continue;
143
- }
144
- // Rule 7 — removed lines (start with '-', but not '---').
145
- if (line.startsWith('-') && !line.startsWith('---')) {
146
- buf.push(line);
147
- continue;
148
- }
149
- // Rule 8 — context lines (start with a space).
150
- if (line.startsWith(' ')) {
151
- if (inHunk) {
152
- currentEndLine++;
153
- }
154
- buf.push(line);
155
- continue;
156
- }
157
- // Rule 9 — all other lines (e.g. `rename from` / `rename to`,
158
- // `similarity index`, `Binary files differ`, `\ No newline at end of
159
- // file`, blank lines between sections, etc.).
160
- buf.push(line);
161
- }
162
- // Flush the final file.
163
- _flush();
164
- return fragments;
165
- }
166
- //# sourceMappingURL=diff-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff-parser.js","sourceRoot":"","sources":["../../../src/spec/mining/diff-parser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAkCH,8CAUC;AA1CD,+CAA8C;AAmB9C,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,QAAgB,EAChB,UAAkB,EAClB,cAAuB;IAEvB,MAAM,IAAI,GAAG,cAAc,IAAI,IAAA,2BAAa,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACnE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,kBAAkB;IAClB,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,IAAI,GAAG,GAAa,EAAE,CAAC;IACvB,IAAI,eAAe,GAAkB,IAAI,CAAC;IAC1C,IAAI,iBAAiB,GAAgC,QAAQ,CAAC;IAC9D,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,yBAAyB;IACzB,MAAM,MAAM,GAAG,GAAS,EAAE;QACxB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YACjD,GAAG,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QAED,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CAAC;YACpD,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,SAAS;QACX,CAAC;QAED,0DAA0D;QAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACpD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,SAAS;QACX,CAAC;QAED,+CAA+C;QAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;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"}
@@ -1,103 +0,0 @@
1
- /**
2
- * Git commit history scanning and spec↔commit pairing.
3
- *
4
- * Replaces `commit4spec/reverse_engineer/git_scanner.py` and
5
- * `commit4spec/reverse_engineer/git_utils.py`. Discovers spec↔commit pairs via
6
- * two strategies:
7
- *
8
- * - **Strategy A — commit message scope:** extract conventional-commit scopes
9
- * from commit messages and resolve them to spec IDs on disk.
10
- * - **Strategy B — commit-info.md:** discover specs on disk, read their
11
- * `commit-info.md` for linked commit hashes, and verify those commits exist.
12
- *
13
- * All Git operations use `execFileSync` with an args array (never template
14
- * strings) to avoid shell injection risks — matching the HomeGraph convention
15
- * in `src/sync/git-hooks.ts` and `src/sync/worktree.ts`.
16
- *
17
- * @module spec/mining/git-scanner
18
- */
19
- import { SpecConfig } from '../config';
20
- import { SpecMetadata } from './spec-extractor';
21
- export interface CommitInfo {
22
- /** Full 40-char commit hash */
23
- hash: string;
24
- /** First line of commit message */
25
- message: string;
26
- /** Author name */
27
- author: string;
28
- /** Unix epoch milliseconds */
29
- timestamp: number;
30
- }
31
- export interface SpecCommitPair {
32
- specId: string;
33
- commitHash: string;
34
- specMetadata: SpecMetadata | null;
35
- commitMetadata: CommitInfo | null;
36
- }
37
- /**
38
- * Check whether `repoPath` is a git repository.
39
- *
40
- * Runs `git rev-parse --git-dir` and returns `true` on success, `false`
41
- * when the command fails (not a repo, git not installed, etc.).
42
- */
43
- export declare function isGitRepo(repoPath: string): boolean;
44
- /**
45
- * Return every commit in `repoPath` as `CommitInfo` objects.
46
- *
47
- * Runs `git log --format='%H%n%aI%n%an%n%s%n---END---'` and parses the
48
- * output one five-line block per commit. Commits are returned in reverse
49
- * chronological order (most recent first), matching Git's default.
50
- *
51
- * An empty repo yields an empty array.
52
- */
53
- export declare function getAllCommits(repoPath: string): CommitInfo[];
54
- /**
55
- * Retrieve metadata for a single commit.
56
- *
57
- * Runs `git show -s --format='%H%n%aI%n%an%n%s' <commitHash>`. Returns
58
- * `null` when the command fails (hash not found, invalid repo, etc.).
59
- */
60
- export declare function getCommitInfo(repoPath: string, commitHash: string): CommitInfo | null;
61
- /**
62
- * Return the full unified diff introduced by `commitHash`.
63
- *
64
- * Strategy:
65
- * 1. Query the parent hash(es) via `git log --pretty=%P -n 1 <commitHash>`.
66
- * 2. If a parent exists, diff it against the commit: `git diff <parent> <commitHash>`.
67
- * 3. For an initial (root) commit with no parent, use `git diff <commitHash>`
68
- * which shows all files added in that commit.
69
- *
70
- * Returns an empty string when any Git command fails.
71
- */
72
- export declare function getCommitDiff(repoPath: string, commitHash: string): string;
73
- /**
74
- * Return every commit between `fromHash` (exclusive) and `toHash`
75
- * (inclusive) in chronological order (oldest first).
76
- *
77
- * Runs `git log --reverse --format="..." fromHash..toHash`. Returns an empty
78
- * array when either hash is not found or the range is empty.
79
- *
80
- * Callers should validate that `fromHash` is an ancestor of `toHash` before
81
- * calling this function (use `git merge-base --is-ancestor`). Results are
82
- * undefined when the two hashes are on unrelated branches.
83
- */
84
- export declare function getCommitRange(repoPath: string, fromHash: string, toHash: string): CommitInfo[];
85
- /**
86
- * Main scanning function — discovers spec↔commit pairs using two strategies.
87
- *
88
- * **Strategy A — commit message scope:**
89
- * Iterates every commit in the repo, extracts a conventional-commit scope from
90
- * its message, normalizes it, and checks whether the resulting spec ID exists
91
- * on disk. When a match is found the pair is recorded with full spec and
92
- * commit metadata.
93
- *
94
- * **Strategy B — commit-info.md:**
95
- * Discovers all specs on disk that were **not** already paired by Strategy A,
96
- * reads their metadata (which may include a commit hash from `commit-info.md`),
97
- * and verifies the commit exists in the repo. Verified pairs are added.
98
- *
99
- * Duplicates (identical specId + commitHash) are de-duplicated via a
100
- * `Map` keyed on `"${specId}|${commitHash}"`.
101
- */
102
- export declare function scan(repoPath: string, specStoragePath: string, config: SpecConfig): SpecCommitPair[];
103
- //# sourceMappingURL=git-scanner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-scanner.d.ts","sourceRoot":"","sources":["../../../src/spec/mining/git-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOrE,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,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;AA8BD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOnD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CAkC5D;AAMD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,UAAU,GAAG,IAAI,CA4BnB;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAmC1E;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,UAAU,EAAE,CAgCd;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,UAAU,GACjB,cAAc,EAAE,CA+ElB"}
@@ -1,307 +0,0 @@
1
- "use strict";
2
- /**
3
- * Git commit history scanning and spec↔commit pairing.
4
- *
5
- * Replaces `commit4spec/reverse_engineer/git_scanner.py` and
6
- * `commit4spec/reverse_engineer/git_utils.py`. Discovers spec↔commit pairs via
7
- * two strategies:
8
- *
9
- * - **Strategy A — commit message scope:** extract conventional-commit scopes
10
- * from commit messages and resolve them to spec IDs on disk.
11
- * - **Strategy B — commit-info.md:** discover specs on disk, read their
12
- * `commit-info.md` for linked commit hashes, and verify those commits exist.
13
- *
14
- * All Git operations use `execFileSync` with an args array (never template
15
- * strings) to avoid shell injection risks — matching the HomeGraph convention
16
- * in `src/sync/git-hooks.ts` and `src/sync/worktree.ts`.
17
- *
18
- * @module spec/mining/git-scanner
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.isGitRepo = isGitRepo;
22
- exports.getAllCommits = getAllCommits;
23
- exports.getCommitInfo = getCommitInfo;
24
- exports.getCommitDiff = getCommitDiff;
25
- exports.getCommitRange = getCommitRange;
26
- exports.scan = scan;
27
- const child_process_1 = require("child_process");
28
- const utils_1 = require("../utils");
29
- const scope_resolver_1 = require("./scope-resolver");
30
- const spec_extractor_1 = require("./spec-extractor");
31
- const errors_1 = require("../../errors");
32
- // ---------------------------------------------------------------------------
33
- // Helpers
34
- // ---------------------------------------------------------------------------
35
- /** Shared options for all `execFileSync` Git calls. */
36
- function gitExecOptions(repoPath) {
37
- const stdio = ['ignore', 'pipe', 'ignore'];
38
- return {
39
- cwd: repoPath,
40
- encoding: 'utf8',
41
- stdio,
42
- windowsHide: true,
43
- };
44
- }
45
- /**
46
- * Convert an ISO-8601 string to Unix epoch milliseconds.
47
- * Returns 0 for invalid or unparseable strings.
48
- */
49
- function parseISOTimestamp(isoString) {
50
- const ts = new Date(isoString).getTime();
51
- return isNaN(ts) ? 0 : ts;
52
- }
53
- // ---------------------------------------------------------------------------
54
- // isGitRepo
55
- // ---------------------------------------------------------------------------
56
- /**
57
- * Check whether `repoPath` is a git repository.
58
- *
59
- * Runs `git rev-parse --git-dir` and returns `true` on success, `false`
60
- * when the command fails (not a repo, git not installed, etc.).
61
- */
62
- function isGitRepo(repoPath) {
63
- try {
64
- (0, child_process_1.execFileSync)('git', ['rev-parse', '--git-dir'], gitExecOptions(repoPath));
65
- return true;
66
- }
67
- catch {
68
- return false;
69
- }
70
- }
71
- // ---------------------------------------------------------------------------
72
- // getAllCommits
73
- // ---------------------------------------------------------------------------
74
- /**
75
- * Return every commit in `repoPath` as `CommitInfo` objects.
76
- *
77
- * Runs `git log --format='%H%n%aI%n%an%n%s%n---END---'` and parses the
78
- * output one five-line block per commit. Commits are returned in reverse
79
- * chronological order (most recent first), matching Git's default.
80
- *
81
- * An empty repo yields an empty array.
82
- */
83
- function getAllCommits(repoPath) {
84
- let stdout;
85
- try {
86
- stdout = (0, child_process_1.execFileSync)('git', ['log', "--format=%H%n%aI%n%an%n%s%n---END---"], gitExecOptions(repoPath));
87
- }
88
- catch {
89
- return [];
90
- }
91
- const lines = stdout.trim().split('\n');
92
- const commits = [];
93
- // Each commit occupies 5 lines: hash, ISO timestamp, author, subject, separator.
94
- for (let i = 0; i + 4 < lines.length; i += 5) {
95
- const hash = lines[i].trim();
96
- const isoString = lines[i + 1].trim();
97
- const author = lines[i + 2].trim();
98
- const message = lines[i + 3].trim();
99
- // lines[i+4] is the ---END--- separator — skip it.
100
- if (!hash)
101
- continue;
102
- commits.push({
103
- hash,
104
- message,
105
- author,
106
- timestamp: parseISOTimestamp(isoString),
107
- });
108
- }
109
- return commits;
110
- }
111
- // ---------------------------------------------------------------------------
112
- // getCommitInfo
113
- // ---------------------------------------------------------------------------
114
- /**
115
- * Retrieve metadata for a single commit.
116
- *
117
- * Runs `git show -s --format='%H%n%aI%n%an%n%s' <commitHash>`. Returns
118
- * `null` when the command fails (hash not found, invalid repo, etc.).
119
- */
120
- function getCommitInfo(repoPath, commitHash) {
121
- let stdout;
122
- try {
123
- stdout = (0, child_process_1.execFileSync)('git', ['show', '-s', "--format=%H%n%aI%n%an%n%s", commitHash], gitExecOptions(repoPath));
124
- }
125
- catch {
126
- return null;
127
- }
128
- const lines = stdout.trim().split('\n');
129
- if (lines.length < 4)
130
- return null;
131
- const hash = lines[0].trim();
132
- const isoString = lines[1].trim();
133
- const author = lines[2].trim();
134
- const message = lines[3].trim();
135
- if (!hash)
136
- return null;
137
- return {
138
- hash,
139
- message,
140
- author,
141
- timestamp: parseISOTimestamp(isoString),
142
- };
143
- }
144
- // ---------------------------------------------------------------------------
145
- // getCommitDiff
146
- // ---------------------------------------------------------------------------
147
- /**
148
- * Return the full unified diff introduced by `commitHash`.
149
- *
150
- * Strategy:
151
- * 1. Query the parent hash(es) via `git log --pretty=%P -n 1 <commitHash>`.
152
- * 2. If a parent exists, diff it against the commit: `git diff <parent> <commitHash>`.
153
- * 3. For an initial (root) commit with no parent, use `git diff <commitHash>`
154
- * which shows all files added in that commit.
155
- *
156
- * Returns an empty string when any Git command fails.
157
- */
158
- function getCommitDiff(repoPath, commitHash) {
159
- // Step 1 — get parent hashes.
160
- let parentStdout;
161
- try {
162
- parentStdout = (0, child_process_1.execFileSync)('git', ['log', '--pretty=%P', '-n', '1', commitHash], gitExecOptions(repoPath));
163
- }
164
- catch {
165
- return '';
166
- }
167
- const parents = parentStdout.trim().split(/\s+/).filter(Boolean);
168
- // Step 2 & 3 — run the appropriate diff.
169
- try {
170
- if (parents.length > 0) {
171
- const parent = parents[0];
172
- return (0, child_process_1.execFileSync)('git', ['diff', parent, commitHash], gitExecOptions(repoPath));
173
- }
174
- // Initial commit — no parent.
175
- return (0, child_process_1.execFileSync)('git', ['diff', commitHash], gitExecOptions(repoPath));
176
- }
177
- catch {
178
- return '';
179
- }
180
- }
181
- // ---------------------------------------------------------------------------
182
- // getCommitRange
183
- // ---------------------------------------------------------------------------
184
- /**
185
- * Return every commit between `fromHash` (exclusive) and `toHash`
186
- * (inclusive) in chronological order (oldest first).
187
- *
188
- * Runs `git log --reverse --format="..." fromHash..toHash`. Returns an empty
189
- * array when either hash is not found or the range is empty.
190
- *
191
- * Callers should validate that `fromHash` is an ancestor of `toHash` before
192
- * calling this function (use `git merge-base --is-ancestor`). Results are
193
- * undefined when the two hashes are on unrelated branches.
194
- */
195
- function getCommitRange(repoPath, fromHash, toHash) {
196
- let stdout;
197
- try {
198
- stdout = (0, child_process_1.execFileSync)('git', ['log', '--reverse', `--format=%H%n%aI%n%an%n%s%n---END---`, `${fromHash}..${toHash}`], gitExecOptions(repoPath));
199
- }
200
- catch {
201
- return [];
202
- }
203
- const lines = stdout.trim().split('\n');
204
- const commits = [];
205
- for (let i = 0; i + 4 < lines.length; i += 5) {
206
- const hash = lines[i].trim();
207
- const isoString = lines[i + 1].trim();
208
- const author = lines[i + 2].trim();
209
- const message = lines[i + 3].trim();
210
- if (!hash)
211
- continue;
212
- commits.push({
213
- hash,
214
- message,
215
- author,
216
- timestamp: parseISOTimestamp(isoString),
217
- });
218
- }
219
- return commits;
220
- }
221
- // ---------------------------------------------------------------------------
222
- // scan
223
- // ---------------------------------------------------------------------------
224
- /**
225
- * Main scanning function — discovers spec↔commit pairs using two strategies.
226
- *
227
- * **Strategy A — commit message scope:**
228
- * Iterates every commit in the repo, extracts a conventional-commit scope from
229
- * its message, normalizes it, and checks whether the resulting spec ID exists
230
- * on disk. When a match is found the pair is recorded with full spec and
231
- * commit metadata.
232
- *
233
- * **Strategy B — commit-info.md:**
234
- * Discovers all specs on disk that were **not** already paired by Strategy A,
235
- * reads their metadata (which may include a commit hash from `commit-info.md`),
236
- * and verifies the commit exists in the repo. Verified pairs are added.
237
- *
238
- * Duplicates (identical specId + commitHash) are de-duplicated via a
239
- * `Map` keyed on `"${specId}|${commitHash}"`.
240
- */
241
- function scan(repoPath, specStoragePath, config) {
242
- const pairs = new Map();
243
- // ---- Strategy A: commit message scope ----
244
- const commits = getAllCommits(repoPath);
245
- for (const commit of commits) {
246
- const specId = (0, scope_resolver_1.resolveScopeToSpec)(commit.message, specStoragePath, config);
247
- if (!specId) {
248
- (0, errors_1.logDebug)('Strategy A: no scope match', {
249
- commitHash: commit.hash.slice(0, 7),
250
- message: commit.message,
251
- });
252
- continue;
253
- }
254
- const specMetadata = (0, spec_extractor_1.extractSpecMetadata)(specStoragePath, specId, config);
255
- const key = `${specId}|${commit.hash}`;
256
- if (!pairs.has(key)) {
257
- pairs.set(key, {
258
- specId,
259
- commitHash: commit.hash,
260
- specMetadata,
261
- commitMetadata: commit,
262
- });
263
- }
264
- }
265
- // ---- Strategy B: commit-info.md ----
266
- // Collect specIds already paired by Strategy A.
267
- const pairedSpecIds = new Set();
268
- for (const pair of pairs.values()) {
269
- pairedSpecIds.add(pair.specId);
270
- }
271
- const specs = (0, utils_1.discoverSpecs)(specStoragePath);
272
- for (const spec of specs) {
273
- if (pairedSpecIds.has(spec.specId)) {
274
- continue;
275
- }
276
- const metadata = (0, spec_extractor_1.extractSpecMetadata)(specStoragePath, spec.specId, config);
277
- if (!metadata) {
278
- // extractSpecMetadata already logs the reason.
279
- continue;
280
- }
281
- if (!metadata.commitHash) {
282
- (0, errors_1.logDebug)('Strategy B: no commit hash in spec metadata', {
283
- specId: spec.specId,
284
- });
285
- continue;
286
- }
287
- const commitInfo = getCommitInfo(repoPath, metadata.commitHash);
288
- if (!commitInfo) {
289
- (0, errors_1.logWarn)('Strategy B: commit-info.md hash does not match any known commit', {
290
- specId: spec.specId,
291
- commitHash: metadata.commitHash,
292
- });
293
- continue;
294
- }
295
- const key = `${spec.specId}|${metadata.commitHash}`;
296
- if (!pairs.has(key)) {
297
- pairs.set(key, {
298
- specId: spec.specId,
299
- commitHash: metadata.commitHash,
300
- specMetadata: metadata,
301
- commitMetadata: commitInfo,
302
- });
303
- }
304
- }
305
- return Array.from(pairs.values());
306
- }
307
- //# sourceMappingURL=git-scanner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-scanner.js","sourceRoot":"","sources":["../../../src/spec/mining/git-scanner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAiEH,8BAOC;AAeD,sCAkCC;AAYD,sCA+BC;AAiBD,sCAmCC;AAiBD,wCAoCC;AAuBD,oBAmFC;AArXD,iDAAgE;AAEhE,oCAAyC;AACzC,qDAAsD;AACtD,qDAAqE;AACrE,yCAAiD;AAwBjD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,uDAAuD;AACvD,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,KAAK,GAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzD,OAAO;QACL,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,MAAe;QACzB,KAAK;QACL,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,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