@botbuddy/cli 1.70.0 → 1.72.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 +8 -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/hooks/register.js +68 -28
- 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/commands.mjs +19 -5
- package/src/session-bootstrap.mjs +3 -0
- package/src/status-band-read.mjs +36 -12
- package/src/status-band.mjs +76 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.72.0
|
|
4
|
+
|
|
5
|
+
- `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.
|
|
6
|
+
|
|
7
|
+
## 1.71.0
|
|
8
|
+
|
|
9
|
+
- `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.
|
|
10
|
+
|
|
3
11
|
## 1.69.8
|
|
4
12
|
|
|
5
13
|
- 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.3.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.3.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"
|
|
@@ -31,6 +31,8 @@ let unbound = false;
|
|
|
31
31
|
// with the free `$.session.usage()` and then only from `session.measure`,
|
|
32
32
|
// which the engine pushes after each main-thread turn: never polled.
|
|
33
33
|
let context = null;
|
|
34
|
+
// BOT-3213: the tenant's ticket prefix the adapter named with ticket_missing.
|
|
35
|
+
let hintPrefix = null;
|
|
34
36
|
// BOT-3212: the waits badge pulses once, for PULSE_MS, when the count changes.
|
|
35
37
|
const PULSE_MS = 2000;
|
|
36
38
|
let pulsing = false;
|
|
@@ -59,7 +61,7 @@ const ERRORS = {
|
|
|
59
61
|
agent_mismatch:
|
|
60
62
|
"BB returned a different agent. Reconnect BB for this session.",
|
|
61
63
|
worktree_mismatch: "BB identity belongs to a different worktree.",
|
|
62
|
-
ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live
|
|
64
|
+
ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live <KEY>, or register as coordinator: bb bootstrap --project-id P-….",
|
|
63
65
|
ticket_scope_mismatch: "Linear issue or workspace does not match BotBuddy.",
|
|
64
66
|
blockers_incomplete: "Blocker list is incomplete. Status is unknown.",
|
|
65
67
|
source_unauthorized:
|
|
@@ -70,6 +72,12 @@ const ERRORS = {
|
|
|
70
72
|
cli_outdated: "Update the bb CLI (bb update) to use this band.",
|
|
71
73
|
};
|
|
72
74
|
function errorText() {
|
|
75
|
+
// BOT-3213 AC-4: the hint speaks in the tenant's own prefix when it is known.
|
|
76
|
+
if (errorCode === "ticket_missing" && hintPrefix)
|
|
77
|
+
return (
|
|
78
|
+
"Use a ticket branch (" + hintPrefix.toLowerCase() + "-…) or /bb-status live " + hintPrefix +
|
|
79
|
+
"-123, or register as coordinator: bb bootstrap --project-id P-" + hintPrefix + "-…."
|
|
80
|
+
);
|
|
73
81
|
return (
|
|
74
82
|
ERRORS[errorCode] ||
|
|
75
83
|
"Status unavailable. Check BB and Linear connections, then refresh."
|
|
@@ -109,6 +117,18 @@ const PR_STATES = ["open", "draft", "merged", "closed"];
|
|
|
109
117
|
const LINEAR_PROJECT_URL = /^https:\/\/linear\.app\/[a-z0-9-]{1,64}\/project\/[a-z0-9-]{1,200}$/;
|
|
110
118
|
const PROJECT_IDENTIFIER = /^P-[A-Z][A-Z0-9]{1,9}-[1-9]\d{0,5}$/;
|
|
111
119
|
const PROJECT_STATES = ["backlog", "planned", "started", "paused", "completed", "canceled"];
|
|
120
|
+
// BOT-3213: a coordinator project's tickets by state; the four add up to total.
|
|
121
|
+
const COUNT_KEYS = ["done", "in_progress", "blocked", "todo"];
|
|
122
|
+
function validCounts(c) {
|
|
123
|
+
return (
|
|
124
|
+
!!c &&
|
|
125
|
+
[...COUNT_KEYS, "total"].every((k) => Number.isSafeInteger(c[k]) && c[k] >= 0 && c[k] <= 100000) &&
|
|
126
|
+
COUNT_KEYS.reduce((n, k) => n + c[k], 0) === c.total
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function countsText(c) {
|
|
130
|
+
return [c.done + " done", c.in_progress + " in progress", c.blocked + " blocked", c.todo + " todo"].join(" · ");
|
|
131
|
+
}
|
|
112
132
|
function validSnapshot(value, harness, now) {
|
|
113
133
|
const prefix = TENANT_PREFIX[value?.tenant];
|
|
114
134
|
const ownKey = (k) => KEY.test(k) && k.startsWith(prefix + "-");
|
|
@@ -122,15 +142,17 @@ function validSnapshot(value, harness, now) {
|
|
|
122
142
|
!safeLabel(value.agent?.name, 100) ||
|
|
123
143
|
!safeLabel(value.branch) ||
|
|
124
144
|
!Array.isArray(value.tickets) ||
|
|
125
|
-
value.tickets.length < 1 ||
|
|
126
145
|
value.tickets.length > 5 ||
|
|
127
146
|
!value.tickets.every(
|
|
128
147
|
(t) => ownKey(t?.key) && safeLabel(t.title) && safeLabel(t.status, 40),
|
|
129
148
|
) ||
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
// BOT-3213: only a coordinator's project binding may carry no ticket.
|
|
150
|
+
(value.tickets.length === 0
|
|
151
|
+
? !(value.binding === "project" && value.ticket === null && value.epic?.role === "coordinator")
|
|
152
|
+
: value.ticket?.key !== value.tickets[0].key ||
|
|
153
|
+
!safeLabel(value.ticket.title) ||
|
|
154
|
+
!safeLabel(value.ticket.status, 40) ||
|
|
155
|
+
(value.ticket.url !== null && !safeLink(value.ticket.url, value.ticket.key))) ||
|
|
134
156
|
(value.prs !== null &&
|
|
135
157
|
!(
|
|
136
158
|
Array.isArray(value.prs) &&
|
|
@@ -158,7 +180,9 @@ function validSnapshot(value, harness, now) {
|
|
|
158
180
|
(value.epic.identifier == null || PROJECT_IDENTIFIER.test(value.epic.identifier)) &&
|
|
159
181
|
Number.isSafeInteger(value.epic.percent) &&
|
|
160
182
|
value.epic.percent >= 0 &&
|
|
161
|
-
value.epic.percent <= 100
|
|
183
|
+
value.epic.percent <= 100 &&
|
|
184
|
+
(value.epic.role === undefined || value.epic.role === "coordinator") &&
|
|
185
|
+
(value.epic.counts === undefined || validCounts(value.epic.counts))
|
|
162
186
|
)) ||
|
|
163
187
|
(value.blockers !== null &&
|
|
164
188
|
!(value.tenant === "botbuddy" && Array.isArray(value.blockers) && value.blockers.length <= 100)) ||
|
|
@@ -312,10 +336,12 @@ async function refresh($, { wake = false, keep = false } = {}) {
|
|
|
312
336
|
snapshot = null;
|
|
313
337
|
return;
|
|
314
338
|
}
|
|
315
|
-
if (result.exitCode !== 0)
|
|
339
|
+
if (result.exitCode !== 0) {
|
|
340
|
+
hintPrefix = data?.error === "ticket_missing" && /^[A-Z]{2,10}$/.test(data.prefix ?? "") ? data.prefix : null;
|
|
316
341
|
throw new Error(
|
|
317
342
|
typeof data.error === "string" ? data.error : "source_unavailable",
|
|
318
343
|
);
|
|
344
|
+
}
|
|
319
345
|
currentTime = await $.clock.now();
|
|
320
346
|
if (request !== generation) return;
|
|
321
347
|
if (previous && data && data.epic_skipped === true) data = keepKnown(data, previous);
|
|
@@ -340,6 +366,7 @@ async function refresh($, { wake = false, keep = false } = {}) {
|
|
|
340
366
|
});
|
|
341
367
|
}
|
|
342
368
|
snapshot = data;
|
|
369
|
+
hintPrefix = TENANT_PREFIX[data.tenant] || null;
|
|
343
370
|
relayFault = null;
|
|
344
371
|
if (!wake) startRelay($);
|
|
345
372
|
}
|
|
@@ -379,7 +406,7 @@ function waitConditions(s) {
|
|
|
379
406
|
conds.push("pr-state:repo=" + p.repo + ",pr=" + p.number);
|
|
380
407
|
// Blockers are read for the primary ticket only, and an `unblocked:` wait on
|
|
381
408
|
// a ticket that is not blocked is granted at once: never arm it for others.
|
|
382
|
-
if (s.tenant === "botbuddy" && s.blockers && s.blockers.length > 0)
|
|
409
|
+
if (s.tenant === "botbuddy" && s.ticket && s.blockers && s.blockers.length > 0)
|
|
383
410
|
conds.push("unblocked:" + s.ticket.key);
|
|
384
411
|
// BOT-3136 AC-1: the epic row wakes on its Linear project's progress.
|
|
385
412
|
if (s.epic && UUID.test(s.epic.id))
|
|
@@ -502,7 +529,7 @@ function startRelay($) {
|
|
|
502
529
|
// (BB's work list covers 3 days); keep what the last full read knew.
|
|
503
530
|
function keepKnown(data, previous) {
|
|
504
531
|
const { epic_skipped, ...rest } = data;
|
|
505
|
-
const samePrimary = previous.tenant === data.tenant && previous.ticket
|
|
532
|
+
const samePrimary = previous.tenant === data.tenant && previous.ticket?.key === data.ticket?.key;
|
|
506
533
|
const known = new Map(previous.tickets.map((t) => [t.key, t]));
|
|
507
534
|
return {
|
|
508
535
|
...rest,
|
|
@@ -884,7 +911,10 @@ function bandLines(el, $, inPane) {
|
|
|
884
911
|
],
|
|
885
912
|
icon: lead(el, "◇", epicHex(s.epic.state), "epic " + s.epic.state + " " + s.epic.percent + "%", epicIcon(s.epic.state, s.epic.percent)),
|
|
886
913
|
status: [{ text: s.epic.percent + "% done", color: epicHex(s.epic.state) }],
|
|
887
|
-
|
|
914
|
+
// BOT-3213: the project a coordinator session runs, with its tickets by state.
|
|
915
|
+
title: s.epic.role === "coordinator"
|
|
916
|
+
? "Coordinating · " + (s.epic.counts ? countsText(s.epic.counts) + " · " : "") + s.epic.name
|
|
917
|
+
: s.epic.name,
|
|
888
918
|
});
|
|
889
919
|
else if (s.epic_unreadable)
|
|
890
920
|
specs.push({ key: k("line-epic"), ids: [], icon: el.Text({ color: "warning", children: ["◇ "] }), status: [], title: UNREAD.epic, dim: true });
|
|
@@ -1033,17 +1063,26 @@ export function register(on) {
|
|
|
1033
1063
|
else {
|
|
1034
1064
|
children.push(
|
|
1035
1065
|
Text({ bold: true, children: [snapshot.agent.name] }),
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1066
|
+
...(snapshot.ticket
|
|
1067
|
+
? [
|
|
1068
|
+
Text({
|
|
1069
|
+
children: [snapshot.ticket.key + " · " + snapshot.ticket.title],
|
|
1070
|
+
}),
|
|
1071
|
+
Text({
|
|
1072
|
+
color: "cyan",
|
|
1073
|
+
// BotBuddy status is read from Linear; SupplyGuard's from BB's copy.
|
|
1074
|
+
children: [
|
|
1075
|
+
(snapshot.ticket.url ? "Linear · " : "BB · ") +
|
|
1076
|
+
snapshot.ticket.status,
|
|
1077
|
+
],
|
|
1078
|
+
}),
|
|
1079
|
+
]
|
|
1080
|
+
: [
|
|
1081
|
+
// BOT-3213: a coordinator session has a project, not a ticket.
|
|
1082
|
+
Text({
|
|
1083
|
+
children: ["Coordinator · " + (snapshot.epic.identifier || snapshot.epic.short_id) + " · " + snapshot.epic.name],
|
|
1084
|
+
}),
|
|
1085
|
+
]),
|
|
1047
1086
|
Text({ children: ["Agent · " + activity] }),
|
|
1048
1087
|
Text({ dimColor: true, children: [snapshot.branch] }),
|
|
1049
1088
|
);
|
|
@@ -1060,11 +1099,12 @@ export function register(on) {
|
|
|
1060
1099
|
// The same three items the band shows, one row each in full.
|
|
1061
1100
|
surface = e.surface;
|
|
1062
1101
|
children.push(...bandLines($.ui.resolve(e), $, true));
|
|
1063
|
-
|
|
1102
|
+
// BOT-3213: a coordinator has no ticket, so it has no ticket blockers to list.
|
|
1103
|
+
if (snapshot.ticket && snapshot.blockers === null)
|
|
1064
1104
|
children.push(
|
|
1065
1105
|
Text({ dimColor: true, children: ["Blockers are read from the BotBuddy Linear workspace only."] }),
|
|
1066
1106
|
);
|
|
1067
|
-
else
|
|
1107
|
+
else if (snapshot.ticket)
|
|
1068
1108
|
children.push(
|
|
1069
1109
|
Text({
|
|
1070
1110
|
bold: true,
|
|
@@ -1084,10 +1124,10 @@ export function register(on) {
|
|
|
1084
1124
|
children.push(
|
|
1085
1125
|
Text({ children: ["No open blockers at the last refresh."] }),
|
|
1086
1126
|
);
|
|
1087
|
-
const links =
|
|
1088
|
-
Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) })
|
|
1089
|
-
|
|
1090
|
-
if (snapshot.ticket
|
|
1127
|
+
const links = snapshot.ticket
|
|
1128
|
+
? [Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) })]
|
|
1129
|
+
: [Link({ label: "Open project ↗", href: LINKS.project(snapshot.epic.id) })];
|
|
1130
|
+
if (snapshot.ticket?.url)
|
|
1091
1131
|
links.push(Link({ label: "Linear ↗", href: snapshot.ticket.url }));
|
|
1092
1132
|
links.push(Link({ label: "Open BB ↗", href: APP }));
|
|
1093
1133
|
children.push(Box({ flexDirection: "row", columnGap: 2, children: links }));
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.72.0",
|
|
3
|
+
"source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
|
|
4
|
+
"source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "17bd44c07d1f07aaea6b9ca1db28b583a01353eb9b396b9c1ed37392964661ee"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.72.0",
|
|
3
|
+
"source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
|
|
4
|
+
"source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "fa0617252f98948c464b679f4ba3697e3d502459bebbb1af8b88508674e2d4d8"
|
|
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.72.0",
|
|
4
|
+
"source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
|
|
5
|
+
"source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
|
|
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": "17bd44c07d1f07aaea6b9ca1db28b583a01353eb9b396b9c1ed37392964661ee",
|
|
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": "fa0617252f98948c464b679f4ba3697e3d502459bebbb1af8b88508674e2d4d8",
|
|
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.72.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/commands.mjs
CHANGED
|
@@ -79,10 +79,20 @@ export function routeHelpArgv(argv) {
|
|
|
79
79
|
|
|
80
80
|
const TICKET_KEY_RE = /^[A-Za-z][A-Za-z0-9]{1,9}-\d{1,6}$/;
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
// BOT-3213: Linear's project identifier shape (the server re-checks it, and
|
|
83
|
+
// that the project belongs to this repo's tenant).
|
|
84
|
+
const PROJECT_ID_RE = /^P-[A-Z][A-Z0-9]{0,9}-[1-9][0-9]{0,6}$/i;
|
|
85
|
+
|
|
86
|
+
export function validateBootstrapLinkage(ticketId, noTicketReason, projectId = null) {
|
|
83
87
|
const ticket = typeof ticketId === "string" ? ticketId.trim() : "";
|
|
84
88
|
const reason = typeof noTicketReason === "string" ? noTicketReason.trim() : "";
|
|
85
|
-
|
|
89
|
+
const project = typeof projectId === "string" ? projectId.trim() : "";
|
|
90
|
+
if (project) {
|
|
91
|
+
if (!PROJECT_ID_RE.test(project)) return "bb bootstrap --project-id must be a Linear project identifier like P-BOT-39";
|
|
92
|
+
if (reason) return "bb bootstrap --project-id registers a coordinator; pass it with or without --ticket-id, but not also --no-ticket-reason";
|
|
93
|
+
} else if (!!ticket === !!reason) {
|
|
94
|
+
return "bb bootstrap requires exactly one of --ticket-id <ticket> or --no-ticket-reason <reason>, or --project-id <P-…> for a coordinator";
|
|
95
|
+
}
|
|
86
96
|
if (ticket && !TICKET_KEY_RE.test(ticket)) return "bb bootstrap --ticket-id must be a ticket key like BOT-123";
|
|
87
97
|
return null;
|
|
88
98
|
}
|
|
@@ -1228,6 +1238,7 @@ export async function cmdBootstrap(args, {
|
|
|
1228
1238
|
let ticketId = null;
|
|
1229
1239
|
let ticketUrl = null;
|
|
1230
1240
|
let noTicketReason = null;
|
|
1241
|
+
let projectId = null;
|
|
1231
1242
|
let prId = null;
|
|
1232
1243
|
let prNumber = null;
|
|
1233
1244
|
let prUrl = null;
|
|
@@ -1244,18 +1255,20 @@ export async function cmdBootstrap(args, {
|
|
|
1244
1255
|
else if (args[i] === "--ticket-id") ticketId = args[++i] || null;
|
|
1245
1256
|
else if (args[i] === "--ticket-url") ticketUrl = args[++i] || null;
|
|
1246
1257
|
else if (args[i] === "--no-ticket-reason") noTicketReason = args[++i] || null;
|
|
1258
|
+
else if (args[i] === "--project-id") projectId = args[++i] || null;
|
|
1247
1259
|
else if (args[i] === "--pr-id") prId = args[++i] || null;
|
|
1248
1260
|
else if (args[i] === "--pr-number") prNumber = Number(args[++i]);
|
|
1249
1261
|
else if (args[i] === "--pr-url") prUrl = args[++i] || null;
|
|
1250
1262
|
else if (args[i] === "--model") model = args[++i] || null;
|
|
1251
1263
|
else if (args[i] === "--effort") effort = args[++i] || null;
|
|
1252
|
-
else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
|
|
1264
|
+
else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --project-id <P-…> [--ticket-id <ticket>] | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
|
|
1253
1265
|
}
|
|
1254
1266
|
if (!harnessSessionId) fail("bb bootstrap requires --session-id <harness UUID>");
|
|
1255
|
-
const linkageError = validateBootstrapLinkage(ticketId, noTicketReason);
|
|
1267
|
+
const linkageError = validateBootstrapLinkage(ticketId, noTicketReason, projectId);
|
|
1256
1268
|
if (linkageError) fail(linkageError);
|
|
1257
1269
|
ticketId = ticketId?.trim() || null;
|
|
1258
1270
|
noTicketReason = noTicketReason?.trim() || null;
|
|
1271
|
+
projectId = projectId?.trim().toUpperCase() || null;
|
|
1259
1272
|
const nativeIdentityError = validateBootstrapNativeIdentity({ type, ticketId, codexThreadId, claudeDesktopSessionId });
|
|
1260
1273
|
if (nativeIdentityError) fail(nativeIdentityError);
|
|
1261
1274
|
if (!nameExplicit) name = `${name}-${harnessSessionId.slice(0, 8)}`;
|
|
@@ -1269,6 +1282,7 @@ export async function cmdBootstrap(args, {
|
|
|
1269
1282
|
ticketId,
|
|
1270
1283
|
ticketUrl,
|
|
1271
1284
|
noTicketReason,
|
|
1285
|
+
projectId,
|
|
1272
1286
|
prId,
|
|
1273
1287
|
prNumber: Number.isSafeInteger(prNumber) && prNumber > 0 ? prNumber : null,
|
|
1274
1288
|
prUrl,
|
|
@@ -1282,7 +1296,7 @@ export async function cmdBootstrap(args, {
|
|
|
1282
1296
|
// BOT-2058: the launcher must see a known-holder warning before it starts a
|
|
1283
1297
|
// new harness. Keep it out of the credential cache, but preserve the
|
|
1284
1298
|
// non-secret concurrency payload in this command receipt.
|
|
1285
|
-
log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
|
|
1299
|
+
log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(projectId ? { project_id: projectId, role: "coordinator" } : {}), ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
|
|
1286
1300
|
}
|
|
1287
1301
|
|
|
1288
1302
|
/** BOT-2457: local preflight mirrors the server's ticket-link identity gate. */
|
|
@@ -289,6 +289,8 @@ export async function bootstrapHarnessSession({
|
|
|
289
289
|
ticketId = null,
|
|
290
290
|
ticketUrl = null,
|
|
291
291
|
noTicketReason = null,
|
|
292
|
+
// BOT-3213: register as this Linear project's coordinator (P-BOT-39).
|
|
293
|
+
projectId = null,
|
|
292
294
|
prId = null,
|
|
293
295
|
prNumber = null,
|
|
294
296
|
prUrl = null,
|
|
@@ -341,6 +343,7 @@ export async function bootstrapHarnessSession({
|
|
|
341
343
|
...(ticketId ? { ticket_id: ticketId } : {}),
|
|
342
344
|
...(ticketUrl ? { ticket_url: ticketUrl } : {}),
|
|
343
345
|
...(noTicketReason ? { no_ticket_reason: noTicketReason } : {}),
|
|
346
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
344
347
|
...(prId ? { pr_id: prId } : {}),
|
|
345
348
|
...(prNumber != null ? { pr_number: prNumber } : {}),
|
|
346
349
|
...(prUrl ? { pr_url: prUrl } : {}),
|
package/src/status-band-read.mjs
CHANGED
|
@@ -61,8 +61,21 @@ function waitsOf(own) {
|
|
|
61
61
|
if (typeof w.oldest_at !== "string" || !Number.isFinite(Date.parse(w.oldest_at))) return null;
|
|
62
62
|
return { count: w.active, oldest_at: new Date(w.oldest_at).toISOString() };
|
|
63
63
|
}
|
|
64
|
-
function refuse(code) {
|
|
65
|
-
throw new Error(code);
|
|
64
|
+
function refuse(code, extra = {}) {
|
|
65
|
+
throw Object.assign(new Error(code), extra);
|
|
66
|
+
}
|
|
67
|
+
// BOT-3213: the project a session registered to coordinate, with its ticket
|
|
68
|
+
// counts by state; null when BB did not say or sent something malformed.
|
|
69
|
+
function coordinatorOf(own) {
|
|
70
|
+
const c = own?.coordinator;
|
|
71
|
+
if (!c || c.role !== "coordinator" || !UUID_LOWER.test(c.linear_project_id)) return null;
|
|
72
|
+
const n = (v) => (Number.isSafeInteger(v) && v >= 0 && v <= 100000 ? v : null);
|
|
73
|
+
const counts = c.counts && typeof c.counts === "object"
|
|
74
|
+
? { done: n(c.counts.done), in_progress: n(c.counts.in_progress), blocked: n(c.counts.blocked), todo: n(c.counts.todo), total: n(c.counts.total) }
|
|
75
|
+
: null;
|
|
76
|
+
const ok = counts && Object.values(counts).every((v) => v !== null) &&
|
|
77
|
+
counts.done + counts.in_progress + counts.blocked + counts.todo === counts.total;
|
|
78
|
+
return { ...c, counts: ok ? counts : null };
|
|
66
79
|
}
|
|
67
80
|
function label(value, max = 240) {
|
|
68
81
|
if (
|
|
@@ -250,15 +263,19 @@ export async function readStatus({
|
|
|
250
263
|
const sessionKeys = ownOk && !selected
|
|
251
264
|
? [...new Set(own.tickets.map((x) => String(x?.key || "").toUpperCase()).filter((k) => keyPattern.test(k)))].slice(0, 5)
|
|
252
265
|
: [];
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
const
|
|
266
|
+
// BOT-3213: a session registered as a project's coordinator, with no ticket of
|
|
267
|
+
// its own, is bound to that project; a branch key is only ever a guess.
|
|
268
|
+
const coordinator = ownOk ? coordinatorOf(own) : null;
|
|
269
|
+
const bindingKind = selected ? "selected" : sessionKeys.length ? "session" : coordinator ? "project" : "branch";
|
|
270
|
+
const keys = selected ?? (sessionKeys.length ? sessionKeys : bindingKind === "project" ? [] : branchKeys);
|
|
271
|
+
// The hint names this tenant's own key prefix (BOT-3213 AC-4).
|
|
272
|
+
if (!keys.length && bindingKind !== "project") refuse("ticket_missing", { prefix });
|
|
273
|
+
const key = keys[0] ?? null;
|
|
274
|
+
const useSession = bindingKind === "session" || bindingKind === "project";
|
|
258
275
|
// The Linear ticket read and the BB reads are independent, so they run
|
|
259
276
|
// together; a refused BB read blanks only its line. The epic read is the slow
|
|
260
277
|
// one (~7 s live), so it gets a longer budget, and a relay wake skips it.
|
|
261
|
-
const linearGraph = useLinear
|
|
278
|
+
const linearGraph = useLinear && key
|
|
262
279
|
? jsonRequest(
|
|
263
280
|
"https://api.linear.app/graphql",
|
|
264
281
|
{
|
|
@@ -284,7 +301,7 @@ export async function readStatus({
|
|
|
284
301
|
]);
|
|
285
302
|
let linearTicket = null;
|
|
286
303
|
const blockers = [];
|
|
287
|
-
if (useLinear) {
|
|
304
|
+
if (useLinear && key) {
|
|
288
305
|
const graph = await linearGraph;
|
|
289
306
|
const issue = graph?.data?.issue;
|
|
290
307
|
if (
|
|
@@ -407,6 +424,12 @@ export async function readStatus({
|
|
|
407
424
|
total,
|
|
408
425
|
percent: Number.isFinite(se.progress_pct) ? Math.max(0, Math.min(100, Math.round(se.progress_pct))) : total ? Math.round((100 * done) / total) : 0,
|
|
409
426
|
};
|
|
427
|
+
// BOT-3213: the project this session coordinates carries its counts by state.
|
|
428
|
+
if (coordinator && coordinator.linear_project_id === epic.id) {
|
|
429
|
+
epic.role = "coordinator";
|
|
430
|
+
if (coordinator.counts) epic.counts = coordinator.counts;
|
|
431
|
+
if (!epic.identifier && PROJECT_IDENTIFIER.test(coordinator.identifier || "")) epic.identifier = coordinator.identifier;
|
|
432
|
+
}
|
|
410
433
|
}
|
|
411
434
|
if (owner) {
|
|
412
435
|
const total = Math.max(0, (owner.children_total ?? 0) - (owner.children_canceled ?? 0));
|
|
@@ -469,7 +492,7 @@ export async function readStatus({
|
|
|
469
492
|
id: state.agent_id,
|
|
470
493
|
name: label(identity.agent.display_name, 100),
|
|
471
494
|
},
|
|
472
|
-
ticket: linearTicket || { ...tickets[0], url: null },
|
|
495
|
+
ticket: linearTicket || (tickets.length ? { ...tickets[0], url: null } : null),
|
|
473
496
|
tickets,
|
|
474
497
|
prs,
|
|
475
498
|
epic,
|
|
@@ -481,7 +504,7 @@ export async function readStatus({
|
|
|
481
504
|
// BOT-3136: where the tickets came from — the registered session, an explicit
|
|
482
505
|
// pick, or (only when the session registered none) a guess from the branch.
|
|
483
506
|
binding: bindingKind,
|
|
484
|
-
blockers: useLinear
|
|
507
|
+
blockers: useLinear && key
|
|
485
508
|
? [...new Map(blockers.map((b) => [b.key, b])).values()].sort((a, b) =>
|
|
486
509
|
a.key.localeCompare(b.key),
|
|
487
510
|
)
|
|
@@ -717,7 +740,8 @@ export async function main(args, {
|
|
|
717
740
|
return 0;
|
|
718
741
|
} catch (error) {
|
|
719
742
|
const known = /^[a-z_]+$/.test(error?.message ?? "") ? error.message : "status_unavailable";
|
|
720
|
-
|
|
743
|
+
const prefix = known === "ticket_missing" && /^[A-Z]{2,10}$/.test(error?.prefix ?? "") ? { prefix: error.prefix } : {};
|
|
744
|
+
out.write(JSON.stringify({ error: known, ...prefix }) + "\n");
|
|
721
745
|
return 1;
|
|
722
746
|
}
|
|
723
747
|
}
|
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.`;
|