@botbuddy/cli 1.72.0 → 1.73.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.73.0
4
+
5
+ - The bb-status band is redrawn (BOT-3223). Its first line shows a red context badge once the session has used more than 30% of its context, then one badge per active bb wait, such as `⏳ Codex review PR 1655 · 4m ↗`, linking to the wait (three at most, then `+N more`); the line wraps. Below it the epic leads a tree: its tickets nest under it, and each PR nests under the ticket its branch or title names; tickets outside the epic and PRs naming no ticket follow, marked "no epic" or "no ticket". Each row is an id link (`BOT-123 ↗`, `PR 456 ↗`), a coloured status badge in Linear's and GitHub's colours, and the title, with the badges in one column. The band's plugin version moves to 1.4.0, so `bb update` installs it.
6
+
3
7
  ## 1.72.0
4
8
 
5
9
  - `bb update` and `bb setup` install a second Claude Code plugin, `bb-session`, from the same `botbuddy-labs` marketplace as the bb-status band. Its SessionStart hook runs `bb bootstrap --session-id <harness id> --type claude` in every repo with a `.botbuddy-agent.json`, so Supply Guard and other repos without a repo hook register each session before the first prompt. The ticket comes from the branch (`bot-N`/`ent-N`) and is sent only with Claude Desktop's `local_<uuid>` identity; otherwise the session registers ticketless. The hook exports `BOTBUDDY_HARNESS_SESSION_ID`, `BOTBUDDY_SESSION_ID` and `BOTBUDDY_CALLER_HARNESS`, and gives the model its BB identity and any ticket-session warning. It never blocks a session: a failure or a bootstrap slower than 20 s exits 0 with one stderr line, and the band's own bootstrap covers that session. Disabling `bb-status` keeps registration. `BOTBUDDY_SESSION_HOOK=0` opts out.
@@ -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.3.0"
14
+ "version": "1.4.0"
15
15
  },
16
16
  {
17
17
  "name": "bb-session",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bb-status",
3
- "version": "1.3.0",
3
+ "version": "1.4.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"
@@ -51,6 +51,19 @@ The relay wakes on `event:type=agent_wait,subject=<agent id>` when one of the
51
51
  agent's waits starts or ends; the age ticks with the 5 s display clock, with no
52
52
  read. The badge is bold for 2 s after a read that changes the count.
53
53
 
54
+ **BOT-3223 layout (supersedes the right-aligned row above).** The band's first
55
+ line holds a red context badge with white text, shown only above 30%, then one
56
+ badge per active wait (`⏳ Codex review PR 1655 · 4m ↗`, from
57
+ `get_session_status.waits.items`), three at most, then `+N more`; the line wraps.
58
+ An older BB that sends no items gets the single count badge. Below it the epic
59
+ leads a tree: the session's tickets in its project nest under it (`├─`, `└─`),
60
+ each PR nests under the session ticket its branch or title names, and tickets
61
+ outside the epic and PRs naming none follow flat, marked "no epic" or "no
62
+ ticket". Each row is three columns: the tree and id link (`BOT-123 ↗`,
63
+ `PR 456 ↗`), a status badge in the band's palette (Linear for tickets and the
64
+ epic, GitHub for PRs; a tint on Desktop, a solid fill with contrasting ink in the
65
+ terminal), and the title.
66
+
54
67
  ## Install
55
68
 
56
69
  The bb CLI ships this mod and installs it (BOT-3152). `bb setup` and `bb update`
@@ -144,7 +144,12 @@ function validSnapshot(value, harness, now) {
144
144
  !Array.isArray(value.tickets) ||
145
145
  value.tickets.length > 5 ||
146
146
  !value.tickets.every(
147
- (t) => ownKey(t?.key) && safeLabel(t.title) && safeLabel(t.status, 40),
147
+ (t) =>
148
+ ownKey(t?.key) &&
149
+ safeLabel(t.title) &&
150
+ safeLabel(t.status, 40) &&
151
+ // BOT-3223: the ticket's project; absent is unknown, null is none.
152
+ (t.project === undefined || t.project === null || PROJECT.test(t.project)),
148
153
  ) ||
149
154
  // BOT-3213: only a coordinator's project binding may carry no ticket.
150
155
  (value.tickets.length === 0
@@ -165,7 +170,9 @@ function validSnapshot(value, harness, now) {
165
170
  safeLabel(p.title) &&
166
171
  PR_STATES.includes(p.state) &&
167
172
  typeof p.conflict === "boolean" &&
168
- (p.reviews == null || (Number.isSafeInteger(p.reviews) && p.reviews >= 0 && p.reviews <= 999)),
173
+ (p.reviews == null || (Number.isSafeInteger(p.reviews) && p.reviews >= 0 && p.reviews <= 999)) &&
174
+ // BOT-3223: the session ticket the PR serves, or null for none.
175
+ (p.ticket === undefined || p.ticket === null || value.tickets.some((t) => t.key === p.ticket)),
169
176
  )
170
177
  )) ||
171
178
  (value.epic !== null &&
@@ -181,6 +188,8 @@ function validSnapshot(value, harness, now) {
181
188
  Number.isSafeInteger(value.epic.percent) &&
182
189
  value.epic.percent >= 0 &&
183
190
  value.epic.percent <= 100 &&
191
+ (value.epic.total === undefined ||
192
+ (Number.isSafeInteger(value.epic.total) && Number.isSafeInteger(value.epic.done) && value.epic.done >= 0 && value.epic.done <= value.epic.total)) &&
184
193
  (value.epic.role === undefined || value.epic.role === "coordinator") &&
185
194
  (value.epic.counts === undefined || validCounts(value.epic.counts))
186
195
  )) ||
@@ -201,7 +210,12 @@ function validSnapshot(value, harness, now) {
201
210
  value.waits.count <= 999 &&
202
211
  (value.waits.count === 0
203
212
  ? value.waits.oldest_at === null
204
- : Number.isFinite(Date.parse(value.waits.oldest_at)))
213
+ : Number.isFinite(Date.parse(value.waits.oldest_at))) &&
214
+ // BOT-3223 AC-1: one badge each; absent from an older CLI.
215
+ (value.waits.items === undefined ||
216
+ (Array.isArray(value.waits.items) &&
217
+ value.waits.items.length <= 5 &&
218
+ value.waits.items.every((i) => UUID.test(i?.id) && safeLabel(i.label, 40) && Number.isFinite(Date.parse(i.created_at)))))
205
219
  ))
206
220
  )
207
221
  return false;
@@ -227,6 +241,8 @@ const LINKS = {
227
241
  ticket: (key) => APP + "/kanban?card=ticket:" + key,
228
242
  project: (id) => APP + "/kanban?card=project:" + id,
229
243
  pr: (repo, n) => APP + "/kanban?card=pr:" + repo + "%23" + n,
244
+ // BOT-3223 AC-1: a wait badge opens that wait on BB's Waits page.
245
+ wait: (id) => APP + "/waits?wait=" + id,
230
246
  // BOT-3152 AC-2: the web top bar's Staging chip link (STAGING_HREF).
231
247
  staging: APP + "/release-readiness/staging/latest",
232
248
  };
@@ -253,14 +269,14 @@ function demoSnapshot(now) {
253
269
  url: "https://linear.app/botbuddy/issue/BOT-2644",
254
270
  },
255
271
  tickets: [
256
- { key: "BOT-2644", title: "Show the session's tickets, PRs and epic inside Claude so an operator can see what the agent is working on without a model turn (example)", status: "In Progress" },
257
- { key: "BOT-2645", title: "Status icons follow Linear (example)", status: "In Review" },
258
- { key: "BOT-2646", title: "Aligned columns in the band (example)", status: "Done" },
272
+ { key: "BOT-2644", title: "Show the session's tickets, PRs and epic inside Claude so an operator can see what the agent is working on without a model turn (example)", status: "In Progress", project: "00000000-0000-4000-8000-000000000000" },
273
+ { key: "BOT-2645", title: "Status icons follow Linear (example)", status: "In Review", project: "00000000-0000-4000-8000-000000000000" },
274
+ { key: "BOT-2646", title: "Aligned columns in the band (example)", status: "Done", project: "00000000-0000-4000-8000-000000000000" },
259
275
  ],
260
276
  prs: [
261
- { repo: "bot-buddy/botbuddy-webapp", number: 1585, title: "feat(BOT-2644): three aligned lines above the prompt, one status icon per ticket and PR, titles that wrap instead of clipping (example)", state: "open", conflict: true, reviews: 2 },
262
- { repo: "bot-buddy/botbuddy-webapp", number: 1586, title: "Status icons (example)", state: "draft", conflict: false, reviews: 0 },
263
- { repo: "bot-buddy/botbuddy-webapp", number: 1571, title: "Card links (example)", state: "merged", conflict: false, reviews: 1 },
277
+ { repo: "bot-buddy/botbuddy-webapp", number: 1585, title: "feat(BOT-2644): three aligned lines above the prompt, one status icon per ticket and PR, titles that wrap instead of clipping (example)", state: "open", conflict: true, reviews: 2, ticket: "BOT-2644" },
278
+ { repo: "bot-buddy/botbuddy-webapp", number: 1586, title: "Status icons (example)", state: "draft", conflict: false, reviews: 0, ticket: "BOT-2645" },
279
+ { repo: "bot-buddy/botbuddy-webapp", number: 1571, title: "Card links (example)", state: "merged", conflict: false, reviews: 1, ticket: "BOT-2646" },
264
280
  ],
265
281
  epic: {
266
282
  id: "00000000-0000-4000-8000-000000000000",
@@ -274,7 +290,14 @@ function demoSnapshot(now) {
274
290
  percent: 45,
275
291
  },
276
292
  staging: { configured: true, red: true, since: new Date(now - 12 * 60000).toISOString() },
277
- waits: { count: 2, oldest_at: new Date(now - 14 * 60000).toISOString() },
293
+ waits: {
294
+ count: 2,
295
+ oldest_at: new Date(now - 14 * 60000).toISOString(),
296
+ items: [
297
+ { id: "00000000-0000-4000-8000-0000000000a1", label: "Codex review PR 1585", created_at: new Date(now - 14 * 60000).toISOString() },
298
+ { id: "00000000-0000-4000-8000-0000000000a2", label: "CI run 43578112184", created_at: new Date(now - 60000).toISOString() },
299
+ ],
300
+ },
278
301
  // Demonstration-only IDs; never interpreted as current dependency state.
279
302
  blockers: [
280
303
  {
@@ -537,9 +560,14 @@ function keepKnown(data, previous) {
537
560
  // with it whether that epic could not be read (review on #1616).
538
561
  epic: samePrimary ? previous.epic : null,
539
562
  epic_unreadable: samePrimary ? previous.epic_unreadable === true : false,
540
- tickets: data.tickets.map((t) =>
541
- t.status === "Unknown" && known.has(t.key) ? known.get(t.key) : t,
542
- ),
563
+ tickets: data.tickets.map((t) => {
564
+ const was = known.get(t.key);
565
+ if (!was) return t;
566
+ if (t.status === "Unknown") return was;
567
+ // BOT-3223 (Codex P2 on #1657): the skipped epic read cannot say which
568
+ // project a ticket is in; keep the last full read's, with the new status.
569
+ return t.project === undefined && was.project !== undefined ? { ...t, project: was.project } : t;
570
+ }),
543
571
  };
544
572
  }
545
573
  // ── BOT-3152 AC-4: only a session on screen holds a live relay ─────────────
@@ -716,41 +744,58 @@ function dim(el, text) {
716
744
  function sep(el) {
717
745
  return dim(el, " · ");
718
746
  }
719
- // Three aligned columns per line: [icon id]…, status, title. The id and
720
- // status columns take the widest line's width on every line and never shrink,
747
+ // Three aligned columns per row: [tree id ↗], status badge, title. The id and
748
+ // status columns take the widest row's width on every row and never shrink,
721
749
  // so ids never break and statuses line up; the title takes the rest and wraps.
722
- // One item per row: tickets, then PRs, then the single epic.
750
+ // BOT-3223: the rows are a tree (epic → tickets → PRs); the tree's branches sit
751
+ // inside the id column, so every status badge starts at the same cell.
723
752
  const ID_GAP = 2;
724
- function idsWidth(ids) {
725
- return ids.reduce((w, id, i) => w + (i ? ID_GAP : 0) + (id.label || "").length + (id.out ? 2 : 0), 0);
753
+ function idsWidth(ids, prefix = "") {
754
+ return prefix.length + ids.reduce((w, id, i) => w + (i ? ID_GAP : 0) + (id.label || "").length + (id.out ? 2 : 0), 0);
726
755
  }
727
- // Icon (2 cells) then the status parts.
756
+ // Badge: one cell of padding each side, the icon (2 cells), then the parts.
728
757
  function statusWidth(spec) {
729
- return (spec.icon ? 2 : 0) + spec.status.reduce((w, part, i) => w + (i ? 3 : 0) + part.text.length, 0);
758
+ if (!spec.status.length) return spec.icon ? 2 : 0;
759
+ return 2 + (spec.icon ? 2 : 0) + spec.status.reduce((w, part, i) => w + (i ? 3 : 0) + part.text.length, 0);
760
+ }
761
+ // BOT-3223 AC-3: the status is a badge in the band's own palette (Linear for
762
+ // tickets and the epic, GitHub for PRs). On Desktop a tint of the colour behind
763
+ // the coloured word, as the web chips draw it; the terminal has no alpha, so
764
+ // there the colour fills the badge and the word takes a contrasting ink.
765
+ function ink(hex) {
766
+ const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex || "");
767
+ if (!m) return "#ffffff";
768
+ const [r, g, b] = m.slice(1).map((x) => parseInt(x, 16) / 255);
769
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.55 ? "#1f2328" : "#ffffff";
770
+ }
771
+ function badgeColors(hex) {
772
+ const solid = surface === "terminal" || !/^#[0-9a-f]{6}$/i.test(hex || "");
773
+ return solid ? { bg: hex, fg: ink(hex), muted: ink(hex) } : { bg: hex + "26", fg: hex, muted: ICON.grey };
774
+ }
775
+ function statusBadge(el, key, spec) {
776
+ if (!spec.status.length) return spec.icon ? [spec.icon] : [];
777
+ const { bg, fg, muted } = badgeColors(spec.hex);
778
+ const children = spec.icon ? [spec.icon] : [];
779
+ spec.status.forEach((part, i) => {
780
+ if (i) children.push(el.Text({ color: muted, children: [" · "] }));
781
+ children.push(el.Text({ color: part.muted ? muted : fg, children: [part.text] }));
782
+ });
783
+ return [el.Box({ key, flexDirection: "row", flexShrink: 0, backgroundColor: bg, paddingX: 1, children })];
730
784
  }
731
785
  function bandLine(el, spec, widths, right) {
732
786
  const ids = [];
787
+ if (spec.prefix) ids.push(dim(el, spec.prefix));
733
788
  spec.ids.forEach((id, i) => {
734
789
  if (i) ids.push(el.Text({ children: [" ".repeat(ID_GAP)] }));
735
790
  if (id.label) ids.push(el.Link({ href: id.href, label: id.label }));
736
791
  if (id.out) ids.push(el.Text({ children: [" "] }), el.Link({ href: id.out, label: "↗" }));
737
792
  });
738
- // The state icon sits left of the status word, in the same colour.
739
- const status = spec.icon ? [spec.icon] : [];
740
- spec.status.forEach((part, i) => {
741
- if (i) status.push(sep(el));
742
- status.push(el.Text({ color: part.color, children: [part.text] }));
743
- });
793
+ const title = [el.Text({ wrap: "wrap", dimColor: spec.dim || undefined, children: [spec.title] })];
794
+ if (spec.note) title.push(dim(el, " " + spec.note));
744
795
  const children = [
745
796
  el.Box({ key: spec.key + "-ids", flexDirection: "row", width: widths.ids, flexShrink: 0, children: ids }),
746
- el.Box({ key: spec.key + "-status", flexDirection: "row", width: widths.status, flexShrink: 0, children: status }),
747
- el.Box({
748
- key: spec.key + "-title",
749
- flexGrow: 1,
750
- flexShrink: 1,
751
- minWidth: 0,
752
- children: [el.Text({ wrap: "wrap", dimColor: spec.dim || undefined, children: [spec.title] })],
753
- }),
797
+ el.Box({ key: spec.key + "-status", flexDirection: "row", width: widths.status, flexShrink: 0, children: statusBadge(el, spec.key + "-badge", spec) }),
798
+ el.Box({ key: spec.key + "-title", flexDirection: "row", flexGrow: 1, flexShrink: 1, minWidth: 0, flexWrap: "wrap", children: title }),
754
799
  ];
755
800
  if (right && right.length)
756
801
  children.push(el.Box({ flexDirection: "row", flexShrink: 0, columnGap: 1, children: right }));
@@ -763,40 +808,55 @@ function contextText(c) {
763
808
  if (!c || !Number.isFinite(c.percent) || c.percent < 0 || c.percent > 100) return null;
764
809
  return "Context " + Math.round(c.percent) + "%";
765
810
  }
766
- // BOT-3217: amber above 30%, red above 50%, judged on the rounded percent the
767
- // row shows, so the colour always matches the number.
768
- function contextColor(c) {
769
- const pct = Math.round(c.percent);
770
- if (pct > 50) return "error";
771
- if (pct > 30) return "warning";
772
- return null;
773
- }
774
811
  // BOT-3212 AC-1: "⏳ 2 · oldest 14m", or null with no active waits or none known.
775
812
  function waitsText(w, now) {
776
813
  if (!w || !Number.isSafeInteger(w.count) || w.count < 1 || !w.oldest_at) return null;
777
814
  return "⏳ " + w.count + " · oldest " + shortAge(w.oldest_at, now);
778
815
  }
779
- // The waits badge, then the context use. Either shows without the other.
816
+ // BOT-3223 AC-1: the top line. A red context badge (white ink) only above 30%,
817
+ // then one badge per active wait — what it waits on, its age, a link to it —
818
+ // at most MAX_WAIT_BADGES, then "+N more". The line wraps; none of it, no line.
819
+ const MAX_WAIT_BADGES = 3;
820
+ const CONTEXT_ALARM = 30;
821
+ function contextAlarm(c) {
822
+ const text = contextText(c);
823
+ return text && Math.round(c.percent) > CONTEXT_ALARM ? text : null;
824
+ }
825
+ function waitBadges(el, key, w, now) {
826
+ if (!w || !Number.isSafeInteger(w.count) || w.count < 1) return [];
827
+ const style = pulsing ? { bold: true } : {};
828
+ const { bg, fg } = badgeColors(ICON.violet);
829
+ // An older BB lists no items: the one count badge, as before.
830
+ if (!Array.isArray(w.items) || !w.items.length) {
831
+ const text = waitsText(w, now);
832
+ return text ? [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, backgroundColor: bg, paddingX: 1, children: [el.Text({ color: fg, ...style, children: [text] })] })] : [];
833
+ }
834
+ const out = w.items.slice(0, MAX_WAIT_BADGES).map((i) =>
835
+ el.Box({
836
+ key: key + "-wait-" + i.id,
837
+ flexDirection: "row",
838
+ flexShrink: 0,
839
+ backgroundColor: bg,
840
+ paddingX: 1,
841
+ children: [
842
+ el.Text({ color: fg, ...style, children: ["⏳ " + i.label + " · " + shortAge(i.created_at, now) + " "] }),
843
+ el.Link({ href: LINKS.wait(i.id), label: "↗" }),
844
+ ],
845
+ }),
846
+ );
847
+ if (w.count > out.length) out.push(dim(el, "+" + (w.count - out.length) + " more"));
848
+ return out;
849
+ }
780
850
  function contextLine(el, key, waits = null) {
781
- const text = contextText(context);
782
- const badge = waitsText(waits, currentTime);
783
- if (!text && !badge) return null;
784
851
  const children = [];
785
- if (badge) {
786
- // The pulse: bold and coloured for PULSE_MS after a change, then quiet.
852
+ const alarm = contextAlarm(context);
853
+ if (alarm)
787
854
  children.push(
788
- pulsing
789
- ? el.Text({ bold: true, color: "warning", children: [badge] })
790
- : el.Text({ dimColor: true, children: [badge] }),
855
+ el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, backgroundColor: "error", paddingX: 1, children: [el.Text({ color: "#ffffff", bold: true, children: [alarm] })] }),
791
856
  );
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 });
857
+ children.push(...waitBadges(el, key, waits, currentTime));
858
+ if (!children.length) return null;
859
+ return el.Box({ key, flexDirection: "row", flexWrap: "wrap", columnGap: 1, rowGap: 0, children });
800
860
  }
801
861
  async function readContext($) {
802
862
  try {
@@ -852,52 +912,37 @@ function bandLines(el, $, inPane) {
852
912
  ].filter(Boolean);
853
913
  }
854
914
  const s = snapshot;
855
- // One row per ticket and per PR, each with its own icon, status and title.
856
- const specs = s.tickets.map((t) => ({
915
+ // BOT-3223 AC-2: a tree. The epic leads; the session's tickets in its project
916
+ // nest under it, and each PR nests under the ticket its branch or title names.
917
+ // Tickets outside the epic and PRs naming no ticket follow, flat, marked.
918
+ const ticketSpec = (t, prefix, note) => ({
857
919
  key: k("line-ticket-" + t.key),
858
- ids: [
859
- {
860
- label: t.key,
861
- href: LINKS.ticket(t.key),
862
- out: OUT.ticket(s.tenant, t.key),
863
- },
864
- ],
865
- icon: lead(el, "◆", ticketHex(t.status), "ticket " + t.status, ticketIcon(t.status)),
866
- status: [{ text: t.status, color: ticketHex(t.status) }],
920
+ prefix,
921
+ ids: [{ label: t.key, href: LINKS.ticket(t.key), out: OUT.ticket(s.tenant, t.key) }],
922
+ icon: lead(el, "◆", badgeColors(ticketHex(t.status)).fg, "ticket " + t.status, ticketIcon(t.status)),
923
+ hex: ticketHex(t.status),
924
+ status: [{ text: t.status }],
867
925
  title: t.title,
868
- }));
869
- // BOT-3152 AC-1: no PR or no epic means no row; a failed read says so.
870
- if (s.prs)
871
- for (const p of s.prs) {
872
- const status = [{ text: PR_LABEL[p.state], color: ICON.pr[p.state] }];
873
- if (p.conflict && p.state !== "merged" && p.state !== "closed")
874
- status.push({ text: "⚠ conflict", color: "#bc4c00" });
875
- // BOT-3152 AC-3: the PR's code-review rounds, as get_pr_state counts them.
876
- if (Number.isSafeInteger(p.reviews))
877
- status.push({ text: p.reviews + (p.reviews === 1 ? " review" : " reviews"), color: ICON.grey });
878
- specs.push({
879
- key: k("line-pr-" + p.number),
880
- ids: [
881
- {
882
- label: "#" + p.number,
883
- href: LINKS.pr(p.repo, p.number),
884
- out: OUT.pr(p.repo, p.number),
885
- },
886
- ],
887
- icon: lead(el, "⎇", ICON.pr[p.state], "pr " + p.state, prIcon(p.state)),
888
- status,
889
- title: p.title,
890
- });
891
- }
892
- else
893
- specs.push({
894
- key: k("line-pr"),
895
- ids: [],
896
- icon: el.Text({ color: "warning", children: ["⎇ "] }),
897
- status: [],
898
- title: UNREAD.prs,
899
- dim: true,
900
- });
926
+ note,
927
+ });
928
+ const prSpec = (p, prefix, note) => {
929
+ const hex = p.conflict && p.state !== "merged" && p.state !== "closed" ? ICON.pr.closed : ICON.pr[p.state];
930
+ const status = [{ text: hex === ICON.pr[p.state] ? PR_LABEL[p.state] : "Conflict" }];
931
+ // BOT-3152 AC-3: the PR's code-review rounds, as get_pr_state counts them.
932
+ if (Number.isSafeInteger(p.reviews))
933
+ status.push({ text: p.reviews + (p.reviews === 1 ? " review" : " reviews"), muted: true });
934
+ return {
935
+ key: k("line-pr-" + p.number),
936
+ prefix,
937
+ ids: [{ label: "PR " + p.number, href: LINKS.pr(p.repo, p.number), out: OUT.pr(p.repo, p.number) }],
938
+ icon: lead(el, "⎇", badgeColors(hex).fg, "pr " + p.state, prIcon(p.state)),
939
+ hex,
940
+ status,
941
+ title: p.title,
942
+ note,
943
+ };
944
+ };
945
+ const specs = [];
901
946
  if (s.epic)
902
947
  specs.push({
903
948
  key: k("line-epic"),
@@ -909,8 +954,9 @@ function bandLines(el, $, inPane) {
909
954
  out: s.epic.url,
910
955
  },
911
956
  ],
912
- icon: lead(el, "◇", epicHex(s.epic.state), "epic " + s.epic.state + " " + s.epic.percent + "%", epicIcon(s.epic.state, s.epic.percent)),
913
- status: [{ text: s.epic.percent + "% done", color: epicHex(s.epic.state) }],
957
+ icon: lead(el, "◇", badgeColors(epicHex(s.epic.state)).fg, "epic " + s.epic.state + " " + s.epic.percent + "%", epicIcon(s.epic.state, s.epic.percent)),
958
+ hex: epicHex(s.epic.state),
959
+ status: [{ text: s.epic.percent + "%" }, ...(Number.isSafeInteger(s.epic.total) && s.epic.total > 0 ? [{ text: s.epic.done + "/" + s.epic.total, muted: true }] : [])],
914
960
  // BOT-3213: the project a coordinator session runs, with its tickets by state.
915
961
  title: s.epic.role === "coordinator"
916
962
  ? "Coordinating · " + (s.epic.counts ? countsText(s.epic.counts) + " · " : "") + s.epic.name
@@ -918,8 +964,38 @@ function bandLines(el, $, inPane) {
918
964
  });
919
965
  else if (s.epic_unreadable)
920
966
  specs.push({ key: k("line-epic"), ids: [], icon: el.Text({ color: "warning", children: ["◇ "] }), status: [], title: UNREAD.epic, dim: true });
967
+ const keys = s.tickets.map((t) => t.key);
968
+ const prsOf = (key) => (s.prs || []).filter((p) => p.ticket === key);
969
+ // A ticket whose project BB did not report (an older CLI) stays in the epic.
970
+ const inEpic = (t) => !!s.epic && (t.project === undefined || t.project === s.epic.id);
971
+ const branch = (last) => (last ? "└─ " : "├─ ");
972
+ const stem = (last) => (last ? " " : "│ ");
973
+ const epicTickets = s.tickets.filter(inEpic);
974
+ epicTickets.forEach((t, i) => {
975
+ const last = i === epicTickets.length - 1;
976
+ specs.push(ticketSpec(t, branch(last)));
977
+ const prs = prsOf(t.key);
978
+ prs.forEach((p, j) => specs.push(prSpec(p, stem(last) + branch(j === prs.length - 1))));
979
+ });
980
+ for (const t of s.tickets.filter((t) => !inEpic(t))) {
981
+ // A ticket in another project is not epic-less (review on #1657).
982
+ specs.push(ticketSpec(t, "", !s.epic ? null : t.project ? "other epic" : "no epic"));
983
+ const prs = prsOf(t.key);
984
+ prs.forEach((p, j) => specs.push(prSpec(p, branch(j === prs.length - 1))));
985
+ }
986
+ // BOT-3152 AC-1: no PR means no row; a failed read says so.
987
+ if (s.prs) for (const p of s.prs.filter((p) => !keys.includes(p.ticket))) specs.push(prSpec(p, "", "no ticket"));
988
+ else
989
+ specs.push({
990
+ key: k("line-pr"),
991
+ ids: [],
992
+ icon: el.Text({ color: "warning", children: ["⎇ "] }),
993
+ status: [],
994
+ title: UNREAD.prs,
995
+ dim: true,
996
+ });
921
997
  const widths = {
922
- ids: Math.max(...specs.map((x) => idsWidth(x.ids))),
998
+ ids: Math.max(...specs.map((x) => idsWidth(x.ids, x.prefix))),
923
999
  status: Math.max(...specs.map(statusWidth)),
924
1000
  };
925
1001
  const right = [...tag];
@@ -928,11 +1004,11 @@ function bandLines(el, $, inPane) {
928
1004
  if (s.staging == null) right.push(dim(el, UNREAD.staging));
929
1005
  if (details) right.push(details);
930
1006
  const lines = specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null));
931
- // BOT-3152 AC-2: the web Staging chip's red, with its link, above the rows.
932
- if (s.staging?.red) lines.unshift(stagingBanner(el, k("line-staging"), s.staging.since));
933
- // BOT-3211: the session's context use, last; BOT-3212: with the waits badge.
1007
+ // BOT-3223 AC-1: context alarm and wait badges lead, on one wrapping line.
934
1008
  const ctx = contextLine(el, k("line-context"), s.waits);
935
- if (ctx) lines.push(ctx);
1009
+ if (ctx) lines.unshift(ctx);
1010
+ // BOT-3152 AC-2: the web Staging chip's red, with its link, above everything.
1011
+ if (s.staging?.red) lines.unshift(stagingBanner(el, k("line-staging"), s.staging.since));
936
1012
  return lines;
937
1013
  }
938
1014
  export function register(on) {
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.72.0",
3
- "source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
4
- "source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
2
+ "release_version": "1.73.0",
3
+ "source_commit": "6b876cc1b10ca1c5c7b088ea4e9afed3cad244bc",
4
+ "source_sha256": "9505b68bc947e163a7415f881062303ff6e210b872c8928725152ab3e921b5ec",
5
5
  "target": "darwin-arm64",
6
- "sha256": "17bd44c07d1f07aaea6b9ca1db28b583a01353eb9b396b9c1ed37392964661ee"
6
+ "sha256": "501fb0b34089c732ef076d5426184205d468ceef5a0d394defc2516c5c820513"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.72.0",
3
- "source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
4
- "source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
2
+ "release_version": "1.73.0",
3
+ "source_commit": "6b876cc1b10ca1c5c7b088ea4e9afed3cad244bc",
4
+ "source_sha256": "9505b68bc947e163a7415f881062303ff6e210b872c8928725152ab3e921b5ec",
5
5
  "target": "linux-x64",
6
- "sha256": "fa0617252f98948c464b679f4ba3697e3d502459bebbb1af8b88508674e2d4d8"
6
+ "sha256": "e12c6d215cda4a772a12d97f10e59c504768ccb74bf9d1b8bb0ddb4ac66ffa48"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.72.0",
4
- "source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
5
- "source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
3
+ "release_version": "1.73.0",
4
+ "source_commit": "6b876cc1b10ca1c5c7b088ea4e9afed3cad244bc",
5
+ "source_sha256": "9505b68bc947e163a7415f881062303ff6e210b872c8928725152ab3e921b5ec",
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": "17bd44c07d1f07aaea6b9ca1db28b583a01353eb9b396b9c1ed37392964661ee",
11
+ "sha256": "501fb0b34089c732ef076d5426184205d468ceef5a0d394defc2516c5c820513",
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": "fa0617252f98948c464b679f4ba3697e3d502459bebbb1af8b88508674e2d4d8",
18
+ "sha256": "e12c6d215cda4a772a12d97f10e59c504768ccb74bf9d1b8bb0ddb4ac66ffa48",
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.72.0",
3
+ "version": "1.73.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,9 +57,14 @@ function stagingOf(own) {
57
57
  function waitsOf(own) {
58
58
  const w = own?.waits;
59
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 };
60
+ if (w.active === 0) return { count: 0, oldest_at: null, items: [] };
61
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() };
62
+ // BOT-3223 AC-1: one badge per wait (an older BB sends none: the band falls back to the count).
63
+ const items = (Array.isArray(w.items) ? w.items : [])
64
+ .filter((i) => UUID_LOWER.test(String(i?.id || "").toLowerCase()) && Number.isFinite(Date.parse(i?.created_at)) && safeText(i?.label))
65
+ .slice(0, 5)
66
+ .map((i) => ({ id: i.id.toLowerCase(), label: safeText(i.label).slice(0, 40), created_at: new Date(i.created_at).toISOString() }));
67
+ return { count: w.active, oldest_at: new Date(w.oldest_at).toISOString(), items };
63
68
  }
64
69
  function refuse(code, extra = {}) {
65
70
  throw Object.assign(new Error(code), extra);
@@ -346,7 +351,14 @@ export async function readStatus({
346
351
  const fromBb = (k) => {
347
352
  if (useSession) {
348
353
  const t = own.tickets.find((x) => String(x?.key || "").toUpperCase() === k);
349
- return t ? { title: t.title, status: STATUS[t.state_type] || (typeof t.state === "string" ? t.state : null) } : null;
354
+ return t
355
+ ? {
356
+ title: t.title,
357
+ status: STATUS[t.state_type] || (typeof t.state === "string" ? t.state : null),
358
+ // BOT-3223: undefined from an older BB (unknown), null for no project.
359
+ project: t.project_linear_id === undefined ? undefined : UUID_LOWER.test(t.project_linear_id || "") ? t.project_linear_id : null,
360
+ }
361
+ : null;
350
362
  }
351
363
  const item = workItems.find((w) => w?.kind === "ticket" && w.ticket === k);
352
364
  if (item) return { title: item.title, status: STATUS[item.stage] };
@@ -356,14 +368,24 @@ export async function readStatus({
356
368
  }
357
369
  return null;
358
370
  };
371
+ // BOT-3223 AC-2: the ticket's Linear project, so the band nests it under its
372
+ // epic. The session path reads it from BB; the branch path from the epic list.
373
+ const projectOf = (k) => {
374
+ if (useSession) return fromBb(k)?.project;
375
+ const e = epics.find((x) => UUID_LOWER.test(x?.epic_project_id) && (x.children || []).some((c) => c?.external_id === k));
376
+ return e ? e.epic_project_id : Array.isArray(epicHealth?.epics) ? null : undefined;
377
+ };
359
378
  const tickets = keys.map((k) => {
379
+ const project = projectOf(k);
380
+ const where = project === undefined ? {} : { project };
360
381
  if (linearTicket && k === key)
361
- return { key: k, title: linearTicket.title, status: linearTicket.status };
382
+ return { key: k, title: linearTicket.title, status: linearTicket.status, ...where };
362
383
  const found = fromBb(k);
363
384
  return {
364
385
  key: k,
365
386
  title: found ? safeText(found.title) || "Not in BB yet" : "Not in BB yet",
366
387
  status: found?.status || "Unknown",
388
+ ...where,
367
389
  };
368
390
  });
369
391
  // PRs whose head is this worktree's branch, or whose title or branch names
@@ -371,6 +393,12 @@ export async function readStatus({
371
393
  const keyRes = keys.map((k) => new RegExp(`(?:^|[^A-Za-z0-9])${k}(?![0-9])`, "i"));
372
394
  const mentions = (p) =>
373
395
  keyRes.some((re) => re.test(String(p?.title || "")) || re.test(String(p?.headRefName || "")));
396
+ // BOT-3223 AC-2: the first of the session's tickets, in session order, that a
397
+ // PR's branch or title names; null when none does.
398
+ const ticketOf = (title, head) => {
399
+ const i = keyRes.findIndex((re) => re.test(String(head || "")) || re.test(String(title || "")));
400
+ return i < 0 ? null : keys[i];
401
+ };
374
402
  // Newest first as BB returns them.
375
403
  const prs = useSession
376
404
  ? (Array.isArray(own.prs) ? own.prs : [])
@@ -384,6 +412,7 @@ export async function readStatus({
384
412
  conflict: false,
385
413
  // BOT-3152 AC-3: pr_state.review_rounds, the column get_pr_state returns as reviewRounds.
386
414
  reviews: reviewCount(p.review_rounds),
415
+ ticket: ticketOf(p.title, p.head_ref),
387
416
  }))
388
417
  : Array.isArray(prState?.prs)
389
418
  ? prState.prs
@@ -397,6 +426,7 @@ export async function readStatus({
397
426
  state: p.state === "draft" || (p.isDraft && p.state === "open") ? "draft" : ["open", "merged", "closed"].includes(p.state) ? p.state : "open",
398
427
  conflict: p.mergeable === "CONFLICTING",
399
428
  reviews: reviewCount(p.reviewRounds),
429
+ ticket: ticketOf(p.title, p.headRefName),
400
430
  }))
401
431
  : null;
402
432
  // Always one epic: the project of the first ticket, in session order, that