homegraph 1.2.0 → 1.4.1
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.
- package/dist/bin/homegraph.js +3 -0
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +85 -0
- package/dist/context/index.js.map +1 -1
- package/dist/db/index.d.ts +64 -5
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +178 -14
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +19 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +117 -2
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +299 -6
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +32 -1
- package/dist/db/wal-valve.d.ts +106 -0
- package/dist/db/wal-valve.d.ts.map +1 -0
- package/dist/db/wal-valve.js +208 -0
- package/dist/db/wal-valve.js.map +1 -0
- package/dist/directory.d.ts +9 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +210 -19
- package/dist/directory.js.map +1 -1
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/dist/extraction/cfml-extractor.js +494 -0
- package/dist/extraction/cfml-extractor.js.map +1 -0
- package/dist/extraction/grammars.d.ts +25 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +177 -24
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +43 -4
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +308 -5
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +42 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +369 -4
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/dist/extraction/languages/cfquery.js +28 -0
- package/dist/extraction/languages/cfquery.js.map +1 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/dist/extraction/languages/cfscript.js +73 -0
- package/dist/extraction/languages/cfscript.js.map +1 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/dist/extraction/languages/cobol.js +499 -0
- package/dist/extraction/languages/cobol.js.map +1 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/dist/extraction/languages/erlang.js +350 -0
- package/dist/extraction/languages/erlang.js.map +1 -0
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +16 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts.map +1 -0
- package/dist/extraction/languages/nix.js +294 -0
- package/dist/extraction/languages/nix.js.map +1 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/dist/extraction/languages/solidity.js +293 -0
- package/dist/extraction/languages/solidity.js.map +1 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/dist/extraction/languages/terraform.js +641 -0
- package/dist/extraction/languages/terraform.js.map +1 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/dist/extraction/languages/vbnet.js +141 -0
- package/dist/extraction/languages/vbnet.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/dist/extraction/mybatis-extractor.js +140 -38
- package/dist/extraction/mybatis-extractor.js.map +1 -1
- package/dist/extraction/parse-pool.d.ts +27 -1
- package/dist/extraction/parse-pool.d.ts.map +1 -1
- package/dist/extraction/parse-pool.js +75 -7
- package/dist/extraction/parse-pool.js.map +1 -1
- package/dist/extraction/parse-worker.js +9 -2
- package/dist/extraction/parse-worker.js.map +1 -1
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/dist/extraction/tree-sitter-helpers.js +1 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/dist/extraction/tree-sitter-types.d.ts +3 -1
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +38 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +754 -10
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +1 -1
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +60 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +348 -5
- package/dist/index.js.map +1 -1
- package/dist/installer/index.d.ts +42 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +97 -2
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/daemon.d.ts +25 -3
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +62 -8
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/dist/mcp/dynamic-boundaries.js +2 -1
- package/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/early-ppid.d.ts.map +1 -0
- package/dist/mcp/early-ppid.js +29 -0
- package/dist/mcp/early-ppid.js.map +1 -0
- package/dist/mcp/engine.d.ts +4 -5
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +27 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +41 -6
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.d.ts +18 -1
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/dist/mcp/liveness-watchdog.js +73 -13
- package/dist/mcp/liveness-watchdog.js.map +1 -1
- package/dist/mcp/memory-budget.d.ts +30 -0
- package/dist/mcp/memory-budget.d.ts.map +1 -0
- package/dist/mcp/memory-budget.js +123 -0
- package/dist/mcp/memory-budget.js.map +1 -0
- package/dist/mcp/proxy.d.ts.map +1 -1
- package/dist/mcp/proxy.js +88 -4
- package/dist/mcp/proxy.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +35 -4
- package/dist/mcp/query-cache.d.ts.map +1 -1
- package/dist/mcp/query-cache.js +89 -19
- package/dist/mcp/query-cache.js.map +1 -1
- package/dist/mcp/query-pool.d.ts +46 -12
- package/dist/mcp/query-pool.d.ts.map +1 -1
- package/dist/mcp/query-pool.js +100 -23
- package/dist/mcp/query-pool.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +4 -27
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +39 -84
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/session.d.ts +14 -0
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +28 -1
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/dist/mcp/startup-handshake.js +73 -0
- package/dist/mcp/startup-handshake.js.map +1 -0
- package/dist/mcp/tools.d.ts +104 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +2390 -191
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +18 -0
- package/dist/mcp/transport.js.map +1 -1
- package/dist/project-config.d.ts +38 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +101 -2
- package/dist/project-config.js.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +178 -146
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +9 -1
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +1164 -176
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/dist/resolution/frameworks/cics.js +90 -0
- package/dist/resolution/frameworks/cics.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +3 -0
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +14 -6
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/dist/resolution/frameworks/terraform.js +277 -0
- package/dist/resolution/frameworks/terraform.js.map +1 -0
- package/dist/resolution/goframe-synthesizer.d.ts +2 -1
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
- package/dist/resolution/goframe-synthesizer.js +8 -3
- package/dist/resolution/goframe-synthesizer.js.map +1 -1
- package/dist/resolution/import-resolver.d.ts +7 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +129 -4
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +60 -7
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +430 -80
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts +0 -3
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +354 -33
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/strip-comments.d.ts +1 -1
- package/dist/resolution/strip-comments.d.ts.map +1 -1
- package/dist/resolution/strip-comments.js +49 -0
- package/dist/resolution/strip-comments.js.map +1 -1
- package/dist/resolution/types.d.ts +29 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +10 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.js +142 -4
- package/dist/resolution/workspace-packages.js.map +1 -1
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/search/identifier-segments.d.ts.map +1 -0
- package/dist/search/identifier-segments.js +176 -0
- package/dist/search/identifier-segments.js.map +1 -0
- package/dist/search/query-utils.d.ts +201 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +919 -2
- package/dist/search/query-utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/watcher.d.ts +10 -5
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +51 -14
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +5 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/types.d.ts +19 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/dist/upgrade/index.d.ts +32 -0
- package/dist/upgrade/index.d.ts.map +1 -1
- package/dist/upgrade/index.js +162 -14
- package/dist/upgrade/index.js.map +1 -1
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/dist/upgrade/remove-binary.js +289 -0
- package/dist/upgrade/remove-binary.js.map +1 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/dist/upgrade/update-check.d.ts.map +1 -0
- package/dist/upgrade/update-check.js +258 -0
- package/dist/upgrade/update-check.js.map +1 -0
- package/package.json +2 -2
- package/scripts/agent-eval/run-all.sh +6 -0
- package/scripts/build-bundle.sh +5 -0
- package/scripts/npm-shim.js +8 -1
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/data/agents.json +0 -109
- package/scripts/exp_boundary_eval/data/experiments.json +0 -140
- package/scripts/qa_eval/README.md +0 -407
- package/scripts/qa_eval/_test_deveco_probe.py +0 -41
- package/scripts/qa_eval/agent_runner.py +0 -526
- package/scripts/qa_eval/data/.gitignore +0 -4
- package/scripts/qa_eval/data/test-set.jsonl +0 -2
- package/scripts/qa_eval/eval_metrics.py +0 -274
- package/scripts/qa_eval/external_agent.py +0 -976
- package/scripts/qa_eval/llm_config.py +0 -92
- package/scripts/qa_eval/memory_monitor.py +0 -132
- package/scripts/qa_eval/my_answer_accuracy.py +0 -187
- package/scripts/qa_eval/requirements.txt +0 -2
- package/scripts/qa_eval/run_pipeline.py +0 -804
- package/scripts/qa_eval/stats_efficiency.py +0 -279
- package/scripts/qa_eval/stats_scores.py +0 -207
package/dist/mcp/query-pool.d.ts
CHANGED
|
@@ -10,17 +10,25 @@
|
|
|
10
10
|
* connection) restores true multi-core parallelism and an idle main loop.
|
|
11
11
|
*
|
|
12
12
|
* Properties:
|
|
13
|
-
* - lazy growth:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - lazy growth: **no worker until the first heavy call**, then grows to
|
|
14
|
+
* `size` on demand. Eager warm-start used to open a second full DB on every
|
|
15
|
+
* MCP session and balloon RSS (~5GB on ~800MB indexes).
|
|
16
|
+
* - **default concurrency is 1** — each worker is another V8 + WAL open; on
|
|
17
|
+
* large indexes two workers routinely doubled working-set into multi-GB.
|
|
18
|
+
* Override with `CODEGRAPH_QUERY_POOL_SIZE` when you truly need more.
|
|
19
|
+
* - **admission**: when outstanding work already fills `size` in-flight plus
|
|
20
|
+
* another `size` waiting, further calls resolve immediately with
|
|
21
|
+
* success-shaped busy/partial guidance instead of queuing up to die at the
|
|
22
|
+
* client hard timeout.
|
|
16
23
|
* - crash recovery: a dead worker is respawned and its in-flight call retried
|
|
17
24
|
* once; a poison call that keeps crashing fails gracefully (never wedges the
|
|
18
25
|
* pool). A crash budget trips a circuit breaker (`healthy` → false) so the
|
|
19
26
|
* caller falls back to in-process dispatch instead of thrashing respawns.
|
|
20
27
|
* - graceful backstop: a call that can't be served within `softTimeoutMs`
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
28
|
+
* (default 20s, clamped ≤30s — well under typical ~60s MCP client timeouts)
|
|
29
|
+
* resolves with SUCCESS-shaped static "Partial / busy, retry" guidance —
|
|
30
|
+
* never `isError`, and never DB/FTS work on the timeout callback (that
|
|
31
|
+
* can freeze the transport so the client still sees empty `-32001`).
|
|
24
32
|
*/
|
|
25
33
|
import type { ToolResult } from './tools';
|
|
26
34
|
/**
|
|
@@ -39,9 +47,9 @@ export interface PoolWorker {
|
|
|
39
47
|
export interface QueryPoolOptions {
|
|
40
48
|
/** Default project root each worker opens at spawn. */
|
|
41
49
|
root: string;
|
|
42
|
-
/** Max worker threads. Defaults to `clamp(cores-1, 1,
|
|
50
|
+
/** Max worker threads. Defaults to `clamp(cores-1, 1, DEFAULT_POOL_CAP)`. */
|
|
43
51
|
size?: number;
|
|
44
|
-
/** Linger before a queued call gets busy-guidance. Default
|
|
52
|
+
/** Linger before a queued/in-flight call gets busy-guidance. Default 20s (≤30s clamp). */
|
|
45
53
|
softTimeoutMs?: number;
|
|
46
54
|
/** Retries for an in-flight call whose worker crashed. Default 1. */
|
|
47
55
|
maxRetries?: number;
|
|
@@ -51,11 +59,19 @@ export interface QueryPoolOptions {
|
|
|
51
59
|
/**
|
|
52
60
|
* Resolve the pool size from the `CODEGRAPH_QUERY_POOL_SIZE` override and the
|
|
53
61
|
* machine's core count. `0` (or a negative) explicitly disables the pool (the
|
|
54
|
-
* caller serves in-process — today's behavior). Unset → `clamp(cores-1, 1,
|
|
55
|
-
*
|
|
56
|
-
*
|
|
62
|
+
* caller serves in-process — today's behavior). Unset → `clamp(cores-1, 1, 1)`:
|
|
63
|
+
* one parallel explore without a second full-DB RSS hit. Explicit overrides still
|
|
64
|
+
* honor up to {@link MAX_POOL_SIZE}.
|
|
57
65
|
*/
|
|
58
66
|
export declare function resolvePoolSize(envVal: string | undefined, cpuCount: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Soft / tool deadline. Env `CODEGRAPH_QUERY_BUSY_TIMEOUT_MS` may raise or
|
|
69
|
+
* lower it, but is always clamped into `[1000, MAX_BUSY_TIMEOUT_MS]` so a
|
|
70
|
+
* mistaken `60000` cannot race DevEco/Cursor's ~60s MCP hard timeout.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveBusyTimeoutMs(): number;
|
|
73
|
+
/** Same as {@link resolveBusyTimeoutMs} — used by ToolHandler for all tools. */
|
|
74
|
+
export declare function resolveToolDeadlineMs(): number;
|
|
59
75
|
export declare class QueryPool {
|
|
60
76
|
private idle;
|
|
61
77
|
private queue;
|
|
@@ -70,7 +86,14 @@ export declare class QueryPool {
|
|
|
70
86
|
private readonly softTimeoutMs;
|
|
71
87
|
private readonly maxRetries;
|
|
72
88
|
private readonly createWorker;
|
|
89
|
+
private everReady;
|
|
73
90
|
constructor(opts: QueryPoolOptions);
|
|
91
|
+
/**
|
|
92
|
+
* True once at least one worker has completed a successful cold-start handshake.
|
|
93
|
+
* False during the cold-start window (and after destroy) so ToolHandler can
|
|
94
|
+
* fall back to in-process dispatch instead of queuing behind a busy backstop.
|
|
95
|
+
*/
|
|
96
|
+
get ready(): boolean;
|
|
74
97
|
/** Pool size cap (for logging/status). */
|
|
75
98
|
get size(): number;
|
|
76
99
|
/** Live worker count (for tests/status). */
|
|
@@ -81,13 +104,24 @@ export declare class QueryPool {
|
|
|
81
104
|
* degrades to today's behavior instead of failing tool calls.
|
|
82
105
|
*/
|
|
83
106
|
get healthy(): boolean;
|
|
107
|
+
/** In-flight + unsettled queued jobs (for admission / tests). */
|
|
108
|
+
outstandingCount(): number;
|
|
109
|
+
/**
|
|
110
|
+
* How many unsettled jobs we tolerate before refusing new ones immediately.
|
|
111
|
+
* One full wave running + one full wave waiting — further fan-out gets
|
|
112
|
+
* busy/partial guidance instead of stacking up to the soft timeout.
|
|
113
|
+
*/
|
|
114
|
+
private admissionLimit;
|
|
84
115
|
private spawnOne;
|
|
85
116
|
private onMessage;
|
|
86
117
|
private onWorkerGone;
|
|
87
118
|
private drain;
|
|
88
119
|
private settle;
|
|
120
|
+
private settleBusyOrPartial;
|
|
89
121
|
/** Run a read tool on the pool. Always resolves (never rejects). */
|
|
90
|
-
run(toolName: string, args: Record<string, unknown
|
|
122
|
+
run(toolName: string, args: Record<string, unknown>, opts?: {
|
|
123
|
+
onSoftTimeout?: () => ToolResult | null | undefined;
|
|
124
|
+
}): Promise<ToolResult>;
|
|
91
125
|
/** Terminate all workers and answer any outstanding calls gracefully. */
|
|
92
126
|
destroy(): Promise<void>;
|
|
93
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-pool.d.ts","sourceRoot":"","sources":["../../src/mcp/query-pool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"query-pool.d.ts","sourceRoot":"","sources":["../../src/mcp/query-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IACrD,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IACjD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;CACrD;AA8DD,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,UAAU,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,UAAU,GAAG,IAAI,GAAG,SAAS,CAAA;KAAE,GAC7D,OAAO,CAAC,UAAU,CAAC;IA2BtB,yEAAyE;IACnE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAc/B"}
|
package/dist/mcp/query-pool.js
CHANGED
|
@@ -11,17 +11,25 @@
|
|
|
11
11
|
* connection) restores true multi-core parallelism and an idle main loop.
|
|
12
12
|
*
|
|
13
13
|
* Properties:
|
|
14
|
-
* - lazy growth:
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - lazy growth: **no worker until the first heavy call**, then grows to
|
|
15
|
+
* `size` on demand. Eager warm-start used to open a second full DB on every
|
|
16
|
+
* MCP session and balloon RSS (~5GB on ~800MB indexes).
|
|
17
|
+
* - **default concurrency is 1** — each worker is another V8 + WAL open; on
|
|
18
|
+
* large indexes two workers routinely doubled working-set into multi-GB.
|
|
19
|
+
* Override with `CODEGRAPH_QUERY_POOL_SIZE` when you truly need more.
|
|
20
|
+
* - **admission**: when outstanding work already fills `size` in-flight plus
|
|
21
|
+
* another `size` waiting, further calls resolve immediately with
|
|
22
|
+
* success-shaped busy/partial guidance instead of queuing up to die at the
|
|
23
|
+
* client hard timeout.
|
|
17
24
|
* - crash recovery: a dead worker is respawned and its in-flight call retried
|
|
18
25
|
* once; a poison call that keeps crashing fails gracefully (never wedges the
|
|
19
26
|
* pool). A crash budget trips a circuit breaker (`healthy` → false) so the
|
|
20
27
|
* caller falls back to in-process dispatch instead of thrashing respawns.
|
|
21
28
|
* - graceful backstop: a call that can't be served within `softTimeoutMs`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
29
|
+
* (default 20s, clamped ≤30s — well under typical ~60s MCP client timeouts)
|
|
30
|
+
* resolves with SUCCESS-shaped static "Partial / busy, retry" guidance —
|
|
31
|
+
* never `isError`, and never DB/FTS work on the timeout callback (that
|
|
32
|
+
* can freeze the transport so the client still sees empty `-32001`).
|
|
25
33
|
*/
|
|
26
34
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
35
|
if (k2 === undefined) k2 = k;
|
|
@@ -59,13 +67,29 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
59
67
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
68
|
exports.QueryPool = void 0;
|
|
61
69
|
exports.resolvePoolSize = resolvePoolSize;
|
|
70
|
+
exports.resolveBusyTimeoutMs = resolveBusyTimeoutMs;
|
|
71
|
+
exports.resolveToolDeadlineMs = resolveToolDeadlineMs;
|
|
62
72
|
const worker_threads_1 = require("worker_threads");
|
|
63
73
|
const path = __importStar(require("path"));
|
|
64
74
|
const os = __importStar(require("os"));
|
|
65
75
|
/** Compiled sibling — `query-worker.js` lives next to this file in `dist/mcp/`. */
|
|
66
76
|
const WORKER_FILE = path.join(__dirname, 'query-worker.js');
|
|
67
|
-
/**
|
|
68
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Default soft backstop — must stay **well below** typical MCP client hard
|
|
79
|
+
* timeouts (~60s). Eval / agent configs sometimes set the env to 60000, which
|
|
80
|
+
* races the client and yields empty `-32001`; we clamp to
|
|
81
|
+
* {@link MAX_BUSY_TIMEOUT_MS} regardless. Prefer returning busy/partial early
|
|
82
|
+
* so the agent can retry once instead of waiting out the client hard cut.
|
|
83
|
+
*/
|
|
84
|
+
const DEFAULT_BUSY_TIMEOUT_MS = 15_000;
|
|
85
|
+
/** Hard ceiling — leave headroom under ~30–60s client timeouts (flush / scheduling). */
|
|
86
|
+
const MAX_BUSY_TIMEOUT_MS = 20_000;
|
|
87
|
+
/**
|
|
88
|
+
* Default concurrent workers when env is unset. Keep at 1: a second connection
|
|
89
|
+
* on a large index is a multi-GB RSS hit. Explicit env overrides still go up to
|
|
90
|
+
* {@link MAX_POOL_SIZE}.
|
|
91
|
+
*/
|
|
92
|
+
const DEFAULT_POOL_CAP = 1;
|
|
69
93
|
/** Hard ceiling on pool size regardless of core count / env. */
|
|
70
94
|
const MAX_POOL_SIZE = 16;
|
|
71
95
|
/**
|
|
@@ -87,9 +111,9 @@ const MAX_CONCURRENT_SPAWN = 2;
|
|
|
87
111
|
/**
|
|
88
112
|
* Resolve the pool size from the `CODEGRAPH_QUERY_POOL_SIZE` override and the
|
|
89
113
|
* machine's core count. `0` (or a negative) explicitly disables the pool (the
|
|
90
|
-
* caller serves in-process — today's behavior). Unset → `clamp(cores-1, 1,
|
|
91
|
-
*
|
|
92
|
-
*
|
|
114
|
+
* caller serves in-process — today's behavior). Unset → `clamp(cores-1, 1, 1)`:
|
|
115
|
+
* one parallel explore without a second full-DB RSS hit. Explicit overrides still
|
|
116
|
+
* honor up to {@link MAX_POOL_SIZE}.
|
|
93
117
|
*/
|
|
94
118
|
function resolvePoolSize(envVal, cpuCount) {
|
|
95
119
|
if (envVal !== undefined && envVal !== '') {
|
|
@@ -98,8 +122,13 @@ function resolvePoolSize(envVal, cpuCount) {
|
|
|
98
122
|
return Math.min(Math.floor(n), MAX_POOL_SIZE);
|
|
99
123
|
// non-numeric / negative → fall through to the default
|
|
100
124
|
}
|
|
101
|
-
return Math.max(1, Math.min(cpuCount - 1,
|
|
125
|
+
return Math.max(1, Math.min(cpuCount - 1, DEFAULT_POOL_CAP));
|
|
102
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Soft / tool deadline. Env `CODEGRAPH_QUERY_BUSY_TIMEOUT_MS` may raise or
|
|
129
|
+
* lower it, but is always clamped into `[1000, MAX_BUSY_TIMEOUT_MS]` so a
|
|
130
|
+
* mistaken `60000` cannot race DevEco/Cursor's ~60s MCP hard timeout.
|
|
131
|
+
*/
|
|
103
132
|
function resolveBusyTimeoutMs() {
|
|
104
133
|
const raw = process.env.CODEGRAPH_QUERY_BUSY_TIMEOUT_MS;
|
|
105
134
|
if (raw === undefined || raw === '')
|
|
@@ -107,17 +136,25 @@ function resolveBusyTimeoutMs() {
|
|
|
107
136
|
const n = Number(raw);
|
|
108
137
|
if (!Number.isFinite(n) || n < 1000)
|
|
109
138
|
return DEFAULT_BUSY_TIMEOUT_MS;
|
|
110
|
-
return Math.floor(n);
|
|
139
|
+
return Math.min(Math.floor(n), MAX_BUSY_TIMEOUT_MS);
|
|
140
|
+
}
|
|
141
|
+
/** Same as {@link resolveBusyTimeoutMs} — used by ToolHandler for all tools. */
|
|
142
|
+
function resolveToolDeadlineMs() {
|
|
143
|
+
return resolveBusyTimeoutMs();
|
|
111
144
|
}
|
|
112
145
|
/** Success-shaped overload guidance (NEVER isError — see the abandonment rule). */
|
|
113
|
-
function busyGuidance(waitedMs) {
|
|
146
|
+
function busyGuidance(waitedMs, reason = 'timeout') {
|
|
114
147
|
const secs = Math.max(1, Math.round(waitedMs / 1000));
|
|
148
|
+
const why = reason === 'admission'
|
|
149
|
+
? 'too many concurrent HomeGraph queries are already in flight'
|
|
150
|
+
: `this call waited ${secs}s in the queue / on a worker`;
|
|
115
151
|
return {
|
|
116
152
|
content: [{
|
|
117
153
|
type: 'text',
|
|
118
|
-
text:
|
|
119
|
-
`
|
|
120
|
-
`
|
|
154
|
+
text: `⚠️ **Partial result** — HomeGraph is busy (${why}). This is NOT an error. ` +
|
|
155
|
+
`Retry ONE \`homegraph_explore\` with the concrete symbol/file names from the question — ` +
|
|
156
|
+
`do not fire search+explore or node+callers+callees in parallel, and do not fall back to grep/read ` +
|
|
157
|
+
`for symbols you already named (that duplicates tokens). A single retry usually returns full source.`,
|
|
121
158
|
}],
|
|
122
159
|
};
|
|
123
160
|
}
|
|
@@ -140,13 +177,23 @@ class QueryPool {
|
|
|
140
177
|
softTimeoutMs;
|
|
141
178
|
maxRetries;
|
|
142
179
|
createWorker;
|
|
180
|
+
everReady = false;
|
|
143
181
|
constructor(opts) {
|
|
144
182
|
this.root = opts.root;
|
|
145
|
-
this.maxSize = Math.max(1, Math.min(opts.size ?? Math.max(1, os.cpus().length - 1), MAX_POOL_SIZE));
|
|
183
|
+
this.maxSize = Math.max(1, Math.min(opts.size ?? Math.min(DEFAULT_POOL_CAP, Math.max(1, os.cpus().length - 1)), MAX_POOL_SIZE));
|
|
146
184
|
this.softTimeoutMs = opts.softTimeoutMs ?? resolveBusyTimeoutMs();
|
|
147
185
|
this.maxRetries = opts.maxRetries ?? 1;
|
|
148
186
|
this.createWorker = opts.createWorker ?? (() => new worker_threads_1.Worker(WORKER_FILE, { workerData: { root: this.root } }));
|
|
149
|
-
|
|
187
|
+
// One eager warm worker so the first tool call isn't queued behind a cold start (#662).
|
|
188
|
+
this.spawnOne();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* True once at least one worker has completed a successful cold-start handshake.
|
|
192
|
+
* False during the cold-start window (and after destroy) so ToolHandler can
|
|
193
|
+
* fall back to in-process dispatch instead of queuing behind a busy backstop.
|
|
194
|
+
*/
|
|
195
|
+
get ready() {
|
|
196
|
+
return this.everReady && !this.destroyed;
|
|
150
197
|
}
|
|
151
198
|
/** Pool size cap (for logging/status). */
|
|
152
199
|
get size() { return this.maxSize; }
|
|
@@ -160,6 +207,18 @@ class QueryPool {
|
|
|
160
207
|
get healthy() {
|
|
161
208
|
return !this.destroyed && this.totalCrashes < CRASH_BUDGET;
|
|
162
209
|
}
|
|
210
|
+
/** In-flight + unsettled queued jobs (for admission / tests). */
|
|
211
|
+
outstandingCount() {
|
|
212
|
+
return this.inflight.size + this.queue.filter((j) => !j.settled).length;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* How many unsettled jobs we tolerate before refusing new ones immediately.
|
|
216
|
+
* One full wave running + one full wave waiting — further fan-out gets
|
|
217
|
+
* busy/partial guidance instead of stacking up to the soft timeout.
|
|
218
|
+
*/
|
|
219
|
+
admissionLimit() {
|
|
220
|
+
return this.maxSize * 2;
|
|
221
|
+
}
|
|
163
222
|
spawnOne() {
|
|
164
223
|
if (this.destroyed || this.workers.size >= this.maxSize)
|
|
165
224
|
return;
|
|
@@ -185,6 +244,8 @@ class QueryPool {
|
|
|
185
244
|
this.pendingWorkers.delete(w);
|
|
186
245
|
if (m.ok === false)
|
|
187
246
|
this.totalCrashes++; // hard open failure
|
|
247
|
+
else
|
|
248
|
+
this.everReady = true;
|
|
188
249
|
this.idle.push(w);
|
|
189
250
|
this.drain();
|
|
190
251
|
return;
|
|
@@ -257,19 +318,35 @@ class QueryPool {
|
|
|
257
318
|
clearTimeout(job.softTimer);
|
|
258
319
|
job.resolve(result);
|
|
259
320
|
}
|
|
321
|
+
settleBusyOrPartial(job, reason) {
|
|
322
|
+
if (job.settled)
|
|
323
|
+
return;
|
|
324
|
+
const partial = job.onSoftTimeout?.();
|
|
325
|
+
if (partial) {
|
|
326
|
+
this.settle(job, partial);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
this.settle(job, busyGuidance(Date.now() - job.enqueuedAt, reason));
|
|
330
|
+
}
|
|
260
331
|
/** Run a read tool on the pool. Always resolves (never rejects). */
|
|
261
|
-
run(toolName, args) {
|
|
332
|
+
run(toolName, args, opts) {
|
|
262
333
|
return new Promise((resolve) => {
|
|
263
334
|
const job = {
|
|
264
335
|
id: this.nextId++, toolName, args, resolve,
|
|
265
336
|
retries: 0, settled: false, enqueuedAt: Date.now(),
|
|
337
|
+
onSoftTimeout: opts?.onSoftTimeout,
|
|
266
338
|
};
|
|
339
|
+
// Hard admission: refuse to stack another wave that would sit until soft
|
|
340
|
+
// timeout / client hard timeout. Caller gets partial/busy NOW.
|
|
341
|
+
if (this.outstandingCount() >= this.admissionLimit()) {
|
|
342
|
+
this.settleBusyOrPartial(job, 'admission');
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
267
345
|
// Don't let the caller wait past softTimeoutMs. The worker may still be
|
|
268
346
|
// busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt,
|
|
269
|
-
// success-shaped "retry" instead of a hard timeout.
|
|
347
|
+
// success-shaped "retry"/partial instead of a hard timeout.
|
|
270
348
|
job.softTimer = setTimeout(() => {
|
|
271
|
-
|
|
272
|
-
this.settle(job, busyGuidance(Date.now() - job.enqueuedAt));
|
|
349
|
+
this.settleBusyOrPartial(job, 'timeout');
|
|
273
350
|
}, this.softTimeoutMs);
|
|
274
351
|
job.softTimer.unref?.();
|
|
275
352
|
this.queue.push(job);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-pool.js","sourceRoot":"","sources":["../../src/mcp/query-pool.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"query-pool.js","sourceRoot":"","sources":["../../src/mcp/query-pool.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGH,0CAOC;AAOD,oDAMC;AAGD,sDAEC;AA/HD,mDAAwC;AACxC,2CAA6B;AAC7B,uCAAyB;AAGzB,mFAAmF;AACnF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAgB5D;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,gEAAgE;AAChE,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAmC/B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,MAA0B,EAAE,QAAgB;IAC1E,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QAC1C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAA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S,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;IACvG,CAAC;CACF;AAvND,8BAuNC"}
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server-level instructions emitted in the MCP `initialize` response.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* giving the agent a high-level playbook for the homegraph toolset
|
|
7
|
-
* before it sees individual tool descriptions.
|
|
8
|
-
*
|
|
9
|
-
* Goals when editing this:
|
|
10
|
-
* - Lead the agent to homegraph_explore for any structural/flow question
|
|
11
|
-
* - Reinforce "explore instead of Read/Grep" for indexed code
|
|
12
|
-
* - Anti-patterns (don't re-verify with grep; don't hand-reconstruct flows)
|
|
13
|
-
*
|
|
14
|
-
* HomeGraph exposes the full tool surface by default (search, node, explore,
|
|
15
|
-
* spec tools, …). Lead with homegraph_explore for structural questions; the
|
|
16
|
-
* other tools are available when a narrower step helps.
|
|
17
|
-
*/
|
|
18
|
-
export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 code intelligence over an indexed knowledge graph\n\nHomeGraph is a SQLite knowledge graph of every symbol, edge, and file in\nthe workspace \u2014 pre-computed structure you would otherwise re-derive by\nreading files (cached intelligence: thousands of parse/trace decisions you\ndon't pay to re-reason each run). Reads are sub-millisecond; the index lags\nwrites by ~1s through the file watcher. Reach for it BEFORE *and* while\nwriting or editing code \u2014 not just for questions: one call returns the\nverbatim source PLUS who calls it and what it affects, so you edit with the\nblast radius in view. More accurate context, in far fewer tokens and\nround-trips than reading files yourself.\n\n## Primary tool: homegraph_explore \u2014 use it instead of reading files\n\nFor structural and flow questions, `homegraph_explore` is Read-equivalent. It\ntakes either a natural-language question or a bag of symbol/file names and\nreturns the **verbatim, line-numbered source** of the relevant symbols\ngrouped by file \u2014 the same `<n>\\t<line>` shape `Read` gives you, safe to\n`Edit` from \u2014 PLUS the call path among them (including dynamic-dispatch hops\nlike callbacks, React re-render, and JSX children that grep can't follow) and\na blast-radius summary of what depends on them.\n\nWhether you're answering \"how does X work\" or implementing a change (fixing a\nbug, adding a feature), call `homegraph_explore` before you Read. ONE call\nusually answers the whole question. HomeGraph IS the pre-built search index \u2014\nso running your own grep + read loop, or delegating the lookup to a separate\nfile-reading sub-task/agent, repeats work homegraph already did and costs more\nfor the same answer. A direct homegraph answer is typically one to a few\ncalls; a grep/read exploration is dozens.\n\n## How to query\n\n- **Almost any question \u2014 \"how does X work\", architecture, a bug, \"what/where is X\", or surveying an area** \u2192 `homegraph_explore` with a natural-language question or the relevant names. ONE capped call returns the verbatim source grouped by file; most often the ONLY call you need.\n- **\"How does X reach/become Y? / the flow / the path from X to Y\"** \u2192 `homegraph_explore`, naming the symbols that span the flow (e.g. `mutateElement renderScene`) \u2014 it surfaces the call path among them, riding dynamic-dispatch hops, and returns their source.\n- **Reading or editing a file/symbol you can name** \u2192 put its name or file path in the `homegraph_explore` query \u2014 it returns that current line-numbered source (safe to `Edit` from) with the call path and blast radius attached, so you don't Read it separately. For an overloaded name it returns every matching definition's body in one call.\n- **Need more?** Call `homegraph_explore` again with more specific names \u2014 treat the source it returns as already Read.\n\n## Anti-patterns\n\n- **Trust homegraph's results \u2014 don't re-verify them with grep.** They come from a full AST parse; re-checking with grep is slower, less accurate, and wastes context.\n- **Don't grep or Read first** to find or understand indexed code \u2014 ONE `homegraph_explore` returns the relevant symbols' source together in a single round-trip. Reach for raw `Read`/`Grep` only to confirm a specific detail homegraph didn't cover, or for what homegraph doesn't index (configs, docs).\n- **Don't reconstruct a flow by hand** \u2014 name the endpoints in one `homegraph_explore` and it surfaces the path between them, dynamic-dispatch hops included.\n- **After editing, check the staleness banner.** When a tool response starts with \"\u26A0\uFE0F Some files referenced below were edited since the last index sync\u2026\", the listed files are pending re-index \u2014 Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust homegraph. A different, rarer banner \u2014 \"\u26A0\uFE0F HomeGraph auto-sync is DISABLED\u2026\" \u2014 means live watching stopped entirely (the whole index is frozen, not just a few files); until it's resolved, Read files directly to confirm anything that may have changed.\n\n## Limitations\n\n- If a tool reports a project isn't indexed (no `.homegraph/`), stop calling homegraph tools for that project for the rest of the session and use your built-in tools there instead. Indexing is the user's decision \u2014 mention they can run `homegraph init` if it comes up, but don't run it yourself.\n- Index lags file writes by ~1 second.\n- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.\n- No live correctness validation \u2014 that's still the TypeScript compiler / test suite / linter's job. HomeGraph supplements those with structural context they don't have.\n";
|
|
19
|
-
/**
|
|
20
|
-
* Instructions variant sent when the server's own root has NO homegraph index.
|
|
21
|
-
*
|
|
22
|
-
* The tools are still exposed (gating tool availability on whether `./` has an
|
|
23
|
-
* index is the bug behind #964: it breaks monorepos where only sub-projects are
|
|
24
|
-
* indexed, and a server that started before `homegraph init` never surfaces the
|
|
25
|
-
* tools afterward). Instead of an "inactive" note, this variant tells the agent
|
|
26
|
-
* homegraph works **per project**: there's no default project to query, so pass
|
|
27
|
-
* a `projectPath` to any project that HAS a `.homegraph/`. The full single-
|
|
28
|
-
* project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
|
|
29
|
-
* IS indexed, so the common case stays tight.
|
|
4
|
+
* Single source of truth for agent-facing tool guidance (issue #529).
|
|
5
|
+
* Edit here — not installer prompts or eval harness prompts.
|
|
30
6
|
*/
|
|
31
|
-
export declare const
|
|
7
|
+
export declare const SERVER_INSTRUCTIONS = "# HomeGraph \u2014 when to call\n\nHomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.\n\n## Call HomeGraph (closed set)\n\nUse `homegraph_explore` (primary) when **all** of these hold:\n\n1. The evidence lives **in this repository's source** (not an external SDK manual).\n2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/`@kit` module.\n3. You can put **concrete names** in `query` \u2014 symbol, `Type.member`, file basename, or `@kit\u2026` (skip `homegraph_search` when names are already known).\n\nTypical fits:\n\n- How a **feature in this repo** is wired (mechanism / cross-file / click\u2192handler flow)\n- Callers / callees / blast radius of a **named** symbol\n- What a **named component/method** does (include the name; one explore is enough)\n- In-repo usages of an imported API (not the official feature catalog)\n\n**One explore with names** beats search\u2192explore\u2192node\u2192grep\u2192read. Treat returned line-numbered source as already Read. After a full explore \u2014 **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial \u2192 retry that **same** explore once.\n\n## Do not call HomeGraph otherwise\n\nIf the question is **outside the set above**, do **not** open any `homegraph_*` tool \u2014 use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.\n\n## Tool roles\n\n| Tool | Role |\n|------|------|\n| **homegraph_explore** | Primary for the closed set above |\n| homegraph_node | One known symbol body (or indexed file) after explore named it |\n| homegraph_callers / callees | Compact edge lists for a named symbol |\n| homegraph_search | Rare \u2014 unknown spelling only |\n| homegraph_files | Folder tree only |\n\n## Tips\n\n- **Deadline / partial** \u2014 success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.\n- **Staleness banner** \u2014 Read only the listed edited files.\n- **Not indexed** \u2014 built-in tools; user runs `homegraph init` \u2014 you do not.\n";
|
|
8
|
+
export declare const SERVER_INSTRUCTIONS_NO_ROOT_INDEX = "# HomeGraph \u2014 per-project (pass projectPath)\n\nHomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has `.homegraph/`. Pass that project as `projectPath`.\n\n- Fits the closed set (structure, callers, wiring, named symbol/file) \u2192 `homegraph_explore`\n- Anything else \u2192 Read/Grep/Glob \u2014 **do not call homegraph_***\n- No index \u2192 Read/Grep/Glob; user runs `homegraph init` if they want indexing\n";
|
|
32
9
|
//# sourceMappingURL=server-instructions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB,wtEAwC/B,CAAC;AAEF,eAAO,MAAM,iCAAiC,yfAO7C,CAAC"}
|
|
@@ -1,104 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = exports.SERVER_INSTRUCTIONS = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* Server-level instructions emitted in the MCP `initialize` response.
|
|
6
4
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* giving the agent a high-level playbook for the homegraph toolset
|
|
10
|
-
* before it sees individual tool descriptions.
|
|
11
|
-
*
|
|
12
|
-
* Goals when editing this:
|
|
13
|
-
* - Lead the agent to homegraph_explore for any structural/flow question
|
|
14
|
-
* - Reinforce "explore instead of Read/Grep" for indexed code
|
|
15
|
-
* - Anti-patterns (don't re-verify with grep; don't hand-reconstruct flows)
|
|
16
|
-
*
|
|
17
|
-
* HomeGraph exposes the full tool surface by default (search, node, explore,
|
|
18
|
-
* spec tools, …). Lead with homegraph_explore for structural questions; the
|
|
19
|
-
* other tools are available when a narrower step helps.
|
|
5
|
+
* Single source of truth for agent-facing tool guidance (issue #529).
|
|
6
|
+
* Edit here — not installer prompts or eval harness prompts.
|
|
20
7
|
*/
|
|
21
|
-
exports
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = exports.SERVER_INSTRUCTIONS = void 0;
|
|
10
|
+
exports.SERVER_INSTRUCTIONS = `# HomeGraph — when to call
|
|
22
11
|
|
|
23
|
-
HomeGraph is a
|
|
24
|
-
the workspace — pre-computed structure you would otherwise re-derive by
|
|
25
|
-
reading files (cached intelligence: thousands of parse/trace decisions you
|
|
26
|
-
don't pay to re-reason each run). Reads are sub-millisecond; the index lags
|
|
27
|
-
writes by ~1s through the file watcher. Reach for it BEFORE *and* while
|
|
28
|
-
writing or editing code — not just for questions: one call returns the
|
|
29
|
-
verbatim source PLUS who calls it and what it affects, so you edit with the
|
|
30
|
-
blast radius in view. More accurate context, in far fewer tokens and
|
|
31
|
-
round-trips than reading files yourself.
|
|
12
|
+
HomeGraph is a **local structural index of THIS repo**: symbols + call/import/extends edges + files. Use it only when the answer needs that graph.
|
|
32
13
|
|
|
33
|
-
##
|
|
14
|
+
## Call HomeGraph (closed set)
|
|
34
15
|
|
|
35
|
-
|
|
36
|
-
takes either a natural-language question or a bag of symbol/file names and
|
|
37
|
-
returns the **verbatim, line-numbered source** of the relevant symbols
|
|
38
|
-
grouped by file — the same \`<n>\\t<line>\` shape \`Read\` gives you, safe to
|
|
39
|
-
\`Edit\` from — PLUS the call path among them (including dynamic-dispatch hops
|
|
40
|
-
like callbacks, React re-render, and JSX children that grep can't follow) and
|
|
41
|
-
a blast-radius summary of what depends on them.
|
|
16
|
+
Use \`homegraph_explore\` (primary) when **all** of these hold:
|
|
42
17
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
so running your own grep + read loop, or delegating the lookup to a separate
|
|
47
|
-
file-reading sub-task/agent, repeats work homegraph already did and costs more
|
|
48
|
-
for the same answer. A direct homegraph answer is typically one to a few
|
|
49
|
-
calls; a grep/read exploration is dozens.
|
|
18
|
+
1. The evidence lives **in this repository's source** (not an external SDK manual).
|
|
19
|
+
2. You need **structure**: definition location, who calls whom, how A reaches B, multi-file wiring, or in-repo import/usage of a named API/\`@kit\` module.
|
|
20
|
+
3. You can put **concrete names** in \`query\` — symbol, \`Type.member\`, file basename, or \`@kit…\` (skip \`homegraph_search\` when names are already known).
|
|
50
21
|
|
|
51
|
-
|
|
22
|
+
Typical fits:
|
|
52
23
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
24
|
+
- How a **feature in this repo** is wired (mechanism / cross-file / click→handler flow)
|
|
25
|
+
- Callers / callees / blast radius of a **named** symbol
|
|
26
|
+
- What a **named component/method** does (include the name; one explore is enough)
|
|
27
|
+
- In-repo usages of an imported API (not the official feature catalog)
|
|
57
28
|
|
|
58
|
-
|
|
29
|
+
**One explore with names** beats search→explore→node→grep→read. Treat returned line-numbered source as already Read. After a full explore — **answer**; do not re-verify with grep/read/node for the same symbols. Busy/partial → retry that **same** explore once.
|
|
59
30
|
|
|
60
|
-
|
|
61
|
-
- **Don't grep or Read first** to find or understand indexed code — ONE \`homegraph_explore\` returns the relevant symbols' source together in a single round-trip. Reach for raw \`Read\`/\`Grep\` only to confirm a specific detail homegraph didn't cover, or for what homegraph doesn't index (configs, docs).
|
|
62
|
-
- **Don't reconstruct a flow by hand** — name the endpoints in one \`homegraph_explore\` and it surfaces the path between them, dynamic-dispatch hops included.
|
|
63
|
-
- **After editing, check the staleness banner.** When a tool response starts with "⚠️ Some files referenced below were edited since the last index sync…", the listed files are pending re-index — Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust homegraph. A different, rarer banner — "⚠️ HomeGraph auto-sync is DISABLED…" — means live watching stopped entirely (the whole index is frozen, not just a few files); until it's resolved, Read files directly to confirm anything that may have changed.
|
|
31
|
+
## Do not call HomeGraph otherwise
|
|
64
32
|
|
|
65
|
-
|
|
33
|
+
If the question is **outside the set above**, do **not** open any \`homegraph_*\` tool — use Read / Grep / Glob / SDK docs. HomeGraph is not a general Q&A layer; forcing it on the wrong shape costs time and tokens and often lowers quality.
|
|
66
34
|
|
|
67
|
-
|
|
68
|
-
- Index lags file writes by ~1 second.
|
|
69
|
-
- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
|
|
70
|
-
- No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. HomeGraph supplements those with structural context they don't have.
|
|
71
|
-
`;
|
|
72
|
-
/**
|
|
73
|
-
* Instructions variant sent when the server's own root has NO homegraph index.
|
|
74
|
-
*
|
|
75
|
-
* The tools are still exposed (gating tool availability on whether `./` has an
|
|
76
|
-
* index is the bug behind #964: it breaks monorepos where only sub-projects are
|
|
77
|
-
* indexed, and a server that started before `homegraph init` never surfaces the
|
|
78
|
-
* tools afterward). Instead of an "inactive" note, this variant tells the agent
|
|
79
|
-
* homegraph works **per project**: there's no default project to query, so pass
|
|
80
|
-
* a `projectPath` to any project that HAS a `.homegraph/`. The full single-
|
|
81
|
-
* project playbook ({@link SERVER_INSTRUCTIONS}) is sent instead when the root
|
|
82
|
-
* IS indexed, so the common case stays tight.
|
|
83
|
-
*/
|
|
84
|
-
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# HomeGraph — available (per-project; pass projectPath)
|
|
35
|
+
## Tool roles
|
|
85
36
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
37
|
+
| Tool | Role |
|
|
38
|
+
|------|------|
|
|
39
|
+
| **homegraph_explore** | Primary for the closed set above |
|
|
40
|
+
| homegraph_node | One known symbol body (or indexed file) after explore named it |
|
|
41
|
+
| homegraph_callers / callees | Compact edge lists for a named symbol |
|
|
42
|
+
| homegraph_search | Rare — unknown spelling only |
|
|
43
|
+
| homegraph_files | Folder tree only |
|
|
44
|
+
|
|
45
|
+
## Tips
|
|
46
|
+
|
|
47
|
+
- **Deadline / partial** — success-shaped; retry ONE explore with the same names. Do not abandon to grep for those symbols.
|
|
48
|
+
- **Staleness banner** — Read only the listed edited files.
|
|
49
|
+
- **Not indexed** — built-in tools; user runs \`homegraph init\` — you do not.
|
|
50
|
+
`;
|
|
51
|
+
exports.SERVER_INSTRUCTIONS_NO_ROOT_INDEX = `# HomeGraph — per-project (pass projectPath)
|
|
90
52
|
|
|
91
|
-
|
|
92
|
-
default project — but the tools are available and work **per project**:
|
|
53
|
+
HomeGraph indexes a codebase into a symbol graph. Call it **only** for in-repo structural / flow / usage questions on a project that has \`.homegraph/\`. Pass that project as \`projectPath\`.
|
|
93
54
|
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
nearest \`.homegraph/\` at or above that path and answers from it — for as many
|
|
98
|
-
projects as you like in one session.
|
|
99
|
-
- For a project with no \`.homegraph/\`, use your built-in tools (Read/Grep/Glob)
|
|
100
|
-
for that project. Indexing is the user's decision — don't run it yourself, but
|
|
101
|
-
if it comes up they can run \`homegraph init\` in a project to enable homegraph
|
|
102
|
-
there (a new index is picked up live, no restart).
|
|
55
|
+
- Fits the closed set (structure, callers, wiring, named symbol/file) → \`homegraph_explore\`
|
|
56
|
+
- Anything else → Read/Grep/Glob — **do not call homegraph_***
|
|
57
|
+
- No index → Read/Grep/Glob; user runs \`homegraph init\` if they want indexing
|
|
103
58
|
`;
|
|
104
59
|
//# sourceMappingURL=server-instructions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../../src/mcp/server-instructions.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwClC,CAAC;AAEW,QAAA,iCAAiC,GAAG;;;;;;;CAOhD,CAAC"}
|