@codeconductorai/harmony-mcp 1.0.24 → 1.0.26
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/README.md +29 -28
- package/package.json +1 -1
- package/src/harmonyClient.js +39 -76
- package/src/server.js +15 -37
- package/src/serverInstructions.js +45 -31
- package/src/telemetry.js +7 -2
- package/src/toolSchemas.js +87 -70
package/README.md
CHANGED
|
@@ -27,12 +27,12 @@ Re-run `node -v` afterwards to confirm before continuing.
|
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
|
-
The server is published as `@codeconductorai/harmony-mcp` and run via `npx`, so no local build step is required. The commands below pin an exact version (`@1.0.
|
|
30
|
+
The server is published as `@codeconductorai/harmony-mcp` and run via `npx`, so no local build step is required. The commands below pin an exact version (`@1.0.26`) rather than a floating tag — this lets `npx` reuse its local cache instead of re-resolving the package from the registry on every agent startup, which otherwise makes MCP initialization noticeably slower (and occasionally hang). Bump the pinned version deliberately when you want to upgrade.
|
|
31
31
|
|
|
32
32
|
### Claude Code
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.
|
|
35
|
+
claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.26
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Antigravity
|
|
@@ -47,7 +47,7 @@ Open **MCP Servers → Manage MCP Servers → View raw config** from the agent p
|
|
|
47
47
|
"mcpServers": {
|
|
48
48
|
"harmony": {
|
|
49
49
|
"command": "npx",
|
|
50
|
-
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.
|
|
50
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.26"]
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -58,7 +58,7 @@ Restart Antigravity (or reload MCP servers) after saving.
|
|
|
58
58
|
### Codex CLI
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.
|
|
61
|
+
codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.26
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
This writes the entry to `~/.codex/config.toml`. To add it by hand instead:
|
|
@@ -66,7 +66,7 @@ This writes the entry to `~/.codex/config.toml`. To add it by hand instead:
|
|
|
66
66
|
```toml
|
|
67
67
|
[mcp_servers.harmony]
|
|
68
68
|
command = "npx"
|
|
69
|
-
args = ["-y", "@codeconductorai/harmony-mcp@1.0.
|
|
69
|
+
args = ["-y", "@codeconductorai/harmony-mcp@1.0.26"]
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
### Aria
|
|
@@ -78,7 +78,7 @@ In the Aria Code panel, click the settings icon → **MCP Servers**, then scroll
|
|
|
78
78
|
"mcpServers": {
|
|
79
79
|
"harmony": {
|
|
80
80
|
"command": "npx",
|
|
81
|
-
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.
|
|
81
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.26"]
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -95,7 +95,7 @@ Any client that reads a `command`/`args` style config (e.g. Claude Desktop's `cl
|
|
|
95
95
|
"mcpServers": {
|
|
96
96
|
"harmony": {
|
|
97
97
|
"command": "npx",
|
|
98
|
-
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.
|
|
98
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.26"]
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -108,7 +108,7 @@ After adding the server and restarting your client:
|
|
|
108
108
|
1. **`setup_workspace`** — registers the current project (`language` and `buildTool` required the first time) and fully indexes it (zips and uploads the codebase) in one call. Call this first, even before logging in: some backend deployments authenticate the workspace internally with no login involved at all, so this can succeed on its own. It's idempotent, so calling it again once setup and indexing have completed is a cheap no-op; if it fails partway, calling it again retries just the incomplete step. Once indexing succeeds, a background file watcher pushes incremental updates to the backend as you edit files.
|
|
109
109
|
2. If `setup_workspace` (or any tool below) fails with a "not authenticated" error, this deployment requires login: call **`login`**, which starts a device-flow login and returns a URL to open in your browser.
|
|
110
110
|
3. Finish logging in, then tell the agent you're done so it can call **`confirm_login`** to complete authentication. The session is cached at `~/.harmony-mcp/session.json`, so you won't need to log in again until it expires. Call `setup_workspace` again afterward.
|
|
111
|
-
4. Use **`context_search`** first to pull relevant code context for a prompt — it's Harmony's newest, best-ranked search endpoint, always available as the default entry point for every discovery need in a task, and takes precedence over
|
|
111
|
+
4. Use **`context_search`** first to pull relevant code context for a prompt — it's Harmony's newest, best-ranked search endpoint, always available as the default entry point for every discovery need in a task, and takes precedence over **`locate`** below. Fall back to `locate` only if `context_search` comes up short or you need its line-number-only anchors — and when you do, feed it a combination of the user's original query and the symbols/identifiers/file paths `context_search` already surfaced, not the raw query on its own. For a question that's inherently about a call relationship or a whole subsystem (not "find me the code for X"), reach directly for **`explain_symbol`**, **`path_between`**, or **`explain_subsystem`** instead of routing through `context_search` first.
|
|
112
112
|
|
|
113
113
|
Workspace state (workspace ID, language, build tool, setup/upload status) is cached in a `.harmony_workspace.json` marker file in the project root.
|
|
114
114
|
|
|
@@ -134,20 +134,17 @@ Registers the current project as a workspace on the backend and fully indexes it
|
|
|
134
134
|
|
|
135
135
|
Every workspace is tagged with a scheme-aware `repoId`, surfaced in the response as `repoId`/`repoIdScheme`: `git_url:<host/org/repo>` (normalized origin remote URL — the common case), falling back to `git_commit:<root sha>` (Git repo with no remote), `artifact:<ecosystem>:<name>` (no `.git` at all — read from `pom.xml`/`package.json`/`go.mod`/`Cargo.toml`/`pyproject.toml`), or `dir:<folder name>` as a last resort.
|
|
136
136
|
|
|
137
|
-
### `get_context_bundle`
|
|
138
|
-
Retrieves a ranked XML context bundle of the most relevant code for a prompt — broader contextual understanding for a task or question, not a specific edit location.
|
|
139
|
-
- `prompt` (required): natural-language question or instruction.
|
|
140
|
-
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
141
|
-
|
|
142
137
|
### `context_search`
|
|
143
138
|
PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked
|
|
144
139
|
search endpoint. Given a natural-language query or exact identifier, returns ranked matching symbols
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
`context_search`'s result is empty/insufficient or you specifically need
|
|
148
|
-
|
|
140
|
+
as structural facts and precise file:line locations, deliberately without embedded source code.
|
|
141
|
+
Takes precedence over `locate`; only fall back to it if
|
|
142
|
+
`context_search`'s result is empty/insufficient or you specifically need its line-number-only
|
|
143
|
+
anchors for a targeted edit. For a call-relationship or whole-subsystem question, reach directly for
|
|
144
|
+
`explain_symbol`/`path_between`/`explain_subsystem` instead — don't route through `context_search`
|
|
145
|
+
first. Treat it as the
|
|
149
146
|
always-on default entry point for every new discovery/comprehension need that comes up during a
|
|
150
|
-
task — call it again each time, not just once. When
|
|
147
|
+
task — call it again each time, not just once. When falling back to `locate` afterward, its input
|
|
151
148
|
should combine the user's original query with the symbols/identifiers/file paths this call already
|
|
152
149
|
surfaced, rather than repeating the same raw query unchanged.
|
|
153
150
|
- `prompt` (required): natural-language query or exact identifier to find context for.
|
|
@@ -162,18 +159,22 @@ Given a natural-language query or exact identifier, returns lightweight symbol c
|
|
|
162
159
|
- `limit` (optional): max results (default 40); the result list is never padded to this size.
|
|
163
160
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
164
161
|
|
|
165
|
-
### `
|
|
166
|
-
Given
|
|
167
|
-
- `prompt` (required):
|
|
168
|
-
- `file_path` (optional): path substring
|
|
169
|
-
- `limit` (optional): max results (default 15).
|
|
162
|
+
### `explain_symbol`
|
|
163
|
+
Given an exact symbol name (method, function, or class), returns what it's connected to in the persisted call graph: which symbols call it, which symbols it calls, and any call targets that couldn't be confidently resolved to a single definition. Use this to understand a symbol's role and blast radius before changing it, or to answer "who calls X" / "what does X call" directly, without falling back to reading every file that might reference it — this is the highest-leverage tool in this set for that shape of question.
|
|
164
|
+
- `prompt` (required): the exact symbol name to explain.
|
|
165
|
+
- `file_path` (optional): path substring narrowing which definition to use when the name alone is ambiguous (e.g. a common interface-method name implemented by hundreds of classes).
|
|
170
166
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
171
167
|
|
|
172
|
-
### `
|
|
173
|
-
Given
|
|
174
|
-
- `
|
|
175
|
-
- `
|
|
176
|
-
- `
|
|
168
|
+
### `path_between`
|
|
169
|
+
Given two exact symbol names, finds the shortest resolved call-graph path from the first to the second (e.g. how a controller method eventually reaches a repository call several hops down). Returns `found: false` if no path exists within the search bounds — that doesn't necessarily mean no relationship exists; it can also mean a bare name was too ambiguous to resolve.
|
|
170
|
+
- `from` / `to` (required): the starting and target symbols' exact names.
|
|
171
|
+
- `from_file_path` / `to_file_path` (optional): path substrings narrowing which definition to use when a name alone is ambiguous.
|
|
172
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
173
|
+
|
|
174
|
+
### `explain_subsystem`
|
|
175
|
+
Given a loose subsystem/module name (e.g. `"billing"`, `"auth"`), returns every file Harmony has clustered into that subsystem via its persisted import-graph communities — a direct listing, not a ranked search. Use this for "how does the billing system work" style questions where you want the whole subsystem's files at once, rather than piecing it together from several `context_search` calls.
|
|
176
|
+
- `prompt` (required): loose subsystem/module name to match against detected community labels.
|
|
177
|
+
- `limit` (optional): max files to return (default 60).
|
|
177
178
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
178
179
|
|
|
179
180
|
## Observability (OpenObserve)
|
package/package.json
CHANGED
package/src/harmonyClient.js
CHANGED
|
@@ -5,7 +5,7 @@ import archiver from "archiver";
|
|
|
5
5
|
import FormData from "form-data";
|
|
6
6
|
|
|
7
7
|
import { log } from "./log.js";
|
|
8
|
-
import { tracedFetch as fetch } from "./telemetry.js";
|
|
8
|
+
import { tracedFetch as fetch, getActiveTraceId } from "./telemetry.js";
|
|
9
9
|
import {
|
|
10
10
|
getSessionToken,
|
|
11
11
|
getWorkspaceToken,
|
|
@@ -27,7 +27,7 @@ async function refreshWorkspaceToken(workspaceId, refreshToken) {
|
|
|
27
27
|
});
|
|
28
28
|
const body = await response.text();
|
|
29
29
|
if (!response.ok) {
|
|
30
|
-
throw new Error(`Workspace token refresh failed: ${response.status} ${body}`);
|
|
30
|
+
throw new Error(`Workspace token refresh failed: ${response.status} ${body}${traceSuffix()}`);
|
|
31
31
|
}
|
|
32
32
|
const newAccessToken = response.headers.get("x-workspace-token");
|
|
33
33
|
if (!newAccessToken) {
|
|
@@ -60,6 +60,11 @@ async function authHeader(workspaceId) {
|
|
|
60
60
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
function traceSuffix() {
|
|
64
|
+
const traceId = getActiveTraceId();
|
|
65
|
+
return traceId ? ` [traceId=${traceId}]` : "";
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
// Zip the working directory, excluding whatever the backend's WorkspaceFileFilter would discard anyway.
|
|
64
69
|
async function zipWorkspace() {
|
|
65
70
|
const workspacePath = process.cwd();
|
|
@@ -82,25 +87,6 @@ async function zipWorkspace() {
|
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
function actionableErrorHint(status, headers) {
|
|
86
|
-
if (status === 401) {
|
|
87
|
-
const wwwAuthenticate = headers.get("www-authenticate");
|
|
88
|
-
return wwwAuthenticate
|
|
89
|
-
? ` (${wwwAuthenticate})`
|
|
90
|
-
: " (this deployment requires login — call the login tool first, then confirm_login once the user has finished)";
|
|
91
|
-
}
|
|
92
|
-
if (status === 400) {
|
|
93
|
-
return " (the request was rejected as malformed — double-check `prompt` is non-blank and `file_path`/`limit` are the right types, then retry once; don't retry blindly)";
|
|
94
|
-
}
|
|
95
|
-
if (status === 404) {
|
|
96
|
-
return " (workspace not found on the backend — call setup_workspace again; the local marker may be stale)";
|
|
97
|
-
}
|
|
98
|
-
if (status >= 500) {
|
|
99
|
-
return " (backend error, not something a different query will fix — fall back to local tools for this lookup rather than retrying)";
|
|
100
|
-
}
|
|
101
|
-
return "";
|
|
102
|
-
}
|
|
103
|
-
|
|
104
90
|
// POST /api/code-workspace/{workspaceId}/create — register a new workspace on the backend.
|
|
105
91
|
export async function setupWorkspace(workspaceId, language, buildTool) {
|
|
106
92
|
try {
|
|
@@ -116,7 +102,13 @@ export async function setupWorkspace(workspaceId, language, buildTool) {
|
|
|
116
102
|
log("Setup status:", response.status);
|
|
117
103
|
log("Setup response:", body);
|
|
118
104
|
if (!response.ok) {
|
|
119
|
-
|
|
105
|
+
const wwwAuthenticate = response.headers.get("www-authenticate");
|
|
106
|
+
const hint = response.status === 401
|
|
107
|
+
? wwwAuthenticate
|
|
108
|
+
? ` (${wwwAuthenticate})`
|
|
109
|
+
: " (this deployment requires login — call the login tool first)"
|
|
110
|
+
: "";
|
|
111
|
+
throw new Error(`Setup failed: ${response.status} ${body}${hint}${traceSuffix()}`);
|
|
120
112
|
}
|
|
121
113
|
return {
|
|
122
114
|
status: response.status,
|
|
@@ -132,7 +124,7 @@ export async function setupWorkspace(workspaceId, language, buildTool) {
|
|
|
132
124
|
}
|
|
133
125
|
|
|
134
126
|
// POST /api/v1/index/zip — upload a zipped snapshot of the workspace for full indexing.
|
|
135
|
-
export async function uploadWorkspace(zipPath, workspaceId, language, buildTool, phase = "
|
|
127
|
+
export async function uploadWorkspace(zipPath, workspaceId, language, buildTool, phase = "LEXICAL") {
|
|
136
128
|
try {
|
|
137
129
|
const form = new FormData();
|
|
138
130
|
|
|
@@ -162,7 +154,7 @@ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool,
|
|
|
162
154
|
log("Upload status:", response.status);
|
|
163
155
|
log("Upload response:", body);
|
|
164
156
|
if (!response.ok) {
|
|
165
|
-
throw new Error(`Upload failed: ${response.status} ${body}`);
|
|
157
|
+
throw new Error(`Upload failed: ${response.status} ${body}${traceSuffix()}`);
|
|
166
158
|
}
|
|
167
159
|
|
|
168
160
|
return {
|
|
@@ -220,8 +212,8 @@ export async function ensureWorkspaceUploaded(language, buildTool) {
|
|
|
220
212
|
}
|
|
221
213
|
|
|
222
214
|
if (!marker.upload?.done || staleSnapshot) {
|
|
223
|
-
//
|
|
224
|
-
const phase =
|
|
215
|
+
// Indexing is lexical-only — no embedding/semantic pass on the backend.
|
|
216
|
+
const phase = "LEXICAL";
|
|
225
217
|
const zipFile = await zipWorkspace();
|
|
226
218
|
const result = await uploadWorkspace(zipFile, workspaceId, lang, tool, phase);
|
|
227
219
|
marker.upload = { done: true, phase, status: result.status, response: result.response };
|
|
@@ -232,21 +224,6 @@ export async function ensureWorkspaceUploaded(language, buildTool) {
|
|
|
232
224
|
return { resynced: staleSnapshot };
|
|
233
225
|
}
|
|
234
226
|
|
|
235
|
-
// Second pass, sent once LEXICAL reaches a terminal status. Callers fire this without awaiting it
|
|
236
|
-
// so the initial request can complete as soon as LEXICAL is done — the phase flag flips
|
|
237
|
-
// synchronously (before any await below) so a concurrent call can't re-trigger it in the meantime.
|
|
238
|
-
export async function advanceToHeuristicGraphPhase(marker) {
|
|
239
|
-
marker.upload = { ...marker.upload, phase: "HEURISTICGRAPH" };
|
|
240
|
-
writeMarker(marker);
|
|
241
|
-
|
|
242
|
-
const { workspaceId, language, buildTool } = marker;
|
|
243
|
-
const zipFile = await zipWorkspace();
|
|
244
|
-
const result = await uploadWorkspace(zipFile, workspaceId, language, buildTool, "HEURISTICGRAPH");
|
|
245
|
-
marker.upload = { done: true, phase: "HEURISTICGRAPH", status: result.status, response: result.response };
|
|
246
|
-
writeMarker(marker);
|
|
247
|
-
return marker;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
227
|
// Statuses that won't change on their own without a new upload — safe to stop polling at.
|
|
251
228
|
const TERMINAL_STATUSES = new Set([
|
|
252
229
|
"TEXT_AND_SYMBOLS_COMPLETE",
|
|
@@ -266,7 +243,7 @@ async function fetchWorkspaceStatus(workspaceId) {
|
|
|
266
243
|
if (response.status === 404) return null;
|
|
267
244
|
const body = await response.text();
|
|
268
245
|
if (!response.ok) {
|
|
269
|
-
throw new Error(`Workspace status request failed: ${response.status} ${body}`);
|
|
246
|
+
throw new Error(`Workspace status request failed: ${response.status} ${body}${traceSuffix()}`);
|
|
270
247
|
}
|
|
271
248
|
const match = body.match(/<status>([^<]+)<\/status>/i);
|
|
272
249
|
return match ? match[1].trim() : null;
|
|
@@ -307,19 +284,7 @@ export async function pollWorkspaceStatus(workspaceId, { maxWaitMs = 120_000, in
|
|
|
307
284
|
return lastStatus;
|
|
308
285
|
}
|
|
309
286
|
|
|
310
|
-
|
|
311
|
-
function truncateForAgent(toolName, body) {
|
|
312
|
-
if (body.length <= MAX_RESPONSE_CHARS) return body;
|
|
313
|
-
const truncated = body.slice(0, MAX_RESPONSE_CHARS);
|
|
314
|
-
return `${truncated}\n\n` +
|
|
315
|
-
`[harmony-mcp note: ${toolName}'s response was truncated at ~${Math.round(MAX_RESPONSE_CHARS / 4)} ` +
|
|
316
|
-
`tokens to protect context. Don't assume the cut-off entry is complete or that nothing else ` +
|
|
317
|
-
`matched — narrow the search instead of re-reading this same response: pass a more specific ` +
|
|
318
|
-
`\`file_path\` scope, lower \`limit\`, or sharpen \`prompt\` to a more specific identifier, then ` +
|
|
319
|
-
`call again.]`;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Shared POST caller for the locate-symbol/search/find-files endpoints — same request/response shape.
|
|
287
|
+
// Shared POST caller for the context-search/locate-symbol/explain-symbol/explain-subsystem endpoints — same request/response shape.
|
|
323
288
|
export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId) {
|
|
324
289
|
const prompt = args.prompt || args.query;
|
|
325
290
|
if (!prompt) throw new Error("prompt is required.");
|
|
@@ -344,22 +309,29 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
|
|
|
344
309
|
});
|
|
345
310
|
const body = await response.text();
|
|
346
311
|
if (!response.ok) {
|
|
347
|
-
throw new Error(`${endpointPath} request failed: ${response.status} ${body}${
|
|
312
|
+
throw new Error(`${endpointPath} request failed: ${response.status} ${body}${traceSuffix()}`);
|
|
348
313
|
}
|
|
349
|
-
return
|
|
314
|
+
return body;
|
|
350
315
|
}
|
|
351
316
|
|
|
352
|
-
// POST /api/code-workspace/{workspaceId}/
|
|
353
|
-
|
|
317
|
+
// POST /api/code-workspace/{workspaceId}/path-between — shortest resolved call-graph path
|
|
318
|
+
// between two symbols. Distinct request shape from callHarmonySearchEndpoint (from/to, not prompt).
|
|
319
|
+
export async function callHarmonyPathBetween(args, workspaceId) {
|
|
320
|
+
const from = args.from;
|
|
321
|
+
const to = args.to;
|
|
322
|
+
if (!from || !to) throw new Error("Both 'from' and 'to' are required.");
|
|
323
|
+
|
|
354
324
|
const requestBody = {
|
|
355
|
-
|
|
356
|
-
|
|
325
|
+
from,
|
|
326
|
+
to,
|
|
327
|
+
from_file_path: args.from_file_path,
|
|
328
|
+
to_file_path: args.to_file_path,
|
|
357
329
|
workspaceMetadata: buildWorkspaceMetadata(workspaceId),
|
|
358
330
|
};
|
|
359
331
|
|
|
360
|
-
log(
|
|
332
|
+
log(`[path-between] Request body:`, JSON.stringify(requestBody, null, 2));
|
|
361
333
|
|
|
362
|
-
const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/
|
|
334
|
+
const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/path-between`, {
|
|
363
335
|
method: "POST",
|
|
364
336
|
headers: {
|
|
365
337
|
"Content-Type": "application/json",
|
|
@@ -370,9 +342,9 @@ export async function fetchContextBundle(workspaceId, prompt) {
|
|
|
370
342
|
});
|
|
371
343
|
const body = await response.text();
|
|
372
344
|
if (!response.ok) {
|
|
373
|
-
throw new Error(`
|
|
345
|
+
throw new Error(`path-between request failed: ${response.status} ${body}${traceSuffix()}`);
|
|
374
346
|
}
|
|
375
|
-
return
|
|
347
|
+
return body;
|
|
376
348
|
}
|
|
377
349
|
|
|
378
350
|
// An empty list is ambiguous (no matches vs. index not ready vs. failed query) — flag it.
|
|
@@ -387,15 +359,6 @@ export function annotateIfEmptyList(toolName, body) {
|
|
|
387
359
|
`verify with local search (rg/grep) rather than concluding nothing exists.]`;
|
|
388
360
|
}
|
|
389
361
|
|
|
390
|
-
// FALLBACK_NATIVE_RECALL means the backend fell back to broad recall — flag it as approximate.
|
|
391
|
-
export function annotateIfFallbackBundle(body) {
|
|
392
|
-
if (!body.includes("FALLBACK_NATIVE_RECALL")) return body;
|
|
393
|
-
return `${body}\n\n` +
|
|
394
|
-
`[harmony-mcp note: this bundle used FALLBACK_NATIVE_RECALL — the backend did not resolve a ` +
|
|
395
|
-
`high-signal call graph for this prompt, so the content above is broad/generic recall rather ` +
|
|
396
|
-
`than a precisely targeted answer. Consider locate/search_code_context for a sharper result.]`;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
362
|
// POST /api/v1/index/files — used by the file watcher for incremental updates.
|
|
400
363
|
export async function sendFileUpdate(filePath, workspaceId, language, buildTool) {
|
|
401
364
|
try {
|
|
@@ -412,7 +375,7 @@ export async function sendFileUpdate(filePath, workspaceId, language, buildTool)
|
|
|
412
375
|
if (buildTool) {
|
|
413
376
|
form.append("buildTool", buildTool);
|
|
414
377
|
}
|
|
415
|
-
form.append("phase", "
|
|
378
|
+
form.append("phase", "LEXICAL");
|
|
416
379
|
|
|
417
380
|
// Field names must match @RequestPart("files") and @RequestParam("paths")
|
|
418
381
|
form.append("files", fs.createReadStream(filePath), { filename: path.basename(filePath) });
|
|
@@ -426,7 +389,7 @@ export async function sendFileUpdate(filePath, workspaceId, language, buildTool)
|
|
|
426
389
|
const body = await response.text();
|
|
427
390
|
log(`[fileWatcher] ${path.relative(process.cwd(), filePath)} -> ${response.status}`);
|
|
428
391
|
if (!response.ok) {
|
|
429
|
-
log(`[fileWatcher] Index failed: ${body}`);
|
|
392
|
+
log(`[fileWatcher] Index failed: ${body}${traceSuffix()}`);
|
|
430
393
|
}
|
|
431
394
|
} catch (error) {
|
|
432
395
|
log(`[fileWatcher] Error sending file update:`, error.message);
|
package/src/server.js
CHANGED
|
@@ -22,14 +22,10 @@ import { readMarker, writeMarker } from "./workspaceMarker.js";
|
|
|
22
22
|
import { startFileWatcher, isFileWatcherActive } from "./fileWatcher.js";
|
|
23
23
|
import {
|
|
24
24
|
ensureWorkspaceUploaded,
|
|
25
|
-
advanceToHeuristicGraphPhase,
|
|
26
|
-
isTerminalIndexStatus,
|
|
27
|
-
isFailedIndexStatus,
|
|
28
25
|
pollWorkspaceStatus,
|
|
29
26
|
callHarmonySearchEndpoint,
|
|
30
|
-
|
|
27
|
+
callHarmonyPathBetween,
|
|
31
28
|
annotateIfEmptyList,
|
|
32
|
-
annotateIfFallbackBundle,
|
|
33
29
|
} from "./harmonyClient.js";
|
|
34
30
|
import { buildServerInstructions } from "./serverInstructions.js";
|
|
35
31
|
import { TOOLS } from "./toolSchemas.js";
|
|
@@ -159,14 +155,16 @@ function describeIndexOutcome(indexStatus, workspaceId) {
|
|
|
159
155
|
return {
|
|
160
156
|
ready: true,
|
|
161
157
|
message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
|
|
162
|
-
`It's ready for context_search, locate,
|
|
158
|
+
`It's ready for context_search, locate, explain_symbol, path_between, and explain_subsystem.`,
|
|
163
159
|
};
|
|
164
160
|
}
|
|
165
161
|
if (DEGRADED_STATUSES.has(indexStatus)) {
|
|
166
162
|
return {
|
|
167
163
|
ready: false,
|
|
168
164
|
message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
|
|
169
|
-
`
|
|
165
|
+
`Symbol-level tools (locate, explain_symbol, path_between, explain_subsystem) and possibly ` +
|
|
166
|
+
`context_search may return incomplete or no results until symbol indexing finishes — verify ` +
|
|
167
|
+
`with local search (rg/grep) if a result looks suspiciously empty.`,
|
|
170
168
|
};
|
|
171
169
|
}
|
|
172
170
|
if (indexStatus === "CORRUPTED") {
|
|
@@ -179,25 +177,10 @@ function describeIndexOutcome(indexStatus, workspaceId) {
|
|
|
179
177
|
ready: false,
|
|
180
178
|
message: `Workspace ${workspaceId} upload succeeded, but the backend is still indexing ` +
|
|
181
179
|
`(status: ${indexStatus || "unknown"}). This can take longer for large repos — call ` +
|
|
182
|
-
`setup_workspace again shortly to check whether it's finished before relying on locate/
|
|
180
|
+
`setup_workspace again shortly to check whether it's finished before relying on locate/context_search results.`,
|
|
183
181
|
};
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
// Once LEXICAL reaches a terminal status, kick off HEURISTICGRAPH in the background — the current
|
|
187
|
-
// call returns on the LEXICAL result rather than waiting on it. Gated on marker.upload.phase, so
|
|
188
|
-
// this fires only once per workspace.
|
|
189
|
-
async function maybeAdvanceToHeuristicPhase(marker, indexStatus, { extra }) {
|
|
190
|
-
if (!marker || marker.upload?.phase !== "LEXICAL") return indexStatus;
|
|
191
|
-
if (!isTerminalIndexStatus(indexStatus) || isFailedIndexStatus(indexStatus)) return indexStatus;
|
|
192
|
-
|
|
193
|
-
// TEMP: HEURISTICGRAPH follow-up disabled — uncomment to restore the parallel background pass.
|
|
194
|
-
// await sendProgress(extra, `Lexical indexing complete for "${getProjectName()}" — heuristic graph indexing started in the background.`);
|
|
195
|
-
// advanceToHeuristicGraphPhase(marker).catch((error) =>
|
|
196
|
-
// log(`[setup_workspace] Heuristic graph phase failed: ${error.message}`)
|
|
197
|
-
// );
|
|
198
|
-
return indexStatus;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
184
|
async function handleSetupWorkspace(args, extra) {
|
|
202
185
|
const { language, buildTool } = args;
|
|
203
186
|
const startedAt = Date.now();
|
|
@@ -220,7 +203,6 @@ async function handleSetupWorkspace(args, extra) {
|
|
|
220
203
|
maxWaitMs: Math.min(15_000, remainingBudgetMs()),
|
|
221
204
|
onTick: onPollTick,
|
|
222
205
|
});
|
|
223
|
-
indexStatus = await maybeAdvanceToHeuristicPhase(existingMarker, indexStatus, { extra });
|
|
224
206
|
persistIndexStatus(existingMarker, indexStatus);
|
|
225
207
|
const outcome = describeIndexOutcome(indexStatus, existingMarker.workspaceId);
|
|
226
208
|
return jsonContent({
|
|
@@ -261,7 +243,6 @@ async function handleSetupWorkspace(args, extra) {
|
|
|
261
243
|
maxWaitMs: remainingBudgetMs(),
|
|
262
244
|
onTick: onPollTick,
|
|
263
245
|
});
|
|
264
|
-
indexStatus = await maybeAdvanceToHeuristicPhase(marker, indexStatus, { extra });
|
|
265
246
|
persistIndexStatus(marker, indexStatus);
|
|
266
247
|
const outcome = describeIndexOutcome(indexStatus, marker?.workspaceId);
|
|
267
248
|
|
|
@@ -285,15 +266,6 @@ async function handleSetupWorkspace(args, extra) {
|
|
|
285
266
|
});
|
|
286
267
|
}
|
|
287
268
|
|
|
288
|
-
async function handleGetContextBundle(args) {
|
|
289
|
-
const workspaceId = resolveWorkspaceId(args);
|
|
290
|
-
const prompt = args.prompt || args.query;
|
|
291
|
-
if (!prompt) throw new Error("prompt is required.");
|
|
292
|
-
|
|
293
|
-
const body = await fetchContextBundle(workspaceId, prompt);
|
|
294
|
-
return textContent(annotateIfFallbackBundle(body));
|
|
295
|
-
}
|
|
296
|
-
|
|
297
269
|
function makeSearchHandler(endpointPath, toolName) {
|
|
298
270
|
return async (args) => {
|
|
299
271
|
const workspaceId = resolveWorkspaceId(args);
|
|
@@ -302,15 +274,21 @@ function makeSearchHandler(endpointPath, toolName) {
|
|
|
302
274
|
};
|
|
303
275
|
}
|
|
304
276
|
|
|
277
|
+
async function handlePathBetween(args) {
|
|
278
|
+
const workspaceId = resolveWorkspaceId(args);
|
|
279
|
+
const body = await callHarmonyPathBetween(args, workspaceId);
|
|
280
|
+
return textContent(body);
|
|
281
|
+
}
|
|
282
|
+
|
|
305
283
|
const TOOL_HANDLERS = {
|
|
306
284
|
login: handleLogin,
|
|
307
285
|
confirm_login: handleConfirmLogin,
|
|
308
286
|
setup_workspace: handleSetupWorkspace,
|
|
309
|
-
get_context_bundle: handleGetContextBundle,
|
|
310
287
|
context_search: makeSearchHandler("context-search", "context_search"),
|
|
311
288
|
locate: makeSearchHandler("locate-symbol", "locate"),
|
|
312
|
-
|
|
313
|
-
|
|
289
|
+
explain_symbol: makeSearchHandler("explain-symbol", "explain_symbol"),
|
|
290
|
+
path_between: handlePathBetween,
|
|
291
|
+
explain_subsystem: makeSearchHandler("explain-subsystem", "explain_subsystem"),
|
|
314
292
|
};
|
|
315
293
|
|
|
316
294
|
const AUTH_EXEMPT_TOOLS = new Set(["login", "confirm_login", "setup_workspace"]);
|
|
@@ -33,7 +33,7 @@ tools are just as fast, or when the task doesn't touch this codebase at all.
|
|
|
33
33
|
|
|
34
34
|
const QUERY_REFINEMENT = `
|
|
35
35
|
Query refinement — once you've decided a Harmony call is the right move, before calling
|
|
36
|
-
context_search
|
|
36
|
+
context_search or locate, judge whether the user's own wording is
|
|
37
37
|
already a specific enough \`prompt\`. Skip this whole section for requests that already name a
|
|
38
38
|
concrete symbol/class/method/route/file ("find CrudController", "where is POST /api/v1/index/zip
|
|
39
39
|
handled") — pass those straight through unchanged. Only vague or generic requests ("show all
|
|
@@ -78,20 +78,29 @@ Choosing among Harmony's tools — once Harmony is the right move for a lookup,
|
|
|
78
78
|
- \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns every
|
|
79
79
|
matching symbol occurrence (definitions and references) with exact line numbers, optionally scoped
|
|
80
80
|
to a file_path once you already know the file.
|
|
81
|
-
- \`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
- \`explain_symbol\` — "who calls X" / "what does X call" / understanding a symbol's blast radius
|
|
82
|
+
before changing it. Reads the persisted call graph directly instead of ranking a search over every
|
|
83
|
+
file that might reference the symbol — pick this over context_search/locate for call-relationship
|
|
84
|
+
questions, it's the highest-leverage tool in this set for exactly that shape of question. Requires
|
|
85
|
+
an exact symbol name (not a natural-language description); use context_search first if you only
|
|
86
|
+
have a vague description and need to find the exact name.
|
|
87
|
+
- \`path_between\` — "how does A eventually reach B" / tracing a multi-hop call chain (e.g. a
|
|
88
|
+
controller method down to a repository call several layers deep). Also reads the persisted call
|
|
89
|
+
graph directly; needs two exact symbol names.
|
|
90
|
+
- \`explain_subsystem\` — "how does the billing/auth/whatever system work" when you want a whole
|
|
91
|
+
module's files at once rather than piecing it together from several context_search calls. Takes a
|
|
92
|
+
loose subsystem name, not an exact identifier.
|
|
93
|
+
|
|
94
|
+
If context_search's result is empty or insufficient, or you specifically need locate's line-number-
|
|
95
|
+
only anchors, fall back to that narrower tool rather than retrying context_search. Composing that
|
|
96
|
+
fallback: never just resend the same raw user query — carry forward the specific symbols,
|
|
97
|
+
identifiers, and file paths context_search's response already surfaced, and combine THOSE with the
|
|
98
|
+
user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
|
|
99
|
+
applicable). The fallback call should read as "user's intent, sharpened by what context_search
|
|
100
|
+
already found," not a blind retry of the same input. explain_symbol/path_between/explain_subsystem
|
|
101
|
+
are different from this fallback chain — reach for them directly, as the first call, whenever the
|
|
102
|
+
question is inherently about a call relationship or a whole subsystem rather than "find me the code
|
|
103
|
+
for X"; don't route through context_search first just to warm up.
|
|
95
104
|
|
|
96
105
|
Carry forward a good result: once a Harmony response gives you a concrete file_path, symbol name, or
|
|
97
106
|
other specific detail relevant to the task, treat it as ground truth for every tool call that
|
|
@@ -100,13 +109,16 @@ This applies equally when you next call another Harmony tool scoped to that file
|
|
|
100
109
|
move on to Read, an edit, or any other tool — use the exact path/identifier already returned rather
|
|
101
110
|
than deriving your own guess at that point.
|
|
102
111
|
|
|
103
|
-
Populate \`file_path\` whenever it's known: context_search
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
Populate \`file_path\` whenever it's known: context_search and locate accept an optional \`file_path\`
|
|
113
|
+
field to scope results to a subdirectory, module, or specific file; explain_symbol takes the same
|
|
114
|
+
idea as \`file_path\` and path_between as \`from_file_path\`/\`to_file_path\`, used specifically to
|
|
115
|
+
disambiguate which definition you mean when a symbol name alone is ambiguous (e.g. a common
|
|
116
|
+
interface-method name implemented by hundreds of classes). Whenever a file path is already known at
|
|
117
|
+
call time — surfaced by an earlier context_search/locate result this task, stated explicitly by the
|
|
118
|
+
user, or established earlier in the conversation — pass it into that call's \`file_path\`
|
|
119
|
+
(or \`from_file_path\`/\`to_file_path\`), don't leave it blank and rely on the \`prompt\` text alone to
|
|
120
|
+
imply scope. Only omit it when no such path is actually known yet; never fill it with a guessed path
|
|
121
|
+
(see refinement step 3 above).
|
|
110
122
|
`.trim();
|
|
111
123
|
|
|
112
124
|
const TRUST_BUT_VERIFY = `
|
|
@@ -120,9 +132,10 @@ re-derive context you just fetched, and don't Read() a whole file the tool alrea
|
|
|
120
132
|
const EFFICIENCY_RULES = `
|
|
121
133
|
Efficiency — once a query is already well-formed (after refinement above), apply these to keep tool
|
|
122
134
|
calls fast and non-redundant:
|
|
123
|
-
- Don't repeat calls — before calling context_search/locate/
|
|
124
|
-
whether this exact (prompt, file_path, workspaceId)
|
|
125
|
-
task; if so, reuse that earlier result instead of
|
|
135
|
+
- Don't repeat calls — before calling context_search/locate/explain_symbol/path_between/
|
|
136
|
+
explain_subsystem, check whether this exact (prompt or from/to, file_path, workspaceId)
|
|
137
|
+
combination was already issued earlier in this task; if so, reuse that earlier result instead of
|
|
138
|
+
calling again.
|
|
126
139
|
- Fan out independent lookups in parallel — when a task needs context on two or more genuinely
|
|
127
140
|
unrelated things (e.g. "how does auth work and how does logging work"), or when refinement above
|
|
128
141
|
produced multiple plausible variant queries for one ambiguous category, issue those calls together
|
|
@@ -134,8 +147,8 @@ calls fast and non-redundant:
|
|
|
134
147
|
queries, where a small limit risks cutting off the right result.
|
|
135
148
|
- Skip redundant ranking on retries — if a symbol's existence and rough location were already
|
|
136
149
|
confirmed by an earlier context_search/locate result this task, a later lookup for that same
|
|
137
|
-
symbol can go straight to the specialized tool (locate for line numbers,
|
|
138
|
-
|
|
150
|
+
symbol can go straight to the specialized tool (locate for line numbers, explain_symbol for its
|
|
151
|
+
callers/callees) instead of re-running context_search's general-purpose ranking pass again.
|
|
139
152
|
`.trim();
|
|
140
153
|
|
|
141
154
|
const SETUP_INSTRUCTIONS = `
|
|
@@ -153,16 +166,17 @@ Workspace setup — before the first search/locate/context call in a project:
|
|
|
153
166
|
HTTP request succeeded. The response's \`ready\` field is only true once the backend confirms both
|
|
154
167
|
text and symbols are indexed.
|
|
155
168
|
- If \`ready\` is false, read \`indexStatus\` and the \`response\` text and relay them to the user in
|
|
156
|
-
plain language before relying on locate/
|
|
169
|
+
plain language before relying on locate/context_search/explain_symbol/path_between/
|
|
170
|
+
explain_subsystem results. If it says indexing is still
|
|
157
171
|
running (the common case for large repos — the time budget ran out before the backend finished),
|
|
158
172
|
this is expected and not a failure: tell the user briefly, then call \`setup_workspace\` again
|
|
159
173
|
after a short wait to re-check — repeat until \`ready\` is true. If it instead reports only
|
|
160
|
-
partially finished (symbols failed/skipped —
|
|
161
|
-
|
|
174
|
+
partially finished (symbols failed/skipped — the symbol-level tools may return incomplete or no
|
|
175
|
+
results) or failed outright, relay that instead of retrying blindly.
|
|
162
176
|
`.trim();
|
|
163
177
|
|
|
164
178
|
const AUTH_INSTRUCTIONS = `
|
|
165
|
-
Auth gate —
|
|
179
|
+
Auth gate — context_search, locate, explain_symbol, path_between, and explain_subsystem all
|
|
166
180
|
return a "not authenticated" error until login has succeeded; run the login flow below before
|
|
167
181
|
using them. setup_workspace is the one exception: call it directly even before logging in — it
|
|
168
182
|
uses the login session when one exists, but some deployments authenticate the workspace
|
package/src/telemetry.js
CHANGED
|
@@ -119,13 +119,17 @@ export async function tracedFetch(url, options = {}) {
|
|
|
119
119
|
return url;
|
|
120
120
|
}
|
|
121
121
|
})();
|
|
122
|
-
|
|
122
|
+
const method = options.method || "GET";
|
|
123
|
+
const traceId = getActiveTraceId();
|
|
124
|
+
span.setAttribute("http.request.method", method);
|
|
123
125
|
span.setAttribute("url.full", url);
|
|
124
|
-
log(`[telemetry] trace id ${
|
|
126
|
+
log(`[telemetry] trace id ${traceId} for ${method} ${path}`);
|
|
125
127
|
const startedAt = Date.now();
|
|
126
128
|
try {
|
|
127
129
|
const response = await fetch(url, { ...options, headers: injectTraceHeaders(options.headers || {}) });
|
|
128
130
|
span.setAttribute("http.response.status_code", response.status);
|
|
131
|
+
log(`[telemetry] trace id ${traceId} for ${method} ${path} -> ${response.status}` +
|
|
132
|
+
(response.ok ? "" : " (backend X-Trace-Id: " + (response.headers.get("x-trace-id") || "none") + ")"));
|
|
129
133
|
if (!response.ok) {
|
|
130
134
|
span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${response.status}` });
|
|
131
135
|
backendRequestErrors.add(1, { "url.path": path, "http.response.status_code": response.status });
|
|
@@ -135,6 +139,7 @@ export async function tracedFetch(url, options = {}) {
|
|
|
135
139
|
span.recordException(error);
|
|
136
140
|
span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });
|
|
137
141
|
backendRequestErrors.add(1, { "url.path": path });
|
|
142
|
+
log(`[telemetry] trace id ${traceId} for ${method} ${path} -> request error: ${error?.message}`);
|
|
138
143
|
throw error;
|
|
139
144
|
} finally {
|
|
140
145
|
backendRequestDuration.record(Date.now() - startedAt, { "url.path": path });
|
package/src/toolSchemas.js
CHANGED
|
@@ -8,8 +8,6 @@ const WORKSPACE_ID_PROPERTY = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const TOOLS = [
|
|
11
|
-
// TEMP: get_context_bundle, search_code_context, and find_files are disabled below — uncomment
|
|
12
|
-
// those blocks to restore the full tool set.
|
|
13
11
|
{
|
|
14
12
|
name: "login",
|
|
15
13
|
description:
|
|
@@ -47,7 +45,8 @@ export const TOOLS = [
|
|
|
47
45
|
"Set up AND fully index the current workspace on the backend in a single call (creates the workspace " +
|
|
48
46
|
"if needed, then zips and uploads the codebase). Safe to call repeatedly — already-completed steps are " +
|
|
49
47
|
"skipped, so calling it again after it has already succeeded is a cheap no-op. Required once per " +
|
|
50
|
-
"project before locate or
|
|
48
|
+
"project before context_search, locate, explain_symbol, path_between, or explain_subsystem will work. " +
|
|
49
|
+
"If it fails partway (e.g. the upload step " +
|
|
51
50
|
"times out) after the workspace was already created, just call it again — language/buildTool can be " +
|
|
52
51
|
"omitted on that retry, since they're remembered from the first call.",
|
|
53
52
|
inputSchema: {
|
|
@@ -72,26 +71,33 @@ export const TOOLS = [
|
|
|
72
71
|
{
|
|
73
72
|
name: "context_search",
|
|
74
73
|
description:
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
74
|
+
"PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
|
|
75
|
+
"search endpoint. Given a natural language query or exact identifier, returns ranked matching symbols " +
|
|
76
|
+
"as structural facts and precise file:line locations — file path, symbol kind/decorators/name, and an " +
|
|
77
|
+
"exact line range per symbol — deliberately WITHOUT embedded source code, the same way graphify's " +
|
|
78
|
+
"query/explain primitives work. Try this BEFORE locate; only fall back to locate if context_search's " +
|
|
79
|
+
"result is empty, insufficient, or you specifically need its line-number-only anchors for a targeted " +
|
|
80
|
+
"edit. For a question that's inherently about a call relationship or a whole subsystem rather than " +
|
|
81
|
+
"'find me the code for X', reach directly for explain_symbol/path_between/explain_subsystem instead — " +
|
|
82
|
+
"don't route through context_search first just to warm up. Treat context_search as the always-on default " +
|
|
83
|
+
"entry point for every new discovery/comprehension need that comes up during a task — call it again " +
|
|
84
|
+
"each time one arises, not just once. Whenever you do fall back to locate, don't " +
|
|
85
|
+
"discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
|
|
86
|
+
"and combine them with the user's original query to build that tool's input, rather than re-issuing " +
|
|
87
|
+
"the raw query alone.\n\n" +
|
|
88
|
+
"RESPONSE SHAPE: the XML response has two separate top-level parts. <Hits><Hit>...</Hit></Hits> is the " +
|
|
89
|
+
"location index — each Hit's <codeSnippet> is a compact table of contents for that file (one line per " +
|
|
90
|
+
"symbol: decorators, kind, name, and its exact lines{start:end} range), and <lineNumbers> pins the " +
|
|
91
|
+
"specific symbol this Hit matched to its own exact range. NEITHER field contains real source lines. " +
|
|
92
|
+
"Once you've decided which hit(s) actually matter, use your own file-read tool on the given file path " +
|
|
93
|
+
"and line range to see the real code — do not answer the user's question from <codeSnippet> alone, " +
|
|
94
|
+
"and never present a lines{a:b} header line as if it were the method body. The sibling " +
|
|
95
|
+
"<harmony_telemetry> block (filesBundledCount, graphEdgesResolved, processingTimeMs, " +
|
|
96
|
+
"estimatedSecondsSaved, estimatedLoopsBypassed, estimatedTokensSaved) is just an operational efficiency " +
|
|
97
|
+
"snapshot of the search itself — not a search result and not code context. Never merge, count, or cite " +
|
|
98
|
+
"<harmony_telemetry> fields as if they were part of <Hits>. If you mention telemetry at all, present it " +
|
|
99
|
+
"separately and clearly labeled (e.g. as a short aside/footnote about how the search performed), and " +
|
|
100
|
+
"only when it's actually relevant to what the user asked — don't surface it by default on every call.",
|
|
95
101
|
inputSchema: {
|
|
96
102
|
type: "object",
|
|
97
103
|
properties: {
|
|
@@ -114,27 +120,6 @@ export const TOOLS = [
|
|
|
114
120
|
required: ["prompt"],
|
|
115
121
|
},
|
|
116
122
|
},
|
|
117
|
-
/*
|
|
118
|
-
{
|
|
119
|
-
name: "get_context_bundle",
|
|
120
|
-
description:
|
|
121
|
-
"Retrieve a coding context bundle for a prompt from the backend. Returns XML context. If reached " +
|
|
122
|
-
"as a fallback after context_search came up short, build this prompt from the user's original " +
|
|
123
|
-
"query plus the symbols/identifiers/file paths context_search's response already surfaced, rather " +
|
|
124
|
-
"than resending the raw query unchanged.",
|
|
125
|
-
inputSchema: {
|
|
126
|
-
type: "object",
|
|
127
|
-
properties: {
|
|
128
|
-
prompt: {
|
|
129
|
-
type: "string",
|
|
130
|
-
description: "The natural language instruction or question to retrieve context for.",
|
|
131
|
-
},
|
|
132
|
-
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
133
|
-
},
|
|
134
|
-
required: ["prompt"],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
*/
|
|
138
123
|
{
|
|
139
124
|
name: "locate",
|
|
140
125
|
description:
|
|
@@ -179,29 +164,31 @@ export const TOOLS = [
|
|
|
179
164
|
required: ["prompt"],
|
|
180
165
|
},
|
|
181
166
|
},
|
|
182
|
-
/*
|
|
183
167
|
{
|
|
184
|
-
name: "
|
|
168
|
+
name: "explain_symbol",
|
|
185
169
|
description:
|
|
186
|
-
"Given
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
170
|
+
"Given an exact symbol name (method, function, or class), returns what it's connected to in the " +
|
|
171
|
+
"persisted call graph: which symbols call it, which symbols it calls, and any call targets that " +
|
|
172
|
+
"couldn't be confidently resolved to a single definition. Use this to understand a symbol's role " +
|
|
173
|
+
"and blast radius before changing it, or to answer 'who calls X' / 'what does X call' directly, " +
|
|
174
|
+
"without falling back to reading every file that might reference it.\n\n" +
|
|
175
|
+
"DISAMBIGUATION: common names (e.g. an interface method like 'processCommand' implemented by " +
|
|
176
|
+
"hundreds of classes) can match many definitions — the response is a list, one item per match. " +
|
|
177
|
+
"If you already know roughly where the symbol lives, pass file_path to narrow it to the exact one " +
|
|
178
|
+
"you mean instead of scanning every item in the list.",
|
|
191
179
|
inputSchema: {
|
|
192
180
|
type: "object",
|
|
193
181
|
properties: {
|
|
194
182
|
prompt: {
|
|
195
183
|
type: "string",
|
|
196
|
-
description: "
|
|
184
|
+
description: "REQUIRED. The exact symbol name to explain (e.g. a method or class name).",
|
|
197
185
|
},
|
|
198
186
|
file_path: {
|
|
199
187
|
type: "string",
|
|
200
|
-
description:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
description: "Maximum number of results to return (default 15).",
|
|
188
|
+
description:
|
|
189
|
+
"Optional path substring narrowing which definition to use when the name alone is ambiguous " +
|
|
190
|
+
"(e.g. \"DisburseWorkingCapitalLoanCommandHandler\" to pick that class's processCommand out of " +
|
|
191
|
+
"hundreds of others with the same name).",
|
|
205
192
|
},
|
|
206
193
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
207
194
|
},
|
|
@@ -209,32 +196,62 @@ export const TOOLS = [
|
|
|
209
196
|
},
|
|
210
197
|
},
|
|
211
198
|
{
|
|
212
|
-
name: "
|
|
199
|
+
name: "path_between",
|
|
213
200
|
description:
|
|
214
|
-
"Given
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
"
|
|
201
|
+
"Given two exact symbol names, finds the shortest resolved call-graph path from the first to the " +
|
|
202
|
+
"second (e.g. how a controller method eventually reaches a repository call several hops down). " +
|
|
203
|
+
"Returns found: false if no path exists within the search bounds — that does not necessarily mean " +
|
|
204
|
+
"no relationship exists: it can also mean the bare name was too ambiguous to resolve to the specific " +
|
|
205
|
+
"definition you meant (common names like interface method implementations can have hundreds of " +
|
|
206
|
+
"matches — try again with from_file_path/to_file_path once you know roughly where each symbol " +
|
|
207
|
+
"lives), or that the call site was ambiguous and intentionally left unresolved at index time (see " +
|
|
208
|
+
"explain_symbol's unresolved_call_targets).",
|
|
219
209
|
inputSchema: {
|
|
220
210
|
type: "object",
|
|
221
211
|
properties: {
|
|
222
|
-
|
|
212
|
+
from: {
|
|
223
213
|
type: "string",
|
|
224
|
-
description: "
|
|
214
|
+
description: "REQUIRED. The starting symbol's exact name.",
|
|
225
215
|
},
|
|
226
|
-
|
|
216
|
+
to: {
|
|
227
217
|
type: "string",
|
|
228
|
-
description: "
|
|
218
|
+
description: "REQUIRED. The target symbol's exact name to find a path to.",
|
|
219
|
+
},
|
|
220
|
+
from_file_path: {
|
|
221
|
+
type: "string",
|
|
222
|
+
description: "Optional path substring narrowing which \"from\" definition to use when the name alone is ambiguous.",
|
|
223
|
+
},
|
|
224
|
+
to_file_path: {
|
|
225
|
+
type: "string",
|
|
226
|
+
description: "Optional path substring narrowing which \"to\" definition to use when the name alone is ambiguous.",
|
|
227
|
+
},
|
|
228
|
+
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
229
|
+
},
|
|
230
|
+
required: ["from", "to"],
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "explain_subsystem",
|
|
235
|
+
description:
|
|
236
|
+
"Given a loose subsystem/module name (e.g. 'billing', 'auth'), returns every file harmony has " +
|
|
237
|
+
"clustered into that subsystem via its persisted import-graph communities — a direct listing, " +
|
|
238
|
+
"not a ranked search. Use this for 'how does the billing system work' style questions where you " +
|
|
239
|
+
"want the whole subsystem's files at once, rather than piecing it together from several " +
|
|
240
|
+
"context_search calls.",
|
|
241
|
+
inputSchema: {
|
|
242
|
+
type: "object",
|
|
243
|
+
properties: {
|
|
244
|
+
prompt: {
|
|
245
|
+
type: "string",
|
|
246
|
+
description: "REQUIRED. Loose subsystem/module name to match against detected community labels.",
|
|
229
247
|
},
|
|
230
248
|
limit: {
|
|
231
249
|
type: "number",
|
|
232
|
-
description: "
|
|
250
|
+
description: "Optional maximum number of files to return (default 60).",
|
|
233
251
|
},
|
|
234
252
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
235
253
|
},
|
|
236
254
|
required: ["prompt"],
|
|
237
255
|
},
|
|
238
|
-
}
|
|
239
|
-
*/
|
|
256
|
+
},
|
|
240
257
|
];
|