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
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+ /**
3
+ * Diff → changed-symbol impact helpers for `homegraph_diff_impact`.
4
+ *
5
+ * Parses unified diffs (new-side line ranges), intersects those ranges with
6
+ * indexed symbol spans, and builds a capped evidence pack (callers / impact
7
+ * summary / UI edges). Spec attachment is left to the MCP handler.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DIFF_IMPACT_LIMITS = exports.DIFF_IMPACT_UI_SYNTHESIZED_BY = exports.DIFF_IMPACT_MAX_DIFF_CHARS = void 0;
11
+ exports.normalizeDiffFilePath = normalizeDiffFilePath;
12
+ exports.parseUnifiedDiff = parseUnifiedDiff;
13
+ exports.mergeRanges = mergeRanges;
14
+ exports.rangesOverlap = rangesOverlap;
15
+ exports.nodeOverlapsRanges = nodeOverlapsRanges;
16
+ exports.selectChangedSymbols = selectChangedSymbols;
17
+ exports.isDiffImpactUiEdge = isDiffImpactUiEdge;
18
+ exports.buildDiffImpactPack = buildDiffImpactPack;
19
+ exports.resolveDiffImpactHunks = resolveDiffImpactHunks;
20
+ /** Max chars accepted for the `diff` argument (DoS bound; still success-shaped). */
21
+ exports.DIFF_IMPACT_MAX_DIFF_CHARS = 500_000;
22
+ exports.DIFF_IMPACT_UI_SYNTHESIZED_BY = new Set([
23
+ 'viewtree',
24
+ 'arkui-state',
25
+ 'arkui-route',
26
+ 'arkui-emitter',
27
+ ]);
28
+ /** Kinds that are almost never useful as "what changed" anchors for review. */
29
+ const SKIP_NODE_KINDS = new Set([
30
+ 'file',
31
+ 'module',
32
+ 'parameter',
33
+ 'import',
34
+ 'export',
35
+ ]);
36
+ exports.DIFF_IMPACT_LIMITS = {
37
+ maxSymbols: 80,
38
+ maxCallersPerSymbol: 8,
39
+ maxImpactSamples: 8,
40
+ maxUiEdges: 40,
41
+ maxSpecSymbols: 15,
42
+ };
43
+ /**
44
+ * Strip unified-diff path prefixes (`a/`, `b/`, `./`) and normalize slashes.
45
+ */
46
+ function normalizeDiffFilePath(raw) {
47
+ let p = raw.trim().replace(/\\/g, '/');
48
+ if (p === '/dev/null' || p === 'nul' || p === 'NUL')
49
+ return '';
50
+ // git often emits "b/src/foo.ts\t" or with timestamps after a tab
51
+ const tab = p.indexOf('\t');
52
+ if (tab >= 0)
53
+ p = p.slice(0, tab);
54
+ if (p.startsWith('a/') || p.startsWith('b/'))
55
+ p = p.slice(2);
56
+ p = p.replace(/^\.\//, '');
57
+ return p;
58
+ }
59
+ /**
60
+ * Parse unified diff text into per-file **new-side** (post-change) line ranges.
61
+ * Pure deletions (new count 0) contribute no ranges but still list the file.
62
+ */
63
+ function parseUnifiedDiff(diff) {
64
+ const notes = [];
65
+ const byFile = new Map();
66
+ let currentPath = '';
67
+ const lines = diff.split(/\r?\n/);
68
+ for (const line of lines) {
69
+ if (line.startsWith('+++ ')) {
70
+ const path = normalizeDiffFilePath(line.slice(4));
71
+ currentPath = path;
72
+ if (path && !byFile.has(path))
73
+ byFile.set(path, []);
74
+ continue;
75
+ }
76
+ if (line.startsWith('--- ')) {
77
+ // Prefer +++ when present; --- alone (e.g. unusual diffs) seeds the path.
78
+ const path = normalizeDiffFilePath(line.slice(4));
79
+ if (path && !currentPath) {
80
+ currentPath = path;
81
+ if (!byFile.has(path))
82
+ byFile.set(path, []);
83
+ }
84
+ continue;
85
+ }
86
+ if (line.startsWith('diff --git ')) {
87
+ currentPath = '';
88
+ continue;
89
+ }
90
+ const m = /^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/.exec(line);
91
+ if (!m)
92
+ continue;
93
+ if (!currentPath) {
94
+ notes.push('Skipped a hunk with no preceding +++ file path.');
95
+ continue;
96
+ }
97
+ const newStart = parseInt(m[3], 10);
98
+ const newCount = m[4] !== undefined ? parseInt(m[4], 10) : 1;
99
+ if (newCount <= 0) {
100
+ // Pure deletion on the new side — keep file listed, no line ranges.
101
+ if (!byFile.has(currentPath))
102
+ byFile.set(currentPath, []);
103
+ continue;
104
+ }
105
+ const ranges = byFile.get(currentPath) ?? [];
106
+ ranges.push({
107
+ startLine: newStart,
108
+ endLine: newStart + newCount - 1,
109
+ });
110
+ byFile.set(currentPath, ranges);
111
+ }
112
+ const hunks = [];
113
+ for (const [path, ranges] of byFile) {
114
+ hunks.push({ path, ranges: mergeRanges(ranges) });
115
+ }
116
+ hunks.sort((a, b) => a.path.localeCompare(b.path));
117
+ return { hunks, notes };
118
+ }
119
+ /** Merge overlapping / adjacent line ranges. */
120
+ function mergeRanges(ranges) {
121
+ if (ranges.length === 0)
122
+ return [];
123
+ const sorted = [...ranges].sort((a, b) => a.startLine - b.startLine || a.endLine - b.endLine);
124
+ const out = [{ ...sorted[0] }];
125
+ for (let i = 1; i < sorted.length; i++) {
126
+ const cur = sorted[i];
127
+ const last = out[out.length - 1];
128
+ if (cur.startLine <= last.endLine + 1) {
129
+ last.endLine = Math.max(last.endLine, cur.endLine);
130
+ }
131
+ else {
132
+ out.push({ ...cur });
133
+ }
134
+ }
135
+ return out;
136
+ }
137
+ function rangesOverlap(a, b) {
138
+ return a.startLine <= b.endLine && b.startLine <= a.endLine;
139
+ }
140
+ function nodeOverlapsRanges(node, ranges) {
141
+ const span = { startLine: node.startLine, endLine: node.endLine };
142
+ return ranges.some((r) => rangesOverlap(span, r));
143
+ }
144
+ /**
145
+ * Select indexed nodes whose spans intersect any changed line range.
146
+ * Skips container/noise kinds. Prefers tighter (inner) symbols when sorting.
147
+ */
148
+ function selectChangedSymbols(nodesByFile, hunks, limits = { maxSymbols: exports.DIFF_IMPACT_LIMITS.maxSymbols }) {
149
+ const picked = [];
150
+ for (const hunk of hunks) {
151
+ if (hunk.ranges.length === 0)
152
+ continue;
153
+ const nodes = nodesByFile.get(hunk.path) ?? [];
154
+ for (const n of nodes) {
155
+ if (SKIP_NODE_KINDS.has(n.kind))
156
+ continue;
157
+ if (!nodeOverlapsRanges(n, hunk.ranges))
158
+ continue;
159
+ picked.push({
160
+ id: n.id,
161
+ name: n.name,
162
+ kind: n.kind,
163
+ filePath: n.filePath,
164
+ startLine: n.startLine,
165
+ endLine: n.endLine,
166
+ });
167
+ }
168
+ }
169
+ // Prefer smaller spans (inner defs) then earlier lines — review noise control.
170
+ picked.sort((a, b) => (a.endLine - a.startLine) - (b.endLine - b.startLine) ||
171
+ a.startLine - b.startLine ||
172
+ a.name.localeCompare(b.name));
173
+ const truncated = picked.length > limits.maxSymbols;
174
+ return {
175
+ symbols: truncated ? picked.slice(0, limits.maxSymbols) : picked,
176
+ truncated,
177
+ };
178
+ }
179
+ function isDiffImpactUiEdge(edge) {
180
+ if (edge.provenance !== 'heuristic')
181
+ return false;
182
+ const m = edge.metadata;
183
+ const by = m?.synthesizedBy;
184
+ return typeof by === 'string' && exports.DIFF_IMPACT_UI_SYNTHESIZED_BY.has(by);
185
+ }
186
+ /**
187
+ * Build the capped evidence pack from hunks + graph. Specs are not included.
188
+ */
189
+ function buildDiffImpactPack(graph, hunks, options = {}) {
190
+ const limits = { ...exports.DIFF_IMPACT_LIMITS, ...options.limits };
191
+ const depth = Math.max(1, Math.min(options.depth ?? 2, 5));
192
+ const notes = [...(options.notes ?? [])];
193
+ const nodesByFile = new Map();
194
+ for (const h of hunks) {
195
+ try {
196
+ nodesByFile.set(h.path, graph.getNodesInFile(h.path));
197
+ }
198
+ catch {
199
+ nodesByFile.set(h.path, []);
200
+ notes.push(`Could not load nodes for ${h.path}`);
201
+ }
202
+ }
203
+ const { symbols, truncated: symbolsTruncated } = selectChangedSymbols(nodesByFile, hunks, {
204
+ maxSymbols: limits.maxSymbols,
205
+ });
206
+ if (symbols.length === 0) {
207
+ notes.push(hunks.some((h) => h.ranges.length > 0)
208
+ ? 'No indexed symbols intersect the changed line ranges (index may be stale relative to the diff, or changes are non-symbol).'
209
+ : 'Diff had no new-side line ranges (pure deletions or empty).');
210
+ }
211
+ const symbolIds = new Set(symbols.map((s) => s.id));
212
+ const nameById = new Map(symbols.map((s) => [s.id, s.name]));
213
+ const callers = [];
214
+ let callersTruncated = false;
215
+ for (const sym of symbols) {
216
+ let list = [];
217
+ try {
218
+ list = graph.getCallers(sym.id, 1);
219
+ }
220
+ catch {
221
+ continue;
222
+ }
223
+ if (list.length > limits.maxCallersPerSymbol) {
224
+ callersTruncated = true;
225
+ list = list.slice(0, limits.maxCallersPerSymbol);
226
+ }
227
+ for (const { node, edge } of list) {
228
+ callers.push({
229
+ symbol: sym.name,
230
+ callerName: node.name,
231
+ callerFile: node.filePath,
232
+ line: edge.line ?? null,
233
+ });
234
+ }
235
+ }
236
+ const impactSummary = [];
237
+ let impactTruncated = false;
238
+ for (const sym of symbols) {
239
+ try {
240
+ const impact = graph.getImpactRadius(sym.id, depth);
241
+ const nodes = normalizeImpactNodes(impact.nodes).filter((n) => n.id !== sym.id);
242
+ if (nodes.length > limits.maxImpactSamples)
243
+ impactTruncated = true;
244
+ impactSummary.push({
245
+ symbol: sym.name,
246
+ affectedCount: nodes.length,
247
+ sampleNames: nodes.slice(0, limits.maxImpactSamples).map((n) => n.name),
248
+ });
249
+ }
250
+ catch {
251
+ impactSummary.push({ symbol: sym.name, affectedCount: 0, sampleNames: [] });
252
+ }
253
+ }
254
+ const uiEdges = [];
255
+ const seenUi = new Set();
256
+ let uiTruncated = false;
257
+ for (const sym of symbols) {
258
+ if (uiEdges.length >= limits.maxUiEdges) {
259
+ uiTruncated = true;
260
+ break;
261
+ }
262
+ let edges = [];
263
+ try {
264
+ edges = [
265
+ ...graph.getOutgoingEdges(sym.id),
266
+ ...graph.getIncomingEdges(sym.id),
267
+ ];
268
+ }
269
+ catch {
270
+ continue;
271
+ }
272
+ for (const edge of edges) {
273
+ if (!isDiffImpactUiEdge(edge))
274
+ continue;
275
+ if (!symbolIds.has(edge.source) && !symbolIds.has(edge.target))
276
+ continue;
277
+ const key = `${edge.source}>${edge.target}>${edge.kind}>${String(edge.metadata?.via ?? '')}`;
278
+ if (seenUi.has(key))
279
+ continue;
280
+ seenUi.add(key);
281
+ const m = edge.metadata;
282
+ const sourceName = nameById.get(edge.source) ?? graph.getNode?.(edge.source)?.name ?? edge.source;
283
+ const targetName = nameById.get(edge.target) ?? graph.getNode?.(edge.target)?.name ?? edge.target;
284
+ uiEdges.push({
285
+ source: edge.source,
286
+ sourceName,
287
+ target: edge.target,
288
+ targetName,
289
+ kind: edge.kind,
290
+ synthesizedBy: String(m?.synthesizedBy ?? ''),
291
+ via: typeof m?.via === 'string' ? m.via : null,
292
+ line: edge.line ?? null,
293
+ });
294
+ if (uiEdges.length >= limits.maxUiEdges) {
295
+ uiTruncated = true;
296
+ break;
297
+ }
298
+ }
299
+ }
300
+ return {
301
+ changedFiles: hunks.map((h) => h.path),
302
+ hunks,
303
+ changedSymbols: symbols,
304
+ callers,
305
+ impactSummary,
306
+ uiEdges,
307
+ truncated: {
308
+ symbols: symbolsTruncated,
309
+ callers: callersTruncated,
310
+ impact: impactTruncated,
311
+ uiEdges: uiTruncated,
312
+ },
313
+ notes,
314
+ };
315
+ }
316
+ function normalizeImpactNodes(nodes) {
317
+ if (Array.isArray(nodes))
318
+ return nodes;
319
+ if (nodes instanceof Map)
320
+ return Array.from(nodes.values());
321
+ return Array.from(nodes);
322
+ }
323
+ /**
324
+ * Accept either a unified `diff` string or explicit `hunks` from the agent.
325
+ */
326
+ function resolveDiffImpactHunks(args) {
327
+ if (typeof args.diff === 'string' && args.diff.length > 0) {
328
+ if (args.diff.length > exports.DIFF_IMPACT_MAX_DIFF_CHARS) {
329
+ return {
330
+ hunks: [],
331
+ notes: [],
332
+ error: `\`diff\` exceeds maximum length of ${exports.DIFF_IMPACT_MAX_DIFF_CHARS} characters ` +
333
+ `(got ${args.diff.length}). Pass a smaller unified diff (e.g. one PR file at a time).`,
334
+ };
335
+ }
336
+ return parseUnifiedDiff(args.diff);
337
+ }
338
+ if (Array.isArray(args.hunks)) {
339
+ const hunks = [];
340
+ const notes = [];
341
+ for (const raw of args.hunks) {
342
+ if (!raw || typeof raw !== 'object') {
343
+ notes.push('Ignored a non-object hunk entry.');
344
+ continue;
345
+ }
346
+ const rec = raw;
347
+ const path = typeof rec.path === 'string'
348
+ ? normalizeDiffFilePath(rec.path)
349
+ : typeof rec.file === 'string'
350
+ ? normalizeDiffFilePath(rec.file)
351
+ : '';
352
+ if (!path) {
353
+ notes.push('Ignored a hunk with no path.');
354
+ continue;
355
+ }
356
+ const startLine = Number(rec.startLine ?? rec.start);
357
+ const endLine = Number(rec.endLine ?? rec.end ?? startLine);
358
+ if (!Number.isFinite(startLine) || startLine < 1) {
359
+ notes.push(`Ignored hunk for ${path}: invalid startLine.`);
360
+ continue;
361
+ }
362
+ const end = Number.isFinite(endLine) && endLine >= startLine ? endLine : startLine;
363
+ hunks.push({ path, ranges: [{ startLine, endLine: end }] });
364
+ }
365
+ // Merge by path
366
+ const byPath = new Map();
367
+ for (const h of hunks) {
368
+ const list = byPath.get(h.path) ?? [];
369
+ list.push(...h.ranges);
370
+ byPath.set(h.path, list);
371
+ }
372
+ const merged = [...byPath.entries()].map(([p, ranges]) => ({
373
+ path: p,
374
+ ranges: mergeRanges(ranges),
375
+ }));
376
+ merged.sort((a, b) => a.path.localeCompare(b.path));
377
+ return { hunks: merged, notes };
378
+ }
379
+ return {
380
+ hunks: [],
381
+ notes: [],
382
+ error: 'Provide either `diff` (unified diff text) or `hunks` (array of { path, startLine, endLine }).',
383
+ };
384
+ }
385
+ //# sourceMappingURL=diff-impact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-impact.js","sourceRoot":"","sources":["../../src/mcp/diff-impact.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA8FH,sDASC;AAMD,4CAsDC;AAGD,kCAcC;AAED,sCAEC;AAED,gDAGC;AAMD,oDAkCC;AAED,gDAKC;AAcD,kDA0IC;AAaD,wDAkEC;AA/cD,oFAAoF;AACvE,QAAA,0BAA0B,GAAG,OAAO,CAAC;AAErC,QAAA,6BAA6B,GAAG,IAAI,GAAG,CAAC;IACnD,UAAU;IACV,aAAa;IACb,aAAa;IACb,eAAe;CAChB,CAAC,CAAC;AAEH,+EAA+E;AAC/E,MAAM,eAAe,GAAG,IAAI,GAAG,CAAW;IACxC,MAAM;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAAG;IAChC,UAAU,EAAE,EAAE;IACd,mBAAmB,EAAE,CAAC;IACtB,gBAAgB,EAAE,CAAC;IACnB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;CACV,CAAC;AA8DX;;GAEG;AACH,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KA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CAAC;IAClC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;QACT,KAAK,EACH,+FAA+F;KAClG,CAAC;AACJ,CAAC"}
@@ -145,57 +145,57 @@ function debug(msg) {
145
145
  * target pid + timeout from argv; an MSG built once at startup (the child is
146
146
  * never wedged, so allocation here is fine).
147
147
  */
148
- const CHILD_SOURCE = `
149
- const fs = require('fs');
150
- const parentPid = Number(process.argv[1]);
151
- const timeoutMs = Number(process.argv[2]);
152
- const capMs = Number(process.argv[3]);
153
- const progressPaths = process.argv.slice(4);
154
- const secs = Math.round(timeoutMs / 1000);
155
- function kill(extra) {
156
- try { fs.writeSync(2, Buffer.from('[HomeGraph] Main thread unresponsive for ~' + secs + 's' + (extra || '') + ' — killing the wedged process so a fresh one can start (#850). Disable with HOMEGRAPH_NO_WATCHDOG=1.\\n')); } catch (e) {}
157
- try { process.kill(parentPid, 'SIGKILL'); } catch (e) {}
158
- process.exit(0);
159
- }
160
- // Fingerprint of the watched files (size + mtime). A change between checks is
161
- // forward disk progress — a slow synchronous SQLite statement, not a wedge.
162
- function snap() {
163
- let s = '';
164
- for (const p of progressPaths) {
165
- try { const st = fs.statSync(p); s += st.size + ':' + st.mtimeMs + ';'; } catch (e) { s += 'x;'; }
166
- }
167
- return s;
168
- }
169
- let lastSnap = progressPaths.length ? snap() : '';
170
- let lastSnapAt = Date.now();
171
- let silentSince = null; // start of the current continuous-silence episode
172
- function onTimeout() {
173
- if (!progressPaths.length) return kill('');
174
- const now = Date.now();
175
- if (silentSince === null) silentSince = now - timeoutMs; // silence began ~one timeout ago
176
- const cur = snap();
177
- if (cur !== lastSnap && now - silentSince < capMs) {
178
- // The event loop is blocked but the DB files are advancing: a legitimate
179
- // long store on slow storage. Defer, re-baseline, keep watching.
180
- lastSnap = cur;
181
- timer = setTimeout(onTimeout, timeoutMs);
182
- return;
183
- }
184
- kill(cur !== lastSnap ? ' despite ongoing disk activity (hard cap ' + Math.round(capMs / 1000) + 's reached)' : '');
185
- }
186
- let timer = setTimeout(onTimeout, timeoutMs);
187
- process.stdin.on('data', () => {
188
- silentSince = null;
189
- // Keep the baseline fresh while healthy (throttled — a stat per second).
190
- if (progressPaths.length) {
191
- const t = Date.now();
192
- if (t - lastSnapAt >= 1000) { lastSnap = snap(); lastSnapAt = t; }
193
- }
194
- clearTimeout(timer); timer = setTimeout(onTimeout, timeoutMs);
195
- });
196
- process.stdin.on('end', () => process.exit(0)); // parent closed the pipe (exited) -> no orphan
197
- process.stdin.on('error', () => process.exit(0)); // pipe broke -> parent gone
198
- process.stdin.resume();
148
+ const CHILD_SOURCE = `
149
+ const fs = require('fs');
150
+ const parentPid = Number(process.argv[1]);
151
+ const timeoutMs = Number(process.argv[2]);
152
+ const capMs = Number(process.argv[3]);
153
+ const progressPaths = process.argv.slice(4);
154
+ const secs = Math.round(timeoutMs / 1000);
155
+ function kill(extra) {
156
+ try { fs.writeSync(2, Buffer.from('[HomeGraph] Main thread unresponsive for ~' + secs + 's' + (extra || '') + ' — killing the wedged process so a fresh one can start (#850). Disable with HOMEGRAPH_NO_WATCHDOG=1.\\n')); } catch (e) {}
157
+ try { process.kill(parentPid, 'SIGKILL'); } catch (e) {}
158
+ process.exit(0);
159
+ }
160
+ // Fingerprint of the watched files (size + mtime). A change between checks is
161
+ // forward disk progress — a slow synchronous SQLite statement, not a wedge.
162
+ function snap() {
163
+ let s = '';
164
+ for (const p of progressPaths) {
165
+ try { const st = fs.statSync(p); s += st.size + ':' + st.mtimeMs + ';'; } catch (e) { s += 'x;'; }
166
+ }
167
+ return s;
168
+ }
169
+ let lastSnap = progressPaths.length ? snap() : '';
170
+ let lastSnapAt = Date.now();
171
+ let silentSince = null; // start of the current continuous-silence episode
172
+ function onTimeout() {
173
+ if (!progressPaths.length) return kill('');
174
+ const now = Date.now();
175
+ if (silentSince === null) silentSince = now - timeoutMs; // silence began ~one timeout ago
176
+ const cur = snap();
177
+ if (cur !== lastSnap && now - silentSince < capMs) {
178
+ // The event loop is blocked but the DB files are advancing: a legitimate
179
+ // long store on slow storage. Defer, re-baseline, keep watching.
180
+ lastSnap = cur;
181
+ timer = setTimeout(onTimeout, timeoutMs);
182
+ return;
183
+ }
184
+ kill(cur !== lastSnap ? ' despite ongoing disk activity (hard cap ' + Math.round(capMs / 1000) + 's reached)' : '');
185
+ }
186
+ let timer = setTimeout(onTimeout, timeoutMs);
187
+ process.stdin.on('data', () => {
188
+ silentSince = null;
189
+ // Keep the baseline fresh while healthy (throttled — a stat per second).
190
+ if (progressPaths.length) {
191
+ const t = Date.now();
192
+ if (t - lastSnapAt >= 1000) { lastSnap = snap(); lastSnapAt = t; }
193
+ }
194
+ clearTimeout(timer); timer = setTimeout(onTimeout, timeoutMs);
195
+ });
196
+ process.stdin.on('end', () => process.exit(0)); // parent closed the pipe (exited) -> no orphan
197
+ process.stdin.on('error', () => process.exit(0)); // pipe broke -> parent gone
198
+ process.stdin.resume();
199
199
  `;
200
200
  /**
201
201
  * Process-wide armed watchdog. `install` / `suspend` / `stop` all mutate this
@@ -4,6 +4,6 @@
4
4
  * Single source of truth for agent-facing tool guidance (issue #529).
5
5
  * Edit here — not installer prompts or eval harness prompts.
6
6
  */
7
- export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 when to call\n\nHomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.\n\n## Call HomeGraph (closed set)\n\nUse `homegraph_explore` (primary) when **all** of these hold:\n\n1. The evidence lives **in this repository's source** (not an external SDK manual).\n2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/`@kit` module.\n3. You can put **concrete names** in `query` \u2014 symbol, `Type.member`, file basename, or `@kit\u2026` (skip `homegraph_search` when names are already known).\n\nTypical fits:\n\n- How a **feature in this repo** is wired (mechanism / cross-file / click\u2192handler flow)\n- Callers / callees / blast radius of a **named** symbol\n- What a **named component/method** does (include the name; one explore is enough)\n- In-repo usages of an imported API (not the official feature catalog)\n\n**One explore with names** beats search\u2192explore\u2192node\u2192grep\u2192read. Treat returned line-numbered source as already Read. After a full explore \u2014 **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial \u2192 retry that **same** explore once.\n\n## Do not call HomeGraph otherwise\n\nIf the question is **outside the set above**, do **not** open any `homegraph_*` tool \u2014 use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.\n\n## Tool roles\n\n| Tool | Role |\n|------|------|\n| **homegraph_explore** | Primary for the closed set above |\n| homegraph_node | One known symbol body (or indexed file) after explore named it |\n| homegraph_callers / callees | Compact edge lists for a named symbol |\n| homegraph_search | Rare \u2014 unknown spelling only |\n| homegraph_files | Folder tree only |\n\n## Tips\n\n- **Deadline / partial** \u2014 success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.\n- **Staleness banner** \u2014 Read only the listed edited files.\n- **Not indexed** \u2014 built-in tools; user runs `homegraph init` \u2014 you do not.\n";
7
+ export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 when to call\n\nHomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.\n\n## Call HomeGraph (closed set)\n\nUse `homegraph_explore` (primary) when **all** of these hold:\n\n1. The evidence lives **in this repository's source** (not an external SDK manual).\n2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/`@kit` module.\n3. You can put **concrete names** in `query` \u2014 symbol, `Type.member`, file basename, or `@kit\u2026` (skip `homegraph_search` when names are already known).\n\nTypical fits:\n\n- How a **feature in this repo** is wired (mechanism / cross-file / click\u2192handler flow)\n- Callers / callees / blast radius of a **named** symbol\n- What a **named component/method** does (include the name; one explore is enough)\n- In-repo usages of an imported API (not the official feature catalog)\n\n**One explore with names** beats search\u2192explore\u2192node\u2192grep\u2192read. Treat returned line-numbered source as already Read. After a full explore \u2014 **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial \u2192 retry that **same** explore once.\n\n## Do not call HomeGraph otherwise\n\nIf the question is **outside the set above**, do **not** open any `homegraph_*` tool \u2014 use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.\n\n## Tool roles\n\n| Tool | Role |\n|------|------|\n| **homegraph_explore** | Primary for the closed set above |\n| homegraph_diff_impact | PR/diff review: unified `diff` or `hunks` \u2192 changed symbols (line\u2229span) + capped callers/impact/UI edges |\n| homegraph_node | One known symbol body (or indexed file) after explore named it |\n| homegraph_callers / callees | Compact edge lists for a named symbol |\n| homegraph_impact | Blast radius for one named symbol (not a whole PR) |\n| homegraph_search | Rare \u2014 unknown spelling only |\n| homegraph_files | Folder tree only |\n\n## Tips\n\n- **Deadline / partial** \u2014 success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.\n- **Staleness banner** \u2014 Read only the listed edited files.\n- **Not indexed** \u2014 built-in tools; user runs `homegraph init` \u2014 you do not.\n";
8
8
  export declare const SERVER_INSTRUCTIONS_NO_ROOT_INDEX = "# HomeGraph \u2014 per-project (pass projectPath)\n\nHomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has `.homegraph/`. Pass that project as `projectPath`.\n\n- Fits the closed set (structure, callers, wiring, named symbol/file) \u2192 `homegraph_explore`\n- Anything else \u2192 Read/Grep/Glob \u2014 **do not call homegraph_***\n- No index \u2192 Read/Grep/Glob; user runs `homegraph init` if they want indexing\n";
9
9
  //# sourceMappingURL=server-instructions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB,wtEAwC/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,yfAO7C,CAAC"}
1
+ {"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB,m7EA0C/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,yfAO7C,CAAC"}
@@ -7,53 +7,55 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = exports.SERVER_INSTRUCTIONS = void 0;
10
- exports.SERVER_INSTRUCTIONS = `# HomeGraph — when to call
11
-
12
- HomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.
13
-
14
- ## Call HomeGraph (closed set)
15
-
16
- Use \`homegraph_explore\` (primary) when **all** of these hold:
17
-
18
- 1. The evidence lives **in this repository's source** (not an external SDK manual).
19
- 2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/\`@kit\` module.
20
- 3. You can put **concrete names** in \`query\` — symbol, \`Type.member\`, file basename, or \`@kit…\` (skip \`homegraph_search\` when names are already known).
21
-
22
- Typical fits:
23
-
24
- - How a **feature in this repo** is wired (mechanism / cross-file / click→handler flow)
25
- - Callers / callees / blast radius of a **named** symbol
26
- - What a **named component/method** does (include the name; one explore is enough)
27
- - In-repo usages of an imported API (not the official feature catalog)
28
-
29
- **One explore with names** beats search→explore→node→grep→read. Treat returned line-numbered source as already Read. After a full explore — **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial → retry that **same** explore once.
30
-
31
- ## Do not call HomeGraph otherwise
32
-
33
- If the question is **outside the set above**, do **not** open any \`homegraph_*\` tool — use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.
34
-
35
- ## Tool roles
36
-
37
- | Tool | Role |
38
- |------|------|
39
- | **homegraph_explore** | Primary for the closed set above |
40
- | homegraph_node | One known symbol body (or indexed file) after explore named it |
41
- | homegraph_callers / callees | Compact edge lists for a named symbol |
42
- | homegraph_search | Rare unknown spelling only |
43
- | homegraph_files | Folder tree only |
44
-
45
- ## Tips
46
-
47
- - **Deadline / partial** — success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.
48
- - **Staleness banner** — Read only the listed edited files.
49
- - **Not indexed** — built-in tools; user runs \`homegraph init\` you do not.
10
+ exports.SERVER_INSTRUCTIONS = `# HomeGraph — when to call
11
+
12
+ HomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.
13
+
14
+ ## Call HomeGraph (closed set)
15
+
16
+ Use \`homegraph_explore\` (primary) when **all** of these hold:
17
+
18
+ 1. The evidence lives **in this repository's source** (not an external SDK manual).
19
+ 2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/\`@kit\` module.
20
+ 3. You can put **concrete names** in \`query\` — symbol, \`Type.member\`, file basename, or \`@kit…\` (skip \`homegraph_search\` when names are already known).
21
+
22
+ Typical fits:
23
+
24
+ - How a **feature in this repo** is wired (mechanism / cross-file / click→handler flow)
25
+ - Callers / callees / blast radius of a **named** symbol
26
+ - What a **named component/method** does (include the name; one explore is enough)
27
+ - In-repo usages of an imported API (not the official feature catalog)
28
+
29
+ **One explore with names** beats search→explore→node→grep→read. Treat returned line-numbered source as already Read. After a full explore — **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial → retry that **same** explore once.
30
+
31
+ ## Do not call HomeGraph otherwise
32
+
33
+ If the question is **outside the set above**, do **not** open any \`homegraph_*\` tool — use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.
34
+
35
+ ## Tool roles
36
+
37
+ | Tool | Role |
38
+ |------|------|
39
+ | **homegraph_explore** | Primary for the closed set above |
40
+ | homegraph_diff_impact | PR/diff review: unified \`diff\` or \`hunks\` → changed symbols (line∩span) + capped callers/impact/UI edges |
41
+ | homegraph_node | One known symbol body (or indexed file) after explore named it |
42
+ | homegraph_callers / callees | Compact edge lists for a named symbol |
43
+ | homegraph_impact | Blast radius for one named symbol (not a whole PR) |
44
+ | homegraph_search | Rare — unknown spelling only |
45
+ | homegraph_files | Folder tree only |
46
+
47
+ ## Tips
48
+
49
+ - **Deadline / partial** — success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.
50
+ - **Staleness banner** — Read only the listed edited files.
51
+ - **Not indexed** — built-in tools; user runs \`homegraph init\` — you do not.
50
52
  `;
51
- exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# HomeGraph — per-project (pass projectPath)
52
-
53
- HomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has \`.homegraph/\`. Pass that project as \`projectPath\`.
54
-
55
- - Fits the closed set (structure, callers, wiring, named symbol/file) → \`homegraph_explore\`
56
- - Anything else → Read/Grep/Glob — **do not call homegraph_***
57
- - No index → Read/Grep/Glob; user runs \`homegraph init\` if they want indexing
53
+ exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# HomeGraph — per-project (pass projectPath)
54
+
55
+ HomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has \`.homegraph/\`. Pass that project as \`projectPath\`.
56
+
57
+ - Fits the closed set (structure, callers, wiring, named symbol/file) → \`homegraph_explore\`
58
+ - Anything else → Read/Grep/Glob — **do not call homegraph_***
59
+ - No index → Read/Grep/Glob; user runs \`homegraph init\` if they want indexing
58
60
  `;
59
61
  //# sourceMappingURL=server-instructions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwClC,CAAC;AAEW,QAAA,iCAAiC,GAAG;;;;;;;CAOhD,CAAC"}
1
+ {"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ClC,CAAC;AAEW,QAAA,iCAAiC,GAAG;;;;;;;CAOhD,CAAC"}