@codeconductorai/harmony-mcp 1.0.10 → 1.0.12
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 +59 -9
- package/package.json +2 -1
- package/src/fileFilters.js +73 -2
- package/src/harmonyClient.js +3 -3
- package/src/server.js +3 -3
- package/src/serverInstructions.js +19 -3
- package/src/toolSchemas.js +52 -5
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.11`) 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.11
|
|
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.11"]
|
|
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.11
|
|
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.11"]
|
|
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.11"]
|
|
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.11"]
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -108,7 +108,7 @@ After adding the server and restarting your client:
|
|
|
108
108
|
1. **`login`** — starts a device-flow login and returns a URL to open in your browser.
|
|
109
109
|
2. 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.
|
|
110
110
|
3. **`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. 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.
|
|
111
|
-
4. Use **`locate`**, **`search_code_context`**, **`find_files`**, or **`get_context_bundle`**
|
|
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`**, **`get_symbol_context`**, **`find_files`**, **`find_related_tests`**, 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. Use **`remember_task_state`** to persist facts/decisions/todos/warnings across a task.
|
|
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
|
|
|
@@ -129,8 +129,29 @@ Registers the current project as a workspace on the backend and fully indexes it
|
|
|
129
129
|
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.
|
|
130
130
|
|
|
131
131
|
### `get_context_bundle`
|
|
132
|
-
Retrieves a ranked XML context bundle of the most relevant code for a prompt
|
|
132
|
+
Retrieves a ranked XML context bundle of the most relevant code for a prompt, including deterministic
|
|
133
|
+
(non-LLM) `guidance` (requirement facets, edit/inspect/test targets, risk checks, suggested verification
|
|
134
|
+
commands), a locally-counted token `budget` (with truncation applied if the ranked results exceed it),
|
|
135
|
+
an `index_state` snapshot (indexed file/symbol/relation counts and last-indexed time), and any
|
|
136
|
+
`memories` recorded for the given `taskId`.
|
|
133
137
|
- `prompt` (required): natural-language question or instruction.
|
|
138
|
+
- `taskId` (optional): pass the same `taskId` used with `remember_task_state` to include those memories.
|
|
139
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
140
|
+
|
|
141
|
+
### `context_search`
|
|
142
|
+
PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked
|
|
143
|
+
search endpoint. Given a natural-language query or exact identifier, returns ranked matching symbols
|
|
144
|
+
with their code snippets, file paths, and relevance. Takes precedence over `locate`,
|
|
145
|
+
`search_code_context`, `find_files`, and `get_context_bundle`; only fall back to one of those if
|
|
146
|
+
`context_search`'s result is empty/insufficient or you specifically need one of their specialized
|
|
147
|
+
output shapes (e.g. `locate`'s line-number-only anchors for a targeted edit). Treat it as the
|
|
148
|
+
always-on default entry point for every new discovery/comprehension need that comes up during a
|
|
149
|
+
task — call it again each time, not just once. When a fallback tool is used afterward, its input
|
|
150
|
+
should combine the user's original query with the symbols/identifiers/file paths this call already
|
|
151
|
+
surfaced, rather than repeating the same raw query unchanged.
|
|
152
|
+
- `prompt` (required): natural-language query or exact identifier to find context for.
|
|
153
|
+
- `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
|
|
154
|
+
- `limit` (optional): max results; the backend applies its own default if omitted.
|
|
134
155
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
135
156
|
|
|
136
157
|
### `locate`
|
|
@@ -154,6 +175,35 @@ Given a natural-language query, returns lightweight file path and architectural
|
|
|
154
175
|
- `limit` (optional): max results (default 30).
|
|
155
176
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
156
177
|
|
|
178
|
+
### `get_symbol_context`
|
|
179
|
+
Like `search_code_context`, but each matched symbol's file is also enriched with one-hop import
|
|
180
|
+
relationships and probable test files, derived from the backend's file-relationship graph (import
|
|
181
|
+
edges, mirrored test-path naming, bounded git co-change). Prefer this over `search_code_context` when
|
|
182
|
+
you're about to edit and need to know what else touches the file.
|
|
183
|
+
- `prompt` (required): natural-language query or unique identifier to find context for.
|
|
184
|
+
- `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
|
|
185
|
+
- `limit` (optional): max results (default 10).
|
|
186
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
187
|
+
|
|
188
|
+
### `find_related_tests`
|
|
189
|
+
Given a file path, returns test files related to it via mirrored test-path naming (e.g.
|
|
190
|
+
`src/foo.py` ↔ `tests/test_foo.py`) or bounded git co-change history, falling back to a lexical
|
|
191
|
+
`primary_role: test` search when the workspace has no relationship-graph edges for it yet (e.g. right
|
|
192
|
+
after a fresh index). Unlike the other search tools, this takes `file_path`, not a natural-language `prompt`.
|
|
193
|
+
- `file_path` (required): the file (or a substring uniquely identifying it) to find related tests for.
|
|
194
|
+
- `limit` (optional): max results (default 10).
|
|
195
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
196
|
+
|
|
197
|
+
### `remember_task_state`
|
|
198
|
+
Records an explicit fact, decision, todo, or warning against a `taskId`, optionally with `evidence`
|
|
199
|
+
(`path:line` references). Recalled later via `get_context_bundle`'s `taskId` parameter — this does not
|
|
200
|
+
affect search/locate ranking directly, it's recall-on-demand within the same task.
|
|
201
|
+
- `taskId` (required): identifier grouping this memory with others from the same task/session.
|
|
202
|
+
- `content` (required): the memory itself, in plain language.
|
|
203
|
+
- `memoryType` (optional): one of `fact`, `decision`, `todo`, `warning` (default `fact`).
|
|
204
|
+
- `evidence` (optional): array of `path:line` references supporting this memory.
|
|
205
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
206
|
+
|
|
157
207
|
## Local development
|
|
158
208
|
|
|
159
209
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeconductorai/harmony-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"archiver": "^7.0.0",
|
|
34
34
|
"form-data": "^4.0.0",
|
|
35
35
|
"jose": "^6.2.3",
|
|
36
|
+
"minimatch": "^5.1.0",
|
|
36
37
|
"node-fetch": "^3.3.2"
|
|
37
38
|
}
|
|
38
39
|
}
|
package/src/fileFilters.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import fs from "fs";
|
|
1
2
|
import path from "path";
|
|
3
|
+
import minimatch from "minimatch";
|
|
2
4
|
import { WORKSPACE_MARKER } from "./workspaceMarker.js";
|
|
3
5
|
|
|
4
6
|
export const EXCLUDED_DIR_NAMES = [
|
|
@@ -14,6 +16,10 @@ export const EXCLUDED_DIR_NAMES = [
|
|
|
14
16
|
"vendor", "pkg", "cmake-build-debug", "cmake-build-release",
|
|
15
17
|
// .NET / C#
|
|
16
18
|
"obj",
|
|
19
|
+
// Secrets / credentials
|
|
20
|
+
".ssh", ".aws", ".gnupg",
|
|
21
|
+
// Seed / fixture / mock data dumps - not application source
|
|
22
|
+
"db_dump", "fixtures", "__fixtures__", "seed", "seeds", "mock-data", "sample-data", "testdata",
|
|
17
23
|
];
|
|
18
24
|
|
|
19
25
|
export const EXCLUDED_DIR_SUFFIXES = [".egg-info"];
|
|
@@ -31,8 +37,58 @@ export const EXCLUDED_EXACT_FILENAMES = [
|
|
|
31
37
|
".DS_Store", "Thumbs.db", "package-lock.json", "yarn.lock", "pnpm-lock.yaml",
|
|
32
38
|
];
|
|
33
39
|
|
|
40
|
+
// Secret-bearing filenames, as glob patterns ("*" only) matched against the basename.
|
|
41
|
+
export const EXCLUDED_FILENAME_GLOBS = [
|
|
42
|
+
".env", ".env.*", "*.pem", "*.key", "*.p12", "*.pfx", "*.keystore",
|
|
43
|
+
"id_rsa", "id_dsa", "id_ecdsa", "id_ed25519", ".npmrc", ".netrc",
|
|
44
|
+
"credentials.json", "*Credentials.json",
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
function escapeRegExpLiteral(text) {
|
|
48
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Matches a basename against a glob pattern that only uses "*" as a wildcard.
|
|
52
|
+
function matchesFilenameGlob(name, pattern) {
|
|
53
|
+
if (!pattern.includes("*")) return name === pattern;
|
|
54
|
+
const regex = new RegExp(`^${pattern.split("*").map(escapeRegExpLiteral).join(".*")}$`);
|
|
55
|
+
return regex.test(name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function gitignoreLineToGlobs(rawLine) {
|
|
59
|
+
let pattern = rawLine;
|
|
60
|
+
const dirOnly = pattern.endsWith("/");
|
|
61
|
+
if (dirOnly) pattern = pattern.slice(0, -1);
|
|
62
|
+
if (!pattern) return [];
|
|
63
|
+
|
|
64
|
+
const anchored = pattern.includes("/");
|
|
65
|
+
if (pattern.startsWith("/")) pattern = pattern.slice(1);
|
|
66
|
+
if (!pattern) return [];
|
|
67
|
+
|
|
68
|
+
return anchored
|
|
69
|
+
? [pattern, `${pattern}/**`]
|
|
70
|
+
: [pattern, `**/${pattern}`, `${pattern}/**`, `**/${pattern}/**`];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Reads .gitignore from the workspace root and expands its rules into glob patterns.
|
|
74
|
+
function loadGitignoreGlobs(workspaceRoot) {
|
|
75
|
+
let contents;
|
|
76
|
+
try {
|
|
77
|
+
contents = fs.readFileSync(path.join(workspaceRoot, ".gitignore"), "utf8");
|
|
78
|
+
} catch {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const globs = [];
|
|
82
|
+
for (const rawLine of contents.split(/\r?\n/)) {
|
|
83
|
+
const line = rawLine.trim();
|
|
84
|
+
if (!line || line.startsWith("#") || line.startsWith("!")) continue;
|
|
85
|
+
globs.push(...gitignoreLineToGlobs(line));
|
|
86
|
+
}
|
|
87
|
+
return globs;
|
|
88
|
+
}
|
|
89
|
+
|
|
34
90
|
// Build the glob ignore list for archiver.glob() from the shared exclusion data above.
|
|
35
|
-
export function buildZipIgnoreGlobs() {
|
|
91
|
+
export function buildZipIgnoreGlobs(workspaceRoot = process.cwd()) {
|
|
36
92
|
const globs = [WORKSPACE_MARKER];
|
|
37
93
|
for (const dir of EXCLUDED_DIR_NAMES) {
|
|
38
94
|
globs.push(`${dir}/**`, `**/${dir}/**`);
|
|
@@ -46,6 +102,10 @@ export function buildZipIgnoreGlobs() {
|
|
|
46
102
|
for (const name of EXCLUDED_EXACT_FILENAMES) {
|
|
47
103
|
globs.push(name, `**/${name}`);
|
|
48
104
|
}
|
|
105
|
+
for (const pattern of EXCLUDED_FILENAME_GLOBS) {
|
|
106
|
+
globs.push(pattern, `**/${pattern}`);
|
|
107
|
+
}
|
|
108
|
+
globs.push(...loadGitignoreGlobs(workspaceRoot));
|
|
49
109
|
return globs;
|
|
50
110
|
}
|
|
51
111
|
|
|
@@ -54,16 +114,27 @@ const WATCH_IGNORE_DIRS = new Set(EXCLUDED_DIR_NAMES);
|
|
|
54
114
|
const WATCH_IGNORE_EXTENSIONS = new Set(EXCLUDED_EXTENSIONS);
|
|
55
115
|
const WATCH_IGNORE_FILENAMES = new Set(EXCLUDED_EXACT_FILENAMES);
|
|
56
116
|
|
|
57
|
-
//
|
|
117
|
+
// .gitignore is read once per process
|
|
118
|
+
let cachedGitignoreGlobs = null;
|
|
119
|
+
function getGitignoreGlobs() {
|
|
120
|
+
if (cachedGitignoreGlobs === null) {
|
|
121
|
+
cachedGitignoreGlobs = loadGitignoreGlobs(process.cwd());
|
|
122
|
+
}
|
|
123
|
+
return cachedGitignoreGlobs;
|
|
124
|
+
}
|
|
125
|
+
|
|
58
126
|
export function shouldIgnore(filePath) {
|
|
59
127
|
const relative = path.relative(process.cwd(), filePath);
|
|
60
128
|
const parts = relative.split(path.sep);
|
|
61
129
|
const base = parts[parts.length - 1];
|
|
62
130
|
if (base === WORKSPACE_MARKER) return true;
|
|
63
131
|
if (WATCH_IGNORE_FILENAMES.has(base)) return true;
|
|
132
|
+
if (EXCLUDED_FILENAME_GLOBS.some((pattern) => matchesFilenameGlob(base, pattern))) return true;
|
|
64
133
|
if (parts.some((part) => WATCH_IGNORE_DIRS.has(part) || EXCLUDED_DIR_SUFFIXES.some((s) => part.endsWith(s)))) {
|
|
65
134
|
return true;
|
|
66
135
|
}
|
|
136
|
+
const posixRelative = parts.join("/");
|
|
137
|
+
if (getGitignoreGlobs().some((glob) => minimatch(posixRelative, glob, { dot: true }))) return true;
|
|
67
138
|
const dotIndex = base.lastIndexOf(".");
|
|
68
139
|
const ext = dotIndex > 0 ? base.slice(dotIndex + 1).toLowerCase() : "";
|
|
69
140
|
return WATCH_IGNORE_EXTENSIONS.has(ext);
|
package/src/harmonyClient.js
CHANGED
|
@@ -30,7 +30,7 @@ async function zipWorkspace() {
|
|
|
30
30
|
// the ones in EXCLUDED_DIR_NAMES) — dotfiles need to reach the ignore-list check, not be
|
|
31
31
|
// filtered out upstream of it.
|
|
32
32
|
dot: true,
|
|
33
|
-
ignore: buildZipIgnoreGlobs(),
|
|
33
|
+
ignore: buildZipIgnoreGlobs(workspacePath),
|
|
34
34
|
});
|
|
35
35
|
archive.finalize();
|
|
36
36
|
});
|
|
@@ -171,7 +171,7 @@ const TERMINAL_STATUSES = new Set([
|
|
|
171
171
|
|
|
172
172
|
async function fetchWorkspaceStatus(workspaceId) {
|
|
173
173
|
const token = await getAccessToken();
|
|
174
|
-
const url = new URL(`/api/code-workspace/${workspaceId}/
|
|
174
|
+
const url = new URL(`/api/code-workspace/${workspaceId}/status`, API_URL);
|
|
175
175
|
url.searchParams.set("productId", PRODUCT_ID);
|
|
176
176
|
url.searchParams.set("appId", APP_ID);
|
|
177
177
|
url.searchParams.set("repoId", REPO_ID);
|
|
@@ -181,7 +181,7 @@ async function fetchWorkspaceStatus(workspaceId) {
|
|
|
181
181
|
if (response.status === 404) return null;
|
|
182
182
|
const body = await response.text();
|
|
183
183
|
if (!response.ok) {
|
|
184
|
-
throw new Error(`Workspace
|
|
184
|
+
throw new Error(`Workspace status request failed: ${response.status} ${body}`);
|
|
185
185
|
}
|
|
186
186
|
const match = body.match(/<status>([^<]+)<\/status>/i);
|
|
187
187
|
return match ? match[1].trim() : null;
|
package/src/server.js
CHANGED
|
@@ -152,14 +152,14 @@ function describeIndexOutcome(indexStatus, workspaceId) {
|
|
|
152
152
|
return {
|
|
153
153
|
ready: true,
|
|
154
154
|
message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
|
|
155
|
-
`It's ready for locate, search_code_context, find_files, and get_context_bundle.`,
|
|
155
|
+
`It's ready for context_search, locate, search_code_context, find_files, and get_context_bundle.`,
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
if (DEGRADED_STATUSES.has(indexStatus)) {
|
|
159
159
|
return {
|
|
160
160
|
ready: false,
|
|
161
161
|
message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
|
|
162
|
-
`find_files and get_context_bundle should still work; locate/search_code_context may return no results.`,
|
|
162
|
+
`find_files and get_context_bundle should still work; locate/search_code_context/context_search may return no results.`,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
if (indexStatus === "CORRUPTED") {
|
|
@@ -270,7 +270,6 @@ async function handleGetContextBundle(args) {
|
|
|
270
270
|
return textContent(annotateIfFallbackBundle(body));
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
// locate, search_code_context, and find_files differ only in backend endpoint and tool name.
|
|
274
273
|
function makeSearchHandler(endpointPath, toolName) {
|
|
275
274
|
return async (args) => {
|
|
276
275
|
const workspaceId = resolveWorkspaceId(args);
|
|
@@ -284,6 +283,7 @@ const TOOL_HANDLERS = {
|
|
|
284
283
|
confirm_login: handleConfirmLogin,
|
|
285
284
|
setup_workspace: handleSetupWorkspace,
|
|
286
285
|
get_context_bundle: handleGetContextBundle,
|
|
286
|
+
context_search: makeSearchHandler("context-search", "context_search"),
|
|
287
287
|
locate: makeSearchHandler("locate-symbol", "locate"),
|
|
288
288
|
search_code_context: makeSearchHandler("search", "search_code_context"),
|
|
289
289
|
find_files: makeSearchHandler("find-files", "find_files"),
|
|
@@ -10,7 +10,14 @@ for the "first call in a session" — it applies every time a new discovery/comp
|
|
|
10
10
|
up during the task, not just once. Local tools are the fallback for when Harmony comes up short
|
|
11
11
|
(see Trust but verify below), never the default first move.
|
|
12
12
|
|
|
13
|
-
Routing —
|
|
13
|
+
Routing — \`context_search\` is the default first call for ANY discovery/comprehension need (finding
|
|
14
|
+
code, understanding how something works, discovering files/modules, gathering context). It is
|
|
15
|
+
Harmony's newest, best-ranked search endpoint and takes precedence over locate, search_code_context and
|
|
16
|
+
find_files — call it first, then only reach for one of those narrower tools if
|
|
17
|
+
context_search's result is empty/insufficient or you specifically need one of their specialized output
|
|
18
|
+
shapes (e.g. locate's line-number-only anchors for a targeted edit):
|
|
19
|
+
- \`context_search\` — try this FIRST. Ranked matching symbols with code snippets, file paths, and
|
|
20
|
+
relevance for a natural language query or exact identifier.
|
|
14
21
|
- \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns
|
|
15
22
|
every matching symbol occurrence (definitions and references) with exact line numbers,
|
|
16
23
|
optionally scoped to a file_path once you already know the file.
|
|
@@ -21,6 +28,15 @@ Routing — pick the narrowest Harmony tool for the job, call one, then decide w
|
|
|
21
28
|
- \`get_context_bundle\` — broader contextual understanding for a task or question, not a specific
|
|
22
29
|
edit location. Returns a fuller XML context bundle for a prompt.
|
|
23
30
|
|
|
31
|
+
High availability: \`context_search\` is the always-on default for every discovery/comprehension need
|
|
32
|
+
that comes up during a task — call it again each time a new one arises, not just once per session or
|
|
33
|
+
once per task. Composing fallback input: when context_search comes up short and you drop down to one
|
|
34
|
+
of the narrower tools above, never just resend the same raw user query — carry forward the specific
|
|
35
|
+
symbols, identifiers, and file paths context_search's response already surfaced, and combine THOSE
|
|
36
|
+
with the user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
|
|
37
|
+
applicable). The fallback call should read as "user's intent, sharpened by what context_search already
|
|
38
|
+
found," not a blind retry of the same input.
|
|
39
|
+
|
|
24
40
|
Trust but verify: Harmony's index can be stale, incomplete, or briefly out of date relative to the
|
|
25
41
|
working tree. If a result is empty, errors, looks stale (references code that no longer exists), or
|
|
26
42
|
is otherwise insufficient, don't retry the same call — fall back immediately to local tools (rg,
|
|
@@ -53,8 +69,8 @@ Workspace setup — before the first search/locate/context call in a project:
|
|
|
53
69
|
`.trim();
|
|
54
70
|
|
|
55
71
|
const AUTH_INSTRUCTIONS = `
|
|
56
|
-
Auth gate — setup_workspace, get_context_bundle, locate, search_code_context
|
|
57
|
-
|
|
72
|
+
Auth gate — setup_workspace, get_context_bundle, context_search, locate, search_code_context and find_files all return a "not
|
|
73
|
+
authenticated" error until login has succeeded. Do not attempt to work around this by
|
|
58
74
|
guessing tokens or skipping the tool; just run the login flow below.
|
|
59
75
|
- Call \`login\`, show the returned loginUrl to the user verbatim, and ask them to complete it in
|
|
60
76
|
their browser.
|
package/src/toolSchemas.js
CHANGED
|
@@ -67,9 +67,49 @@ export const TOOLS = [
|
|
|
67
67
|
required: [],
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
name: "context_search",
|
|
72
|
+
description:
|
|
73
|
+
"PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
|
|
74
|
+
"search endpoint. Given a natural language query or exact identifier, returns ranked matching symbols " +
|
|
75
|
+
"with their code snippets, file paths, and relevance. Try this BEFORE locate, search_code_context, " +
|
|
76
|
+
"find_files; only fall back to one of those narrower tools if context_search's " +
|
|
77
|
+
"result is empty, insufficient, or you specifically need one of their specialized output shapes " +
|
|
78
|
+
"(e.g. locate's line-number-only anchors for a targeted edit). Treat this as the always-on default " +
|
|
79
|
+
"entry point for every new discovery/comprehension need that comes up during a task — call it again " +
|
|
80
|
+
"each time one arises, not just once. Whenever you do fall back to one of the narrower tools, don't " +
|
|
81
|
+
"discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
|
|
82
|
+
"and combine them with the user's original query to build that tool's input, rather than re-issuing " +
|
|
83
|
+
"the raw query alone.",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
prompt: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description:
|
|
90
|
+
"REQUIRED. Natural language query or exact identifier (symbol name, class name, endpoint " +
|
|
91
|
+
"route, API path) describing what to find context for.",
|
|
92
|
+
},
|
|
93
|
+
file_path: {
|
|
94
|
+
type: "string",
|
|
95
|
+
description: "Optional path substring to restrict results to a subdirectory, module, or specific file.",
|
|
96
|
+
},
|
|
97
|
+
limit: {
|
|
98
|
+
type: "number",
|
|
99
|
+
description: "Optional maximum number of results to return; the backend applies its own default if omitted.",
|
|
100
|
+
},
|
|
101
|
+
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
102
|
+
},
|
|
103
|
+
required: ["prompt"],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
70
106
|
{
|
|
71
107
|
name: "get_context_bundle",
|
|
72
|
-
description:
|
|
108
|
+
description:
|
|
109
|
+
"Retrieve a coding context bundle for a prompt from the backend. Returns XML context. If reached " +
|
|
110
|
+
"as a fallback after context_search came up short, build this prompt from the user's original " +
|
|
111
|
+
"query plus the symbols/identifiers/file paths context_search's response already surfaced, rather " +
|
|
112
|
+
"than resending the raw query unchanged.",
|
|
73
113
|
inputSchema: {
|
|
74
114
|
type: "object",
|
|
75
115
|
properties: {
|
|
@@ -91,7 +131,10 @@ export const TOOLS = [
|
|
|
91
131
|
"edit for a task, e.g. every occurrence of a name across the codebase, or (scoped with file_path) " +
|
|
92
132
|
"exact line numbers within a file you already know. It does not return full file content — Read() the " +
|
|
93
133
|
"file once you have the line numbers if you need surrounding context beyond what the anchor tells you. " +
|
|
94
|
-
"A missing/blank prompt returns an empty result list rather than an error or 'match everything'."
|
|
134
|
+
"A missing/blank prompt returns an empty result list rather than an error or 'match everything'. If " +
|
|
135
|
+
"reached as a fallback after context_search came up short, build this prompt from the user's original " +
|
|
136
|
+
"query plus the specific symbol/identifier names context_search's response already surfaced, rather " +
|
|
137
|
+
"than repeating the raw query verbatim.",
|
|
95
138
|
inputSchema: {
|
|
96
139
|
type: "object",
|
|
97
140
|
properties: {
|
|
@@ -128,7 +171,9 @@ export const TOOLS = [
|
|
|
128
171
|
description:
|
|
129
172
|
"Given a natural language query, returns rich Q&A context: matching symbols along with their code " +
|
|
130
173
|
"snippets, documentation, and decorators. Use this when you need to understand or explain how " +
|
|
131
|
-
"something works, not when you're about to make a targeted edit (use locate for that)."
|
|
174
|
+
"something works, not when you're about to make a targeted edit (use locate for that). If reached " +
|
|
175
|
+
"as a fallback after context_search came up short, fold the symbols/identifiers/file paths from " +
|
|
176
|
+
"context_search's response together with the user's original query into this prompt.",
|
|
132
177
|
inputSchema: {
|
|
133
178
|
type: "object",
|
|
134
179
|
properties: {
|
|
@@ -154,7 +199,9 @@ export const TOOLS = [
|
|
|
154
199
|
description:
|
|
155
200
|
"Given a natural language query, returns lightweight file path and architectural role/tag matches — " +
|
|
156
201
|
"no symbols or code content. Use this for broad file/module discovery (e.g. \"find all the " +
|
|
157
|
-
"controllers\") rather than pinpointing a specific edit location."
|
|
202
|
+
"controllers\") rather than pinpointing a specific edit location. If reached as a fallback after " +
|
|
203
|
+
"context_search came up short, incorporate any relevant file paths/modules context_search already " +
|
|
204
|
+
"surfaced along with the user's original query when composing this prompt.",
|
|
158
205
|
inputSchema: {
|
|
159
206
|
type: "object",
|
|
160
207
|
properties: {
|
|
@@ -174,5 +221,5 @@ export const TOOLS = [
|
|
|
174
221
|
},
|
|
175
222
|
required: ["prompt"],
|
|
176
223
|
},
|
|
177
|
-
}
|
|
224
|
+
}
|
|
178
225
|
];
|