severally-mcp 2.0.0 → 2.3.1

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.
Files changed (40) hide show
  1. package/CODE_OF_CONDUCT.md +83 -0
  2. package/CONFIG.md +13 -7
  3. package/README.ja.md +157 -77
  4. package/README.md +162 -81
  5. package/bin/severally-mcp.mjs +3 -0
  6. package/config.example.json +26 -0
  7. package/docs/how-it-works.ja.md +11 -3
  8. package/docs/how-it-works.md +12 -4
  9. package/docs/install.ja.md +25 -6
  10. package/docs/install.md +30 -7
  11. package/package.json +5 -3
  12. package/plugins/severally/.claude-plugin/plugin.json +1 -1
  13. package/plugins/severally/.codex-plugin/plugin.json +4 -2
  14. package/plugins/severally/.mcp.json +2 -1
  15. package/plugins/severally/dist/severally-mcp.mjs +29639 -28215
  16. package/plugins/severally/skills/_template/SKILL.md.tmpl +19 -23
  17. package/plugins/severally/skills/_template/reference.md.tmpl +22 -10
  18. package/plugins/severally/skills/antigravity/severally/SKILL.md +19 -23
  19. package/plugins/severally/skills/antigravity/severally/reference.md +22 -10
  20. package/plugins/severally/skills/claude/severally/SKILL.md +19 -23
  21. package/plugins/severally/skills/claude/severally/reference.md +22 -10
  22. package/plugins/severally/skills/codex/severally/SKILL.md +19 -23
  23. package/plugins/severally/skills/codex/severally/reference.md +22 -10
  24. package/plugins/severally/skills/opencode/severally/SKILL.md +19 -23
  25. package/plugins/severally/skills/opencode/severally/reference.md +22 -10
  26. package/scripts/init-config.mjs +1 -1
  27. package/scripts/install.mjs +124 -9
  28. package/src/adapters/antigravity-sandbox.mjs +5 -1
  29. package/src/adapters/codex.mjs +17 -6
  30. package/src/brief.mjs +38 -16
  31. package/src/consultants.mjs +31 -10
  32. package/src/expose-paths.mjs +68 -5
  33. package/src/jobs.mjs +294 -56
  34. package/src/policy.mjs +49 -11
  35. package/src/redact.mjs +20 -1
  36. package/src/run.mjs +38 -5
  37. package/src/schema.mjs +35 -12
  38. package/src/server.mjs +96 -120
  39. package/src/status.mjs +63 -0
  40. package/src/store.mjs +44 -1
@@ -17,9 +17,8 @@ checked as given: the server rejects a first-round `explore` that carries a prop
17
17
  anchoring-sensitive — if you want your plan critiqued, that is `review`.
18
18
 
19
19
  **For a decision heavy enough to be worth two consultations**, ask `explore` first on the facts alone, then
20
- `review` with the proposal, and read what the first raised that the second never did. Measured on this
21
- project: repeat runs of the identical brief did not move the bottom line, while withholding the proposal once
22
- did, and the withheld run was the only one to question what the decision was even about.
20
+ `review` with the proposal, and read what the first raised that the second never did. A consultant that sees
21
+ your proposal tends to answer around it; one that does not is more likely to question the framing itself.
23
22
 
24
23
  ## A brief for a decision you will live with
25
24
 
@@ -70,10 +69,14 @@ names. Your own CLI is a fresh session but not another lineage, and its `quality
70
69
  consultants of one vendor.
71
70
 
72
71
  Send **one** `targets` call: every consultant receives the byte-identical brief, which is what makes the answers
73
- comparable. Poll the single group with `consult_get({ group_id })` and stop it with
74
- `consult_cancel({ group_id })`. A fan-out takes one slot of the concurrency cap (nine by default, shared by
75
- every severally session on this machine) and one consultation's quota per consultant, and `targets` is refused
76
- on a follow-up.
72
+ comparable (on a follow-up to the group, the same new question, with each one's own earlier rounds). Poll the single group with `consult_get({ group_id })` and stop it with
73
+ `consult_cancel({ group_id })`. A fan-out takes one slot of the concurrency cap per consultant (nine by default,
74
+ shared by every severally session on this machine; the group starts only if every member gets one) and one
75
+ consultation's quota per consultant. To ask every member again, follow up the group: `followup_to: "<group_id>"`
76
+ with no `target` or `targets` (see Follow-ups).
77
+
78
+ While you wait, `consult_get` blocks for up to its limit (ten minutes where the client allows it). To work on
79
+ something independent in between, pass a shorter `wait_ms` and come back.
77
80
 
78
81
  `comparison.by_target` holds, per consultant: stance, summary, confidence, evidence basis, finding points (each
79
82
  with its `id` and severity), `severity_counts`, `decision_changers`, alternatives, unknowns (`u1` …),
@@ -93,7 +96,7 @@ Reading them against each other:
93
96
  4. **Read `decision_changers` before spending a follow-up**: a consultant that named the condition under which
94
97
  it would change its mind has told you what evidence to go get.
95
98
  5. **Spend a follow-up only on a divergence that would change your decision**, sent only to the consultant
96
- whose reading it belongs to.
99
+ whose reading it belongs to, or to the whole group (`followup_to: "<group_id>"`) when it concerns all of them.
97
100
  6. **A stance every consultant shares is not evidence that the plan was checked.** Look for a premise they all
98
101
  rely on and none could verify; name it only if you can actually identify one.
99
102
 
@@ -123,14 +126,23 @@ in `failure.detail`, which tells you whether to retry with a longer budget or a
123
126
 
124
127
  By default a chain has five rounds: one initial round plus up to four follow-ups
125
128
  (`followup_to: "<previous job_id>"`); the operator can configure 1–20 (`server.max_rounds`), and
126
- `rounds_remaining` says what is left. A follow-up starts in a fresh working directory with no files: pass
129
+ `rounds_remaining` says what is left. `followup_to: "<group_id>"`, with no `target` or `targets`, sends the same new
130
+ question to every member of a fan-out, each continuing from its own latest round with its own history; a member
131
+ that is still running, never answered or has used its rounds is listed under `skipped` and not asked.
132
+
133
+ A follow-up needs only `followup_to` and the new `question`:
134
+ `consult_start({ request: { followup_to: "<job_id>", question: "..." } })`. The consultant, the mode, `network` and what
135
+ the earlier round was given (objective, constraints, success criteria, facts, proposal, counterpoints,
136
+ artifacts) carry over, and the brief restates them; a field you pass replaces the earlier one, an empty list
137
+ included. A follow-up starts in a fresh working directory with no files: pass
127
138
  `context.expose_from_parent: true` to copy again, as they are now, the paths the earlier round exposed (a changed
128
139
  or vanished entry is marked), and leave it off when the follow-up does not need them.
129
140
 
130
141
  Spend follow-ups only where you and the consultant actually diverge: quote the specific point, give the evidence
131
142
  that answers it, and ask what would change their view. Write your verdicts with `consult_record` first: the
132
143
  consultant is shown each earlier point with your verdict, so it answers what your checking found instead of
133
- restating it. A follow-up works across a server restart.
144
+ restating it. A follow-up works across a server restart; `consult_list` shows an earlier session's
145
+ consultations with their `job_id` and `group_id`.
134
146
 
135
147
  After each follow-up, state in one sentence the cause you still differ on. If it is the same as last round and
136
148
  the round brought no new evidence and no new condition that would change the judgement, stop and hand the user
@@ -5,9 +5,9 @@ description: Use when a decision deserves a second, independent mind - an archit
5
5
 
6
6
  # Consulting a peer agent
7
7
 
8
- You have three peers, each reached through the `severally` MCP server as a fresh child session. They can
9
- search and browse the web. They cannot edit files, reach the network outside search/browse, load MCP tools,
10
- see your session, or consult anyone else. In practice they know only what you put in the brief and the files you expose to them.
8
+ You have three peers, each reached through the `severally` MCP server as a fresh child session that can read files
9
+ and search the web, but not edit them, load MCP tools, see your session or consult anyone else. Each knows only
10
+ what you put in the brief and the files you expose to it.
11
11
 
12
12
  One caveat on that list: a consultant can read local files. Its writes are blocked,
13
13
  its network reaches only web search and browsing (none with `network: "off"`), credential and history
@@ -29,13 +29,14 @@ copied read-only into its working directory. The Codex consultant additionally h
29
29
  }})
30
30
  ```
31
31
 
32
- 2. **`consult_get({ group_id })`** (`consult_get({ job_id })` for one consultant). It waits up to 45 seconds for
33
- the answer by itself; call it again while `status` is `running`, and work on something independent in between.
32
+ 2. **`consult_get({ group_id })`** (`consult_get({ job_id })` for one consultant). It waits for the answer by itself,
33
+ up to a limit the server sets (45 seconds, or ten minutes where the client allows it); call it again while
34
+ `status` is `running`. To work on something independent meanwhile, ask for a shorter wait (`reference.md`).
34
35
  3. **Check one point, report, and record it once** (see **Before you hand the decision back**).
35
36
 
36
- That is the whole routine. The rest of the record — more verdicts, a prediction and reflection, follow-ups,
37
- the export into the repository, the details of reading a fan-out — is in `reference.md`, in the same
38
- directory as this file. Read it only for a decision you will have to justify later, or when you follow up.
37
+ That is the whole routine. The rest — follow-ups, a prediction and reflection, the export, reading a fan-out
38
+ in detail — is in `reference.md`, in the same directory as this file. Read it for a decision you will have to
39
+ justify later, or when you follow up.
39
40
 
40
41
  ## Pick the consultant
41
42
 
@@ -53,12 +54,10 @@ costs one consultation's quota per consultant. Narrow to `target` (singular) onl
53
54
  specific peer, or when the decision clearly does not warrant that much. This is the one rule for how many to
54
55
  ask.
55
56
 
56
- A consultant is one CLI running one model, and the operator decides which ones exist. `consult_start`'s
57
- description lists the ones this machine can actually reach as `name: CLI, model`. When the user names one,
58
- pass **the word the user used** as `target` — a name, a CLI (`codex`, `agy`), a vendor or a model
59
- (「Claude Opusと相談して」 is `target: "claude opus"`) — and let the server resolve it. A word that fits several
60
- comes back as `target_ambiguous` with the candidates: ask the user which one they meant. One that is not
61
- installed comes back as `target_unavailable` with the available list: take that as final and tell the user.
57
+ The operator decides which consultants exist; `consult_start`'s description lists the ones this machine can
58
+ actually reach. When the user names one, pass **the word the user used** as `target`
59
+ (「Claude Opusと相談して」 is `target: "claude opus"`). `target_ambiguous`: ask the user which one they meant.
60
+ `target_unavailable`: take the available list as final and tell the user.
62
61
 
63
62
  **Do not pick a model yourself.** When the user named no one, ask everyone; overriding the operator's
64
63
  consultants on your own judgement — including after a `usage_limit` failure — substitutes a different mind
@@ -72,9 +71,8 @@ answer can say which model answered.
72
71
 
73
72
  ## When this is worth it
74
73
 
75
- When a wrong answer is expensive or hard to undo: an architectural or interface decision, a data migration, a
76
- security or concurrency design; two options that still look close; an investigation that has stalled after two
77
- failed attempts; or the user asked. Not for routine edits, a rename, a test that just needs writing, or
74
+ When a wrong answer is expensive or hard to undo (an interface, a migration, a security or concurrency design),
75
+ two options still look close, an investigation has stalled after two attempts, or the user asked. Not for
78
76
  anything you would be comfortable defending on your own.
79
77
 
80
78
  **Before you ask the user to approve a change that is hard to reverse** and nobody else has reviewed it,
@@ -91,15 +89,13 @@ Pass `initiator: "user"` when the user asked for the consultation; leave it out
91
89
  - **Ask one decidable question.** What runs out the clock is scope, not brief length: when the budget runs out
92
90
  the session is killed and you get nothing. Split "research everything about X" or three questions at once,
93
91
  and ask the one whose answer changes what you do next.
94
- - **Hand over the code.** The consultant starts in an empty working directory and is not told where your
95
- repository is. Name the files by absolute path in `context.expose_paths` in this first call (at most 20
96
- entries, 500 files, 5 MB; never your home directory or one holding keys), or pass
92
+ - **Hand over the code.** The consultant is not told where your repository is. Name the files by absolute path
93
+ in `context.expose_paths` (a repository root works; never your home directory or one holding keys), or pass
97
94
  `context.expose_diff: { repo: "<absolute path>" }` for a change you are making. When `consult_start` answers
98
95
  `files_exposed: 0` and the question is about code, `consult_cancel` and start again with `expose_paths`.
99
96
  - **Put the load-bearing facts in `context.facts`**, and test output or a log in `context.artifacts`.
100
- - **The mode follows from the context.** Leave `mode` out: no proposal is `explore`, a proposal is `review`, a
101
- proposal with `counterpoints` (the other side's claims) is `debate`. To gather opinions without showing your
102
- own, leave `context.proposal` empty; a reviewed plan is answered around the plan.
97
+ - **Leave `mode` out**; it follows from the context. To gather opinions without showing your own, leave
98
+ `context.proposal` empty: a reviewed plan is answered around the plan.
103
99
  - A constraint is read as fixed and will not be challenged; if it is your own call, put it under `facts` with
104
100
  its reason. For material that must not leave the machine through a URL, pass `network: "off"`.
105
101
 
@@ -17,9 +17,8 @@ checked as given: the server rejects a first-round `explore` that carries a prop
17
17
  anchoring-sensitive — if you want your plan critiqued, that is `review`.
18
18
 
19
19
  **For a decision heavy enough to be worth two consultations**, ask `explore` first on the facts alone, then
20
- `review` with the proposal, and read what the first raised that the second never did. Measured on this
21
- project: repeat runs of the identical brief did not move the bottom line, while withholding the proposal once
22
- did, and the withheld run was the only one to question what the decision was even about.
20
+ `review` with the proposal, and read what the first raised that the second never did. A consultant that sees
21
+ your proposal tends to answer around it; one that does not is more likely to question the framing itself.
23
22
 
24
23
  ## A brief for a decision you will live with
25
24
 
@@ -70,10 +69,14 @@ names. Your own CLI is a fresh session but not another lineage, and its `quality
70
69
  consultants of one vendor.
71
70
 
72
71
  Send **one** `targets` call: every consultant receives the byte-identical brief, which is what makes the answers
73
- comparable. Poll the single group with `consult_get({ group_id })` and stop it with
74
- `consult_cancel({ group_id })`. A fan-out takes one slot of the concurrency cap (nine by default, shared by
75
- every severally session on this machine) and one consultation's quota per consultant, and `targets` is refused
76
- on a follow-up.
72
+ comparable (on a follow-up to the group, the same new question, with each one's own earlier rounds). Poll the single group with `consult_get({ group_id })` and stop it with
73
+ `consult_cancel({ group_id })`. A fan-out takes one slot of the concurrency cap per consultant (nine by default,
74
+ shared by every severally session on this machine; the group starts only if every member gets one) and one
75
+ consultation's quota per consultant. To ask every member again, follow up the group: `followup_to: "<group_id>"`
76
+ with no `target` or `targets` (see Follow-ups).
77
+
78
+ While you wait, `consult_get` blocks for up to its limit (ten minutes where the client allows it). To work on
79
+ something independent in between, pass a shorter `wait_ms` and come back.
77
80
 
78
81
  `comparison.by_target` holds, per consultant: stance, summary, confidence, evidence basis, finding points (each
79
82
  with its `id` and severity), `severity_counts`, `decision_changers`, alternatives, unknowns (`u1` …),
@@ -93,7 +96,7 @@ Reading them against each other:
93
96
  4. **Read `decision_changers` before spending a follow-up**: a consultant that named the condition under which
94
97
  it would change its mind has told you what evidence to go get.
95
98
  5. **Spend a follow-up only on a divergence that would change your decision**, sent only to the consultant
96
- whose reading it belongs to.
99
+ whose reading it belongs to, or to the whole group (`followup_to: "<group_id>"`) when it concerns all of them.
97
100
  6. **A stance every consultant shares is not evidence that the plan was checked.** Look for a premise they all
98
101
  rely on and none could verify; name it only if you can actually identify one.
99
102
 
@@ -123,14 +126,23 @@ in `failure.detail`, which tells you whether to retry with a longer budget or a
123
126
 
124
127
  By default a chain has five rounds: one initial round plus up to four follow-ups
125
128
  (`followup_to: "<previous job_id>"`); the operator can configure 1–20 (`server.max_rounds`), and
126
- `rounds_remaining` says what is left. A follow-up starts in a fresh working directory with no files: pass
129
+ `rounds_remaining` says what is left. `followup_to: "<group_id>"`, with no `target` or `targets`, sends the same new
130
+ question to every member of a fan-out, each continuing from its own latest round with its own history; a member
131
+ that is still running, never answered or has used its rounds is listed under `skipped` and not asked.
132
+
133
+ A follow-up needs only `followup_to` and the new `question`:
134
+ `consult_start({ request: { followup_to: "<job_id>", question: "..." } })`. The consultant, the mode, `network` and what
135
+ the earlier round was given (objective, constraints, success criteria, facts, proposal, counterpoints,
136
+ artifacts) carry over, and the brief restates them; a field you pass replaces the earlier one, an empty list
137
+ included. A follow-up starts in a fresh working directory with no files: pass
127
138
  `context.expose_from_parent: true` to copy again, as they are now, the paths the earlier round exposed (a changed
128
139
  or vanished entry is marked), and leave it off when the follow-up does not need them.
129
140
 
130
141
  Spend follow-ups only where you and the consultant actually diverge: quote the specific point, give the evidence
131
142
  that answers it, and ask what would change their view. Write your verdicts with `consult_record` first: the
132
143
  consultant is shown each earlier point with your verdict, so it answers what your checking found instead of
133
- restating it. A follow-up works across a server restart.
144
+ restating it. A follow-up works across a server restart; `consult_list` shows an earlier session's
145
+ consultations with their `job_id` and `group_id`.
134
146
 
135
147
  After each follow-up, state in one sentence the cause you still differ on. If it is the same as last round and
136
148
  the round brought no new evidence and no new condition that would change the judgement, stop and hand the user
@@ -53,7 +53,7 @@ export function renderConfig() {
53
53
  ' // ranking: optional, higher first -- which consultant a name that fits several goes to,',
54
54
  ' // before the built-in rules (opus over sonnet, newer version). e.g. "ranking": ["sol", "opus"]',
55
55
  ' //',
56
- ' // server: optional -- max_rounds (5, 1-20), max_concurrent (9, 1-9), timeout_ms (3600000),',
56
+ ' // server: optional -- max_rounds (5, 1-20), max_concurrent (9, 1-9), timeout_ms (1800000),',
57
57
  ' // max_wait_ms (45000), max_jobs_retained, kill_grace_ms: see CONFIG.md',
58
58
  ' "clis": {},',
59
59
  ' "consultants": {',
@@ -243,6 +243,57 @@ if (mode === 'plugin') {
243
243
  log(` server command: ${JSON.stringify(serverCommand)}`);
244
244
 
245
245
  const codexHome = process.env.CODEX_HOME ?? path.join(home, '.codex');
246
+ // consult_get waits 45 s by default, under the 60 s that some MCP clients
247
+ // allow a tool call. A client known to wait longer is registered with this,
248
+ // so one consult_get usually covers a whole consultation. The plugin's own
249
+ // .mcp.json carries the same value for Claude Code, and its Codex manifest
250
+ // with tool_timeout_sec 660 (codex 0.163 stops a tool call at 300 s by
251
+ // default, progress notwithstanding). `codex mcp add` cannot set that
252
+ // timeout, so a --manual Codex gets it as one line written into config.toml
253
+ // under [mcp_servers.severally] (see the Codex row), together with the env;
254
+ // both or neither, since the wait without the timeout would outlast Codex's
255
+ // own deadline.
256
+ const LONG_WAIT = 'SEVERALLY_MAX_WAIT_MS=600000';
257
+ const AGY_WAIT = 'SEVERALLY_MAX_WAIT_MS=165000';
258
+ const agyConfig = path.join(home, '.gemini', 'config', 'mcp_config.json');
259
+ const CODEX_TIMEOUT_SEC = 660;
260
+ const codexConfig = path.join(codexHome, 'config.toml');
261
+ // The user's own tool_timeout_sec, read before --force removes the table that holds it.
262
+ let priorCodexTimeout;
263
+
264
+ // Where [mcp_servers.severally] sits in config.toml, and what it holds.
265
+ // A minimal text read, not a TOML parser: the table runs to the next header
266
+ // that is not one of its own sub-tables (codex may put env in one).
267
+ function codexTable() {
268
+ let lines;
269
+ try { lines = fs.readFileSync(codexConfig, 'utf8').split('\n'); } catch (err) { return { reason: `cannot read ${codexConfig}: ${err.message}` }; }
270
+ const start = lines.findIndex((l) => /^\s*\[\s*mcp_servers\.severally\s*\]/.test(l));
271
+ if (start < 0) return { reason: `${codexConfig} has no [mcp_servers.severally] table` };
272
+ let end = lines.findIndex((l, i) => i > start && /^\s*\[/.test(l) && !/^\s*\[\s*mcp_servers\.severally\./.test(l));
273
+ if (end < 0) end = lines.length;
274
+ const block = lines.slice(start + 1, end).join('\n');
275
+ const timeout = block.match(/^\s*tool_timeout_sec\s*=\s*(\d+(?:\.\d+)?)/m)?.[1];
276
+ return { lines, start, timeout: timeout === undefined ? undefined : Number(timeout), wait: /SEVERALLY_MAX_WAIT_MS\s*=\s*"?\d+/.test(block) };
277
+ }
278
+
279
+ // The wait follows the timeout Codex will enforce: 15 s under the user's own
280
+ // tool_timeout_sec when that is short, else the full 600000 ms.
281
+ function codexPlan() {
282
+ const sec = priorCodexTimeout ?? CODEX_TIMEOUT_SEC;
283
+ return { sec, ms: sec < 615 ? Math.max(0, Math.floor((sec - 15) * 1000)) : 600000 };
284
+ }
285
+
286
+ // Inserts tool_timeout_sec right after the table header. Returns why it could
287
+ // not, or null.
288
+ function writeCodexTimeout(sec) {
289
+ const t = codexTable();
290
+ if (t.reason) return t.reason;
291
+ if (t.timeout !== undefined) return null; // never overwrite the user's value
292
+ t.lines.splice(t.start + 1, 0, `tool_timeout_sec = ${sec}`);
293
+ try { fs.writeFileSync(codexConfig, t.lines.join('\n')); } catch (err) { return `cannot write ${codexConfig}: ${err.message}`; }
294
+ return null;
295
+ }
296
+
246
297
  const claudeSkillsDir = path.join(home, '.claude', 'skills');
247
298
 
248
299
  // ---------------------------------------------------------------- clients
@@ -260,7 +311,9 @@ const CLIENTS = [
260
311
  // `claude mcp get` exits non-zero when the server is not registered.
261
312
  isRegistered: () => tryRun('claude', ['mcp', 'get', 'severally'], { real: true }).ok,
262
313
  remove: () => tryRun('claude', ['mcp', 'remove', '--scope', 'user', 'severally']),
263
- add: (bin) => tryRun('claude', ['mcp', 'add', '--scope', 'user', 'severally', '--', ...bin]),
314
+ // Claude Code waits on a tool call far longer than consult_get's ten
315
+ // minutes, so its consult_get may wait that long (see LONG_WAIT).
316
+ add: (bin) => tryRun('claude', ['mcp', 'add', '--scope', 'user', 'severally', '--env', LONG_WAIT, '--', ...bin]),
264
317
  skillFrom: path.join(PLUGIN, 'skills', 'claude', 'severally'),
265
318
  skillTo: path.join(claudeSkillsDir, 'severally'),
266
319
  },
@@ -269,8 +322,35 @@ const CLIENTS = [
269
322
  label: 'Codex',
270
323
  backup: [path.join(codexHome, 'config.toml')],
271
324
  isRegistered: () => tryRun('codex', ['mcp', 'get', 'severally'], { real: true }).ok,
272
- remove: () => tryRun('codex', ['mcp', 'remove', 'severally']),
273
- add: (bin) => tryRun('codex', ['mcp', 'add', 'severally', '--', ...bin]),
325
+ remove: () => {
326
+ priorCodexTimeout = codexTable().timeout;
327
+ return tryRun('codex', ['mcp', 'remove', 'severally']);
328
+ },
329
+ // The long wait is the env plus tool_timeout_sec in config.toml, both or neither.
330
+ add: (bin) => {
331
+ const { sec, ms } = codexPlan();
332
+ const r = tryRun('codex', ['mcp', 'add', 'severally', '--env', `SEVERALLY_MAX_WAIT_MS=${ms}`, '--', ...bin]);
333
+ if (!r.ok) return r;
334
+ if (dryRun) {
335
+ log(` [dry-run] write tool_timeout_sec = ${sec} into ${codexConfig} under [mcp_servers.severally]`);
336
+ return r;
337
+ }
338
+ const why = writeCodexTimeout(sec);
339
+ if (!why) {
340
+ log(` consult_get waits up to ${ms / 1000} s (SEVERALLY_MAX_WAIT_MS=${ms}, tool_timeout_sec = ${sec})`);
341
+ return r;
342
+ }
343
+ const back = tryRun('codex', ['mcp', 'remove', 'severally']);
344
+ if (!back.ok) return back;
345
+ log(` the long consult_get wait was not set (it stays 45 s): ${why}`);
346
+ return tryRun('codex', ['mcp', 'add', 'severally', '--', ...bin]);
347
+ },
348
+ keptNote: () => {
349
+ const t = codexTable();
350
+ if (t.timeout === undefined || !t.wait) {
351
+ log(` this registration lacks the long consult_get wait (45 s); --force adds it (SEVERALLY_MAX_WAIT_MS and tool_timeout_sec = ${CODEX_TIMEOUT_SEC})`);
352
+ }
353
+ },
274
354
  skillFrom: path.join(PLUGIN, 'skills', 'codex', 'severally'),
275
355
  skillTo: path.join(codexHome, 'skills', 'severally'),
276
356
  },
@@ -287,7 +367,14 @@ const CLIENTS = [
287
367
  return r.ok && /severally/.test(r.out);
288
368
  },
289
369
  remove: () => tryRun('agy', ['mcp', 'remove', 'severally']),
290
- add: (bin) => tryRun('agy', ['mcp', 'add', 'severally', ...bin]),
370
+ // agy stops an MCP tool call at 3 minutes, progress notifications or not
371
+ // (measured: a 310 s call ended at 180 s), so its wait is 15 s under that.
372
+ add: (bin) => tryRun('agy', ['mcp', 'add', '--env', AGY_WAIT, 'severally', ...bin]),
373
+ keptNote: () => {
374
+ if (!/SEVERALLY_MAX_WAIT_MS/.test(fs.existsSync(agyConfig) ? fs.readFileSync(agyConfig, 'utf8') : '')) {
375
+ log(' this registration lacks the longer consult_get wait (45 s); --force adds it (SEVERALLY_MAX_WAIT_MS=165000)');
376
+ }
377
+ },
291
378
  skillFrom: path.join(PLUGIN, 'skills', 'antigravity', 'severally'),
292
379
  skillTo: path.join(home, '.gemini', 'config', 'skills', 'severally'),
293
380
  },
@@ -316,7 +403,14 @@ const CLIENTS = [
316
403
  // reachable only inside whatever directory the installer happened to
317
404
  // run from.
318
405
  remove: () => ({ ok: true, out: 'opencode has no mcp remove; re-adding replaces the entry' }),
319
- add: (bin) => tryRun('opencode', ['mcp', 'add', 'severally', '--global', '--', ...bin]),
406
+ // OpenCode sets no deadline of its own on a tool call (a 610 s call came
407
+ // back), so it gets the long consult_get wait with no timeout to pair.
408
+ add: (bin) => tryRun('opencode', ['mcp', 'add', 'severally', '--global', '--env', LONG_WAIT, '--', ...bin]),
409
+ keptNote: () => {
410
+ const text = [path.join(xdgConfig, 'opencode', 'opencode.json'), path.join(xdgConfig, 'opencode', 'opencode.jsonc')]
411
+ .map((f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return ''; } }).join('\n');
412
+ if (!text.includes('SEVERALLY_MAX_WAIT_MS')) log(' this registration lacks the long consult_get wait (45 s); --force adds it (SEVERALLY_MAX_WAIT_MS)');
413
+ },
320
414
  // A zero exit from `mcp add` can be a usage dump in disguise (see above),
321
415
  // so this client's registration is verified by listing after adding --
322
416
  // and the recorded command is compared against this install's.
@@ -349,6 +443,16 @@ function registrationCommandMatches(client, bin) {
349
443
  return false;
350
444
  }
351
445
 
446
+ // The list right after an add can be briefly empty, so it is asked up to
447
+ // three times, 1.5 s apart, before the add is judged.
448
+ function listedAfterAdd(client) {
449
+ for (let i = 0; i < 3; i++) {
450
+ if (i) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1500);
451
+ if (client.isRegistered()) return true;
452
+ }
453
+ return false;
454
+ }
455
+
352
456
  // Registers one client's MCP server directly (through its own `mcp add`) and
353
457
  // copies its skill, backing up everything it touches first. Shared by plugin
354
458
  // mode (Antigravity only) and --manual mode (all three clients).
@@ -361,19 +465,30 @@ function installClientDirectly(client, bin) { step(`Registering with ${client.l
361
465
  if (client.isRegistered() && !force) {
362
466
  keptRegistrations = true;
363
467
  log(' already registered; leaving it as it is (use --force to re-register)');
468
+ client.keptNote?.();
364
469
  } else {
365
470
  if (client.isRegistered()) client.remove();
366
471
  const r = client.add(bin);
367
472
  if (!r.ok) {
368
473
  log(` failed: ${r.out}`);
369
474
  process.exitCode = 1;
370
- } else if (!dryRun && client.verifyAdd && !client.isRegistered()) {
475
+ } else if (!dryRun && client.verifyAdd && !listedAfterAdd(client)) {
371
476
  // opencode prints usage and exits 0 on flags a future version renames,
372
477
  // so a zero exit from `mcp add` proves nothing: confirm the entry is
373
478
  // actually listed, or the server silently never reaches the client.
374
- log(' add exited 0 but the server is not listed; registration failed');
375
- log(` the list said: ${lastListOutput.slice(0, 500) || '(nothing)'}`);
376
- process.exitCode = 1;
479
+ // Its list has also come back empty with the server in its config
480
+ // (twice, on the first run after an upgrade), so a config
481
+ // holding exactly this install's command is a registration, noted.
482
+ const said = ` the list said: ${lastListOutput.slice(0, 500) || '(nothing)'}`;
483
+ if (registrationCommandMatches(client, bin)) {
484
+ log(` registered in ${client.label}'s global config, but \`${client.bin} mcp list\` does not show it yet`);
485
+ log(said);
486
+ log(` check with \`${client.bin} mcp list\` after restarting it`);
487
+ } else {
488
+ log(' add exited 0 but the server is not listed; registration failed');
489
+ log(said);
490
+ process.exitCode = 1;
491
+ }
377
492
  } else if (!dryRun && client.verifyAdd && !registrationCommandMatches(client, bin)) {
378
493
  log(' registration not verified: the listed server command does not match this install');
379
494
  process.exitCode = 1;
@@ -55,7 +55,11 @@ const WEB_TOOLS = new Set(['search_web', 'read_url_content']);
55
55
  // call through. So the hook always answers, allow included, and anything it
56
56
  // cannot read or check -- broken JSON, a stdin error, arguments nested past
57
57
  // what it walks, an exception of its own -- is denied. A hook that never runs
58
- // or is killed answers nothing, and that stays agy's call. For the file-reading tool
58
+ // or is killed answers nothing, and that stays agy's call: agy 1.4.2 fails such
59
+ // a call rather than running it ("JSON hook ... failed: command failed: ..."),
60
+ // checked live on 2026-10-20 with invoke_subagent against a hook that exited 1,
61
+ // exited 2, outlived the 10 s timeout, and whose script was missing -- each
62
+ // time the step ended in ERROR and no child agent started. For the file-reading tool
59
63
  // and for a file: URL, every path-like parameter is also checked against the
60
64
  // protected roots and file names, before and after resolving links, with ~
61
65
  // expanded: a consultant that can browse must not read a credential and
@@ -167,11 +167,16 @@ export function interpret({ stdout, stderr, code, lastMessageText }) {
167
167
  }
168
168
  }
169
169
 
170
- if (errorEvents.length) {
171
- const msg = errorEvents
172
- .map((e) => e.message ?? e.error?.message ?? JSON.stringify(e))
173
- .join(' | ');
174
- return { ok: false, failureKind: classifyMessage(msg), message: msg, usageRaw: usage, events: events.length };
170
+ const errorMsg = errorEvents
171
+ .map((e) => e.message ?? e.error?.message ?? JSON.stringify(e))
172
+ .join(' | ');
173
+ // An error the turn recovered from (the stream still ends in
174
+ // turn.completed, with an answer) does not throw the answer away; the lead
175
+ // is told about it instead. A turn that ends in turn.failed has failed,
176
+ // whatever text it left behind.
177
+ const recovered = errorEvents.length > 0 && Boolean(text) && events.at(-1)?.type === 'turn.completed';
178
+ if (errorEvents.length && !recovered) {
179
+ return { ok: false, failureKind: classifyMessage(errorMsg), message: errorMsg, usageRaw: usage, events: events.length };
175
180
  }
176
181
  if (!text) {
177
182
  const msg = (stderr || '').trim() || `codex exited with code ${code} and produced no final message`;
@@ -183,7 +188,13 @@ export function interpret({ stdout, stderr, code, lastMessageText }) {
183
188
  events: events.length,
184
189
  };
185
190
  }
186
- return { ok: true, text, usageRaw: usage, events: events.length };
191
+ return {
192
+ ok: true,
193
+ text,
194
+ usageRaw: usage,
195
+ events: events.length,
196
+ recoveredError: recovered ? { failureKind: classifyMessage(errorMsg), message: errorMsg } : null,
197
+ };
187
198
  }
188
199
 
189
200
  /**
package/src/brief.mjs CHANGED
@@ -184,6 +184,8 @@ function renderExposeManifest(manifest) {
184
184
  const skipped = [
185
185
  count('symlink') ? `${count('symlink')} symlink(s), or path(s) through one, were skipped, not followed.` : null,
186
186
  count('protected') ? `${count('protected')} credential or history path(s) were left out on purpose.` : null,
187
+ count('ignored') ? `${count('ignored')} path(s) (.git, node_modules, whatever .gitignore excludes) were left out as not source.` : null,
188
+ count('submodule') ? `${count('submodule')} submodule(s) or nested repositor(ies) were left out; their files are not copied.` : null,
187
189
  count('gone') ? `No longer there, so not copied again: ${named('gone')}.` : null,
188
190
  count('masked') ? `Not copied again, because the record of the earlier round masked the path: ${named('masked')}.` : null,
189
191
  count('replaced') ? `The earlier round's change is replaced by the diff given in this round: ${named('replaced')}.` : null,
@@ -204,9 +206,30 @@ function renderExposeManifest(manifest) {
204
206
  // from crowding out the question it is there to inform.
205
207
  const clip = (s, max = 400) => (s.length > max ? `${s.slice(0, max)}...` : s);
206
208
 
209
+ // The earlier rounds have a budget of their own, beside the request's cap:
210
+ // when they outgrow it, the oldest rounds are left out, and the brief says so.
211
+ const HISTORY_CHARS = 40_000;
212
+
213
+ function renderRound(p) {
214
+ // Prefixed with the round, so a point from round 1 is not taken for this one's.
215
+ const tag = (id) => `r${p.round}.${id}`;
216
+ const verdict = (x) => (x.verdict ? ` -- lead's verdict: ${x.verdict}${x.effect ? ` (${clip(x.effect)})` : ''}` : '');
217
+ const list = (title, items, line) => (items?.length ? [title, ...items.map(line)].join('\n') : null);
218
+ return [
219
+ `### Round ${p.round} (${p.mode})`,
220
+ `Question asked: ${p.question}`,
221
+ `Your answer, summarised: ${p.summary}`,
222
+ list('Points you raised:', p.findings,
223
+ (f) => `- ${tag(f.id)}: ${clip(f.point)}${verdict(f)}${f.grounds ? `\n grounds: ${clip(f.grounds)}` : ''}`),
224
+ list('Unknowns you named:', p.unknowns, (u) => `- ${tag(u.id)}: ${clip(u.point)}${verdict(u)}`),
225
+ list('Checks you proposed:', p.next_checks, (c) => `- ${tag(c.id)}: ${clip(c.point)}${verdict(c)}`),
226
+ ].filter(Boolean).join('\n');
227
+ }
228
+
207
229
  /**
208
230
  * @param {object} req validated request
209
- * @param {object} chain { round, priorRounds: [{question, mode, summary, findings: [{id, point, verdict, effect}]}] }
231
+ * @param {object} chain { round, priorRounds: [{question, mode, summary, findings: [{id, point, grounds, verdict, effect}],
232
+ * unknowns: [{id, point, verdict, effect}], next_checks: [{id, point, verdict, effect}]}] }
210
233
  */
211
234
  export function renderBrief(req, chain = { round: 1, priorRounds: [] }, exposeManifest = null) {
212
235
  const parts = [];
@@ -238,22 +261,21 @@ export function renderBrief(req, chain = { round: 1, priorRounds: [] }, exposeMa
238
261
  if (chain.priorRounds && chain.priorRounds.length) {
239
262
  parts.push('');
240
263
  parts.push('## Earlier rounds of this same consultation');
241
- for (const p of chain.priorRounds) {
242
- parts.push(
243
- [
244
- `### Round ${p.round} (${p.mode})`,
245
- `Question asked: ${p.question}`,
246
- `Your answer, summarised: ${p.summary}`,
247
- p.findings && p.findings.length
248
- ? ['Points you raised, with what the lead\'s own check found -- confirmed: it held; not_applicable: checked, and it'
249
- + ' does not apply here; unverifiable: could not be checked; no verdict: not checked yet:',
250
- ...p.findings.map((f) => `- ${f.id}: ${clip(f.point)}${f.verdict ? ` -- lead's verdict: ${f.verdict}${f.effect ? ` (${clip(f.effect)})` : ''}` : ''}`)].join('\n')
251
- : null,
252
- ]
253
- .filter(Boolean)
254
- .join('\n'),
255
- );
264
+ parts.push(
265
+ 'Each point carries the lead\'s own check where there is one -- confirmed: it held; not_applicable: checked, and'
266
+ + ' it does not apply here; unverifiable: could not be checked; unverified, or no verdict: not checked yet.',
267
+ );
268
+ const blocks = chain.priorRounds.map(renderRound);
269
+ let kept = 0;
270
+ let used = 0;
271
+ // Newest first: the round being followed up always goes in.
272
+ for (let i = blocks.length - 1; i >= 0 && (kept === 0 || used + blocks[i].length <= HISTORY_CHARS); i--) {
273
+ used += blocks[i].length;
274
+ kept += 1;
256
275
  }
276
+ const left = chain.priorRounds.slice(0, blocks.length - kept).map((p) => p.round);
277
+ if (left.length) parts.push(`(Round${left.length > 1 ? 's' : ''} ${left.join(', ')} left out to keep this brief within its size.)`);
278
+ parts.push(...blocks.slice(blocks.length - kept));
257
279
  parts.push('');
258
280
  parts.push(
259
281
  'This round is a follow-up. The lead has narrowed the exchange to the divergences above. Do not restate your earlier answer; address what is new, and say plainly if the new information changes or does not change your position.',