homegraph 1.5.0 → 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 (213) hide show
  1. package/dist/bin/command-supervision.d.ts.map +1 -1
  2. package/dist/bin/command-supervision.js +7 -4
  3. package/dist/bin/command-supervision.js.map +1 -1
  4. package/dist/extraction/index.d.ts +1 -1
  5. package/dist/extraction/index.d.ts.map +1 -1
  6. package/dist/extraction/index.js +54 -43
  7. package/dist/extraction/index.js.map +1 -1
  8. package/dist/extraction/languages/arkts.d.ts +69 -12
  9. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  10. package/dist/extraction/languages/arkts.js +739 -86
  11. package/dist/extraction/languages/arkts.js.map +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp/diff-impact.d.ts +131 -0
  16. package/dist/mcp/diff-impact.d.ts.map +1 -0
  17. package/dist/mcp/diff-impact.js +385 -0
  18. package/dist/mcp/diff-impact.js.map +1 -0
  19. package/dist/mcp/liveness-watchdog.d.ts +18 -0
  20. package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  21. package/dist/mcp/liveness-watchdog.js +134 -22
  22. package/dist/mcp/liveness-watchdog.js.map +1 -1
  23. package/dist/mcp/server-instructions.d.ts +1 -1
  24. package/dist/mcp/server-instructions.d.ts.map +1 -1
  25. package/dist/mcp/server-instructions.js +2 -0
  26. package/dist/mcp/server-instructions.js.map +1 -1
  27. package/dist/mcp/tools.d.ts +21 -5
  28. package/dist/mcp/tools.d.ts.map +1 -1
  29. package/dist/mcp/tools.js +305 -55
  30. package/dist/mcp/tools.js.map +1 -1
  31. package/dist/resolution/callback-synthesizer.d.ts +2 -1
  32. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  33. package/dist/resolution/callback-synthesizer.js +153 -53
  34. package/dist/resolution/callback-synthesizer.js.map +1 -1
  35. package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -1
  36. package/dist/resolution/frameworks/arkts-entry.js +20 -9
  37. package/dist/resolution/frameworks/arkts-entry.js.map +1 -1
  38. package/dist/resolution/index.d.ts.map +1 -1
  39. package/dist/resolution/index.js +1 -1
  40. package/dist/resolution/index.js.map +1 -1
  41. package/dist/resolution/memory-budget.d.ts +33 -0
  42. package/dist/resolution/memory-budget.d.ts.map +1 -1
  43. package/dist/resolution/memory-budget.js +58 -0
  44. package/dist/resolution/memory-budget.js.map +1 -1
  45. package/dist/resolution/resolver-pool.d.ts +2 -0
  46. package/dist/resolution/resolver-pool.d.ts.map +1 -1
  47. package/dist/resolution/resolver-pool.js +4 -0
  48. package/dist/resolution/resolver-pool.js.map +1 -1
  49. package/dist/ui/shimmer-progress.d.ts.map +1 -1
  50. package/dist/ui/shimmer-progress.js +4 -1
  51. package/dist/ui/shimmer-progress.js.map +1 -1
  52. package/package.json +4 -5
  53. package/dist/arkts/ohos-api-index.d.ts +0 -15
  54. package/dist/arkts/ohos-api-index.d.ts.map +0 -1
  55. package/dist/arkts/ohos-api-index.js +0 -190
  56. package/dist/arkts/ohos-api-index.js.map +0 -1
  57. package/dist/arkts/ohos-sdk-input.d.ts +0 -36
  58. package/dist/arkts/ohos-sdk-input.d.ts.map +0 -1
  59. package/dist/arkts/ohos-sdk-input.js +0 -214
  60. package/dist/arkts/ohos-sdk-input.js.map +0 -1
  61. package/dist/extraction/languages/arkts-state-decorators.d.ts +0 -13
  62. package/dist/extraction/languages/arkts-state-decorators.d.ts.map +0 -1
  63. package/dist/extraction/languages/arkts-state-decorators.js +0 -26
  64. package/dist/extraction/languages/arkts-state-decorators.js.map +0 -1
  65. package/dist/extraction/languages/arkts-viewtree.d.ts +0 -24
  66. package/dist/extraction/languages/arkts-viewtree.d.ts.map +0 -1
  67. package/dist/extraction/languages/arkts-viewtree.js +0 -148
  68. package/dist/extraction/languages/arkts-viewtree.js.map +0 -1
  69. package/dist/extraction/languages/ohos-api-consumer.d.ts +0 -34
  70. package/dist/extraction/languages/ohos-api-consumer.d.ts.map +0 -1
  71. package/dist/extraction/languages/ohos-api-consumer.js +0 -283
  72. package/dist/extraction/languages/ohos-api-consumer.js.map +0 -1
  73. package/dist/reasoning/config.d.ts +0 -45
  74. package/dist/reasoning/config.d.ts.map +0 -1
  75. package/dist/reasoning/config.js +0 -171
  76. package/dist/reasoning/config.js.map +0 -1
  77. package/dist/reasoning/credentials.d.ts +0 -5
  78. package/dist/reasoning/credentials.d.ts.map +0 -1
  79. package/dist/reasoning/credentials.js +0 -83
  80. package/dist/reasoning/credentials.js.map +0 -1
  81. package/dist/reasoning/login.d.ts +0 -21
  82. package/dist/reasoning/login.d.ts.map +0 -1
  83. package/dist/reasoning/login.js +0 -85
  84. package/dist/reasoning/login.js.map +0 -1
  85. package/dist/reasoning/reasoner.d.ts +0 -43
  86. package/dist/reasoning/reasoner.d.ts.map +0 -1
  87. package/dist/reasoning/reasoner.js +0 -308
  88. package/dist/reasoning/reasoner.js.map +0 -1
  89. package/dist/spec/build/git-scanner.d.ts +0 -93
  90. package/dist/spec/build/git-scanner.d.ts.map +0 -1
  91. package/dist/spec/build/git-scanner.js +0 -254
  92. package/dist/spec/build/git-scanner.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/git-utils.d.ts +0 -8
  102. package/dist/spec/git-utils.d.ts.map +0 -1
  103. package/dist/spec/git-utils.js +0 -14
  104. package/dist/spec/git-utils.js.map +0 -1
  105. package/dist/spec/llm/index.d.ts +0 -3
  106. package/dist/spec/llm/index.d.ts.map +0 -1
  107. package/dist/spec/llm/index.js +0 -11
  108. package/dist/spec/llm/index.js.map +0 -1
  109. package/dist/spec/mine/clusterer.d.ts +0 -63
  110. package/dist/spec/mine/clusterer.d.ts.map +0 -1
  111. package/dist/spec/mine/clusterer.js +0 -904
  112. package/dist/spec/mine/clusterer.js.map +0 -1
  113. package/dist/spec/mine/progress-handler.d.ts +0 -22
  114. package/dist/spec/mine/progress-handler.d.ts.map +0 -1
  115. package/dist/spec/mine/progress-handler.js +0 -108
  116. package/dist/spec/mine/progress-handler.js.map +0 -1
  117. package/dist/spec/mine/progress.d.ts +0 -23
  118. package/dist/spec/mine/progress.d.ts.map +0 -1
  119. package/dist/spec/mine/progress.js +0 -12
  120. package/dist/spec/mine/progress.js.map +0 -1
  121. package/dist/spec/mining/diff-parser.d.ts +0 -33
  122. package/dist/spec/mining/diff-parser.d.ts.map +0 -1
  123. package/dist/spec/mining/diff-parser.js +0 -166
  124. package/dist/spec/mining/diff-parser.js.map +0 -1
  125. package/dist/spec/mining/git-scanner.d.ts +0 -103
  126. package/dist/spec/mining/git-scanner.d.ts.map +0 -1
  127. package/dist/spec/mining/git-scanner.js +0 -307
  128. package/dist/spec/mining/git-scanner.js.map +0 -1
  129. package/dist/spec/mining/pipeline.d.ts +0 -53
  130. package/dist/spec/mining/pipeline.d.ts.map +0 -1
  131. package/dist/spec/mining/pipeline.js +0 -178
  132. package/dist/spec/mining/pipeline.js.map +0 -1
  133. package/dist/spec/mining/scope-resolver.d.ts +0 -45
  134. package/dist/spec/mining/scope-resolver.d.ts.map +0 -1
  135. package/dist/spec/mining/scope-resolver.js +0 -103
  136. package/dist/spec/mining/scope-resolver.js.map +0 -1
  137. package/dist/spec/mining/spec-extractor.d.ts +0 -69
  138. package/dist/spec/mining/spec-extractor.d.ts.map +0 -1
  139. package/dist/spec/mining/spec-extractor.js +0 -369
  140. package/dist/spec/mining/spec-extractor.js.map +0 -1
  141. package/dist/spec/utils.d.ts +0 -155
  142. package/dist/spec/utils.d.ts.map +0 -1
  143. package/dist/spec/utils.js +0 -411
  144. package/dist/spec/utils.js.map +0 -1
  145. package/scripts/add-lang/bench.sh +0 -60
  146. package/scripts/add-lang/check-grammar.mjs +0 -75
  147. package/scripts/add-lang/dump-ast.mjs +0 -103
  148. package/scripts/add-lang/verify-extraction.mjs +0 -70
  149. package/scripts/agent-eval/ab-adoption.sh +0 -91
  150. package/scripts/agent-eval/ab-hook.sh +0 -86
  151. package/scripts/agent-eval/ab-impl.sh +0 -78
  152. package/scripts/agent-eval/ab-new-vs-baseline.sh +0 -102
  153. package/scripts/agent-eval/ab-sufficiency.sh +0 -78
  154. package/scripts/agent-eval/arms-F.sh +0 -21
  155. package/scripts/agent-eval/arms-matrix.sh +0 -37
  156. package/scripts/agent-eval/audit.sh +0 -68
  157. package/scripts/agent-eval/bench-readme.sh +0 -28
  158. package/scripts/agent-eval/bench-why-repo.sh +0 -22
  159. package/scripts/agent-eval/block-read-hook.sh +0 -19
  160. package/scripts/agent-eval/hook-settings.json +0 -15
  161. package/scripts/agent-eval/itrun.sh +0 -120
  162. package/scripts/agent-eval/offload-eval-3arm.sh +0 -72
  163. package/scripts/agent-eval/offload-eval-cost.mjs +0 -133
  164. package/scripts/agent-eval/offload-eval-effort.mjs +0 -108
  165. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +0 -25
  166. package/scripts/agent-eval/offload-eval-frontload.sh +0 -47
  167. package/scripts/agent-eval/offload-eval-ground-truth.json +0 -18
  168. package/scripts/agent-eval/offload-eval-hook.mjs +0 -84
  169. package/scripts/agent-eval/offload-eval-judge.mjs +0 -103
  170. package/scripts/agent-eval/offload-eval-matrix.sh +0 -20
  171. package/scripts/agent-eval/offload-eval-metrics.mjs +0 -94
  172. package/scripts/agent-eval/offload-eval-refs1.sh +0 -50
  173. package/scripts/agent-eval/offload-eval-setup.sh +0 -24
  174. package/scripts/agent-eval/offload-eval-styles.sh +0 -72
  175. package/scripts/agent-eval/offload-eval-summarize.mjs +0 -68
  176. package/scripts/agent-eval/offload-eval.md +0 -76
  177. package/scripts/agent-eval/parse-arms.mjs +0 -116
  178. package/scripts/agent-eval/parse-bench-readme.mjs +0 -84
  179. package/scripts/agent-eval/parse-run.mjs +0 -45
  180. package/scripts/agent-eval/parse-session.mjs +0 -93
  181. package/scripts/agent-eval/probe-context.mjs +0 -21
  182. package/scripts/agent-eval/probe-explore.mjs +0 -40
  183. package/scripts/agent-eval/probe-node.mjs +0 -20
  184. package/scripts/agent-eval/probe-sweep.mjs +0 -119
  185. package/scripts/agent-eval/probe-trace.mjs +0 -20
  186. package/scripts/agent-eval/redirect-read-hook.sh +0 -38
  187. package/scripts/agent-eval/repro-concurrent-explore.mjs +0 -119
  188. package/scripts/agent-eval/repro-daemon-clients.mjs +0 -125
  189. package/scripts/agent-eval/run-agent.sh +0 -34
  190. package/scripts/agent-eval/run-all.sh +0 -75
  191. package/scripts/agent-eval/run-arms.sh +0 -56
  192. package/scripts/agent-eval/seq-matrix.mjs +0 -137
  193. package/scripts/build-bundle.sh +0 -123
  194. package/scripts/exp_boundary_eval/README.md +0 -247
  195. package/scripts/exp_boundary_eval/_test_mcp_chain.py +0 -78
  196. package/scripts/exp_boundary_eval/_test_stdin.py +0 -8
  197. package/scripts/exp_boundary_eval/_utils.py +0 -1116
  198. package/scripts/exp_boundary_eval/analyze.py +0 -1313
  199. package/scripts/exp_boundary_eval/deveco_arm.py +0 -519
  200. package/scripts/exp_boundary_eval/run_all.py +0 -378
  201. package/scripts/exp_boundary_eval/run_one.py +0 -165
  202. package/scripts/exp_boundary_eval/run_session.py +0 -158
  203. package/scripts/exp_boundary_eval/setup.py +0 -120
  204. package/scripts/exp_boundary_eval/win_mcp_launcher.py +0 -73
  205. package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +0 -36
  206. package/scripts/exp_boundary_eval/win_node_launcher.py +0 -24
  207. package/scripts/extract-release-notes.mjs +0 -130
  208. package/scripts/local-install.sh +0 -41
  209. package/scripts/npm-sdk.js +0 -75
  210. package/scripts/npm-shim.js +0 -275
  211. package/scripts/ohos-sdk-publish.mjs +0 -133
  212. package/scripts/pack-npm.sh +0 -119
  213. package/scripts/prepare-release.mjs +0 -270
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env node
2
- // probe-sweep — direct MCP test across N repos × N tools, no claude needed.
3
- //
4
- // Measures response characteristics (size, sections present, signals fired)
5
- // for each (repo, query) pair against the built dist/. Sub-second per probe;
6
- // the full sweep below runs in ~10-30s vs hours for a real claude audit.
7
- //
8
- // Use this to iterate on backend changes rapidly: change tools.ts /
9
- // context-builder, npm run build, re-run probe-sweep, compare. Once a
10
- // change looks good on probe metrics, run a focused claude audit for the
11
- // few repos that matter to confirm end-to-end cost behavior.
12
- //
13
- // Usage: node scripts/agent-eval/probe-sweep.mjs [--tool=context|explore|trace] [--repos=a,b,c]
14
- import { pathToFileURL } from 'node:url';
15
- import { resolve } from 'node:path';
16
-
17
- const args = Object.fromEntries(
18
- process.argv.slice(2).map(a => a.startsWith('--') ? a.slice(2).split('=') : [a, true])
19
- );
20
- const TOOL = args.tool ?? 'context';
21
-
22
- const load = (rel) => import(pathToFileURL(resolve(rel)).href);
23
- const idx = await load('dist/index.js');
24
- const tools = await load('dist/mcp/tools.js');
25
- const HomeGraph = idx.default?.default ?? idx.default ?? idx.HomeGraph;
26
- const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
27
-
28
- // Each entry: repo, query, optional 2nd arg for trace (from, to).
29
- // The query is the same prompt used in the real claude audits, so probe
30
- // output is directly comparable to the agent's would-be input.
31
- const SWEEP = [
32
- // Small realworld template repos (the loss cases from the cross-language sweep)
33
- { id: 'gin-rw', repo: '/tmp/homegraph-corpus/gin-realworld', q: 'How does this Gin app route a request through its middleware chain to a handler?' },
34
- { id: 'go-mux', repo: '/tmp/homegraph-corpus/go-mux', q: 'How does this gorilla/mux app route a request to its handler?' },
35
- { id: 'fastapi-rw', repo: '/tmp/homegraph-corpus/fastapi-realworld', q: 'How does FastAPI route a request through its dependencies to a handler?' },
36
- { id: 'spring-pc', repo: '/tmp/homegraph-corpus/spring-petclinic', q: 'How does Spring route an HTTP request to a controller method?' },
37
- { id: 'axum-rw', repo: '/tmp/homegraph-corpus/rust-axum-realworld', q: 'How does Axum route a request to its handler in this app?' },
38
- { id: 'express-rw', repo: '/tmp/homegraph-corpus/express-realworld', q: 'How does this Express app route a request through middleware to a handler?' },
39
- { id: 'kotlin-pc', repo: '/tmp/homegraph-corpus/kotlin-petclinic', q: 'How does the Kotlin Spring app route an HTTP request to its handler?' },
40
- { id: 'flask-mb', repo: '/tmp/homegraph-corpus/flask-microblog', q: 'How does this Flask app route a request to a view function?' },
41
- { id: 'vapor-tpl', repo: '/tmp/homegraph-corpus/vapor-template', q: 'How does Vapor route an HTTP request to its handler?' },
42
- { id: 'cpp-leveldb', repo: '/tmp/homegraph-corpus/cpp-leveldb', q: 'How does LevelDB handle a Put operation through to disk?' },
43
- { id: 'lualine', repo: '/tmp/homegraph-corpus/lualine.nvim', q: 'How does lualine assemble and render the statusline?' },
44
- { id: 'drupal-admin', repo: '/tmp/homegraph-corpus/drupal-admintoolbar', q: 'How does the Drupal admin toolbar module render its toolbar?' },
45
- { id: 'svelte-rw', repo: '/tmp/homegraph-corpus/svelte-realworld', q: 'How does this SvelteKit app route a request to a handler?' },
46
- { id: 'react-rw', repo: '/tmp/homegraph-corpus/react-realworld', q: 'How does this React app fetch and display articles?' },
47
- { id: 'rails-rw', repo: '/tmp/homegraph-corpus/rails-realworld', q: 'How does Rails route a request to a controller action?' },
48
- { id: 'flask-rest', repo: '/tmp/homegraph-corpus/flask-restful-realworld', q: 'How does Flask-RESTful route a request to a resource method?' },
49
- { id: 'laravel-rw', repo: '/tmp/homegraph-corpus/laravel-realworld', q: 'How does Laravel route a request to the controller method?' },
50
- { id: 'aspnet-rw', repo: '/tmp/homegraph-corpus/aspnet-realworld', q: 'How does ASP.NET route a request to the controller action?' },
51
- // The iter7 wins/ties (to make sure we don't regress)
52
- { id: 'cobra', repo: '/tmp/homegraph-corpus/cobra', q: 'How does cobra parse commands and flags?' },
53
- { id: 'sinatra', repo: '/tmp/homegraph-corpus/sinatra', q: 'How does sinatra route a request to its handler?' },
54
- { id: 'slim', repo: '/tmp/homegraph-corpus/slim', q: 'How does slim route a request and apply middleware?' },
55
- ];
56
-
57
- // Detect signals in response text — these are the levers we've added that
58
- // otherwise only show up via "agent ran X more tool calls" downstream.
59
- const detect = (text) => ({
60
- hasEntryPoints: /^### Entry Points/m.test(text),
61
- hasRelatedSymbols: /^### Related Symbols/m.test(text),
62
- hasFlowTrace: /^## Inline flow trace/m.test(text),
63
- hasRouteManifest: /^## Routing manifest/m.test(text),
64
- hasTopHandler: /^### Top handler file/m.test(text),
65
- hasSmallRepoTail: /This project is small/.test(text),
66
- });
67
-
68
- const filterRepos = args.repos ? new Set(String(args.repos).split(',')) : null;
69
- const subjects = SWEEP.filter(s => !filterRepos || filterRepos.has(s.id));
70
-
71
- const t0 = Date.now();
72
- const rows = [];
73
- for (const s of subjects) {
74
- try {
75
- const cg = HomeGraph.openSync(s.repo);
76
- const handler = new ToolHandler(cg);
77
- const t1 = Date.now();
78
- const res = await handler.execute('homegraph_' + TOOL,
79
- TOOL === 'context' ? { task: s.q } :
80
- TOOL === 'explore' ? { query: s.q } : { from: 'main', to: 'main' });
81
- const text = res.content?.[0]?.text ?? '';
82
- const signals = detect(text);
83
- rows.push({
84
- id: s.id,
85
- ms: Date.now() - t1,
86
- chars: text.length,
87
- lines: text.split('\n').length,
88
- ...signals,
89
- });
90
- try { cg.close?.(); } catch {}
91
- } catch (e) {
92
- rows.push({ id: s.id, error: String(e).slice(0, 80) });
93
- }
94
- }
95
-
96
- // Pretty-print as a compact table.
97
- const fmt = (r) =>
98
- r.error
99
- ? ` ${r.id.padEnd(13)} ERROR: ${r.error}`
100
- : ` ${r.id.padEnd(13)} ${String(r.chars).padStart(6)}c ${String(r.lines).padStart(4)}L ${String(r.ms).padStart(4)}ms` +
101
- ` ${r.hasEntryPoints ? 'EP ' : ' '}` +
102
- `${r.hasFlowTrace ? 'TRC ' : ' '}` +
103
- `${r.hasRouteManifest ? 'MAN ' : ' '}` +
104
- `${r.hasTopHandler ? 'HND ' : ' '}` +
105
- `${r.hasSmallRepoTail ? 'TAIL' : ' '}`;
106
- console.log(`=== probe-sweep tool=${TOOL} n=${subjects.length} (${Date.now() - t0}ms total) ===`);
107
- console.log(' id chars lines ms signals');
108
- console.log(' ' + '-'.repeat(56));
109
- for (const r of rows) console.log(fmt(r));
110
-
111
- // Sum + medians for the size pillar
112
- const sizes = rows.filter(r => !r.error).map(r => r.chars);
113
- sizes.sort((a, b) => a - b);
114
- const median = sizes[Math.floor(sizes.length / 2)];
115
- const sum = sizes.reduce((a, b) => a + b, 0);
116
- console.log(` ${'-'.repeat(64)}`);
117
- console.log(` median=${median}c total=${sum}c ` +
118
- `manifest=${rows.filter(r => r.hasRouteManifest).length}/${rows.filter(r => !r.error).length} ` +
119
- `top-handler=${rows.filter(r => r.hasTopHandler).length}/${rows.filter(r => !r.error).length}`);
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- // Probe homegraph_trace against an index using the built dist.
3
- // Usage: node probe-trace.mjs <repo-with-.homegraph> <from> <to>
4
- import { pathToFileURL } from 'node:url';
5
- import { resolve } from 'node:path';
6
-
7
- const [, , repo, from, to] = process.argv;
8
- if (!repo || !from || !to) { console.error('usage: probe-trace.mjs <repo> <from> <to>'); process.exit(1); }
9
-
10
- const load = async (rel) => import(pathToFileURL(resolve(rel)).href);
11
- const idx = await load('dist/index.js');
12
- const tools = await load('dist/mcp/tools.js');
13
- const HomeGraph = idx.default?.default ?? idx.default ?? idx.HomeGraph;
14
- const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
15
-
16
- const cg = HomeGraph.openSync(repo);
17
- const h = new ToolHandler(cg);
18
- const res = await h.execute('homegraph_trace', { from, to });
19
- console.log(res.content?.[0]?.text ?? '(no text)');
20
- try { cg.close?.(); } catch {}
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env bash
2
- # PreToolUse(Read) REDIRECT hook — prototype for A/B (P1: get agents off Read and
3
- # onto homegraph_node during implementation, not just for Q&A).
4
- #
5
- # When the agent Reads a SOURCE file, deny it and steer to homegraph_node's
6
- # file-view, which (as of the Lever-1 change) returns the WHOLE file verbatim
7
- # WITH line numbers — imports, top-level code, comments and all — PLUS the file's
8
- # blast radius, in one call. That output is a strict superset of Read, so the
9
- # redirect is lossless: the agent loses nothing by taking it, and gains who-
10
- # depends-on-this for the edit it's about to make.
11
- #
12
- # Differs from block-read-hook.sh (which steers to explore/node-by-symbol): this
13
- # names the FILE-VIEW path explicitly (file:"<base>" + includeCode:true), the
14
- # 1:1 Read replacement we're trying to get picked during implementation.
15
- #
16
- # Non-source files (configs, docs, lockfiles, .env) pass through to a real Read.
17
- # A redirect to a file homegraph hasn't indexed SELF-CORRECTS: the file-view
18
- # replies "No indexed file matches … Read it directly", so a just-created file
19
- # never dead-ends — the agent Reads it on the next turn.
20
- #
21
- # Wire via: claude ... --settings <settings-with-this-as-PreToolUse(Read)>
22
- # Eval artifact only. The production version is an indexed-aware `homegraph`
23
- # subcommand (cross-platform — no bash/jq — and queries the index so it never
24
- # bounces a new/un-indexed file), wired opt-in by the installer.
25
- set -uo pipefail
26
- input="$(cat)"
27
- fp="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty' 2>/dev/null)"
28
- [ -n "$fp" ] || exit 0
29
- base="$(basename "$fp")"
30
-
31
- case "$fp" in
32
- *.ts|*.tsx|*.js|*.jsx|*.mjs|*.cjs|*.py|*.go|*.rs|*.java|*.rb|*.php|*.swift|*.kt|*.kts|*.scala|*.c|*.cc|*.cpp|*.h|*.hpp|*.cs|*.lua|*.vue|*.svelte|*.m|*.mm)
33
- msg="homegraph has this file indexed (kept in sync on every edit). Call homegraph_node with file:\"$base\" and includeCode:true instead of Read — it returns the WHOLE file verbatim WITH line numbers (imports, top-level code and all — safe to base an Edit on) PLUS which files depend on it, in one call. Treat its output as already-Read; do not Read this file. (If it answers that the file isn't indexed — e.g. you just created it — then Read it directly.)"
34
- jq -n --arg m "$msg" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$m}}'
35
- exit 0
36
- ;;
37
- esac
38
- exit 0
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env node
2
- // Reproduction harness A — does the shared daemon serialize concurrent explore?
3
- //
4
- // Mirrors the daemon's reality: ONE CodeGraph + ONE ToolHandler (as MCPEngine
5
- // shares across all sessions), then fires N concurrent codegraph_explore calls
6
- // and measures:
7
- // - each call's wall-clock latency + completion order
8
- // - an event-loop HEARTBEAT (setInterval 50ms): the max gap between ticks is a
9
- // direct measure of how long synchronous compute blocked the loop. In the
10
- // real daemon a blocked loop can't flush a finished response or read the
11
- // next request, so this gap is what starves the MCP transport.
12
- //
13
- // Usage: node repro-concurrent-explore.mjs <repo-with-.codegraph> <N> [timeoutMs]
14
- import { pathToFileURL } from 'node:url';
15
- import { resolve } from 'node:path';
16
- import { performance } from 'node:perf_hooks';
17
-
18
- const [, , repo, nRaw, timeoutRaw] = process.argv;
19
- if (!repo) {
20
- console.error('usage: repro-concurrent-explore.mjs <repo> <N=10> [timeoutMs=60000]');
21
- process.exit(1);
22
- }
23
- const N = Number(nRaw) || 10;
24
- const TIMEOUT_MS = Number(timeoutRaw) || 60000; // ~ MCP SDK default request timeout
25
-
26
- const load = async (rel) => import(pathToFileURL(resolve(rel)).href);
27
- const idx = await load('dist/index.js');
28
- const tools = await load('dist/mcp/tools.js');
29
- const CodeGraph = idx.default?.default ?? idx.default ?? idx.CodeGraph;
30
- const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
31
-
32
- // Distinct queries so no two calls are trivially identical. Mix of NL questions
33
- // (exercise FTS + RWR over the whole graph) — the expensive explore path.
34
- const QUERIES = [
35
- 'how does the text model handle edits and undo',
36
- 'how does the file service watch for changes on disk',
37
- 'how does the keybinding service resolve a chord to a command',
38
- 'how does the extension host activate an extension',
39
- 'how does the editor render decorations in the viewport',
40
- 'how does the search service stream results to the UI',
41
- 'how does the terminal process manager spawn a shell',
42
- 'how does the configuration service merge user and workspace settings',
43
- 'how does the debug adapter forward breakpoints to the runtime',
44
- 'how does the quick input widget filter its items',
45
- 'how does the notification service queue and show toasts',
46
- 'how does the git extension compute the diff for a file',
47
- 'how does the language features registry dispatch a hover request',
48
- 'how does the workbench layout restore editor groups on reload',
49
- 'how does the storage service persist state between sessions',
50
- 'how does the menu service build a context menu from contributions',
51
- ];
52
-
53
- const cg = CodeGraph.openSync(repo);
54
- let fileCount = 0;
55
- try { fileCount = cg.getStats().fileCount; } catch {}
56
- const handler = new ToolHandler(cg);
57
-
58
- // --- event-loop heartbeat ---
59
- let lastTick = performance.now();
60
- let maxGap = 0;
61
- const gaps = [];
62
- const hb = setInterval(() => {
63
- const now = performance.now();
64
- const gap = now - lastTick;
65
- lastTick = now;
66
- if (gap > 60) gaps.push(Math.round(gap)); // expected ~50ms; record stalls
67
- if (gap > maxGap) maxGap = gap;
68
- }, 50);
69
-
70
- function runOne(i) {
71
- const q = QUERIES[i % QUERIES.length];
72
- const startedAt = performance.now();
73
- let timer;
74
- const timeout = new Promise((res) => {
75
- timer = setTimeout(() => res({ timedOut: true }), TIMEOUT_MS);
76
- });
77
- const work = handler
78
- .execute('codegraph_explore', { query: q })
79
- .then((r) => ({ ok: !r.isError, chars: r.content?.[0]?.text?.length ?? 0 }))
80
- .catch((e) => ({ ok: false, err: String(e?.message ?? e) }));
81
- return Promise.race([work, timeout]).then((r) => {
82
- clearTimeout(timer);
83
- return { i, q, ms: Math.round(performance.now() - startedAt), ...r };
84
- });
85
- }
86
-
87
- // Baseline: one warm single call (so the first-call cold paths don't skew N).
88
- const warmStart = performance.now();
89
- await runOne(0);
90
- const warmMs = Math.round(performance.now() - warmStart);
91
-
92
- // Reset heartbeat stats for the concurrent run.
93
- gaps.length = 0; maxGap = 0; lastTick = performance.now();
94
-
95
- const batchStart = performance.now();
96
- const results = await Promise.all(Array.from({ length: N }, (_, i) => runOne(i)));
97
- const batchMs = Math.round(performance.now() - batchStart);
98
- clearInterval(hb);
99
-
100
- const lat = results.map((r) => r.ms).sort((a, b) => a - b);
101
- const timeouts = results.filter((r) => r.timedOut).length;
102
- const p = (q) => lat[Math.min(lat.length - 1, Math.floor(q * lat.length))];
103
-
104
- console.log('='.repeat(64));
105
- console.log(`repo=${repo}`);
106
- console.log(`fileCount=${fileCount} N=${N} perCallTimeout=${TIMEOUT_MS}ms`);
107
- console.log(`single warm explore: ${warmMs}ms`);
108
- console.log('-'.repeat(64));
109
- console.log(`concurrent batch wall-clock: ${batchMs}ms`);
110
- console.log(`per-call latency min=${lat[0]} p50=${p(0.5)} p90=${p(0.9)} max=${lat[lat.length - 1]} (ms)`);
111
- console.log(`TIMEOUTS (>${TIMEOUT_MS}ms): ${timeouts} / ${N}`);
112
- console.log(`event-loop max stall: ${Math.round(maxGap)}ms stalls>60ms: ${gaps.length}`);
113
- console.log(` sum of stalls: ${gaps.reduce((a, b) => a + b, 0)}ms biggest 5: ${gaps.sort((a,b)=>b-a).slice(0,5).join(', ')}`);
114
- console.log('-'.repeat(64));
115
- console.log('SERIALIZATION CHECK:');
116
- console.log(` if serialized, batch ≈ N×single = ~${N * warmMs}ms; actual=${batchMs}ms (ratio ${(batchMs / (N * warmMs)).toFixed(2)})`);
117
- console.log(` max latency / single = ${(lat[lat.length - 1] / warmMs).toFixed(1)}× (≈N means last call waited for all others)`);
118
- console.log('='.repeat(64));
119
- try { cg.close?.(); } catch {}
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- // Reproduction harness B — the FAITHFUL opencode scenario.
3
- //
4
- // Spawns N real `codegraph serve --mcp --path <repo>` processes (each becomes a
5
- // proxy that attaches to ONE shared daemon — exactly what opencode does with N
6
- // subagents), drives clean MCP JSON-RPC over each child's stdio, then fires ONE
7
- // concurrent wave of codegraph_explore tools/call across all N and measures
8
- // end-to-end latency + timeouts. This captures transport-flush starvation: a
9
- // daemon event-loop blocked in synchronous explore compute can neither read the
10
- // next request nor flush a finished response.
11
- //
12
- // Usage: node repro-daemon-clients.mjs <repo> <N=10> [perCallTimeoutMs=60000] [warm=1]
13
- import { spawn } from 'node:child_process';
14
- import { performance } from 'node:perf_hooks';
15
- import { resolve } from 'node:path';
16
-
17
- const [, , repoRaw, nRaw, timeoutRaw, warmRaw] = process.argv;
18
- const repo = resolve(repoRaw || '.');
19
- const N = Number(nRaw) || 10;
20
- const TIMEOUT_MS = Number(timeoutRaw) || 60000;
21
- const WARM = warmRaw === undefined ? true : warmRaw !== '0';
22
- const CLI = resolve('dist/bin/codegraph.js');
23
-
24
- const QUERIES = [
25
- 'how does the text model handle edits and undo',
26
- 'how does the file service watch for changes on disk',
27
- 'how does the keybinding service resolve a chord to a command',
28
- 'how does the extension host activate an extension',
29
- 'how does the editor render decorations in the viewport',
30
- 'how does the search service stream results to the UI',
31
- 'how does the terminal process manager spawn a shell',
32
- 'how does the configuration service merge user and workspace settings',
33
- 'how does the debug adapter forward breakpoints to the runtime',
34
- 'how does the quick input widget filter its items',
35
- 'how does the notification service queue and show toasts',
36
- 'how does the git extension compute the diff for a file',
37
- ];
38
-
39
- function makeClient(id) {
40
- const child = spawn('node', [CLI, 'serve', '--mcp', '--path', repo], {
41
- env: { ...process.env, CODEGRAPH_TELEMETRY: '0', DO_NOT_TRACK: '1', CODEGRAPH_MCP_LOG_ATTACH: '0' },
42
- stdio: ['pipe', 'pipe', 'inherit'],
43
- });
44
- let buf = '';
45
- const waiters = new Map(); // id -> resolve
46
- child.stdout.setEncoding('utf8');
47
- child.stdout.on('data', (chunk) => {
48
- buf += chunk;
49
- let idx;
50
- while ((idx = buf.indexOf('\n')) !== -1) {
51
- const line = buf.slice(0, idx).trim();
52
- buf = buf.slice(idx + 1);
53
- if (!line) continue;
54
- let msg; try { msg = JSON.parse(line); } catch { continue; }
55
- if (msg.id !== undefined && waiters.has(msg.id)) {
56
- waiters.get(msg.id)(msg);
57
- waiters.delete(msg.id);
58
- }
59
- }
60
- });
61
- const send = (obj) => child.stdin.write(JSON.stringify(obj) + '\n');
62
- const request = (method, params, rpcId, timeoutMs) =>
63
- new Promise((res) => {
64
- let timer;
65
- if (timeoutMs) timer = setTimeout(() => { waiters.delete(rpcId); res({ __timeout: true }); }, timeoutMs);
66
- waiters.set(rpcId, (m) => { if (timer) clearTimeout(timer); res(m); });
67
- send({ jsonrpc: '2.0', id: rpcId, method, params });
68
- });
69
- return { id, child, send, request };
70
- }
71
-
72
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
73
-
74
- const clients = Array.from({ length: N }, (_, i) => makeClient(i));
75
-
76
- // Initialize every client (handshake is answered locally by each proxy, instant).
77
- await Promise.all(clients.map((c) =>
78
- c.request('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'repro', version: '1' } }, `init-${c.id}`, 10000)
79
- .then(() => c.send({ jsonrpc: '2.0', method: 'initialized' }))
80
- ));
81
-
82
- // Warm the daemon: one explore through client 0 forces daemon spawn + project
83
- // open + catch-up gate to complete, so the concurrent wave measures the STEADY
84
- // state (the user's real scenario after the first call), not cold start.
85
- if (WARM) {
86
- process.stderr.write('[repro] warming daemon (first explore triggers spawn+open+catchup)...\n');
87
- const t0 = performance.now();
88
- const r = await clients[0].request('tools/call', { name: 'codegraph_explore', arguments: { query: QUERIES[0] } }, 'warm-0', 120000);
89
- process.stderr.write(`[repro] warm explore took ${Math.round(performance.now() - t0)}ms (timeout=${!!r.__timeout})\n`);
90
- await sleep(500);
91
- }
92
-
93
- // THE WAVE: fire one explore on every client as simultaneously as possible.
94
- process.stderr.write(`[repro] firing ${N} concurrent explores...\n`);
95
- const waveStart = performance.now();
96
- const results = await Promise.all(clients.map((c, i) => {
97
- const started = performance.now();
98
- return c.request('tools/call', { name: 'codegraph_explore', arguments: { query: QUERIES[i % QUERIES.length] } }, `call-${c.id}`, TIMEOUT_MS)
99
- .then((m) => ({
100
- id: c.id,
101
- ms: Math.round(performance.now() - started),
102
- timedOut: !!m.__timeout,
103
- ok: !!m.result && !m.result.isError,
104
- chars: m.result?.content?.[0]?.text?.length ?? 0,
105
- }));
106
- }));
107
- const waveMs = Math.round(performance.now() - waveStart);
108
-
109
- const lat = results.map((r) => r.ms).sort((a, b) => a - b);
110
- const timeouts = results.filter((r) => r.timedOut).length;
111
- const p = (q) => lat[Math.min(lat.length - 1, Math.floor(q * lat.length))];
112
-
113
- console.log('='.repeat(64));
114
- console.log(`HARNESS B (real daemon + ${N} proxies) repo=${repo}`);
115
- console.log(`warm=${WARM} perCallTimeout=${TIMEOUT_MS}ms`);
116
- console.log('-'.repeat(64));
117
- console.log(`wave wall-clock: ${waveMs}ms`);
118
- console.log(`per-call latency min=${lat[0]} p50=${p(0.5)} p90=${p(0.9)} max=${lat[lat.length - 1]} (ms)`);
119
- console.log(`TIMEOUTS (>${TIMEOUT_MS}ms): ${timeouts} / ${N}`);
120
- console.log(`completion order (id:ms): ${results.slice().sort((a,b)=>a.ms-b.ms).map(r=>`${r.id}:${r.ms}`).join(' ')}`);
121
- console.log('='.repeat(64));
122
-
123
- for (const c of clients) { try { c.child.stdin.end(); c.child.kill('SIGTERM'); } catch {} }
124
- await sleep(300);
125
- process.exit(0);
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Headless Claude Code run against a repo with homegraph MCP, capturing the
3
- # full stream-json so we can see tool calls + token usage. Complements the
4
- # interactive itrun.sh: headless gives a clean per-tool breakdown + exact
5
- # tokens/cost, but defaults to the general-purpose subagent (not Explore).
6
- # To force the Explore path, ask for it in the prompt.
7
- #
8
- # Usage: run-agent.sh <repo-path> <label> "<prompt>"
9
- # Env: AGENT_EVAL_OUT (default /tmp/agent-eval), CG_BIN (homegraph dist binary)
10
- set -uo pipefail
11
-
12
- REPO="$1"; LABEL="$2"; PROMPT="$3"
13
- CG_BIN="${CG_BIN:-$(command -v homegraph || echo /usr/local/bin/homegraph)}"
14
- OUT_DIR="${AGENT_EVAL_OUT:-/tmp/agent-eval}"; mkdir -p "$OUT_DIR"
15
- OUT="$OUT_DIR/run-${LABEL}.jsonl"
16
-
17
- MCP_CONFIG=$(cat <<JSON
18
- {"mcpServers":{"homegraph":{"command":"${CG_BIN}","args":["serve","--mcp","--path","${REPO}"]}}}
19
- JSON
20
- )
21
-
22
- echo "→ running [$LABEL] in $REPO"
23
- cd "$REPO" || exit 1
24
-
25
- claude -p "$PROMPT" \
26
- --output-format stream-json --verbose \
27
- --permission-mode bypassPermissions \
28
- --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" \
29
- --max-budget-usd 2 \
30
- --strict-mcp-config --mcp-config "$MCP_CONFIG" \
31
- > "$OUT" 2>"$OUT_DIR/run-${LABEL}.err"
32
-
33
- echo "exit: $? | wrote $OUT ($(wc -l < "$OUT") lines)"
34
- node "$(cd "$(dirname "$0")" && pwd)/parse-run.mjs" "$OUT" 2>/dev/null || true
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env bash
2
- # With/without A/B (and optional interactive) eval for a homegraph version on a
3
- # repo. Codegraph is the ONLY variable: both arms launch claude with
4
- # --strict-mcp-config — with = homegraph-only MCP (pointed at $CG_BIN),
5
- # without = empty MCP. Built-in Read/Grep/Bash stay available in both arms.
6
- #
7
- # Usage: run-all.sh <repo-path> "<question>" [headless|tmux|all]
8
- # Env: CG_BIN homegraph binary (default: command -v homegraph)
9
- # AGENT_EVAL_OUT output dir (default: /tmp/agent-eval)
10
- # MODEL / EFFORT claude model/effort (default: sonnet / high — the
11
- # standing A/B policy; see CLAUDE.md, don't raise)
12
- set -uo pipefail
13
-
14
- REPO="${1:?usage: run-all.sh <repo-path> \"<question>\" [headless|tmux|all]}"
15
- Q="${2:?question required}"
16
- MODE="${3:-headless}"
17
- CG_BIN="${CG_BIN:-$(command -v homegraph)}"
18
- OUT="${AGENT_EVAL_OUT:-/tmp/agent-eval}"
19
- HARNESS="$(cd "$(dirname "$0")" && pwd)"
20
- mkdir -p "$OUT"
21
-
22
- # Neutralize any ambient HomeGraph prompt-hook (~/.claude) in BOTH arms:
23
- # the hook injects homegraph context into every prompt, which contaminates
24
- # the without-arm (free structural context) and double-counts the with-arm.
25
- # The A/B's only variable must be the MCP server wired below.
26
- export HOMEGRAPH_NO_PROMPT_HOOK=1
27
-
28
- [ -n "$CG_BIN" ] || { echo "no homegraph binary on PATH (set CG_BIN)"; exit 1; }
29
- [ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO — index it first"; exit 1; }
30
- case "$MODE" in headless|tmux|all) ;; *) echo "mode must be headless|tmux|all (got '$MODE')"; exit 1;; esac
31
-
32
- # MCP config files (path form avoids inline-JSON quoting through tmux).
33
- cat > "$OUT/mcp-homegraph.json" <<JSON
34
- {"mcpServers":{"homegraph":{"command":"$CG_BIN","args":["serve","--mcp","--path","$REPO"]}}}
35
- JSON
36
- echo '{"mcpServers":{}}' > "$OUT/mcp-empty.json"
37
-
38
- echo "###### homegraph: $CG_BIN"
39
- echo "###### repo: $REPO"
40
- echo "###### question: $Q"
41
- echo
42
-
43
- # Headless arm: claude -p with stream-json -> exact tool sequence + tokens/cost.
44
- headless() {
45
- local label="$1" cfg="$2"
46
- echo "############################## HEADLESS [$label] ##############################"
47
- ( cd "$REPO" && claude -p "$Q" \
48
- --output-format stream-json --verbose \
49
- --permission-mode bypassPermissions \
50
- --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" \
51
- --max-budget-usd 4 \
52
- --strict-mcp-config --mcp-config "$cfg" \
53
- > "$OUT/run-$label.jsonl" 2>"$OUT/run-$label.err" )
54
- echo "exit $? -> $OUT/run-$label.jsonl ($(wc -l < "$OUT/run-$label.jsonl" | tr -d ' ') lines)"
55
- tail -2 "$OUT/run-$label.err" 2>/dev/null
56
- node "$HARNESS/parse-run.mjs" "$OUT/run-$label.jsonl" 2>&1 || true
57
- echo
58
- }
59
-
60
- if [ "$MODE" = headless ] || [ "$MODE" = all ]; then
61
- headless "headless-with" "$OUT/mcp-homegraph.json"
62
- headless "headless-without" "$OUT/mcp-empty.json"
63
- fi
64
-
65
- if [ "$MODE" = tmux ] || [ "$MODE" = all ]; then
66
- echo "############################## INTERACTIVE [with] ##############################"
67
- CLAUDE_EXTRA_ARGS="--model ${MODEL:-sonnet} --effort ${EFFORT:-high} --strict-mcp-config --mcp-config $OUT/mcp-homegraph.json" \
68
- bash "$HARNESS/itrun.sh" "$REPO" "int-with" "$Q" 2>&1 || echo "[itrun WITH failed]"
69
- echo
70
- echo "############################## INTERACTIVE [without] ##############################"
71
- CLAUDE_EXTRA_ARGS="--model ${MODEL:-sonnet} --effort ${EFFORT:-high} --strict-mcp-config --mcp-config $OUT/mcp-empty.json" \
72
- bash "$HARNESS/itrun.sh" "$REPO" "int-without" "$Q" 2>&1 || echo "[itrun WITHOUT failed]"
73
- echo
74
- fi
75
- echo "############################## RUN-ALL COMPLETE ##############################"
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Tool-surface ablation — run ONE repo+question under ONE arm.
3
- #
4
- # Arms vary (exposed homegraph tools, trace-first steering). Tools are trimmed
5
- # SERVER-SIDE via HOMEGRAPH_MCP_TOOLS in the MCP config's `env` block, so an
6
- # ablated tool is genuinely absent from ListTools — no deferred-ToolSearch or
7
- # denied-call confound (which --disallowedTools would introduce). Steering is
8
- # injected with --append-system-prompt, so no rebuild of the shipped
9
- # server-instructions is needed to A/B it.
10
- #
11
- # A control all tools no steering
12
- # B steer all tools trace-first
13
- # C no-explore hide explore trace-first
14
- # D trace-centric hide explore+context trace-first
15
- # E control-probe hide explore+context trace-first (caller passes a NON-flow Q)
16
- #
17
- # Usage: run-arms.sh <repo-path> "<question>" <A|B|C|D|E> [run-id]
18
- set -uo pipefail
19
- REPO="${1:?repo path}"; Q="${2:?question}"; ARM="${3:?arm A-E}"; RID="${4:-1}"
20
- CG_BIN="${CG_BIN:-$(command -v homegraph)}"
21
- OUT="${ARMS_OUT:-/tmp/arms}/$(basename "$REPO")"
22
- mkdir -p "$OUT"
23
- [ -n "$CG_BIN" ] || { echo "no homegraph binary (set CG_BIN)"; exit 1; }
24
- [ -d "$REPO/.homegraph" ] || { echo "no .homegraph index at $REPO"; exit 1; }
25
-
26
- STEER='Flow questions ("how does X reach/become Y", "trace the flow", request to handler, state to render): call homegraph_trace(from,to) FIRST — one call returns the whole path. Use homegraph_context/search only to locate the two endpoint symbols if you do not know them. Do NOT reconstruct the path with repeated search/callers/explore.'
27
- KEEP_NO_EXPLORE="trace,search,node,context,callers,callees,impact,files,status"
28
- KEEP_TRACE_CENTRIC="trace,search,node,callers,callees,impact,files,status"
29
-
30
- case "$ARM" in
31
- A|G|H|I) TOOLS=""; STEERING="" ;; # no steering; H = body-trace, I = body-trace + destination callees (sufficiency)
32
- B|F) TOOLS=""; STEERING="$STEER" ;; # F = B's surface, run on the body-inlining trace build
33
- C) TOOLS="$KEEP_NO_EXPLORE"; STEERING="$STEER" ;;
34
- D|E) TOOLS="$KEEP_TRACE_CENTRIC"; STEERING="$STEER" ;;
35
- *) echo "bad arm '$ARM' (want A|B|C|D|E)"; exit 1 ;;
36
- esac
37
-
38
- CFG="$OUT/mcp-$ARM.json"
39
- if [ -n "$TOOLS" ]; then
40
- cat > "$CFG" <<JSON
41
- {"mcpServers":{"homegraph":{"command":"$CG_BIN","args":["serve","--mcp","--path","$REPO"],"env":{"HOMEGRAPH_MCP_TOOLS":"$TOOLS"}}}}
42
- JSON
43
- else
44
- cat > "$CFG" <<JSON
45
- {"mcpServers":{"homegraph":{"command":"$CG_BIN","args":["serve","--mcp","--path","$REPO"]}}}
46
- JSON
47
- fi
48
-
49
- LOG="$OUT/$ARM-r$RID.jsonl"; ERR="$OUT/$ARM-r$RID.err"
50
- ARGS=( -p "$Q" --output-format stream-json --verbose
51
- --permission-mode bypassPermissions --model "${MODEL:-sonnet}" --effort "${EFFORT:-high}" --max-budget-usd 4
52
- --strict-mcp-config --mcp-config "$CFG" )
53
- [ -n "$STEERING" ] && ARGS+=( --append-system-prompt "$STEERING" )
54
-
55
- ( cd "$REPO" && claude "${ARGS[@]}" > "$LOG" 2>"$ERR" )
56
- echo "[$(basename "$REPO") $ARM r$RID] exit $? -> $LOG ($(wc -l < "$LOG" | tr -d ' ') lines)"