herdr-orchestra 6.44.2 → 6.46.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,38 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.46.0] - 2026-11-30
6
+
7
+ The team's panes are readable. `orch team up` used to put every new pane in the lead's tab: the first one to the right of the lead, each next one split down from the one before. With two coders and a reviewer the lead got half the screen and the agents got thin strips, so text was cut off.
8
+
9
+ Example: a Codex lead with codex-1, codex-2 and a reviewer. Before, the lead's tab held all four panes. Now the lead keeps its whole tab, and a new herdr tab `team` holds codex-1 and codex-2 side by side on top and the reviewer full width below.
10
+
11
+ ### Changed
12
+ - **`orch team up` opens the team in a herdr tab of its own, as a grid of equal panes.** The tab is called `team` (`backend team` in a workspace of several repos). Layout: 1 agent full size, 2 side by side, 3 as two on top and the reviewer below, 4 as 2×2. At most 4 go in a tab; more go to `team 2`. orch reads the screen size from `herdr pane layout` and keeps each pane at least 80 columns × 20 rows, so a small screen gets fewer panes per tab. The reviewer always comes last. Sizes are set with `--ratio`, so the panes are equal. The lead's tab is never split.
13
+ - `orch team up --here` splits next to the lead as before. A herdr that can't make tabs gets a `NOTE`, and the panes then open next to the lead.
14
+ - Settings: `ORCH_TEAM_MAX_PER_TAB` (default 4), `ORCH_PANE_MIN_COLS` (80), `ORCH_PANE_MIN_ROWS` (20).
15
+
16
+ ### Added
17
+ - **`orch team tidy [--dry-run]`** moves the coder and reviewer panes that are already open (opened by hand, or next to the lead by an older orch) into the same `team` tab grid with `herdr pane move`. The agents keep running and keep their names, so wake-ups and prompts still reach them. It never moves the lead's pane or the pane it runs in.
18
+
19
+ Not yet tried on a real herdr: tested with the simulated herdr only. The herdr commands it uses (`tab create`, `pane split --ratio`, `pane layout`, `pane move`) were checked against herdr 0.9.5's source and docs.
20
+
21
+ ## [6.45.0] - 2026-11-30
22
+
23
+ The board stopped showing the wrong run, the board popup key is set up by one command, and the board comes to the Herdr desktop app. A lead planned new work as `.orchestrate/sap-business-one-hana-plan.md` because `plan.md` still held the last, finished run. orch reads only `plan.md`, so the new plan was never loaded: the work got done, but orch never tracked it, and the board kept showing the old run. Separately, `orch view plugin link` linked the popup, but `prefix+a` did nothing: Herdr takes keys only from its own config, and nothing put the key there.
24
+
25
+ Example: M9 landed 6 days ago and its plan is still in `plan.md`. Before, the lead wrote the SAP plan under another name, and `orch sync` loaded the old M9 plan with only a warning. Now `orch lead plan` first moves the old plan to `.orchestrate/archive/2026-11-24-dashboard-dynamic-cards-plan.md` and tells the lead to write the new one in `plan.md`. If a new plan still lands under another name, `orch sync` stops and says which file to copy to `plan.md`. For the key, `orch view plugin key` adds `prefix+a` to Herdr's `config.toml` and makes Herdr reload it.
26
+
27
+ ### Fixed
28
+ - **A finished run's plan is archived when a new plan starts.** `orch lead plan` moves `.orchestrate/plan.md` to `.orchestrate/archive/<date>-<branch>-plan.md` (a second one the same day gets `-2`) when it is still the plan of a run that is over: every milestone landed, nothing running, the same `Branch:` as the run, not changed since. It prints `ARCHIVED ...`. A plan whose run is still going, or a new plan written after the run, is never moved.
29
+ - **The lead is told: one plan file.** The plan playbook says every plan, quick or full, goes in `.orchestrate/plan.md`, never under another name, and why.
30
+ - **`orch sync` stops instead of loading the old plan.** When `plan.md` is still the finished run's plan and a newer `.orchestrate/*.md` sits next to it, `orch sync` stops, names the file, and says how to keep the old plan and load the new one. While a run is going, a newer file is still only a warning.
31
+
32
+ ### Added
33
+ - **`orch view plugin key [<key>]`** puts the board popup key (default `prefix+a`) in Herdr's `config.toml` (`$XDG_CONFIG_HOME/herdr` or `~/.config/herdr`) once, and runs `herdr server reload-config`, so no restart is needed. A key the config already uses is refused, with a free one to pick. A key Herdr uses by default gets a warning. When Herdr can't reload, it says to restart Herdr. `orch view plugin link` now says that linking gives no key, and names this command.
34
+ - **The board in the Herdr desktop app.** `orch view app link` puts an `orch-board` mod in the app's mods folder (`~/.config/herdr-app/mods/`). Pick "orch: run board" in the app's command palette, or bind `mod.open:orch-board` to a key in `keys.json`. It starts `orch board` through herdr-core in the folder of the terminal you were in, and shows it in a window with a title bar. `q` or ✕ closes it and ends that terminal. If the board can't start, the window says why. Every install updates an installed mod (`orch view plugin refresh`), and `orch view app unlink` removes it. Enter-to-jump to an agent and full runs still need Herdr in a terminal. It has not been tried in a real desktop app yet.
35
+ - **Docs: the board popup, set up and fixed.** The "Watch a run" page has the two setup commands, how to undo, how to pick another key, and a table for when the popup doesn't open: nothing happens on the key, testing without the key, a command run outside the Herdr window, a popup that flashes and closes, an old popup after an update, an old run on the board, and the Herdr desktop app (its own board, below).
36
+
5
37
  ## [6.44.2] - 2026-11-30
6
38
 
7
39
  Project setup no longer asks about agents you are not using. A Codex lead ran `/orch-plan`, and the setup question offered "add a local link from .agent/skills to .agents/skills so Antigravity sees the repo's skills". Antigravity was installed on the machine, but nobody used it in that project. orch checked every agent installed on the machine, not the agents in this team.
package/README.md CHANGED
@@ -135,7 +135,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
135
135
 
136
136
  `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.
137
137
 
138
- **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.
138
+ **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 in a herdr tab of their own called `team`, as a grid of equal panes (2 side by side, 3 as two on top and the reviewer below, 4 as 2×2; a fifth goes to `team 2`, and a small screen gets fewer per tab), each in its own folder and on its model, and names them. The lead keeps its whole tab. `orch team tidy` moves panes that are already open (by hand, or next to the lead) into that grid; `orch team up --here` splits next to the lead as before. 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.
139
139
 
140
140
  ```
141
141
  you (1 Codex pane) ──► $orch-plan add a login page
@@ -348,7 +348,7 @@ A subagent run: `/orch-plan` as usual (the plan's team is `Workers: coder (pi)`,
348
348
  Three views show a run while it goes; none of them changes it.
349
349
 
350
350
  - **`orch view`** opens the run as a live picture in your browser: the run ring, a milestone graph (arrows = "needs this first", red = needs you) with a one-line description under each milestone, the agents, the details of the milestone you click (with the exact `orch answer` command), time and cost against the estimate, a replay slider, and an optional browser alert when something needs you. `orch view --lan` also opens it to your phone on the same Wi-Fi, behind a secret link. `orch status` and the lead's "needs you" lines print its link while it runs.
351
- - **`orch board`** draws the same run as text for a Herdr pane; `orch view plugin link` adds a small Herdr plugin that opens it as a popup (Herdr 0.7.4+).
351
+ - **`orch board`** draws the same run as text for a Herdr pane; `orch view plugin link` adds a small Herdr plugin that opens it as a popup and `orch view plugin key` puts `prefix+a` in Herdr's config (Herdr 0.7.4+). In the Herdr desktop app, `orch view app link` adds the board to its command palette.
352
352
  - **What each milestone changed**: press `f` on the board, or click a milestone in `orch view`, for its changed files by folder with `+/-` counts (live while the coder works, unsaved files included), and a file for its diff. `orch changes M2` prints the same. Read-only.
353
353
  - **Herdr's sidebar** names each agent by what it does (`codex-1 · M2 building`), set by the event manager on a separate thread, display only (Herdr 0.6.3+; `ORCH_SIDEBAR=0` turns it off). `orch view herdr-config` prints extra sidebar rows.
354
354
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.44.2
1
+ 6.46.0
Binary file
package/bin/orch CHANGED
@@ -195,9 +195,9 @@ def driver_info():
195
195
  return {}
196
196
 
197
197
 
198
- def driver_alive():
198
+ def driver_alive(orch_dir=None):
199
199
  """True while an `orch autopilot` holds the run's driver lease (the kernel drops it if autopilot dies)."""
200
- p = ORCH / "driver.lock"
200
+ p = (orch_dir or ORCH) / "driver.lock"
201
201
  if not p.exists():
202
202
  return False
203
203
  with open(p, "a") as f:
@@ -1400,6 +1400,13 @@ def cmd_sync(args):
1400
1400
  cfg, tasks = parse_plan(plan_text)
1401
1401
  errors, warns = [], []
1402
1402
  newer = other_plan_files(plan.stat().st_mtime)
1403
+ if newer and finished_plan(ORCH):
1404
+ die(f"plan.md is still the plan of the finished run ({plan_branch(plan_text)}), and "
1405
+ f"{', '.join('.orchestrate/' + n for n in newer[:3])} {'is' if len(newer) == 1 else 'are'} newer. "
1406
+ f"orch reads only .orchestrate/plan.md, so a new plan under another name is never run or shown on the "
1407
+ f"board. If {'that is' if len(newer) == 1 else 'one of those is'} your new plan: keep the old one with "
1408
+ f"`mkdir -p .orchestrate/archive && mv .orchestrate/plan.md .orchestrate/archive/`, copy the new plan to "
1409
+ f".orchestrate/plan.md, and run `orch sync` again")
1403
1410
  if newer:
1404
1411
  warns.append(f"{', '.join(newer[:3])} {'is' if len(newer) == 1 else 'are'} newer than plan.md, but orch only "
1405
1412
  f"reads plan.md. If that is the plan you mean, copy it to plan.md and run `orch sync` again")
@@ -8571,11 +8578,14 @@ def team_pick(cands, n):
8571
8578
 
8572
8579
  def cmd_team(args):
8573
8580
  """orch team <kind> [--coders N] [--models a,b] [--no-reviewer] -> the plan's team built from one tool.
8574
- orch team up [--dry-run] -> open a herdr pane for every agent in the plan that herdr cannot find."""
8581
+ orch team up [--dry-run] [--here] -> open a herdr pane for every agent in the plan that herdr cannot find.
8582
+ orch team tidy [--dry-run] -> move the open coder/reviewer panes into the team tab grid."""
8575
8583
  if args and args[0] == "up":
8576
8584
  return team_up(args[1:])
8585
+ if args and args[0] == "tidy":
8586
+ return team_tidy(args[1:])
8577
8587
  usage = ("usage: orch team <kind> [--coders N] [--models a,b] [--no-reviewer] [--prefix <name>] | "
8578
- "orch team up [--dry-run]")
8588
+ "orch team up [--dry-run] [--here] | orch team tidy [--dry-run]")
8579
8589
  rest, coders, models, reviewer, prefix = list(args), None, None, True, None
8580
8590
  if "--prefix" in rest:
8581
8591
  i = rest.index("--prefix")
@@ -8665,14 +8675,207 @@ def _herdr_json(cmd):
8665
8675
  return r.returncode == 0, data, out
8666
8676
 
8667
8677
 
8678
+ TEAM_MAX_PER_TAB = max(1, int(os.environ.get("ORCH_TEAM_MAX_PER_TAB", "4")))
8679
+ PANE_MIN_COLS = max(20, int(os.environ.get("ORCH_PANE_MIN_COLS", "80"))) # an agent's screen stays readable at this size
8680
+ PANE_MIN_ROWS = max(8, int(os.environ.get("ORCH_PANE_MIN_ROWS", "20")))
8681
+
8682
+
8683
+ def herdr_screen(pane=None):
8684
+ """(workspace id, width, height) of the tab `pane` sits in (default: the pane this runs in), in terminal cells,
8685
+ from `herdr pane layout`. Nones for what herdr can't tell."""
8686
+ cmd = [HERDR, "pane", "layout"] + (["--pane", pane] if pane else
8687
+ ["--current"] if os.environ.get("HERDR_PANE_ID") else [])
8688
+ ok, data, _ = _herdr_json(cmd)
8689
+ lay = _dicts_with(data, "tab_id") if ok and data is not None else []
8690
+ lay = next((d for d, _ in lay if isinstance(d.get("area"), dict)), None)
8691
+ ws = os.environ.get("HERDR_WORKSPACE_ID") or (lay or {}).get("workspace_id")
8692
+ area = (lay or {}).get("area") or {}
8693
+ w, h = area.get("width"), area.get("height")
8694
+ return ws, (w if isinstance(w, int) and w > 0 else None), (h if isinstance(h, int) and h > 0 else None)
8695
+
8696
+
8697
+ def team_grid(n, width, height):
8698
+ """How many panes go in one team tab, and the rows for n of them: [panes in row 1, row 2, ...]. Every pane gets
8699
+ at least PANE_MIN_COLS x PANE_MIN_ROWS of a screen this size (2 across when the size is unknown), at most
8700
+ TEAM_MAX_PER_TAB per tab, rows as even as they can be (3 -> [2, 1], 4 -> [2, 2])."""
8701
+ cols = max(1, width // PANE_MIN_COLS) if width else 2
8702
+ rows = max(1, height // PANE_MIN_ROWS) if height else 2
8703
+ cap = max(1, min(TEAM_MAX_PER_TAB, cols * rows))
8704
+ n = min(n, cap)
8705
+ r = max(1, -(-n // min(cols, n))) if n else 0
8706
+ return cap, [n // r + (1 if i < n % r else 0) for i in range(r)]
8707
+
8708
+
8709
+ def build_grid(rows, first, split):
8710
+ """Make a grid of equal panes, row by row: first() -> the top-left pane id; split(pane, direction, ratio, slot)
8711
+ -> the pane id for grid slot `slot` (row-major), cut from `pane`. Returns the pane id of every slot, None where
8712
+ herdr refused. herdr's ratio is the share the pane being split keeps, so 1/k for k panes left gives equal sizes."""
8713
+ out = [None] * sum(rows)
8714
+ top = first()
8715
+ if not top:
8716
+ return out
8717
+ starts = [sum(rows[:i]) for i in range(len(rows))]
8718
+ heads, cur = [top], top
8719
+ for i in range(1, len(rows)):
8720
+ cur = split(cur, "down", 1 / (len(rows) - i + 1), starts[i]) if cur else None
8721
+ heads.append(cur)
8722
+ for head, k, s in zip(heads, rows, starts):
8723
+ cur = out[s] = head
8724
+ for j in range(1, k):
8725
+ cur = out[s + j] = split(cur, "right", 1 / (k - j + 1), s + j) if cur else None
8726
+ return out
8727
+
8728
+
8729
+ def team_tab_label(i, st=None):
8730
+ """"team", "team 2", ...; in a workspace of several repos each repo's team gets its own: "backend team"."""
8731
+ base = f"{ROOT.name} team" if (st or {}).get("workspace") and ROOT else "team"
8732
+ return base if i == 0 else f"{base} {i + 1}"
8733
+
8734
+
8735
+ def _new_pane_id(ok, data, out, key="pane"):
8736
+ """The pane id in a herdr answer: .result.<key>.pane_id (pane split: pane, tab create: root_pane), loosely."""
8737
+ if not ok:
8738
+ return None
8739
+ res = (data or {}).get("result") if isinstance(data, dict) else None
8740
+ pid = _find_key((res or {}).get(key), "pane_id") if isinstance(res, dict) else None
8741
+ return pid or (re.search(r'"pane_id"\s*:\s*"([\w:.-]+)"', out or "") or [None, None])[1]
8742
+
8743
+
8744
+ def team_tab_panes(new, dry=False, lead_pane=None, st=None):
8745
+ """Open one pane per (name, folder) in `new`, in new herdr tabs ("team", "team 2", ...) laid out by team_grid.
8746
+ Returns ({name: pane id, None when herdr refused; dry: the command it would run}, {name: why it failed},
8747
+ [tab labels]). When herdr can't make the first tab (an older herdr), returns ({}, {}, []) after a NOTE, and
8748
+ team up opens the panes next to this one as before."""
8749
+ ws, w, h = herdr_screen(lead_pane)
8750
+ cap, _ = team_grid(len(new), w, h)
8751
+ placed, errs, labels = {}, {}, []
8752
+ q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
8753
+ for c, i in enumerate(range(0, len(new), cap)):
8754
+ chunk, label = new[i:i + cap], team_tab_label(c, st)
8755
+ _, rows = team_grid(len(chunk), w, h)
8756
+ tab_cmd = [HERDR, "tab", "create"] + (["--workspace", ws] if ws else []) + \
8757
+ ["--cwd", chunk[0][1], "--label", label, "--no-focus"]
8758
+
8759
+ def first():
8760
+ if dry:
8761
+ placed[chunk[0][0]] = f"new tab: {q(tab_cmd)}"
8762
+ return f"<{chunk[0][0]}>"
8763
+ ok, data, out = _herdr_json(tab_cmd)
8764
+ pid = _new_pane_id(ok, data, out, "root_pane")
8765
+ if not pid:
8766
+ errs[chunk[0][0]] = out.splitlines()[-1] if out else "no output"
8767
+ return pid
8768
+
8769
+ def split(cur, direction, ratio, slot):
8770
+ name, d = chunk[slot]
8771
+ cmd = [HERDR, "pane", "split", cur, "--direction", direction, "--ratio", f"{ratio:.3f}",
8772
+ "--cwd", d, "--no-focus"]
8773
+ if dry:
8774
+ placed[name] = q(cmd)
8775
+ return f"<{name}>"
8776
+ ok, data, out = _herdr_json(cmd)
8777
+ pid = _new_pane_id(ok, data, out)
8778
+ if not pid:
8779
+ errs[name] = out.splitlines()[-1] if out else "no output"
8780
+ return pid
8781
+
8782
+ pids = build_grid(rows, first, split)
8783
+ if c == 0 and not pids[0] and not dry:
8784
+ print(f"NOTE herdr could not open a tab for the team ({errs.get(chunk[0][0])}), so the panes open "
8785
+ f"next to this one")
8786
+ return {}, {}, []
8787
+ if not dry:
8788
+ placed.update({n: p for (n, _), p in zip(chunk, pids)})
8789
+ for (n, _), p in zip(chunk, pids):
8790
+ if not p and n not in errs:
8791
+ errs[n] = "the pane it splits from was not opened"
8792
+ labels.append(label)
8793
+ return placed, errs, labels
8794
+
8795
+
8796
+ def team_tidy(args):
8797
+ """Move the coders' and the reviewer's panes that are open now (opened by hand, or by an older orch next to the
8798
+ lead) into team tabs, as a grid of equal panes, the same layout `orch team up` opens. The agents keep running
8799
+ and keep their names. Never moves the lead's pane or the pane this runs in."""
8800
+ usage = "usage: orch team tidy [--dry-run]"
8801
+ if any(a != "--dry-run" for a in args):
8802
+ die(usage)
8803
+ dry = "--dry-run" in args
8804
+ st = load()
8805
+ if run_mode(st) == "subagent":
8806
+ print("mode subagent: no panes to arrange; the coder and the reviewer are Pi subagents")
8807
+ return
8808
+ names = [(n, w) for n, w in st["workers"].items()]
8809
+ if st.get("reviewer"):
8810
+ names.append((st["reviewer"], st.get("reviewer_info") or {}))
8811
+ lead = (st.get("lead") or {}).get("name")
8812
+ lead_pane = (st.get("lead") or {}).get("pane") or (agent_pane(lead) if lead else None)
8813
+ keep = {lead_pane, os.environ.get("HERDR_PANE_ID")} - {None}
8814
+ panes = []
8815
+ for n, w in names:
8816
+ p = w.get("pane") or agent_pane(n)
8817
+ if not p:
8818
+ print(f"skip {n}: herdr can't find it (`orch team up` opens it)")
8819
+ elif p in keep:
8820
+ print(f"skip {n}: pane {p} is the lead's (or this) pane, it stays where it is")
8821
+ else:
8822
+ panes.append((n, p))
8823
+ if not panes:
8824
+ print("TEAM TIDY: no coder or reviewer pane to arrange")
8825
+ return
8826
+ ws, w, h = herdr_screen(lead_pane)
8827
+ cap, _ = team_grid(len(panes), w, h)
8828
+ q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
8829
+ failed, labels = 0, []
8830
+ for c, i in enumerate(range(0, len(panes), cap)):
8831
+ chunk, label, tab = panes[i:i + cap], team_tab_label(c, st), [None]
8832
+ _, rows = team_grid(len(chunk), w, h)
8833
+
8834
+ def move(cmd, name, old):
8835
+ if dry:
8836
+ print(f"WOULD {name}: {q(cmd)}")
8837
+ return f"<{name}>"
8838
+ ok, data, out = _herdr_json(cmd)
8839
+ res = ((data or {}).get("result") or {}).get("move_result") if ok and isinstance(data, dict) else None
8840
+ pid = _find_key((res or {}).get("pane"), "pane_id") if isinstance(res, dict) else None
8841
+ tab[0] = tab[0] or (_find_key((res or {}).get("pane"), "tab_id") if isinstance(res, dict) else None)
8842
+ if not pid:
8843
+ print(f"FAILED {name}: herdr could not move pane {old} ({out.splitlines()[-1] if out else 'no output'})")
8844
+ return None
8845
+ print(f"MOVED {name}: pane {old} -> tab \"{label}\"" + (f" (now {pid})" if pid != old else ""))
8846
+ return pid
8847
+
8848
+ def first():
8849
+ n, p = chunk[0]
8850
+ return move([HERDR, "pane", "move", p, "--new-tab"] + (["--workspace", ws] if ws else []) +
8851
+ ["--label", label, "--no-focus"], n, p)
8852
+
8853
+ def split(cur, direction, ratio, slot):
8854
+ n, p = chunk[slot]
8855
+ if not dry and not tab[0]:
8856
+ print(f"FAILED {n}: herdr did not say which tab \"{label}\" is, so pane {p} stays where it is")
8857
+ return None
8858
+ return move([HERDR, "pane", "move", p, "--tab", tab[0] or f"<tab {label}>", "--split", direction,
8859
+ "--target-pane", cur, "--ratio", f"{ratio:.3f}", "--no-focus"], n, p)
8860
+
8861
+ failed += sum(1 for x in build_grid(rows, first, split) if not x)
8862
+ labels.append(label)
8863
+ if dry:
8864
+ return
8865
+ print(f"TEAM TIDY: {'done' if not failed else f'{failed} pane(s) not moved — see above'}; the team is in the "
8866
+ f"herdr tab{'s' if len(labels) > 1 else ''} " + ", ".join(f'"{t}"' for t in labels))
8867
+ if failed:
8868
+ sys.exit(3)
8869
+
8870
+
8668
8871
  def team_up(args):
8669
8872
  """Open a pane for every worker and the reviewer in the plan that herdr can't find: split from this pane, cd
8670
8873
  into the agent's folder (its worktree, or the repo), start it on its plan model, and give it its plan name."""
8671
8874
  args = list(args)
8672
- flag = mode_flag(args, "usage: orch team up [--dry-run] [--mode panes|subagent]")
8875
+ flag = mode_flag(args, "usage: orch team up [--dry-run] [--here] [--mode panes|subagent]")
8673
8876
  dry = "--dry-run" in args
8674
8877
  if flag and not dry:
8675
- set_mode(flag, hint=False, agent=mode_target(flag, "usage: orch team up [--dry-run] [--mode panes|subagent]"))
8878
+ set_mode(flag, hint=False, agent=mode_target(flag, "usage: orch team up [--dry-run] [--here] [--mode panes|subagent]"))
8676
8879
  st = load()
8677
8880
  if (flag or run_mode(st)) == "subagent":
8678
8881
  print("mode subagent: no panes to open; the coder and the reviewer are Pi subagents")
@@ -8706,22 +8909,38 @@ def team_up(args):
8706
8909
  print("TEAM UP: every agent in the plan is running")
8707
8910
  return
8708
8911
  failed, last, opened = 0, None, []
8912
+ runnable = []
8709
8913
  for name, w, d in todo:
8710
- kind, model = w.get("kind"), w.get("model")
8711
- v = reg.get(kind)
8914
+ v = reg.get(w.get("kind"))
8712
8915
  if not v:
8713
- print(f"SKIP {name}: kind {kind!r} is not in the agent registry — start it yourself in {d}")
8916
+ print(f"SKIP {name}: kind {w.get('kind')!r} is not in the agent registry — start it yourself in {d}")
8714
8917
  failed += 1
8715
8918
  continue
8919
+ runnable.append((name, w, d, v))
8920
+ # new panes go in a herdr tab of their own ("team"), as a grid of equal panes, so the lead keeps its whole
8921
+ # screen and every agent stays readable; --here (or a herdr that can't make tabs) splits next to this pane
8922
+ new = [(n, d) for n, w, d, v in runnable if not empty.get(n)]
8923
+ placed, errs, tabs = {}, {}, []
8924
+ if new and "--here" not in args:
8925
+ placed, errs, tabs = team_tab_panes(new, dry, lead_pane, st)
8926
+ for name, w, d, v in runnable:
8927
+ kind, model = w.get("kind"), w.get("model")
8716
8928
  cmd = launch_cmd(kind, v, model, strict=False, role="reviewer" if name == st.get("reviewer") else None, cwd=d)
8717
8929
  split = [HERDR, "pane", "split"] + ([last] if last else []) + \
8718
8930
  ["--direction", "down" if last else "right", "--cwd", d, "--no-focus"]
8719
8931
  if dry:
8720
- print(f"WOULD {name}: {' '.join(shlex.quote(x) for x in split)} then herdr pane run <new pane> "
8932
+ how = placed.get(name) or " ".join(shlex.quote(x) for x in split)
8933
+ print(f"WOULD {name}: {how} then herdr pane run <new pane> "
8721
8934
  f"{shlex.quote(cmd)} then herdr agent rename <new pane> {name}")
8722
8935
  continue
8723
8936
  pid = empty.get(name)
8724
- if not pid:
8937
+ if not pid and name in placed:
8938
+ pid = placed[name]
8939
+ if not pid:
8940
+ print(f"FAILED {name}: herdr could not open its pane in the team tab ({errs.get(name) or 'no output'})")
8941
+ failed += 1
8942
+ continue
8943
+ elif not pid:
8725
8944
  ok, data, out = _herdr_json(split)
8726
8945
  try:
8727
8946
  pid = data["result"]["pane"]["pane_id"] if ok else None
@@ -8775,6 +8994,10 @@ def team_up(args):
8775
8994
  + (f" (its last screen is in {short(saved)})" if saved else "") + ", then `orch team up` again")
8776
8995
  log_line(f"{run_tag(st)} QUIT {name}: {w.get('kind')} exited right after `orch team up` started it "
8777
8996
  f"in pane {pid}")
8997
+ if tabs and not dry:
8998
+ print(f"TAB the team is in the herdr tab{'s' if len(tabs) > 1 else ''} " + ", ".join(f'"{t}"' for t in tabs)
8999
+ + ", so the lead keeps its whole screen — switch tabs to watch them (`orch team tidy` moves panes "
9000
+ "opened by hand there too)")
8778
9001
  print("TEAM UP: done — run `orch start` again; every agent should show herdr=found" if not failed else
8779
9002
  f"TEAM UP: {failed} agent(s) not ready — see above, then `orch team up` again")
8780
9003
  if failed:
@@ -9067,6 +9290,65 @@ def _ago(secs):
9067
9290
  f"{secs // 3600} h" if secs < 86400 else f"{secs // 86400} d")
9068
9291
 
9069
9292
 
9293
+ def run_finished(st, orch_dir=None):
9294
+ """True when the run in `st` is over: every milestone landed or skipped (or the lead finished it), nothing is being
9295
+ worked on, and no event manager is running."""
9296
+ tasks = st.get("tasks", {})
9297
+ if any((tasks.get(t) or {}).get("status") in ACTIVE for t in st.get("order", [])) or driver_alive(orch_dir):
9298
+ return False
9299
+ return bool(st.get("order")) and (
9300
+ all((tasks.get(t) or {}).get("status") in ("merged", "skipped") for t in st["order"])
9301
+ or any(e.get("kind") == "finished" for e in st.get("lead_events", [])))
9302
+
9303
+
9304
+ def plan_branch(text):
9305
+ m = re.search(r"(?mi)^Branch:\s*(\S+)", text or "")
9306
+ return m.group(1) if m else None
9307
+
9308
+
9309
+ def finished_plan(orch_dir):
9310
+ """(plan.md, state) when .orchestrate/plan.md is still the plan of a run that is over (same Branch, not changed
9311
+ since the run), else None. Never fails."""
9312
+ plan, state = orch_dir / "plan.md", orch_dir / "state.json"
9313
+ try:
9314
+ if not plan.is_file() or not state.is_file() or plan.stat().st_mtime > state.stat().st_mtime:
9315
+ return None
9316
+ st = migrate(json.loads(state.read_text()))
9317
+ if not run_finished(st, orch_dir) or plan_branch(plan.read_text()) != st.get("branch"):
9318
+ return None
9319
+ return plan, st
9320
+ except (OSError, ValueError, AttributeError, TypeError):
9321
+ return None
9322
+
9323
+
9324
+ def archive_finished_plan():
9325
+ """`orch lead plan`: when plan.md is still the finished run's plan, move it to .orchestrate/archive/ so the lead
9326
+ writes the new plan in plan.md. Without this a lead kept the old plan and wrote the new one under another name,
9327
+ which orch never read (the run was never tracked, and the board kept showing the old run). Returns the note."""
9328
+ root = onboard_root()
9329
+ if root is None:
9330
+ return ""
9331
+ orch_dir = root / ".orchestrate"
9332
+ found = finished_plan(orch_dir)
9333
+ if not found:
9334
+ return ""
9335
+ plan, st = found
9336
+ day = time.strftime("%Y-%m-%d", time.localtime((orch_dir / "state.json").stat().st_mtime))
9337
+ slug = re.sub(r"[^A-Za-z0-9._-]+", "-", (st.get("branch") or "run").split("/")[-1]).strip("-") or "run"
9338
+ arch = orch_dir / "archive"
9339
+ try:
9340
+ arch.mkdir(exist_ok=True)
9341
+ dest, n = arch / f"{day}-{slug}-plan.md", 2
9342
+ while dest.exists():
9343
+ dest, n = arch / f"{day}-{slug}-plan-{n}.md", n + 1
9344
+ plan.rename(dest)
9345
+ except OSError as e:
9346
+ return f"WARN could not move the finished run's plan.md to .orchestrate/archive/ ({e})\n\n"
9347
+ return (f"ARCHIVED the finished run's plan ({st.get('title') or st.get('branch')}): .orchestrate/plan.md -> "
9348
+ f".orchestrate/archive/{dest.name}\n"
9349
+ f"Write the new plan in .orchestrate/plan.md. Never use another file name: orch reads only plan.md.\n\n")
9350
+
9351
+
9070
9352
  def run_notices(st):
9071
9353
  """Plain-words notes for the views and `orch status` when what they show is not a run that is going now:
9072
9354
  the last run finished long ago, or a plan was written that orch will not read. Never fails."""
@@ -9077,12 +9359,7 @@ def run_notices(st):
9077
9359
  state_t = 0
9078
9360
  out = []
9079
9361
  if st is not None:
9080
- tasks = st.get("tasks", {})
9081
- active = any((tasks.get(t) or {}).get("status") in ACTIVE for t in st.get("order", []))
9082
- done = bool(st.get("order")) and (
9083
- all((tasks.get(t) or {}).get("status") in ("merged", "skipped") for t in st["order"])
9084
- or any(e.get("kind") == "finished" for e in st.get("lead_events", [])))
9085
- if active or driver_alive() or not done:
9362
+ if not run_finished(st):
9086
9363
  return out # a run is going (or stopped half way): nothing to add
9087
9364
  out.append({"kind": "old_run", "text": (
9088
9365
  f"This is the last run ({st.get('title') or st.get('branch')}): all its milestones landed "
@@ -9394,6 +9671,50 @@ description = "orch run board"
9394
9671
  """
9395
9672
 
9396
9673
 
9674
+ BOARD_KEY_BLOCK = ('[[keys.command]]\nkey = "{key}"\ntype = "plugin_action"\n'
9675
+ 'command = "herdr-orchestra.board.open"\ndescription = "orch run board"\n')
9676
+
9677
+
9678
+ HERDR_DEFAULT_KEYS = {f"prefix+{c}" for c in "bcefghjklnopqrsvwxyz"} # herdr 0.9.5's own prefix keys
9679
+
9680
+
9681
+ def herdr_config_path():
9682
+ """herdr's config.toml, found the way herdr finds it on Linux and macOS ($XDG_CONFIG_HOME, else ~/.config)."""
9683
+ base = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
9684
+ return Path(base) / "herdr" / "config.toml"
9685
+
9686
+
9687
+ def board_key_add(key="prefix+a"):
9688
+ """`orch view plugin key [<key>]`: put the board key in herdr's config.toml (once) and make herdr reload it.
9689
+ `orch view plugin link` alone gives no key: herdr reads keys only from its config, so prefix+a did nothing."""
9690
+ if not re.fullmatch(r"[A-Za-z0-9+_-]+", key):
9691
+ die(f"not a herdr key: {key!r} (for example prefix+a or prefix+o)")
9692
+ cfg = herdr_config_path()
9693
+ text = cfg.read_text() if cfg.is_file() else ""
9694
+ m = re.search(r'(?ms)^\[\[keys\.command\]\][^\[]*?command\s*=\s*"herdr-orchestra\.board\.open"', text)
9695
+ if m:
9696
+ km = re.search(r'(?m)^key\s*=\s*"([^"]*)"', m.group(0))
9697
+ print(f"the board key is already in {cfg} ({km.group(1) if km else 'no key line'}); nothing added")
9698
+ else:
9699
+ if re.search(rf'(?m)^\s*\w+\s*=\s*"{re.escape(key)}"', text):
9700
+ die(f"{key} is already used in {cfg}, and herdr would keep that one. Pick a free key, for example "
9701
+ f"`orch view plugin key prefix+i` (`prefix+?` in herdr shows every key in use)")
9702
+ if key.lower() in HERDR_DEFAULT_KEYS:
9703
+ print(f"WARN herdr uses {key} by default; unless your config moved that action, herdr keeps its own and "
9704
+ f"ignores this one. Free in herdr's defaults: prefix+a, prefix+d, prefix+i, prefix+m, prefix+u")
9705
+ cfg.parent.mkdir(parents=True, exist_ok=True)
9706
+ with open(cfg, "a") as f:
9707
+ f.write(("\n" if text and not text.endswith("\n") else "") + ("\n" if text else "")
9708
+ + BOARD_KEY_BLOCK.format(key=key))
9709
+ print(f"added the board key {key} to {cfg}")
9710
+ r = subprocess.run([HERDR, "server", "reload-config"], text=True, capture_output=True)
9711
+ if r.returncode == 0:
9712
+ print("herdr reloaded its config: press your herdr prefix (default ctrl+b), let go, then the key's letter")
9713
+ else:
9714
+ print(f"herdr did not reload its config ({(r.stdout + r.stderr).strip() or 'no answer'}): restart herdr, "
9715
+ f"or run `herdr server reload-config` inside herdr")
9716
+
9717
+
9397
9718
  def board_plugin_dir():
9398
9719
  """The board plugin folder to give herdr: `current/view/herdr-plugin` for an install, the checkout's folder for a
9399
9720
  checkout. Herdr stores the real folder behind a link (it resolves `current` to the version folder), so a link
@@ -9406,6 +9727,36 @@ def board_plugin_dir():
9406
9727
  return cur if installed and cur.is_dir() else asset("view/herdr-plugin")
9407
9728
 
9408
9729
 
9730
+ APP_MOD_NAME = "orch-board"
9731
+
9732
+
9733
+ def herdr_app_mods_dir():
9734
+ """The Herdr desktop app's mods folder ($XDG_CONFIG_HOME or ~/.config, then herdr-app/mods)."""
9735
+ base = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
9736
+ return Path(base) / "herdr-app" / "mods"
9737
+
9738
+
9739
+ def app_mod_install(quiet=False):
9740
+ """Copy the board mod into the desktop app's mods folder (the app reloads a saved mod by itself). A copy, not a
9741
+ link: every install refreshes it (`orch view plugin refresh`), so updates reach the app too."""
9742
+ src = asset(f"view/herdr-app-mod/{APP_MOD_NAME}")
9743
+ if not src:
9744
+ die(f"view/herdr-app-mod/{APP_MOD_NAME} not found next to orch or in the install")
9745
+ dest = herdr_app_mods_dir() / APP_MOD_NAME
9746
+ dest.mkdir(parents=True, exist_ok=True)
9747
+ for f in src.iterdir():
9748
+ if f.is_file():
9749
+ shutil.copyfile(f, dest / f.name)
9750
+ if not quiet:
9751
+ print(f"installed the orch board mod for the Herdr desktop app: {dest}\n"
9752
+ f"In the app: Ctrl+Shift+P (Cmd+Shift+P on macOS) -> \"orch: run board\". It opens the board for the "
9753
+ f"folder of the terminal you were in; q or the x closes it.\n"
9754
+ f"For a key, add to ~/.config/herdr-app/keys.json under \"global\": "
9755
+ f"\"ctrl-shift-b\": \"mod.open:{APP_MOD_NAME}\" (Ctrl+Shift+P shows whether a key is free).\n"
9756
+ f"Undo with `orch view app unlink`.")
9757
+ return dest
9758
+
9759
+
9409
9760
  def board_plugin_linked():
9410
9761
  """True when the board plugin was linked: by this version (remembered in settings) or by an older one, which
9411
9762
  left no note, so herdr's own plugin list is asked too."""
@@ -9439,7 +9790,7 @@ def board_plugin_link(d):
9439
9790
 
9440
9791
  def cmd_view(args):
9441
9792
  """orch view [--lan] [--port N] [--no-open] [--bg] -> the run as a live picture in your browser (view only).
9442
- orch view stop | status | herdr-config | plugin link|unlink|refresh"""
9793
+ orch view stop | status | herdr-config | plugin link|key|unlink|refresh | app link|unlink"""
9443
9794
  sub = args[0] if args and not args[0].startswith("-") else None
9444
9795
  if sub == "status":
9445
9796
  v = view_info()
@@ -9461,6 +9812,20 @@ def cmd_view(args):
9461
9812
  if sub == "herdr-config":
9462
9813
  print(SIDEBAR_CONFIG, end="")
9463
9814
  return
9815
+ if sub == "app":
9816
+ act = args[1] if len(args) > 1 else ""
9817
+ if act == "link":
9818
+ app_mod_install()
9819
+ return
9820
+ if act == "unlink":
9821
+ dest = herdr_app_mods_dir() / APP_MOD_NAME
9822
+ if dest.is_dir():
9823
+ shutil.rmtree(dest)
9824
+ print(f"removed {dest}")
9825
+ else:
9826
+ print("the orch board mod is not installed in the Herdr desktop app")
9827
+ return
9828
+ die("usage: orch view app link|unlink (the Herdr desktop app's board mod)")
9464
9829
  if sub == "plugin":
9465
9830
  act = args[1] if len(args) > 1 else ""
9466
9831
  d = board_plugin_dir()
@@ -9472,6 +9837,9 @@ def cmd_view(args):
9472
9837
  print(f"board popup plugin re-linked to {d}" if r.returncode == 0
9473
9838
  else f"WARN could not re-link the board popup plugin: {(r.stdout + r.stderr).strip()} "
9474
9839
  f"(run `orch view plugin link`)")
9840
+ if (herdr_app_mods_dir() / APP_MOD_NAME / "mod.json").is_file(): # the desktop app's board mod
9841
+ with contextlib.suppress(OSError, SystemExit):
9842
+ print(f"desktop app board mod updated: {app_mod_install(quiet=True)}")
9475
9843
  return
9476
9844
  if act == "link":
9477
9845
  if not d:
@@ -9479,13 +9847,17 @@ def cmd_view(args):
9479
9847
  r = board_plugin_link(d)
9480
9848
  print((r.stdout + r.stderr).strip() or f"linked {d}")
9481
9849
  if r.returncode == 0:
9482
- print("To open the board with a key, add this to herdr's config.toml and restart herdr "
9483
- "(`orch view herdr-config` prints it too). prefix+a is free in herdr's defaults; "
9484
- "`prefix+?` shows every key in use. If the key is taken, herdr keeps its own and ignores this one.\n\n"
9485
- "[[keys.command]]\nkey = \"prefix+a\"\ntype = \"plugin_action\"\n"
9486
- "command = \"herdr-orchestra.board.open\"\ndescription = \"orch run board\"\n\n"
9850
+ print("Linking adds the popup, not a key. Next, run `orch view plugin key`: it adds prefix+a to "
9851
+ f"herdr's config ({herdr_config_path()}) and makes herdr reload it "
9852
+ "(another key: `orch view plugin key prefix+i`). Or add these lines yourself, then run `herdr server reload-config` "
9853
+ "(or restart herdr). prefix+a is free in herdr's defaults; `prefix+?` shows every key in use. "
9854
+ "If the key is taken, herdr keeps its own and ignores this one.\n\n"
9855
+ + BOARD_KEY_BLOCK.format(key="prefix+a") + "\n"
9487
9856
  "Undo with `orch view plugin unlink`.")
9488
9857
  sys.exit(r.returncode)
9858
+ if act == "key":
9859
+ board_key_add(args[2] if len(args) > 2 else "prefix+a")
9860
+ return
9489
9861
  if act == "unlink":
9490
9862
  r = subprocess.run([HERDR, "plugin", "unlink", VIEW_PLUGIN_ID], text=True, capture_output=True)
9491
9863
  print((r.stdout + r.stderr).strip() or f"unlinked {VIEW_PLUGIN_ID}")
@@ -9493,10 +9865,10 @@ def cmd_view(args):
9493
9865
  if st.pop("board_plugin_linked", None) is not None:
9494
9866
  settings_save(st)
9495
9867
  sys.exit(r.returncode)
9496
- die("usage: orch view plugin link|unlink|refresh (herdr 0.7.4 or newer)")
9868
+ die("usage: orch view plugin link|key [<key>]|unlink|refresh (herdr 0.7.4 or newer)")
9497
9869
  if sub:
9498
9870
  die(f"unknown `orch view {sub}` — use: orch view [--lan] [--port N] [--no-open] [--bg] | stop | status | "
9499
- f"herdr-config | plugin link|unlink|refresh")
9871
+ f"herdr-config | plugin link|key|unlink|refresh | app link|unlink")
9500
9872
  lan = "--lan" in args
9501
9873
  port = 0
9502
9874
  if "--port" in args:
@@ -10480,9 +10852,13 @@ USAGE = """usage: orch <command> [args]
10480
10852
  team <kind> [--coders N] [--models a,b] [--no-reviewer] [--prefix <name>]
10481
10853
  the plan's team built from one installed tool: coders + reviewer on its catalog models
10482
10854
  (named after the repo, e.g. app-codex-1, while another run is going on this machine)
10483
- team up [--dry-run] [--mode panes|subagent]
10484
- open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it
10485
- (subagent mode: no panes; sets up the Pi coder/reviewer subagents instead)
10855
+ team up [--dry-run] [--here] [--mode panes|subagent]
10856
+ open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it,
10857
+ in a herdr tab of their own ("team") as a grid of equal panes (at most 4 a tab, fewer on a
10858
+ small screen; more go to "team 2"), so the lead keeps its whole screen. --here: split
10859
+ next to this pane instead (subagent mode: no panes; sets up the Pi subagents instead)
10860
+ team tidy [--dry-run] move the coder and reviewer panes already open (by hand, or next to the lead) into that
10861
+ team tab grid; they keep running and keep their names. Never moves the lead's pane
10486
10862
  mode [panes|subagent] [--agent <kind>] this agent's mode, or save one: panes (herdr panes, the default for
10487
10863
  every agent) or subagent (one Pi window; Pi only). Saved per agent in
10488
10864
  ~/.config/herdr-orchestra/config.json ("modes": {"pi": "subagent"}); ORCH_MODE=panes|subagent
@@ -10528,7 +10904,7 @@ USAGE = """usage: orch <command> [args]
10528
10904
  view [--lan] [--port N] [--no-open] [--bg]
10529
10905
  the run as a live picture in your browser (view only): milestone graph, agents, details,
10530
10906
  "needs you" alert, time and cost, replay. --lan: also from your phone, with a secret link
10531
- view stop|status|herdr-config|plugin link|unlink|refresh
10907
+ view stop|status|herdr-config|plugin link|key|unlink|refresh|app link|unlink
10532
10908
  stop it / show its link / sidebar lines for herdr's config / the optional herdr plugin
10533
10909
  board [--once] the run as text, redrawn when it changes: for a herdr pane or popup (any terminal);
10534
10910
  [f] or [enter] on a milestone shows its changed files, [enter] on a file its diff
@@ -10840,6 +11216,8 @@ def cmd_lead(args):
10840
11216
  if not part and not subagent:
10841
11217
  lead_self_name()
10842
11218
  guard_ensure(say_changes=False) # no agent pushes to main: the repo refuses it from the start
11219
+ if sub == "plan":
11220
+ print(archive_finished_plan(), end="") # the new plan goes in plan.md, never under another name
10843
11221
  if sub == "plan" and not part:
10844
11222
  print(picker_note(lead_kind()), end="")
10845
11223
  print(onboard_plan_note(), end="") # a project never set up for its agents: set it up first
@@ -12816,7 +13194,7 @@ if __name__ == "__main__":
12816
13194
  "team": cmd_team, "update": cmd_update, "config": cmd_config, "mode": cmd_mode,
12817
13195
  "setup": cmd_setup, "guard": cmd_guard}
12818
13196
  if (len(sys.argv) >= 2 and sys.argv[1] in NO_REPO_COMMANDS # work outside a git repo
12819
- and sys.argv[2:3] != ["up"] and sys.argv[2:3] != ["--crash"]): # (`orch team up` reads the run's state)
13197
+ and sys.argv[2:3] not in (["up"], ["tidy"], ["--crash"])): # (`orch team up|tidy` read the run's state)
12820
13198
  try:
12821
13199
  NO_REPO_COMMANDS[sys.argv[1]](sys.argv[2:])
12822
13200
  sys.stdout.flush()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.44.2",
3
+ "version": "6.46.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": {
package/playbooks/plan.md CHANGED
@@ -11,6 +11,7 @@ You need only three herdr commands, exactly as written here: `herdr agent list`
11
11
  - You give every milestone a **role**: the specialist the coder should work as, and what that specialist cares about here (step 6, Role). That sets the standard, not the method.
12
12
  - You also decide **which level of model each milestone needs** (small, medium or high) and say why (step 6), and **how long each milestone and the whole feature should take** (step 6, Estimate).
13
13
  - **Nobody pushes to main.** No agent (you, the coders, the reviewer) ever pushes to main, master or the repo's default branch, or merges a PR, in any situation, even when the developer asks: refuse in one line and offer the run's branch and a PR, which a person merges by hand. A plan's `Branch:` is never main or master (`orch sync` refuses it), and the repo's pre-push guard (`orch guard`) refuses such a push anyway: never get around it.
14
+ - **One plan file: `.orchestrate/plan.md`.** Every plan, quick or full, goes in `.orchestrate/plan.md`, even when one is already there. Never write a plan under another name (`.orchestrate/sap-plan.md`, `new-plan.md`...): orch reads only plan.md, so a plan under another name is never run, never tracked, and the board keeps showing the old run. A finished run's plan is not lost: `orch lead plan` moved it to `.orchestrate/archive/` (the `ARCHIVED` line above). If plan.md is still there, it belongs to a run that is not over: ask the developer before replacing it.
14
15
  - You never edit application code, and you never prompt worker agents: you hand out work with `orch dispatch`, and the event manager (`orch autopilot`, a plain script) prompts the agents, watches them and wakes you when something needs a decision.
15
16
 
16
17
  Feature request = the user's message that asked you to run this playbook.
package/playbooks/run.md CHANGED
@@ -28,7 +28,7 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
28
28
 
29
29
  ## 1. Start the run (the developer said go)
30
30
  1. Run `orch sync`. Stop on ERROR; report every WARN.
31
- 2. Run `orch start`. It checks that herdr can wake you: it names your pane `lead` if it is not named yet (`NAMED`), or refuses with `NO LEAD` and the exact `herdr agent rename <pane> lead` command; give that to the developer and stop. `orch dispatch` makes the same check. If a worker or the reviewer shows `herdr=NOT FOUND`, run `orch team up`: it opens a pane for each missing agent next to yours, in its folder (its worktree, or the repo), starts it on its plan model and gives it its plan name. Then run `orch start` again. If team up reports `WAITING` (the new pane shows a first-run question such as "trust this folder" or a sign-in) or `FAILED`, or a worker shows `STALE pane`, tell the developer exactly what to do in which pane (`orch agents launch <kind> --model <id>` gives the start command), and stop. `WARN agent <kind>: …` means a launch flag in the registry is out of date for the installed tool; show it (`orch doctor <kind>` has the detail). Workers shown as `detect:off` are fine.
31
+ 2. Run `orch start`. It checks that herdr can wake you: it names your pane `lead` if it is not named yet (`NAMED`), or refuses with `NO LEAD` and the exact `herdr agent rename <pane> lead` command; give that to the developer and stop. `orch dispatch` makes the same check. If a worker or the reviewer shows `herdr=NOT FOUND`, run `orch team up`: it opens a pane for each missing agent in a herdr tab called `team` (your tab stays whole), in its folder (its worktree, or the repo), starts it on its plan model and gives it its plan name. Then run `orch start` again. If team up reports `WAITING` (the new pane shows a first-run question such as "trust this folder" or a sign-in) or `FAILED`, or a worker shows `STALE pane`, tell the developer exactly what to do in which pane (`orch agents launch <kind> --model <id>` gives the start command), and stop. `WARN agent <kind>: …` means a launch flag in the registry is out of date for the installed tool; show it (`orch doctor <kind>` has the detail). Workers shown as `detect:off` are fine.
32
32
  3. Dispatch every milestone whose dependencies are met: `orch dispatch M1 M2`. It prints who can take each one, and starts the event manager if none is running. If it says it could not start it, ask the developer to run `orch autopilot` in a terminal.
33
33
  - `--to <worker>` gives a milestone to one coder; `--tier high` asks for a stronger model than the plan says. Use them only with a reason, and tell the developer.
34
34
  4. Tell the developer in two lines what is running where (milestone → coder and model). **STOP.**
@@ -0,0 +1,110 @@
1
+ // The herdr-orchestra run board in the Herdr desktop app (herdr-app). Installed by `orch view plugin link`.
2
+ // Command palette: "orch: run board" (mod.open). It starts `orch board` in a herdr-core terminal, in the folder of
3
+ // the terminal you were in, and shows it in a window over your tabs with a thin title bar. `q` in the board, or ✕,
4
+ // closes it. Herdr in a terminal uses the herdr plugin in ../herdr-plugin instead (prefix+a).
5
+ //
6
+ // Two roles, by props:
7
+ // opener (mod.open, no props): starts the board terminal, opens the window, closes itself;
8
+ // shows the error instead when the board can't start.
9
+ // bar ({ bar: true, terminal }): the window's title bar; ends the board terminal when the window goes.
10
+
11
+ import { View, div } from "gpui-kit";
12
+ import { v_flex, h_flex } from "gpui-base";
13
+ import { hc, run, props, focused, spaces, theme, openOverlay, closeOverlay, checking } from "herdr";
14
+
15
+ // orch on PATH (the core loads the login shell's exports), else where install.sh puts it
16
+ const BOARD = 'if command -v orch >/dev/null 2>&1; then exec orch board; else exec "$HOME/.local/bin/orch" board; fi';
17
+
18
+ export default class OrchBoard extends View {
19
+ init(_props, cx) {
20
+ this.error = null;
21
+ if (props()?.bar || checking()) return;
22
+ cx.spawn(async (cx) => {
23
+ const f = focused();
24
+ const space = spaces().find((s) => s.id === f?.space) ?? spaces().find((s) => s.active);
25
+ const cwd = f?.cwd || space?.folder || null;
26
+ const args = ["run", "--bg", "--json", "--rm", "--no-parent", "--name", `orch-board-${Date.now() % 100000}`];
27
+ if (space?.machine) args.push("--on", space.machine);
28
+ if (cwd) args.push("--cwd", cwd);
29
+ args.push("--", "sh", "-c", BOARD);
30
+ let r;
31
+ try {
32
+ r = await hc(args);
33
+ } catch (e) {
34
+ r = { code: 1, stdout: "", stderr: String(e) };
35
+ }
36
+ let addr = null;
37
+ try {
38
+ addr = r.code === 0 ? JSON.parse(r.stdout).address : null;
39
+ } catch {}
40
+ if (!addr) {
41
+ this.error = `Could not start orch board: ${(r.stderr || r.stdout || "no answer from hc").trim()}`;
42
+ cx.notify();
43
+ return;
44
+ }
45
+ openOverlay({
46
+ kind: "dialog",
47
+ width: 0.9,
48
+ height: 0.85,
49
+ layout: {
50
+ type: "column",
51
+ children: [
52
+ { type: "block", size: { px: 28 }, content: { mod: "orch-board", props: { bar: true, terminal: addr } } },
53
+ { type: "block", content: { terminal: addr } },
54
+ ],
55
+ },
56
+ });
57
+ run("pane.focus", { terminal: addr });
58
+ closeOverlay(props()?.overlay);
59
+ });
60
+ }
61
+
62
+ async close(_cx) {
63
+ const p = props() ?? {};
64
+ if (p.bar && p.terminal) run("terminal.kill", { terminal: p.terminal });
65
+ }
66
+
67
+ render(_cx) {
68
+ const t = theme();
69
+ const p = props() ?? {};
70
+ if (p.bar) {
71
+ return h_flex()
72
+ .id("orch-board-bar")
73
+ .size_full()
74
+ .px(12)
75
+ .gap(8)
76
+ .items_center()
77
+ .bg(t.surface)
78
+ .border_b(1)
79
+ .border_color(t.border)
80
+ .text_size(12)
81
+ .child(div().font_semibold().text_color(t.foreground).child("orch board"))
82
+ .child(div().text_color(t.dim).child("q closes"))
83
+ .child(div().flex_1())
84
+ .child(
85
+ div()
86
+ .id("orch-board-close")
87
+ .px(8)
88
+ .py(2)
89
+ .rounded(5)
90
+ .text_color(t.muted)
91
+ .cursor_pointer()
92
+ .hover((s) => s.bg(t.hover).text_color(t.foreground))
93
+ .on_click(() => closeOverlay(p.overlay))
94
+ .child("✕"),
95
+ );
96
+ }
97
+ return v_flex()
98
+ .id("orch-board-open")
99
+ .size_full()
100
+ .p(18)
101
+ .gap(8)
102
+ .bg(t.popover)
103
+ .text_size(13)
104
+ .child(div().text_size(15).font_semibold().text_color(t.foreground).child("orch board"))
105
+ .child(div().text_color(this.error ? t.blocked ?? t.foreground : t.muted).child(this.error ?? "Starting the board…"))
106
+ .when(Boolean(this.error), (el) =>
107
+ el.child(div().text_color(t.dim).child("Check that orch is installed (`orch --version` in a terminal here), then try again.")),
108
+ );
109
+ }
110
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "place": "none",
3
+ "title": "orch board",
4
+ "overlay": {
5
+ "width": 460,
6
+ "height": 150
7
+ },
8
+ "palette": [
9
+ {
10
+ "title": "orch: run board",
11
+ "command": "mod.open",
12
+ "args": {
13
+ "name": "orch-board"
14
+ },
15
+ "words": "orch herdr-orchestra board run milestones"
16
+ }
17
+ ]
18
+ }