@botbuddy/cli 1.69.8 → 1.71.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,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.71.0
4
+
5
+ - `bb bootstrap --project-id P-BOT-39` registers a coordinator session: one that runs a Linear project (an epic) and starts a session per ticket, with no ticket branch of its own. No ticket and no `--no-ticket-reason` are needed, and `--ticket-id` may be added. BB checks that the project belongs to the repo's tenant and refuses a malformed or foreign id before any session is kept. The bb-status band on such a session shows the project row, `Coordinating · 9 done · 2 in progress · 1 blocked · 3 todo`, linked to BB and Linear, and it updates on the project's own wake. When a band has nothing to show, its hint now names the tenant's own prefix (`ENT-` on Supply Guard) and the coordinator option. The band's plugin version moves to 1.3.0, so `bb update` installs it.
3
6
  ## 1.69.8
4
7
 
5
8
  - 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.
@@ -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.3.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.3.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,12 @@ 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-3213: the tenant's ticket prefix the adapter named with ticket_missing.
35
+ let hintPrefix = null;
36
+ // BOT-3212: the waits badge pulses once, for PULSE_MS, when the count changes.
37
+ const PULSE_MS = 2000;
38
+ let pulsing = false;
39
+ let pulseToken = 0;
34
40
  const ERRORS = {
35
41
  linear_key_missing:
36
42
  "Export LINEAR_BB_API_KEY to Claude Desktop before using Live.",
@@ -55,7 +61,7 @@ const ERRORS = {
55
61
  agent_mismatch:
56
62
  "BB returned a different agent. Reconnect BB for this session.",
57
63
  worktree_mismatch: "BB identity belongs to a different worktree.",
58
- ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live BOT-2644.",
64
+ ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live <KEY>, or register as coordinator: bb bootstrap --project-id P-….",
59
65
  ticket_scope_mismatch: "Linear issue or workspace does not match BotBuddy.",
60
66
  blockers_incomplete: "Blocker list is incomplete. Status is unknown.",
61
67
  source_unauthorized:
@@ -66,6 +72,12 @@ const ERRORS = {
66
72
  cli_outdated: "Update the bb CLI (bb update) to use this band.",
67
73
  };
68
74
  function errorText() {
75
+ // BOT-3213 AC-4: the hint speaks in the tenant's own prefix when it is known.
76
+ if (errorCode === "ticket_missing" && hintPrefix)
77
+ return (
78
+ "Use a ticket branch (" + hintPrefix.toLowerCase() + "-…) or /bb-status live " + hintPrefix +
79
+ "-123, or register as coordinator: bb bootstrap --project-id P-" + hintPrefix + "-…."
80
+ );
69
81
  return (
70
82
  ERRORS[errorCode] ||
71
83
  "Status unavailable. Check BB and Linear connections, then refresh."
@@ -105,6 +117,18 @@ const PR_STATES = ["open", "draft", "merged", "closed"];
105
117
  const LINEAR_PROJECT_URL = /^https:\/\/linear\.app\/[a-z0-9-]{1,64}\/project\/[a-z0-9-]{1,200}$/;
106
118
  const PROJECT_IDENTIFIER = /^P-[A-Z][A-Z0-9]{1,9}-[1-9]\d{0,5}$/;
107
119
  const PROJECT_STATES = ["backlog", "planned", "started", "paused", "completed", "canceled"];
120
+ // BOT-3213: a coordinator project's tickets by state; the four add up to total.
121
+ const COUNT_KEYS = ["done", "in_progress", "blocked", "todo"];
122
+ function validCounts(c) {
123
+ return (
124
+ !!c &&
125
+ [...COUNT_KEYS, "total"].every((k) => Number.isSafeInteger(c[k]) && c[k] >= 0 && c[k] <= 100000) &&
126
+ COUNT_KEYS.reduce((n, k) => n + c[k], 0) === c.total
127
+ );
128
+ }
129
+ function countsText(c) {
130
+ return [c.done + " done", c.in_progress + " in progress", c.blocked + " blocked", c.todo + " todo"].join(" · ");
131
+ }
108
132
  function validSnapshot(value, harness, now) {
109
133
  const prefix = TENANT_PREFIX[value?.tenant];
110
134
  const ownKey = (k) => KEY.test(k) && k.startsWith(prefix + "-");
@@ -118,15 +142,17 @@ function validSnapshot(value, harness, now) {
118
142
  !safeLabel(value.agent?.name, 100) ||
119
143
  !safeLabel(value.branch) ||
120
144
  !Array.isArray(value.tickets) ||
121
- value.tickets.length < 1 ||
122
145
  value.tickets.length > 5 ||
123
146
  !value.tickets.every(
124
147
  (t) => ownKey(t?.key) && safeLabel(t.title) && safeLabel(t.status, 40),
125
148
  ) ||
126
- value.ticket?.key !== value.tickets[0].key ||
127
- !safeLabel(value.ticket.title) ||
128
- !safeLabel(value.ticket.status, 40) ||
129
- (value.ticket.url !== null && !safeLink(value.ticket.url, value.ticket.key)) ||
149
+ // BOT-3213: only a coordinator's project binding may carry no ticket.
150
+ (value.tickets.length === 0
151
+ ? !(value.binding === "project" && value.ticket === null && value.epic?.role === "coordinator")
152
+ : value.ticket?.key !== value.tickets[0].key ||
153
+ !safeLabel(value.ticket.title) ||
154
+ !safeLabel(value.ticket.status, 40) ||
155
+ (value.ticket.url !== null && !safeLink(value.ticket.url, value.ticket.key))) ||
130
156
  (value.prs !== null &&
131
157
  !(
132
158
  Array.isArray(value.prs) &&
@@ -154,7 +180,9 @@ function validSnapshot(value, harness, now) {
154
180
  (value.epic.identifier == null || PROJECT_IDENTIFIER.test(value.epic.identifier)) &&
155
181
  Number.isSafeInteger(value.epic.percent) &&
156
182
  value.epic.percent >= 0 &&
157
- value.epic.percent <= 100
183
+ value.epic.percent <= 100 &&
184
+ (value.epic.role === undefined || value.epic.role === "coordinator") &&
185
+ (value.epic.counts === undefined || validCounts(value.epic.counts))
158
186
  )) ||
159
187
  (value.blockers !== null &&
160
188
  !(value.tenant === "botbuddy" && Array.isArray(value.blockers) && value.blockers.length <= 100)) ||
@@ -164,6 +192,16 @@ function validSnapshot(value, harness, now) {
164
192
  typeof value.staging.configured === "boolean" &&
165
193
  typeof value.staging.red === "boolean" &&
166
194
  (value.staging.since === null || Number.isFinite(Date.parse(value.staging.since)))
195
+ )) ||
196
+ // BOT-3212: the agent's active waits; null or absent means unknown (no badge).
197
+ (value.waits != null &&
198
+ !(
199
+ Number.isSafeInteger(value.waits.count) &&
200
+ value.waits.count >= 0 &&
201
+ value.waits.count <= 999 &&
202
+ (value.waits.count === 0
203
+ ? value.waits.oldest_at === null
204
+ : Number.isFinite(Date.parse(value.waits.oldest_at)))
167
205
  ))
168
206
  )
169
207
  return false;
@@ -236,6 +274,7 @@ function demoSnapshot(now) {
236
274
  percent: 45,
237
275
  },
238
276
  staging: { configured: true, red: true, since: new Date(now - 12 * 60000).toISOString() },
277
+ waits: { count: 2, oldest_at: new Date(now - 14 * 60000).toISOString() },
239
278
  // Demonstration-only IDs; never interpreted as current dependency state.
240
279
  blockers: [
241
280
  {
@@ -297,10 +336,12 @@ async function refresh($, { wake = false, keep = false } = {}) {
297
336
  snapshot = null;
298
337
  return;
299
338
  }
300
- if (result.exitCode !== 0)
339
+ if (result.exitCode !== 0) {
340
+ hintPrefix = data?.error === "ticket_missing" && /^[A-Z]{2,10}$/.test(data.prefix ?? "") ? data.prefix : null;
301
341
  throw new Error(
302
342
  typeof data.error === "string" ? data.error : "source_unavailable",
303
343
  );
344
+ }
304
345
  currentTime = await $.clock.now();
305
346
  if (request !== generation) return;
306
347
  if (previous && data && data.epic_skipped === true) data = keepKnown(data, previous);
@@ -310,7 +351,22 @@ async function refresh($, { wake = false, keep = false } = {}) {
310
351
  )
311
352
  throw new Error("session_changed");
312
353
  if (request === generation) {
354
+ // BOT-3212 AC-3: a changed count pulses the badge once; a first read or
355
+ // an unchanged one does not.
356
+ const before = snapshot?.waits?.count;
357
+ const after = data.waits?.count;
358
+ if (Number.isSafeInteger(before) && Number.isSafeInteger(after) && before !== after) {
359
+ pulsing = true;
360
+ const token = ++pulseToken;
361
+ $.clock.after(PULSE_MS, () => {
362
+ // A later change restarted the pulse: that one ends it.
363
+ if (token !== pulseToken) return;
364
+ pulsing = false;
365
+ $.ui.invalidate("ui.render");
366
+ });
367
+ }
313
368
  snapshot = data;
369
+ hintPrefix = TENANT_PREFIX[data.tenant] || null;
314
370
  relayFault = null;
315
371
  if (!wake) startRelay($);
316
372
  }
@@ -331,22 +387,26 @@ async function refresh($, { wake = false, keep = false } = {}) {
331
387
  }
332
388
  }
333
389
  // ── 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;
390
+ // What the band waits on: each ticket, the agent's own waits (BOT-3212), each PR
391
+ // still open or draft, and, when BotBuddy blockers are listed, each ticket's
392
+ // last blocker clearing, and the epic's Linear project (BOT-3136).
393
+ const MAX_CONDITIONS = 19;
338
394
  function waitConditions(s) {
339
395
  // BOT-3152 AC-2: unknown staging (null: a failed read) also wakes on it
340
396
  // (review on #1616), so the next incident re-reads; only a tenant known to
341
397
  // have no staging skips it.
342
398
  const staging = s.staging?.configured === false ? [] : ["event:type=staging_incident"];
343
399
  const conds = s.tickets.map((t) => "linear:issue=" + t.key);
400
+ // BOT-3212 AC-2: one of this agent's waits starting or ending. Armed only when
401
+ // BB read the waits, so a server without them is never waited on.
402
+ if (s.waits != null && UUID.test(s.agent?.id))
403
+ conds.push("event:type=agent_wait,subject=" + s.agent.id.toLowerCase());
344
404
  for (const p of s.prs || [])
345
405
  if (p.state === "open" || p.state === "draft")
346
406
  conds.push("pr-state:repo=" + p.repo + ",pr=" + p.number);
347
407
  // Blockers are read for the primary ticket only, and an `unblocked:` wait on
348
408
  // a ticket that is not blocked is granted at once: never arm it for others.
349
- if (s.tenant === "botbuddy" && s.blockers && s.blockers.length > 0)
409
+ if (s.tenant === "botbuddy" && s.ticket && s.blockers && s.blockers.length > 0)
350
410
  conds.push("unblocked:" + s.ticket.key);
351
411
  // BOT-3136 AC-1: the epic row wakes on its Linear project's progress.
352
412
  if (s.epic && UUID.test(s.epic.id))
@@ -357,8 +417,9 @@ function waitConditions(s) {
357
417
  for (const p of s.prs || [])
358
418
  if (p.state === "open" || p.state === "draft")
359
419
  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).
420
+ // At most 5 tickets, the agent's waits, 5 PRs (state + review), blockers, epic
421
+ // and staging: 19, the relay's limit, so no wake is ever dropped (review on
422
+ // #1616, round 4; BOT-3212).
362
423
  return [...conds, ...staging].slice(0, MAX_CONDITIONS);
363
424
  }
364
425
  // Ending the loop's stream kills the child; a module unload does the same.
@@ -468,7 +529,7 @@ function startRelay($) {
468
529
  // (BB's work list covers 3 days); keep what the last full read knew.
469
530
  function keepKnown(data, previous) {
470
531
  const { epic_skipped, ...rest } = data;
471
- const samePrimary = previous.tenant === data.tenant && previous.ticket.key === data.ticket.key;
532
+ const samePrimary = previous.tenant === data.tenant && previous.ticket?.key === data.ticket?.key;
472
533
  const known = new Map(previous.tickets.map((t) => [t.key, t]));
473
534
  return {
474
535
  ...rest,
@@ -710,17 +771,32 @@ function contextColor(c) {
710
771
  if (pct > 30) return "warning";
711
772
  return null;
712
773
  }
713
- function contextLine(el, key) {
774
+ // BOT-3212 AC-1: "⏳ 2 · oldest 14m", or null with no active waits or none known.
775
+ function waitsText(w, now) {
776
+ if (!w || !Number.isSafeInteger(w.count) || w.count < 1 || !w.oldest_at) return null;
777
+ return "⏳ " + w.count + " · oldest " + shortAge(w.oldest_at, now);
778
+ }
779
+ // The waits badge, then the context use. Either shows without the other.
780
+ function contextLine(el, key, waits = null) {
714
781
  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
- });
782
+ const badge = waitsText(waits, currentTime);
783
+ if (!text && !badge) return null;
784
+ const children = [];
785
+ if (badge) {
786
+ // The pulse: bold and coloured for PULSE_MS after a change, then quiet.
787
+ children.push(
788
+ pulsing
789
+ ? el.Text({ bold: true, color: "warning", children: [badge] })
790
+ : el.Text({ dimColor: true, children: [badge] }),
791
+ );
792
+ if (text) children.push(sep(el));
793
+ }
794
+ if (text) {
795
+ const color = contextColor(context);
796
+ children.push(color ? el.Text({ color, children: [text] }) : dim(el, text));
797
+ }
798
+ // Right-aligned on its own row (Jono, BOT-3217), the badge left of the context.
799
+ return el.Box({ key, flexDirection: "row", justifyContent: "flex-end", children });
724
800
  }
725
801
  async function readContext($) {
726
802
  try {
@@ -835,7 +911,10 @@ function bandLines(el, $, inPane) {
835
911
  ],
836
912
  icon: lead(el, "◇", epicHex(s.epic.state), "epic " + s.epic.state + " " + s.epic.percent + "%", epicIcon(s.epic.state, s.epic.percent)),
837
913
  status: [{ text: s.epic.percent + "% done", color: epicHex(s.epic.state) }],
838
- title: s.epic.name,
914
+ // BOT-3213: the project a coordinator session runs, with its tickets by state.
915
+ title: s.epic.role === "coordinator"
916
+ ? "Coordinating · " + (s.epic.counts ? countsText(s.epic.counts) + " · " : "") + s.epic.name
917
+ : s.epic.name,
839
918
  });
840
919
  else if (s.epic_unreadable)
841
920
  specs.push({ key: k("line-epic"), ids: [], icon: el.Text({ color: "warning", children: ["◇ "] }), status: [], title: UNREAD.epic, dim: true });
@@ -851,8 +930,8 @@ function bandLines(el, $, inPane) {
851
930
  const lines = specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null));
852
931
  // BOT-3152 AC-2: the web Staging chip's red, with its link, above the rows.
853
932
  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"));
933
+ // BOT-3211: the session's context use, last; BOT-3212: with the waits badge.
934
+ const ctx = contextLine(el, k("line-context"), s.waits);
856
935
  if (ctx) lines.push(ctx);
857
936
  return lines;
858
937
  }
@@ -937,6 +1016,8 @@ export function register(on) {
937
1016
  parked = false;
938
1017
  unbound = false;
939
1018
  context = null;
1019
+ pulsing = false;
1020
+ pulseToken++;
940
1021
  if (timer) timer.cancel();
941
1022
  return next(e);
942
1023
  });
@@ -982,17 +1063,26 @@ export function register(on) {
982
1063
  else {
983
1064
  children.push(
984
1065
  Text({ bold: true, children: [snapshot.agent.name] }),
985
- Text({
986
- children: [snapshot.ticket.key + " · " + snapshot.ticket.title],
987
- }),
988
- Text({
989
- color: "cyan",
990
- // BotBuddy status is read from Linear; SupplyGuard's from BB's copy.
991
- children: [
992
- (snapshot.ticket.url ? "Linear · " : "BB · ") +
993
- snapshot.ticket.status,
994
- ],
995
- }),
1066
+ ...(snapshot.ticket
1067
+ ? [
1068
+ Text({
1069
+ children: [snapshot.ticket.key + " · " + snapshot.ticket.title],
1070
+ }),
1071
+ Text({
1072
+ color: "cyan",
1073
+ // BotBuddy status is read from Linear; SupplyGuard's from BB's copy.
1074
+ children: [
1075
+ (snapshot.ticket.url ? "Linear · " : "BB · ") +
1076
+ snapshot.ticket.status,
1077
+ ],
1078
+ }),
1079
+ ]
1080
+ : [
1081
+ // BOT-3213: a coordinator session has a project, not a ticket.
1082
+ Text({
1083
+ children: ["Coordinator · " + (snapshot.epic.identifier || snapshot.epic.short_id) + " · " + snapshot.epic.name],
1084
+ }),
1085
+ ]),
996
1086
  Text({ children: ["Agent · " + activity] }),
997
1087
  Text({ dimColor: true, children: [snapshot.branch] }),
998
1088
  );
@@ -1009,11 +1099,12 @@ export function register(on) {
1009
1099
  // The same three items the band shows, one row each in full.
1010
1100
  surface = e.surface;
1011
1101
  children.push(...bandLines($.ui.resolve(e), $, true));
1012
- if (snapshot.blockers === null)
1102
+ // BOT-3213: a coordinator has no ticket, so it has no ticket blockers to list.
1103
+ if (snapshot.ticket && snapshot.blockers === null)
1013
1104
  children.push(
1014
1105
  Text({ dimColor: true, children: ["Blockers are read from the BotBuddy Linear workspace only."] }),
1015
1106
  );
1016
- else
1107
+ else if (snapshot.ticket)
1017
1108
  children.push(
1018
1109
  Text({
1019
1110
  bold: true,
@@ -1033,10 +1124,10 @@ export function register(on) {
1033
1124
  children.push(
1034
1125
  Text({ children: ["No open blockers at the last refresh."] }),
1035
1126
  );
1036
- const links = [
1037
- Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) }),
1038
- ];
1039
- if (snapshot.ticket.url)
1127
+ const links = snapshot.ticket
1128
+ ? [Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) })]
1129
+ : [Link({ label: "Open project ↗", href: LINKS.project(snapshot.epic.id) })];
1130
+ if (snapshot.ticket?.url)
1040
1131
  links.push(Link({ label: "Linear ↗", href: snapshot.ticket.url }));
1041
1132
  links.push(Link({ label: "Open BB ↗", href: APP }));
1042
1133
  children.push(Box({ flexDirection: "row", columnGap: 2, children: links }));
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.69.8",
3
- "source_commit": "704da4fe10bcbc13f1ca3abc6b0d47d2260e2c62",
4
- "source_sha256": "2465657c2fe4fa188d73f3b7efda0f608144afcfd8d7eba465ece55ccb1204f3",
2
+ "release_version": "1.71.0",
3
+ "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
4
+ "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
5
5
  "target": "darwin-arm64",
6
- "sha256": "865f29aebd07e09de6c5b77fd5297db5a568c30843c4395e8ae4e927b0d4e7ad"
6
+ "sha256": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570"
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.71.0",
3
+ "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
4
+ "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
5
5
  "target": "linux-x64",
6
- "sha256": "6ad28e621587a5a697621c54c5a9b09f90c79b0687a4ae1f25f380ef02843d4b"
6
+ "sha256": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec"
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.71.0",
4
+ "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
5
+ "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
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": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570",
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": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec",
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.71.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
package/src/commands.mjs CHANGED
@@ -79,10 +79,20 @@ export function routeHelpArgv(argv) {
79
79
 
80
80
  const TICKET_KEY_RE = /^[A-Za-z][A-Za-z0-9]{1,9}-\d{1,6}$/;
81
81
 
82
- export function validateBootstrapLinkage(ticketId, noTicketReason) {
82
+ // BOT-3213: Linear's project identifier shape (the server re-checks it, and
83
+ // that the project belongs to this repo's tenant).
84
+ const PROJECT_ID_RE = /^P-[A-Z][A-Z0-9]{0,9}-[1-9][0-9]{0,6}$/i;
85
+
86
+ export function validateBootstrapLinkage(ticketId, noTicketReason, projectId = null) {
83
87
  const ticket = typeof ticketId === "string" ? ticketId.trim() : "";
84
88
  const reason = typeof noTicketReason === "string" ? noTicketReason.trim() : "";
85
- if (!!ticket === !!reason) return "bb bootstrap requires exactly one of --ticket-id <ticket> or --no-ticket-reason <reason>";
89
+ const project = typeof projectId === "string" ? projectId.trim() : "";
90
+ if (project) {
91
+ if (!PROJECT_ID_RE.test(project)) return "bb bootstrap --project-id must be a Linear project identifier like P-BOT-39";
92
+ if (reason) return "bb bootstrap --project-id registers a coordinator; pass it with or without --ticket-id, but not also --no-ticket-reason";
93
+ } else if (!!ticket === !!reason) {
94
+ return "bb bootstrap requires exactly one of --ticket-id <ticket> or --no-ticket-reason <reason>, or --project-id <P-…> for a coordinator";
95
+ }
86
96
  if (ticket && !TICKET_KEY_RE.test(ticket)) return "bb bootstrap --ticket-id must be a ticket key like BOT-123";
87
97
  return null;
88
98
  }
@@ -1228,6 +1238,7 @@ export async function cmdBootstrap(args, {
1228
1238
  let ticketId = null;
1229
1239
  let ticketUrl = null;
1230
1240
  let noTicketReason = null;
1241
+ let projectId = null;
1231
1242
  let prId = null;
1232
1243
  let prNumber = null;
1233
1244
  let prUrl = null;
@@ -1244,18 +1255,20 @@ export async function cmdBootstrap(args, {
1244
1255
  else if (args[i] === "--ticket-id") ticketId = args[++i] || null;
1245
1256
  else if (args[i] === "--ticket-url") ticketUrl = args[++i] || null;
1246
1257
  else if (args[i] === "--no-ticket-reason") noTicketReason = args[++i] || null;
1258
+ else if (args[i] === "--project-id") projectId = args[++i] || null;
1247
1259
  else if (args[i] === "--pr-id") prId = args[++i] || null;
1248
1260
  else if (args[i] === "--pr-number") prNumber = Number(args[++i]);
1249
1261
  else if (args[i] === "--pr-url") prUrl = args[++i] || null;
1250
1262
  else if (args[i] === "--model") model = args[++i] || null;
1251
1263
  else if (args[i] === "--effort") effort = args[++i] || null;
1252
- else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
1264
+ else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --project-id <P-…> [--ticket-id <ticket>] | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
1253
1265
  }
1254
1266
  if (!harnessSessionId) fail("bb bootstrap requires --session-id <harness UUID>");
1255
- const linkageError = validateBootstrapLinkage(ticketId, noTicketReason);
1267
+ const linkageError = validateBootstrapLinkage(ticketId, noTicketReason, projectId);
1256
1268
  if (linkageError) fail(linkageError);
1257
1269
  ticketId = ticketId?.trim() || null;
1258
1270
  noTicketReason = noTicketReason?.trim() || null;
1271
+ projectId = projectId?.trim().toUpperCase() || null;
1259
1272
  const nativeIdentityError = validateBootstrapNativeIdentity({ type, ticketId, codexThreadId, claudeDesktopSessionId });
1260
1273
  if (nativeIdentityError) fail(nativeIdentityError);
1261
1274
  if (!nameExplicit) name = `${name}-${harnessSessionId.slice(0, 8)}`;
@@ -1269,6 +1282,7 @@ export async function cmdBootstrap(args, {
1269
1282
  ticketId,
1270
1283
  ticketUrl,
1271
1284
  noTicketReason,
1285
+ projectId,
1272
1286
  prId,
1273
1287
  prNumber: Number.isSafeInteger(prNumber) && prNumber > 0 ? prNumber : null,
1274
1288
  prUrl,
@@ -1282,7 +1296,7 @@ export async function cmdBootstrap(args, {
1282
1296
  // BOT-2058: the launcher must see a known-holder warning before it starts a
1283
1297
  // new harness. Keep it out of the credential cache, but preserve the
1284
1298
  // non-secret concurrency payload in this command receipt.
1285
- log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
1299
+ log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(projectId ? { project_id: projectId, role: "coordinator" } : {}), ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
1286
1300
  }
1287
1301
 
1288
1302
  /** BOT-2457: local preflight mirrors the server's ticket-link identity gate. */
@@ -289,6 +289,8 @@ export async function bootstrapHarnessSession({
289
289
  ticketId = null,
290
290
  ticketUrl = null,
291
291
  noTicketReason = null,
292
+ // BOT-3213: register as this Linear project's coordinator (P-BOT-39).
293
+ projectId = null,
292
294
  prId = null,
293
295
  prNumber = null,
294
296
  prUrl = null,
@@ -341,6 +343,7 @@ export async function bootstrapHarnessSession({
341
343
  ...(ticketId ? { ticket_id: ticketId } : {}),
342
344
  ...(ticketUrl ? { ticket_url: ticketUrl } : {}),
343
345
  ...(noTicketReason ? { no_ticket_reason: noTicketReason } : {}),
346
+ ...(projectId ? { project_id: projectId } : {}),
344
347
  ...(prId ? { pr_id: prId } : {}),
345
348
  ...(prNumber != null ? { pr_number: prNumber } : {}),
346
349
  ...(prUrl ? { pr_url: prUrl } : {}),
@@ -52,8 +52,30 @@ 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
- function refuse(code) {
56
- throw new Error(code);
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
+ }
64
+ function refuse(code, extra = {}) {
65
+ throw Object.assign(new Error(code), extra);
66
+ }
67
+ // BOT-3213: the project a session registered to coordinate, with its ticket
68
+ // counts by state; null when BB did not say or sent something malformed.
69
+ function coordinatorOf(own) {
70
+ const c = own?.coordinator;
71
+ if (!c || c.role !== "coordinator" || !UUID_LOWER.test(c.linear_project_id)) return null;
72
+ const n = (v) => (Number.isSafeInteger(v) && v >= 0 && v <= 100000 ? v : null);
73
+ const counts = c.counts && typeof c.counts === "object"
74
+ ? { done: n(c.counts.done), in_progress: n(c.counts.in_progress), blocked: n(c.counts.blocked), todo: n(c.counts.todo), total: n(c.counts.total) }
75
+ : null;
76
+ const ok = counts && Object.values(counts).every((v) => v !== null) &&
77
+ counts.done + counts.in_progress + counts.blocked + counts.todo === counts.total;
78
+ return { ...c, counts: ok ? counts : null };
57
79
  }
58
80
  function label(value, max = 240) {
59
81
  if (
@@ -241,15 +263,19 @@ export async function readStatus({
241
263
  const sessionKeys = ownOk && !selected
242
264
  ? [...new Set(own.tickets.map((x) => String(x?.key || "").toUpperCase()).filter((k) => keyPattern.test(k)))].slice(0, 5)
243
265
  : [];
244
- const bindingKind = selected ? "selected" : sessionKeys.length ? "session" : "branch";
245
- const keys = selected ?? (sessionKeys.length ? sessionKeys : branchKeys);
246
- if (!keys.length) refuse("ticket_missing");
247
- const key = keys[0];
248
- const useSession = bindingKind === "session";
266
+ // BOT-3213: a session registered as a project's coordinator, with no ticket of
267
+ // its own, is bound to that project; a branch key is only ever a guess.
268
+ const coordinator = ownOk ? coordinatorOf(own) : null;
269
+ const bindingKind = selected ? "selected" : sessionKeys.length ? "session" : coordinator ? "project" : "branch";
270
+ const keys = selected ?? (sessionKeys.length ? sessionKeys : bindingKind === "project" ? [] : branchKeys);
271
+ // The hint names this tenant's own key prefix (BOT-3213 AC-4).
272
+ if (!keys.length && bindingKind !== "project") refuse("ticket_missing", { prefix });
273
+ const key = keys[0] ?? null;
274
+ const useSession = bindingKind === "session" || bindingKind === "project";
249
275
  // The Linear ticket read and the BB reads are independent, so they run
250
276
  // together; a refused BB read blanks only its line. The epic read is the slow
251
277
  // one (~7 s live), so it gets a longer budget, and a relay wake skips it.
252
- const linearGraph = useLinear
278
+ const linearGraph = useLinear && key
253
279
  ? jsonRequest(
254
280
  "https://api.linear.app/graphql",
255
281
  {
@@ -275,7 +301,7 @@ export async function readStatus({
275
301
  ]);
276
302
  let linearTicket = null;
277
303
  const blockers = [];
278
- if (useLinear) {
304
+ if (useLinear && key) {
279
305
  const graph = await linearGraph;
280
306
  const issue = graph?.data?.issue;
281
307
  if (
@@ -398,6 +424,12 @@ export async function readStatus({
398
424
  total,
399
425
  percent: Number.isFinite(se.progress_pct) ? Math.max(0, Math.min(100, Math.round(se.progress_pct))) : total ? Math.round((100 * done) / total) : 0,
400
426
  };
427
+ // BOT-3213: the project this session coordinates carries its counts by state.
428
+ if (coordinator && coordinator.linear_project_id === epic.id) {
429
+ epic.role = "coordinator";
430
+ if (coordinator.counts) epic.counts = coordinator.counts;
431
+ if (!epic.identifier && PROJECT_IDENTIFIER.test(coordinator.identifier || "")) epic.identifier = coordinator.identifier;
432
+ }
401
433
  }
402
434
  if (owner) {
403
435
  const total = Math.max(0, (owner.children_total ?? 0) - (owner.children_canceled ?? 0));
@@ -460,7 +492,7 @@ export async function readStatus({
460
492
  id: state.agent_id,
461
493
  name: label(identity.agent.display_name, 100),
462
494
  },
463
- ticket: linearTicket || { ...tickets[0], url: null },
495
+ ticket: linearTicket || (tickets.length ? { ...tickets[0], url: null } : null),
464
496
  tickets,
465
497
  prs,
466
498
  epic,
@@ -468,10 +500,11 @@ export async function readStatus({
468
500
  // BOT-3152 AC-1: the epic source failed, so "no epic" would be a guess.
469
501
  epic_unreadable: useSession ? false : !skipEpic && !Array.isArray(epicHealth?.epics),
470
502
  staging: ownOk ? stagingOf(own) : null,
503
+ waits: ownOk ? waitsOf(own) : null,
471
504
  // BOT-3136: where the tickets came from — the registered session, an explicit
472
505
  // pick, or (only when the session registered none) a guess from the branch.
473
506
  binding: bindingKind,
474
- blockers: useLinear
507
+ blockers: useLinear && key
475
508
  ? [...new Map(blockers.map((b) => [b.key, b])).values()].sort((a, b) =>
476
509
  a.key.localeCompare(b.key),
477
510
  )
@@ -707,7 +740,8 @@ export async function main(args, {
707
740
  return 0;
708
741
  } catch (error) {
709
742
  const known = /^[a-z_]+$/.test(error?.message ?? "") ? error.message : "status_unavailable";
710
- out.write(JSON.stringify({ error: known }) + "\n");
743
+ const prefix = known === "ticket_missing" && /^[A-Z]{2,10}$/.test(error?.prefix ?? "") ? { prefix: error.prefix } : {};
744
+ out.write(JSON.stringify({ error: known, ...prefix }) + "\n");
711
745
  return 1;
712
746
  }
713
747
  }
@@ -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.