herdr-orchestra 6.48.0 → 6.48.2

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,66 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.48.2] - 2026-12-02
6
+
7
+ `orch board` now has three tabs: Milestones, Agents and Tokens. The run's top lines (how many landed, time so far, total tokens, who needs you) stay on every tab, so nothing important is ever hidden. Switch with Tab, the left and right arrows, or the keys 1, 2 and 3. The board opens on Milestones. Every tab updates live, and the old keys still work: up/down to pick, Enter for a milestone's changed files (Milestones tab) or to jump to an agent (Agents tab), f, w and q. Agent names show in full, however long they are.
8
+
9
+ Example (the Agents tab):
10
+ ```
11
+ orch board · feat/rupee-flow 17:44 · live
12
+ 2 of 5 landed · 1 needs you · 38m so far of ~1h 10m
13
+ tokens 341k so far · lead 61k
14
+
15
+ 1 Milestones [2 Agents] 3 Tokens
16
+
17
+ ◆ lead claude high planning
18
+ ›● agy-2 agy medium M3 · building
19
+ ○ rupee-flow-review codex high free
20
+
21
+ [tab ←→ 1-3] switch [↑↓] pick [enter] jump to that agent [f] files [w] web [q] close
22
+ ```
23
+
24
+ Each agent's pane now carries a label that says who it is and what it does: `agy-2 · coder · M3`, `agy-2 · coder` when it is free, `rupee-flow-review · reviewer`, and `lead`. It changes when a coder moves to another milestone. orch sets it with herdr's `pane rename`, a pane label that is separate from the agent's name, so orch still finds every agent by its name.
25
+
26
+ ### Added
27
+ - `orch board`: tabs Milestones, Agents, Tokens (Tab, Shift+Tab, ←→, 1-3). The Tokens tab also lists each milestone's tokens. `orch board --once --tab agents` prints one tab; `--once` alone still prints the whole board.
28
+ - Pane labels: orch labels each agent's pane when a coder starts or finishes a milestone, and gives every label again on `orch team up` and `orch resume` (a herdr restart loses them). Only a label that changed is sent. `ORCH_PANE_LABELS=0` turns them off.
29
+
30
+ ### Changed
31
+ - The board no longer cuts or misaligns long agent names: the name column is as wide as the longest name.
32
+ - AGENTS.md: the token rule now covers every agent, not only the lead. A change must not raise the total tokens of a run (lead, coders, reviewer) without a reason, and must not make runs work worse. PRs report coder and reviewer text sizes too when they change.
33
+ - `orch view` (the browser page) has its own layout and is unchanged. The herdr desktop app's board runs `orch board`, so it gets the tabs too. The lead reads no new text.
34
+
35
+ ## [6.48.1] - 2026-12-02
36
+
37
+ `orch board` gets a TOKENS part: one row per agent (the lead, each coder, the reviewer) with what it read (in, and the cached part of that) and what it wrote (out), counted live. Before, a job's tokens showed only after the job ended. Now the job an agent is running counts too, read from the agent's own log from the job's start to now, so the numbers move after each reply the tool writes. The board looks again every 10 seconds while a job runs. Each coder that is on a milestone also shows that milestone's role and the skills the plan gave it.
38
+
39
+ Example:
40
+ ```
41
+ AGENTS
42
+ ● codex-1 codex M2 · building
43
+ role: senior frontend engineer
44
+ skills: frontend-developer (codex can't see its folder), ghost-skill (not in this repo)
45
+
46
+ TOKENS read live from each agent's own log
47
+ in cached out
48
+ ◆ lead-1 codex 50k 30k 4k
49
+ ● codex-1 codex 100k 76k 7k M2 now 44k
50
+ ○ rev-1 codex 8k 6k 1k
51
+ ○ oc-1 opencode n/a: orch can't read opencode's logs yet
52
+ total 158k 112k 12k
53
+ ```
54
+
55
+ Which agents can show live numbers: Claude Code, Codex and Pi save the token count after every reply, so they show live. Antigravity (agy) is read the same way, but it has not yet been checked on a real machine whether agy writes its log while it works or only at the end. OpenCode logs are not read yet, so OpenCode agents show "n/a" with that reason, never a guessed number.
56
+
57
+ ### Added
58
+ - `orch board`: TOKENS part (in, cached, out per agent; "Mn now" for the running job; total), "+Nk now" on a building milestone, and a role and skills line under each busy coder. A skill the coder's tool can't see, or that is not in the repo, is marked.
59
+ - `orch view`: "Tokens per agent (live)" in the Time and tokens card, the total includes running jobs, and each busy coder shows its role and skills. The page gets a fresh copy every 10 seconds while a job runs.
60
+ - `orch status --json`: `agent_tokens`, plus `step_role` and `skills` on busy coders.
61
+
62
+ ### Changed
63
+ - The board and the view read the logs themselves (read only). A log is read again only when its size or change time changed. The lead reads no new text and gets no new wake-ups.
64
+
5
65
  ## [6.48.0] - 2026-12-02
6
66
 
7
67
  The lead now follows a repository's own delivery standard. When `AGENTS.md` points to one (a doc, a checklist, a skill or a link that says what every change must deliver), the lead reads it while planning, writes the requirements that apply to this change into the plan, makes sure every coder's brief spells them out as plain instructions (so a coder that does not have that doc or skill can still follow them), and checks each one at the end. A repository whose `AGENTS.md` names no delivery standard gets exactly the same plan and run as before.
package/README.md CHANGED
@@ -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 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.
351
+ - **`orch board`** draws the same run as text for a Herdr pane, in three tabs under the run's top line: Milestones, Agents and Tokens (switch with Tab, ←→ or 1-3); `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.48.0
1
+ 6.48.2
Binary file
package/bin/orch CHANGED
@@ -263,6 +263,7 @@ def save(st):
263
263
  tmp = STATE.with_suffix(".tmp")
264
264
  tmp.write_text(json.dumps(st, indent=2))
265
265
  tmp.replace(STATE)
266
+ pane_labels(st)
266
267
  if _EVENTS:
267
268
  with (ORCH / "events.jsonl").open("a") as f:
268
269
  for ev in _EVENTS:
@@ -270,6 +271,49 @@ def save(st):
270
271
  _EVENTS.clear()
271
272
 
272
273
 
274
+ # ---- pane labels (6.48.2): each agent's pane says who it is and what it does, e.g. "agy-2 · coder · M3". herdr's
275
+ # `pane rename` sets a pane label (shown on the pane's border) that is separate from the agent's name, so orch still
276
+ # finds the agent by name. Only a label that changed is sent, so most saves don't call herdr at all.
277
+ PANE_LABELS = ".pane-labels.json" # in .orchestrate: the labels orch last gave each pane
278
+ PANE_LABEL_RETRY_S = 60 # an agent herdr can't find yet: try again after this long, not on every save
279
+
280
+
281
+ def pane_label_map(st):
282
+ """{agent name: its pane label} for the lead, every coder and the reviewer."""
283
+ out = {}
284
+ ld = (st.get("lead") or {}).get("name")
285
+ if ld:
286
+ out[ld] = "lead" if ld == "lead" else f"{ld} · lead"
287
+ for n, w in (st.get("workers") or {}).items():
288
+ out[n] = f"{n} · coder" + (f" · {w['task']}" if w.get("task") else "")
289
+ if st.get("reviewer"):
290
+ out[st["reviewer"]] = f"{st['reviewer']} · reviewer"
291
+ return out
292
+
293
+
294
+ def pane_labels(st, force=False):
295
+ """Give each agent's pane its label when it changed (a coder moved to another milestone, or was freed)."""
296
+ if os.environ.get("ORCH_PANE_LABELS", "1") == "0" or run_mode(st) != "panes":
297
+ return
298
+ want = pane_label_map(st)
299
+ p = ORCH / PANE_LABELS
300
+ try:
301
+ had = json.loads(p.read_text())
302
+ except (OSError, ValueError):
303
+ had = {}
304
+ now, changed = time.time(), False
305
+ for n, label in want.items():
306
+ h = had.get(n) or {}
307
+ if not force and h.get("label") == label and (h.get("ok") or now - h.get("ts", 0) < PANE_LABEL_RETRY_S):
308
+ continue
309
+ pane = agent_info(st, n).get("pane") or agent_pane(n)
310
+ ok = bool(pane) and _herdr_json([HERDR, "pane", "rename", pane, label])[0]
311
+ had[n], changed = {"label": label, "pane": pane, "ok": ok, "ts": now}, True
312
+ if changed:
313
+ with contextlib.suppress(OSError):
314
+ p.write_text(json.dumps(had))
315
+
316
+
273
317
  def fault(point):
274
318
  """Test hook: ORCH_FAULT=<point> kills orch (and the autopilot driving it) right here, like a crash."""
275
319
  if os.environ.get("ORCH_FAULT") != point:
@@ -2475,8 +2519,31 @@ TOKEN_GLOBS = {"claude": "*/*.jsonl", "codex": "**/rollout-*.jsonl*", "pi": "*/*
2475
2519
  "agy": "*/.system_generated/logs/transcript_full.jsonl"}
2476
2520
 
2477
2521
 
2522
+ _TOK_TEXT = {}
2523
+
2524
+
2478
2525
  def _tok_text(path):
2526
+ """A log's text. The live board reads the same logs every few seconds: a file that has not changed since the last
2527
+ read is not read again (kept by size and change time, the last few files only)."""
2479
2528
  p = str(path)
2529
+ try:
2530
+ s = os.stat(p)
2531
+ sig = (s.st_mtime_ns, s.st_size)
2532
+ except OSError:
2533
+ sig = None
2534
+ hit = _TOK_TEXT.get(p)
2535
+ if sig and hit and hit[0] == sig:
2536
+ return hit[1]
2537
+ text = _tok_text_read(p)
2538
+ if sig:
2539
+ _TOK_TEXT.pop(p, None)
2540
+ _TOK_TEXT[p] = (sig, text)
2541
+ while len(_TOK_TEXT) > 12:
2542
+ _TOK_TEXT.pop(next(iter(_TOK_TEXT)))
2543
+ return text
2544
+
2545
+
2546
+ def _tok_text_read(p):
2480
2547
  if p.endswith(".zst"):
2481
2548
  if not shutil.which("zstd"):
2482
2549
  raise TokenNA("the log is compressed (.zst) and the `zstd` tool is not installed")
@@ -2912,6 +2979,148 @@ def token_lines(acct):
2912
2979
  return out
2913
2980
 
2914
2981
 
2982
+ # ---- live tokens per agent, for the board and the browser view (6.48.1). The board process reads the logs, never
2983
+ # the lead: a running job's tokens are its log from the job's start to now, so they move after each reply the tool
2984
+ # writes. Read only, and a log is read again only when it changed.
2985
+ _LIVE_FIND, _LIVE_MISS, _LIVE_WIN = {}, {}, {}
2986
+
2987
+
2988
+ def _tok_sig(kind, path):
2989
+ files = [Path(path)]
2990
+ if kind == "claude":
2991
+ files += sorted((Path(path).with_suffix("") / "subagents").glob("*.jsonl"))
2992
+ sig = []
2993
+ for f in files:
2994
+ with contextlib.suppress(OSError):
2995
+ s = f.stat()
2996
+ sig.append((str(f), s.st_mtime_ns, s.st_size))
2997
+ return tuple(sig)
2998
+
2999
+
3000
+ def token_live(st, agent, kind, marker, start, end=None):
3001
+ """One job's tokens up to now (end None: still running) or up to its end: {"in", "cached", "out"}, {"na": why},
3002
+ or None (no reply in the tool's log yet)."""
3003
+ if not kind:
3004
+ return {"na": "orch does not know which tool this agent runs"}
3005
+ if kind not in TOKEN_KINDS:
3006
+ return {"na": f"orch can't read {kind}'s logs yet"}
3007
+ if not marker:
3008
+ return {"na": "no job prompt to find the log by"}
3009
+ path = _LIVE_FIND.get((kind, marker))
3010
+ if not path or not Path(path).exists():
3011
+ if time.time() - _LIVE_MISS.get((kind, marker), 0) < 10: # not there 10s ago: don't search every redraw
3012
+ return None
3013
+ path = token_log_find(kind, marker, start, (st.get("token_logs") or {}).get(agent) or [])
3014
+ if not path:
3015
+ _LIVE_MISS[(kind, marker)] = time.time()
3016
+ return None
3017
+ _LIVE_FIND[(kind, marker)] = path
3018
+ key, sig = (kind, path, start, end), _tok_sig(kind, path)
3019
+ hit = _LIVE_WIN.get(key)
3020
+ if hit and hit[0] == sig:
3021
+ return hit[1]
3022
+ try:
3023
+ acc = token_window(kind, path, start, end + 1 if end else float("inf"))
3024
+ r = {"in": acc["in"], "cached": acc["cached"], "out": acc["out"]} if acc["replies"] else None
3025
+ except TokenNA as e:
3026
+ r = {"na": str(e)}
3027
+ _LIVE_WIN[key] = (sig, r)
3028
+ if len(_LIVE_WIN) > 200:
3029
+ _LIVE_WIN.pop(next(iter(_LIVE_WIN)))
3030
+ return r
3031
+
3032
+
3033
+ def agent_tokens(st):
3034
+ """Tokens per agent (lead, each coder, the reviewer): every finished job plus the one it runs now, read live.
3035
+ [{name, role, kind, in, cached, out, known, jobs, na: [why], task: running milestone, now: its tokens so far}]"""
3036
+ rows, t_now = {}, now()
3037
+
3038
+ def row(name, role, kind):
3039
+ if name not in rows:
3040
+ rows[name] = {"name": name, "role": role, "kind": kind, "in": 0, "cached": 0, "out": 0, "known": 0,
3041
+ "jobs": 0, "na": [], "task": None, "now": None}
3042
+ return rows[name]
3043
+
3044
+ def add(r, u):
3045
+ r["jobs"] += 1
3046
+ if "na" in u:
3047
+ r["na"].append(u["na"])
3048
+ return
3049
+ r["known"] += 1
3050
+ for k in ("in", "cached", "out"):
3051
+ r[k] += int(u.get(k) or 0)
3052
+ ld, run = st.get("lead") or {}, st.get("run") or {}
3053
+ if ld.get("name"):
3054
+ r = row(ld["name"], "lead", ld.get("kind"))
3055
+ if run.get("started"):
3056
+ u = token_live(st, ld["name"], ld.get("kind"), f"in the run on {st.get('branch')} need the lead",
3057
+ run["started"], run.get("ended"))
3058
+ saved = run.get("lead_tokens")
3059
+ if (u is None or "na" in u) and isinstance(saved, dict) and "na" not in saved:
3060
+ u = saved
3061
+ add(r, u or {"na": "orch has not woken the lead in this run yet"})
3062
+ for n, w in st.get("workers", {}).items():
3063
+ row(n, "coder", w.get("kind"))
3064
+ if st.get("reviewer"):
3065
+ row(st["reviewer"], "reviewer", (st.get("reviewer_info") or {}).get("kind"))
3066
+ for tid in st.get("order", []):
3067
+ t = st["tasks"].get(tid) or {}
3068
+ for a in t.get("attempts") or []:
3069
+ if not isinstance(a, dict) or not a.get("agent") or not (a.get("tok_marker") or a.get("tokens")):
3070
+ continue
3071
+ r = row(a["agent"], "reviewer" if a.get("kind") == "reviewer" else "coder",
3072
+ a.get("tok_kind") or agent_kind_of(st, a["agent"]))
3073
+ u = a.get("tokens")
3074
+ if u is None: # finished a moment ago: orch saves it after a short wait
3075
+ u = token_live(st, a["agent"], r["kind"], a["tok_marker"], a.get("start", 0), a.get("end", t_now))
3076
+ if u is None:
3077
+ if t_now - a.get("end", t_now) < TOKEN_GIVE_UP_S:
3078
+ continue
3079
+ u = {"na": f"no {r['kind']} log has this job's prompt"}
3080
+ add(r, u if isinstance(u, dict) else {"na": "not read"})
3081
+ w = t.get("wait") or {}
3082
+ if w.get("agent") and w.get("prompt") and t.get("status") in ACTIVE:
3083
+ r = row(w["agent"], "reviewer" if w.get("kind") == "reviewer" else "coder", agent_kind_of(st, w["agent"]))
3084
+ u = token_live(st, w["agent"], r["kind"], token_marker(w["prompt"]), w.get("started", w.get("since", 0)))
3085
+ r["task"], r["now"] = tid, u or {"in": 0, "cached": 0, "out": 0}
3086
+ if u:
3087
+ add(r, u)
3088
+ return list(rows.values())
3089
+
3090
+
3091
+ def agent_steps(st):
3092
+ """For each coder on a milestone now: the milestone's role and the skills the plan gave it, each with a note when
3093
+ the coder's tool can't see that skill's folder. {agent: {"task", "role", "skills": [{"name", "note"}]}}"""
3094
+ busy = {}
3095
+ for n, w in st.get("workers", {}).items():
3096
+ if w.get("task"):
3097
+ busy[n] = (w["task"], w.get("kind"))
3098
+ if not busy:
3099
+ return {}
3100
+ try:
3101
+ secs, _ = plan_sections()
3102
+ except OSError:
3103
+ secs = {}
3104
+ reg = registry(required=False) or {}
3105
+ try:
3106
+ skills = project_skills(ROOT, reg)
3107
+ except OSError:
3108
+ skills = []
3109
+ names = {s["name"] for s in skills}
3110
+ out = {}
3111
+ for n, (tid, kind) in busy.items():
3112
+ t = st["tasks"].get(tid) or {}
3113
+ want = plan_skills(secs[tid]) if tid in secs else []
3114
+ v = reg.get(kind) if kind else None
3115
+ sees = ({s["name"] for s in agent_project_view(ROOT, kind, v, skills)["skills"]}
3116
+ if v and v.get("project_skills_reads") else None)
3117
+ out[n] = {"task": tid, "role": t.get("role") or "",
3118
+ "skills": [{"name": w_, "note": "not in this repo" if w_ not in names else
3119
+ f"{kind} can't see its folder" if sees is not None and w_ not in sees else ""}
3120
+ for w_ in want]}
3121
+ return out
3122
+
3123
+
2915
3124
  def finding_axis(f):
2916
3125
  """Which of the reviewer's two questions a finding answers: "spec" (built what was asked?) or "rules" (follows
2917
3126
  the repo's written rules?); None for a review written before 6.6.0 that does not say."""
@@ -9057,6 +9266,8 @@ def team_up(args):
9057
9266
  continue
9058
9267
  todo.append((name, w, d))
9059
9268
  if not todo:
9269
+ if not dry:
9270
+ pane_labels(st, force=True)
9060
9271
  print("TEAM UP: every agent in the plan is running")
9061
9272
  return
9062
9273
  failed, last, opened = 0, None, []
@@ -9145,6 +9356,7 @@ def team_up(args):
9145
9356
  + (f" (its last screen is in {short(saved)})" if saved else "") + ", then `orch team up` again")
9146
9357
  log_line(f"{run_tag(st)} QUIT {name}: {w.get('kind')} exited right after `orch team up` started it "
9147
9358
  f"in pane {pid}")
9359
+ pane_labels(st, force=True) # each pane says who it is: "agy-2 · coder", "rev-1 · reviewer", "lead"
9148
9360
  if tabs and not dry:
9149
9361
  print(f"TAB the team is in the herdr tab{'s' if len(tabs) > 1 else ''} " + ", ".join(f'"{t}"' for t in tabs)
9150
9362
  + ", so the lead keeps its whole screen — switch tabs to watch them (`orch team tidy` moves panes "
@@ -9312,6 +9524,8 @@ def cmd_resume(args):
9312
9524
  busy = [(tid, st["tasks"][tid]["wait"]) for tid in st["order"] if st["tasks"][tid].get("wait")]
9313
9525
  gap = account_downtime(st)
9314
9526
  save(st)
9527
+ if not from_manager:
9528
+ pane_labels(st, force=True) # a restart loses the pane labels too
9315
9529
  if from_manager and not gap:
9316
9530
  return
9317
9531
  if gap and (busy or not from_manager):
@@ -9600,6 +9814,18 @@ def view_model(st=None, recent=40):
9600
9814
  agents.append({"name": st["reviewer"], "role": "reviewer", "kind": ri.get("kind"), "model": ri.get("model"),
9601
9815
  "tier": ri.get("tier"), "task": busy, "state": "reviewing" if busy else
9602
9816
  "compacting" if ri.get("compacting") else "free"})
9817
+ try:
9818
+ steps = agent_steps(st)
9819
+ except Exception: # a broken plan or registry never stops the board
9820
+ steps = {}
9821
+ for a in agents:
9822
+ sp = steps.get(a["name"])
9823
+ if sp and sp["task"] == a.get("task"):
9824
+ a["step_role"], a["skills"] = sp["role"], sp["skills"]
9825
+ try:
9826
+ atok = agent_tokens(st)
9827
+ except Exception:
9828
+ atok = []
9603
9829
  groups = [m["group"] for m in ms]
9604
9830
  run = st.get("run") or {}
9605
9831
  return {
@@ -9620,7 +9846,7 @@ def view_model(st=None, recent=40):
9620
9846
  "cached": tacct["lead"]["cached"], "out": tacct["lead"]["out"]}},
9621
9847
  "usage": {"total": _usage_sum([u for v in by_model.values() for u in v]),
9622
9848
  "by_model": {k: _usage_sum(v) for k, v in by_model.items()}},
9623
- "milestones": ms, "agents": agents,
9849
+ "milestones": ms, "agents": agents, "agent_tokens": atok,
9624
9850
  "lead": ({"name": st["lead"]["name"], "unread": len(unread_events(st)),
9625
9851
  "open": len([e for e in st.get("lead_events", []) if event_open(st, e)])} if st.get("lead") else None),
9626
9852
  "recent": view_events(recent)[::-1],
@@ -9726,13 +9952,15 @@ def serve_view(port, lan, token, opened):
9726
9952
  self.send_header("Content-Type", "text/event-stream")
9727
9953
  self.send_header("Cache-Control", "no-store")
9728
9954
  self.end_headers()
9729
- last, beat = None, time.time()
9955
+ last, beat, running = None, time.time(), False
9730
9956
  try:
9731
9957
  while True:
9732
9958
  k = _view_snapshot_key()
9733
- if k != last:
9959
+ if k != last or running and time.time() - beat > 10: # live tokens: again every 10s
9734
9960
  last = k
9735
- self.wfile.write(f"event: state\ndata: {json.dumps(view_model())}\n\n".encode())
9961
+ vm_ = view_model()
9962
+ running = any(r.get("task") for r in vm_.get("agent_tokens") or [])
9963
+ self.wfile.write(f"event: state\ndata: {json.dumps(vm_)}\n\n".encode())
9736
9964
  self.wfile.flush()
9737
9965
  beat = time.time()
9738
9966
  elif time.time() - beat > 15:
@@ -10514,7 +10742,9 @@ def _fmt_min(s):
10514
10742
  return f"{s // 3600}h {s % 3600 // 60}m" if s >= 3600 else f"{max(0, s) // 60}m"
10515
10743
 
10516
10744
 
10517
- def render_board(vm, width=100, color=True, sel=None, note=""):
10745
+ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10746
+ """The board as lines. tab None: every part one under the other (`orch board --once`); "m", "a" or "t": the top
10747
+ lines, the tab bar and that tab only (the live board)."""
10518
10748
  def c(k, s):
10519
10749
  return f"\x1b[{_C[k]}m{s}\x1b[0m" if color and k else s
10520
10750
 
@@ -10530,7 +10760,11 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10530
10760
  + (" · " + c("r", f"{cn['needs_you']} needs you") if cn["needs_you"] else "")
10531
10761
  + c("d", f" · {_fmt_min(vm['time']['driven_s'])} so far"
10532
10762
  + (f" of ~{_fmt_min(vm['time']['estimate_s'])}" if vm["time"].get("estimate_s") else ""))]
10533
- tk = vm.get("tokens") or {}
10763
+ tk = dict(vm.get("tokens") or {})
10764
+ at = vm.get("agent_tokens") or []
10765
+ if any(r["known"] for r in at): # the live count: finished jobs and the jobs running now
10766
+ tk["total"] = sum(r["in"] + r["out"] for r in at)
10767
+ tk["partial"] = any(r["na"] for r in at)
10534
10768
  if tk.get("total") or tk.get("lead"):
10535
10769
  ld = tk.get("lead") or {}
10536
10770
  out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far"
@@ -10539,9 +10773,14 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10539
10773
  if vm.get("all_done"):
10540
10774
  out.append(c("g", "ALL DONE — `orch finish` pushes the branch and opens the PR"))
10541
10775
  out += notes
10542
- out += ["", c("d", "MILESTONES")]
10776
+ if tab:
10777
+ out += ["", " ".join(c("a", f"[{i} {w}]") if k == tab else c("d", f" {i} {w} ")
10778
+ for i, (k, w) in enumerate(BOARD_TABS, 1))]
10779
+ if tab in (None, "m"):
10780
+ out += [""] + ([c("d", "MILESTONES")] if tab is None else [])
10543
10781
  ms = {m["id"]: m for m in vm["milestones"]}
10544
- rows = board_rows(vm)
10782
+ live_now = {r["task"]: r.get("now") for r in at if r.get("task")}
10783
+ rows = board_rows(vm, tab)
10545
10784
  picked = rows[sel] if sel is not None and sel < len(rows) else None
10546
10785
  name_w = max(18, min(34, width - 52))
10547
10786
 
@@ -10555,6 +10794,9 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10555
10794
  if mt:
10556
10795
  extra += (" " if extra else "") + (f"{_tk(mt['total'])}{'+' if mt['partial'] else ''} tok"
10557
10796
  if mt["total"] else "tokens n/a")
10797
+ nw = live_now.get(m["id"])
10798
+ if nw and "na" not in nw:
10799
+ extra += (" " if extra else "") + f"+{_tk(nw['in'] + nw['out'])} now"
10558
10800
  if g == "waiting" and m["deps"]:
10559
10801
  word = "waits for " + ",".join(d for d in m["deps"] if ms.get(d, {}).get("group") != "landed") \
10560
10802
  if any(ms.get(d, {}).get("group") != "landed" for d in m["deps"]) else "ready"
@@ -10568,26 +10810,96 @@ def render_board(vm, width=100, color=True, sel=None, note=""):
10568
10810
  if m["group"] == "needs_you" and (m.get("question") or m.get("reason")):
10569
10811
  out.append(" " + sub + c("r", cut(f"\"{m.get('question') or m.get('reason')}\"", width - len(sub) - 2)))
10570
10812
 
10571
- for tid, pre, sub in board_tree(vm):
10572
- line(ms[tid], pre, sub)
10573
- out += ["", c("d", "AGENTS")]
10574
- for i, a in enumerate(vm["agents"]):
10575
- busy = a.get("task") or a["role"] == "lead"
10576
- col = "a" if a["role"] == "lead" else ("p" if a["role"] == "reviewer" else "b") if a.get("task") else "d"
10577
- mark = "›" if picked == ("a", i) else " "
10578
- out.append(f"{mark}{c(col, '◆' if a['role'] == 'lead' else '●' if busy else '○')} "
10579
- f"{a['name']:<12} {str(a.get('kind') or ''):<8} {str(a.get('tier') or ''):<7} "
10580
- + c(col if busy else "d", (f"{a['task']} · " if a.get("task") else "") + a["state"]))
10581
- if vm.get("recent"):
10813
+ nw_ = max([12] + [len(str(a.get("name") or "")) for a in (vm.get("agents") or []) + at]) # names in full
10814
+
10815
+ def agents_part():
10816
+ for i, a in enumerate(vm["agents"]):
10817
+ busy = a.get("task") or a["role"] == "lead"
10818
+ col = "a" if a["role"] == "lead" else ("p" if a["role"] == "reviewer" else "b") if a.get("task") else "d"
10819
+ mark = "›" if picked == ("a", i) else " "
10820
+ out.append(f"{mark}{c(col, '◆' if a['role'] == 'lead' else '●' if busy else '○')} "
10821
+ f"{a['name']:<{nw_}} {str(a.get('kind') or ''):<8} {str(a.get('tier') or ''):<7} "
10822
+ + c(col if busy else "d", (f"{a['task']} · " if a.get("task") else "") + a["state"]))
10823
+ if a.get("step_role") or a.get("skills"):
10824
+ sk = ", ".join(x["name"] + (f" ({x['note']})" if x.get("note") else "") for x in a.get("skills") or [])
10825
+ if a.get("step_role"):
10826
+ out.append(c("d", " role: ") + cut(a["step_role"], width - 11))
10827
+ out.append(c("d", " skills: ") + (cut(sk, width - 13) if sk else c("d", "none for this step")))
10828
+
10829
+ def tokens_part():
10830
+ if not at:
10831
+ out.append(c("d", "No token counts yet: they show once an agent has done a job."))
10832
+ return
10833
+ out.extend(([c("d", "TOKENS") + c("d", " read live from each agent's own log")] if tab is None else
10834
+ [c("d", "read live from each agent's own log")])
10835
+ + [c("d", f" {'':<{nw_}} {'':<8} {'in':>7} {'cached':>8} {'out':>7}")])
10836
+ for r in at:
10837
+ col = "a" if r["role"] == "lead" else "p" if r["role"] == "reviewer" else "b"
10838
+ mark = c(col, "◆" if r["role"] == "lead" else "●" if r.get("task") else "○")
10839
+ head = f"{mark} {r['name']:<{nw_}} {str(r.get('kind') or ''):<8} "
10840
+ if r.get("kind") and r["kind"] not in TOKEN_KINDS:
10841
+ out.append(head + c("d", f"n/a: orch can't read {r['kind']}'s logs yet"))
10842
+ continue
10843
+ if not r["known"] and r["na"]:
10844
+ out.append(head + c("d", cut(f"n/a: {r['na'][0]}", width - nw_ - 13)))
10845
+ continue
10846
+ if not r["known"] and not r.get("task"):
10847
+ out.append(head + c("d", "no jobs yet"))
10848
+ continue
10849
+ tnote = []
10850
+ if r.get("task"):
10851
+ nw = r.get("now") or {}
10852
+ tnote.append(f"{r['task']} now {_tk(nw.get('in', 0) + nw.get('out', 0))}" if "na" not in nw else
10853
+ f"{r['task']} now n/a")
10854
+ if r["na"]:
10855
+ tnote.append(f"+ {len(r['na'])} job(s) n/a")
10856
+ out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tk(r['out']):>7}"
10857
+ + (c("d", " " + " · ".join(tnote)) if tnote else ""))
10858
+ tot_in, tot_out = sum(r["in"] for r in at), sum(r["out"] for r in at)
10859
+ out.append(c("B", f" {'total':<{nw_ + 9}} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {_tk(tot_out):>7}")
10860
+ + (c("d", " + some jobs n/a") if any(r["na"] for r in at) else ""))
10861
+ if tab == "t":
10862
+ per = [f"{m['id']} " + (f"{_tk(m['tokens']['total'])}{'+' if m['tokens']['partial'] else ''}"
10863
+ if m.get("tokens") and m["tokens"]["total"] else "–") for m in vm["milestones"]]
10864
+ if per:
10865
+ out.extend(["", c("d", "Per milestone: ") + cut(" · ".join(per), width - 18)])
10866
+
10867
+ if tab in (None, "m"):
10868
+ for tid, pre, sub in board_tree(vm):
10869
+ line(ms[tid], pre, sub)
10870
+ if tab in (None, "a"):
10871
+ out += ["", c("d", "AGENTS")] if tab is None else [""]
10872
+ agents_part()
10873
+ if tab == "t" or (tab is None and at):
10874
+ out.append("")
10875
+ tokens_part()
10876
+ if tab in (None, "m") and vm.get("recent"):
10582
10877
  out += ["", c("d", "LAST EVENTS")]
10583
10878
  for e in vm["recent"][:6]:
10584
10879
  out.append(c("d", time.strftime("%H:%M", time.localtime(e["ts"] or 0))) + f" {e['task']} {e['from']} → {e['to']}"
10585
10880
  + (c("d", f" {cut(e.get('why') or '', 50)}") if e.get("why") else ""))
10586
- if note:
10587
- out += ["", c("a", note)]
10588
- out += ["", c("d", "[↑↓] pick [enter] a milestone's changed files / jump to an agent [f] changed files "
10589
- "[w] web view [q] close")]
10590
- return out
10881
+ keys = {None: "[↑↓] pick [enter] a milestone's changed files / jump to an agent [f] changed files [w] web view "
10882
+ "[q] close",
10883
+ "m": "[tab ←→ 1-3] switch [↑↓] pick [enter] changed files [f] files [w] web [q] close",
10884
+ "a": "[tab ←→ 1-3] switch [↑↓] pick [enter] jump to that agent [f] files [w] web [q] close",
10885
+ "t": "[tab ←→ 1-3] switch [f] files [w] web [q] close"}[tab]
10886
+ foot = (["", c("a", note)] if note else []) + ["", c("d", keys)]
10887
+ return BoardLines(out + foot, foot=len(foot))
10888
+
10889
+
10890
+ class BoardLines(list):
10891
+ """The board's lines; `foot` = how many at the end (the note and the keys) must stay on a short screen."""
10892
+ def __init__(self, lines, foot=0):
10893
+ super().__init__(lines)
10894
+ self.foot = foot
10895
+
10896
+
10897
+ def fit_screen(lines, height):
10898
+ """The lines that fit the screen: on a short one the middle is cut, never the note and the keys at the end."""
10899
+ foot = getattr(lines, "foot", 0)
10900
+ if len(lines) <= height or not foot or height <= foot + 2:
10901
+ return list(lines[:height])
10902
+ return list(lines[:height - foot - 1]) + ["…"] + list(lines[-foot:])
10591
10903
 
10592
10904
 
10593
10905
  def board_tree(vm):
@@ -10616,9 +10928,14 @@ def board_tree(vm):
10616
10928
  return rows
10617
10929
 
10618
10930
 
10619
- def board_rows(vm):
10620
- """What [↑↓] moves through on the board: every milestone (board order), then every agent."""
10621
- return [("m", tid) for tid, _, _ in board_tree(vm)] + [("a", i) for i in range(len(vm.get("agents", [])))]
10931
+ BOARD_TABS = (("m", "Milestones"), ("a", "Agents"), ("t", "Tokens")) # the live board's tabs (6.48.2)
10932
+
10933
+
10934
+ def board_rows(vm, tab=None):
10935
+ """What [↑↓] moves through on the board: the Milestones tab its milestones (board order), the Agents tab its
10936
+ agents, the Tokens tab nothing; with no tab (the whole board) every milestone, then every agent."""
10937
+ ms = [("m", tid) for tid, _, _ in board_tree(vm)] if tab in (None, "m") else []
10938
+ return ms + ([("a", i) for i in range(len(vm.get("agents", [])))] if tab in (None, "a") else [])
10622
10939
 
10623
10940
 
10624
10941
  def board_default_milestone(vm, row=None):
@@ -10824,14 +11141,21 @@ def cmd_changes(args):
10824
11141
 
10825
11142
 
10826
11143
  def cmd_board(args):
10827
- """orch board [--once] [--no-color] -> the run as text, redrawn when it changes (for a herdr pane or popup).
11144
+ """orch board [--once] [--tab milestones|agents|tokens] [--no-color] -> the run as text, redrawn when it changes
11145
+ (for a herdr pane or popup). Three tabs under the top lines: Milestones, Agents, Tokens ([tab], [←→] or 1-3).
10828
11146
  [f] or [enter] on a milestone opens its changed files, [enter] on a file its diff; q goes back one screen.
10829
11147
  [enter] on an agent jumps to it; in the board popup (prefix+a) it also closes the popup."""
10830
11148
  # live needs a keyboard and a screen: with stdin or stdout not a terminal, draw once (termios would fail)
10831
11149
  once = "--once" in args or not (sys.stdout.isatty() and sys.stdin.isatty())
10832
11150
  color = "--no-color" not in args and sys.stdout.isatty() and not os.environ.get("NO_COLOR")
11151
+ tab = "m" # the live board opens on Milestones; --once prints the whole board
11152
+ if "--tab" in args:
11153
+ want = (args[args.index("--tab") + 1:] or [""])[0].lower()
11154
+ tab = next((k for k, w in BOARD_TABS if want in (k, w.lower())), None) or \
11155
+ die("usage: orch board [--once] [--tab milestones|agents|tokens]")
10833
11156
  if once:
10834
- print("\n".join(render_board(view_model(), shutil.get_terminal_size((100, 40)).columns, color)))
11157
+ print("\n".join(render_board(view_model(), shutil.get_terminal_size((100, 40)).columns, color,
11158
+ tab=tab if "--tab" in args else None)))
10835
11159
  return
10836
11160
  import select
10837
11161
  import termios
@@ -10850,7 +11174,8 @@ def cmd_board(args):
10850
11174
  while True:
10851
11175
  k = _view_snapshot_key()
10852
11176
  live = screen != "run" and ch is not None and ch["kind"] == "live"
10853
- if k != last or time.time() - fetched > (2 if live else 30): # a coder's unsaved files: look every 2s
11177
+ running = any(r.get("task") for r in vm.get("agent_tokens") or []) # live tokens: look every 10s
11178
+ if k != last or time.time() - fetched > (2 if live else 10 if running else 30): # unsaved files: 2s
10854
11179
  last, need = k, True
10855
11180
  if need or redraw:
10856
11181
  size = shutil.get_terminal_size((100, 40))
@@ -10865,7 +11190,7 @@ def cmd_board(args):
10865
11190
  dlines, derr = file_diff(st, mid, dfile["path"])
10866
11191
  need = redraw = False
10867
11192
  if screen == "run":
10868
- lines = render_board(vm, size.columns, color, sel, note)
11193
+ lines = render_board(vm, size.columns, color, sel, note, tab)
10869
11194
  elif screen == "files":
10870
11195
  fsel = min(fsel, max(0, len(ch["files"]) - 1))
10871
11196
  lines, ftop = render_changes(ch, size.columns, size.lines, color, fsel, ftop)
@@ -10876,7 +11201,7 @@ def cmd_board(args):
10876
11201
  need = redraw = False
10877
11202
  lines = board_error_lines(e, "this run" if screen == "run" else f"{mid}'s changes",
10878
11203
  "[q] close" if screen == "run" else "[q] back")
10879
- sys.stdout.write("\x1b[H\x1b[2J" + "\n".join(lines[:size.lines]))
11204
+ sys.stdout.write("\x1b[H\x1b[2J" + "\n".join(fit_screen(lines, size.lines)))
10880
11205
  sys.stdout.flush()
10881
11206
  r, _, _ = select.select([sys.stdin], [], [], 0.5)
10882
11207
  if not r:
@@ -10918,11 +11243,20 @@ def cmd_board(args):
10918
11243
  dfile, dtop, screen, need = ch["files"][fsel], 0, "diff", True
10919
11244
  redraw = True
10920
11245
  continue
10921
- rows = board_rows(vm)
11246
+ rows = board_rows(vm, tab)
10922
11247
  n = len(rows)
10923
11248
  if key in ("q", "Q", "\x1b"):
10924
11249
  closed_by = repr(key)
10925
11250
  break
11251
+ tabs = [k for k, _ in BOARD_TABS]
11252
+ to = {"1": 0, "2": 1, "3": 2}.get(key)
11253
+ if to is None and key in ("\t", RIGHT, "\x1b[Z", LEFT):
11254
+ to = (tabs.index(tab) + (1 if key in ("\t", RIGHT) else -1)) % len(tabs)
11255
+ if to is not None:
11256
+ if tabs[to] != tab:
11257
+ tab, sel, note = tabs[to], None, ""
11258
+ redraw = True
11259
+ continue
10926
11260
  if key in (UP, "k"):
10927
11261
  sel = (n - 1 if sel is None else max(0, sel - 1)) if n else None
10928
11262
  elif key in (DOWN, "j"):
@@ -11062,7 +11396,8 @@ USAGE = """usage: orch <command> [args]
11062
11396
  "needs you" alert, time and cost, replay. --lan: also from your phone, with a secret link
11063
11397
  view stop|status|herdr-config|plugin link|key|unlink|refresh|app link|unlink
11064
11398
  stop it / show its link / sidebar lines for herdr's config / the optional herdr plugin
11065
- board [--once] the run as text, redrawn when it changes: for a herdr pane or popup (any terminal);
11399
+ board [--once] [--tab milestones|agents|tokens] the run as text, redrawn when it changes: for a herdr pane or
11400
+ popup (any terminal); tabs Milestones, Agents, Tokens ([tab], [←→] or 1-3);
11066
11401
  [f] or [enter] on a milestone shows its changed files, [enter] on a file its diff
11067
11402
  changes [Mn [file]] [--json] what each milestone changed: files with +/- counts, or one file's diff
11068
11403
  (live while a coder works, unsaved files included; landed = its commit). Read-only
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.48.0",
3
+ "version": "6.48.2",
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/view/index.html CHANGED
@@ -255,7 +255,8 @@ function agents(v) {
255
255
  const col = a.role === "lead" ? "#e5a93b" : !a.task ? "#626979" : a.role === "reviewer" ? "#b392f0" : "#7aa2f7";
256
256
  return `<div class="ag"><i class="dot" style="background:${col}"></i><span class="n">${esc(a.name)}</span>
257
257
  <span class="w" style="color:${col}">${esc(a.task ? a.task + " · " + a.state : a.state)}</span>
258
- <span class="k">${esc([a.role, a.kind, a.model, a.tier].filter(Boolean).join(" · "))}</span></div>`;
258
+ <span class="k">${esc([a.role, a.kind, a.model, a.tier].filter(Boolean).join(" · "))}</span>${a.step_role || a.skills ? `
259
+ <span class="k">${esc([a.step_role ? "role: " + a.step_role : "", "skills: " + ((a.skills || []).map((x) => x.name + (x.note ? " (" + x.note + ")" : "")).join(", ") || "none for this step")].filter(Boolean).join(" · "))}</span>` : ""}</div>`;
259
260
  }).join("") || `<div class="muted">No agents in this run.</div>`;
260
261
  }
261
262
 
@@ -351,9 +352,13 @@ function cost(v) {
351
352
  }).join("");
352
353
  const T = v.tokens || {}, L = T.lead;
353
354
  const lead = L ? `<tr><td class="muted">lead (whole run)</td><td>${L.total != null ? tk(L.total) + " tok" : "tokens n/a (" + esc(L.na) + ")"}</td></tr>` : "";
355
+ const AT = v.agent_tokens || [], readable = ["claude", "codex", "pi", "agy"];
356
+ const arow = (r) => `<tr><td class="muted" style="white-space:nowrap">${esc(r.name)} <span class="faint">${esc(r.role)}</span></td><td>${r.kind && !readable.includes(r.kind) ? "n/a (orch can't read " + esc(r.kind) + "'s logs yet)" : !r.known && r.na.length ? "n/a (" + esc(r.na[0]) + ")" : !r.known && !r.task ? "no jobs yet" : "in " + tk(r.in) + " (" + tk(r.cached) + " cached) · out " + tk(r.out) + (r.task && r.now && r.now.na == null ? " · " + esc(r.task) + " now " + tk(r.now.in + r.now.out) : "") + (r.na.length ? " · " + r.na.length + " job(s) n/a" : "")}</td></tr>`;
357
+ const liveTot = AT.some((r) => r.known) ? AT.reduce((n, r) => n + r.in + r.out, 0) : 0; // running jobs included
358
+ const agTok = AT.length ? `<div class="h" style="margin:10px 0 4px">Tokens per agent (live)</div><table>${AT.map(arow).join("")}</table>` : "";
354
359
  $("cost").innerHTML = `<div class="card"><div class="h" style="margin-bottom:6px">Time and tokens</div>
355
360
  <div style="margin-bottom:8px">${mins(so)} so far${est ? ` of ~${mins(est)} planned` : ""}</div>
356
- <table>${rows}${lead}<tr><td><b>Total tokens</b></td><td><b>${T.total ? tk(T.total) + (T.partial ? "+" : "") : "none yet"}</b></td></tr></table>
361
+ <table>${rows}${lead}<tr><td><b>Total tokens</b></td><td><b>${liveTot ? tk(liveTot) + (AT.some((r) => r.na.length) ? "+" : "") : T.total ? tk(T.total) + (T.partial ? "+" : "") : "none yet"}</b></td></tr></table>${agTok}
357
362
  <div class="faint" style="font-size:11px;margin-top:6px">Read from each agent's own log. In = what it read (cached = its own chat read again, much cheaper), out = what it wrote. + = some jobs not available.</div></div>`;
358
363
  }
359
364