@botbuddy/cli 1.69.8 → 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.
@@ -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.1"
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.1",
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
  },
@@ -42,6 +42,15 @@ its next response), never shown as 0%. It is dim up to 30%, amber (`warning`)
42
42
  above 30% and red (`error`) above 50% (BOT-3217), judged on the rounded percent
43
43
  it shows.
44
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.
53
+
45
54
  ## Install
46
55
 
47
56
  The bb CLI ships this mod and installs it (BOT-3152). `bb setup` and `bb update`
@@ -97,6 +106,8 @@ Data refreshes **when BB reports a change** (BOT-3135). After each live read the
97
106
  mod starts one relay child, `bb status-band relay`. The relay runs the installed CLI's own `bb wait`
98
107
  on the band's subjects:
99
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);
100
111
  - each open or draft PR (`pr-state:`);
101
112
  - for BotBuddy blockers, each ticket's last blocker clearing (`unblocked:`).
102
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.
@@ -710,17 +744,32 @@ function contextColor(c) {
710
744
  if (pct > 30) return "warning";
711
745
  return null;
712
746
  }
713
- function contextLine(el, key) {
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) {
714
754
  const text = contextText(context);
715
- if (!text) return null;
716
- const color = contextColor(context);
717
- // Right-aligned on its own row (Jono, BOT-3217).
718
- return el.Box({
719
- key,
720
- flexDirection: "row",
721
- justifyContent: "flex-end",
722
- children: [color ? el.Text({ color, children: [text] }) : dim(el, text)],
723
- });
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 });
724
773
  }
725
774
  async function readContext($) {
726
775
  try {
@@ -851,8 +900,8 @@ function bandLines(el, $, inPane) {
851
900
  const lines = specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null));
852
901
  // BOT-3152 AC-2: the web Staging chip's red, with its link, above the rows.
853
902
  if (s.staging?.red) lines.unshift(stagingBanner(el, k("line-staging"), s.staging.since));
854
- // BOT-3211: the session's context use, last.
855
- 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);
856
905
  if (ctx) lines.push(ctx);
857
906
  return lines;
858
907
  }
@@ -937,6 +986,8 @@ export function register(on) {
937
986
  parked = false;
938
987
  unbound = false;
939
988
  context = null;
989
+ pulsing = false;
990
+ pulseToken++;
940
991
  if (timer) timer.cancel();
941
992
  return next(e);
942
993
  });
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.69.8",
3
- "source_commit": "704da4fe10bcbc13f1ca3abc6b0d47d2260e2c62",
4
- "source_sha256": "2465657c2fe4fa188d73f3b7efda0f608144afcfd8d7eba465ece55ccb1204f3",
2
+ "release_version": "1.70.0",
3
+ "source_commit": "bc5701b6250bbba9c5df68d1595267468333bb1c",
4
+ "source_sha256": "28d90039fee54b2112bad6d8ae946034a326794731e69a4aaa455dd5dc895fa6",
5
5
  "target": "darwin-arm64",
6
- "sha256": "865f29aebd07e09de6c5b77fd5297db5a568c30843c4395e8ae4e927b0d4e7ad"
6
+ "sha256": "625e79dbbe96865740dc33d6ceef73d9e8b9242a9116c01935d86dd763745cdb"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.69.8",
3
- "source_commit": "704da4fe10bcbc13f1ca3abc6b0d47d2260e2c62",
4
- "source_sha256": "2465657c2fe4fa188d73f3b7efda0f608144afcfd8d7eba465ece55ccb1204f3",
2
+ "release_version": "1.70.0",
3
+ "source_commit": "bc5701b6250bbba9c5df68d1595267468333bb1c",
4
+ "source_sha256": "28d90039fee54b2112bad6d8ae946034a326794731e69a4aaa455dd5dc895fa6",
5
5
  "target": "linux-x64",
6
- "sha256": "6ad28e621587a5a697621c54c5a9b09f90c79b0687a4ae1f25f380ef02843d4b"
6
+ "sha256": "fef2aec1c2199ae01c38e96ef90ae7fc007ac77ec24aa916894e5f7ee60276a8"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.69.8",
4
- "source_commit": "704da4fe10bcbc13f1ca3abc6b0d47d2260e2c62",
5
- "source_sha256": "2465657c2fe4fa188d73f3b7efda0f608144afcfd8d7eba465ece55ccb1204f3",
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": "865f29aebd07e09de6c5b77fd5297db5a568c30843c4395e8ae4e927b0d4e7ad",
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": "6ad28e621587a5a697621c54c5a9b09f90c79b0687a4ae1f25f380ef02843d4b",
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.8",
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.