@codeconductorai/harmony-mcp 1.0.27 → 1.0.29

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.27`) 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.29`) 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.27
35
+ claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.29
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.27"]
50
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.29"]
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.27
61
+ codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.29
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.27"]
69
+ args = ["-y", "@codeconductorai/harmony-mcp@1.0.29"]
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.27"]
81
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.29"]
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.27"]
98
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.29"]
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 **`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.
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.
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
 
@@ -140,9 +140,7 @@ search endpoint. Given a natural-language query or exact identifier, returns ran
140
140
  as structural facts and precise file:line locations, deliberately without embedded source code.
141
141
  Takes precedence over `locate`; only fall back to it if
142
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
143
+ anchors for a targeted edit. Treat it as the
146
144
  always-on default entry point for every new discovery/comprehension need that comes up during a
147
145
  task — call it again each time, not just once. When falling back to `locate` afterward, its input
148
146
  should combine the user's original query with the symbols/identifiers/file paths this call already
@@ -159,27 +157,11 @@ Given a natural-language query or exact identifier, returns lightweight symbol c
159
157
  - `limit` (optional): max results (default 40); the result list is never padded to this size.
160
158
  - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
161
159
 
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).
166
- - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
167
-
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).
178
- - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
179
-
180
160
  ## Observability (OpenObserve)
181
161
 
182
- The server ships its own logs, traces, and metrics over OTLP/HTTP using OpenTelemetry, and forwards the active trace id to every request it makes to the harmony backend (as a W3C `traceparent` header plus a plain `X-Trace-Id` header) so backend-side logs can be correlated with the MCP session that triggered them.
162
+ **Telemetry export is disabled by default.** Set `HARMONY_TELEMETRY_ENABLED=true` in the server's environment to turn it on; otherwise no logs, traces, or metrics are sent and no trace headers are added to backend requests. Local file logging is unaffected.
163
+
164
+ When enabled, the server ships its own logs, traces, and metrics over OTLP/HTTP using OpenTelemetry, and forwards the active trace id to every request it makes to the harmony backend (as a W3C `traceparent` header plus a plain `X-Trace-Id` header) so backend-side logs can be correlated with the MCP session that triggered them.
183
165
 
184
166
  Telemetry is exported to the harmony backend's `/api/v1/otel/{traces,metrics,logs}` endpoints rather than straight to [OpenObserve](https://openobserve.codeconductor.ai/) — the backend forwards it on to OpenObserve using a server-side-only ingestion credential. This package holds no OpenObserve credential of its own: it authenticates to the backend with whichever Bearer session or workspace token it already uses for every other API call, so nothing extra needs to be configured, and a plain `npx` install never needs (or can leak) an ingestion secret. If neither token is available yet (e.g. before `login`/`setup_workspace`), export calls simply fail unauthenticated against the backend and are logged, without affecting normal server operation.
185
167
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeconductorai/harmony-mcp",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -284,7 +284,7 @@ export async function pollWorkspaceStatus(workspaceId, { maxWaitMs = 120_000, in
284
284
  return lastStatus;
285
285
  }
286
286
 
287
- // Shared POST caller for the context-search/locate-symbol/explain-symbol/explain-subsystem endpoints — same request/response shape.
287
+ // Shared POST caller for the context-search/locate-symbol endpoints — same request/response shape.
288
288
  export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId) {
289
289
  const prompt = args.prompt || args.query;
290
290
  if (!prompt) throw new Error("prompt is required.");
@@ -293,6 +293,10 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
293
293
  prompt,
294
294
  file_path: args.file_path,
295
295
  limit: args.limit,
296
+ // context_search returns code by default so the agent need not re-read the files; locate stays coordinates-only
297
+ include_code_snippets: args.include_code_snippets ?? (endpointPath === "context-search" ? true : undefined),
298
+ // context_search answers in the compact LLM format (llm-context-format-guide.md); locate keeps its own format
299
+ response_format: endpointPath === "context-search" ? "compact" : undefined,
296
300
  workspaceMetadata: buildWorkspaceMetadata(workspaceId),
297
301
  };
298
302
 
@@ -314,24 +318,12 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
314
318
  return body;
315
319
  }
316
320
 
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
-
324
- const requestBody = {
325
- from,
326
- to,
327
- from_file_path: args.from_file_path,
328
- to_file_path: args.to_file_path,
329
- workspaceMetadata: buildWorkspaceMetadata(workspaceId),
330
- };
331
-
332
- log(`[path-between] Request body:`, JSON.stringify(requestBody, null, 2));
321
+ // Shared POST caller for the newer single-purpose endpoints (query-module-dependencies,
322
+ // outline-file-symbols, get-repository-map) — identical JSON-in/XML-out shape, different path/body.
323
+ async function callHarmonyJsonEndpoint(endpointPath, requestBody, workspaceId) {
324
+ log(`[${endpointPath}] Request body:`, JSON.stringify(requestBody, null, 2));
333
325
 
334
- const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/path-between`, {
326
+ const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/${endpointPath}`, {
335
327
  method: "POST",
336
328
  headers: {
337
329
  "Content-Type": "application/json",
@@ -342,11 +334,43 @@ export async function callHarmonyPathBetween(args, workspaceId) {
342
334
  });
343
335
  const body = await response.text();
344
336
  if (!response.ok) {
345
- throw new Error(`path-between request failed: ${response.status} ${body}${traceSuffix()}`);
337
+ throw new Error(`${endpointPath} request failed: ${response.status} ${body}${traceSuffix()}`);
346
338
  }
347
339
  return body;
348
340
  }
349
341
 
342
+ // POST /api/code-workspace/{workspaceId}/query-module-dependencies — a file's directed
343
+ // import/inheritance dependencies.
344
+ export async function callHarmonyModuleDependencies(args, workspaceId) {
345
+ if (!args.file_path) throw new Error("file_path is required.");
346
+ return callHarmonyJsonEndpoint("query-module-dependencies", {
347
+ file_path: args.file_path,
348
+ depth: args.depth,
349
+ workspaceMetadata: buildWorkspaceMetadata(workspaceId),
350
+ }, workspaceId);
351
+ }
352
+
353
+ // POST /api/code-workspace/{workspaceId}/outline-file-symbols — a file's structural skeleton.
354
+ export async function callHarmonyFileOutline(args, workspaceId) {
355
+ if (!args.file_path) throw new Error("file_path is required.");
356
+ return callHarmonyJsonEndpoint("outline-file-symbols", {
357
+ file_path: args.file_path,
358
+ include_private: args.include_private,
359
+ workspaceMetadata: buildWorkspaceMetadata(workspaceId),
360
+ }, workspaceId);
361
+ }
362
+
363
+ // POST /api/code-workspace/{workspaceId}/get-repository-map — ranked, token-budgeted architectural
364
+ // map of the workspace.
365
+ export async function callHarmonyRepositoryMap(args, workspaceId) {
366
+ return callHarmonyJsonEndpoint("get-repository-map", {
367
+ focus_files: args.focus_files,
368
+ max_tokens: args.max_tokens,
369
+ directory_filter: args.directory_filter,
370
+ workspaceMetadata: buildWorkspaceMetadata(workspaceId),
371
+ }, workspaceId);
372
+ }
373
+
350
374
  // POST /api/v1/index/files — used by the file watcher for incremental updates.
351
375
  export async function sendFileUpdate(filePath, workspaceId, language, buildTool) {
352
376
  try {
package/src/server.js CHANGED
@@ -24,7 +24,9 @@ import {
24
24
  ensureWorkspaceUploaded,
25
25
  pollWorkspaceStatus,
26
26
  callHarmonySearchEndpoint,
27
- callHarmonyPathBetween,
27
+ callHarmonyModuleDependencies,
28
+ callHarmonyFileOutline,
29
+ callHarmonyRepositoryMap,
28
30
  } from "./harmonyClient.js";
29
31
  import { buildServerInstructions } from "./serverInstructions.js";
30
32
  import { TOOLS } from "./toolSchemas.js";
@@ -154,16 +156,17 @@ function describeIndexOutcome(indexStatus, workspaceId) {
154
156
  return {
155
157
  ready: true,
156
158
  message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
157
- `It's ready for context_search, locate, explain_symbol, path_between, and explain_subsystem.`,
159
+ `It's ready for context_search, locate, query_module_dependencies, outline_file_symbols, ` +
160
+ `and get_repository_map.`,
158
161
  };
159
162
  }
160
163
  if (DEGRADED_STATUSES.has(indexStatus)) {
161
164
  return {
162
165
  ready: false,
163
166
  message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
164
- `Symbol-level tools (locate, explain_symbol, path_between, explain_subsystem) and possibly ` +
165
- `context_search may return incomplete or no results until symbol indexing finishes — verify ` +
166
- `with local search (rg/grep) if a result looks suspiciously empty.`,
167
+ `Symbol-level tools (locate, outline_file_symbols, get_repository_map) and possibly ` +
168
+ `context_search/query_module_dependencies may return incomplete or no results until symbol ` +
169
+ `indexing finishes — verify with local search (rg/grep) if a result looks suspiciously empty.`,
167
170
  };
168
171
  }
169
172
  if (indexStatus === "CORRUPTED") {
@@ -274,10 +277,24 @@ function makeSearchHandler(endpointPath, toolName) {
274
277
  };
275
278
  }
276
279
 
277
- async function handlePathBetween(args) {
280
+ async function handleModuleDependencies(args) {
278
281
  const workspaceId = resolveWorkspaceId(args);
279
- const body = await callHarmonyPathBetween(args, workspaceId);
280
- log(`[path_between] response ${body.length} chars`);
282
+ const body = await callHarmonyModuleDependencies(args, workspaceId);
283
+ log(`[query_module_dependencies] response ${body.length} chars`);
284
+ return textContent(body);
285
+ }
286
+
287
+ async function handleFileOutline(args) {
288
+ const workspaceId = resolveWorkspaceId(args);
289
+ const body = await callHarmonyFileOutline(args, workspaceId);
290
+ log(`[outline_file_symbols] response ${body.length} chars`);
291
+ return textContent(body);
292
+ }
293
+
294
+ async function handleRepositoryMap(args) {
295
+ const workspaceId = resolveWorkspaceId(args);
296
+ const body = await callHarmonyRepositoryMap(args, workspaceId);
297
+ log(`[get_repository_map] response ${body.length} chars`);
281
298
  return textContent(body);
282
299
  }
283
300
 
@@ -287,9 +304,9 @@ const TOOL_HANDLERS = {
287
304
  setup_workspace: handleSetupWorkspace,
288
305
  context_search: makeSearchHandler("context-search", "context_search"),
289
306
  locate: makeSearchHandler("locate-symbol", "locate"),
290
- explain_symbol: makeSearchHandler("explain-symbol", "explain_symbol"),
291
- path_between: handlePathBetween,
292
- explain_subsystem: makeSearchHandler("explain-subsystem", "explain_subsystem"),
307
+ query_module_dependencies: handleModuleDependencies,
308
+ outline_file_symbols: handleFileOutline,
309
+ get_repository_map: handleRepositoryMap,
293
310
  };
294
311
 
295
312
  const AUTH_EXEMPT_TOOLS = new Set(["login", "confirm_login", "setup_workspace"]);
@@ -311,11 +328,10 @@ function workspaceIdForLog(args) {
311
328
  }
312
329
  }
313
330
 
314
- // The agent-supplied intent behind the call, whatever the tool names it — path_between has no
315
- // single prompt field, so its two endpoints stand in for one.
331
+ // The agent-supplied intent behind the call, whatever the tool names it.
316
332
  function userPromptForLog(args) {
317
333
  if (typeof args?.prompt === "string") return args.prompt;
318
- if (args?.from && args?.to) return `${args.from} → ${args.to}`;
334
+ if (typeof args?.file_path === "string") return args.file_path;
319
335
  return undefined;
320
336
  }
321
337
 
@@ -329,7 +345,7 @@ function responseTextForLog(result) {
329
345
 
330
346
  // Arguments minus the prompt, which is logged on its own field.
331
347
  function toolArgsForLog(args) {
332
- const { prompt, from, to, ...rest } = args || {};
348
+ const { prompt, ...rest } = args || {};
333
349
  return Object.keys(rest).length ? rest : undefined;
334
350
  }
335
351
 
@@ -20,8 +20,11 @@ instead:
20
20
  already see) — just Read it or Grep for the exact string; that's faster and skips network/auth/
21
21
  indexing latency for no benefit.
22
22
  - Small, local edits or reasoning fully contained in a file you already have open.
23
- - The workspace isn't indexed yet, or Harmony just returned empty/stale/irrelevant results for this
24
- specific lookup — fall back to rg/grep/Read for that lookup rather than retrying Harmony.
23
+ - The workspace isn't indexed yet — fall back to rg/grep/Read for that lookup.
24
+ - Harmony just returned empty/stale/irrelevant results for this specific lookup from one tool — don't
25
+ fall back to rg/grep/Read yet; try another Harmony tool suited to the same lookup first (see "Trust
26
+ but verify" below). Only fall back to local tools once that alternate Harmony tool also comes up
27
+ short.
25
28
  - Writing new code, boilerplate, or general-purpose logic that doesn't depend on this repo's
26
29
  existing implementation.
27
30
 
@@ -72,24 +75,27 @@ to act on — it doesn't replace them, and it doesn't apply to the setup/auth to
72
75
 
73
76
  const ROUTING_RULES = `
74
77
  Choosing among Harmony's tools — once Harmony is the right move for a lookup, pick the narrowest fit:
78
+ - \`get_repository_map\` — the FIRST call for an unfamiliar codebase or subsystem: a ranked,
79
+ token-budgeted architectural overview (the most structurally important files by call-graph
80
+ centrality and subsystem clustering, with their top symbols) in one call, instead of directory
81
+ traversals or a string of unscoped context_search calls just to build a mental model. Pass
82
+ focus_files when specific files are already known to be relevant (open in the editor, mentioned by
83
+ the user) to rank them first. This is orientation, not a substitute for the targeted lookups below
84
+ — move on to context_search/locate once you have specific symbols or files in mind.
75
85
  - \`context_search\` — usually the best starting point for open-ended discovery/comprehension: ranked
76
86
  matching symbols with code snippets, file paths, and relevance for a natural language query or
77
87
  exact identifier.
78
88
  - \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns every
79
89
  matching symbol occurrence (definitions and references) with exact line numbers, optionally scoped
80
90
  to a file_path once you already know the file.
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.
91
+ - \`outline_file_symbols\` — a specific file's structural skeleton: every definition's signature line,
92
+ docstring, and line number, with implementation bodies omitted. Use this INSTEAD of Read() when you
93
+ only need to understand a file's interface and capabilities rather than its execution logic — far
94
+ cheaper than reading the whole file.
95
+ - \`query_module_dependencies\` — a file's directed import/inheritance dependencies: what it depends
96
+ on, and what depends on it, optionally one further transitive hop. Use this INSTEAD of manually
97
+ grepping import statements across files to check coupling or trace architectural boundaries before
98
+ touching a shared file.
93
99
 
94
100
  If context_search's result is empty or insufficient, or you specifically need locate's line-number-
95
101
  only anchors, fall back to that narrower tool rather than retrying context_search. Composing that
@@ -97,10 +103,7 @@ fallback: never just resend the same raw user query — carry forward the specif
97
103
  identifiers, and file paths context_search's response already surfaced, and combine THOSE with the
98
104
  user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
99
105
  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.
106
+ already found," not a blind retry of the same input.
104
107
 
105
108
  Carry forward a good result: once a Harmony response gives you a concrete file_path, symbol name, or
106
109
  other specific detail relevant to the task, treat it as ground truth for every tool call that
@@ -110,32 +113,42 @@ move on to Read, an edit, or any other tool — use the exact path/identifier al
110
113
  than deriving your own guess at that point.
111
114
 
112
115
  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).
116
+ field to scope results to a subdirectory, module, or specific file. Whenever a file path is already
117
+ known at call time — surfaced by an earlier context_search/locate result this task, stated explicitly
118
+ by the user, or established earlier in the conversation — pass it into that call's \`file_path\`,
119
+ don't leave it blank and rely on the \`prompt\` text alone to imply scope. Only omit it when no such
120
+ path is actually known yet; never fill it with a guessed path (see refinement step 3 above).
122
121
  `.trim();
123
122
 
124
123
  const TRUST_BUT_VERIFY = `
125
124
  Trust but verify: Harmony's index can be stale, incomplete, or briefly out of date relative to the
126
125
  working tree. If a result is empty, errors, looks stale (references code that no longer exists), or
127
- is otherwise insufficient, don't retry the same call — fall back to local tools (rg, Read, etc.) for
128
- that specific lookup only. After a good Harmony result, proceed straight to the edit/answer — don't
129
- re-derive context you just fetched, and don't Read() a whole file the tool already covered.
126
+ is otherwise insufficient, don't retry the same call — and don't jump straight to local tools either.
127
+ First try whichever other Harmony tool is the next-best fit for that same lookup, carrying forward
128
+ anything the failed call already surfaced (a symbol name, a file path) into the new call rather than
129
+ starting from scratch:
130
+ - \`context_search\` came up empty/insufficient → try \`locate\` with the same (or refined) prompt for
131
+ its line-number anchors, or \`get_repository_map\` if the ask was really about orientation in an
132
+ unfamiliar area.
133
+ - \`locate\` came up empty for a file you already know → try \`outline_file_symbols\` on it directly
134
+ instead of assuming the symbol isn't there.
135
+ - A coupling/"what depends on this" question came up empty from \`context_search\`/\`locate\` → try
136
+ \`query_module_dependencies\` on the file in question.
137
+ - Any symbol-shaped query came up empty as a natural-language \`prompt\` → retry it as \`locate\` with
138
+ the exact identifier instead, in case the phrasing (not the index) was the problem.
139
+ Only once that alternate Harmony tool has also failed to turn up anything relevant should you fall
140
+ back to local tools (rg, Read, etc.) for that specific lookup — this is a last resort, not the second
141
+ thing you try. After a good Harmony result (from either the first or the alternate tool), proceed
142
+ straight to the edit/answer — don't re-derive context you just fetched, and don't Read() a whole file
143
+ the tool already covered.
130
144
  `.trim();
131
145
 
132
146
  const EFFICIENCY_RULES = `
133
147
  Efficiency — once a query is already well-formed (after refinement above), apply these to keep tool
134
148
  calls fast and non-redundant:
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.
149
+ - Don't repeat calls — before calling context_search/locate, check whether this exact (prompt,
150
+ file_path, workspaceId) combination was already issued earlier in this task; if so, reuse that
151
+ earlier result instead of calling again.
139
152
  - Fan out independent lookups in parallel — when a task needs context on two or more genuinely
140
153
  unrelated things (e.g. "how does auth work and how does logging work"), or when refinement above
141
154
  produced multiple plausible variant queries for one ambiguous category, issue those calls together
@@ -147,8 +160,8 @@ calls fast and non-redundant:
147
160
  queries, where a small limit risks cutting off the right result.
148
161
  - Skip redundant ranking on retries — if a symbol's existence and rough location were already
149
162
  confirmed by an earlier context_search/locate result this task, a later lookup for that same
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.
163
+ symbol can go straight to locate for its line numbers instead of re-running context_search's
164
+ general-purpose ranking pass again.
152
165
  `.trim();
153
166
 
154
167
  const SETUP_INSTRUCTIONS = `
@@ -166,8 +179,7 @@ Workspace setup — before the first search/locate/context call in a project:
166
179
  HTTP request succeeded. The response's \`ready\` field is only true once the backend confirms both
167
180
  text and symbols are indexed.
168
181
  - If \`ready\` is false, read \`indexStatus\` and the \`response\` text and relay them to the user in
169
- plain language before relying on locate/context_search/explain_symbol/path_between/
170
- explain_subsystem results. If it says indexing is still
182
+ plain language before relying on locate/context_search results. If it says indexing is still
171
183
  running (the common case for large repos — the time budget ran out before the backend finished),
172
184
  this is expected and not a failure: tell the user briefly, then call \`setup_workspace\` again
173
185
  after a short wait to re-check — repeat until \`ready\` is true. If it instead reports only
@@ -176,7 +188,8 @@ Workspace setup — before the first search/locate/context call in a project:
176
188
  `.trim();
177
189
 
178
190
  const AUTH_INSTRUCTIONS = `
179
- Auth gate — context_search, locate, explain_symbol, path_between, and explain_subsystem all
191
+ Auth gate — context_search, locate, query_module_dependencies, outline_file_symbols, and
192
+ get_repository_map all
180
193
  return a "not authenticated" error until login has succeeded; run the login flow below before
181
194
  using them. setup_workspace is the one exception: call it directly even before logging in — it
182
195
  uses the login session when one exists, but some deployments authenticate the workspace
package/src/telemetry.js CHANGED
@@ -61,13 +61,21 @@ const sdk = new NodeSDK({
61
61
  logRecordProcessors: [new BatchLogRecordProcessor({ exporter: logExporter })],
62
62
  });
63
63
 
64
+ // Export to OpenObserve is opt-in. Without a started SDK the @opentelemetry/api calls below are
65
+ // no-ops, so no logs, metrics, or traces leave the process.
66
+ const TELEMETRY_ENABLED = process.env.HARMONY_TELEMETRY_ENABLED === "true";
67
+
64
68
  let started = false;
65
- try {
66
- sdk.start();
67
- started = true;
68
- log(`[telemetry] OpenTelemetry started — exporting via backend proxy at ${OTLP_BASE}`);
69
- } catch (err) {
70
- log(`[telemetry] Failed to start OpenTelemetry SDK: ${err?.message || err}`);
69
+ if (TELEMETRY_ENABLED) {
70
+ try {
71
+ sdk.start();
72
+ started = true;
73
+ log(`[telemetry] OpenTelemetry started — exporting via backend proxy at ${OTLP_BASE}`);
74
+ } catch (err) {
75
+ log(`[telemetry] Failed to start OpenTelemetry SDK: ${err?.message || err}`);
76
+ }
77
+ } else {
78
+ log("[telemetry] OpenTelemetry export disabled (set HARMONY_TELEMETRY_ENABLED=true to enable)");
71
79
  }
72
80
 
73
81
  export async function shutdownTelemetry() {
@@ -123,12 +131,12 @@ export async function tracedFetch(url, options = {}) {
123
131
  const traceId = getActiveTraceId();
124
132
  span.setAttribute("http.request.method", method);
125
133
  span.setAttribute("url.full", url);
126
- log(`[telemetry] trace id ${traceId} for ${method} ${path}`);
134
+ if (traceId) log(`[telemetry] trace id ${traceId} for ${method} ${path}`);
127
135
  const startedAt = Date.now();
128
136
  try {
129
137
  const response = await fetch(url, { ...options, headers: injectTraceHeaders(options.headers || {}) });
130
138
  span.setAttribute("http.response.status_code", response.status);
131
- log(`[telemetry] trace id ${traceId} for ${method} ${path} -> ${response.status}` +
139
+ if (traceId) log(`[telemetry] trace id ${traceId} for ${method} ${path} -> ${response.status}` +
132
140
  (response.ok ? "" : " (backend X-Trace-Id: " + (response.headers.get("x-trace-id") || "none") + ")"));
133
141
  if (!response.ok) {
134
142
  span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${response.status}` });
@@ -139,7 +147,7 @@ export async function tracedFetch(url, options = {}) {
139
147
  span.recordException(error);
140
148
  span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });
141
149
  backendRequestErrors.add(1, { "url.path": path });
142
- log(`[telemetry] trace id ${traceId} for ${method} ${path} -> request error: ${error?.message}`);
150
+ if (traceId) log(`[telemetry] trace id ${traceId} for ${method} ${path} -> request error: ${error?.message}`);
143
151
  throw error;
144
152
  } finally {
145
153
  backendRequestDuration.record(Date.now() - startedAt, { "url.path": path });
@@ -45,7 +45,7 @@ export const TOOLS = [
45
45
  "Set up AND fully index the current workspace on the backend in a single call (creates the workspace " +
46
46
  "if needed, then zips and uploads the codebase). Safe to call repeatedly — already-completed steps are " +
47
47
  "skipped, so calling it again after it has already succeeded is a cheap no-op. Required once per " +
48
- "project before context_search, locate, explain_symbol, path_between, or explain_subsystem will work. " +
48
+ "project before context_search or locate will work. " +
49
49
  "If it fails partway (e.g. the upload step " +
50
50
  "times out) after the workspace was already created, just call it again — language/buildTool can be " +
51
51
  "omitted on that retry, since they're remembered from the first call.",
@@ -70,16 +70,18 @@ export const TOOLS = [
70
70
  },
71
71
  {
72
72
  name: "context_search",
73
+ _meta: { "anthropic/alwaysLoad": true },
73
74
  description:
74
75
  "PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
75
76
  "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 " +
77
+ "in a compact format: one root with relative paths; verbatim code (exact=\"true\", safe to use for an " +
78
+ "Edit) for the top hits, limited to the members that match the question; the remaining hits as one line " +
79
+ "each with member signatures and line ranges; other members named so you can tell what was left out; " +
80
+ "flow questions answered as a one-line-per-step trace. Code marked exact=\"false\" has collapsed or cut " +
81
+ "lines, named in the block. The answer usually needs no follow-up file reads — read a file only for " +
82
+ "lines it names as not shown, or before editing. Try this BEFORE locate; only fall back to locate if context_search's " +
79
83
  "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 " +
84
+ "edit. Treat context_search as the always-on default " +
83
85
  "entry point for every new discovery/comprehension need that comes up during a task — call it again " +
84
86
  "each time one arises, not just once. Whenever you do fall back to locate, don't " +
85
87
  "discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
@@ -102,6 +104,12 @@ export const TOOLS = [
102
104
  type: "number",
103
105
  description: "Optional maximum number of results to return; the backend applies its own default if omitted.",
104
106
  },
107
+ include_code_snippets: {
108
+ type: "boolean",
109
+ description:
110
+ "Optional, default true. Each returned symbol (and each step of a traced flow) includes its source " +
111
+ "excerpt (method or class body, capped at 50 lines). Set false to get file paths and line numbers only.",
112
+ },
105
113
  workspaceId: WORKSPACE_ID_PROPERTY,
106
114
  },
107
115
  required: ["prompt"],
@@ -144,7 +152,7 @@ export const TOOLS = [
144
152
  },
145
153
  limit: {
146
154
  type: "number",
147
- description: "Maximum number of results to return (default 40). The result list is never padded to this size.",
155
+ description: "Maximum number of results to return (default 10). The result list is never padded to this size.",
148
156
  },
149
157
  workspaceId: WORKSPACE_ID_PROPERTY,
150
158
  },
@@ -152,93 +160,83 @@ export const TOOLS = [
152
160
  },
153
161
  },
154
162
  {
155
- name: "explain_symbol",
163
+ name: "query_module_dependencies",
156
164
  description:
157
- "Given an exact symbol name (method, function, or class), returns what it's connected to in the " +
158
- "persisted call graph: which symbols call it, which symbols it calls, and any call targets that " +
159
- "couldn't be confidently resolved to a single definition. Use this to understand a symbol's role " +
160
- "and blast radius before changing it, or to answer 'who calls X' / 'what does X call' directly, " +
161
- "without falling back to reading every file that might reference it.\n\n" +
162
- "DISAMBIGUATION: common names (e.g. an interface method like 'processCommand' implemented by " +
163
- "hundreds of classes) can match many definitions — the response is a list, one item per match. " +
164
- "If you already know roughly where the symbol lives, pass file_path to narrow it to the exact one " +
165
- "you mean instead of scanning every item in the list.",
165
+ "Given a file path, returns its directed import/inheritance dependencies: every in-workspace " +
166
+ "file it depends on, and every file that depends on it. Use this INSTEAD of manually grepping " +
167
+ "import statements across files to check coupling or trace architectural boundaries before " +
168
+ "touching a shared file.",
166
169
  inputSchema: {
167
170
  type: "object",
168
171
  properties: {
169
- prompt: {
170
- type: "string",
171
- description: "REQUIRED. The exact symbol name to explain (e.g. a method or class name).",
172
- },
173
172
  file_path: {
174
173
  type: "string",
174
+ description: "REQUIRED. The relative file path whose dependencies should be resolved.",
175
+ },
176
+ depth: {
177
+ type: "number",
175
178
  description:
176
- "Optional path substring narrowing which definition to use when the name alone is ambiguous " +
177
- "(e.g. \"DisburseWorkingCapitalLoanCommandHandler\" to pick that class's processCommand out of " +
178
- "hundreds of others with the same name).",
179
+ "Traversal depth: 1 (default) for direct dependencies only, 2 for one further transitive hop.",
179
180
  },
180
181
  workspaceId: WORKSPACE_ID_PROPERTY,
181
182
  },
182
- required: ["prompt"],
183
+ required: ["file_path"],
183
184
  },
184
185
  },
185
186
  {
186
- name: "path_between",
187
+ name: "outline_file_symbols",
187
188
  description:
188
- "Given two exact symbol names, finds the shortest resolved call-graph path from the first to the " +
189
- "second (e.g. how a controller method eventually reaches a repository call several hops down). " +
190
- "Returns found: false if no path exists within the search bounds — that does not necessarily mean " +
191
- "no relationship exists: it can also mean the bare name was too ambiguous to resolve to the specific " +
192
- "definition you meant (common names like interface method implementations can have hundreds of " +
193
- "matches — try again with from_file_path/to_file_path once you know roughly where each symbol " +
194
- "lives), or that the call site was ambiguous and intentionally left unresolved at index time (see " +
195
- "explain_symbol's unresolved_call_targets).",
189
+ "Extracts a file's structural skeleton — every definition's signature line, docstring, and " +
190
+ "line number, with implementation bodies omitted. Use this INSTEAD of reading the whole file " +
191
+ "with Read() when you only need to understand a file's interface and capabilities, not its " +
192
+ "execution logic.",
196
193
  inputSchema: {
197
194
  type: "object",
198
195
  properties: {
199
- from: {
200
- type: "string",
201
- description: "REQUIRED. The starting symbol's exact name.",
202
- },
203
- to: {
204
- type: "string",
205
- description: "REQUIRED. The target symbol's exact name to find a path to.",
206
- },
207
- from_file_path: {
196
+ file_path: {
208
197
  type: "string",
209
- description: "Optional path substring narrowing which \"from\" definition to use when the name alone is ambiguous.",
198
+ description: "REQUIRED. Relative path to the source file (e.g. 'src/main/java/app/OrderService.java').",
210
199
  },
211
- to_file_path: {
212
- type: "string",
213
- description: "Optional path substring narrowing which \"to\" definition to use when the name alone is ambiguous.",
200
+ include_private: {
201
+ type: "boolean",
202
+ description:
203
+ "Whether to include symbols that look private/unexported. Default false (exported-only) " +
204
+ "to preserve token economy.",
214
205
  },
215
206
  workspaceId: WORKSPACE_ID_PROPERTY,
216
207
  },
217
- required: ["from", "to"],
208
+ required: ["file_path"],
218
209
  },
219
210
  },
220
211
  {
221
- name: "explain_subsystem",
212
+ name: "get_repository_map",
222
213
  description:
223
- "Given a loose subsystem/module name (e.g. 'billing', 'auth'), returns every file harmony has " +
224
- "clustered into that subsystem via its persisted import-graph communities — a direct listing, " +
225
- "not a ranked search. Use this for 'how does the billing system work' style questions where you " +
226
- "want the whole subsystem's files at once, rather than piecing it together from several " +
227
- "context_search calls.",
214
+ "Generates a ranked, token-budgeted architectural map of the repository: the most " +
215
+ "structurally important files (by call-graph centrality and subsystem clustering) and their " +
216
+ "top symbols. Use this tool FIRST when working in an unfamiliar codebase or subsystem, to " +
217
+ "understand project layout and find relevant modules, INSTEAD of manual directory traversals " +
218
+ "or a string of unscoped context_search calls.",
228
219
  inputSchema: {
229
220
  type: "object",
230
221
  properties: {
231
- prompt: {
232
- type: "string",
233
- description: "REQUIRED. Loose subsystem/module name to match against detected community labels.",
222
+ focus_files: {
223
+ type: "array",
224
+ items: { type: "string" },
225
+ description:
226
+ "Optional list of relative file paths to prioritize (e.g. files currently open or " +
227
+ "mentioned in the user's prompt) — ranked ahead of everything else.",
234
228
  },
235
- limit: {
229
+ max_tokens: {
236
230
  type: "number",
237
- description: "Optional maximum number of files to return (default 60).",
231
+ description: "Maximum token budget for the returned map (default 1024).",
232
+ },
233
+ directory_filter: {
234
+ type: "string",
235
+ description: "Optional relative subdirectory to scope the map to (e.g. 'src/backend').",
238
236
  },
239
237
  workspaceId: WORKSPACE_ID_PROPERTY,
240
238
  },
241
- required: ["prompt"],
239
+ required: [],
242
240
  },
243
241
  },
244
242
  ];