@botbuddy/cli 1.121.1 → 1.121.3

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.121.3
4
+
5
+ - BOT-3644: the bb-status band no longer fails on long titles. `bb status-band read` used to refuse the whole snapshot with `invalid_response` when a ticket title, a blocker title or the branch name was over 240 characters, which is common for user-story titles. It now shortens that text to 240 characters ending in "…"; the branch still matches tickets and PRs by its full name. Every bootstrap failure the band reports now names its own code (`bootstrap_refused` or the server's code, `not_authenticated`, `ticket_exclusivity_unverified`, `ticket_attribution_required`, `cache_cleanup_credential_missing`, `cached_session_close_failed`, `session_persist_failed`, `session_cleanup_unconfirmed`, `cached_session_unretired`) instead of `bootstrap_failed`. The band (1.11.0) never shows the catch-all "Status unavailable": every code `bb status-band read` emits has its own line, and a code it does not know is shown by name. After a transient failure (`source_unreachable`, `source_unavailable`, `invalid_response`, `status_unavailable`) it keeps the last good status on screen, marked STALE with the code, and reads again by itself after 30 s, doubling to at most 5 min. Identity and configuration failures still clear the band and are not retried.
6
+
7
+ ## 1.121.2
8
+
9
+ - BOT-3524: the fleet host daemon reports each stack's true memory high-water mark as `memory_peak_bytes`. It is the sum of the stack's containers' cgroup marks: cgroup v2 `memory.peak`, read from the cgroup that the container's own `/proc/<pid>/cgroup` names (its leaf must name the container ID), or cgroup v1 `max_usage` from the Engine stats. Summing per-container marks is an upper bound on the peak of the stack's total, which no cgroup records because compose containers share no parent cgroup. The mark counts page cache, like `memory.current`, so it is never below `memory_used_bytes`. Each container's highest mark is kept in the daemon's local state, so a restart, which gives the container a fresh cgroup, does not lower the stack's peak. When any running member's mark can't be read (Docker Desktop, a kernel older than 5.19), `memory_peak_status` is `unavailable` and no value is sent. Before, the peak was the larger of two 30 s polls and missed every spike between them.
10
+
3
11
  ## 1.121.0
4
12
 
5
13
  - BOT-3638: `bb release-notes submit --help` shows the optional `tour.where` in the sample pack: the screen's name in plain text (at most 120 characters), shown as the text of the "where to find it" link. It explains that BotBuddy shows `tour.find_it` as a link: an https URL as written, or an app path on your one production origin (`bb release-notes origins set --environment production --origin …`). `--pack` sends `tour.where` unchanged. Needs MCP 2.164.0.
@@ -11,7 +11,7 @@
11
11
  "name": "bb-status",
12
12
  "source": "./bb-status",
13
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.10.0"
14
+ "version": "1.11.0"
15
15
  },
16
16
  {
17
17
  "name": "bb-session",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
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"
@@ -19,6 +19,13 @@ let relayStream = null;
19
19
  let relayArmed = false;
20
20
  let keptLive = false;
21
21
  let relayFault = null;
22
+ // BOT-3644 AC-4/5: a transient read failure keeps the last good snapshot on
23
+ // screen (marked STALE with its code) and retries by itself with backoff.
24
+ const TRANSIENT = new Set(["source_unreachable", "source_unavailable", "invalid_response", "status_unavailable"]);
25
+ const READ_RETRY_FIRST_MS = 30000;
26
+ const READ_RETRY_MAX_MS = 300000;
27
+ let readFault = null;
28
+ let readBackoffMs = 0;
22
29
  let backoffMs = 0;
23
30
  const WAKE_READ_GAP_MS = 15000;
24
31
  // BOT-3152 AC-4: while no surface draws this session the relay is parked (no
@@ -76,6 +83,13 @@ const ERRORS = {
76
83
  "BB or Linear refused access. Check the existing connection.",
77
84
  source_unreachable: "BB or Linear could not be reached. Refresh to retry.",
78
85
  source_unavailable: "A status source is unavailable. Refresh to retry.",
86
+ // BOT-3644 AC-2: every code `bb status-band read` emits has its own line
87
+ // (cli/src/status-band-contract.test.mjs keeps the two in step).
88
+ source_rejected: "BB or Linear rejected the status request. Refresh to retry.",
89
+ invalid_response: "BB returned a status the band could not read (invalid_response). Refresh to retry.",
90
+ status_unavailable: "The bb CLI failed without naming a cause (status_unavailable). Refresh to retry.",
91
+ unsafe_link: "BB returned a link the band will not open (unsafe_link). Refresh to retry.",
92
+ invalid_arguments: "The band and the bb CLI disagree on arguments. Run `bb update`, then Refresh.",
79
93
  cli_missing: "Install the bb CLI (npm i -g @botbuddy/cli), then run bb setup.",
80
94
  cli_outdated: "Update the bb CLI (bb update) to use this band.",
81
95
  };
@@ -88,10 +102,8 @@ function errorText() {
88
102
  );
89
103
  if (errorCode === "session_bind_failed")
90
104
  return "BB could not connect this session (" + (bindReason || "bootstrap_failed") + "). Refresh to retry.";
91
- return (
92
- ERRORS[errorCode] ||
93
- "Status unavailable. Check BB and Linear connections, then refresh."
94
- );
105
+ // BOT-3644 AC-2: never a catch-all that names no cause.
106
+ return ERRORS[errorCode] || "BB status failed (" + errorCode + "). Refresh to retry.";
95
107
  }
96
108
  function safeLabel(value, max = 240) {
97
109
  return (
@@ -399,7 +411,10 @@ async function refresh($, { wake = false, keep = false } = {}) {
399
411
  // A Refresh of a live band stays "Live" until its read lands (review on #1598).
400
412
  keptLive = keep && relayArmed && !relayFault && !!snapshot;
401
413
  stopRelay();
402
- if (!keep) snapshot = null;
414
+ if (!keep) {
415
+ snapshot = null;
416
+ readFault = null;
417
+ }
403
418
  }
404
419
  errorCode = null;
405
420
  loading = true;
@@ -475,15 +490,28 @@ async function refresh($, { wake = false, keep = false } = {}) {
475
490
  snapshot = data;
476
491
  hintPrefix = TENANT_PREFIX[data.tenant] || null;
477
492
  relayFault = null;
493
+ readFault = null;
494
+ readBackoffMs = 0;
478
495
  if (!wake) startRelay($);
479
496
  }
480
497
  } catch (error) {
481
498
  if (request === generation) {
482
499
  if (wake) stopRelay();
483
- snapshot = null;
484
- errorCode = Object.hasOwn(ERRORS, error.message)
485
- ? error.message
500
+ // BOT-3644 AC-2: a snake_case code is kept even when the band has no line
501
+ // for it, so errorText() names it.
502
+ const message = String(error?.message ?? "");
503
+ errorCode = Object.hasOwn(ERRORS, message) || /^[a-z][a-z0-9_]{0,63}$/.test(message)
504
+ ? message
486
505
  : "status_unavailable";
506
+ // BOT-3644 AC-4: a transient failure keeps the last good status (STALE);
507
+ // any other failure clears it, so a wrong identity is never left drawn.
508
+ if (TRANSIENT.has(errorCode) && snapshot) readFault = errorCode;
509
+ else {
510
+ snapshot = null;
511
+ readFault = null;
512
+ }
513
+ if (TRANSIENT.has(errorCode)) retryRead($, request);
514
+ else readBackoffMs = 0;
487
515
  // BOT-3222: the hook is still registering this session; read once more
488
516
  // when the adapter says, unless another read has started since.
489
517
  if (errorCode === "session_starting") {
@@ -509,6 +537,22 @@ async function refresh($, { wake = false, keep = false } = {}) {
509
537
  }
510
538
  }
511
539
  }
540
+ // BOT-3644 AC-5: read again after a transient failure: 30 s, doubling, capped
541
+ // at 5 min. Any later read (a Refresh, a wake) bumps `generation` and cancels
542
+ // this one; a hidden session stays parked until a surface draws it again.
543
+ function retryRead($, request) {
544
+ readBackoffMs = Math.min(readBackoffMs ? readBackoffMs * 2 : READ_RETRY_FIRST_MS, READ_RETRY_MAX_MS);
545
+ const after = readBackoffMs;
546
+ void (async () => {
547
+ await delay($, after + 500);
548
+ if (request !== generation || mode !== "live" || !TRANSIENT.has(errorCode)) return;
549
+ if (parked || !(await onScreen($))) {
550
+ parked = true;
551
+ return;
552
+ }
553
+ await refresh($, { keep: true });
554
+ })();
555
+ }
512
556
  // ── BOT-3135 relay ─────────────────────────────────────────────────────
513
557
  // What the band waits on: each ticket, the agent's own waits (BOT-3212), each PR
514
558
  // still open or draft, and, when BotBuddy blockers are listed, each ticket's
@@ -711,10 +755,14 @@ async function followVisibility($) {
711
755
  }
712
756
  function stale() {
713
757
  if (mode !== "live" || !snapshot || parked) return false;
714
- if (relayFault) return true;
758
+ if (relayFault || readFault) return true;
715
759
  return !relayArmed && !keptLive && currentTime - Date.parse(snapshot.observed_at) > 60000;
716
760
  }
717
761
  function staleText() {
762
+ if (readFault) {
763
+ const why = ERRORS[readFault] || "BB status failed (" + readFault + "). Refresh to retry.";
764
+ return "STALE · " + (why.includes("(" + readFault + ")") ? why : why.replace(/\.( Refresh|$)/, " (" + readFault + ").$1"));
765
+ }
718
766
  if (relayFault === "session_expired")
719
767
  return "STALE · BB session expired. Run `bb doctor --fix` in this worktree, then Refresh.";
720
768
  if (relayFault) return "STALE · Live updates stopped. Refresh to check current status.";
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.121.1",
3
- "source_commit": "3412bf24bad730f10f7ba6ba2b6e88ffbba47557",
4
- "source_sha256": "549b73d360a137fe8c35afed5b0b564d59595f5ca0ac2b1bf56712ed78a5abb7",
2
+ "release_version": "1.121.3",
3
+ "source_commit": "a14f08eb5d01e005dcc8a99e751d8db218028ad6",
4
+ "source_sha256": "955dd23cb9101b28e5f579893614bcb16eb35f550b646f172965b773013acbef",
5
5
  "target": "darwin-arm64",
6
- "sha256": "34d471028f10013e838c2c97c35dc9dd348bdc2e17ce9e5a4ef1e55cd7ada99b"
6
+ "sha256": "32c9d6a4f9d29288b0f48f5ff4ebb519773259602a65f462db1aecf113699f2d"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.121.1",
3
- "source_commit": "3412bf24bad730f10f7ba6ba2b6e88ffbba47557",
4
- "source_sha256": "549b73d360a137fe8c35afed5b0b564d59595f5ca0ac2b1bf56712ed78a5abb7",
2
+ "release_version": "1.121.3",
3
+ "source_commit": "a14f08eb5d01e005dcc8a99e751d8db218028ad6",
4
+ "source_sha256": "955dd23cb9101b28e5f579893614bcb16eb35f550b646f172965b773013acbef",
5
5
  "target": "linux-x64",
6
- "sha256": "b7cab7b86a47235607c51371f3da67e1cc575c3f89af2b9e285b0c8f0f29a8e5"
6
+ "sha256": "1c519837c6862181fc1c0aebfb7690342c2083cd3d1e83e58d8bbe6f83bdf443"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.121.1",
4
- "source_commit": "3412bf24bad730f10f7ba6ba2b6e88ffbba47557",
5
- "source_sha256": "549b73d360a137fe8c35afed5b0b564d59595f5ca0ac2b1bf56712ed78a5abb7",
3
+ "release_version": "1.121.3",
4
+ "source_commit": "a14f08eb5d01e005dcc8a99e751d8db218028ad6",
5
+ "source_sha256": "955dd23cb9101b28e5f579893614bcb16eb35f550b646f172965b773013acbef",
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": "34d471028f10013e838c2c97c35dc9dd348bdc2e17ce9e5a4ef1e55cd7ada99b",
11
+ "sha256": "32c9d6a4f9d29288b0f48f5ff4ebb519773259602a65f462db1aecf113699f2d",
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": "b7cab7b86a47235607c51371f3da67e1cc575c3f89af2b9e285b0c8f0f29a8e5",
18
+ "sha256": "1c519837c6862181fc1c0aebfb7690342c2083cd3d1e83e58d8bbe6f83bdf443",
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.121.1",
3
+ "version": "1.121.3",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -100,6 +100,26 @@ async function closeWithDurableCredential(call, args, options) {
100
100
  }
101
101
  }
102
102
 
103
+ // BOT-3644 AC-3: every bootstrap failure carries a snake_case `code`, so the
104
+ // bb-status band names its cause instead of the catch-all bootstrap_failed.
105
+ // The message stays free text for the CLI; only the code reaches the band.
106
+ const CODE = /^[a-z][a-z0-9_]{0,63}$/;
107
+ function coded(code, message) {
108
+ return Object.assign(new Error(message), { code });
109
+ }
110
+ // A rethrown error keeps its own snake_case code; any other gets `fallback`.
111
+ function tagCode(error, fallback) {
112
+ if (error && typeof error === "object" && !CODE.test(error.code ?? "")) {
113
+ try { error.code = fallback; } catch { /* frozen: bindFailed falls back */ }
114
+ }
115
+ }
116
+ function refusalCode(response) {
117
+ if (response?.auth) return "not_authenticated";
118
+ for (const c of [response?.code, response?.data?.code, response?.data?.error, response?.error])
119
+ if (typeof c === "string" && CODE.test(c)) return c;
120
+ return "bootstrap_refused";
121
+ }
122
+
103
123
  // BOT-1650 (Codex round-24/25): a session was admitted but could not be retired.
104
124
  // Persist a cleanup marker so a later bootstrap retires it, then ALWAYS throw a
105
125
  // failure that preserves the primary cause, the retirement failure, AND any
@@ -119,7 +139,10 @@ async function recordOrphanAndFail({ session, cwd, retirementError, primaryError
119
139
  if (primaryError) parts.push(primaryError.message);
120
140
  parts.push(`the admitted session could not be retired: ${retirementError.message}`);
121
141
  if (persistError) parts.push(`and its cleanup marker could not be persisted: ${persistError.message}`);
122
- const err = new Error(parts.join("; "));
142
+ const err = coded(
143
+ CODE.test(primaryError?.code ?? "") ? primaryError.code : "session_cleanup_unconfirmed",
144
+ parts.join("; "),
145
+ );
123
146
  err.cause = primaryError ?? retirementError;
124
147
  throw err;
125
148
  }
@@ -328,7 +351,7 @@ export async function bootstrapHarnessSession({
328
351
  store = saveHarnessSession,
329
352
  transaction = withHarnessBootstrapLock,
330
353
  } = {}) {
331
- if (!name || !harnessSessionId) throw new Error("bootstrap requires name and harnessSessionId");
354
+ if (!name || !harnessSessionId) throw coded("bootstrap_invalid_arguments", "bootstrap requires name and harnessSessionId");
332
355
  const worktree = await worktreeRoot(cwd);
333
356
  return transaction({ cwd: worktree }, async () => {
334
357
  // BOT-1650 (Codex round-24): before admitting a new session, retry retiring
@@ -377,7 +400,7 @@ export async function bootstrapHarnessSession({
377
400
  harness,
378
401
  }, callOptions);
379
402
  if (!response?.ok || response.isError) {
380
- throw new Error(response?.data?.message || response?.error || "bootstrap_agent_session failed");
403
+ throw coded(refusalCode(response), response?.data?.message || response?.error || "bootstrap_agent_session failed");
381
404
  }
382
405
  // Persist only the four session-secret fields. Ticket signals are intentionally
383
406
  // returned to the launcher, never copied into the runtime credential file.
@@ -386,8 +409,8 @@ export async function bootstrapHarnessSession({
386
409
  // new harness session after a previous session's shutdown was not observed.
387
410
  // The signal remains on the returned result so callers can show the holder;
388
411
  // resource locks, not ticket presence, continue to arbitrate shared state.
389
- if (ticketSignals?.policy) throw new Error(ticketSignals.concurrency?.warning || "Ticket-session exclusivity could not be verified.");
390
- if (linkage?.status === "gap") throw new Error(linkage.warning || "Session bootstrap requires ticket attribution.");
412
+ if (ticketSignals?.policy) throw coded("ticket_exclusivity_unverified", ticketSignals.concurrency?.warning || "Ticket-session exclusivity could not be verified.");
413
+ if (linkage?.status === "gap") throw coded("ticket_attribution_required", linkage.warning || "Session bootstrap requires ticket attribution.");
391
414
  // A new harness may be admitted only after an abandoned cache aged out of
392
415
  // the server's liveness window. Before replacing that file, ask the server
393
416
  // to retire the cached session *only if its authoritative holder-liveness
@@ -405,7 +428,7 @@ export async function bootstrapHarnessSession({
405
428
  // it with its own scoped token first, and if that cannot be confirmed record
406
429
  // an orphan marker for a later bootstrap to drain — then fail closed. Matches
407
430
  // the store()-failure path's no-durable-credential handling.
408
- const primaryError = new Error("a replacement harness cache requires a durable credential to confirm remote session cleanup");
431
+ const primaryError = coded("cache_cleanup_credential_missing", "a replacement harness cache requires a durable credential to confirm remote session cleanup");
409
432
  const direct = await closeWithDurableCredential(call, {
410
433
  session_id: session.session_id,
411
434
  ...(session.session_token_generation ? { session_token_generation: session.session_token_generation } : {}),
@@ -435,7 +458,7 @@ export async function bootstrapHarnessSession({
435
458
  if (direct.closed) return;
436
459
  const confirmed = await closeWithDurableCredential(call, closeArgs, cleanupOptions);
437
460
  if (confirmed.closed) return;
438
- throw new Error(cleanupError(confirmed.response) || direct.error?.message || "new harness session cleanup could not be confirmed");
461
+ throw coded("session_cleanup_unconfirmed", cleanupError(confirmed.response) || direct.error?.message || "new harness session cleanup could not be confirmed");
439
462
  };
440
463
  const cachedCloseArgs = {
441
464
  session_id: cached.session_id,
@@ -446,6 +469,8 @@ export async function bootstrapHarnessSession({
446
469
  try {
447
470
  retired = await call("close_session", cachedCloseArgs, cleanupOptions);
448
471
  } catch (error) {
472
+ // BOT-3644 AC-3: the band names this cause (it is rethrown below).
473
+ tagCode(error, "cached_session_close_failed");
449
474
  // BOT-1650 (Codex round-22): a THROWN cached-close (e.g. its idempotent
450
475
  // close committed but the response was lost) must not bypass cleanup and
451
476
  // strand the newly-admitted session — whose bearer is neither returned nor
@@ -501,7 +526,7 @@ export async function bootstrapHarnessSession({
501
526
  `session_still_active: BB session ${cached.session_id} is still live and holds this worktree's session cache, so it was left running. Use another worktree, or retry once that session has ended.`,
502
527
  ), { code: refusal });
503
528
  }
504
- throw new Error(refusal || "cached harness session is still live or could not be retired");
529
+ throw coded(CODE.test(refusal ?? "") ? refusal : "cached_session_unretired", refusal || "cached harness session is still live or could not be retired");
505
530
  }
506
531
  replacedCachedSession = { session_id: cached.session_id, retired: !leftToExpire };
507
532
  await clearHarnessSession(cached.session_id, {
@@ -514,6 +539,8 @@ export async function bootstrapHarnessSession({
514
539
  try {
515
540
  state = await store(session, { cwd: worktree, harnessSessionId });
516
541
  } catch (error) {
542
+ // BOT-3644 AC-3: the band names this cause (it is rethrown below).
543
+ tagCode(error, "session_persist_failed");
517
544
  // The server session is unusable if this harness cannot persist its only
518
545
  // credential. The freshly issued session bearer is scoped to this exact
519
546
  // session and can self-close, so try it first — the durable OAuth/MCP
@@ -313,7 +313,9 @@ export async function readStatus({
313
313
  !/^bb_(?:agent|sess)_[0-9a-f]{64}$/.test(state.agent_session_token)
314
314
  )
315
315
  refuse("session_invalid");
316
- const branch = label(await branchReader(root));
316
+ // BOT-3644 AC-1: the branch drives matching whole (git allows long names);
317
+ // only the displayed copy is shortened, so a long name never fails the read.
318
+ const branch = label(await branchReader(root), 4096);
317
319
  const keyPattern = new RegExp(`^${prefix}-[1-9]\\d*$`);
318
320
  const branchTicket = branch.match(
319
321
  new RegExp(`(?:^|/)${prefix.toLowerCase()}-([1-9]\\d*)(?:-|$)`, "i"),
@@ -444,7 +446,7 @@ export async function readStatus({
444
446
  const agent = ownOk ? blockerAgentOf(own, blocker.identifier) : undefined;
445
447
  blockers.push({
446
448
  key: blocker.identifier,
447
- title: label(blocker.title),
449
+ title: safeText(blocker.title) || "Untitled",
448
450
  status: label(blocker.state.name),
449
451
  url: issueLink(blocker.url, blocker.identifier),
450
452
  ...(agent === undefined ? {} : { agent }),
@@ -452,7 +454,7 @@ export async function readStatus({
452
454
  }
453
455
  linearTicket = {
454
456
  key,
455
- title: label(issue.title),
457
+ title: safeText(issue.title) || "Untitled",
456
458
  status: label(issue.state?.name),
457
459
  url: issueLink(issue.url, key),
458
460
  };
@@ -649,7 +651,7 @@ export async function readStatus({
649
651
  harness_session_id: harnessSessionId.toLowerCase(),
650
652
  session_id: state.session_id,
651
653
  observed_at: new Date(now()).toISOString(),
652
- branch,
654
+ branch: safeText(branch),
653
655
  agent: {
654
656
  id: state.agent_id,
655
657
  name: label(identity.agent.display_name, 100),