@botbuddy/cli 1.69.7 → 1.70.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
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.69.8
4
+
5
+ - The bb-status band's context row is simpler: just `Context 45%`, right-aligned, without the token counts. It turns amber above 30% context use and red above 50%, on every surface, so a session running low on context stands out. The colour is judged on the rounded percent the row shows. The band's plugin version moves to 1.1.1, so `bb update` re-installs it.
6
+
3
7
  ## 1.69.6
4
8
 
5
9
  - A new Claude Code session in a reused worktree binds its bb-status band even when the worktree's BotBuddy session was started by an earlier Claude session that has since gone. Before, the band said "BB identity belongs to another session" for as long as that BB session stayed live, and other sessions' `bb` commands in the worktree kept renewing it. The band now judges the holder by its Claude session: when the holder's transcript has been silent for 30 minutes, the band moves its cache aside to `.botbuddy/agent-state.superseded-<id>.json` and binds this session. The old BB session is not closed, so waits still running on it carry on, and it expires on its own. A holder whose Claude session is active is never replaced.
@@ -10,8 +10,8 @@
10
10
  {
11
11
  "name": "bb-status",
12
12
  "source": "./bb-status",
13
- "description": "BB session status above the prompt: tickets, PRs with review counts, epic and staging, for BotBuddy and Supply Guard sessions",
14
- "version": "1.1.0"
13
+ "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
14
+ "version": "1.2.0"
15
15
  }
16
16
  ]
17
17
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.1.0",
4
- "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging and context use, live only while the session is on screen.",
3
+ "version": "1.2.0",
4
+ "description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
5
5
  "author": {
6
6
  "name": "BotBuddy"
7
7
  },
@@ -32,12 +32,24 @@ session. Once a surface draws the session again, the 5 s display tick does one
32
32
  read and re-arms the relay.
33
33
 
34
34
  **BOT-3211 context row.** The last row shows the session's context use as
35
- Claude Code's status line has it, for example `Context 62% · 124k of 200k`. The
35
+ Claude Code's status line has it, right-aligned, for example `Context 62%`
36
+ (BOT-3217 dropped the token counts). The
36
37
  mod reads it once with the free `$.session.usage()` (no `breakdown`) at
37
38
  session start and resume, then only from the `session.measure` event the
38
39
  engine pushes after each main-thread turn: no timer reads it. The row is hidden
39
40
  while the runtime has no fill figure (a fresh or just-compacted session before
40
- its next response), never shown as 0%.
41
+ its next response), never shown as 0%. It is dim up to 30%, amber (`warning`)
42
+ above 30% and red (`error`) above 50% (BOT-3217), judged on the rounded percent
43
+ it shows.
44
+
45
+ **BOT-3212 waits badge.** The same right-aligned row starts with a badge for the session
46
+ agent's active `bb wait`s and the oldest one's age, for example
47
+ `⏳ 2 · oldest 14m`. The figures come from `get_session_status.waits`, which
48
+ leaves out the band's own relay wait. There is no badge with no active waits or
49
+ when BB could not read them, and the badge shows without the context figure.
50
+ The relay wakes on `event:type=agent_wait,subject=<agent id>` when one of the
51
+ agent's waits starts or ends; the age ticks with the 5 s display clock, with no
52
+ read. The badge is bold for 2 s after a read that changes the count.
41
53
 
42
54
  ## Install
43
55
 
@@ -94,6 +106,8 @@ Data refreshes **when BB reports a change** (BOT-3135). After each live read the
94
106
  mod starts one relay child, `bb status-band relay`. The relay runs the installed CLI's own `bb wait`
95
107
  on the band's subjects:
96
108
  - each ticket (`linear:issue=`);
109
+ - when BB read the agent's waits, one of them starting or ending
110
+ (`event:type=agent_wait,subject=<agent uuid>`, BOT-3212);
97
111
  - each open or draft PR (`pr-state:`);
98
112
  - for BotBuddy blockers, each ticket's last blocker clearing (`unblocked:`).
99
113
  - the epic's Linear project (`event:type=linear_project,subject=<uuid>`, BOT-3136);
@@ -31,6 +31,10 @@ let unbound = false;
31
31
  // with the free `$.session.usage()` and then only from `session.measure`,
32
32
  // which the engine pushes after each main-thread turn: never polled.
33
33
  let context = null;
34
+ // BOT-3212: the waits badge pulses once, for PULSE_MS, when the count changes.
35
+ const PULSE_MS = 2000;
36
+ let pulsing = false;
37
+ let pulseToken = 0;
34
38
  const ERRORS = {
35
39
  linear_key_missing:
36
40
  "Export LINEAR_BB_API_KEY to Claude Desktop before using Live.",
@@ -164,6 +168,16 @@ function validSnapshot(value, harness, now) {
164
168
  typeof value.staging.configured === "boolean" &&
165
169
  typeof value.staging.red === "boolean" &&
166
170
  (value.staging.since === null || Number.isFinite(Date.parse(value.staging.since)))
171
+ )) ||
172
+ // BOT-3212: the agent's active waits; null or absent means unknown (no badge).
173
+ (value.waits != null &&
174
+ !(
175
+ Number.isSafeInteger(value.waits.count) &&
176
+ value.waits.count >= 0 &&
177
+ value.waits.count <= 999 &&
178
+ (value.waits.count === 0
179
+ ? value.waits.oldest_at === null
180
+ : Number.isFinite(Date.parse(value.waits.oldest_at)))
167
181
  ))
168
182
  )
169
183
  return false;
@@ -236,6 +250,7 @@ function demoSnapshot(now) {
236
250
  percent: 45,
237
251
  },
238
252
  staging: { configured: true, red: true, since: new Date(now - 12 * 60000).toISOString() },
253
+ waits: { count: 2, oldest_at: new Date(now - 14 * 60000).toISOString() },
239
254
  // Demonstration-only IDs; never interpreted as current dependency state.
240
255
  blockers: [
241
256
  {
@@ -310,6 +325,20 @@ async function refresh($, { wake = false, keep = false } = {}) {
310
325
  )
311
326
  throw new Error("session_changed");
312
327
  if (request === generation) {
328
+ // BOT-3212 AC-3: a changed count pulses the badge once; a first read or
329
+ // an unchanged one does not.
330
+ const before = snapshot?.waits?.count;
331
+ const after = data.waits?.count;
332
+ if (Number.isSafeInteger(before) && Number.isSafeInteger(after) && before !== after) {
333
+ pulsing = true;
334
+ const token = ++pulseToken;
335
+ $.clock.after(PULSE_MS, () => {
336
+ // A later change restarted the pulse: that one ends it.
337
+ if (token !== pulseToken) return;
338
+ pulsing = false;
339
+ $.ui.invalidate("ui.render");
340
+ });
341
+ }
313
342
  snapshot = data;
314
343
  relayFault = null;
315
344
  if (!wake) startRelay($);
@@ -331,16 +360,20 @@ async function refresh($, { wake = false, keep = false } = {}) {
331
360
  }
332
361
  }
333
362
  // ── BOT-3135 relay ─────────────────────────────────────────────────────
334
- // What the band waits on: each ticket, each PR still open or draft, and, when
335
- // BotBuddy blockers are listed, each ticket's last blocker clearing, and the
336
- // epic's Linear project (BOT-3136).
337
- const MAX_CONDITIONS = 18;
363
+ // What the band waits on: each ticket, the agent's own waits (BOT-3212), each PR
364
+ // still open or draft, and, when BotBuddy blockers are listed, each ticket's
365
+ // last blocker clearing, and the epic's Linear project (BOT-3136).
366
+ const MAX_CONDITIONS = 19;
338
367
  function waitConditions(s) {
339
368
  // BOT-3152 AC-2: unknown staging (null: a failed read) also wakes on it
340
369
  // (review on #1616), so the next incident re-reads; only a tenant known to
341
370
  // have no staging skips it.
342
371
  const staging = s.staging?.configured === false ? [] : ["event:type=staging_incident"];
343
372
  const conds = s.tickets.map((t) => "linear:issue=" + t.key);
373
+ // BOT-3212 AC-2: one of this agent's waits starting or ending. Armed only when
374
+ // BB read the waits, so a server without them is never waited on.
375
+ if (s.waits != null && UUID.test(s.agent?.id))
376
+ conds.push("event:type=agent_wait,subject=" + s.agent.id.toLowerCase());
344
377
  for (const p of s.prs || [])
345
378
  if (p.state === "open" || p.state === "draft")
346
379
  conds.push("pr-state:repo=" + p.repo + ",pr=" + p.number);
@@ -357,8 +390,9 @@ function waitConditions(s) {
357
390
  for (const p of s.prs || [])
358
391
  if (p.state === "open" || p.state === "draft")
359
392
  conds.push("pr-review:repo=" + p.repo + ",pr=" + p.number);
360
- // At most 5 tickets, 5 PRs (state + review), blockers, epic and staging: 18,
361
- // the relay's limit, so no wake is ever dropped (review on #1616, round 4).
393
+ // At most 5 tickets, the agent's waits, 5 PRs (state + review), blockers, epic
394
+ // and staging: 19, the relay's limit, so no wake is ever dropped (review on
395
+ // #1616, round 4; BOT-3212).
362
396
  return [...conds, ...staging].slice(0, MAX_CONDITIONS);
363
397
  }
364
398
  // Ending the loop's stream kills the child; a module unload does the same.
@@ -696,33 +730,46 @@ function bandLine(el, spec, widths, right) {
696
730
  // Top-aligned: with a wrapped title, the id and status sit on its first line.
697
731
  return el.Box({ key: spec.key, flexDirection: "row", alignItems: "flex-start", columnGap: 1, children });
698
732
  }
699
- // BOT-3211: 124000 → "124k", 1000000 → "1M".
700
- function tokens(n) {
701
- if (n >= 999500) return String(Math.round(n / 100000) / 10).replace(/\.0$/, "") + "M";
702
- if (n >= 1000) return Math.round(n / 1000) + "k";
703
- return String(n);
704
- }
705
- // The row's text, or null when the runtime has no fill figure (a fresh or
706
- // just-compacted session): hidden, never "0%".
733
+ // BOT-3211/BOT-3217: "Context 62%", or null when the runtime has no fill
734
+ // figure (a fresh or just-compacted session): hidden, never "0%".
707
735
  function contextText(c) {
708
- if (
709
- !c ||
710
- !Number.isFinite(c.percent) ||
711
- c.percent < 0 ||
712
- c.percent > 100 ||
713
- !Number.isSafeInteger(c.window) ||
714
- c.window <= 0
715
- )
716
- return null;
717
- const pct = "Context " + Math.round(c.percent) + "%";
718
- return Number.isSafeInteger(c.tokens) && c.tokens >= 0
719
- ? pct + " · " + tokens(c.tokens) + " of " + tokens(c.window)
720
- : pct + " of " + tokens(c.window);
736
+ if (!c || !Number.isFinite(c.percent) || c.percent < 0 || c.percent > 100) return null;
737
+ return "Context " + Math.round(c.percent) + "%";
721
738
  }
722
- function contextLine(el, key) {
739
+ // BOT-3217: amber above 30%, red above 50%, judged on the rounded percent the
740
+ // row shows, so the colour always matches the number.
741
+ function contextColor(c) {
742
+ const pct = Math.round(c.percent);
743
+ if (pct > 50) return "error";
744
+ if (pct > 30) return "warning";
745
+ return null;
746
+ }
747
+ // BOT-3212 AC-1: "⏳ 2 · oldest 14m", or null with no active waits or none known.
748
+ function waitsText(w, now) {
749
+ if (!w || !Number.isSafeInteger(w.count) || w.count < 1 || !w.oldest_at) return null;
750
+ return "⏳ " + w.count + " · oldest " + shortAge(w.oldest_at, now);
751
+ }
752
+ // The waits badge, then the context use. Either shows without the other.
753
+ function contextLine(el, key, waits = null) {
723
754
  const text = contextText(context);
724
- if (!text) return null;
725
- return el.Box({ key, flexDirection: "row", children: [dim(el, text)] });
755
+ const badge = waitsText(waits, currentTime);
756
+ if (!text && !badge) return null;
757
+ const children = [];
758
+ if (badge) {
759
+ // The pulse: bold and coloured for PULSE_MS after a change, then quiet.
760
+ children.push(
761
+ pulsing
762
+ ? el.Text({ bold: true, color: "warning", children: [badge] })
763
+ : el.Text({ dimColor: true, children: [badge] }),
764
+ );
765
+ if (text) children.push(sep(el));
766
+ }
767
+ if (text) {
768
+ const color = contextColor(context);
769
+ children.push(color ? el.Text({ color, children: [text] }) : dim(el, text));
770
+ }
771
+ // Right-aligned on its own row (Jono, BOT-3217), the badge left of the context.
772
+ return el.Box({ key, flexDirection: "row", justifyContent: "flex-end", children });
726
773
  }
727
774
  async function readContext($) {
728
775
  try {
@@ -853,8 +900,8 @@ function bandLines(el, $, inPane) {
853
900
  const lines = specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null));
854
901
  // BOT-3152 AC-2: the web Staging chip's red, with its link, above the rows.
855
902
  if (s.staging?.red) lines.unshift(stagingBanner(el, k("line-staging"), s.staging.since));
856
- // BOT-3211: the session's context use, last.
857
- const ctx = contextLine(el, k("line-context"));
903
+ // BOT-3211: the session's context use, last; BOT-3212: with the waits badge.
904
+ const ctx = contextLine(el, k("line-context"), s.waits);
858
905
  if (ctx) lines.push(ctx);
859
906
  return lines;
860
907
  }
@@ -939,6 +986,8 @@ export function register(on) {
939
986
  parked = false;
940
987
  unbound = false;
941
988
  context = null;
989
+ pulsing = false;
990
+ pulseToken++;
942
991
  if (timer) timer.cancel();
943
992
  return next(e);
944
993
  });
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.69.7",
3
- "source_commit": "52aeefbc6a3f3a3227d48751cf58574975ad59c2",
4
- "source_sha256": "fcfafa031f43c1216a917942b1d33030ccb67d3031d22f1dbb7cd82c264ec62f",
2
+ "release_version": "1.70.0",
3
+ "source_commit": "bc5701b6250bbba9c5df68d1595267468333bb1c",
4
+ "source_sha256": "28d90039fee54b2112bad6d8ae946034a326794731e69a4aaa455dd5dc895fa6",
5
5
  "target": "darwin-arm64",
6
- "sha256": "d7206dcfb3c2b5c3ca5d15efc42de45c13c9d0fe874555a10968bf08585f0cae"
6
+ "sha256": "625e79dbbe96865740dc33d6ceef73d9e8b9242a9116c01935d86dd763745cdb"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.69.7",
3
- "source_commit": "52aeefbc6a3f3a3227d48751cf58574975ad59c2",
4
- "source_sha256": "fcfafa031f43c1216a917942b1d33030ccb67d3031d22f1dbb7cd82c264ec62f",
2
+ "release_version": "1.70.0",
3
+ "source_commit": "bc5701b6250bbba9c5df68d1595267468333bb1c",
4
+ "source_sha256": "28d90039fee54b2112bad6d8ae946034a326794731e69a4aaa455dd5dc895fa6",
5
5
  "target": "linux-x64",
6
- "sha256": "c57454938647984335e54841948df3a07797deaebf75694225b4843a3b65b372"
6
+ "sha256": "fef2aec1c2199ae01c38e96ef90ae7fc007ac77ec24aa916894e5f7ee60276a8"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.69.7",
4
- "source_commit": "52aeefbc6a3f3a3227d48751cf58574975ad59c2",
5
- "source_sha256": "fcfafa031f43c1216a917942b1d33030ccb67d3031d22f1dbb7cd82c264ec62f",
3
+ "release_version": "1.70.0",
4
+ "source_commit": "bc5701b6250bbba9c5df68d1595267468333bb1c",
5
+ "source_sha256": "28d90039fee54b2112bad6d8ae946034a326794731e69a4aaa455dd5dc895fa6",
6
6
  "targets": {
7
7
  "darwin-arm64": {
8
8
  "goos": "darwin",
9
9
  "goarch": "arm64",
10
10
  "binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
11
- "sha256": "d7206dcfb3c2b5c3ca5d15efc42de45c13c9d0fe874555a10968bf08585f0cae",
11
+ "sha256": "625e79dbbe96865740dc33d6ceef73d9e8b9242a9116c01935d86dd763745cdb",
12
12
  "mode": "0755"
13
13
  },
14
14
  "linux-x64": {
15
15
  "goos": "linux",
16
16
  "goarch": "amd64",
17
17
  "binary": "daemon/bin/linux-x64/botbuddy-daemon",
18
- "sha256": "c57454938647984335e54841948df3a07797deaebf75694225b4843a3b65b372",
18
+ "sha256": "fef2aec1c2199ae01c38e96ef90ae7fc007ac77ec24aa916894e5f7ee60276a8",
19
19
  "mode": "0755"
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbuddy/cli",
3
- "version": "1.69.7",
3
+ "version": "1.70.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,6 +52,15 @@ function stagingOf(own) {
52
52
  const since = typeof st.open_since === "string" && Number.isFinite(Date.parse(st.open_since)) ? new Date(st.open_since).toISOString() : null;
53
53
  return { configured: st.configured, red: st.configured && since !== null, since: st.configured ? since : null };
54
54
  }
55
+ // BOT-3212 AC-1: the session agent's active bb waits, for the band's badge; null
56
+ // when BB did not say (no badge rather than a false "none").
57
+ function waitsOf(own) {
58
+ const w = own?.waits;
59
+ if (!w || typeof w !== "object" || !Number.isSafeInteger(w.active) || w.active < 0 || w.active > 999) return null;
60
+ if (w.active === 0) return { count: 0, oldest_at: null };
61
+ if (typeof w.oldest_at !== "string" || !Number.isFinite(Date.parse(w.oldest_at))) return null;
62
+ return { count: w.active, oldest_at: new Date(w.oldest_at).toISOString() };
63
+ }
55
64
  function refuse(code) {
56
65
  throw new Error(code);
57
66
  }
@@ -468,6 +477,7 @@ export async function readStatus({
468
477
  // BOT-3152 AC-1: the epic source failed, so "no epic" would be a guess.
469
478
  epic_unreadable: useSession ? false : !skipEpic && !Array.isArray(epicHealth?.epics),
470
479
  staging: ownOk ? stagingOf(own) : null,
480
+ waits: ownOk ? waitsOf(own) : null,
471
481
  // BOT-3136: where the tickets came from — the registered session, an explicit
472
482
  // pick, or (only when the session registered none) a guess from the branch.
473
483
  binding: bindingKind,
@@ -18,12 +18,15 @@ const REPO = "[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}";
18
18
  const PROJECT = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
19
19
  // BOT-3152 AC-2: any staging incident of the session's tenant opening or closing.
20
20
  const STAGING = "event:type=staging_incident";
21
+ // BOT-3212 AC-2: the waits badge wakes when one of the agent's own waits starts or ends.
22
+ const AGENT_WAITS = `event:type=agent_wait,subject=${PROJECT}`;
21
23
  const CONDITION = new RegExp(
22
- `^(?:linear:issue=${KEY}|unblocked:${KEY}|pr-(?:state|review):repo=${REPO},pr=[1-9]\\d{0,6}|event:type=linear_project,subject=${PROJECT}|${STAGING})$`,
24
+ `^(?:linear:issue=${KEY}|unblocked:${KEY}|pr-(?:state|review):repo=${REPO},pr=[1-9]\\d{0,6}|event:type=linear_project,subject=${PROJECT}|${STAGING}|${AGENT_WAITS})$`,
23
25
  );
24
26
  const CURSOR = /^\d{1,16}$/;
25
- // The band's largest list: 5 tickets, 5 PRs (state + review), blockers, epic, staging.
26
- const MAX_CONDITIONS = 18;
27
+ // The band's largest list: 5 tickets, 5 PRs (state + review), blockers, epic,
28
+ // staging and the agent's own waits (BOT-3212).
29
+ const MAX_CONDITIONS = 19;
27
30
  export const CLI_ENTRY = join(resolve(dirname(fileURLToPath(import.meta.url)), ".."), "bin", "botbuddy.mjs");
28
31
 
29
32
  function invalid() {
package/src/wait-core.mjs CHANGED
@@ -132,6 +132,10 @@ export const SIGNAL_TYPES = Object.freeze([
132
132
  // BOT-3152: a staging incident of the caller's tenant opening or closing
133
133
  // (subject = owner/repo). The bb-status band's staging banner wakes on it.
134
134
  "staging_incident",
135
+ // BOT-3212: one of an agent's own bb waits starting or ending (subject = the
136
+ // agent's lower-case UUID), recipient-scoped to that agent. The bb-status
137
+ // band's waits badge wakes on it; the band's own relay wait never emits it.
138
+ "agent_wait",
135
139
  ]);
136
140
 
137
141
  const LOCK_SUBTYPES = Object.freeze(["playwright_lane", "vite_port", "backend_port", "supabase_local"]);
@@ -550,6 +554,14 @@ const VALIDATORS = {
550
554
  }
551
555
  return { type: p.type, subject: id };
552
556
  }
557
+ // BOT-3212: an agent_wait subject is the agent's UUID, as the emitter writes it.
558
+ if (p.type === "agent_wait") {
559
+ const id = subject ? subject.toLowerCase() : "";
560
+ if (!CANONICAL_UUID_RE.test(id)) {
561
+ throw new Error("event:type=agent_wait needs subject=<agent UUID>");
562
+ }
563
+ return { type: p.type, subject: id };
564
+ }
553
565
  return { type: p.type, subject };
554
566
  },
555
567
  };
package/src/wait.mjs CHANGED
@@ -258,6 +258,10 @@ CONDITIONS (TYPE:key=val,key=val — repeat for several; --any wakes on the fir
258
258
  Staging state uses event:type=staging_incident;
259
259
  it wakes when one of your tenant's staging incidents
260
260
  opens or closes (the band's staging banner, BOT-3152).
261
+ Your own waits use
262
+ event:type=agent_wait,subject=<your agent UUID>;
263
+ it wakes when one of that agent's bb waits starts or
264
+ ends (the band's waits badge, BOT-3212).
261
265
 
262
266
  OPTIONS
263
267
  Review intervention: exact-head Codex waits have a durable one-shot diagnostic.