herdr-orchestra 6.48.3 → 6.48.5

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,34 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.48.5] - 2026-12-03
6
+
7
+ `orch team up` now puts the lead in the `team` tab too. Before, the coders and the reviewer opened in the `team` tab and the lead stayed alone in its own tab, so you could not watch the lead and its team at the same time. Now the lead's pane moves into the `team` tab, top left, and the team fills the rest. The lead keeps running: only its place changes, nothing is restarted or closed. Its pane is at least as big as any other (2 agents: the lead on top across the whole width, the 2 below; 3 agents: a 2×2 grid). A big team still spills into `team 2`, without the lead. `orch team tidy` does the same for panes that are already open.
8
+
9
+ The lead stays where it is, and orch says why in one `NOTE` line, when herdr can't find the lead's pane, when herdr can't move it, when the screen is so small it fits only one agent a tab, or when the lead already sits beside agents of this run. `orch team up --here` works as before.
10
+
11
+ Example (`orch team up` with codex-1, codex-2 and the reviewer):
12
+ ```
13
+ OPENED codex-1: pane w1:p3 in app-wt/codex-1 ...
14
+ TAB the lead and the team are in the herdr tab "team", the lead top left (`orch team tidy` moves panes opened by hand there too)
15
+ ```
16
+
17
+ No agent gets any new text to read: the lead's playbooks, wake-ups, task files and review prompts are unchanged. The one line `orch team up` prints at the end got shorter.
18
+
19
+ ## [6.48.4] - 2026-12-03
20
+
21
+ The board's Tokens tab has a new **fresh** column: in minus cached, the part the agent read new. A coder can show "10.8M in" and look very costly, but most of that is its own chat read again from the cache, which costs much less. Fresh shows the part that really costs. It is in each agent's row, the total row, the top line (`tokens 257k so far · fresh 57k`), the agent details (total, now and each milestone) and the browser view's tokens per agent. The numbers are the ones the board already reads from each agent's own log, so no agent spends a single extra token. A tool whose log gives no cached number shows fresh as "n/a", and the total fresh then reads "at least" (`57k+`).
22
+
23
+ Example (Tokens tab):
24
+ ```
25
+ in cached fresh out
26
+ ◆ lead-1 (lead) codex 50k 30k 20k 4k
27
+ ○ claude-1 (coder) claude 36k 32k 4k 3k
28
+ ○ agy-3 (coder) agy 4k 0 n/a 300
29
+ total 90k 62k 24k+ 7k
30
+ fresh = in minus cached: what the agent read new. Cached is its own chat read again, much cheaper.
31
+ ```
32
+
5
33
  ## [6.48.3] - 2026-12-02
6
34
 
7
35
  `orch board` can now show one agent in detail. On the Agents tab or the Tokens tab, pick an agent with up/down and press Enter. You see its tool, model, role, skills and what it does right now; its tokens (in, cached, out) in total, for the job it runs now, and for each milestone it worked on; its milestones with the time it spent on each; and its pane. Esc or Backspace goes back to the list. The numbers come from the same agent logs the board already reads, so no agent spends a single extra token. Where a tool keeps no counts (OpenCode, an old agy), it says "n/a" and why, never a guess.
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 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.
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's pane moves into that tab too, top left, so you see the lead and its team together (it keeps running; if herdr can't move it, it stays where it is and orch says so). `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
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.48.3
1
+ 6.48.5
Binary file
package/bin/orch CHANGED
@@ -2652,6 +2652,16 @@ def token_log_find(kind, marker, since, known=()):
2652
2652
  return None
2653
2653
 
2654
2654
 
2655
+ def _nc(u):
2656
+ return {"nocache": True} if u.get("nocache") else {}
2657
+
2658
+
2659
+ def _fresh(u):
2660
+ """Fresh = in minus cached: what the agent read new (the cached part is its own chat read again, much cheaper).
2661
+ None when the tool's log gives no cached number."""
2662
+ return None if u.get("nocache") else max(0, int(u.get("in") or 0) - int(u.get("cached") or 0))
2663
+
2664
+
2655
2665
  def _tok_add(acc, ts, start, end, inp, cached, out):
2656
2666
  if ts is None or ts < start or ts > end:
2657
2667
  return
@@ -2666,7 +2676,7 @@ def token_window(kind, path, start, end):
2666
2676
  Raises TokenNA when the log has no token counts at all."""
2667
2677
  acc = {"in": 0, "cached": 0, "out": 0, "replies": 0}
2668
2678
  text = _tok_text(path)
2669
- seen_counts = False
2679
+ seen_counts = seen_cache = False
2670
2680
  if kind == "claude":
2671
2681
  files = [text] + [_tok_text(s) for s in sorted((Path(path).with_suffix("") / "subagents").glob("*.jsonl"))]
2672
2682
  for tx in files:
@@ -2677,6 +2687,7 @@ def token_window(kind, path, start, end):
2677
2687
  if d.get("type") != "assistant" or not isinstance(u, dict):
2678
2688
  continue
2679
2689
  seen_counts = True
2690
+ seen_cache |= "cache_read_input_tokens" in u
2680
2691
  key = (m.get("id"), d.get("requestId")) if m.get("id") else d.get("uuid") or id(d)
2681
2692
  ts = _tok_ts(d.get("timestamp"))
2682
2693
  row = (int(u.get("input_tokens") or 0) + int(u.get("cache_creation_input_tokens") or 0)
@@ -2696,6 +2707,7 @@ def token_window(kind, path, start, end):
2696
2707
  if not isinstance(tot, dict):
2697
2708
  continue
2698
2709
  seen_counts = True
2710
+ seen_cache |= "cached_input_tokens" in tot
2699
2711
  ts = _tok_ts(d.get("timestamp"))
2700
2712
  if ts is None:
2701
2713
  continue
@@ -2719,6 +2731,7 @@ def token_window(kind, path, start, end):
2719
2731
  if not isinstance(u, dict) or d.get("type") == "message" and m.get("role") != "assistant":
2720
2732
  continue
2721
2733
  seen_counts = True
2734
+ seen_cache |= "cacheRead" in u
2722
2735
  _tok_add(acc, _tok_ts(d.get("timestamp")) or _tok_ts(m.get("timestamp")), start, end,
2723
2736
  int(u.get("input") or 0) + int(u.get("cacheRead") or 0) + int(u.get("cacheWrite") or 0),
2724
2737
  u.get("cacheRead"), u.get("output"))
@@ -2730,6 +2743,7 @@ def token_window(kind, path, start, end):
2730
2743
  if not any(k in d for k in ("input_tokens", "output_tokens")):
2731
2744
  continue
2732
2745
  seen_counts = True
2746
+ seen_cache |= "cache_read_tokens" in d
2733
2747
  _tok_add(acc, _tok_ts(d.get("created_at")), start, end,
2734
2748
  int(d.get("input_tokens") or 0) + int(d.get("cache_read_tokens") or 0),
2735
2749
  d.get("cache_read_tokens"), d.get("output_tokens"))
@@ -2739,6 +2753,8 @@ def token_window(kind, path, start, end):
2739
2753
  raise TokenNA(f"orch can't read {kind}'s logs")
2740
2754
  if not seen_counts:
2741
2755
  raise TokenNA(f"{kind}'s log has no token counts")
2756
+ if not seen_cache:
2757
+ acc["nocache"] = True # the log gives no cached number: "fresh" (in minus cached) shows n/a
2742
2758
  return acc
2743
2759
 
2744
2760
 
@@ -2779,7 +2795,7 @@ def token_measure(st, agent, kind, marker, start, end, cap=None):
2779
2795
  logs[agent] = (known + [path])[-6:]
2780
2796
  if not acc["replies"]:
2781
2797
  return None if now() - end < TOKEN_GIVE_UP_S else {"na": "no replies in the log during this job"}
2782
- return {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], "log": kind}
2798
+ return {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], "log": kind, **_nc(acc)}
2783
2799
 
2784
2800
 
2785
2801
  def token_fill(st, force=False):
@@ -2878,6 +2894,7 @@ def _tok_merge(rows):
2878
2894
  acc["na"].append((u or {}).get("na") if isinstance(u, dict) else "not read yet")
2879
2895
  continue
2880
2896
  acc["known"] += 1
2897
+ acc.update(_nc(u))
2881
2898
  for k in ("in", "cached", "out"):
2882
2899
  acc[k] += int(u.get(k) or 0)
2883
2900
  return acc
@@ -2942,6 +2959,11 @@ def _tk(n):
2942
2959
  return f"{n / 1e6:.1f}M" if n >= 1_000_000 else f"{round(n / 1000)}k" if n >= 1000 else str(n)
2943
2960
 
2944
2961
 
2962
+ def _tkf(u):
2963
+ f = _fresh(u)
2964
+ return "n/a" if f is None else _tk(f)
2965
+
2966
+
2945
2967
  def _tok_cell(u, who=""):
2946
2968
  if not u:
2947
2969
  return "-"
@@ -3021,7 +3043,7 @@ def token_live(st, agent, kind, marker, start, end=None):
3021
3043
  return hit[1]
3022
3044
  try:
3023
3045
  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
3046
+ r = {"in": acc["in"], "cached": acc["cached"], "out": acc["out"], **_nc(acc)} if acc["replies"] else None
3025
3047
  except TokenNA as e:
3026
3048
  r = {"na": str(e)}
3027
3049
  _LIVE_WIN[key] = (sig, r)
@@ -3050,6 +3072,7 @@ def agent_tokens(st):
3050
3072
  x["na"].append(u["na"])
3051
3073
  continue
3052
3074
  x["known"] += 1
3075
+ x.update(_nc(u))
3053
3076
  for k in ("in", "cached", "out"):
3054
3077
  x[k] += int(u.get(k) or 0)
3055
3078
  ld, run = st.get("lead") or {}, st.get("run") or {}
@@ -9057,16 +9080,18 @@ def herdr_screen(pane=None):
9057
9080
  return ws, (w if isinstance(w, int) and w > 0 else None), (h if isinstance(h, int) and h > 0 else None)
9058
9081
 
9059
9082
 
9060
- def team_grid(n, width, height):
9083
+ def team_grid(n, width, height, lead=False):
9061
9084
  """How many panes go in one team tab, and the rows for n of them: [panes in row 1, row 2, ...]. Every pane gets
9062
9085
  at least PANE_MIN_COLS x PANE_MIN_ROWS of a screen this size (2 across when the size is unknown), at most
9063
- TEAM_MAX_PER_TAB per tab, rows as even as they can be (3 -> [2, 1], 4 -> [2, 2])."""
9086
+ TEAM_MAX_PER_TAB per tab, rows as even as they can be (3 -> [2, 1], 4 -> [2, 2]). lead: n counts the lead too,
9087
+ who takes one more place and sits first in the row with the fewest panes, so it is as big as any (3 -> [1, 2])."""
9064
9088
  cols = max(1, width // PANE_MIN_COLS) if width else 2
9065
9089
  rows = max(1, height // PANE_MIN_ROWS) if height else 2
9066
- cap = max(1, min(TEAM_MAX_PER_TAB, cols * rows))
9090
+ cap = max(1, min(TEAM_MAX_PER_TAB + (1 if lead else 0), cols * rows))
9067
9091
  n = min(n, cap)
9068
9092
  r = max(1, -(-n // min(cols, n))) if n else 0
9069
- return cap, [n // r + (1 if i < n % r else 0) for i in range(r)]
9093
+ out = [n // r + (1 if i < n % r else 0) for i in range(r)]
9094
+ return cap, out[::-1] if lead else out
9070
9095
 
9071
9096
 
9072
9097
  def build_grid(rows, first, split):
@@ -9104,22 +9129,61 @@ def _new_pane_id(ok, data, out, key="pane"):
9104
9129
  return pid or (re.search(r'"pane_id"\s*:\s*"([\w:.-]+)"', out or "") or [None, None])[1]
9105
9130
 
9106
9131
 
9107
- def team_tab_panes(new, dry=False, lead_pane=None, st=None):
9132
+ def herdr_tab_panes(pane):
9133
+ """The pane ids in the tab `pane` sits in, from `herdr pane layout` (empty when herdr can't tell)."""
9134
+ ok, data, _ = _herdr_json([HERDR, "pane", "layout", "--pane", pane])
9135
+ return {d["pane_id"] for d, _ in (_dicts_with(data, "pane_id") if ok and data is not None else [])}
9136
+
9137
+
9138
+ def lead_to_team_tab(lead_pane, ws, label, dry, q):
9139
+ """Move the lead's pane into a new tab `label`, focused: the lead keeps running, only its place changes. Returns
9140
+ (pane id, tab id) once moved; (None, None) after a NOTE that it stays where it is. dry: prints the command."""
9141
+ cmd = [HERDR, "pane", "move", lead_pane, "--new-tab"] + (["--workspace", ws] if ws else []) + ["--label", label]
9142
+ if dry:
9143
+ print(f"WOULD lead: {q(cmd)}")
9144
+ return lead_pane, f"<tab {label}>"
9145
+ ok, data, out = _herdr_json(cmd)
9146
+ res = ((data or {}).get("result") or {}).get("move_result") if ok and isinstance(data, dict) else None
9147
+ pane = (res or {}).get("pane") if isinstance(res, dict) else None
9148
+ pid, tab = _find_key(pane, "pane_id"), _find_key(pane, "tab_id")
9149
+ if pid and tab:
9150
+ return pid, tab
9151
+ print(f"NOTE the lead stays in its own tab: herdr could not move pane {lead_pane} "
9152
+ f"({out.splitlines()[-1] if out else 'no output'})")
9153
+ return None, None
9154
+
9155
+
9156
+ def team_tab_panes(new, dry=False, lead_pane=None, st=None, with_lead=False):
9108
9157
  """Open one pane per (name, folder) in `new`, in new herdr tabs ("team", "team 2", ...) laid out by team_grid.
9158
+ with_lead: the lead's pane moves into the first tab, top left (lead_to_team_tab), the team beside and below it.
9109
9159
  Returns ({name: pane id, None when herdr refused; dry: the command it would run}, {name: why it failed},
9110
- [tab labels]). When herdr can't make the first tab (an older herdr), returns ({}, {}, []) after a NOTE, and
9111
- team up opens the panes next to this one as before."""
9160
+ [tab labels], lead moved). When herdr can't make the first tab (an older herdr), returns ({}, {}, [], False)
9161
+ after a NOTE, and team up opens the panes next to this one as before."""
9112
9162
  ws, w, h = herdr_screen(lead_pane)
9113
9163
  cap, _ = team_grid(len(new), w, h)
9114
9164
  placed, errs, labels = {}, {}, []
9115
9165
  q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
9116
- for c, i in enumerate(range(0, len(new), cap)):
9117
- chunk, label = new[i:i + cap], team_tab_label(c, st)
9118
- _, rows = team_grid(len(chunk), w, h)
9166
+ lead_tab = None
9167
+ if with_lead and lead_pane:
9168
+ if team_grid(len(new) + 1, w, h, lead=True)[0] < 2:
9169
+ print(f"NOTE the lead stays in its own tab: this screen ({w}x{h}) fits one agent a tab")
9170
+ else:
9171
+ lead_pane, lead_tab = lead_to_team_tab(lead_pane, ws, team_tab_label(0, st), dry, q)
9172
+ chunks, i = [], 0
9173
+ while i < len(new):
9174
+ k = team_grid(len(new) + 1, w, h, lead=True)[0] - 1 if lead_tab and not chunks else cap
9175
+ chunks.append(new[i:i + k])
9176
+ i += k
9177
+ for c, chunk in enumerate(chunks):
9178
+ label, lead_here = team_tab_label(c, st), bool(lead_tab) and c == 0
9179
+ rows = team_grid(len(chunk) + 1, w, h, lead=True)[1] if lead_here else team_grid(len(chunk), w, h)[1]
9180
+ slots = ([("lead", None)] if lead_here else []) + chunk
9119
9181
  tab_cmd = [HERDR, "tab", "create"] + (["--workspace", ws] if ws else []) + \
9120
9182
  ["--cwd", chunk[0][1], "--label", label, "--no-focus"]
9121
9183
 
9122
9184
  def first():
9185
+ if lead_here:
9186
+ return lead_pane
9123
9187
  if dry:
9124
9188
  placed[chunk[0][0]] = f"new tab: {q(tab_cmd)}"
9125
9189
  return f"<{chunk[0][0]}>"
@@ -9130,7 +9194,7 @@ def team_tab_panes(new, dry=False, lead_pane=None, st=None):
9130
9194
  return pid
9131
9195
 
9132
9196
  def split(cur, direction, ratio, slot):
9133
- name, d = chunk[slot]
9197
+ name, d = slots[slot]
9134
9198
  cmd = [HERDR, "pane", "split", cur, "--direction", direction, "--ratio", f"{ratio:.3f}",
9135
9199
  "--cwd", d, "--no-focus"]
9136
9200
  if dry:
@@ -9142,24 +9206,24 @@ def team_tab_panes(new, dry=False, lead_pane=None, st=None):
9142
9206
  errs[name] = out.splitlines()[-1] if out else "no output"
9143
9207
  return pid
9144
9208
 
9145
- pids = build_grid(rows, first, split)
9146
- if c == 0 and not pids[0] and not dry:
9209
+ pids = build_grid(rows, first, split)[1 if lead_here else 0:]
9210
+ if c == 0 and not lead_here and not pids[0] and not dry:
9147
9211
  print(f"NOTE herdr could not open a tab for the team ({errs.get(chunk[0][0])}), so the panes open "
9148
9212
  f"next to this one")
9149
- return {}, {}, []
9213
+ return {}, {}, [], False
9150
9214
  if not dry:
9151
9215
  placed.update({n: p for (n, _), p in zip(chunk, pids)})
9152
9216
  for (n, _), p in zip(chunk, pids):
9153
9217
  if not p and n not in errs:
9154
9218
  errs[n] = "the pane it splits from was not opened"
9155
9219
  labels.append(label)
9156
- return placed, errs, labels
9220
+ return placed, errs, labels, bool(lead_tab)
9157
9221
 
9158
9222
 
9159
9223
  def team_tidy(args):
9160
9224
  """Move the coders' and the reviewer's panes that are open now (opened by hand, or by an older orch next to the
9161
- lead) into team tabs, as a grid of equal panes, the same layout `orch team up` opens. The agents keep running
9162
- and keep their names. Never moves the lead's pane or the pane this runs in."""
9225
+ lead) into team tabs, as a grid of equal panes, the same layout `orch team up` opens: the lead's pane joins the
9226
+ first, top left. The agents and the lead keep running and keep their names."""
9163
9227
  usage = "usage: orch team tidy [--dry-run]"
9164
9228
  if any(a != "--dry-run" for a in args):
9165
9229
  die(usage)
@@ -9189,10 +9253,23 @@ def team_tidy(args):
9189
9253
  ws, w, h = herdr_screen(lead_pane)
9190
9254
  cap, _ = team_grid(len(panes), w, h)
9191
9255
  q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
9192
- failed, labels = 0, []
9193
- for c, i in enumerate(range(0, len(panes), cap)):
9194
- chunk, label, tab = panes[i:i + cap], team_tab_label(c, st), [None]
9195
- _, rows = team_grid(len(chunk), w, h)
9256
+ failed, labels, lead_tab = 0, [], None
9257
+ if not lead_pane:
9258
+ print("NOTE the lead stays in its own tab: herdr can't find the lead's pane")
9259
+ elif team_grid(len(panes) + 1, w, h, lead=True)[0] < 2:
9260
+ print(f"NOTE the lead stays in its own tab: this screen ({w}x{h}) fits one agent a tab")
9261
+ else:
9262
+ lead_pane, lead_tab = lead_to_team_tab(lead_pane, ws, team_tab_label(0, st), dry, q)
9263
+ chunks, i = [], 0
9264
+ while i < len(panes):
9265
+ k = team_grid(len(panes) + 1, w, h, lead=True)[0] - 1 if lead_tab and not chunks else cap
9266
+ chunks.append(panes[i:i + k])
9267
+ i += k
9268
+ for c, chunk in enumerate(chunks):
9269
+ label, lead_here = team_tab_label(c, st), bool(lead_tab) and c == 0
9270
+ tab = [lead_tab if lead_here else None]
9271
+ rows = team_grid(len(chunk) + 1, w, h, lead=True)[1] if lead_here else team_grid(len(chunk), w, h)[1]
9272
+ slots = ([("lead", lead_pane)] if lead_here else []) + chunk
9196
9273
 
9197
9274
  def move(cmd, name, old):
9198
9275
  if dry:
@@ -9209,12 +9286,14 @@ def team_tidy(args):
9209
9286
  return pid
9210
9287
 
9211
9288
  def first():
9212
- n, p = chunk[0]
9289
+ n, p = slots[0]
9290
+ if lead_here:
9291
+ return p
9213
9292
  return move([HERDR, "pane", "move", p, "--new-tab"] + (["--workspace", ws] if ws else []) +
9214
9293
  ["--label", label, "--no-focus"], n, p)
9215
9294
 
9216
9295
  def split(cur, direction, ratio, slot):
9217
- n, p = chunk[slot]
9296
+ n, p = slots[slot]
9218
9297
  if not dry and not tab[0]:
9219
9298
  print(f"FAILED {n}: herdr did not say which tab \"{label}\" is, so pane {p} stays where it is")
9220
9299
  return None
@@ -9225,8 +9304,9 @@ def team_tidy(args):
9225
9304
  labels.append(label)
9226
9305
  if dry:
9227
9306
  return
9228
- print(f"TEAM TIDY: {'done' if not failed else f'{failed} pane(s) not moved — see above'}; the team is in the "
9229
- f"herdr tab{'s' if len(labels) > 1 else ''} " + ", ".join(f'"{t}"' for t in labels))
9307
+ print(f"TEAM TIDY: {'done' if not failed else f'{failed} pane(s) not moved — see above'}; the "
9308
+ f"{'lead and the team are' if lead_tab else 'team is'} in the herdr tab{'s' if len(labels) > 1 else ''} "
9309
+ + ", ".join(f'"{t}"' for t in labels))
9230
9310
  if failed:
9231
9311
  sys.exit(3)
9232
9312
 
@@ -9254,18 +9334,21 @@ def team_up(args):
9254
9334
  die(f"run `orch start` first: it makes each coder's folder ({', '.join(missing_dirs)} have none yet)")
9255
9335
  # after a restart: panes that only lost their name get it back, and a coder's own pane that came back as a
9256
9336
  # plain shell gets its agent started again, instead of a second pane next to it
9257
- lead_pane = agent_pane(st["lead"]["name"]) if (st.get("lead") or {}).get("name") else None
9337
+ lead_pane = (st.get("lead") or {}).get("pane") or \
9338
+ (agent_pane(st["lead"]["name"]) if (st.get("lead") or {}).get("name") else None)
9258
9339
  empty = {} if dry else rename_lost(dict(st, lead=None), hints=False, keep_out=[lead_pane] if lead_pane else [])
9259
- todo = []
9340
+ todo, running = [], []
9260
9341
  for name, w, d in agents:
9261
9342
  if w.get("pane"):
9262
9343
  ok, _, _ = _herdr_json([HERDR, "pane", "get", w["pane"]])
9263
9344
  print(f"ok {name}: pane {w['pane']}" if ok else
9264
9345
  f"STALE {name}: pane {w['pane']} is gone — remove `@pane:` from plan.md, `orch sync`, then "
9265
9346
  f"`orch team up` again")
9347
+ running.append(w["pane"] if ok else None)
9266
9348
  continue
9267
9349
  if herdr_state(name) is not None:
9268
9350
  print(f"ok {name}: already running")
9351
+ running.append(agent_pane(name))
9269
9352
  continue
9270
9353
  todo.append((name, w, d))
9271
9354
  if not todo:
@@ -9282,12 +9365,16 @@ def team_up(args):
9282
9365
  failed += 1
9283
9366
  continue
9284
9367
  runnable.append((name, w, d, v))
9285
- # new panes go in a herdr tab of their own ("team"), as a grid of equal panes, so the lead keeps its whole
9286
- # screen and every agent stays readable; --here (or a herdr that can't make tabs) splits next to this pane
9368
+ # new panes go in a herdr tab of their own ("team"), as a grid of equal panes, the lead's pane moved in top left
9369
+ # so the developer sees them all; --here (or a herdr that can't make tabs) splits next to this pane
9287
9370
  new = [(n, d) for n, w, d, v in runnable if not empty.get(n)]
9288
- placed, errs, tabs = {}, {}, []
9371
+ placed, errs, tabs, lead_moved = {}, {}, [], False
9289
9372
  if new and "--here" not in args:
9290
- placed, errs, tabs = team_tab_panes(new, dry, lead_pane, st)
9373
+ # the lead joins the team's tab, unless it already sits with agents of this run (it has its team in view)
9374
+ with_lead = bool(lead_pane) and not (set(running + list(empty.values())) - {None}) & herdr_tab_panes(lead_pane)
9375
+ if not lead_pane:
9376
+ print("NOTE the lead stays in its own tab: herdr can't find the lead's pane")
9377
+ placed, errs, tabs, lead_moved = team_tab_panes(new, dry, lead_pane, st, with_lead)
9291
9378
  for name, w, d, v in runnable:
9292
9379
  kind, model = w.get("kind"), w.get("model")
9293
9380
  cmd = launch_cmd(kind, v, model, strict=False, role="reviewer" if name == st.get("reviewer") else None, cwd=d)
@@ -9361,9 +9448,9 @@ def team_up(args):
9361
9448
  f"in pane {pid}")
9362
9449
  pane_labels(st, force=True) # each pane says who it is: "agy-2 · coder", "rev-1 · reviewer", "lead"
9363
9450
  if tabs and not dry:
9364
- print(f"TAB the team is in the herdr tab{'s' if len(tabs) > 1 else ''} " + ", ".join(f'"{t}"' for t in tabs)
9365
- + ", so the lead keeps its whole screen — switch tabs to watch them (`orch team tidy` moves panes "
9366
- "opened by hand there too)")
9451
+ print(f"TAB the {'lead and the team are' if lead_moved else 'team is'} in the herdr tab"
9452
+ f"{'s' if len(tabs) > 1 else ''} " + ", ".join(f'"{t}"' for t in tabs)
9453
+ + (", the lead top left" if lead_moved else "") + " (`orch team tidy` moves panes opened by hand there too)")
9367
9454
  print("TEAM UP: done — run `orch start` again; every agent should show herdr=found" if not failed else
9368
9455
  f"TEAM UP: {failed} agent(s) not ready — see above, then `orch team up` again")
9369
9456
  if failed:
@@ -10784,7 +10871,11 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10784
10871
  tk["partial"] = any(r["na"] for r in at)
10785
10872
  if tk.get("total") or tk.get("lead"):
10786
10873
  ld = tk.get("lead") or {}
10787
- out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far"
10874
+ kn = [r for r in at if r["known"]]
10875
+ fr = ("" if not kn else " · fresh n/a" if all(r.get("nocache") for r in kn) else
10876
+ f" · fresh {_tk(sum(_fresh(r) or 0 for r in kn))}"
10877
+ f"{'+' if tk.get('partial') or any(r.get('nocache') for r in kn) else ''}")
10878
+ out.append(c("d", f"tokens {_tk(tk.get('total'))}{'+' if tk.get('partial') else ''} so far{fr}"
10788
10879
  + (f" · lead {_tk(ld['total'])}" if ld.get("total") else
10789
10880
  " · lead: not available" if ld.get("na") else "")))
10790
10881
  if vm.get("all_done"):
@@ -10850,7 +10941,7 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10850
10941
  pk = " " if tab == "t" and sel is not None else "" # picking a row: a column for the › mark
10851
10942
  out.extend(([c("d", "TOKENS") + c("d", " read live from each agent's own log")] if tab is None else
10852
10943
  [c("d", "read live from each agent's own log")])
10853
- + [c("d", f"{pk} {'':<{nw_}} {'':<8} {'in':>7} {'cached':>8} {'out':>7}")])
10944
+ + [c("d", f"{pk} {'':<{nw_}} {'':<8} {'in':>7} {'cached':>8} {'fresh':>7} {'out':>7}")])
10854
10945
  for i, r in enumerate(at):
10855
10946
  col = "a" if r["role"] == "lead" else "p" if r["role"] == "reviewer" else "b"
10856
10947
  mark = (("›" if picked == ("t", i) else " ") if pk else "") \
@@ -10872,12 +10963,17 @@ def render_board(vm, width=100, color=True, sel=None, note="", tab=None):
10872
10963
  f"{r['task']} now n/a")
10873
10964
  if r["na"]:
10874
10965
  tnote.append(f"+ {len(r['na'])} job(s) n/a")
10875
- out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tk(r['out']):>7}"
10966
+ out.append(head + f"{_tk(r['in']):>7} {_tk(r['cached']):>8} {_tkf(r):>7} {_tk(r['out']):>7}"
10876
10967
  + (c("d", " " + " · ".join(tnote)) if tnote else ""))
10877
10968
  tot_in, tot_out = sum(r["in"] for r in at), sum(r["out"] for r in at)
10878
- out.append(c("B", f"{pk} {'total':<{nw_ + 9}} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {_tk(tot_out):>7}")
10969
+ kn = [r for r in at if r["known"]]
10970
+ tfr = "n/a" if kn and all(r.get("nocache") for r in kn) else \
10971
+ _tk(sum(_fresh(r) or 0 for r in kn)) + ("+" if any(r.get("nocache") for r in kn) else "")
10972
+ out.append(c("B", f"{pk} {'total':<{nw_ + 9}} {_tk(tot_in):>7} {_tk(sum(r['cached'] for r in at)):>8} {tfr:>7} {_tk(tot_out):>7}")
10879
10973
  + (c("d", " + some jobs n/a") if any(r["na"] for r in at) else ""))
10880
10974
  if tab == "t":
10975
+ out.append(c("d", "fresh = in minus cached: what the agent read new. Cached is its own chat read again, "
10976
+ "much cheaper."))
10881
10977
  per = [f"{m['id']} " + (f"{_tk(m['tokens']['total'])}{'+' if m['tokens']['partial'] else ''}"
10882
10978
  if m.get("tokens") and m["tokens"]["total"] else "–") for m in vm["milestones"]]
10883
10979
  if per:
@@ -11014,8 +11110,8 @@ def render_agent(vm, name, width=100, color=True, note=""):
11014
11110
  rows.append(("pane", (a.get("label") or name) + (f" (herdr pane {a['pane']})" if a.get("pane") else "")))
11015
11111
  out += [c("d", f" {k + ':':<11}") + cut(str(v), width - 14) for k, v in rows]
11016
11112
 
11017
- out += ["", c("d", "TOKENS") + c("d", " read live from its own log")]
11018
- nums = lambda u: f"{_tk(u['in']):>7} {_tk(u['cached']):>8} {_tk(u['out']):>7}"
11113
+ out += ["", c("d", "TOKENS") + c("d", " read live from its own log · fresh = in minus cached (read new)")]
11114
+ nums = lambda u: f"{_tk(u['in']):>7} {_tk(u['cached']):>8} {_tkf(u):>7} {_tk(u['out']):>7}"
11019
11115
  if not kind:
11020
11116
  out.append(" n/a: orch does not know which tool this agent runs")
11021
11117
  elif kind not in TOKEN_KINDS:
@@ -11023,7 +11119,7 @@ def render_agent(vm, name, width=100, color=True, note=""):
11023
11119
  elif not r or (not r["jobs"] and not r.get("task")):
11024
11120
  out.append(c("d", " no jobs yet"))
11025
11121
  else:
11026
- out.append(c("d", f" {'':<16} {'in':>7} {'cached':>8} {'out':>7}"))
11122
+ out.append(c("d", f" {'':<16} {'in':>7} {'cached':>8} {'fresh':>7} {'out':>7}"))
11027
11123
  tot = "whole run" if role == "lead" else "total"
11028
11124
  out.append(f" {tot:<16} " + (nums(r) if r["known"] else c("d", cut(f"n/a: {r['na'][0]}", width - 20)) if r["na"]
11029
11125
  else nums(r)) + (c("d", f" + {len(r['na'])} job(s) n/a") if r["known"] and r["na"] else ""))
@@ -11475,10 +11571,10 @@ USAGE = """usage: orch <command> [args]
11475
11571
  team up [--dry-run] [--here] [--mode panes|subagent]
11476
11572
  open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it,
11477
11573
  in a herdr tab of their own ("team") as a grid of equal panes (at most 4 a tab, fewer on a
11478
- small screen; more go to "team 2"), so the lead keeps its whole screen. --here: split
11574
+ small screen; more go to "team 2"); the lead's pane moves in, top left. --here: split
11479
11575
  next to this pane instead (subagent mode: no panes; sets up the Pi subagents instead)
11480
11576
  team tidy [--dry-run] move the coder and reviewer panes already open (by hand, or next to the lead) into that
11481
- team tab grid; they keep running and keep their names. Never moves the lead's pane
11577
+ team tab grid, the lead top left; all keep running and keep their names
11482
11578
  mode [panes|subagent] [--agent <kind>] this agent's mode, or save one: panes (herdr panes, the default for
11483
11579
  every agent) or subagent (one Pi window; Pi only). Saved per agent in
11484
11580
  ~/.config/herdr-orchestra/config.json ("modes": {"pi": "subagent"}); ORCH_MODE=panes|subagent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.48.3",
3
+ "version": "6.48.5",
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
@@ -353,13 +353,13 @@ function cost(v) {
353
353
  const T = v.tokens || {}, L = T.lead;
354
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
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>`;
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, " + (r.nocache ? "n/a" : tk(r.in - r.cached)) + " fresh) · 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
357
  const liveTot = AT.some((r) => r.known) ? AT.reduce((n, r) => n + r.in + r.out, 0) : 0; // running jobs included
358
358
  const agTok = AT.length ? `<div class="h" style="margin:10px 0 4px">Tokens per agent (live)</div><table>${AT.map(arow).join("")}</table>` : "";
359
359
  $("cost").innerHTML = `<div class="card"><div class="h" style="margin-bottom:6px">Time and tokens</div>
360
360
  <div style="margin-bottom:8px">${mins(so)} so far${est ? ` of ~${mins(est)} planned` : ""}</div>
361
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}
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>`;
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; fresh = in minus cached, what it read new), out = what it wrote. + = some jobs not available.</div></div>`;
363
363
  }
364
364
 
365
365
  function timeline(v) {