tryharness 0.7.45 → 0.7.54
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 +239 -14
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +497 -196
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +165 -222
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +570 -0
- package/lib/agentSignIn.mjs +226 -0
- package/lib/atlas.mjs +7 -2
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +523 -0
- package/lib/boardProtocol.json +263 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +26 -4
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +159 -16
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +25 -5
- package/lib/connectionTools.d.ts +13 -0
- package/lib/connectionTools.js +45 -0
- package/lib/connectorAuth.mjs +309 -0
- package/lib/connectorCatalog.json +41 -0
- package/lib/connectorCommands.mjs +121 -0
- package/lib/connectorGoogle.mjs +513 -0
- package/lib/connectors.mjs +805 -0
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +152 -39
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +973 -54
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +113 -8
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +825 -0
- package/lib/folders.mjs +4 -4
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +58 -14
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +263 -152
- package/lib/landed.mjs +887 -0
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- package/lib/live.mjs +284 -13
- package/lib/localmodels.mjs +10 -0
- package/lib/machineIdentity.mjs +3 -0
- package/lib/machineRoutes.mjs +40 -2
- package/lib/machineRuns.mjs +30 -3
- package/lib/machineSeal.mjs +69 -10
- package/lib/mcp-stdio.mjs +189 -120
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +26 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/models.mjs +48 -15
- package/lib/museSession.mjs +122 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +7 -2
- package/lib/nudge.mjs +57 -18
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +828 -39
- package/lib/pairing.mjs +182 -0
- package/lib/paths.mjs +8 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +119 -3
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +337 -9
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projects.mjs +624 -137
- package/lib/readiness.mjs +400 -0
- package/lib/record.mjs +115 -0
- package/lib/repoLinks.mjs +354 -0
- package/lib/roomChannels.mjs +641 -0
- package/lib/runBrief.mjs +32 -2
- package/lib/runRequests.mjs +157 -0
- package/lib/runWorker.mjs +37 -9
- package/lib/runner.mjs +74 -11
- package/lib/secretPatterns.json +55 -0
- package/lib/secrets.mjs +10 -27
- package/lib/seen.mjs +102 -0
- package/lib/service.mjs +11 -6
- package/lib/sessionControl.mjs +386 -96
- package/lib/sessionIndex.mjs +5 -3
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +829 -29
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +483 -37
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +56 -17
- package/lib/taskCommands.mjs +91 -13
- package/lib/taskRuns.mjs +68 -11
- package/lib/team.json +253 -144
- package/lib/team.mjs +538 -147
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +78 -12
- package/lib/threadView.mjs +66 -16
- package/lib/tokenizer.mjs +405 -0
- package/lib/ui.mjs +16 -2
- package/lib/usageTotals.mjs +148 -0
- package/lib/vault.mjs +1144 -0
- package/lib/vaultCloud.mjs +117 -0
- package/lib/vaultCommands.mjs +201 -0
- package/lib/vaultTools.d.ts +12 -0
- package/lib/vaultTools.js +42 -0
- package/lib/windowAsks.mjs +42 -0
- package/lib/workFocus.mjs +59 -0
- package/lib/workLinks.mjs +90 -0
- package/lib/worktrees.mjs +51 -13
- package/package.json +10 -5
package/lib/actorRoster.mjs
CHANGED
|
@@ -9,6 +9,10 @@ export function createActorRoster({
|
|
|
9
9
|
authority,
|
|
10
10
|
localWaker,
|
|
11
11
|
connected,
|
|
12
|
+
// Whether the person put this agent in their swarm (lineup.mjs); an agent they did not is never offered.
|
|
13
|
+
inLineup = () => true,
|
|
14
|
+
// A coding agent's last check (readiness.mjs): whether it took a prompt, so every surface shows it ready or not.
|
|
15
|
+
readinessOf = () => null,
|
|
12
16
|
// The person's computers that have this agent, this one included: [{ label, online, here }] (ownMachines.mjs).
|
|
13
17
|
computersWith = () => [],
|
|
14
18
|
}) {
|
|
@@ -53,19 +57,23 @@ export function createActorRoster({
|
|
|
53
57
|
return `${nameOf(agent)} is not answering right now, so this waits until it does.`;
|
|
54
58
|
return null;
|
|
55
59
|
};
|
|
56
|
-
/** The agents this person can ask right now: coding agents installed here, the server's while connected, any agent that has used the board, and those Harness says can be set up. */
|
|
60
|
+
/** The agents this person can ask right now, of those in their swarm: coding agents installed here, the server's while connected, any agent that has used the board, and those Harness says can be set up. */
|
|
57
61
|
const available = () => {
|
|
58
62
|
const seen = new Set(store.agentsSeen().map((row) => row.agent));
|
|
59
63
|
const woken = localWakes();
|
|
60
64
|
return ROOM_AGENTS.filter(
|
|
61
65
|
(agent) =>
|
|
62
66
|
agent === "harness" ||
|
|
67
|
+
// A coding agent is in the lineup of the computer it runs on, which runs it only then (installedAgents).
|
|
63
68
|
(RUNNERS.has(agent)
|
|
64
69
|
? installedAgents.includes(agent) ||
|
|
65
70
|
computersWith(agent).some((computer) => !computer.here)
|
|
66
|
-
:
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
: inLineup(agent) &&
|
|
72
|
+
(CLOUD_AGENTS.has(agent)
|
|
73
|
+
? connected()
|
|
74
|
+
: seen.has(agent) ||
|
|
75
|
+
Boolean(woken[agent]) ||
|
|
76
|
+
cloudSetup.has(agent)))
|
|
69
77
|
);
|
|
70
78
|
};
|
|
71
79
|
// Each agent's card (cards.mjs) as every other agent is told it, its setup included; `lessons`: what the person said
|
|
@@ -80,12 +88,27 @@ export function createActorRoster({
|
|
|
80
88
|
}
|
|
81
89
|
: card;
|
|
82
90
|
};
|
|
91
|
+
const withReadiness = (card) => {
|
|
92
|
+
const check = RUNNERS.has(card.id) ? readinessOf(card.id) : null;
|
|
93
|
+
return check
|
|
94
|
+
? {
|
|
95
|
+
...card,
|
|
96
|
+
readiness: {
|
|
97
|
+
state: check.state,
|
|
98
|
+
detail: check.detail,
|
|
99
|
+
checkedAt: check.checkedAt,
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
: card;
|
|
103
|
+
};
|
|
83
104
|
const cardsFor = (ids, { lessons = true } = {}) =>
|
|
84
105
|
swarmCards(
|
|
85
106
|
store,
|
|
86
107
|
ids.map((id) => ({ id, setup: setupOf(id) })),
|
|
87
108
|
{ lessons }
|
|
88
|
-
)
|
|
109
|
+
)
|
|
110
|
+
.map(withMachines)
|
|
111
|
+
.map(withReadiness);
|
|
89
112
|
// The person's words from other threads (lessons.mjs) stay with the agents on this computer and Harness.
|
|
90
113
|
const readsLessonsHere = (agent) => RUNNERS.has(agent) || agent === "harness";
|
|
91
114
|
|
package/lib/adapters.mjs
CHANGED
|
@@ -4,6 +4,12 @@ import path from "node:path";
|
|
|
4
4
|
import { detectAgents, run } from "./commands.mjs";
|
|
5
5
|
import { ensureDir, readJson } from "./files.mjs";
|
|
6
6
|
import { MACHINE_RUNNERS } from "./members.mjs";
|
|
7
|
+
import {
|
|
8
|
+
HOOK_AGENTS,
|
|
9
|
+
installSessionHooks,
|
|
10
|
+
removeSessionHooks,
|
|
11
|
+
sessionHooksPath,
|
|
12
|
+
} from "./hookDialects.mjs";
|
|
7
13
|
|
|
8
14
|
export const AGENTS = MACHINE_RUNNERS;
|
|
9
15
|
|
|
@@ -93,13 +99,14 @@ export function mcpClientSnippet({
|
|
|
93
99
|
function installAsset(
|
|
94
100
|
source,
|
|
95
101
|
target,
|
|
96
|
-
{ runtimeRoot, nodePath = process.execPath }
|
|
102
|
+
{ runtimeRoot, nodePath = process.execPath, agent = "" }
|
|
97
103
|
) {
|
|
98
104
|
ensureDir(path.dirname(target));
|
|
99
105
|
const text = fs
|
|
100
106
|
.readFileSync(source, "utf8")
|
|
101
107
|
.replaceAll('"__HARNESS_RUNTIME__"', JSON.stringify(runtimeRoot))
|
|
102
|
-
.replaceAll('"__HARNESS_NODE__"', JSON.stringify(nodePath))
|
|
108
|
+
.replaceAll('"__HARNESS_NODE__"', JSON.stringify(nodePath))
|
|
109
|
+
.replaceAll('"__HARNESS_AGENT__"', JSON.stringify(agent));
|
|
103
110
|
fs.writeFileSync(target, text, { mode: 0o600 });
|
|
104
111
|
try {
|
|
105
112
|
fs.chmodSync(target, 0o600);
|
|
@@ -123,188 +130,136 @@ export function integrationAssets(homeDir = os.homedir()) {
|
|
|
123
130
|
"plugins",
|
|
124
131
|
"tryharness.js"
|
|
125
132
|
),
|
|
133
|
+
// Kilo, OpenCode's fork, reads plugins from its own folder only.
|
|
134
|
+
kilo: path.join(homeDir, ".config", "kilo", "plugins", "tryharness.js"),
|
|
135
|
+
// DeepSeek Harness loads a plugin named beside the patch file that names it.
|
|
136
|
+
dsh: path.join(dshHome(homeDir), "tryharness-dsh.mjs"),
|
|
126
137
|
};
|
|
127
138
|
}
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
// its context. The hook is one entry in the user's settings, added once and removed on
|
|
131
|
-
// disconnect; every other setting and hook is left as it was.
|
|
132
|
-
export function claudeSettingsPath(homeDir = os.homedir()) {
|
|
133
|
-
return path.join(homeDir, ".claude", "settings.json");
|
|
134
|
-
}
|
|
135
|
-
const isHarnessHook = (entry) =>
|
|
136
|
-
JSON.stringify(entry).includes("/lib/nudge.mjs");
|
|
140
|
+
const dshHome = (homeDir) => process.env.DSH_HOME || path.join(homeDir, ".dsh");
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
starts.push({
|
|
152
|
-
hooks: [
|
|
153
|
-
{
|
|
154
|
-
type: "command",
|
|
155
|
-
command: `${JSON.stringify(nodePath)} ${nudge} --agent claude-code`,
|
|
156
|
-
timeout: 10,
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
});
|
|
160
|
-
// Mid-session: on every prompt, one line only when the queue changed since the session last saw it.
|
|
161
|
-
const prompts = (
|
|
162
|
-
Array.isArray(hooks.UserPromptSubmit) ? hooks.UserPromptSubmit : []
|
|
163
|
-
).filter((entry) => !isHarnessHook(entry));
|
|
164
|
-
prompts.push({
|
|
165
|
-
hooks: [
|
|
166
|
-
{
|
|
167
|
-
type: "command",
|
|
168
|
-
command: `${JSON.stringify(nodePath)} ${nudge} --agent claude-code --if-changed`,
|
|
169
|
-
timeout: 10,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
});
|
|
173
|
-
// When a turn ends: a message the person sent this session from Harness keeps it going.
|
|
174
|
-
const stops = (Array.isArray(hooks.Stop) ? hooks.Stop : []).filter(
|
|
175
|
-
(entry) => !isHarnessHook(entry)
|
|
142
|
+
// DeepSeek Harness has no command that adds an MCP server or a plugin: both are rows in its home-level patch file
|
|
143
|
+
// (~/.dsh/cordis.patch.yml, a YAML list that applies to every profile and that people edit). Harness's rows are one
|
|
144
|
+
// marked block at its end, replaced by setup and taken out by uninstall; the rest of the file is kept as it is.
|
|
145
|
+
const DSH_BEGIN =
|
|
146
|
+
"# tryharness: begin (Harness's board; written and removed by npx tryharness)";
|
|
147
|
+
const DSH_END = "# tryharness: end";
|
|
148
|
+
function withoutDshBlock(text) {
|
|
149
|
+
const start = text.indexOf(DSH_BEGIN);
|
|
150
|
+
const end = text.indexOf(DSH_END);
|
|
151
|
+
if (start < 0 || end < start) return text;
|
|
152
|
+
return (text.slice(0, start) + text.slice(end + DSH_END.length)).replace(
|
|
153
|
+
/\n{3,}/g,
|
|
154
|
+
"\n\n"
|
|
176
155
|
);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
156
|
+
}
|
|
157
|
+
function writeDshRows(homeDir, { mcpPath } = {}) {
|
|
158
|
+
const file = path.join(dshHome(homeDir), "cordis.patch.yml");
|
|
159
|
+
let text = "";
|
|
160
|
+
try {
|
|
161
|
+
text = fs.readFileSync(file, "utf8");
|
|
162
|
+
} catch {}
|
|
163
|
+
const kept = withoutDshBlock(text).trimEnd();
|
|
164
|
+
const block = mcpPath
|
|
165
|
+
? [
|
|
166
|
+
DSH_BEGIN,
|
|
167
|
+
"- insert:",
|
|
168
|
+
" - id: harness",
|
|
169
|
+
" name: '@deepseek-ai/dsh-mcp-client'",
|
|
170
|
+
" config:",
|
|
171
|
+
" serverName: harness",
|
|
172
|
+
" transport: stdio",
|
|
173
|
+
` command: ${JSON.stringify(process.execPath)}`,
|
|
174
|
+
` args: ${JSON.stringify([mcpPath, "--agent", "dsh"])}`,
|
|
175
|
+
" env: {}",
|
|
176
|
+
" - id: tryharness",
|
|
177
|
+
" name: ./tryharness-dsh.mjs",
|
|
178
|
+
DSH_END,
|
|
179
|
+
].join("\n")
|
|
180
|
+
: "";
|
|
181
|
+
const next = [kept, block].filter(Boolean).join("\n\n");
|
|
182
|
+
if (!next && !text) return;
|
|
186
183
|
ensureDir(path.dirname(file));
|
|
187
|
-
fs.writeFileSync(
|
|
188
|
-
file,
|
|
189
|
-
JSON.stringify(
|
|
190
|
-
{
|
|
191
|
-
...settings,
|
|
192
|
-
hooks: {
|
|
193
|
-
...hooks,
|
|
194
|
-
SessionStart: starts,
|
|
195
|
-
UserPromptSubmit: prompts,
|
|
196
|
-
Stop: stops,
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
null,
|
|
200
|
-
2
|
|
201
|
-
) + "\n"
|
|
202
|
-
);
|
|
184
|
+
fs.writeFileSync(file, next ? next + "\n" : "");
|
|
203
185
|
}
|
|
204
186
|
|
|
205
|
-
|
|
206
|
-
// stdout added as developer context). Codex asks the person to trust a new or changed hook once,
|
|
207
|
-
// with /hooks in its TUI, before it runs; setup says so.
|
|
208
|
-
export function codexHooksPath(homeDir = os.homedir()) {
|
|
209
|
-
return path.join(homeDir, ".codex", "hooks.json");
|
|
210
|
-
}
|
|
187
|
+
export { installSessionHooks, removeSessionHooks, sessionHooksPath };
|
|
211
188
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
});
|
|
189
|
+
// How Harness's MCP server goes into each hook agent's own config (its session hooks: hookDialects.mjs). By the
|
|
190
|
+
// agent's own command (`remove` first, so setup replaces an older entry), or, where it has no command for it, in its
|
|
191
|
+
// config file. Setup's line about it, when there is more to say than that it is configured.
|
|
192
|
+
const MCP_SETUP = {
|
|
193
|
+
// Other agents start the servers in Claude Code's config too (nudge.mjs startedByAnother).
|
|
194
|
+
"claude-code": {
|
|
195
|
+
remove: ["mcp", "remove", "--scope", "user", "harness"],
|
|
196
|
+
add: ["mcp", "add", "--scope", "user", "harness"],
|
|
197
|
+
flags: ["--check-host"],
|
|
198
|
+
},
|
|
199
|
+
codex: {
|
|
200
|
+
remove: ["mcp", "remove", "harness"],
|
|
201
|
+
add: ["mcp", "add", "harness"],
|
|
202
|
+
note: "in Codex run /hooks once to trust them",
|
|
203
|
+
},
|
|
204
|
+
"grok-build": {
|
|
205
|
+
remove: ["mcp", "remove", "--scope", "user", "harness"],
|
|
206
|
+
add: ["mcp", "add", "--scope", "user", "harness"],
|
|
207
|
+
},
|
|
208
|
+
copilot: {
|
|
209
|
+
remove: ["mcp", "remove", "harness"],
|
|
210
|
+
add: ["mcp", "add", "harness"],
|
|
211
|
+
},
|
|
212
|
+
devin: {
|
|
213
|
+
remove: ["mcp", "remove", "harness", "--scope", "user"],
|
|
214
|
+
add: ["mcp", "add", "--scope", "user", "harness"],
|
|
215
|
+
},
|
|
216
|
+
// Cursor's CLI documents no command to add one, and asks before a new server runs: `mcp enable` approves it. Grok
|
|
217
|
+
// Build starts the servers in Cursor's file too (nudge.mjs startedByAnother).
|
|
218
|
+
cursor: {
|
|
219
|
+
file: (home) => path.join(home, ".cursor", "mcp.json"),
|
|
220
|
+
entry: { type: "stdio" },
|
|
221
|
+
flags: ["--check-host"],
|
|
222
|
+
enable: ["mcp", "enable", "harness"],
|
|
223
|
+
},
|
|
224
|
+
antigravity: {
|
|
225
|
+
file: (home) => path.join(home, ".gemini", "config", "mcp_config.json"),
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
function writeMcpEntry(file, entry) {
|
|
230
|
+
const config = readJson(file, {});
|
|
231
|
+
const servers = { ...(config.mcpServers ?? {}) };
|
|
232
|
+
if (entry) servers.harness = entry;
|
|
233
|
+
else if (!servers.harness) return;
|
|
234
|
+
else delete servers.harness;
|
|
261
235
|
ensureDir(path.dirname(file));
|
|
262
236
|
fs.writeFileSync(
|
|
263
237
|
file,
|
|
264
|
-
JSON.stringify(
|
|
265
|
-
{
|
|
266
|
-
...settings,
|
|
267
|
-
hooks: {
|
|
268
|
-
...hooks,
|
|
269
|
-
SessionStart: starts,
|
|
270
|
-
UserPromptSubmit: prompts,
|
|
271
|
-
Stop: stops,
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
null,
|
|
275
|
-
2
|
|
276
|
-
) + "\n"
|
|
238
|
+
JSON.stringify({ ...config, mcpServers: servers }, null, 2) + "\n"
|
|
277
239
|
);
|
|
278
240
|
}
|
|
279
241
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
242
|
+
/** Harness's MCP server in a hook agent's own config: the command's result, or the file written. */
|
|
243
|
+
function addMcpServer(agent, executable, { mcpPath, homeDir, execute }) {
|
|
244
|
+
const setup = MCP_SETUP[agent];
|
|
245
|
+
const server = [mcpPath, "--agent", agent, ...(setup.flags ?? [])];
|
|
246
|
+
if (setup.file) {
|
|
247
|
+
writeMcpEntry(setup.file(homeDir), {
|
|
248
|
+
...setup.entry,
|
|
249
|
+
command: process.execPath,
|
|
250
|
+
args: server,
|
|
251
|
+
});
|
|
252
|
+
if (setup.enable) execute(executable, setup.enable);
|
|
253
|
+
return { ok: true };
|
|
288
254
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
JSON.stringify({ ...settings, hooks }, null, 2) + "\n"
|
|
292
|
-
);
|
|
255
|
+
execute(executable, setup.remove);
|
|
256
|
+
return execute(executable, [...setup.add, "--", process.execPath, ...server]);
|
|
293
257
|
}
|
|
294
258
|
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const hooks = { ...settings.hooks };
|
|
300
|
-
for (const event of ["SessionStart", "UserPromptSubmit", "Stop"]) {
|
|
301
|
-
if (Array.isArray(hooks[event]))
|
|
302
|
-
hooks[event] = hooks[event].filter((entry) => !isHarnessHook(entry));
|
|
303
|
-
}
|
|
304
|
-
fs.writeFileSync(
|
|
305
|
-
file,
|
|
306
|
-
JSON.stringify({ ...settings, hooks }, null, 2) + "\n"
|
|
307
|
-
);
|
|
259
|
+
function removeMcpServer(agent, executable, { homeDir, execute }) {
|
|
260
|
+
const setup = MCP_SETUP[agent];
|
|
261
|
+
if (setup.file) writeMcpEntry(setup.file(homeDir), null);
|
|
262
|
+
else execute(executable, setup.remove);
|
|
308
263
|
}
|
|
309
264
|
|
|
310
265
|
export function configureAgents({
|
|
@@ -338,61 +293,26 @@ export function configureAgents({
|
|
|
338
293
|
});
|
|
339
294
|
continue;
|
|
340
295
|
}
|
|
341
|
-
if (agent
|
|
342
|
-
|
|
343
|
-
const added = execute(found.path, [
|
|
344
|
-
"mcp",
|
|
345
|
-
"add",
|
|
346
|
-
"--scope",
|
|
347
|
-
"user",
|
|
348
|
-
"harness",
|
|
349
|
-
"--",
|
|
350
|
-
process.execPath,
|
|
296
|
+
if (HOOK_AGENTS.includes(agent)) {
|
|
297
|
+
const added = addMcpServer(agent, found.path, {
|
|
351
298
|
mcpPath,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
]);
|
|
355
|
-
let hooked = true;
|
|
356
|
-
try {
|
|
357
|
-
installClaudeSessionHook({ runtimeRoot, homeDir });
|
|
358
|
-
} catch {
|
|
359
|
-
hooked = false;
|
|
360
|
-
}
|
|
361
|
-
states.push({
|
|
362
|
-
agent,
|
|
363
|
-
installed: true,
|
|
364
|
-
configured: added.ok,
|
|
365
|
-
detail: added.ok
|
|
366
|
-
? hooked
|
|
367
|
-
? "MCP and session-start nudge configured"
|
|
368
|
-
: "MCP configured; the session-start hook could not be written"
|
|
369
|
-
: diagnostic(added),
|
|
299
|
+
homeDir,
|
|
300
|
+
execute,
|
|
370
301
|
});
|
|
371
|
-
} else if (agent === "codex") {
|
|
372
|
-
execute(found.path, ["mcp", "remove", "harness"]);
|
|
373
|
-
const added = execute(found.path, [
|
|
374
|
-
"mcp",
|
|
375
|
-
"add",
|
|
376
|
-
"harness",
|
|
377
|
-
"--",
|
|
378
|
-
process.execPath,
|
|
379
|
-
mcpPath,
|
|
380
|
-
"--agent",
|
|
381
|
-
agent,
|
|
382
|
-
]);
|
|
383
302
|
let hooked = true;
|
|
384
303
|
try {
|
|
385
|
-
|
|
304
|
+
installSessionHooks(agent, { runtimeRoot, homeDir });
|
|
386
305
|
} catch {
|
|
387
306
|
hooked = false;
|
|
388
307
|
}
|
|
308
|
+
const note = MCP_SETUP[agent].note;
|
|
389
309
|
states.push({
|
|
390
310
|
agent,
|
|
391
311
|
installed: true,
|
|
392
312
|
configured: added.ok,
|
|
393
313
|
detail: added.ok
|
|
394
314
|
? hooked
|
|
395
|
-
?
|
|
315
|
+
? `MCP and session hooks configured${note ? `; ${note}` : ""}`
|
|
396
316
|
: "MCP configured; the session hooks could not be written"
|
|
397
317
|
: diagnostic(added),
|
|
398
318
|
});
|
|
@@ -409,11 +329,11 @@ export function configureAgents({
|
|
|
409
329
|
configured: fs.existsSync(assets.pi),
|
|
410
330
|
detail: "extension installed",
|
|
411
331
|
});
|
|
412
|
-
} else {
|
|
332
|
+
} else if (agent === "opencode" || agent === "kilo") {
|
|
413
333
|
installAsset(
|
|
414
334
|
path.join(runtimeRoot, "assets", "opencode-plugin.js"),
|
|
415
|
-
assets
|
|
416
|
-
{ runtimeRoot }
|
|
335
|
+
assets[agent],
|
|
336
|
+
{ runtimeRoot, agent }
|
|
417
337
|
);
|
|
418
338
|
// The same stdio server as Claude Code and Codex. opencode has no `mcp remove`; `mcp add` replaces the entry.
|
|
419
339
|
const added = execute(found.path, [
|
|
@@ -434,6 +354,27 @@ export function configureAgents({
|
|
|
434
354
|
? "MCP and plugin configured"
|
|
435
355
|
: `plugin installed; MCP: ${diagnostic(added)}`,
|
|
436
356
|
});
|
|
357
|
+
} else if (agent === "dsh") {
|
|
358
|
+
installAsset(
|
|
359
|
+
path.join(runtimeRoot, "assets", "dsh-plugin.mjs"),
|
|
360
|
+
assets.dsh,
|
|
361
|
+
{ runtimeRoot }
|
|
362
|
+
);
|
|
363
|
+
writeDshRows(homeDir, { mcpPath });
|
|
364
|
+
states.push({
|
|
365
|
+
agent,
|
|
366
|
+
installed: true,
|
|
367
|
+
configured: true,
|
|
368
|
+
detail: "MCP and plugin configured",
|
|
369
|
+
});
|
|
370
|
+
} else {
|
|
371
|
+
states.push({
|
|
372
|
+
agent,
|
|
373
|
+
installed: true,
|
|
374
|
+
configured: true,
|
|
375
|
+
detail:
|
|
376
|
+
"Uses its installed protocol for each Harness run; native login and permissions still apply.",
|
|
377
|
+
});
|
|
437
378
|
}
|
|
438
379
|
}
|
|
439
380
|
return states;
|
|
@@ -449,23 +390,25 @@ export function removeAgentConfigurations({
|
|
|
449
390
|
execute = run,
|
|
450
391
|
} = {}) {
|
|
451
392
|
for (const found of detected) {
|
|
452
|
-
if (!found.path) continue;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
removeClaudeSessionHook(homeDir);
|
|
456
|
-
} else if (found.agent === "codex") {
|
|
457
|
-
execute(found.path, ["mcp", "remove", "harness"]);
|
|
458
|
-
removeCodexHooks(homeDir);
|
|
459
|
-
}
|
|
393
|
+
if (!found.path || !HOOK_AGENTS.includes(found.agent)) continue;
|
|
394
|
+
removeMcpServer(found.agent, found.path, { homeDir, execute });
|
|
395
|
+
removeSessionHooks(found.agent, homeDir);
|
|
460
396
|
}
|
|
461
|
-
// opencode
|
|
462
|
-
for (const
|
|
463
|
-
|
|
397
|
+
// opencode and Kilo have no `mcp remove`, so the entry comes out of the config file `mcp add` wrote it to.
|
|
398
|
+
for (const file of [
|
|
399
|
+
...["opencode.json", "opencode.jsonc"].map((name) =>
|
|
400
|
+
path.join(homeDir, ".config", "opencode", name)
|
|
401
|
+
),
|
|
402
|
+
...["kilo.json", "kilo.jsonc", "opencode.json", "opencode.jsonc"].map(
|
|
403
|
+
(name) => path.join(homeDir, ".config", "kilo", name)
|
|
404
|
+
),
|
|
405
|
+
]) {
|
|
464
406
|
const config = readJson(file, null);
|
|
465
407
|
if (!config?.mcp?.harness) continue;
|
|
466
408
|
delete config.mcp.harness;
|
|
467
409
|
fs.writeFileSync(file, JSON.stringify(config, null, 2) + "\n");
|
|
468
410
|
}
|
|
411
|
+
writeDshRows(homeDir);
|
|
469
412
|
const assets = integrationAssets(homeDir);
|
|
470
413
|
for (const target of Object.values(assets)) {
|
|
471
414
|
try {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { member } from "./members.mjs";
|
|
3
|
+
import { paths } from "./paths.mjs";
|
|
4
|
+
|
|
5
|
+
/** Installed agents only: the owner's executable selection never comes from a model or task. */
|
|
6
|
+
export function runtimeOf(agent) {
|
|
7
|
+
const runtime = member(agent)?.runtime;
|
|
8
|
+
if (!runtime) return null;
|
|
9
|
+
let configured;
|
|
10
|
+
try {
|
|
11
|
+
configured = JSON.parse(readFileSync(paths.config, "utf8")).agentCommands?.[
|
|
12
|
+
agent
|
|
13
|
+
];
|
|
14
|
+
} catch {}
|
|
15
|
+
const defaultCommand =
|
|
16
|
+
agent === "antigravity" && process.platform === "win32"
|
|
17
|
+
? "agy_acp_server.exe"
|
|
18
|
+
: runtime.command;
|
|
19
|
+
const command =
|
|
20
|
+
typeof configured?.command === "string" && configured.command.trim()
|
|
21
|
+
? configured.command
|
|
22
|
+
: defaultCommand;
|
|
23
|
+
const args =
|
|
24
|
+
Array.isArray(configured?.args) &&
|
|
25
|
+
configured.args.every((arg) => typeof arg === "string")
|
|
26
|
+
? configured.args
|
|
27
|
+
: runtime.args;
|
|
28
|
+
return {
|
|
29
|
+
...runtime,
|
|
30
|
+
command,
|
|
31
|
+
args,
|
|
32
|
+
...(typeof configured?.approvalMode === "string"
|
|
33
|
+
? { approvalMode: configured.approvalMode }
|
|
34
|
+
: {}),
|
|
35
|
+
};
|
|
36
|
+
}
|