herdr-orchestra 6.4.0 → 6.5.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.5.0] - 2026-11-22
6
+
7
+ Subagent mode is now set up from inside Pi with one slash command. Before, `/orch-mode subagent` only saved the mode and printed `NEXT run orch setup --mode subagent`, which you had to run in a separate, normal terminal. Now the slash command does that work itself.
8
+
9
+ Example: in Pi you type `/orch-mode subagent`. Pi shows
10
+
11
+ ```
12
+ mode: subagent (saved in ~/.config/herdr-orchestra/config.json)
13
+ WROTE ~/.pi/agent/agents/coder.md (model: the same as the lead)
14
+ WROTE ~/.pi/agent/agents/reviewer.md (model: the same as the lead)
15
+ INSTALLED npm:@tintinweb/pi-subagents: ...
16
+ Done: subagent mode is ready. Plan with /orch-plan as usual.
17
+ ```
18
+
19
+ then reloads itself so the `Agent` tool is there. Type `/orch-plan` next. No terminal needed.
20
+
21
+ ### Changed
22
+ - **`/orch-mode subagent` sets subagent mode up.** It runs `orch setup --mode subagent` (saves the mode, writes the coder and reviewer agent files, runs `pi install npm:@tintinweb/pi-subagents`). When the `orch` command is missing or older than the Pi package, it runs this package's installer with `--mode subagent` instead, which does the same after installing `orch`. When pi-subagents was just installed, Pi reloads by itself (`ctx.reload()`), so there is no restart either. If a step fails (no `pi` on PATH, a model the policy denies), it says what failed and to type `/orch-mode subagent` again after fixing it. `/orch-mode panes` is unchanged.
23
+ - **`/orch-setup --mode subagent`** (or `/orch-setup subagent`) installs `orch` and sets subagent mode up in one go. `/orch-setup` alone still installs `orch` and, when the saved mode is subagent, sets it up too.
24
+ - The terminal stays supported: `orch setup --mode subagent` works as before; its `NEXT` and `INSTALLED` lines now mention the Pi slash command. The subagent playbook tells the lead to point the developer at `/orch-mode subagent` when the `Agent` tool is missing.
25
+
5
26
  ## [6.4.0] - 2026-11-21
6
27
 
7
28
  At the end of a run, the things you should try by hand now come to you as a plain numbered list: `orch finish` prints them, and the lead posts them in its chat. Nothing else changes: the lead writes the same "Manual verification checklist" in the summary as before, and orch reads it from there.
package/README.md CHANGED
@@ -265,13 +265,15 @@ Runs have two modes. Nothing changes for anyone who never picks the second one.
265
265
  | `panes` (default) | herdr panes, as described above | the event manager; the lead dispatches and pauses |
266
266
  | `subagent` | inside one Pi window, as Pi subagents ([pi-subagents](https://www.npmjs.com/package/@tintinweb/pi-subagents)) | the lead, one milestone at a time |
267
267
 
268
- Switch with `/orch-mode subagent` in Pi, or `orch mode subagent` in a terminal; `/orch-mode` alone shows the mode, and Pi's footer shows it too (`orch: subagent`). The choice is saved in `~/.config/herdr-orchestra/config.json`, and a run keeps the mode it was planned in. Set up subagent mode once:
268
+ Switch with `/orch-mode subagent` in Pi; `/orch-mode` alone shows the mode, and Pi's footer shows it too (`orch: subagent`). The choice is saved in `~/.config/herdr-orchestra/config.json`, and a run keeps the mode it was planned in.
269
+
270
+ `/orch-mode subagent` also sets subagent mode up, right there in Pi, with no terminal step: it installs the `orch` command if it is missing or old, writes the coder and reviewer agents, installs pi-subagents, and reloads Pi so the `Agent` tool is ready. It ends with `Done: subagent mode is ready.` `/orch-setup --mode subagent` does the same. From a normal terminal (no Pi open), the same setup is:
269
271
 
270
272
  ```bash
271
273
  orch setup --mode subagent # or: npx herdr-orchestra@latest --mode subagent, or orch team up --mode subagent
272
274
  ```
273
275
 
274
- It writes `~/.pi/agent/agents/coder.md` and `reviewer.md` (the reviewer cannot edit files) and installs `npm:@tintinweb/pi-subagents`. Pick their models in the config file; with none, they use the lead's model. A model the policy denies is refused, and a file you edited yourself (without orch's line in it) is left alone.
276
+ Setup writes `~/.pi/agent/agents/coder.md` and `reviewer.md` (the reviewer cannot edit files) and installs `npm:@tintinweb/pi-subagents`. Pick their models in the config file; with none, they use the lead's model. A model the policy denies is refused, and a file you edited yourself (without orch's line in it) is left alone.
275
277
 
276
278
  ```json
277
279
  {
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.4.0
1
+ 6.5.0
@@ -119,4 +119,4 @@ skills_dirs = ["~/.agents/skills"]
119
119
  skills_reads = ["~/.pi/agent/skills", "~/.agents/skills"]
120
120
  invoke = "/skill:orch-plan <feature>"
121
121
  verified = false
122
- notes = "Pi (pi.dev, npm @earendil-works/pi-coding-agent 1.6): `pi install npm:herdr-orchestra` adds the orch skills and the orch-mode extension (/orch-mode, /orch-setup). Pi also reads ~/.agents/skills, so it may warn once that orch-plan / orch-run are found twice; it keeps the first copy. Docs list `--model`; herdr detection of Pi is unverified, so orch relies on the done file in panes mode. Subagent mode (one Pi window): `orch setup --mode subagent`."
122
+ notes = "Pi (pi.dev, npm @earendil-works/pi-coding-agent 1.6): `pi install npm:herdr-orchestra` adds the orch skills and the orch-mode extension (/orch-mode, /orch-setup). Pi also reads ~/.agents/skills, so it may warn once that orch-plan / orch-run are found twice; it keeps the first copy. Docs list `--model`; herdr detection of Pi is unverified, so orch relies on the done file in panes mode. Subagent mode (one Pi window): `/orch-mode subagent` in Pi sets it up (or `orch setup --mode subagent` in a terminal)."
Binary file
package/bin/orch CHANGED
@@ -7450,7 +7450,8 @@ def pi_setup():
7450
7450
  except (OSError, subprocess.TimeoutExpired) as e:
7451
7451
  ok, out = False, str(e)
7452
7452
  if ok:
7453
- print(f"INSTALLED {PI_SUBAGENTS}: restart Pi (or /reload) so it loads the Agent tool")
7453
+ print(f"INSTALLED {PI_SUBAGENTS}: restart Pi (or /reload) so it loads the Agent tool "
7454
+ f"(/orch-mode subagent in Pi reloads it for you)")
7454
7455
  return problems
7455
7456
  print(f"FAILED pi install {PI_SUBAGENTS}:\n" + "\n".join(out.splitlines()[-10:])
7456
7457
  + f"\n run it yourself: pi install {PI_SUBAGENTS}")
@@ -7511,8 +7512,8 @@ def set_mode(mode, hint=True):
7511
7512
  if mode == "subagent" and hint:
7512
7513
  missing = [r for r in ("coder", "reviewer") if not (pi_agents_dir() / f"{r}.md").exists()]
7513
7514
  if missing:
7514
- print(f"NEXT run `orch setup --mode subagent`: it writes the {' and '.join(missing)} agent file(s) "
7515
- f"and installs pi-subagents")
7515
+ print(f"NEXT run `orch setup --mode subagent` (in Pi, `/orch-mode subagent` does it for you): it writes "
7516
+ f"the {' and '.join(missing)} agent file(s) and installs pi-subagents")
7516
7517
 
7517
7518
 
7518
7519
  SUBAGENT_PLAN_NOTE = """SUBAGENT MODE (Pi, one window). This replaces every herdr step below:
@@ -9,9 +9,14 @@
9
9
  // Where the mode comes from: this repo's run (.orchestrate/state.json, `orch_mode`; a run from before 6.2.0 is
10
10
  // panes), else ~/.config/herdr-orchestra/config.json (`mode`), else panes.
11
11
  //
12
- // Commands: /orch-mode [panes|subagent] show or switch the mode
13
- // /orch-setup install the `orch` command from this package (needed once)
14
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
12
+ // Commands: /orch-mode [panes|subagent] show or switch the mode; `subagent` also sets it up (below)
13
+ // /orch-setup [--mode panes|subagent] install the `orch` command from this package (needed once)
14
+ //
15
+ // Subagent mode is set up from inside Pi, with no terminal step: `/orch-mode subagent` runs
16
+ // `orch setup --mode subagent` (or this package's installer when orch is missing or old), which writes
17
+ // ~/.pi/agent/agents/coder.md and reviewer.md and runs `pi install npm:@tintinweb/pi-subagents`. When that install
18
+ // is new, the command reloads Pi (ctx.reload) so the Agent tool is there at once.
19
+ import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
15
20
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
16
21
  import { homedir } from "node:os";
17
22
  import { dirname, join, resolve } from "node:path";
@@ -20,6 +25,8 @@ import { fileURLToPath } from "node:url";
20
25
  type Mode = "panes" | "subagent";
21
26
  const MODES: Mode[] = ["panes", "subagent"];
22
27
  const STATUS_KEY = "orch";
28
+ /** `orch setup` result lines (bin/orch pi_setup and set_mode). */
29
+ const SETUP_LINE = /^(WROTE|ok |KEPT|REFUSED|NO PI|INSTALL|INSTALLED|FAILED|mode:|mode panes:|this repo|NOT CHANGED|run it yourself)/;
23
30
 
24
31
  function packageRoot(): string {
25
32
  const here = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
@@ -149,8 +156,65 @@ export default function orchMode(pi: ExtensionAPI) {
149
156
  return { systemPrompt: `${event.systemPrompt}\n\n${line}` };
150
157
  });
151
158
 
159
+ /** Lines worth showing from installer / `orch setup` output (both can be long). */
160
+ function keyLines(out: string, extra: RegExp): string {
161
+ return out
162
+ .replace(/\x1b\[[0-9;]*m/g, "")
163
+ .split("\n")
164
+ .map((l) => l.trimEnd())
165
+ .filter((l) => extra.test(l.trim()) || SETUP_LINE.test(l.trim()))
166
+ .slice(-16)
167
+ .join("\n");
168
+ }
169
+
170
+ /** Run the installer (always with install=true; also when orch is missing or older than this package), else
171
+ * `orch setup --mode subagent`; then reload Pi when pi-subagents was just installed. Returns true when Pi is reloading (the caller must return at once). */
172
+ async function setUp(ctx: ExtensionCommandContext, want: Mode | undefined, install: boolean): Promise<boolean> {
173
+ const o = await orchState(pi);
174
+ let r: { stdout: string; stderr: string; code: number };
175
+ let shown: string;
176
+ if (!install && o.state === "ok" && want === "subagent") {
177
+ ctx.ui.notify("Setting up subagent mode: the coder and reviewer agents, and pi-subagents (can take a minute)...", "info");
178
+ r = await pi.exec(o.path!, ["setup", "--mode", "subagent"], { cwd: ctx.cwd, timeout: 600000 });
179
+ shown = keyLines(r.stdout + r.stderr, /^$/);
180
+ } else {
181
+ const installer = join(packageRoot(), "install.sh");
182
+ if (!existsSync(installer)) {
183
+ ctx.ui.notify(`install.sh not found next to this extension (${installer}). Run: npx herdr-orchestra@latest`, "error");
184
+ return false;
185
+ }
186
+ ctx.ui.notify(
187
+ "Installing herdr-orchestra (orch)" + (want === "subagent" ? " and setting up subagent mode" : "") + "...",
188
+ "info",
189
+ );
190
+ // ORCH_TTY=/dev/null: the installer must not read Pi's terminal. An unanswered auto-update question gets the
191
+ // installer's default (on); the output says how to turn it off (`orch config auto-update off`).
192
+ const args = ["ORCH_PACKAGE=1", "ORCH_TTY=/dev/null", "bash", installer, ...(want ? ["--mode", want] : [])];
193
+ r = await pi.exec("env", args, { cwd: ctx.cwd, timeout: 600000 });
194
+ shown = keyLines(r.stdout + r.stderr, /^(==>|warn:|error:)|auto-update|is active/);
195
+ }
196
+ const out = (r.stdout + r.stderr).replace(/\x1b\[[0-9;]*m/g, "");
197
+ // the installer only warns when its `orch setup` step fails, so look at orch's own lines too
198
+ const ok = r.code === 0 && !/^(FAILED|REFUSED|NO PI)\b|orch setup --mode \S+ did not finish/m.test(out);
199
+ mode = (await readMode(pi, ctx.cwd)).mode;
200
+ showStatus(ctx, mode);
201
+ if (want === "subagent" && ok) {
202
+ shown += "\nDone: subagent mode is ready. Plan with /orch-plan as usual.";
203
+ } else if (want === "subagent") {
204
+ shown += "\nSubagent setup is not finished: fix what it says above, then type /orch-mode subagent again.";
205
+ }
206
+ ctx.ui.notify(shown.trim() || (ok ? "Installed." : "The installer failed."), ok ? "info" : "error");
207
+ if (ok && /^INSTALLED\s+npm:@tintinweb\/pi-subagents/m.test(out)) {
208
+ // pi-subagents is new: reload so its Agent tool is loaded now, not after a restart.
209
+ ctx.ui.notify("Reloading Pi so the new Agent tool loads...", "info");
210
+ await ctx.reload();
211
+ return true;
212
+ }
213
+ return false;
214
+ }
215
+
152
216
  pi.registerCommand("orch-mode", {
153
- description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window)",
217
+ description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window, set up for you)",
154
218
  getArgumentCompletions: (prefix: string) =>
155
219
  MODES.filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
156
220
  handler: async (args, ctx) => {
@@ -167,6 +231,15 @@ export default function orchMode(pi: ExtensionAPI) {
167
231
  ctx.ui.notify(`Unknown mode "${want}". Use /orch-mode panes or /orch-mode subagent.`, "error");
168
232
  return;
169
233
  }
234
+ if (next === "subagent") {
235
+ // `orch setup --mode subagent` saves the mode (and this repo's run, when nothing is in progress) and sets it up
236
+ if (await setUp(ctx, "subagent", false)) return;
237
+ const now = await readMode(pi, ctx.cwd);
238
+ if (now.mode !== next) {
239
+ ctx.ui.notify(`This repo's run stays ${now.mode} (something is in progress). New runs use ${next}.`, "warning");
240
+ }
241
+ return;
242
+ }
170
243
  const o = await orchState(pi);
171
244
  const orch = o.state === "ok" ? o.path : undefined;
172
245
  if (orch) {
@@ -197,28 +270,20 @@ export default function orchMode(pi: ExtensionAPI) {
197
270
  });
198
271
 
199
272
  pi.registerCommand("orch-setup", {
200
- description: "Install the herdr-orchestra `orch` command from this package (and, in subagent mode, its Pi subagents)",
201
- handler: async (_args, ctx) => {
202
- const installer = join(packageRoot(), "install.sh");
203
- if (!existsSync(installer)) {
204
- ctx.ui.notify(`install.sh not found next to this extension (${installer}). Run: npx herdr-orchestra@latest`, "error");
273
+ description: "Install the herdr-orchestra `orch` command from this package; --mode subagent also sets up its Pi subagents",
274
+ getArgumentCompletions: (prefix: string) =>
275
+ ["--mode panes", "--mode subagent"].filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
276
+ handler: async (args, ctx) => {
277
+ const words = args.trim().toLowerCase().split(/\s+/).filter(Boolean);
278
+ if (words[0] === "--mode") words.shift();
279
+ const named = words.length ? asMode(words[0]) : undefined;
280
+ if (words.length > 1 || (words.length && !named)) {
281
+ ctx.ui.notify("Usage: /orch-setup [--mode panes|subagent]", "error");
205
282
  return;
206
283
  }
207
- const cur = await readMode(pi, ctx.cwd);
208
- ctx.ui.notify("Installing herdr-orchestra (orch)...", "info");
209
- // ORCH_TTY=/dev/null: the installer must not read Pi's terminal. An unanswered auto-update question gets the
210
- // installer's default (on); the output says how to turn it off (`orch config auto-update off`).
211
- const args = ["ORCH_PACKAGE=1", "ORCH_TTY=/dev/null", "bash", installer, ...(cur.mode === "subagent" ? ["--mode", "subagent"] : [])];
212
- const r = await pi.exec("env", args, { cwd: ctx.cwd, timeout: 600000 });
213
- const tail = (r.stdout + r.stderr)
214
- .replace(/\x1b\[[0-9;]*m/g, "")
215
- .split("\n")
216
- .filter((l) => /^(==>|warn:|error:)|auto-update|is active/.test(l.trim()))
217
- .slice(-12)
218
- .join("\n");
219
- ctx.ui.notify(tail || (r.code === 0 ? "Installed." : "The installer failed."), r.code === 0 ? "info" : "error");
220
- mode = (await readMode(pi, ctx.cwd)).mode;
221
- showStatus(ctx, mode);
284
+ // No mode named: the saved one (in subagent mode the installer sets the agents up again, which is harmless)
285
+ const want = named ?? ((await readMode(pi, ctx.cwd)).mode === "subagent" ? "subagent" : undefined);
286
+ await setUp(ctx, want, true);
222
287
  },
223
288
  });
224
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp, Pi) as one team: a lead plans, coders build, a reviewer checks, you get one PR. Runs in Herdr panes, or in one Pi window with subagents.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -16,7 +16,7 @@ There is no event manager and there are no herdr panes. You drive one milestone
16
16
  ## 1. Start the run (the developer said go)
17
17
  1. Run `orch sync`. Stop on ERROR; report every WARN except the ones about Workers naming no model (the subagents run on the models in `~/.config/herdr-orchestra/config.json`).
18
18
  2. Run `orch start` (it makes or switches to the feature branch).
19
- 3. Check that the `Agent` tool is available to you. If it is not, tell the developer to run `orch setup --mode subagent` and restart Pi, and **STOP**.
19
+ 3. Check that the `Agent` tool is available to you. If it is not, tell the developer to type `/orch-mode subagent` in Pi (it sets up the subagents and reloads Pi; outside Pi: `orch setup --mode subagent`, then restart Pi), and **STOP**.
20
20
 
21
21
  ## 2. One milestone
22
22
  1. Run `orch sub next`. It prints `NEXT Mn: <title>`, `TASK <path to task.md>` and `REVIEW yes|no`. (`CURRENT Mn` means a milestone was started and not saved: carry on with it from step 2. `HELD`, `WAITING` or `ALL_DONE`: see below.)