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,203 +1,203 @@
1
- -- HomeGraph SQLite Schema
2
- -- Version 1
3
-
4
- -- Schema version tracking
5
- CREATE TABLE IF NOT EXISTS schema_versions (
6
- version INTEGER PRIMARY KEY,
7
- applied_at INTEGER NOT NULL,
8
- description TEXT
9
- );
10
-
11
- -- Insert initial version
12
- INSERT INTO schema_versions (version, applied_at, description)
13
- VALUES (1, strftime('%s', 'now') * 1000, 'Initial schema');
14
-
15
- -- =============================================================================
16
- -- Core Tables
17
- -- =============================================================================
18
-
19
- -- Nodes: Code symbols (functions, classes, variables, etc.)
20
- CREATE TABLE IF NOT EXISTS nodes (
21
- id TEXT PRIMARY KEY,
22
- kind TEXT NOT NULL,
23
- name TEXT NOT NULL,
24
- qualified_name TEXT NOT NULL,
25
- file_path TEXT NOT NULL,
26
- language TEXT NOT NULL,
27
- start_line INTEGER NOT NULL,
28
- end_line INTEGER NOT NULL,
29
- start_column INTEGER NOT NULL,
30
- end_column INTEGER NOT NULL,
31
- docstring TEXT,
32
- signature TEXT,
33
- visibility TEXT,
34
- is_exported INTEGER DEFAULT 0,
35
- is_async INTEGER DEFAULT 0,
36
- is_static INTEGER DEFAULT 0,
37
- is_abstract INTEGER DEFAULT 0,
38
- decorators TEXT, -- JSON array
39
- type_parameters TEXT, -- JSON array
40
- return_type TEXT, -- normalized return/result type name (e.g. C++ method return, for receiver-type inference)
41
- updated_at INTEGER NOT NULL
42
- );
43
-
44
- -- Edges: Relationships between nodes
45
- CREATE TABLE IF NOT EXISTS edges (
46
- id INTEGER PRIMARY KEY AUTOINCREMENT,
47
- source TEXT NOT NULL,
48
- target TEXT NOT NULL,
49
- kind TEXT NOT NULL,
50
- metadata TEXT, -- JSON object
51
- line INTEGER,
52
- col INTEGER,
53
- provenance TEXT DEFAULT NULL,
54
- FOREIGN KEY (source) REFERENCES nodes(id) ON DELETE CASCADE,
55
- FOREIGN KEY (target) REFERENCES nodes(id) ON DELETE CASCADE
56
- );
57
-
58
- -- Files: Tracked source files
59
- CREATE TABLE IF NOT EXISTS files (
60
- path TEXT PRIMARY KEY,
61
- content_hash TEXT NOT NULL,
62
- language TEXT NOT NULL,
63
- size INTEGER NOT NULL,
64
- modified_at INTEGER NOT NULL,
65
- indexed_at INTEGER NOT NULL,
66
- node_count INTEGER DEFAULT 0,
67
- errors TEXT -- JSON array
68
- );
69
-
70
- -- Unresolved References: References that need resolution after full indexing.
71
- -- status lifecycle: rows are inserted 'pending' by extraction; a completed
72
- -- resolution pass either deletes a row (resolved) or marks it 'failed'
73
- -- (attempted, no match — kept so a later sync can retry it when a changed
74
- -- file introduces a symbol that could satisfy it, #1240). name_tail is the
75
- -- last segment of reference_name ('util.greet' → 'greet'), written when a
76
- -- row is marked failed, so the retry lookup matches new node names against
77
- -- dotted refs too. Rows follow their from_node via ON DELETE CASCADE, so
78
- -- re-extracting or deleting a file clears its stale rows in any status.
79
- CREATE TABLE IF NOT EXISTS unresolved_refs (
80
- id INTEGER PRIMARY KEY AUTOINCREMENT,
81
- from_node_id TEXT NOT NULL,
82
- reference_name TEXT NOT NULL,
83
- reference_kind TEXT NOT NULL,
84
- line INTEGER NOT NULL,
85
- col INTEGER NOT NULL,
86
- candidates TEXT, -- JSON array
87
- file_path TEXT NOT NULL DEFAULT '',
88
- language TEXT NOT NULL DEFAULT 'unknown',
89
- status TEXT NOT NULL DEFAULT 'pending',
90
- name_tail TEXT NOT NULL DEFAULT '',
91
- FOREIGN KEY (from_node_id) REFERENCES nodes(id) ON DELETE CASCADE
92
- );
93
-
94
- -- =============================================================================
95
- -- Indexes for Query Performance
96
- -- =============================================================================
97
-
98
- -- Node indexes
99
- CREATE INDEX IF NOT EXISTS idx_nodes_kind ON nodes(kind);
100
- CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name);
101
- CREATE INDEX IF NOT EXISTS idx_nodes_qualified_name ON nodes(qualified_name);
102
- CREATE INDEX IF NOT EXISTS idx_nodes_file_path ON nodes(file_path);
103
- CREATE INDEX IF NOT EXISTS idx_nodes_language ON nodes(language);
104
- CREATE INDEX IF NOT EXISTS idx_nodes_file_line ON nodes(file_path, start_line);
105
- CREATE INDEX IF NOT EXISTS idx_nodes_lower_name ON nodes(lower(name));
106
-
107
- -- Full-text search index on node names, docstrings, and signatures
108
- CREATE VIRTUAL TABLE IF NOT EXISTS nodes_fts USING fts5(
109
- id,
110
- name,
111
- qualified_name,
112
- docstring,
113
- signature,
114
- content='nodes',
115
- content_rowid='rowid'
116
- );
117
-
118
- -- Triggers to keep FTS index in sync
119
- CREATE TRIGGER IF NOT EXISTS nodes_ai AFTER INSERT ON nodes BEGIN
120
- INSERT INTO nodes_fts(rowid, id, name, qualified_name, docstring, signature)
121
- VALUES (NEW.rowid, NEW.id, NEW.name, NEW.qualified_name, NEW.docstring, NEW.signature);
122
- END;
123
-
124
- CREATE TRIGGER IF NOT EXISTS nodes_ad AFTER DELETE ON nodes BEGIN
125
- INSERT INTO nodes_fts(nodes_fts, rowid, id, name, qualified_name, docstring, signature)
126
- VALUES ('delete', OLD.rowid, OLD.id, OLD.name, OLD.qualified_name, OLD.docstring, OLD.signature);
127
- END;
128
-
129
- CREATE TRIGGER IF NOT EXISTS nodes_au AFTER UPDATE ON nodes BEGIN
130
- INSERT INTO nodes_fts(nodes_fts, rowid, id, name, qualified_name, docstring, signature)
131
- VALUES ('delete', OLD.rowid, OLD.id, OLD.name, OLD.qualified_name, OLD.docstring, OLD.signature);
132
- INSERT INTO nodes_fts(rowid, id, name, qualified_name, docstring, signature)
133
- VALUES (NEW.rowid, NEW.id, NEW.name, NEW.qualified_name, NEW.docstring, NEW.signature);
134
- END;
135
-
136
- -- Prose-word → symbol-name lookup for the prompt hook's graph-derived gate.
137
- -- One row per (segment, name): segment is a lowercased word of a symbol name
138
- -- ("OrderStateMachine" → order, state, machine — see identifier-segments.ts),
139
- -- which lets natural-language prompt words be verified against the graph in
140
- -- any language whose technical nouns are Latin script. File nodes are
141
- -- excluded — a file's basename duplicates the symbols inside it and skews the
142
- -- singleton-vs-cluster rarity statistics. FTS can't serve this lookup (its
143
- -- tokenizer keeps camelCase names as single tokens), so segments are
144
- -- materialized on the node write path.
145
- -- Deletions leave orphan rows ON PURPOSE: rows are PROPOSALS, always
146
- -- re-verified against nodes before being surfaced (HomeGraph.getSegmentMatches),
147
- -- and a full index clears the table at its start. Populated lazily on old
148
- -- databases (empty until the next index/sync heals it).
149
- CREATE TABLE IF NOT EXISTS name_segment_vocab (
150
- segment TEXT NOT NULL,
151
- name TEXT NOT NULL,
152
- PRIMARY KEY (segment, name)
153
- ) WITHOUT ROWID;
154
-
155
- -- Edge indexes.
156
- -- idx_edges_source / idx_edges_target are intentionally omitted —
157
- -- the (source, kind) and (target, kind) composites below cover the
158
- -- corresponding source-only / target-only lookups via SQLite's
159
- -- left-prefix scan, so the narrow indexes are dead weight on writes.
160
- -- Migration v4 drops them on existing databases.
161
- CREATE INDEX IF NOT EXISTS idx_edges_kind ON edges(kind);
162
- CREATE INDEX IF NOT EXISTS idx_edges_source_kind ON edges(source, kind);
163
- CREATE INDEX IF NOT EXISTS idx_edges_target_kind ON edges(target, kind);
164
-
165
- -- Edge identity uniqueness. An edge IS uniquely (source, target, kind, line,
166
- -- col); insertEdge uses `INSERT OR IGNORE`, but without something UNIQUE to
167
- -- conflict on it behaved like a plain INSERT, so two passes emitting the same
168
- -- edge produced byte-identical duplicate rows that inflated counts and flowed
169
- -- into callers/impact (#1034). IFNULL folds the nullable line/col so
170
- -- coordinate-less edges (synthesized / file-level) dedup too — SQLite treats
171
- -- each NULL as distinct otherwise. Migration v6 dedups existing rows + adds
172
- -- this on older databases.
173
- CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_identity
174
- ON edges(source, target, kind, IFNULL(line, -1), IFNULL(col, -1));
175
-
176
- -- File indexes
177
- CREATE INDEX IF NOT EXISTS idx_files_language ON files(language);
178
- CREATE INDEX IF NOT EXISTS idx_files_modified_at ON files(modified_at);
179
-
180
- -- Unresolved refs indexes
181
- CREATE INDEX IF NOT EXISTS idx_unresolved_from_node ON unresolved_refs(from_node_id);
182
- CREATE INDEX IF NOT EXISTS idx_unresolved_name ON unresolved_refs(reference_name);
183
- CREATE INDEX IF NOT EXISTS idx_unresolved_file_path ON unresolved_refs(file_path);
184
- CREATE INDEX IF NOT EXISTS idx_unresolved_from_name ON unresolved_refs(from_node_id, reference_name);
185
- CREATE INDEX IF NOT EXISTS idx_unresolved_status ON unresolved_refs(status);
186
- CREATE INDEX IF NOT EXISTS idx_unresolved_failed_tail ON unresolved_refs(name_tail) WHERE status = 'failed';
187
- CREATE INDEX IF NOT EXISTS idx_edges_provenance ON edges(provenance);
188
-
189
- -- Project metadata for version/provenance tracking
190
- CREATE TABLE IF NOT EXISTS project_metadata (
191
- key TEXT PRIMARY KEY,
192
- value TEXT NOT NULL,
193
- updated_at INTEGER NOT NULL
194
- );
195
-
196
- -- MCP tool response cache (invalidated wholesale on index stamp change)
197
- CREATE TABLE IF NOT EXISTS mcp_query_cache (
198
- cache_key TEXT PRIMARY KEY,
199
- tool TEXT NOT NULL,
200
- response TEXT NOT NULL,
201
- created_at INTEGER NOT NULL
202
- );
203
- CREATE INDEX IF NOT EXISTS idx_mcp_query_cache_tool ON mcp_query_cache(tool);
1
+ -- HomeGraph SQLite Schema
2
+ -- Version 1
3
+
4
+ -- Schema version tracking
5
+ CREATE TABLE IF NOT EXISTS schema_versions (
6
+ version INTEGER PRIMARY KEY,
7
+ applied_at INTEGER NOT NULL,
8
+ description TEXT
9
+ );
10
+
11
+ -- Insert initial version
12
+ INSERT INTO schema_versions (version, applied_at, description)
13
+ VALUES (1, strftime('%s', 'now') * 1000, 'Initial schema');
14
+
15
+ -- =============================================================================
16
+ -- Core Tables
17
+ -- =============================================================================
18
+
19
+ -- Nodes: Code symbols (functions, classes, variables, etc.)
20
+ CREATE TABLE IF NOT EXISTS nodes (
21
+ id TEXT PRIMARY KEY,
22
+ kind TEXT NOT NULL,
23
+ name TEXT NOT NULL,
24
+ qualified_name TEXT NOT NULL,
25
+ file_path TEXT NOT NULL,
26
+ language TEXT NOT NULL,
27
+ start_line INTEGER NOT NULL,
28
+ end_line INTEGER NOT NULL,
29
+ start_column INTEGER NOT NULL,
30
+ end_column INTEGER NOT NULL,
31
+ docstring TEXT,
32
+ signature TEXT,
33
+ visibility TEXT,
34
+ is_exported INTEGER DEFAULT 0,
35
+ is_async INTEGER DEFAULT 0,
36
+ is_static INTEGER DEFAULT 0,
37
+ is_abstract INTEGER DEFAULT 0,
38
+ decorators TEXT, -- JSON array
39
+ type_parameters TEXT, -- JSON array
40
+ return_type TEXT, -- normalized return/result type name (e.g. C++ method return, for receiver-type inference)
41
+ updated_at INTEGER NOT NULL
42
+ );
43
+
44
+ -- Edges: Relationships between nodes
45
+ CREATE TABLE IF NOT EXISTS edges (
46
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
47
+ source TEXT NOT NULL,
48
+ target TEXT NOT NULL,
49
+ kind TEXT NOT NULL,
50
+ metadata TEXT, -- JSON object
51
+ line INTEGER,
52
+ col INTEGER,
53
+ provenance TEXT DEFAULT NULL,
54
+ FOREIGN KEY (source) REFERENCES nodes(id) ON DELETE CASCADE,
55
+ FOREIGN KEY (target) REFERENCES nodes(id) ON DELETE CASCADE
56
+ );
57
+
58
+ -- Files: Tracked source files
59
+ CREATE TABLE IF NOT EXISTS files (
60
+ path TEXT PRIMARY KEY,
61
+ content_hash TEXT NOT NULL,
62
+ language TEXT NOT NULL,
63
+ size INTEGER NOT NULL,
64
+ modified_at INTEGER NOT NULL,
65
+ indexed_at INTEGER NOT NULL,
66
+ node_count INTEGER DEFAULT 0,
67
+ errors TEXT -- JSON array
68
+ );
69
+
70
+ -- Unresolved References: References that need resolution after full indexing.
71
+ -- status lifecycle: rows are inserted 'pending' by extraction; a completed
72
+ -- resolution pass either deletes a row (resolved) or marks it 'failed'
73
+ -- (attempted, no match — kept so a later sync can retry it when a changed
74
+ -- file introduces a symbol that could satisfy it, #1240). name_tail is the
75
+ -- last segment of reference_name ('util.greet' → 'greet'), written when a
76
+ -- row is marked failed, so the retry lookup matches new node names against
77
+ -- dotted refs too. Rows follow their from_node via ON DELETE CASCADE, so
78
+ -- re-extracting or deleting a file clears its stale rows in any status.
79
+ CREATE TABLE IF NOT EXISTS unresolved_refs (
80
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
81
+ from_node_id TEXT NOT NULL,
82
+ reference_name TEXT NOT NULL,
83
+ reference_kind TEXT NOT NULL,
84
+ line INTEGER NOT NULL,
85
+ col INTEGER NOT NULL,
86
+ candidates TEXT, -- JSON array
87
+ file_path TEXT NOT NULL DEFAULT '',
88
+ language TEXT NOT NULL DEFAULT 'unknown',
89
+ status TEXT NOT NULL DEFAULT 'pending',
90
+ name_tail TEXT NOT NULL DEFAULT '',
91
+ FOREIGN KEY (from_node_id) REFERENCES nodes(id) ON DELETE CASCADE
92
+ );
93
+
94
+ -- =============================================================================
95
+ -- Indexes for Query Performance
96
+ -- =============================================================================
97
+
98
+ -- Node indexes
99
+ CREATE INDEX IF NOT EXISTS idx_nodes_kind ON nodes(kind);
100
+ CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name);
101
+ CREATE INDEX IF NOT EXISTS idx_nodes_qualified_name ON nodes(qualified_name);
102
+ CREATE INDEX IF NOT EXISTS idx_nodes_file_path ON nodes(file_path);
103
+ CREATE INDEX IF NOT EXISTS idx_nodes_language ON nodes(language);
104
+ CREATE INDEX IF NOT EXISTS idx_nodes_file_line ON nodes(file_path, start_line);
105
+ CREATE INDEX IF NOT EXISTS idx_nodes_lower_name ON nodes(lower(name));
106
+
107
+ -- Full-text search index on node names, docstrings, and signatures
108
+ CREATE VIRTUAL TABLE IF NOT EXISTS nodes_fts USING fts5(
109
+ id,
110
+ name,
111
+ qualified_name,
112
+ docstring,
113
+ signature,
114
+ content='nodes',
115
+ content_rowid='rowid'
116
+ );
117
+
118
+ -- Triggers to keep FTS index in sync
119
+ CREATE TRIGGER IF NOT EXISTS nodes_ai AFTER INSERT ON nodes BEGIN
120
+ INSERT INTO nodes_fts(rowid, id, name, qualified_name, docstring, signature)
121
+ VALUES (NEW.rowid, NEW.id, NEW.name, NEW.qualified_name, NEW.docstring, NEW.signature);
122
+ END;
123
+
124
+ CREATE TRIGGER IF NOT EXISTS nodes_ad AFTER DELETE ON nodes BEGIN
125
+ INSERT INTO nodes_fts(nodes_fts, rowid, id, name, qualified_name, docstring, signature)
126
+ VALUES ('delete', OLD.rowid, OLD.id, OLD.name, OLD.qualified_name, OLD.docstring, OLD.signature);
127
+ END;
128
+
129
+ CREATE TRIGGER IF NOT EXISTS nodes_au AFTER UPDATE ON nodes BEGIN
130
+ INSERT INTO nodes_fts(nodes_fts, rowid, id, name, qualified_name, docstring, signature)
131
+ VALUES ('delete', OLD.rowid, OLD.id, OLD.name, OLD.qualified_name, OLD.docstring, OLD.signature);
132
+ INSERT INTO nodes_fts(rowid, id, name, qualified_name, docstring, signature)
133
+ VALUES (NEW.rowid, NEW.id, NEW.name, NEW.qualified_name, NEW.docstring, NEW.signature);
134
+ END;
135
+
136
+ -- Prose-word → symbol-name lookup for the prompt hook's graph-derived gate.
137
+ -- One row per (segment, name): segment is a lowercased word of a symbol name
138
+ -- ("OrderStateMachine" → order, state, machine — see identifier-segments.ts),
139
+ -- which lets natural-language prompt words be verified against the graph in
140
+ -- any language whose technical nouns are Latin script. File nodes are
141
+ -- excluded — a file's basename duplicates the symbols inside it and skews the
142
+ -- singleton-vs-cluster rarity statistics. FTS can't serve this lookup (its
143
+ -- tokenizer keeps camelCase names as single tokens), so segments are
144
+ -- materialized on the node write path.
145
+ -- Deletions leave orphan rows ON PURPOSE: rows are PROPOSALS, always
146
+ -- re-verified against nodes before being surfaced (HomeGraph.getSegmentMatches),
147
+ -- and a full index clears the table at its start. Populated lazily on old
148
+ -- databases (empty until the next index/sync heals it).
149
+ CREATE TABLE IF NOT EXISTS name_segment_vocab (
150
+ segment TEXT NOT NULL,
151
+ name TEXT NOT NULL,
152
+ PRIMARY KEY (segment, name)
153
+ ) WITHOUT ROWID;
154
+
155
+ -- Edge indexes.
156
+ -- idx_edges_source / idx_edges_target are intentionally omitted —
157
+ -- the (source, kind) and (target, kind) composites below cover the
158
+ -- corresponding source-only / target-only lookups via SQLite's
159
+ -- left-prefix scan, so the narrow indexes are dead weight on writes.
160
+ -- Migration v4 drops them on existing databases.
161
+ CREATE INDEX IF NOT EXISTS idx_edges_kind ON edges(kind);
162
+ CREATE INDEX IF NOT EXISTS idx_edges_source_kind ON edges(source, kind);
163
+ CREATE INDEX IF NOT EXISTS idx_edges_target_kind ON edges(target, kind);
164
+
165
+ -- Edge identity uniqueness. An edge IS uniquely (source, target, kind, line,
166
+ -- col); insertEdge uses `INSERT OR IGNORE`, but without something UNIQUE to
167
+ -- conflict on it behaved like a plain INSERT, so two passes emitting the same
168
+ -- edge produced byte-identical duplicate rows that inflated counts and flowed
169
+ -- into callers/impact (#1034). IFNULL folds the nullable line/col so
170
+ -- coordinate-less edges (synthesized / file-level) dedup too — SQLite treats
171
+ -- each NULL as distinct otherwise. Migration v6 dedups existing rows + adds
172
+ -- this on older databases.
173
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_identity
174
+ ON edges(source, target, kind, IFNULL(line, -1), IFNULL(col, -1));
175
+
176
+ -- File indexes
177
+ CREATE INDEX IF NOT EXISTS idx_files_language ON files(language);
178
+ CREATE INDEX IF NOT EXISTS idx_files_modified_at ON files(modified_at);
179
+
180
+ -- Unresolved refs indexes
181
+ CREATE INDEX IF NOT EXISTS idx_unresolved_from_node ON unresolved_refs(from_node_id);
182
+ CREATE INDEX IF NOT EXISTS idx_unresolved_name ON unresolved_refs(reference_name);
183
+ CREATE INDEX IF NOT EXISTS idx_unresolved_file_path ON unresolved_refs(file_path);
184
+ CREATE INDEX IF NOT EXISTS idx_unresolved_from_name ON unresolved_refs(from_node_id, reference_name);
185
+ CREATE INDEX IF NOT EXISTS idx_unresolved_status ON unresolved_refs(status);
186
+ CREATE INDEX IF NOT EXISTS idx_unresolved_failed_tail ON unresolved_refs(name_tail) WHERE status = 'failed';
187
+ CREATE INDEX IF NOT EXISTS idx_edges_provenance ON edges(provenance);
188
+
189
+ -- Project metadata for version/provenance tracking
190
+ CREATE TABLE IF NOT EXISTS project_metadata (
191
+ key TEXT PRIMARY KEY,
192
+ value TEXT NOT NULL,
193
+ updated_at INTEGER NOT NULL
194
+ );
195
+
196
+ -- MCP tool response cache (invalidated wholesale on index stamp change)
197
+ CREATE TABLE IF NOT EXISTS mcp_query_cache (
198
+ cache_key TEXT PRIMARY KEY,
199
+ tool TEXT NOT NULL,
200
+ response TEXT NOT NULL,
201
+ created_at INTEGER NOT NULL
202
+ );
203
+ CREATE INDEX IF NOT EXISTS idx_mcp_query_cache_tool ON mcp_query_cache(tool);
package/dist/directory.js CHANGED
@@ -599,11 +599,11 @@ function planFrontload(cwd, prompt) {
599
599
  * explicit allowlist that never listed `daemon.pid` or the socket, so those
600
600
  * runtime files were silently committed.
601
601
  */
602
- const GITIGNORE_CONTENT = `# HomeGraph data files — local to each machine, not for committing.
603
- # Ignore everything in .homegraph/ except this file itself, so transient
604
- # files (the database, daemon.pid, sockets, logs) never show up in git.
605
- *
606
- !.gitignore
602
+ const GITIGNORE_CONTENT = `# HomeGraph data files — local to each machine, not for committing.
603
+ # Ignore everything in .homegraph/ except this file itself, so transient
604
+ # files (the database, daemon.pid, sockets, logs) never show up in git.
605
+ *
606
+ !.gitignore
607
607
  `;
608
608
  /** Header line that prefixes every .gitignore HomeGraph has auto-generated. */
609
609
  const GITIGNORE_MARKER = '# HomeGraph data files';
@@ -12,7 +12,7 @@ export { buildDefaultIgnore } from './default-ignore';
12
12
  * Progress callback for indexing operations
13
13
  */
14
14
  export interface IndexProgress {
15
- phase: 'scanning' | 'parsing' | 'arkts-batch' | 'storing' | 'resolving' | 'linking';
15
+ phase: 'scanning' | 'parsing' | 'arkts-batch' | 'ohos-api' | 'storing' | 'resolving' | 'linking';
16
16
  current: number;
17
17
  total: number;
18
18
  currentFile?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extraction/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAMzB,OAAO,EAGL,gBAAgB,EAChB,eAAe,EAKhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAU7C,OAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAgDtD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IACpF,OAAO,EAAE,M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W,CAAC,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,UAAU,CAAC;IA+MtB;;;OAGG;IACH,eAAe,IAAI;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;CAwF9E;AAGD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,qBAAqB,EAAE,YAAY,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -1314,57 +1314,25 @@ class ExtractionOrchestrator {
1314
1314
  durationMs: Date.now() - startTime,
1315
1315
  };
1316
1316
  }
1317
- // Phase 2: Parse files in a worker thread (keeps main thread unblocked for UI)
1317
+ // Do NOT emit `parsing` before the ArkTS Scene batch that makes the
1318
+ // shimmer print "Parsing code - done" when Scene starts, which looks like
1319
+ // a restart. Parsing progress starts after primeArkTSBatch below.
1318
1320
  const total = files.length;
1319
1321
  let processed = 0;
1320
- // Emit parsing phase immediately so the progress bar appears during worker setup.
1321
- // The yield lets the shimmer worker flush the phase transition to stdout before
1322
- // the main thread starts synchronous grammar detection work.
1323
- onProgress?.({
1324
- phase: 'parsing',
1325
- current: 0,
1326
- total,
1327
- });
1328
- await new Promise(resolve => setImmediate(resolve));
1329
- // Detect needed languages and load grammars in the parse worker
1322
+ // Detect needed languages. Parse workers start AFTER the ArkTS Scene batch
1323
+ // so peak RSS is not Scene IR + N×WASM grammars at once.
1330
1324
  const neededLanguages = [...new Set(files.map((f) => (0, grammars_1.detectLanguage)(f, undefined, overrides)))];
1331
1325
  // .h files default to 'c' but may be C++ — ensure cpp grammar is loaded when c is needed
1332
1326
  if (neededLanguages.includes('c') && !neededLanguages.includes('cpp')) {
1333
1327
  neededLanguages.push('cpp');
1334
1328
  }
1335
- // Parse files on a pool of worker threads (keeps the main thread free for UI
1336
- // and uses every core). Falls back to in-process parsing when the compiled
1337
- // worker is unavailable (e.g. running from source in tests).
1338
1329
  const parseWorkerPath = path.join(__dirname, 'parse-worker.js');
1339
1330
  const useWorker = fs.existsSync(parseWorkerPath);
1331
+ // Assigned after ArkTS batch (see below).
1340
1332
  let pool = null;
1341
- if (useWorker) {
1342
- // CODEGRAPH_PARSE_WORKERS: explicit worker count; 1 = the old single-worker
1343
- // behaviour (the conservative rollback). Unset → clamp(cores-1, 1, 8).
1344
- const poolSize = (0, parse_pool_1.resolveParsePoolSize)(process.env.CODEGRAPH_PARSE_WORKERS, os.cpus().length);
1345
- pool = new parse_pool_1.ParseWorkerPool({
1346
- languages: neededLanguages,
1347
- size: poolSize,
1348
- workerScriptPath: parseWorkerPath,
1349
- recycleInterval: WORKER_RECYCLE_INTERVAL,
1350
- parseTimeoutMs: PARSE_TIMEOUT_MS,
1351
- log,
1352
- });
1353
- log(`Parse worker pool: ${poolSize} worker(s)`);
1354
- }
1355
- else {
1356
- // In-process fallback: load grammars locally and parse on the main thread.
1357
- await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1358
- }
1359
- const storeWorkerPath = path.join(__dirname, 'store-worker.js');
1360
1333
  let storeWriter = null;
1361
- if (storeWriterOpts &&
1362
- process.env.HOMEGRAPH_NO_STORE_WORKER !== '1' &&
1363
- fs.existsSync(storeWorkerPath)) {
1364
- storeWriter = new store_writer_1.StoreWriter(storeWorkerPath, storeWriterOpts.dbPath, storeWriterOpts.fastInit);
1365
- log('Store writer thread active');
1366
- }
1367
1334
  const STORE_WRITER_WINDOW = 64;
1335
+ let windowSize = 1;
1368
1336
  /**
1369
1337
  * Parse one file: on the pool when available (the promise REJECTS on a worker
1370
1338
  * crash/timeout — the caller records it and the retry pass re-attempts), or
@@ -1387,8 +1355,7 @@ class ExtractionOrchestrator {
1387
1355
  // stable commit order keeps the resulting graph deterministic — byte-identical
1388
1356
  // to the single-worker path — instead of drifting with parse timing. The
1389
1357
  // `completed` buffer holds at most ~windowSize out-of-order results, so memory
1390
- // stays bounded.
1391
- const windowSize = pool ? Math.max(4, pool.size * 2) : 1;
1358
+ // stays bounded. windowSize is set when the parse pool starts (after ArkTS).
1392
1359
  const inFlight = new Set();
1393
1360
  const completed = new Map();
1394
1361
  let nextSeq = 0; // file-order sequence assigned at dispatch
@@ -1507,6 +1474,46 @@ class ExtractionOrchestrator {
1507
1474
  await (0, arkts_1.primeArkTSBatch)(this.rootDir, this.queries, firstEtsFile);
1508
1475
  errors.push(...(0, arkts_1.drainArkTSIndexNotices)());
1509
1476
  }
1477
+ // Start parse pool only after Scene teardown — most .ets are already in DB.
1478
+ const remainingToParse = files.filter((f) => !((0, arkts_1.isArkTSBatchPersisted)(f) || ((0, arkts_1.isArkTSBatchCommitted)() && (0, arkts_1.isArkAnalyzerSourcePath)(f)))).length;
1479
+ if (useWorker) {
1480
+ // CODEGRAPH_PARSE_WORKERS: explicit worker count; 1 = the old single-worker
1481
+ // behaviour (the conservative rollback). Unset → clamp(cores-1, 1, 8).
1482
+ let poolSize = (0, parse_pool_1.resolveParsePoolSize)(process.env.CODEGRAPH_PARSE_WORKERS, os.cpus().length);
1483
+ if (!process.env.CODEGRAPH_PARSE_WORKERS?.trim() && remainingToParse < 500) {
1484
+ poolSize = Math.min(poolSize, 2);
1485
+ }
1486
+ else if (!process.env.CODEGRAPH_PARSE_WORKERS?.trim() && remainingToParse < 2000) {
1487
+ poolSize = Math.min(poolSize, 4);
1488
+ }
1489
+ pool = new parse_pool_1.ParseWorkerPool({
1490
+ languages: neededLanguages,
1491
+ size: poolSize,
1492
+ workerScriptPath: parseWorkerPath,
1493
+ recycleInterval: WORKER_RECYCLE_INTERVAL,
1494
+ parseTimeoutMs: PARSE_TIMEOUT_MS,
1495
+ log,
1496
+ });
1497
+ windowSize = Math.max(4, pool.size * 2);
1498
+ log(`Parse worker pool: ${poolSize} worker(s) (remaining files≈${remainingToParse})`);
1499
+ }
1500
+ else {
1501
+ await (0, grammars_1.loadGrammarsForLanguages)(neededLanguages);
1502
+ }
1503
+ const storeWorkerPath = path.join(__dirname, 'store-worker.js');
1504
+ if (storeWriterOpts &&
1505
+ process.env.HOMEGRAPH_NO_STORE_WORKER !== '1' &&
1506
+ fs.existsSync(storeWorkerPath)) {
1507
+ storeWriter = new store_writer_1.StoreWriter(storeWorkerPath, storeWriterOpts.dbPath, storeWriterOpts.fastInit);
1508
+ log('Store writer thread active');
1509
+ }
1510
+ // Parsing progress only after ArkTS batch (avoids false "Parsing - done").
1511
+ onProgress?.({
1512
+ phase: 'parsing',
1513
+ current: 0,
1514
+ total,
1515
+ });
1516
+ await new Promise((resolve) => setImmediate(resolve));
1510
1517
  for (let i = 0; i < files.length; i += FILE_IO_BATCH_SIZE) {
1511
1518
  if (signal?.aborted) {
1512
1519
  aborted = true;
@@ -1515,7 +1522,8 @@ class ExtractionOrchestrator {
1515
1522
  const batch = files.slice(i, i + FILE_IO_BATCH_SIZE);
1516
1523
  // Read files in parallel (with path validation before any I/O)
1517
1524
  const fileContents = await Promise.all(batch.map(async (fp) => {
1518
- if ((0, arkts_1.isArkTSBatchPersisted)(fp)) {
1525
+ if ((0, arkts_1.isArkTSBatchPersisted)(fp) ||
1526
+ ((0, arkts_1.isArkTSBatchCommitted)() && (0, arkts_1.isArkAnalyzerSourcePath)(fp))) {
1519
1527
  return {
1520
1528
  filePath: fp,
1521
1529
  content: null,
@@ -1550,7 +1558,9 @@ class ExtractionOrchestrator {
1550
1558
  aborted = true;
1551
1559
  break;
1552
1560
  }
1553
- if ((0, arkts_1.isArkTSBatchPersisted)(filePath) || arktsBatchSkipped) {
1561
+ if ((0, arkts_1.isArkTSBatchPersisted)(filePath) ||
1562
+ arktsBatchSkipped ||
1563
+ ((0, arkts_1.isArkTSBatchCommitted)() && (0, arkts_1.isArkAnalyzerSourcePath)(filePath))) {
1554
1564
  processed++;
1555
1565
  filesIndexed++;
1556
1566
  onProgress?.({ phase: 'parsing', current: processed, total, currentFile: filePath });
@@ -1748,6 +1758,7 @@ class ExtractionOrchestrator {
1748
1758
  // Shut down the parse worker pool.
1749
1759
  if (pool)
1750
1760
  await pool.destroy();
1761
+ (0, arkts_1.shrinkArkTSBatchPostParse)();
1751
1762
  return {
1752
1763
  success: filesIndexed > 0 || errors.filter((e) => e.severity === 'error').length === 0,
1753
1764
  filesIndexed,