herdr-orchestra 6.6.0 → 6.7.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.
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.7.1] - 2026-11-23
6
+
7
+ Pi now gets everything from 6.6.0 without a manual step. Pi's `/orch-plan` already ran the same `orch lead plan`, so the lead there asks first, writes `Door:` lines and new glossary words like everywhere else; its task files already had the project rules and the proof request; and a hard-to-undo milestone was already held. What was missing: the reviewer and coder subagent files written by an older orch kept their old text until you re-ran `orch setup --mode subagent`. This also brings in the 6.7.0 agent text (descriptions that say "only for orch runs", the reviewer's `disallowed_tools`) with no step from you.
8
+
9
+ ### Fixed
10
+ - **Pi subagents refresh themselves.** In subagent mode, `orch lead run` and `orch sub next` rewrite `~/.pi/agent/agents/reviewer.md` and `coder.md` when orch wrote them and their text is from an older orch, so the reviewer asks the two questions (`[spec]` and `[rules: …]`) and the coder writes its `PROOF:` line. They print `UPDATED <file>` when they do. A file you edited yourself (the orch line removed) is never touched. Restart Pi if a subagent it already started should use the new text.
11
+ - Tests check that Pi's `orch-plan` skill stays the same as the main one, and run the 6.6.0 features in subagent mode.
12
+
13
+ ## [6.7.0] - 2026-11-22
14
+
15
+ The coder and reviewer agents now follow Claude Code's subagent guide (code.claude.com/docs/en/sub-agents): each agent does one job, has only the tools that job needs, and has a description that names exactly when to use it.
16
+
17
+ Example: your reviewer pane is Claude Code. `orch team up` now starts it as `claude --permission-mode acceptEdits --disallowedTools Edit,NotebookEdit --model opus`, so it can read the change and write its review file, but it cannot "just fix" the code itself and slip an unreviewed change into the milestone. In Pi subagent mode, asking Pi "fix this typo" in a normal chat no longer starts orch's `coder`: its description now says it is only for orch runs.
18
+
19
+ ### Added
20
+ - **Read-only Claude reviewer.** New optional registry key `review_launch`: the command for the reviewer pane. Claude Code's turns off `Edit` and `NotebookEdit` (it keeps `Write` for its review file). `orch team up` uses it for the reviewer, the "start it yourself" hints after a restart show it, `orch agents launch <kind> --role reviewer` prints it, and `orch doctor` checks its flags too. A kind without it starts its reviewer like a coder, as before. If your own `agents.toml` sets `launch` for a kind but no `review_launch`, your `launch` is used for the reviewer too.
21
+ - **Pi subagents: `max_turns`.** `"max_turns": 80` under `subagent.coder` or `subagent.reviewer` in `~/.config/herdr-orchestra/config.json` stops a looping subagent after that many turns. The subagent playbook tells the lead to resume a coder that stopped early once, then ask you. Not set: no limit, as before.
22
+
23
+ ### Changed
24
+ - **Pi subagent descriptions** say they are only for herdr-orchestra runs, so Pi does not pick `coder` or `reviewer` for other work. The Pi reviewer also lists `disallowed_tools: edit, write`, so an extension's edit tool cannot reach it either. Run `orch setup --mode subagent` (or `/orch-mode subagent` in Pi) to refresh the two agent files.
25
+
5
26
  ## [6.6.0] - 2026-11-22
6
27
 
7
28
  Three upgrades that make plans and reviews follow your project, and show you where the risk is. Each one stays out of the way when you don't use it: a repo without the new files, and a plan without the new lines, run exactly as before.
@@ -10,7 +31,7 @@ Example: you ask for "add discounts to orders". The lead reads the code and your
10
31
 
11
32
  ### Added
12
33
  - **House rules.** Optional files in your repo: `docs/glossary.md` (your words, and words to avoid: `- **Discount**: money off an order total. Avoid: coupon, promo`), `docs/adr/*.md` (decisions already made) and `docs/coding-standards.md`. Each coder's task file gets a short "Project rules" block: only the glossary words its milestone uses (orch matches the words, so a long glossary costs nothing extra), one line per decision, and where the coding rules are. task.json lists them under `project_rules`. The plan header `Docs: <folder>` names another folder.
13
- - **Two-question review.** The reviewer answers separately: `spec` (did it build what was asked, no more and no less? orch tells it which files changed outside Likely files) and `rules` (does it follow the repo's written rules? it names the rule). It is told not to report what the check command already catches. `review-N.json` findings get `axis` and `rule` (both optional: older reviews read as before). Blocker and suggestion lines carry `[spec]` or `[rules: <rule>]`. The summary has "Review findings: spec and rules" with the rules broken most often, and `orch report` (and `--json`) counts them. Pi subagent mode's reviewer gets the same two questions (run `orch setup --mode subagent` to refresh its agent file).
34
+ - **Two-question review.** The reviewer answers separately: `spec` (did it build what was asked, no more and no less? orch tells it which files changed outside Likely files) and `rules` (does it follow the repo's written rules? it names the rule). It is told not to report what the check command already catches. `review-N.json` findings get `axis` and `rule` (both optional: older reviews read as before). Blocker and suggestion lines carry `[spec]` or `[rules: <rule>]`. The summary has "Review findings: spec and rules" with the rules broken most often, and `orch report` (and `--json`) counts them. Pi subagent mode's reviewer gets the same two questions.
14
35
  - **Lead asks first.** Plan playbook step 2a: after research and before any plan, the lead asks what only you can decide, all in one message, each question with 2 or 3 choices and its own suggestion, then waits. No questions when the code settles everything. Start a request with `grill:` for one question at a time. Your answers go into the plan where they apply. The questions are kept in `.orchestrate/questions.md`, and `orch lead run` refuses to start a run from an older plan while they are unanswered (your answer is planning, not "go").
15
36
  - **New words and decisions get written down.** A plan can list `## Glossary additions`; the milestone that brings the word (or a hard-to-change decision, as `docs/adr/NNNN-*.md`) writes it, through an acceptance criterion. `orch sync` warns when the plan uses a word the glossary says to avoid, when a new word has no milestone with `docs/glossary.md` in its Likely files, and when an acceptance criterion names a glossary or decision file that is not in the milestone's Likely files. `orch plan show` lists the new words.
16
37
  - **Risky-change label.** `Door: one-way (why)` on a milestone that is hard to undo once it runs (a migration on real data, a public API others call, deleting data, sending emails). It always waits for your `orch approve`, even when no file looks risky, and its coder is asked for proof (`proof` in the result file, or a `PROOF:` report line). `Risk hold: off` still turns every hold off (`orch sync` warns). A quick run is never one-way (`orch sync` refuses it).
package/README.md CHANGED
@@ -128,9 +128,9 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
128
128
  | Lead | any agent, e.g. `claude` or `opencode` | `lead` (the playbook does it) |
129
129
  | Coder (medium work) | `claude --permission-mode acceptEdits --model sonnet` | `claude-1` |
130
130
  | Coder (small work) | `claude --permission-mode acceptEdits --model haiku` | `claude-2` |
131
- | Reviewer (optional) | `claude --model opus`, `agy --mode accept-edits` or a spare agent | `reviewer` |
131
+ | Reviewer (optional) | `claude --permission-mode acceptEdits --disallowedTools Edit,NotebookEdit --model opus`, `agy --mode accept-edits` or a spare agent | `reviewer` |
132
132
 
133
- `orch agents launch <kind> --model <id>` prints the command with the model; `orch models` lists the models and their tiers. Use whatever your installed agents already reach.
133
+ `orch agents launch <kind> --model <id>` prints the command with the model (`--role reviewer` gives the reviewer's command: for Claude Code its edit tools are off, it only reads the change and writes its review file); `orch models` lists the models and their tiers. Use whatever your installed agents already reach.
134
134
 
135
135
  **Only one tool installed, or just one window open?** Open only the lead and start the plan playbook. The lead sees it is alone and builds the team from its own tool: `orch team codex` picks coders and a reviewer of that tool on the models the catalog allows, spread over its tiers, and the lead writes them into the plan. When you say go, `orch team up` opens their panes next to the lead, each in its own folder and on its model, and names them. You never type either command yourself (you can: `orch team codex --coders 1`, `orch team up --dry-run`). Each pane is a separate session of the same tool, on your existing login.
136
136
 
@@ -208,6 +208,7 @@ The skills and slash commands are thin wrappers: the playbooks themselves live i
208
208
  ```toml
209
209
  [claude]
210
210
  launch = "claude --permission-mode acceptEdits"
211
+ review_launch = "claude --permission-mode acceptEdits --disallowedTools Edit,NotebookEdit" # the reviewer pane
211
212
  model_flag = "--model" # what `orch agents launch claude --model <id>` appends
212
213
 
213
214
  [myagent] # a new kind
@@ -218,7 +219,7 @@ roles = ["coder"]
218
219
  skills_dirs = ["~/.myagent/skills"]
219
220
  ```
220
221
 
221
- `orch doctor [kind]` checks an installed agent against the real tool (version, whether the launch flags still exist in its `--help`, skills, herdr detection). `orch agents launch <kind>` prints the command · `orch team <kind>` / `orch team up` build and open a whole team from one tool · `orch agents sync` installs the skills for every installed agent (run it after adding a new one) · `orch agents check` confirms every installed agent sees each skill exactly once (not missing, not twice). Many tools read more than one folder (Codex reads `~/.agents/skills` and `~/.codex/skills` and lists a skill found in both twice), so the installer writes the fewest folders that give each installed agent one copy, e.g. with Claude, Codex and OpenCode: `~/.claude/skills` (Claude) and `~/.agents/skills` (Codex; OpenCode reads both, and its docs say one copy wins). Claude Code gets the skill only (a skill is already the `/orch-plan` command); OpenCode gets slash commands in `~/.config/opencode/commands`.
222
+ `orch doctor [kind]` checks an installed agent against the real tool (version, whether the launch flags still exist in its `--help`, skills, herdr detection; the `review_launch` flags too). `orch agents launch <kind>` prints the command · If you set your own `launch` for a kind and no `review_launch`, your `launch` is used for the reviewer too · `orch team <kind>` / `orch team up` build and open a whole team from one tool · `orch agents sync` installs the skills for every installed agent (run it after adding a new one) · `orch agents check` confirms every installed agent sees each skill exactly once (not missing, not twice). Many tools read more than one folder (Codex reads `~/.agents/skills` and `~/.codex/skills` and lists a skill found in both twice), so the installer writes the fewest folders that give each installed agent one copy, e.g. with Claude, Codex and OpenCode: `~/.claude/skills` (Claude) and `~/.agents/skills` (Codex; OpenCode reads both, and its docs say one copy wins). Claude Code gets the skill only (a skill is already the `/orch-plan` command); OpenCode gets slash commands in `~/.config/opencode/commands`.
222
223
 
223
224
  ### Agents herdr can't watch
224
225
  For a kind with `herdr_detect = false` (or one missing from the registry, which `orch sync` warns about), `orch` relies only on the **done file and the time budget**: it never reports GONE, BLOCKED or IDLE for it, treats it as free whenever it has no task, and `orch status` marks it `detect:off`. If herdr doesn't recognise the pane as an agent at all, address it by pane id: `Workers: hermes-1 (hermes @pane:w1:p3)`. `orch` then types prompts into that pane, and `orch start` reports a `STALE pane` when the id has changed (`herdr pane list` shows the current ids).
@@ -273,13 +274,13 @@ Switch with `/orch-mode subagent` in Pi; `/orch-mode` alone shows the mode, and
273
274
  orch setup --mode subagent # or: npx herdr-orchestra@latest --mode subagent, or orch team up --mode subagent
274
275
  ```
275
276
 
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.
277
+ 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. `max_turns` (optional) stops a subagent that loops after that many turns; the lead then resumes it once or asks you. A model the policy denies is refused, and a file you edited yourself (without orch's line in it) is left alone. Both agents' descriptions say they are only for orch runs, so a normal Pi chat does not hand its own work to them.
277
278
 
278
279
  ```json
279
280
  {
280
281
  "mode": "subagent",
281
282
  "subagent": {
282
- "coder": { "model": "anthropic/claude-sonnet-4-5", "thinking": "medium" },
283
+ "coder": { "model": "anthropic/claude-sonnet-4-5", "thinking": "medium", "max_turns": 80 },
283
284
  "reviewer": { "model": "openai/gpt-5", "thinking": "high" }
284
285
  }
285
286
  }
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.6.0
1
+ 6.7.1
@@ -3,6 +3,9 @@
3
3
  #
4
4
  # binary executable that must be on PATH for the kind to count as installed
5
5
  # launch command to start it in a herdr pane, with its auto-approve-edits option
6
+ # review_launch optional: the command for the REVIEWER pane, with the tool's code-editing tools turned off (the
7
+ # reviewer only reads the change and writes its review file). `orch team up` uses it for the reviewer;
8
+ # `orch agents launch <kind> --role reviewer` prints it. Left out: the reviewer starts like a coder
6
9
  # model_flag the launch option that picks the model (`orch agents launch <kind> --model <id>`); leave it
7
10
  # out when the tool has none or it is unverified, and choose the model inside the tool
8
11
  # herdr_detect herdr can tell idle / working / blocked for it (false: orch relies on the done file only)
@@ -32,6 +35,7 @@
32
35
  [claude]
33
36
  binary = "claude"
34
37
  launch = "claude --permission-mode acceptEdits"
38
+ review_launch = "claude --permission-mode acceptEdits --disallowedTools Edit,NotebookEdit"
35
39
  model_flag = "--model"
36
40
  herdr_detect = true
37
41
  interrupt_keys = ["esc"]
@@ -41,7 +45,7 @@ skills_one_wins = true
41
45
  old_dirs = ["~/.claude/commands"]
42
46
  invoke = "/orch-plan <feature>"
43
47
  verified = true
44
- notes = "Claude Code 2.1: --permission-mode acceptEdits in --help; ~/.claude/skills present; herdr kind 'claude'. A skill is also a slash command (/orch-plan) and its docs say a skill beats a ~/.claude/commands file of the same name, so no commands copy is installed."
48
+ notes = "Claude Code 2.1: --permission-mode acceptEdits in --help; ~/.claude/skills present; herdr kind 'claude'. A skill is also a slash command (/orch-plan) and its docs say a skill beats a ~/.claude/commands file of the same name, so no commands copy is installed. review_launch: --disallowedTools is in --help (2.1); the reviewer keeps Write for its review file."
45
49
 
46
50
  [codex]
47
51
  binary = "codex"
Binary file
package/bin/orch CHANGED
@@ -734,6 +734,8 @@ def registry(required=True):
734
734
  if uf.exists():
735
735
  for kind, vals in tomllib.loads(uf.read_text()).items():
736
736
  if isinstance(vals, dict):
737
+ if "launch" in vals and "review_launch" not in vals:
738
+ reg.get(kind, {}).pop("review_launch", None) # your own launch command wins for the reviewer too
737
739
  reg.setdefault(kind, {}).update(vals)
738
740
  except tomllib.TOMLDecodeError as e:
739
741
  die(f"agent registry: {e}")
@@ -6132,10 +6134,11 @@ def cmd_report(args):
6132
6134
  print(f" rule broken {n}x: {r}")
6133
6135
 
6134
6136
 
6135
- def launch_cmd(kind, v, model=None, strict=True):
6137
+ def launch_cmd(kind, v, model=None, strict=True, role=None):
6136
6138
  """The shell command that starts agent `kind` in a pane, on `model` when given. With strict=False a kind
6137
- without a model_flag starts on its default model instead of failing (the caller says so)."""
6138
- cmd = v.get("launch") or v.get("binary", kind)
6139
+ without a model_flag starts on its default model instead of failing (the caller says so). role="reviewer"
6140
+ uses the kind's `review_launch` when it has one: the same tool with its code-editing tools turned off."""
6141
+ cmd = (v.get("review_launch") if role == "reviewer" else None) or v.get("launch") or v.get("binary", kind)
6139
6142
  if model:
6140
6143
  cat = models_catalog()
6141
6144
  why = model_denied(cat, model)
@@ -6302,7 +6305,7 @@ def team_up(args):
6302
6305
  print(f"SKIP {name}: kind {kind!r} is not in the agent registry — start it yourself in {d}")
6303
6306
  failed += 1
6304
6307
  continue
6305
- cmd = launch_cmd(kind, v, model, strict=False)
6308
+ cmd = launch_cmd(kind, v, model, strict=False, role="reviewer" if name == st.get("reviewer") else None)
6306
6309
  split = [HERDR, "pane", "split"] + ([last] if last else []) + \
6307
6310
  ["--direction", "down" if last else "right", "--cwd", d, "--no-focus"]
6308
6311
  if dry:
@@ -6474,7 +6477,9 @@ def rename_lost(st, hints=True, keep_out=()):
6474
6477
  continue
6475
6478
  still[n] = pick if own else None
6476
6479
  v = reg.get(w.get("kind"))
6477
- cmd = launch_cmd(w.get("kind"), v, w.get("model"), strict=False) if v else (w.get("kind") or "<its agent>")
6480
+ cmd = (launch_cmd(w.get("kind"), v, w.get("model"), strict=False,
6481
+ role="reviewer" if n == st.get("reviewer") else None)
6482
+ if v else (w.get("kind") or "<its agent>"))
6478
6483
  say(f"LOST {n}: pane {pick} is in its folder ({short(d)}), but herdr sees no agent running in it. "
6479
6484
  + (f"`orch team up` starts it there; or start it yourself (`{cmd}`)" if own else
6480
6485
  f"Start it there (`{cmd}`)") + f", then: herdr agent rename {pick} {n}")
@@ -6613,7 +6618,8 @@ USAGE = """usage: orch <command> [args]
6613
6618
  setup [--mode panes|subagent] get this machine ready for a mode; subagent: write ~/.pi/agent/agents/coder.md and
6614
6619
  reviewer.md from ~/.config/herdr-orchestra/config.json and install pi-subagents
6615
6620
  agents the agent registry: kinds, installed?, roles, herdr detection, launch commands
6616
- agents launch <kind> [--model <id>] print the command that starts <kind> in a pane (auto-approve edits)
6621
+ agents launch <kind> [--model <id>] [--role reviewer] print the command that starts <kind> in a pane
6622
+ (auto-approve edits; --role reviewer: its read-only reviewer command when it has one)
6617
6623
  models the model catalog: tiers (small / medium / high), ratings, and what policy forbids
6618
6624
  models show|check <id> one model's ratings and evidence / is it allowed?
6619
6625
  resume after a restart (computer off, herdr closed): name the agents' panes again, save unsaved
@@ -6902,6 +6908,7 @@ def cmd_lead(args):
6902
6908
  label = f"{sub} ({part})" if part else sub
6903
6909
  subagent = current_mode()[0] == "subagent"
6904
6910
  if subagent and sub == "run":
6911
+ pi_agents_refresh()
6905
6912
  pb = asset("playbooks/subagent.md") or die("playbooks/subagent.md not found next to orch or in the install")
6906
6913
  label = "run (subagent mode)"
6907
6914
  print(f"herdr-orchestra {installed_version()} — lead playbook: {label}\n")
@@ -7203,15 +7210,22 @@ def cmd_agents(args):
7203
7210
  installed = {k: bool(shutil.which(v.get("binary", k))) for k, v in reg.items()}
7204
7211
  if sub == "launch":
7205
7212
  rest = args[1:]
7206
- model = None
7213
+ model, role = None, None
7214
+ use = "usage: orch agents launch <kind> [--model <id>] [--role coder|reviewer]"
7207
7215
  if "--model" in rest:
7208
7216
  i = rest.index("--model")
7209
- model = rest[i + 1] if len(rest) > i + 1 else die("usage: orch agents launch <kind> [--model <id>]")
7217
+ model = rest[i + 1] if len(rest) > i + 1 else die(use)
7210
7218
  del rest[i:i + 2]
7211
- kind = rest[0] if rest else die("usage: orch agents launch <kind> [--model <id>]")
7219
+ if "--role" in rest:
7220
+ i = rest.index("--role")
7221
+ role = rest[i + 1] if len(rest) > i + 1 else die(use)
7222
+ if role not in ("coder", "reviewer", "lead"):
7223
+ die(f"--role must be coder, reviewer or lead, got {role!r} — {use}")
7224
+ del rest[i:i + 2]
7225
+ kind = rest[0] if rest else die(use)
7212
7226
  v = reg.get(kind) or die(f"unknown agent kind {kind!r} — known: {', '.join(reg)} "
7213
7227
  f"(add it in {user_agents_file()})")
7214
- print(launch_cmd(kind, v, model))
7228
+ print(launch_cmd(kind, v, model, role=role))
7215
7229
  return
7216
7230
  if sub == "dirs": # the folders `orch agents sync` writes: <skills|commands>\t<dir>[\t<commands_from>]
7217
7231
  sdirs, _, cdirs, _ = sync_plan(reg, installed)
@@ -7279,11 +7293,13 @@ def doctor_kind(kind, v, full=True):
7279
7293
  out.append((True, f"version: {first}" if code == 0 and first else f"version: unknown (`{vcmd}` failed)"))
7280
7294
  hcmd = v.get("help_cmd") or f"{binary} --help"
7281
7295
  code, help_ = _probe(hcmd)
7282
- try:
7283
- launch = shlex.split(v.get("launch") or binary)
7284
- except ValueError:
7285
- launch = [binary]
7286
- flags = [tok.split("=")[0] for tok in launch[1:] if tok.startswith("-")]
7296
+ flags = []
7297
+ for key in ("launch", "review_launch"):
7298
+ try:
7299
+ launch = shlex.split(v.get(key) or binary)
7300
+ except ValueError:
7301
+ launch = [binary]
7302
+ flags += [f for f in (tok.split("=")[0] for tok in launch[1:] if tok.startswith("-")) if f not in flags]
7287
7303
  for fl in flags:
7288
7304
  if code is None:
7289
7305
  out.append((False, f"launch flag {fl}: `{hcmd}` did not run ({help_.strip()[:80]})"))
@@ -7784,20 +7800,52 @@ Then one line per acceptance criterion: `AC<n>: met|not met - <evidence>`.
7784
7800
  def pi_agent_text(role, conf):
7785
7801
  """coder.md / reviewer.md for pi-subagents: front matter from the config, then the role's instructions."""
7786
7802
  model, thinking = (conf or {}).get("model"), (conf or {}).get("thinking")
7787
- desc = ("herdr-orchestra coder: builds one milestone from its task file" if role == "coder" else
7788
- "herdr-orchestra reviewer: reviews one milestone, never edits files")
7803
+ turns = (conf or {}).get("max_turns")
7804
+ # One description per agent that names who starts it, so a normal Pi chat never hands its own work to them
7805
+ # (Claude Code's subagent docs: write descriptions that single out one subagent).
7806
+ desc = ("Only for a herdr-orchestra run: the orch lead starts it with one milestone's task file and it builds "
7807
+ "that milestone. Not for other coding work." if role == "coder" else
7808
+ "Only for a herdr-orchestra run: the orch lead starts it to review one milestone. Read-only, never edits "
7809
+ "files. Not for other reviews.")
7789
7810
  fm = [f"name: {role}", f"description: {desc}"]
7790
7811
  if role == "reviewer":
7791
7812
  fm.append("tools: read, bash, grep, find, ls")
7813
+ fm.append("disallowed_tools: edit, write")
7792
7814
  if model:
7793
7815
  fm.append(f"model: {model}")
7794
7816
  if thinking:
7795
7817
  fm.append(f"thinking: {thinking}")
7818
+ if isinstance(turns, int) and not isinstance(turns, bool) and turns > 0:
7819
+ fm.append(f"max_turns: {turns}")
7796
7820
  fm += ["prompt_mode: append", "skills: false", "run_in_background: false"]
7797
7821
  body = PI_CODER_BODY if role == "coder" else PI_REVIEWER_BODY
7798
7822
  return "---\n" + "\n".join(fm) + "\n---\n\n" + PI_AGENT_MARK + "\n\n" + body
7799
7823
 
7800
7824
 
7825
+ def pi_agents_refresh():
7826
+ """Subagent mode: rewrite the coder.md / reviewer.md that orch wrote (they carry PI_AGENT_MARK) when this orch
7827
+ would write them differently, e.g. after an update changed the instructions. A file you edited is left alone,
7828
+ a missing one is left for `orch setup --mode subagent`, and a model the policy denies is never written."""
7829
+ conf = config_load().get("subagent") or {}
7830
+ conf = conf if isinstance(conf, dict) else {}
7831
+ cat = models_catalog()
7832
+ for role in ("coder", "reviewer"):
7833
+ rc = conf.get(role) if isinstance(conf.get(role), dict) else {}
7834
+ p = pi_agents_dir() / f"{role}.md"
7835
+ try:
7836
+ old = p.read_text() if p.exists() else None
7837
+ except OSError:
7838
+ continue
7839
+ if old is None or PI_AGENT_MARK not in old or model_denied(cat, str(rc.get("model") or "").lower() or None):
7840
+ continue
7841
+ text = pi_agent_text(role, rc)
7842
+ if old != text:
7843
+ with contextlib.suppress(OSError):
7844
+ p.write_text(text)
7845
+ print(f"UPDATED {short(p)}: the {role} subagent now has this orch's instructions "
7846
+ f"({installed_version()}); restart Pi if a subagent it already started should use them")
7847
+
7848
+
7801
7849
  def pi_setup():
7802
7850
  """Subagent mode: write ~/.pi/agent/agents/coder.md and reviewer.md from the config, and install pi-subagents.
7803
7851
  Returns the number of problems (0 = ready)."""
@@ -7825,7 +7873,8 @@ def pi_setup():
7825
7873
  p.parent.mkdir(parents=True, exist_ok=True)
7826
7874
  p.write_text(text)
7827
7875
  print(f"WROTE {short(p)} (model: {rc.get('model') or 'the same as the lead'}"
7828
- + (f", thinking: {rc['thinking']}" if rc.get("thinking") else "") + ")")
7876
+ + (f", thinking: {rc['thinking']}" if rc.get("thinking") else "")
7877
+ + (f", max_turns: {rc['max_turns']}" if f"max_turns: {rc.get('max_turns')}" in text else "") + ")")
7829
7878
  pi = shutil.which(pi_bin())
7830
7879
  if not pi:
7831
7880
  print(f"NO PI `{pi_bin()}` is not on PATH. Install Pi (npm install -g @earendil-works/pi-coding-agent), "
@@ -7971,6 +8020,7 @@ def cmd_sub(args):
7971
8020
  subagent_ready_or_die(st)
7972
8021
  coder = next(iter(st["workers"]), None) or die("the plan has no Workers line")
7973
8022
  if sub == "next":
8023
+ pi_agents_refresh() # an update may have changed what the coder and reviewer are told
7974
8024
  cur = [k for k in st["order"] if st["tasks"][k]["status"] in ("coding", "verifying")]
7975
8025
  if cur:
7976
8026
  tid = cur[0]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.6.0",
3
+ "version": "6.7.1",
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": {
@@ -21,6 +21,7 @@ There is no event manager and there are no herdr panes. You drive one milestone
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.)
23
23
  2. **Coder.** Call the `Agent` tool: `subagent_type: "coder"`, `description: "Mn <short title>"`, `run_in_background: false`, and a prompt like `Build milestone Mn. Read the task file <TASK path> and follow it. The check command is: <check command>. There is no result file or done file in this run: put your report in your reply.`
24
+ - If the coder's reply says it stopped early (its turn limit, `max_turns` in the config), resume the same coder once with `Carry on with Mn from where you stopped.` If it stops early again, tell the developer what it reported and **STOP**.
24
25
  - If the coder replies `QUESTION: ...`: answer it from the plan or the code (say where the answer comes from), or ask the developer with 2–3 options and **STOP**. Write the answer under that milestone's "Notes from user" in `.orchestrate/plan.md`, then send it to the same coder with the `Agent` tool's `resume` (its agent id), so it carries on from its work.
25
26
  3. **Check.** Run `orch check Mn`. On `CHECK FAIL`, resume the same coder with the failing output (the last lines `orch check` printed) and ask it to fix the cause. Run `orch check Mn` again. At most 3 fix rounds; after that, run `orch set Mn failed "<what keeps failing>"`, explain it to the developer in two lines, and **STOP**.
26
27
  4. **Review** (only when `REVIEW yes`). Call the `Agent` tool: `subagent_type: "reviewer"`, `run_in_background: false`, prompt `Review milestone Mn. Task file: <TASK path>. Look at the change with git diff HEAD and git status --short.` Each `BLOCKER:` line goes back to the same coder (resume it with those lines only), then `orch check Mn` again, then one more review. At most 2 review rounds; blockers still left after that: `orch set Mn failed "<the blockers>"`, tell the developer, **STOP**. `SUGGESTION:` lines do not block: keep them for the summary.