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,103 +0,0 @@
1
- #!/usr/bin/env node
2
- // Dump the tree-sitter AST for a sample file so you can write a LanguageExtractor
3
- // mapping. Loads a grammar .wasm directly via web-tree-sitter (the same runtime
4
- // homegraph uses) — you do NOT need to register the language first.
5
- //
6
- // Usage:
7
- // node scripts/add-lang/dump-ast.mjs <lang|wasm-path> <sample-file> [--depth=N] [--full]
8
- // Examples:
9
- // node scripts/add-lang/dump-ast.mjs lua sample.lua
10
- // node scripts/add-lang/dump-ast.mjs src/extraction/wasm/tree-sitter-zig.wasm a.zig --depth=4
11
- //
12
- // Output: an indented AST (named nodes, with field names) followed by a
13
- // node-type FREQUENCY table. The frequency table is the payoff — it tells you
14
- // which node types to map to functionTypes / classTypes / importTypes / etc.
15
-
16
- import { readFileSync, existsSync } from 'node:fs';
17
- import { createRequire } from 'node:module';
18
- import { Parser, Language } from 'web-tree-sitter';
19
-
20
- const require = createRequire(import.meta.url);
21
- const fail = (msg) => { console.error(`[dump-ast] ${msg}`); process.exit(1); };
22
-
23
- const argv = process.argv.slice(2);
24
- const positional = argv.filter((a) => !a.startsWith('--'));
25
- const [langOrWasm, sampleFile] = positional;
26
- const depthFlag = argv.find((a) => a.startsWith('--depth='));
27
- const showAll = argv.includes('--full'); // also print anonymous (token) nodes
28
- const maxDepth = depthFlag ? parseInt(depthFlag.split('=')[1], 10) : (showAll ? Infinity : 8);
29
-
30
- if (!langOrWasm || !sampleFile) {
31
- fail('usage: dump-ast.mjs <lang|wasm-path> <sample-file> [--depth=N] [--full]');
32
- }
33
- if (!existsSync(sampleFile)) fail(`sample file not found: ${sampleFile}`);
34
-
35
- // Language tokens whose tree-sitter-wasms filename differs from the token.
36
- const WASM_SPECIAL = { csharp: 'c_sharp', 'c#': 'c_sharp' };
37
-
38
- function resolveWasm(token) {
39
- if (token.endsWith('.wasm')) {
40
- if (!existsSync(token)) fail(`wasm not found: ${token}`);
41
- return token;
42
- }
43
- const base = WASM_SPECIAL[token.toLowerCase()] ?? token.toLowerCase();
44
- try {
45
- return require.resolve(`tree-sitter-wasms/out/tree-sitter-${base}.wasm`);
46
- } catch {
47
- /* not in tree-sitter-wasms — try a vendored copy */
48
- }
49
- const vendored = `src/extraction/wasm/tree-sitter-${base}.wasm`;
50
- if (existsSync(vendored)) return vendored;
51
- fail(
52
- `no grammar for "${token}" — not in tree-sitter-wasms and not vendored at ` +
53
- `${vendored}. Pass an explicit .wasm path, or vendor one (see SKILL.md "Find a grammar").`
54
- );
55
- }
56
-
57
- const wasmPath = resolveWasm(langOrWasm);
58
- const source = readFileSync(sampleFile, 'utf8');
59
-
60
- try {
61
- await Parser.init();
62
- } catch {
63
- await Parser.init({ locateFile: () => require.resolve('web-tree-sitter/tree-sitter.wasm') });
64
- }
65
-
66
- let language;
67
- try {
68
- language = await Language.load(wasmPath);
69
- } catch (e) {
70
- fail(`failed to load grammar ${wasmPath}: ${e.message}`);
71
- }
72
-
73
- const parser = new Parser();
74
- parser.setLanguage(language);
75
- const tree = parser.parse(source);
76
-
77
- const freq = new Map();
78
- const snippet = (node) => {
79
- const t = node.text.replace(/\s+/g, ' ').trim();
80
- return t.length > 48 ? `${t.slice(0, 48)}…` : t;
81
- };
82
-
83
- function walk(node, depth, fieldName) {
84
- if (node.isNamed) freq.set(node.type, (freq.get(node.type) || 0) + 1);
85
- if ((node.isNamed || showAll) && depth <= maxDepth) {
86
- const field = fieldName ? `${fieldName}: ` : '';
87
- const leaf = node.childCount === 0 ? ` "${snippet(node)}"` : '';
88
- console.log(`${' '.repeat(depth)}${field}${node.type} @${node.startPosition.row + 1}:${node.startPosition.column}${leaf}`);
89
- }
90
- for (let i = 0; i < node.childCount; i++) {
91
- const child = node.child(i);
92
- if (child) walk(child, depth + 1, node.fieldNameForChild(i));
93
- }
94
- }
95
-
96
- console.log(`\n# AST for ${sampleFile} (grammar: ${wasmPath.split('/').pop()})\n`);
97
- walk(tree.rootNode, 0, null);
98
-
99
- console.log('\n# Node-type frequency (named nodes) — map the relevant ones in your extractor:\n');
100
- [...freq.entries()]
101
- .sort((a, b) => b[1] - a[1])
102
- .forEach(([type, n]) => console.log(` ${String(n).padStart(5)} ${type}`));
103
- console.log();
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- // Sanity-check that homegraph extracted REAL symbols (not just file/import nodes)
3
- // from a repo for a given language. Exits non-zero on a critical failure so it
4
- // can drive a write-extractor -> build -> re-check loop.
5
- //
6
- // Usage: node scripts/add-lang/verify-extraction.mjs <repo-path> <lang>
7
- // Reads `homegraph status <repo> --json` using whatever homegraph is on PATH,
8
- // so it reflects the binary that built the index.
9
- //
10
- // Exit codes: 0 = pass or soft-warn, 1 = critical fail, 2 = could not run.
11
-
12
- import { execFileSync } from 'node:child_process';
13
-
14
- const [repo, lang] = process.argv.slice(2);
15
- if (!repo || !lang) {
16
- console.error('usage: verify-extraction.mjs <repo-path> <lang>');
17
- process.exit(2);
18
- }
19
-
20
- let status;
21
- try {
22
- const out = execFileSync('homegraph', ['status', repo, '--json'], { encoding: 'utf8' });
23
- status = JSON.parse(out);
24
- } catch (e) {
25
- console.error(`[verify] could not read homegraph status for ${repo}: ${e.message}`);
26
- process.exit(2);
27
- }
28
-
29
- // Kinds that prove the extractor mapped AST node types (everything except
30
- // 'file' and 'import', which homegraph creates structurally for any language).
31
- const SYMBOL_KINDS = new Set([
32
- 'module', 'class', 'struct', 'interface', 'trait', 'protocol', 'function',
33
- 'method', 'property', 'field', 'variable', 'constant', 'enum', 'enum_member',
34
- 'type_alias', 'namespace', 'route', 'component',
35
- ]);
36
-
37
- const byKind = status.nodesByKind || {};
38
- const langs = status.languages || [];
39
- const files = status.fileCount || 0;
40
- const edges = status.edgeCount || 0;
41
- const symbolKinds = Object.keys(byKind).filter((k) => SYMBOL_KINDS.has(k));
42
- const symbolCount = symbolKinds.reduce((s, k) => s + byKind[k], 0);
43
-
44
- const checks = [];
45
- const add = (severity, ok, label, detail) => checks.push({ severity, ok, label, detail });
46
-
47
- add('critical', status.initialized === true, 'index initialized', `initialized=${status.initialized}`);
48
- add('critical', langs.includes(lang), `language "${lang}" detected`, `languages=[${langs.join(', ')}]`);
49
- add('critical', symbolCount > 0, 'structural symbols extracted', `${symbolCount} symbols (${symbolKinds.join(', ') || 'NONE — only file/import nodes!'})`);
50
- add('soft', symbolCount >= files, 'symbol density >= 1/file', `${symbolCount} symbols across ${files} files`);
51
- add('soft', edges > files, 'edges resolved', `${edges} edges across ${files} files`);
52
-
53
- console.log(`\n# Extraction check — ${repo} (lang=${lang}, backend=${status.backend})`);
54
- console.log(` files=${files} nodes=${status.nodeCount} edges=${edges}`);
55
- console.log(` nodesByKind: ${JSON.stringify(byKind)}\n`);
56
- for (const c of checks) console.log(` ${c.ok ? '✓' : '✗'} ${c.label} — ${c.detail}`);
57
-
58
- const critical = checks.filter((c) => !c.ok && c.severity === 'critical');
59
- const soft = checks.filter((c) => !c.ok && c.severity === 'soft');
60
- console.log();
61
- if (critical.length) {
62
- console.log(`RESULT: FAIL (${critical.length} critical) — extractor or grammar wiring is broken. Re-run dump-ast.mjs and fix the node-type mappings.`);
63
- process.exit(1);
64
- }
65
- if (soft.length) {
66
- console.log(`RESULT: WARN (${soft.length} soft) — extraction works but looks thin; inspect the counts above.`);
67
- process.exit(0);
68
- }
69
- console.log('RESULT: PASS — extraction looks healthy.');
70
- process.exit(0);
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Does the agent PICK homegraph_node to read a file, vs the built-in Read tool?
3
- # Build A/B: NEW build (HEAD, homegraph_node has Read parity) vs BASELINE build
4
- # (a ref where it doesn't), BOTH homegraph-attached + pre-warmed, same task. The
5
- # metric is tool CHOICE: Read calls vs homegraph_node[file] calls per run.
6
- #
7
- # Usage: ab-adoption.sh <indexed-repo> "<task>" [runs-per-arm] [baseline-ref]
8
- # Env: AGENT_EVAL_OUT (default: /tmp/ab-adoption)
9
- set -uo pipefail
10
- TARGET="${1:?usage: ab-adoption.sh <indexed-repo> \"<task>\" [runs] [baseline-ref]}"
11
- TASK="${2:?task required}"
12
- RUNS="${3:-2}"
13
- BASE_REF="${4:-HEAD~1}"
14
- ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
15
- BIN="$ENGINE/dist/bin/homegraph.js"
16
- OUT="${AGENT_EVAL_OUT:-/tmp/ab-adoption}"
17
-
18
- command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
19
- [ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
20
- git -C "$ENGINE" diff --quiet && git -C "$ENGINE" diff --cached --quiet || { echo "engine has uncommitted changes — commit/stash first"; exit 1; }
21
- CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
22
- [ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD"; exit 1; }
23
-
24
- cleanup() {
25
- pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
26
- git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
27
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
28
- }
29
- trap cleanup EXIT
30
- mkdir -p "$OUT"
31
- echo "###### target=$TARGET runs/arm=$RUNS baseline=$BASE_REF"
32
- echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
33
- echo "###### task=$TASK"; echo
34
-
35
- prewarm() {
36
- pkill -9 -f "serve --mcp --path $1" 2>/dev/null
37
- HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
38
- node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" >/dev/null 2>&1
39
- }
40
-
41
- # Per-run tool-choice counts: Read vs homegraph_node[file] vs [symbol].
42
- count() {
43
- node -e '
44
- const fs=require("fs");
45
- const lines=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
46
- let read=0,cgFile=0,cgSym=0,cgOther=0,exposed="?";
47
- for(const l of lines){try{const o=JSON.parse(l);
48
- if(o.type==="system"&&o.subtype==="init"){exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;}
49
- const blocks=o.message?.content||[];
50
- for(const b of (Array.isArray(blocks)?blocks:[])){
51
- if(b.type!=="tool_use")continue;
52
- if(b.name==="Read")read++;
53
- else if(b.name==="mcp__homegraph__homegraph_node"){ if(b.input&&b.input.symbol)cgSym++; else cgFile++; }
54
- else if(/mcp__homegraph__/.test(b.name))cgOther++;
55
- }
56
- }catch{}}
57
- console.log(` Read=${read} homegraph_node[file]=${cgFile} homegraph_node[symbol]=${cgSym} other_cg=${cgOther} (cg exposed=${exposed})`);
58
- ' "$1"
59
- }
60
-
61
- run_arm() { # label, N
62
- local label="$1" n="$2"
63
- local c="$OUT/mcp-$label.json"
64
- for i in $(seq 1 "$n"); do
65
- local tgt="$OUT/t-$label-$i"
66
- rm -rf "$tgt"
67
- rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
68
- node "$BIN" init "$tgt" >/dev/null 2>&1
69
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
70
- prewarm "$tgt"
71
- echo "----- [$label] run $i -----"
72
- ( cd "$tgt" && claude -p "$TASK" \
73
- --output-format stream-json --verbose --permission-mode bypassPermissions \
74
- --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
75
- </dev/null > "$OUT/run-$label-$i.jsonl" 2>"$OUT/run-$label-$i.err" )
76
- count "$OUT/run-$label-$i.jsonl"
77
- pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
78
- done
79
- echo
80
- }
81
-
82
- echo "== NEW build (HEAD: homegraph_node has Read parity) =="
83
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
84
- run_arm new "$RUNS"
85
-
86
- echo "== BASELINE build ($BASE_REF) =="
87
- git -C "$ENGINE" checkout "$BASE_REF" -- $CHANGED
88
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
89
- run_arm baseline "$RUNS"
90
-
91
- echo "###### DONE — compare [new] vs [baseline]: does homegraph_node[file] rise / Read fall? Logs: $OUT"
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env bash
2
- # A/B the PreToolUse(Read) REDIRECT hook (P1): does steering Read → homegraph_node
3
- # file-view actually move the agent off Read during implementation? BOTH arms use
4
- # the CURRENT build with homegraph attached and pre-warmed; the only difference is
5
- # the hook. Isolates the hook's behavioral effect from the build/file-view change
6
- # (use ab-new-vs-baseline.sh for the build A/B).
7
- #
8
- # arm [nohook] — homegraph on, no hook (does the better file-view get picked on its own?)
9
- # arm [hook] — homegraph on, + redirect hook (does routing close it?)
10
- #
11
- # Reliable attach (works nested): each arm pre-warms a persistent daemon and skips
12
- # the startup re-exec (HOMEGRAPH_WASM_RELAUNCHED=1), so claude connects before the
13
- # agent's first turn. Judge by ACTUAL homegraph usage in parse-run.mjs's "by type",
14
- # not claude's init snapshot (which can read pending even when it then connects).
15
- #
16
- # Usage: ab-hook.sh <indexed-repo> "<implementation task>" [runs-per-arm]
17
- # <indexed-repo> a repo with a .homegraph index (copied per arm; never mutated)
18
- # "<task>" a GENUINELY-NEW implementation task (verify it isn't already done)
19
- # [runs-per-arm] default 2 (n=1 is noisy — the doctrine says >=2)
20
- # Env: AGENT_EVAL_OUT (default: /tmp/ab-hook)
21
- set -uo pipefail
22
-
23
- TARGET="${1:?usage: ab-hook.sh <indexed-repo> \"<task>\" [runs-per-arm]}"
24
- TASK="${2:?task required}"
25
- RUNS="${3:-2}"
26
- ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
27
- BIN="$ENGINE/dist/bin/homegraph.js"
28
- HOOK="$ENGINE/scripts/agent-eval/redirect-read-hook.sh"
29
- OUT="${AGENT_EVAL_OUT:-/tmp/ab-hook}"
30
- PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
31
-
32
- command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
33
- command -v jq >/dev/null || { echo "jq not on PATH (the hook needs it)"; exit 1; }
34
- [ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
35
- chmod +x "$HOOK"
36
-
37
- cleanup() { pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
38
- trap cleanup EXIT
39
-
40
- mkdir -p "$OUT"
41
- echo "###### engine=$ENGINE"
42
- echo "###### target=$TARGET runs/arm=$RUNS"
43
- echo "###### task=$TASK"
44
- echo
45
-
46
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
47
-
48
- # A settings file carrying ONLY the PreToolUse(Read) redirect hook.
49
- HOOK_SETTINGS="$OUT/hook-settings.json"
50
- jq -n --arg cmd "bash $HOOK" \
51
- '{hooks:{PreToolUse:[{matcher:"Read",hooks:[{type:"command",command:$cmd}]}]}}' > "$HOOK_SETTINGS"
52
-
53
- prewarm() { # target — spawn a persistent daemon and wait for its socket
54
- pkill -9 -f "serve --mcp --path $1" 2>/dev/null
55
- HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
56
- node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
57
- && echo " daemon warm: $1" || echo " WARN: daemon never bound for $1"
58
- }
59
-
60
- run_one() { # arm-label, run-index, use-hook(0|1)
61
- local label="$1" idx="$2" hook="$3"
62
- local tgt="$OUT/t-$label-$idx" c="$OUT/mcp-$label.json"
63
- rm -rf "$tgt"
64
- rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$tgt/"
65
- node "$BIN" init "$tgt" >/dev/null 2>&1
66
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
67
- prewarm "$tgt"
68
- local extra=()
69
- [ "$hook" = "1" ] && extra=(--settings "$HOOK_SETTINGS")
70
- echo "----- [$label] run $idx -----"
71
- # ${extra[@]+...} guard: bash 3.2 (macOS) under `set -u` errors on an empty
72
- # array expansion otherwise, which would skip the no-hook arm's claude run.
73
- ( cd "$tgt" && claude -p "$TASK" \
74
- --output-format stream-json --verbose --permission-mode bypassPermissions \
75
- --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" ${extra[@]+"${extra[@]}"} \
76
- </dev/null > "$OUT/run-$label-$idx.jsonl" 2>"$OUT/run-$label-$idx.err" )
77
- node "$PARSE" "$OUT/run-$label-$idx.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label-$idx.jsonl)"
78
- pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
79
- echo
80
- }
81
-
82
- for i in $(seq 1 "$RUNS"); do run_one nohook "$i" 0; done
83
- for i in $(seq 1 "$RUNS"); do run_one hook "$i" 1; done
84
-
85
- echo "###### DONE. Compare [nohook] vs [hook] 'by type' — Read should fall and"
86
- echo "###### mcp__homegraph__homegraph_node should rise in the [hook] arm. Logs: $OUT"
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Sufficiency A/B for an IMPLEMENTATION task (the agent edits): when it uses
3
- # homegraph (explore/node) to understand before editing, does it still Read? Like
4
- # ab-sufficiency.sh but copies+indexes a FRESH target per run (the agent mutates
5
- # it), so runs don't see each other's edits.
6
- #
7
- # WITH homegraph (pre-warmed) vs WITHOUT (empty MCP), N runs each. Reports
8
- # explore/node vs Read/Grep + the files Read, and whether the build still passes.
9
- #
10
- # Usage: ab-impl.sh <indexed-repo> "<task>" [runs] [build-cmd]
11
- # Env: AGENT_EVAL_OUT (default: /tmp/ab-impl)
12
- set -uo pipefail
13
- REPO="${1:?usage: ab-impl.sh <indexed-repo> \"<task>\" [runs] [build-cmd]}"
14
- Q="${2:?task required}"
15
- RUNS="${3:-2}"
16
- BUILD_CMD="${4:-}"
17
- ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
18
- BIN="$ENGINE/dist/bin/homegraph.js"
19
- OUT="${AGENT_EVAL_OUT:-/tmp/ab-impl}"
20
- command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
21
- [ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO"; exit 1; }
22
- cleanup(){ pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null; }
23
- trap cleanup EXIT
24
- mkdir -p "$OUT"
25
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built engine"
26
- echo "###### repo=$REPO runs/arm=$RUNS"
27
- echo "###### task=$Q"; echo
28
- echo '{"mcpServers":{}}' > "$OUT/mcp-empty.json"
29
-
30
- prewarm(){
31
- pkill -9 -f "serve --mcp --path $1" 2>/dev/null
32
- HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
33
- node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" >/dev/null 2>&1
34
- }
35
-
36
- analyze(){
37
- node -e '
38
- const fs=require("fs");
39
- const L=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
40
- let ex=0,nf=0,ns=0,oc=0,gr=0,ed=0,exposed="?";const reads=[];
41
- for(const l of L){try{const o=JSON.parse(l);
42
- if(o.type==="system"&&o.subtype==="init")exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;
43
- for(const b of (o.message?.content||[])){if(b.type!=="tool_use")continue;
44
- if(b.name==="mcp__homegraph__homegraph_explore")ex++;
45
- else if(b.name==="mcp__homegraph__homegraph_node"){if(b.input&&b.input.symbol)ns++;else nf++;}
46
- else if(/mcp__homegraph__/.test(b.name))oc++;
47
- else if(b.name==="Read")reads.push((b.input?.file_path||"").split("/").pop());
48
- else if(b.name==="Grep")gr++;
49
- else if(b.name==="Edit"||b.name==="Write")ed++;
50
- }}catch{}}
51
- console.log(` explore=${ex} node[sym]=${ns} node[file]=${nf} other_cg=${oc} | Read=${reads.length}${reads.length?" ("+reads.join(", ")+")":""} Grep=${gr} Edit=${ed} [cg exposed=${exposed}]`);
52
- ' "$1"
53
- }
54
-
55
- run(){ # label, withCodegraph(0/1)
56
- local label="$1" wcg="$2"
57
- for i in $(seq 1 "$RUNS"); do
58
- local tgt="$OUT/t-$label-$i" cfg="$OUT/mcp-$label.json"
59
- rm -rf "$tgt"
60
- rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$REPO/" "$tgt/"
61
- node "$BIN" init "$tgt" >/dev/null 2>&1
62
- if [ "$wcg" = "1" ]; then
63
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$cfg"
64
- prewarm "$tgt"
65
- else cp "$OUT/mcp-empty.json" "$cfg"; fi
66
- ( cd "$tgt" && claude -p "$Q" --output-format stream-json --verbose \
67
- --permission-mode bypassPermissions --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
68
- --strict-mcp-config --mcp-config "$cfg" </dev/null > "$OUT/$label-$i.jsonl" 2>"$OUT/$label-$i.err" )
69
- echo "[$label] run $i:"; analyze "$OUT/$label-$i.jsonl"
70
- if [ -n "$BUILD_CMD" ]; then ( cd "$tgt" && eval "$BUILD_CMD" >/dev/null 2>&1 && echo " build: PASS" || echo " build: FAIL" ); fi
71
- pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
72
- done
73
- echo
74
- }
75
-
76
- echo "== WITH homegraph =="; run with 1
77
- echo "== WITHOUT (Read/Grep only) =="; run without 0
78
- echo "###### DONE: $OUT"
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env bash
2
- # A/B a homegraph retrieval/steering change: the NEW build (current HEAD) vs a
3
- # BASELINE build (a git ref) — BOTH with homegraph attached — on the same
4
- # implementation task, measuring how many Read vs homegraph calls the agent
5
- # makes. ISOLATES the change (unlike run-all.sh's with-vs-without). The agent
6
- # works on a throwaway copy of the target, so your repos are never touched.
7
- #
8
- # Reliable attach (works even when this is itself run nested inside a Claude
9
- # session): each arm PRE-WARMS a persistent homegraph daemon for its target so
10
- # claude connects to an already-bound, index-loaded daemon instantly — before
11
- # the agent's first turn — and SKIPS homegraph's startup re-exec via
12
- # HOMEGRAPH_WASM_RELAUNCHED=1. Without this, on a multi-step task the agent
13
- # dives into Read/grep before homegraph finishes its ~2-3s startup (worse under
14
- # the CPU contention of a nested run) and runs with NO homegraph.
15
- #
16
- # Gotcha: claude's `system/init` snapshot can read status:"pending" / 0 tools
17
- # even when the server then connects fine — judge by ACTUAL homegraph usage in
18
- # parse-run.mjs's "by type", not the init line.
19
- #
20
- # Usage: ab-new-vs-baseline.sh <indexed-repo> "<task>" [baseline-ref]
21
- # <indexed-repo> a repo with a .homegraph index (copied per arm)
22
- # "<task>" an implementation task, e.g. "Add X to Y and wire it through"
23
- # [baseline-ref] git ref for the BEFORE build (default: HEAD~1)
24
- # Env: AGENT_EVAL_OUT (default: /tmp/ab-new-vs-baseline)
25
- set -uo pipefail
26
-
27
- TARGET="${1:?usage: ab-new-vs-baseline.sh <indexed-repo> \"<task>\" [baseline-ref]}"
28
- TASK="${2:?task required}"
29
- BASE_REF="${3:-HEAD~1}"
30
- ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
31
- BIN="$ENGINE/dist/bin/homegraph.js"
32
- OUT="${AGENT_EVAL_OUT:-/tmp/ab-new-vs-baseline}"
33
- PARSE="$ENGINE/scripts/agent-eval/parse-run.mjs"
34
-
35
- command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
36
- [ -d "$TARGET/.homegraph" ] || { echo "target not indexed: run 'homegraph init $TARGET' first"; exit 1; }
37
- if ! git -C "$ENGINE" diff --quiet || ! git -C "$ENGINE" diff --cached --quiet; then
38
- echo "engine repo has uncommitted changes — commit or stash first (this script checks files out)"; exit 1
39
- fi
40
- CHANGED=$(git -C "$ENGINE" diff --name-only "$BASE_REF" HEAD -- src 2>/dev/null)
41
- [ -n "$CHANGED" ] || { echo "no src/ changes between $BASE_REF and HEAD — nothing to A/B"; exit 1; }
42
-
43
- # On exit: kill any eval daemons + restore the engine to HEAD.
44
- cleanup() {
45
- pkill -9 -f "serve --mcp --path $OUT/" 2>/dev/null
46
- git -C "$ENGINE" checkout HEAD -- $CHANGED 2>/dev/null
47
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 )
48
- }
49
- trap cleanup EXIT
50
-
51
- mkdir -p "$OUT"
52
- echo "###### engine=$ENGINE baseline=$BASE_REF"
53
- echo "###### changed: $(echo "$CHANGED" | tr '\n' ' ')"
54
- echo "###### target=$TARGET"
55
- echo "###### task=$TASK"
56
- echo
57
-
58
- # Two pristine copies so each arm starts clean (the agent edits its own copy).
59
- rm -rf "$OUT/t-new" "$OUT/t-base"
60
- rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$TARGET/" "$OUT/t-new/"
61
- cp -R "$OUT/t-new" "$OUT/t-base"
62
-
63
- prewarm() { # target — spawn a persistent daemon (current $BIN) and wait for its socket
64
- pkill -9 -f "serve --mcp --path $1" 2>/dev/null
65
- HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$1" </dev/null >/dev/null 2>&1 &
66
- node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$1" \
67
- && echo " daemon warm: $1" || echo " WARN: daemon never bound for $1 (arm may run without homegraph)"
68
- }
69
-
70
- run_arm() { # label, target-copy
71
- local label="$1" tgt="$2" c="$OUT/mcp-$1.json"
72
- # Connect to the pre-warmed daemon; skip the startup re-exec for a fast attach.
73
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$tgt" > "$c"
74
- prewarm "$tgt"
75
- echo "############## ARM [$label] ##############"
76
- ( cd "$tgt" && claude -p "$TASK" \
77
- --output-format stream-json --verbose --permission-mode bypassPermissions \
78
- --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 --strict-mcp-config --mcp-config "$c" \
79
- </dev/null > "$OUT/run-$label.jsonl" 2>"$OUT/run-$label.err" )
80
- node "$PARSE" "$OUT/run-$label.jsonl" 2>&1 | grep -E "by type|Result" || echo " (parse failed — see $OUT/run-$label.jsonl)"
81
- pkill -9 -f "serve --mcp --path $tgt" 2>/dev/null
82
- echo
83
- }
84
-
85
- echo "== NEW build (HEAD) =="
86
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
87
- node "$BIN" init "$OUT/t-new" >/dev/null 2>&1 && echo " indexed t-new"
88
- run_arm new "$OUT/t-new"
89
-
90
- echo "== BASELINE build ($BASE_REF) =="
91
- # Per-file: a file ADDED since baseline has no pathspec on the ref — and a
92
- # single multi-file checkout with one bad pathspec checks out NOTHING, which
93
- # silently ran the NEW build in the baseline arm. Absent-on-baseline → remove.
94
- for f in $CHANGED; do
95
- git -C "$ENGINE" checkout "$BASE_REF" -- "$f" 2>/dev/null || rm -f "$ENGINE/$f"
96
- done
97
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo " built"
98
- node "$BIN" init "$OUT/t-base" >/dev/null 2>&1 && echo " indexed t-base"
99
- run_arm baseline "$OUT/t-base"
100
-
101
- echo "###### DONE. Compare the [new] vs [baseline] 'by type' counts above"
102
- echo "###### (especially Read vs mcp__homegraph__*). Full logs in: $OUT"
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Sufficiency A/B: on a real understanding/flow question, WHEN the agent uses
3
- # homegraph (explore/node), does it still Read? Premise under test: explore/node
4
- # return source WITH line numbers, so a Read should not be needed.
5
- #
6
- # WITH homegraph (pre-warmed daemon, reliable nested attach) vs WITHOUT (empty
7
- # MCP, Read/Grep only), N runs each, on a throwaway copy of the repo. Reports
8
- # explore/node vs Read/Grep, and LISTS the files Read in the WITH arm so a true
9
- # sufficiency gap (an indexed source file) is distinguishable from out-of-scope
10
- # (configs, docs, a file homegraph didn't index).
11
- #
12
- # Usage: ab-sufficiency.sh <indexed-repo> "<question>" [runs-per-arm]
13
- # Env: AGENT_EVAL_OUT (default: /tmp/ab-sufficiency)
14
- set -uo pipefail
15
- REPO="${1:?usage: ab-sufficiency.sh <indexed-repo> \"<question>\" [runs]}"
16
- Q="${2:?question required}"
17
- RUNS="${3:-2}"
18
- ENGINE="$(cd "$(dirname "$0")/../.." && pwd)"
19
- BIN="$ENGINE/dist/bin/homegraph.js"
20
- OUT="${AGENT_EVAL_OUT:-/tmp/ab-sufficiency}"
21
- TGT="$OUT/target"
22
- command -v claude >/dev/null || { echo "claude CLI not on PATH"; exit 1; }
23
- [ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO"; exit 1; }
24
- cleanup(){ pkill -9 -f "serve --mcp --path $TGT" 2>/dev/null; }
25
- trap cleanup EXIT
26
- mkdir -p "$OUT"
27
- ( cd "$ENGINE" && npm run build >/dev/null 2>&1 ) && echo "built"
28
-
29
- # Throwaway copy + fresh index (the agent works here; a read-only question won't
30
- # edit, but isolate anyway). Excludes the source repo's index/build/vcs.
31
- rm -rf "$TGT"
32
- rsync -a --exclude node_modules --exclude .git --exclude dist --exclude .homegraph "$REPO/" "$TGT/"
33
- node "$BIN" init "$TGT" >/dev/null 2>&1 && echo "indexed copy ($(node "$BIN" status --json 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{console.log(JSON.parse(s).fileCount+" files")}catch{console.log("?")}})' 2>/dev/null || echo '?'))"
34
-
35
- echo "###### repo=$REPO runs/arm=$RUNS"
36
- echo "###### Q=$Q"; echo
37
- echo '{"mcpServers":{}}' > "$OUT/mcp-empty.json"
38
- printf '{"mcpServers":{"homegraph":{"command":"env","args":["HOMEGRAPH_WASM_RELAUNCHED=1","node","%s","serve","--mcp","--path","%s"]}}}' "$BIN" "$TGT" > "$OUT/mcp-cg.json"
39
-
40
- prewarm(){
41
- pkill -9 -f "serve --mcp --path $TGT" 2>/dev/null
42
- HOMEGRAPH_DAEMON_IDLE_TIMEOUT_MS=1800000 node "$BIN" serve --mcp --path "$TGT" </dev/null >/dev/null 2>&1 &
43
- node -e 'const fs=require("fs");let n=0;const t=setInterval(()=>{if(fs.existsSync(process.argv[1]+"/.homegraph/daemon.sock")){clearInterval(t);process.exit(0)}if(n++>150){clearInterval(t);process.exit(1)}},100)' "$TGT" >/dev/null 2>&1
44
- }
45
-
46
- analyze(){
47
- node -e '
48
- const fs=require("fs");
49
- const L=fs.readFileSync(process.argv[1],"utf8").split("\n").filter(Boolean);
50
- let ex=0,nf=0,ns=0,oc=0,gr=0,exposed="?";const reads=[];
51
- for(const l of L){try{const o=JSON.parse(l);
52
- if(o.type==="system"&&o.subtype==="init")exposed=(o.tools||[]).filter(t=>/homegraph/.test(t)).length;
53
- for(const b of (o.message?.content||[])){if(b.type!=="tool_use")continue;
54
- if(b.name==="mcp__homegraph__homegraph_explore")ex++;
55
- else if(b.name==="mcp__homegraph__homegraph_node"){if(b.input&&b.input.symbol)ns++;else nf++;}
56
- else if(/mcp__homegraph__/.test(b.name))oc++;
57
- else if(b.name==="Read")reads.push((b.input?.file_path||"").split("/").pop());
58
- else if(b.name==="Grep")gr++;
59
- }}catch{}}
60
- console.log(` explore=${ex} node[sym]=${ns} node[file]=${nf} other_cg=${oc} | Read=${reads.length}${reads.length?" ("+reads.join(", ")+")":""} Grep=${gr} [cg exposed=${exposed}]`);
61
- ' "$1"
62
- }
63
-
64
- run(){ # label, cfg, prewarm(0/1)
65
- local label="$1" cfg="$2" pw="$3"
66
- for i in $(seq 1 "$RUNS"); do
67
- [ "$pw" = "1" ] && prewarm
68
- ( cd "$TGT" && claude -p "$Q" --output-format stream-json --verbose \
69
- --permission-mode bypassPermissions --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4 \
70
- --strict-mcp-config --mcp-config "$cfg" </dev/null > "$OUT/$label-$i.jsonl" 2>"$OUT/$label-$i.err" )
71
- echo "[$label] run $i:"; analyze "$OUT/$label-$i.jsonl"
72
- done
73
- echo
74
- }
75
-
76
- echo "== WITH homegraph (premise: explore/node used -> Read ~0) =="; run with "$OUT/mcp-cg.json" 1
77
- echo "== WITHOUT (Read/Grep only — the contrast) =="; run without "$OUT/mcp-empty.json" 0
78
- echo "###### DONE. In the WITH arm: are explore/node>0 and Read~0? Any Read of an INDEXED source file = sufficiency gap. Logs: $OUT"
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Arm F (body-inlining trace + trace-first steering) across the same 6 repos as
3
- # arms-matrix.sh, so F vs B isolates the trace-enrichment effect (same surface,
4
- # old thin trace in B vs body-inlining trace here).
5
- set -uo pipefail
6
- H="$(cd "$(dirname "$0")" && pwd)"; RUNS="${RUNS:-2}"; C="${CORPUS:-/tmp/homegraph-corpus}"
7
- ROWS=(
8
- "$C/flutter-samples/add_to_app/books/flutter_module_books|How does the books UI build and what child widgets does it show?"
9
- "$C/aspnet-realworld|How is creating an article handled? Trace the controller to the service."
10
- "$C/spring-mall|How is a product-list request handled? Trace the controller to the service."
11
- "$C/vapor-spi|How is a package-show request handled? Name the route and controller."
12
- "$C/excalidraw|How does updating an element re-render the canvas on screen? Trace the flow."
13
- "$C/spring-halo|How is publishing a post handled? Trace the controller to the service."
14
- )
15
- ARM="${ARM:-F}"
16
- echo "### ARM $ARM START $(date) RUNS=$RUNS"
17
- for row in "${ROWS[@]}"; do
18
- repo="${row%%|*}"; q="${row#*|}"
19
- for r in $(seq 1 "$RUNS"); do bash "$H/run-arms.sh" "$repo" "$q" "$ARM" "$r"; done
20
- done
21
- echo "### ARM $ARM COMPLETE $(date)"