@botbuddy/cli 1.71.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 CHANGED
@@ -1,8 +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
+
3
7
  ## 1.71.0
4
8
 
5
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
+
6
11
  ## 1.69.8
7
12
 
8
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.
@@ -12,6 +12,12 @@
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
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,15 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.mjs\"",
9
+ "timeout": 30
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -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,7 +1,7 @@
1
1
  {
2
- "release_version": "1.71.0",
3
- "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
4
- "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
2
+ "release_version": "1.72.0",
3
+ "source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
4
+ "source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
5
5
  "target": "darwin-arm64",
6
- "sha256": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570"
6
+ "sha256": "17bd44c07d1f07aaea6b9ca1db28b583a01353eb9b396b9c1ed37392964661ee"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.71.0",
3
- "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
4
- "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
2
+ "release_version": "1.72.0",
3
+ "source_commit": "ea5d912bff641a64e288c7c5fc116eacb29cc39a",
4
+ "source_sha256": "e8c960ad27e9fd8da5b4826f6c1d599aeed503e4e26f9504533acdb2f659acee",
5
5
  "target": "linux-x64",
6
- "sha256": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec"
6
+ "sha256": "fa0617252f98948c464b679f4ba3697e3d502459bebbb1af8b88508674e2d4d8"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.71.0",
4
- "source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
5
- "source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
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": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570",
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": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec",
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.71.0",
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",
@@ -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
- const PLUGIN_ID = `${PLUGIN}@${MARKETPLACE}`;
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 into Claude Code once, at user scope, from
32
- this installed CLI package. bb setup and bb update run it for you.`;
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 { status, … } where status is
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
- let shipped;
84
- try {
85
- shipped = (await readJson(join(marketplaceDir, PLUGIN, ".claude-plugin", "plugin.json"))).version;
86
- } catch {
87
- return { status: "failed", reason: "plugin_missing_from_package" };
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
- const current = Array.isArray(markets) ? markets.find((m) => m?.name === MARKETPLACE) : null;
92
- const repointed = Boolean(current) && resolve(String(current.path ?? "")) !== resolve(marketplaceDir);
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
- const plugins = await claudeJson(run, ["list"]);
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
- const detail = String(error?.stderr || error?.message || error).trim().split("\n")[0].slice(0, 200);
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.`;