@botbuddy/cli 1.75.0 → 1.75.2
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/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 +1 -1
- package/src/status-band-read.mjs +10 -7
- package/src/status-band.mjs +128 -4
- package/src/update-check.mjs +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.75.2
|
|
4
|
+
|
|
5
|
+
- The bb-status band connects a new Claude Code session in a reused worktree whose cache belongs to a Claude session that has gone **and** whose BB session has expired (BOT-3252). Before, the band moved such a cache aside only while the old BB session was still live; for an expired one it bootstrapped with the stale cache in place, the bootstrap's `close_session` on the owner sign-in was refused with `agent_identity_required`, and the band showed "BB identity belongs to another session" forever. It now sets the cache aside to `.botbuddy/agent-state.superseded-<id>.json` in that case too (and for an expired holder with no transcript on this host), under the same state lock, and restores it if the bootstrap fails. A holder whose Claude session is active is still never taken over.
|
|
6
|
+
|
|
7
|
+
## 1.75.1
|
|
8
|
+
|
|
9
|
+
- `bb update` (and `bb setup`, `bb status-band install`) now brings every copy of the bb-status band and the bb-session start-up hook up to date, not just the user-scope one (BOT-3216). A copy installed at local or project scope wins over user scope for its project, so stale ones kept old bands in Supply Guard worktrees: a checkout's local install was copied into every new worktree through its `settings.local.json`, and each copy stayed at the version current when that worktree was made. Now an enabled local copy behind the shipped version is uninstalled so the user-scope install applies (this also clears the checkout's `enabledPlugins` line, so new worktrees stop getting copies), a disabled one is updated and stays disabled, a project-scope one is updated in place, and a deleted worktree's entry is removed. If the user-scope install failed, nothing is removed, only updated. The install line ends with a count, e.g. `4 stale project copies removed (user scope now applies), 1 stale project copy updated.` A second run changes nothing.
|
|
10
|
+
|
|
3
11
|
## 1.75.0
|
|
4
12
|
|
|
5
13
|
- New `bb release-notes keys create|list|revoke` and `bb release-notes origins set` let a tenant owner give their own app a way to show release notes without its users signing in to BotBuddy (BOT-3158). `keys create --environment <local|preview|staging|production> --out <file>` writes the new viewer-key secret to a new file with mode 0600 and never prints it (not with `--json`, not on error); the file is claimed before BotBuddy is called and removed if nothing was created. `keys list` shows each key id (`<tenant>:<environment>:<n>`), active or revoked, and each environment's origins. `keys revoke --environment <env> --key <n>` makes tokens signed with that key fail at once. `origins set --environment <env> --origin <origin>…` (or `--none`) replaces the web origins that may read the feed. Refusals name their code (`owner_required`, `entitlement_missing`, `too_many_active_keys`, `key_not_found`, `origin_refused`) and exit 1.
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.75.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.75.2",
|
|
3
|
+
"source_commit": "ccd86f542412dac79337afbcdcb3e80fc323366b",
|
|
4
|
+
"source_sha256": "2695260c9fea9c4b011c3da9148c1da79b775a048490ca66f2e4497fc6222ad0",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "b54bce075fd7a877a6547ffd7971d62afb73cfea09509c5529c09baed97de2b4"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.75.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.75.2",
|
|
3
|
+
"source_commit": "ccd86f542412dac79337afbcdcb3e80fc323366b",
|
|
4
|
+
"source_sha256": "2695260c9fea9c4b011c3da9148c1da79b775a048490ca66f2e4497fc6222ad0",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "092310979a23f3c2f072975190af2899c6fe4cca213ffe3a1853092f007639cd"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.75.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.75.2",
|
|
4
|
+
"source_commit": "ccd86f542412dac79337afbcdcb3e80fc323366b",
|
|
5
|
+
"source_sha256": "2695260c9fea9c4b011c3da9148c1da79b775a048490ca66f2e4497fc6222ad0",
|
|
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": "b54bce075fd7a877a6547ffd7971d62afb73cfea09509c5529c09baed97de2b4",
|
|
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": "092310979a23f3c2f072975190af2899c6fe4cca213ffe3a1853092f007639cd",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/status-band-read.mjs
CHANGED
|
@@ -631,12 +631,15 @@ export async function claudeHolderActive(holder, worktree, { env = process.env,
|
|
|
631
631
|
if (at == null) return null;
|
|
632
632
|
return now() - at < HOLDER_IDLE_MS;
|
|
633
633
|
}
|
|
634
|
-
// Returns false (never bind), true (bootstrap as is), or { aside } —
|
|
635
|
-
// holder's cache
|
|
636
|
-
//
|
|
637
|
-
// live
|
|
638
|
-
//
|
|
639
|
-
//
|
|
634
|
+
// Returns false (never bind), true (bootstrap as is), or { aside } — another
|
|
635
|
+
// holder's cache to move out of the way first. The bootstrap would otherwise
|
|
636
|
+
// try to retire that BB session and discard the new one when it cannot: the
|
|
637
|
+
// server refuses the retirement for a live session (which would end the waits
|
|
638
|
+
// other sessions still run on its token), and refuses it for an EXPIRED one too
|
|
639
|
+
// whenever the durable credential is an owner bearer, since close_session needs
|
|
640
|
+
// an agent identity (BOT-3252: the band then stayed on "belongs to another
|
|
641
|
+
// session" forever in a reused worktree). Set aside, a live session expires on
|
|
642
|
+
// its own once nothing renews it; the file is kept for recovery.
|
|
640
643
|
async function bindable(cwd, harnessSessionId, now, holderActive) {
|
|
641
644
|
let state;
|
|
642
645
|
let root;
|
|
@@ -651,7 +654,7 @@ async function bindable(cwd, harnessSessionId, now, holderActive) {
|
|
|
651
654
|
const expired = !(Date.parse(state.expires_at) > now());
|
|
652
655
|
const active = await holderActive(holder, root).catch(() => null);
|
|
653
656
|
if (active === true) return false;
|
|
654
|
-
if (active === false
|
|
657
|
+
if ((active === false || expired) && UUID_ONLY.test(holder)) {
|
|
655
658
|
return {
|
|
656
659
|
cache: join(root, ".botbuddy/agent-state.json"),
|
|
657
660
|
aside: join(root, `.botbuddy/agent-state.superseded-${holder.slice(0, 8)}.json`),
|
package/src/status-band.mjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// `botbuddy-labs` Claude Code marketplace at the plugin shipped in this package
|
|
10
10
|
// and installs `bb-status` at user scope, so every worktree gets the band.
|
|
11
11
|
import { execFile as nodeExecFile } from "node:child_process";
|
|
12
|
-
import {
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
import { mkdir, readFile, rmdir } from "node:fs/promises";
|
|
13
14
|
import { dirname, join, resolve, sep } from "node:path";
|
|
14
15
|
import { fileURLToPath } from "node:url";
|
|
15
16
|
import { promisify } from "node:util";
|
|
@@ -83,6 +84,106 @@ async function installOne({ run, name, shipped, installed, repointed }) {
|
|
|
83
84
|
return { status: mine && !repointed ? "updated" : "installed", version: shipped };
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
// BOT-3216: a local- or project-scope copy wins over user scope for its project.
|
|
88
|
+
// The desktop app copies a checkout's gitignored .claude/settings.local.json into
|
|
89
|
+
// every new worktree, and Claude Code then installs the plugin at local scope at
|
|
90
|
+
// whatever version is current — a copy nothing ever updated again.
|
|
91
|
+
export const projectDirs = {
|
|
92
|
+
exists: (p) => existsSync(p),
|
|
93
|
+
// Claude Code keeps a git worktree's local enabledPlugins in its main
|
|
94
|
+
// checkout's settings.local.json, so it alone knows the effective state:
|
|
95
|
+
// `claude plugin list` run from the project reports it.
|
|
96
|
+
async enabled(p, id, run) {
|
|
97
|
+
const { stdout } = await run(["plugin", "list", "--json"], { cwd: p });
|
|
98
|
+
const list = JSON.parse(stdout);
|
|
99
|
+
const entry = Array.isArray(list) ? list.find((e) => e?.id === id && e?.scope === "local" && e?.projectPath === p) : null;
|
|
100
|
+
return entry?.enabled !== false;
|
|
101
|
+
},
|
|
102
|
+
// A deleted worktree's entry can only be uninstalled from its own path, so the
|
|
103
|
+
// path is recreated empty for that one command and the dirs made are removed
|
|
104
|
+
// again (rmdir only: never deletes anything it did not create).
|
|
105
|
+
async materialize(p) {
|
|
106
|
+
const made = [];
|
|
107
|
+
for (let d = resolve(p); !existsSync(d); d = dirname(d)) made.push(d);
|
|
108
|
+
await mkdir(p, { recursive: true });
|
|
109
|
+
return async () => {
|
|
110
|
+
for (const d of made) await rmdir(d).catch(() => {});
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Bring every local/project copy of our plugins that is behind the shipped
|
|
116
|
+
// version up to date. An enabled local copy is uninstalled so user scope takes
|
|
117
|
+
// over (that also drops its enabledPlugins line, so the checkout stops seeding
|
|
118
|
+
// new worktrees); a disabled one is updated and stays disabled; a project-scope
|
|
119
|
+
// one is updated in place (never edits committed settings). When the user-scope
|
|
120
|
+
// install failed nothing is removed, only updated. Sequential: every command
|
|
121
|
+
// rewrites Claude Code's one installed_plugins.json.
|
|
122
|
+
async function refreshScoped({ run, installed, shipped, userOk, dirs }) {
|
|
123
|
+
const counts = { removed: 0, updated: 0, failed: 0 };
|
|
124
|
+
const ours = (Array.isArray(installed) ? installed : []).filter((p) => {
|
|
125
|
+
const [name, market] = String(p?.id ?? "").split("@");
|
|
126
|
+
return market === MARKETPLACE && name in shipped && (p.scope === "local" || p.scope === "project") && p.projectPath;
|
|
127
|
+
});
|
|
128
|
+
const stale = ours.filter((p) => p.version !== shipped[p.id.split("@")[0]]);
|
|
129
|
+
if (!stale.length) return null;
|
|
130
|
+
const nameOf = (p) => p.id.split("@")[0];
|
|
131
|
+
// Snapshot every existing local copy's effective state (true | false | null =
|
|
132
|
+
// unread) before changing any: one removal rewrites the settings file a whole
|
|
133
|
+
// checkout's worktrees share, so it can change copies it never touched.
|
|
134
|
+
const state = new Map();
|
|
135
|
+
for (const p of ours) {
|
|
136
|
+
if (p.scope !== "local" || !dirs.exists(p.projectPath)) continue;
|
|
137
|
+
state.set(p, await dirs.enabled(p.projectPath, p.id, run).catch(() => null));
|
|
138
|
+
}
|
|
139
|
+
const plan = stale.map((p) => {
|
|
140
|
+
const exists = dirs.exists(p.projectPath);
|
|
141
|
+
// A local override is removed only when user scope will run it in its
|
|
142
|
+
// place and its state is known; a deleted worktree's entry always goes.
|
|
143
|
+
const remove = p.scope === "local" && (!exists || (userOk[nameOf(p)] && state.get(p) === true));
|
|
144
|
+
return { p, exists, remove };
|
|
145
|
+
});
|
|
146
|
+
for (const { p, exists, remove } of plan) {
|
|
147
|
+
let cleanup = null;
|
|
148
|
+
try {
|
|
149
|
+
if (!exists) cleanup = await dirs.materialize(p.projectPath);
|
|
150
|
+
await run(["plugin", remove ? "uninstall" : "update", p.id, "--scope", p.scope], { cwd: p.projectPath });
|
|
151
|
+
counts[remove ? "removed" : "updated"] += 1;
|
|
152
|
+
} catch {
|
|
153
|
+
counts.failed += 1;
|
|
154
|
+
} finally {
|
|
155
|
+
if (cleanup) await cleanup().catch(() => {});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (!counts.removed) return counts;
|
|
159
|
+
// Put back what a removal may have cleared from the shared settings: a
|
|
160
|
+
// disabled copy is disabled again; an enabled one is re-enabled only where
|
|
161
|
+
// user scope would not run it (re-enabling elsewhere would re-seed new
|
|
162
|
+
// worktrees). A copy left in the wrong state is a failure named with the one
|
|
163
|
+
// command that fixes it, since the stale entry is gone and a re-run would not
|
|
164
|
+
// revisit it; a copy whose state could not be read is reported, never guessed.
|
|
165
|
+
const removed = new Set(plan.filter((x) => x.remove).map((x) => x.p));
|
|
166
|
+
for (const [p, was] of state) {
|
|
167
|
+
if (removed.has(p)) continue;
|
|
168
|
+
if (was === null) {
|
|
169
|
+
counts.failed += 1;
|
|
170
|
+
(counts.unread ??= []).push({ id: p.id, projectPath: p.projectPath });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (was === true && userOk[nameOf(p)]) continue;
|
|
174
|
+
const now = await dirs.enabled(p.projectPath, p.id, run).catch(() => null);
|
|
175
|
+
if (now === was) continue;
|
|
176
|
+
const verb = was ? "enable" : "disable";
|
|
177
|
+
try {
|
|
178
|
+
await run(["plugin", verb, p.id, "--scope", "local"], { cwd: p.projectPath });
|
|
179
|
+
} catch {
|
|
180
|
+
counts.failed += 1;
|
|
181
|
+
(counts.restore ??= []).push({ id: p.id, projectPath: p.projectPath, verb });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return counts;
|
|
185
|
+
}
|
|
186
|
+
|
|
86
187
|
/**
|
|
87
188
|
* Point `botbuddy-labs` at this package's plugin folder and install `bb-status`
|
|
88
189
|
* (and, BOT-3222, `bb-session`) at user scope. Idempotent; never throws. Returns
|
|
@@ -96,9 +197,10 @@ export async function installStatusBand({
|
|
|
96
197
|
claude = "claude",
|
|
97
198
|
execFileImpl = promisify(nodeExecFile),
|
|
98
199
|
readJson = async (p) => JSON.parse(await readFile(p, "utf8")),
|
|
200
|
+
projectDirs: dirs = projectDirs,
|
|
99
201
|
} = {}) {
|
|
100
202
|
if (!isInstalledPackage(packageRoot)) return { status: "skipped", reason: "not_installed_package" };
|
|
101
|
-
const run = (args) => execFileImpl(claude, args, { timeout: 60_000, maxBuffer: 4 * 1024 * 1024 });
|
|
203
|
+
const run = (args, extra = {}) => execFileImpl(claude, args, { timeout: 60_000, maxBuffer: 4 * 1024 * 1024, ...extra });
|
|
102
204
|
try {
|
|
103
205
|
await run(["--version"]);
|
|
104
206
|
} catch {
|
|
@@ -139,12 +241,34 @@ export async function installStatusBand({
|
|
|
139
241
|
const band = wanted.includes(PLUGIN) ? await one(PLUGIN) : { status: "skipped", reason: "not_requested" };
|
|
140
242
|
const result = { ...band, ...(band.status !== "failed" && repointed ? { replaced: String(current.path ?? "") } : {}) };
|
|
141
243
|
if (wanted.includes(SESSION_PLUGIN)) result.session = await one(SESSION_PLUGIN);
|
|
244
|
+
// The band's user copy is always (re-)enabled; bb-session's stays disabled if
|
|
245
|
+
// the operator disabled it, and then a local override is not safe to remove.
|
|
246
|
+
const userSession = Array.isArray(installed) ? installed.find((p) => p?.id === `${SESSION_PLUGIN}@${MARKETPLACE}` && p?.scope === "user") : null;
|
|
247
|
+
const userOk = {
|
|
248
|
+
[PLUGIN]: band.status !== "failed",
|
|
249
|
+
[SESSION_PLUGIN]: Boolean(result.session) && result.session.status !== "failed" && userSession?.enabled !== false,
|
|
250
|
+
};
|
|
251
|
+
const scoped = await refreshScoped({ run, installed, shipped, userOk, dirs });
|
|
252
|
+
if (scoped) result.scoped = scoped;
|
|
142
253
|
return result;
|
|
143
254
|
}
|
|
144
255
|
|
|
145
256
|
export function statusBandLine(result) {
|
|
146
|
-
const
|
|
147
|
-
|
|
257
|
+
const parts = [bandLine(result)];
|
|
258
|
+
if (result?.session) parts.push(sessionLine(result.session));
|
|
259
|
+
if (result?.scoped) parts.push(scopedLine(result.scoped));
|
|
260
|
+
return parts.join(" ");
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const copies = (n) => `${n} stale project ${n === 1 ? "copy" : "copies"}`;
|
|
264
|
+
function scopedLine({ removed = 0, updated = 0, failed = 0, restore = [], unread = [] }) {
|
|
265
|
+
const done = [removed && `${copies(removed)} removed (user scope now applies)`, updated && `${copies(updated)} updated`].filter(Boolean);
|
|
266
|
+
const head = done.length ? `${done.join(", ")}.` : "";
|
|
267
|
+
const other = failed - restore.length - unread.length;
|
|
268
|
+
const tail = other > 0 ? `${copies(other)} could not be fixed; run bb status-band install to retry.` : "";
|
|
269
|
+
const fix = restore.map((r) => `A copy lost its ${r.verb === "disable" ? "disabled" : "enabled"} setting; restore it: cd ${r.projectPath} && claude plugin ${r.verb} ${r.id} --scope local`);
|
|
270
|
+
const check = unread.map((r) => `Could not read whether ${r.id} is enabled in ${r.projectPath}; check it with claude plugin list there.`);
|
|
271
|
+
return [head, tail, ...fix, ...check].filter(Boolean).join(" ");
|
|
148
272
|
}
|
|
149
273
|
|
|
150
274
|
function sessionLine(s) {
|
package/src/update-check.mjs
CHANGED
|
@@ -306,9 +306,11 @@ export async function refreshInstalledPools({
|
|
|
306
306
|
|
|
307
307
|
// BOT-3152: run the NEW package's `status-band install` (this process is the old
|
|
308
308
|
// one), so Claude Code's bb-status band and its marketplace match the update.
|
|
309
|
+
// BOT-3216: it also fixes every stale local/project copy, two `claude` calls
|
|
310
|
+
// each (53 on one Mac), so it gets 10 minutes rather than 3.
|
|
309
311
|
export async function installBandFromNewPackage({ npmBin, shellOpt, probeImpl, log, nodeBin = process.execPath, execFileImpl = promisify(execFile) }) {
|
|
310
312
|
const root = readNpmGlobalRoot({ npmBin, shellOpt, probeImpl });
|
|
311
|
-
const { stdout } = await execFileImpl(nodeBin, [join(root, "@botbuddy", "cli", "bin", "botbuddy.mjs"), "status-band", "install"], { timeout:
|
|
313
|
+
const { stdout } = await execFileImpl(nodeBin, [join(root, "@botbuddy", "cli", "bin", "botbuddy.mjs"), "status-band", "install"], { timeout: 600_000, maxBuffer: 1024 * 1024 });
|
|
312
314
|
const line = String(stdout).trim().split("\n").filter(Boolean).pop();
|
|
313
315
|
if (line) log(line);
|
|
314
316
|
}
|