@botbuddy/cli 1.71.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 +9 -0
- package/claude-plugin/.claude-plugin/marketplace.json +7 -1
- package/claude-plugin/bb-session/.claude-plugin/plugin.json +9 -0
- package/claude-plugin/bb-session/hooks/hooks.json +15 -0
- package/claude-plugin/bb-session/hooks/session-start.mjs +150 -0
- package/claude-plugin/bb-status/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/bb-status/README.md +13 -0
- package/claude-plugin/bb-status/hooks/register.js +186 -110
- package/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +5 -2
- package/src/status-band-read.mjs +34 -4
- package/src/status-band.mjs +76 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
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
|
+
|
|
7
|
+
## 1.72.0
|
|
8
|
+
|
|
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.
|
|
10
|
+
|
|
3
11
|
## 1.71.0
|
|
4
12
|
|
|
5
13
|
- `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.
|
|
14
|
+
|
|
6
15
|
## 1.69.8
|
|
7
16
|
|
|
8
17
|
- 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.
|
|
@@ -11,7 +11,13 @@
|
|
|
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.
|
|
14
|
+
"version": "1.4.0"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "bb-session",
|
|
18
|
+
"source": "./bb-session",
|
|
19
|
+
"description": "Registers each Claude Code session with BotBuddy at start-up, with the ticket from the branch, in every BB-bound repo (BOT-3222)",
|
|
20
|
+
"version": "1.0.0"
|
|
15
21
|
}
|
|
16
22
|
]
|
|
17
23
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bb-session",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Registers each Claude Code session with BotBuddy at start-up, with the ticket from the branch, in every repo bound to a BB tenant. No UI.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "BotBuddy"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT"
|
|
9
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// BOT-3222 — the bb-session plugin's SessionStart command hook.
|
|
2
|
+
//
|
|
3
|
+
// Registers THIS Claude Code session with BotBuddy before the first prompt, in
|
|
4
|
+
// every repo bound to a BB tenant (a `.botbuddy-agent.json` at the worktree
|
|
5
|
+
// root), whether or not the repo ships its own hook or the bb-status band is
|
|
6
|
+
// installed or rendered. It runs
|
|
7
|
+
//
|
|
8
|
+
// bb bootstrap --session-id <harness id> --type claude [--branch <b>]
|
|
9
|
+
// (--ticket-id <BOT-N|ENT-N> | --no-ticket-reason <why>)
|
|
10
|
+
//
|
|
11
|
+
// with the ticket from the branch. A ticket is sent only with Claude Desktop's
|
|
12
|
+
// native `local_<uuid>` identity (BOT-2457); without one the session registers
|
|
13
|
+
// ticketless rather than being refused. Mirrors botbuddy-web's
|
|
14
|
+
// `.claude/hooks/session-start.sh` local path: the harness id is exported to the
|
|
15
|
+
// session's shells first (BOT-2425), then the BB session id, and the model gets
|
|
16
|
+
// its BB identity and any ticket-session warning (BOT-2058) as context.
|
|
17
|
+
//
|
|
18
|
+
// Never blocks the session: every failure exits 0 with one stderr line, and the
|
|
19
|
+
// bootstrap is killed after DEFAULT_TIMEOUT_MS. The band's own bootstrap
|
|
20
|
+
// (status-band-read.mjs) is the fallback for a session this hook missed.
|
|
21
|
+
// Secrets never pass through here: bb reads its own credentials, and only the
|
|
22
|
+
// public session id is exported.
|
|
23
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
24
|
+
import { appendFileSync, existsSync } from "node:fs";
|
|
25
|
+
import { join, resolve } from "node:path";
|
|
26
|
+
import { pathToFileURL } from "node:url";
|
|
27
|
+
|
|
28
|
+
const DEFAULT_TIMEOUT_MS = 20_000;
|
|
29
|
+
const HARNESS_ID = /^[A-Za-z0-9-]{8,64}$/;
|
|
30
|
+
const DESKTOP_ID = /^local_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
31
|
+
const TICKET = /(?:^|\/)((?:bot|ent)-[0-9]+)/i;
|
|
32
|
+
|
|
33
|
+
const note = (line) => {
|
|
34
|
+
try {
|
|
35
|
+
process.stderr.write(`bb-session: ${line}\n`);
|
|
36
|
+
} catch { /* ignore */ }
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function exportLine(env, name, value) {
|
|
40
|
+
if (!env.CLAUDE_ENV_FILE) return;
|
|
41
|
+
try {
|
|
42
|
+
appendFileSync(env.CLAUDE_ENV_FILE, `export ${name}=${value}\n`);
|
|
43
|
+
} catch { /* a failed write stays silent, as in the repo hook */ }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function git(cwd, args) {
|
|
47
|
+
const res = spawnSync("git", ["-C", cwd, ...args], { encoding: "utf8", timeout: 5000 });
|
|
48
|
+
return res.status === 0 ? res.stdout.trim() : "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function readStdin() {
|
|
52
|
+
let s = "";
|
|
53
|
+
for await (const chunk of process.stdin) s += chunk;
|
|
54
|
+
return s;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function runBootstrap(argv, { cwd, env, timeoutMs }) {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
let out = "";
|
|
60
|
+
let err = "";
|
|
61
|
+
let child;
|
|
62
|
+
try {
|
|
63
|
+
child = spawn("bb", argv, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
|
|
64
|
+
} catch (error) {
|
|
65
|
+
resolve({ error });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const timer = setTimeout(() => {
|
|
69
|
+
child.kill("SIGKILL");
|
|
70
|
+
resolve({ timedOut: true });
|
|
71
|
+
}, timeoutMs);
|
|
72
|
+
child.stdout.on("data", (d) => (out += d));
|
|
73
|
+
child.stderr.on("data", (d) => (err += d));
|
|
74
|
+
child.on("error", (error) => {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
resolve({ error });
|
|
77
|
+
});
|
|
78
|
+
child.on("close", (code) => {
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
resolve({ code, out, err });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function main({ env = process.env, cwd = process.cwd(), input } = {}) {
|
|
86
|
+
if (env.BOTBUDDY_SESSION_HOOK === "0") return;
|
|
87
|
+
let sessionId = "";
|
|
88
|
+
try {
|
|
89
|
+
sessionId = JSON.parse(input ?? (await readStdin())).session_id;
|
|
90
|
+
} catch { /* not JSON: nothing to register */ }
|
|
91
|
+
if (typeof sessionId !== "string" || !HARNESS_ID.test(sessionId)) return;
|
|
92
|
+
|
|
93
|
+
const project = env.CLAUDE_PROJECT_DIR || cwd;
|
|
94
|
+
const root = git(project, ["rev-parse", "--show-toplevel"]);
|
|
95
|
+
if (!root || !existsSync(join(root, ".botbuddy-agent.json"))) return;
|
|
96
|
+
|
|
97
|
+
// BOT-2425: the harness id is the session-lifetime identity key. Export it
|
|
98
|
+
// before bootstrapping so a later CLI mint re-binds even if this one fails.
|
|
99
|
+
exportLine(env, "BOTBUDDY_HARNESS_SESSION_ID", sessionId);
|
|
100
|
+
|
|
101
|
+
const branch = git(root, ["symbolic-ref", "--short", "-q", "HEAD"]);
|
|
102
|
+
const ticket = branch.match(TICKET)?.[1]?.toUpperCase() ?? null;
|
|
103
|
+
const desktop = DESKTOP_ID.test(env.CLAUDE_CODE_HOST_SESSION_ID ?? "");
|
|
104
|
+
const argv = ["bootstrap", "--session-id", sessionId, "--type", "claude", ...(branch ? ["--branch", branch] : [])];
|
|
105
|
+
if (ticket && desktop) argv.push("--ticket-id", ticket);
|
|
106
|
+
else if (ticket) argv.push("--no-ticket-reason", `branch names ${ticket} but this Claude session has no Claude Desktop session id (terminal or cloud)`);
|
|
107
|
+
else argv.push("--no-ticket-reason", "Claude Code session on a branch without a BOT-N or ENT-N key");
|
|
108
|
+
|
|
109
|
+
const timeoutMs = Number(env.BB_SESSION_HOOK_TIMEOUT_MS) > 0 ? Number(env.BB_SESSION_HOOK_TIMEOUT_MS) : DEFAULT_TIMEOUT_MS;
|
|
110
|
+
const res = await runBootstrap(argv, { cwd: root, env, timeoutMs });
|
|
111
|
+
const fallback = "the bb-status band will register this session when it renders.";
|
|
112
|
+
if (res.error?.code === "ENOENT") return note(`BotBuddy registration skipped: no bb command on PATH; ${fallback}`);
|
|
113
|
+
if (res.error) return note(`BotBuddy registration failed (${res.error.message}); ${fallback}`);
|
|
114
|
+
if (res.timedOut) return note(`BotBuddy registration failed (bb bootstrap timed out after ${timeoutMs / 1000} s); ${fallback}`);
|
|
115
|
+
if (res.code !== 0) {
|
|
116
|
+
// The error is bb's first stderr line; a feedback hint may follow it.
|
|
117
|
+
const why = res.err.trim().split("\n")[0]?.slice(0, 200) || "no output";
|
|
118
|
+
return note(`BotBuddy registration failed (bb bootstrap exited ${res.code}: ${why}); ${fallback}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let receipt = {};
|
|
122
|
+
try {
|
|
123
|
+
receipt = JSON.parse(res.out.trim().split("\n").pop()) || {};
|
|
124
|
+
} catch { /* an unreadable receipt still registered the session */ }
|
|
125
|
+
if (typeof receipt.session_id === "string" && HARNESS_ID.test(receipt.session_id)) exportLine(env, "BOTBUDDY_SESSION_ID", receipt.session_id);
|
|
126
|
+
exportLine(env, "BOTBUDDY_CALLER_HARNESS", "claude-code");
|
|
127
|
+
|
|
128
|
+
// BOT-2425: hand the model this session's BB identity so its MCP
|
|
129
|
+
// register_agent re-binds to the SAME agent instead of minting a second one.
|
|
130
|
+
const parts = [];
|
|
131
|
+
if (typeof receipt.agent_id === "string" && /^[0-9a-f-]{36}$/i.test(receipt.agent_id)) {
|
|
132
|
+
const name = typeof receipt.display_name === "string" && receipt.display_name ? receipt.display_name : "this session";
|
|
133
|
+
parts.push(
|
|
134
|
+
`BotBuddy identity for this whole session: ${name} (agent_id ${receipt.agent_id}, harness_session_id ${sessionId}). ` +
|
|
135
|
+
`When you call the BotBuddy MCP register_agent, pass agent_id "${receipt.agent_id}" and harness_session_id "${sessionId}" so the MCP connection binds to this same agent; ` +
|
|
136
|
+
"re-run it the same way after an MCP reconnect. Subagents must not pass these values.",
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
const warning = receipt.ticket_session_warning?.warning;
|
|
140
|
+
if (typeof warning === "string" && warning) parts.push(`BotBuddy ticket-session warning: ${warning}`);
|
|
141
|
+
if (parts.length) process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: parts.join("\n") } }));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Exit 0 whatever happens; let the event loop drain (never process.exit) so a
|
|
145
|
+
// pipe write to Claude Code is flushed (macOS pipes are asynchronous in Node).
|
|
146
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
147
|
+
main()
|
|
148
|
+
.catch((error) => note(`BotBuddy registration failed (${error?.message ?? error}); the bb-status band will register this session when it renders.`))
|
|
149
|
+
.finally(() => { process.exitCode = 0; });
|
|
150
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bb-status",
|
|
3
|
-
"version": "1.
|
|
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) =>
|
|
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: {
|
|
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
|
-
|
|
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
|
|
720
|
-
// status columns take the widest
|
|
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
|
-
//
|
|
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
|
-
//
|
|
756
|
+
// Badge: one cell of padding each side, the icon (2 cells), then the parts.
|
|
728
757
|
function statusWidth(spec) {
|
|
729
|
-
|
|
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
|
-
|
|
739
|
-
|
|
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:
|
|
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
|
-
//
|
|
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
|
-
|
|
786
|
-
|
|
852
|
+
const alarm = contextAlarm(context);
|
|
853
|
+
if (alarm)
|
|
787
854
|
children.push(
|
|
788
|
-
|
|
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
|
-
|
|
793
|
-
|
|
794
|
-
|
|
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
|
-
//
|
|
856
|
-
|
|
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
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
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
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
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
|
-
|
|
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-
|
|
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.
|
|
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) {
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.73.0",
|
|
3
|
+
"source_commit": "6b876cc1b10ca1c5c7b088ea4e9afed3cad244bc",
|
|
4
|
+
"source_sha256": "9505b68bc947e163a7415f881062303ff6e210b872c8928725152ab3e921b5ec",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "501fb0b34089c732ef076d5426184205d468ceef5a0d394defc2516c5c820513"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.73.0",
|
|
3
|
+
"source_commit": "6b876cc1b10ca1c5c7b088ea4e9afed3cad244bc",
|
|
4
|
+
"source_sha256": "9505b68bc947e163a7415f881062303ff6e210b872c8928725152ab3e921b5ec",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "e12c6d215cda4a772a12d97f10e59c504768ccb74bf9d1b8bb0ddb4ac66ffa48"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
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": "
|
|
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": "
|
|
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.
|
|
3
|
+
"version": "1.73.0",
|
|
4
4
|
"description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
"claude-plugin/bb-status/.claude-plugin/",
|
|
26
26
|
"claude-plugin/bb-status/hooks/hooks.json",
|
|
27
27
|
"claude-plugin/bb-status/hooks/register.js",
|
|
28
|
-
"claude-plugin/bb-status/README.md"
|
|
28
|
+
"claude-plugin/bb-status/README.md",
|
|
29
|
+
"claude-plugin/bb-session/.claude-plugin/",
|
|
30
|
+
"claude-plugin/bb-session/hooks/hooks.json",
|
|
31
|
+
"claude-plugin/bb-session/hooks/session-start.mjs"
|
|
29
32
|
],
|
|
30
33
|
"keywords": [
|
|
31
34
|
"mcp",
|
package/src/status-band-read.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
package/src/status-band.mjs
CHANGED
|
@@ -16,7 +16,10 @@ import { promisify } from "node:util";
|
|
|
16
16
|
|
|
17
17
|
export const MARKETPLACE = "botbuddy-labs";
|
|
18
18
|
export const PLUGIN = "bb-status";
|
|
19
|
-
|
|
19
|
+
// BOT-3222: the SessionStart hook that registers every session with BB lives in
|
|
20
|
+
// its own plugin, so a tenant can disable the band and keep registration.
|
|
21
|
+
export const SESSION_PLUGIN = "bb-session";
|
|
22
|
+
export const PLUGINS = [PLUGIN, SESSION_PLUGIN];
|
|
20
23
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
21
24
|
export const PACKAGE_ROOT = resolve(HERE, "..");
|
|
22
25
|
export const MARKETPLACE_DIR = join(PACKAGE_ROOT, "claude-plugin");
|
|
@@ -28,8 +31,9 @@ const HELP = `bb status-band <read|relay|install>
|
|
|
28
31
|
relay --cond <condition>… [--since <cursor>]
|
|
29
32
|
Arm one bb wait on the band's subjects and print how it ended.
|
|
30
33
|
install
|
|
31
|
-
Install the bb-status band
|
|
32
|
-
|
|
34
|
+
Install the bb-status band and the bb-session start-up registration hook
|
|
35
|
+
into Claude Code once, at user scope, from this installed CLI package.
|
|
36
|
+
bb setup and bb update run it for you.`;
|
|
33
37
|
|
|
34
38
|
export async function cmdStatusBand(args, { log = (l) => console.log(l), out = process.stdout } = {}) {
|
|
35
39
|
const [sub, ...rest] = args;
|
|
@@ -44,7 +48,7 @@ export async function cmdStatusBand(args, { log = (l) => console.log(l), out = p
|
|
|
44
48
|
if (sub === "install") {
|
|
45
49
|
const result = await installStatusBand();
|
|
46
50
|
log(statusBandLine(result));
|
|
47
|
-
return result.status === "failed" ? 1 : 0;
|
|
51
|
+
return result.status === "failed" || result.session?.status === "failed" ? 1 : 0;
|
|
48
52
|
}
|
|
49
53
|
log(HELP);
|
|
50
54
|
return sub === undefined || sub === "--help" || sub === "-h" || sub === "help" ? 0 : 2;
|
|
@@ -61,14 +65,34 @@ async function claudeJson(run, args) {
|
|
|
61
65
|
return JSON.parse(stdout);
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
function commandFailure(error) {
|
|
69
|
+
const detail = String(error?.stderr || error?.message || error).trim().split("\n")[0].slice(0, 200);
|
|
70
|
+
return { status: "failed", reason: "claude_plugin_command_failed", detail };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Install or update one plugin from the (already refreshed) marketplace.
|
|
74
|
+
async function installOne({ run, name, shipped, installed, repointed }) {
|
|
75
|
+
const id = `${name}@${MARKETPLACE}`;
|
|
76
|
+
const mine = Array.isArray(installed) ? installed.find((p) => p?.id === id && p?.scope === "user") : null;
|
|
77
|
+
if (mine && mine.version === shipped && mine.enabled !== false && !repointed) return { status: "unchanged", version: shipped };
|
|
78
|
+
if (mine && !repointed) await run(["plugin", "update", id, "--scope", "user"]);
|
|
79
|
+
else await run(["plugin", "install", id, "--scope", "user"]);
|
|
80
|
+
// The band's own disabled state is re-enabled as before (BOT-3152); bb-session
|
|
81
|
+
// is left disabled if the operator disabled it.
|
|
82
|
+
if (mine && mine.enabled === false && name === PLUGIN) await run(["plugin", "enable", id, "--scope", "user"]);
|
|
83
|
+
return { status: mine && !repointed ? "updated" : "installed", version: shipped };
|
|
84
|
+
}
|
|
85
|
+
|
|
64
86
|
/**
|
|
65
87
|
* Point `botbuddy-labs` at this package's plugin folder and install `bb-status`
|
|
66
|
-
* at user scope. Idempotent; never throws. Returns
|
|
67
|
-
* installed | updated | unchanged | skipped | failed
|
|
88
|
+
* (and, BOT-3222, `bb-session`) at user scope. Idempotent; never throws. Returns
|
|
89
|
+
* the band's { status, … } (installed | updated | unchanged | skipped | failed)
|
|
90
|
+
* with `session: { status, … }` for bb-session when it is in `plugins`.
|
|
68
91
|
*/
|
|
69
92
|
export async function installStatusBand({
|
|
70
93
|
marketplaceDir = MARKETPLACE_DIR,
|
|
71
94
|
packageRoot = PACKAGE_ROOT,
|
|
95
|
+
plugins: wanted = PLUGINS,
|
|
72
96
|
claude = "claude",
|
|
73
97
|
execFileImpl = promisify(nodeExecFile),
|
|
74
98
|
readJson = async (p) => JSON.parse(await readFile(p, "utf8")),
|
|
@@ -80,35 +104,63 @@ export async function installStatusBand({
|
|
|
80
104
|
} catch {
|
|
81
105
|
return { status: "skipped", reason: "claude_missing" };
|
|
82
106
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
const shipped = {};
|
|
108
|
+
for (const name of wanted) {
|
|
109
|
+
try {
|
|
110
|
+
shipped[name] = (await readJson(join(marketplaceDir, name, ".claude-plugin", "plugin.json"))).version;
|
|
111
|
+
} catch {
|
|
112
|
+
if (name === PLUGIN) return { status: "failed", reason: "plugin_missing_from_package" };
|
|
113
|
+
}
|
|
88
114
|
}
|
|
115
|
+
let current;
|
|
116
|
+
let repointed;
|
|
117
|
+
let installed;
|
|
89
118
|
try {
|
|
90
119
|
const markets = await claudeJson(run, ["marketplace", "list"]);
|
|
91
|
-
|
|
92
|
-
|
|
120
|
+
current = Array.isArray(markets) ? markets.find((m) => m?.name === MARKETPLACE) : null;
|
|
121
|
+
repointed = Boolean(current) && resolve(String(current.path ?? "")) !== resolve(marketplaceDir);
|
|
93
122
|
if (repointed) await run(["plugin", "marketplace", "remove", MARKETPLACE]);
|
|
94
123
|
if (!current || repointed) await run(["plugin", "marketplace", "add", marketplaceDir, "--scope", "user"]);
|
|
95
124
|
else await run(["plugin", "marketplace", "update", MARKETPLACE]);
|
|
96
|
-
|
|
97
|
-
const mine = Array.isArray(plugins) ? plugins.find((p) => p?.id === PLUGIN_ID && p?.scope === "user") : null;
|
|
98
|
-
if (mine && mine.version === shipped && mine.enabled !== false && !repointed) {
|
|
99
|
-
return { status: "unchanged", version: shipped };
|
|
100
|
-
}
|
|
101
|
-
if (mine && !repointed) await run(["plugin", "update", PLUGIN_ID, "--scope", "user"]);
|
|
102
|
-
else await run(["plugin", "install", PLUGIN_ID, "--scope", "user"]);
|
|
103
|
-
if (mine && mine.enabled === false) await run(["plugin", "enable", PLUGIN_ID, "--scope", "user"]);
|
|
104
|
-
return { status: mine && !repointed ? "updated" : "installed", version: shipped, ...(repointed ? { replaced: String(current.path ?? "") } : {}) };
|
|
125
|
+
installed = await claudeJson(run, ["list"]);
|
|
105
126
|
} catch (error) {
|
|
106
|
-
|
|
107
|
-
return { status: "failed", reason: "claude_plugin_command_failed", detail };
|
|
127
|
+
return commandFailure(error);
|
|
108
128
|
}
|
|
129
|
+
const one = async (name) => {
|
|
130
|
+
if (!(name in shipped)) return { status: "failed", reason: "plugin_missing_from_package" };
|
|
131
|
+
try {
|
|
132
|
+
return await installOne({ run, name, shipped: shipped[name], installed, repointed });
|
|
133
|
+
} catch (error) {
|
|
134
|
+
return commandFailure(error);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
// Each plugin installs on its own: a refused band install never stops
|
|
138
|
+
// start-up registration, and the reverse.
|
|
139
|
+
const band = wanted.includes(PLUGIN) ? await one(PLUGIN) : { status: "skipped", reason: "not_requested" };
|
|
140
|
+
const result = { ...band, ...(band.status !== "failed" && repointed ? { replaced: String(current.path ?? "") } : {}) };
|
|
141
|
+
if (wanted.includes(SESSION_PLUGIN)) result.session = await one(SESSION_PLUGIN);
|
|
142
|
+
return result;
|
|
109
143
|
}
|
|
110
144
|
|
|
111
145
|
export function statusBandLine(result) {
|
|
146
|
+
const band = bandLine(result);
|
|
147
|
+
return result?.session ? `${band} ${sessionLine(result.session)}` : band;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function sessionLine(s) {
|
|
151
|
+
switch (s?.status) {
|
|
152
|
+
case "installed":
|
|
153
|
+
return `bb-session start-up registration installed in Claude Code (user scope, v${s.version}); new sessions register with BB.`;
|
|
154
|
+
case "updated":
|
|
155
|
+
return `bb-session start-up registration updated to v${s.version}.`;
|
|
156
|
+
case "unchanged":
|
|
157
|
+
return `bb-session start-up registration already installed (v${s.version}).`;
|
|
158
|
+
default:
|
|
159
|
+
return `bb-session could not be installed (${s?.reason ?? "unknown"}${s?.detail ? `: ${s.detail}` : ""}); run bb status-band install to retry.`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function bandLine(result) {
|
|
112
164
|
switch (result?.status) {
|
|
113
165
|
case "installed":
|
|
114
166
|
return `bb-status band installed in Claude Code (user scope, v${result.version}); new sessions show it. Run /reload-plugins in open ones.`;
|