@codeconductorai/harmony-mcp 1.0.24 → 1.0.25

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 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.24`) 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.
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.25`) 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.24
35
+ claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.25
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.24"]
50
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.25"]
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.24
61
+ codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.25
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.24"]
69
+ args = ["-y", "@codeconductorai/harmony-mcp@1.0.25"]
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.24"]
81
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.25"]
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.24"]
98
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.25"]
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 the others below. Fall back to **`locate`**, **`search_code_context`**, **`find_files`**, or **`get_context_bundle`** only if it comes up short or you need one of their specialized output shapes — and when you do, feed the fallback tool 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.
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
- with their code snippets, file paths, and relevance. Takes precedence over `locate`,
146
- `search_code_context`, `find_files`, and `get_context_bundle`; only fall back to one of those if
147
- `context_search`'s result is empty/insufficient or you specifically need one of their specialized
148
- output shapes (e.g. `locate`'s line-number-only anchors for a targeted edit). Treat it as the
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 a fallback tool is used afterward, its input
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
- ### `search_code_context`
166
- Given a natural-language query, returns matching symbols along with their code snippets, documentation, and decorators. Use this to understand or explain how something works, not to pinpoint an edit (use `locate` for that).
167
- - `prompt` (required): what to find context for.
168
- - `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
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
- ### `find_files`
173
- Given a natural-language query, returns lightweight file path and architectural role/tag matches — no symbols or code content. Use this for broad file/module discovery (e.g. `"find all the controllers"`).
174
- - `prompt` (required): what kind of file to find.
175
- - `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
176
- - `limit` (optional): max results (default 30).
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeconductorai/harmony-mcp",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -82,25 +82,6 @@ async function zipWorkspace() {
82
82
  });
83
83
  }
84
84
 
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
85
  // POST /api/code-workspace/{workspaceId}/create — register a new workspace on the backend.
105
86
  export async function setupWorkspace(workspaceId, language, buildTool) {
106
87
  try {
@@ -116,7 +97,13 @@ export async function setupWorkspace(workspaceId, language, buildTool) {
116
97
  log("Setup status:", response.status);
117
98
  log("Setup response:", body);
118
99
  if (!response.ok) {
119
- throw new Error(`Setup failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
100
+ const wwwAuthenticate = response.headers.get("www-authenticate");
101
+ const hint = response.status === 401
102
+ ? wwwAuthenticate
103
+ ? ` (${wwwAuthenticate})`
104
+ : " (this deployment requires login — call the login tool first)"
105
+ : "";
106
+ throw new Error(`Setup failed: ${response.status} ${body}${hint}`);
120
107
  }
121
108
  return {
122
109
  status: response.status,
@@ -307,18 +294,6 @@ export async function pollWorkspaceStatus(workspaceId, { maxWaitMs = 120_000, in
307
294
  return lastStatus;
308
295
  }
309
296
 
310
- const MAX_RESPONSE_CHARS = 90_000;
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
297
  // Shared POST caller for the locate-symbol/search/find-files endpoints — same request/response shape.
323
298
  export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId) {
324
299
  const prompt = args.prompt || args.query;
@@ -344,9 +319,42 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
344
319
  });
345
320
  const body = await response.text();
346
321
  if (!response.ok) {
347
- throw new Error(`${endpointPath} request failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
322
+ throw new Error(`${endpointPath} request failed: ${response.status} ${body}`);
323
+ }
324
+ return body;
325
+ }
326
+
327
+ // POST /api/code-workspace/{workspaceId}/path-between — shortest resolved call-graph path
328
+ // between two symbols. Distinct request shape from callHarmonySearchEndpoint (from/to, not prompt).
329
+ export async function callHarmonyPathBetween(args, workspaceId) {
330
+ const from = args.from;
331
+ const to = args.to;
332
+ if (!from || !to) throw new Error("Both 'from' and 'to' are required.");
333
+
334
+ const requestBody = {
335
+ from,
336
+ to,
337
+ from_file_path: args.from_file_path,
338
+ to_file_path: args.to_file_path,
339
+ workspaceMetadata: buildWorkspaceMetadata(workspaceId),
340
+ };
341
+
342
+ log(`[path-between] Request body:`, JSON.stringify(requestBody, null, 2));
343
+
344
+ const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/path-between`, {
345
+ method: "POST",
346
+ headers: {
347
+ "Content-Type": "application/json",
348
+ Accept: "application/xml",
349
+ ...(await authHeader(workspaceId)),
350
+ },
351
+ body: JSON.stringify(requestBody),
352
+ });
353
+ const body = await response.text();
354
+ if (!response.ok) {
355
+ throw new Error(`path-between request failed: ${response.status} ${body}`);
348
356
  }
349
- return truncateForAgent(endpointPath, body);
357
+ return body;
350
358
  }
351
359
 
352
360
  // POST /api/code-workspace/{workspaceId}/bundle — ranked XML context bundle for a prompt.
@@ -370,9 +378,9 @@ export async function fetchContextBundle(workspaceId, prompt) {
370
378
  });
371
379
  const body = await response.text();
372
380
  if (!response.ok) {
373
- throw new Error(`Bundle request failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
381
+ throw new Error(`Bundle request failed: ${response.status} ${body}`);
374
382
  }
375
- return truncateForAgent("get_context_bundle", body);
383
+ return body;
376
384
  }
377
385
 
378
386
  // An empty list is ambiguous (no matches vs. index not ready vs. failed query) — flag it.
@@ -393,7 +401,7 @@ export function annotateIfFallbackBundle(body) {
393
401
  return `${body}\n\n` +
394
402
  `[harmony-mcp note: this bundle used FALLBACK_NATIVE_RECALL — the backend did not resolve a ` +
395
403
  `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.]`;
404
+ `than a precisely targeted answer. Consider locate or context_search for a sharper result.]`;
397
405
  }
398
406
 
399
407
  // POST /api/v1/index/files — used by the file watcher for incremental updates.
package/src/server.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  isFailedIndexStatus,
28
28
  pollWorkspaceStatus,
29
29
  callHarmonySearchEndpoint,
30
+ callHarmonyPathBetween,
30
31
  fetchContextBundle,
31
32
  annotateIfEmptyList,
32
33
  annotateIfFallbackBundle,
@@ -159,14 +160,16 @@ function describeIndexOutcome(indexStatus, workspaceId) {
159
160
  return {
160
161
  ready: true,
161
162
  message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
162
- `It's ready for context_search, locate, search_code_context, find_files, and get_context_bundle.`,
163
+ `It's ready for context_search, locate, explain_symbol, path_between, and explain_subsystem.`,
163
164
  };
164
165
  }
165
166
  if (DEGRADED_STATUSES.has(indexStatus)) {
166
167
  return {
167
168
  ready: false,
168
169
  message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
169
- `find_files and get_context_bundle should still work; locate/search_code_context/context_search may return no results.`,
170
+ `Symbol-level tools (locate, explain_symbol, path_between, explain_subsystem) and possibly ` +
171
+ `context_search may return incomplete or no results until symbol indexing finishes — verify ` +
172
+ `with local search (rg/grep) if a result looks suspiciously empty.`,
170
173
  };
171
174
  }
172
175
  if (indexStatus === "CORRUPTED") {
@@ -179,7 +182,7 @@ function describeIndexOutcome(indexStatus, workspaceId) {
179
182
  ready: false,
180
183
  message: `Workspace ${workspaceId} upload succeeded, but the backend is still indexing ` +
181
184
  `(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/search_code_context.`,
185
+ `setup_workspace again shortly to check whether it's finished before relying on locate/context_search results.`,
183
186
  };
184
187
  }
185
188
 
@@ -302,6 +305,12 @@ function makeSearchHandler(endpointPath, toolName) {
302
305
  };
303
306
  }
304
307
 
308
+ async function handlePathBetween(args) {
309
+ const workspaceId = resolveWorkspaceId(args);
310
+ const body = await callHarmonyPathBetween(args, workspaceId);
311
+ return textContent(body);
312
+ }
313
+
305
314
  const TOOL_HANDLERS = {
306
315
  login: handleLogin,
307
316
  confirm_login: handleConfirmLogin,
@@ -311,6 +320,9 @@ const TOOL_HANDLERS = {
311
320
  locate: makeSearchHandler("locate-symbol", "locate"),
312
321
  search_code_context: makeSearchHandler("search", "search_code_context"),
313
322
  find_files: makeSearchHandler("find-files", "find_files"),
323
+ explain_symbol: makeSearchHandler("explain-symbol", "explain_symbol"),
324
+ path_between: handlePathBetween,
325
+ explain_subsystem: makeSearchHandler("explain-subsystem", "explain_subsystem"),
314
326
  };
315
327
 
316
328
  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, locate, search_code_context, or find_files, judge whether the user's own wording is
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
- - \`search_code_context\` — you need to understand or explain how something works: matching symbols
82
- with their code snippets, documentation, and decorators. Not for pinpointing an edit.
83
- - \`find_files\` — broad file/module discovery ("find all the controllers") without needing symbols
84
- or code content.
85
- - \`get_context_bundle\` — broader contextual understanding for a task or question, not a specific
86
- edit location. Returns a fuller XML context bundle for a prompt.
87
-
88
- If context_search's result is empty or insufficient, or you specifically need one of the other
89
- tools' output shape (e.g. locate's line-number-only anchors), fall back to that narrower tool rather
90
- than retrying context_search. Composing that fallback: never just resend the same raw user query —
91
- carry forward the specific symbols, identifiers, and file paths context_search's response already
92
- surfaced, and combine THOSE with the user's original query when building the fallback tool's
93
- \`prompt\` (and \`file_path\` where applicable). The fallback call should read as "user's intent,
94
- sharpened by what context_search already found," not a blind retry of the same input.
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, locate, search_code_context, and
104
- find_files all accept the same optional \`file_path\` field to scope results to a subdirectory,
105
- module, or specific file. Whenever a file path is already known at call time — surfaced by an
106
- earlier context_search/locate/find_files result this task, stated explicitly by the user, or
107
- established earlier in the conversation — pass it into that call's \`file_path\`, don't leave it
108
- blank and rely on the \`prompt\` text alone to imply scope. Only omit \`file_path\` when no such path
109
- is actually known yet; never fill it with a guessed path (see refinement step 3 above).
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/search_code_context/find_files, check
124
- whether this exact (prompt, file_path, workspaceId) combination was already issued earlier in this
125
- task; if so, reuse that earlier result instead of calling again.
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, search_code_context for
138
- full detail) instead of re-running context_search's general-purpose ranking pass again.
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/search_code_context results. If it says indexing is still
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 — find_files and get_context_bundle still work,
161
- locate/search_code_context may not) or failed outright, relay that instead of retrying blindly.
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 — get_context_bundle, context_search, locate, search_code_context and find_files all
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
@@ -47,7 +47,8 @@ export const TOOLS = [
47
47
  "Set up AND fully index the current workspace on the backend in a single call (creates the workspace " +
48
48
  "if needed, then zips and uploads the codebase). Safe to call repeatedly — already-completed steps are " +
49
49
  "skipped, so calling it again after it has already succeeded is a cheap no-op. Required once per " +
50
- "project before locate or get_context_bundle will work. If it fails partway (e.g. the upload step " +
50
+ "project before context_search, locate, explain_symbol, path_between, or explain_subsystem will work. " +
51
+ "If it fails partway (e.g. the upload step " +
51
52
  "times out) after the workspace was already created, just call it again — language/buildTool can be " +
52
53
  "omitted on that retry, since they're remembered from the first call.",
53
54
  inputSchema: {
@@ -72,26 +73,33 @@ export const TOOLS = [
72
73
  {
73
74
  name: "context_search",
74
75
  description:
75
- "Searches this codebase's remote-indexed context — matching symbols with code snippets, file paths, " +
76
- "and relevance ranking, for a natural language query or exact identifier. Best fit when you don't yet " +
77
- "know which file/symbol is relevant, or need a fuzzy/semantic match rather than a literal string " +
78
- "(the kind of query grep/rg would miss or over-return). If you already know the exact file or string, " +
79
- "Read/Grep is usually faster. Often a good starting point among Harmony's own tools before locate, " +
80
- "search_code_context, or find_files; fall back to one of those narrower tools if this result is " +
81
- "empty, insufficient, or you specifically need one of their specialized output shapes (e.g. locate's " +
82
- "line-number-only anchors for a targeted edit). Whenever you do fall back to one of the narrower " +
83
- "tools, don't discard what this call already found: carry its matched symbols, identifiers, and file " +
84
- "paths forward and combine them with the user's original query to build that tool's input, rather " +
85
- "than re-issuing the raw query alone.\n\n" +
86
- "RESPONSE SHAPE: the XML response has two separate top-level parts — <Hits><Hit>...</Hit></Hits>, " +
87
- "which is the actual code context (the matched symbols/snippets/file paths you answer the user's " +
88
- "query with), and a sibling <harmony_telemetry> block (filesBundledCount, graphEdgesResolved, " +
89
- "processingTimeMs, estimatedSecondsSaved, estimatedLoopsBypassed, estimatedTokensSaved) which is just " +
90
- "an operational efficiency snapshot of the search itself — not a search result and not code context. " +
91
- "Never merge, count, or cite <harmony_telemetry> fields as if they were part of <Hits>. Use only <Hits> " +
92
- "to answer the user's actual question. If you mention telemetry at all, present it separately and " +
93
- "clearly labeled (e.g. as a short aside/footnote about how the search performed), and only when it's " +
94
- "actually relevant to what the user asked — don't surface it by default on every call.",
76
+ "PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
77
+ "search endpoint. Given a natural language query or exact identifier, returns ranked matching symbols " +
78
+ "as structural facts and precise file:line locations — file path, symbol kind/decorators/name, and an " +
79
+ "exact line range per symbol — deliberately WITHOUT embedded source code, the same way graphify's " +
80
+ "query/explain primitives work. Try this BEFORE locate; only fall back to locate if context_search's " +
81
+ "result is empty, insufficient, or you specifically need its line-number-only anchors for a targeted " +
82
+ "edit. For a question that's inherently about a call relationship or a whole subsystem rather than " +
83
+ "'find me the code for X', reach directly for explain_symbol/path_between/explain_subsystem instead — " +
84
+ "don't route through context_search first just to warm up. Treat context_search as the always-on default " +
85
+ "entry point for every new discovery/comprehension need that comes up during a task — call it again " +
86
+ "each time one arises, not just once. Whenever you do fall back to locate, don't " +
87
+ "discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
88
+ "and combine them with the user's original query to build that tool's input, rather than re-issuing " +
89
+ "the raw query alone.\n\n" +
90
+ "RESPONSE SHAPE: the XML response has two separate top-level parts. <Hits><Hit>...</Hit></Hits> is the " +
91
+ "location index — each Hit's <codeSnippet> is a compact table of contents for that file (one line per " +
92
+ "symbol: decorators, kind, name, and its exact lines{start:end} range), and <lineNumbers> pins the " +
93
+ "specific symbol this Hit matched to its own exact range. NEITHER field contains real source lines. " +
94
+ "Once you've decided which hit(s) actually matter, use your own file-read tool on the given file path " +
95
+ "and line range to see the real code — do not answer the user's question from <codeSnippet> alone, " +
96
+ "and never present a lines{a:b} header line as if it were the method body. The sibling " +
97
+ "<harmony_telemetry> block (filesBundledCount, graphEdgesResolved, processingTimeMs, " +
98
+ "estimatedSecondsSaved, estimatedLoopsBypassed, estimatedTokensSaved) is just an operational efficiency " +
99
+ "snapshot of the search itself — not a search result and not code context. Never merge, count, or cite " +
100
+ "<harmony_telemetry> fields as if they were part of <Hits>. If you mention telemetry at all, present it " +
101
+ "separately and clearly labeled (e.g. as a short aside/footnote about how the search performed), and " +
102
+ "only when it's actually relevant to what the user asked — don't surface it by default on every call.",
95
103
  inputSchema: {
96
104
  type: "object",
97
105
  properties: {
@@ -179,8 +187,7 @@ export const TOOLS = [
179
187
  required: ["prompt"],
180
188
  },
181
189
  },
182
- /*
183
- {
190
+ /* {
184
191
  name: "search_code_context",
185
192
  description:
186
193
  "Given a natural language query, returns rich Q&A context: matching symbols along with their code " +
@@ -208,6 +215,98 @@ export const TOOLS = [
208
215
  required: ["prompt"],
209
216
  },
210
217
  },
218
+ */
219
+ {
220
+ name: "explain_symbol",
221
+ description:
222
+ "Given an exact symbol name (method, function, or class), returns what it's connected to in the " +
223
+ "persisted call graph: which symbols call it, which symbols it calls, and any call targets that " +
224
+ "couldn't be confidently resolved to a single definition. Use this to understand a symbol's role " +
225
+ "and blast radius before changing it, or to answer 'who calls X' / 'what does X call' directly, " +
226
+ "without falling back to reading every file that might reference it.\n\n" +
227
+ "DISAMBIGUATION: common names (e.g. an interface method like 'processCommand' implemented by " +
228
+ "hundreds of classes) can match many definitions — the response is a list, one item per match. " +
229
+ "If you already know roughly where the symbol lives, pass file_path to narrow it to the exact one " +
230
+ "you mean instead of scanning every item in the list.",
231
+ inputSchema: {
232
+ type: "object",
233
+ properties: {
234
+ prompt: {
235
+ type: "string",
236
+ description: "REQUIRED. The exact symbol name to explain (e.g. a method or class name).",
237
+ },
238
+ file_path: {
239
+ type: "string",
240
+ description:
241
+ "Optional path substring narrowing which definition to use when the name alone is ambiguous " +
242
+ "(e.g. \"DisburseWorkingCapitalLoanCommandHandler\" to pick that class's processCommand out of " +
243
+ "hundreds of others with the same name).",
244
+ },
245
+ workspaceId: WORKSPACE_ID_PROPERTY,
246
+ },
247
+ required: ["prompt"],
248
+ },
249
+ },
250
+ {
251
+ name: "path_between",
252
+ description:
253
+ "Given two exact symbol names, finds the shortest resolved call-graph path from the first to the " +
254
+ "second (e.g. how a controller method eventually reaches a repository call several hops down). " +
255
+ "Returns found: false if no path exists within the search bounds — that does not necessarily mean " +
256
+ "no relationship exists: it can also mean the bare name was too ambiguous to resolve to the specific " +
257
+ "definition you meant (common names like interface method implementations can have hundreds of " +
258
+ "matches — try again with from_file_path/to_file_path once you know roughly where each symbol " +
259
+ "lives), or that the call site was ambiguous and intentionally left unresolved at index time (see " +
260
+ "explain_symbol's unresolved_call_targets).",
261
+ inputSchema: {
262
+ type: "object",
263
+ properties: {
264
+ from: {
265
+ type: "string",
266
+ description: "REQUIRED. The starting symbol's exact name.",
267
+ },
268
+ to: {
269
+ type: "string",
270
+ description: "REQUIRED. The target symbol's exact name to find a path to.",
271
+ },
272
+ from_file_path: {
273
+ type: "string",
274
+ description: "Optional path substring narrowing which \"from\" definition to use when the name alone is ambiguous.",
275
+ },
276
+ to_file_path: {
277
+ type: "string",
278
+ description: "Optional path substring narrowing which \"to\" definition to use when the name alone is ambiguous.",
279
+ },
280
+ workspaceId: WORKSPACE_ID_PROPERTY,
281
+ },
282
+ required: ["from", "to"],
283
+ },
284
+ },
285
+ {
286
+ name: "explain_subsystem",
287
+ description:
288
+ "Given a loose subsystem/module name (e.g. 'billing', 'auth'), returns every file harmony has " +
289
+ "clustered into that subsystem via its persisted import-graph communities — a direct listing, " +
290
+ "not a ranked search. Use this for 'how does the billing system work' style questions where you " +
291
+ "want the whole subsystem's files at once, rather than piecing it together from several " +
292
+ "context_search calls.",
293
+ inputSchema: {
294
+ type: "object",
295
+ properties: {
296
+ prompt: {
297
+ type: "string",
298
+ description: "REQUIRED. Loose subsystem/module name to match against detected community labels.",
299
+ },
300
+ limit: {
301
+ type: "number",
302
+ description: "Optional maximum number of files to return (default 60).",
303
+ },
304
+ workspaceId: WORKSPACE_ID_PROPERTY,
305
+ },
306
+ required: ["prompt"],
307
+ },
308
+ },
309
+ /*
211
310
  {
212
311
  name: "find_files",
213
312
  description:
@@ -235,6 +334,6 @@ export const TOOLS = [
235
334
  },
236
335
  required: ["prompt"],
237
336
  },
238
- }
337
+ },
239
338
  */
240
339
  ];