@botbuddy/cli 1.118.4 → 1.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.120.0
4
+
5
+ - BOT-3569: `bb report upload <file.html> --type <type> --title <title>` stores one HTML report (at most 5,242,880 bytes) in your tenant's private report store and prints its BotBuddy link, `<app>/reports/stored/<id>`, with the report id and the file's sha256. It calls the MCP tool `begin_report_upload`, PUTs the bytes straight to Storage through the one signed URL it returns, then `finalize_report_upload`, which reads the stored bytes back and checks size, sha256 and HTML shape. `--ticket`, `--pr` (repository from `--repository` or the origin remote) and `--release` link the report; `--source-key` and `--json` as usual. A refusal (`report_not_html`, `report_too_large`, `report_type_unknown`, `report_digest_mismatch`, `scope_missing`) exits 1 and prints the code, the limit and the fix. Needs MCP 2.163.0.
6
+
7
+ ## 1.119.0
8
+
9
+ - BOT-3529: a host child layer's system packages keep their symlinks as the package ships them. The layer build unpacked each `.deb` with `cpio --no-absolute-filenames`, which also strips a leading `../` from link targets, so `/usr/bin/psql -> ../share/postgresql-common/pg_wrapper` dangled and a child could not run `psql`. The fleet host daemon now unpacks each package itself (its binary is bound read-only into the build unit): link targets are kept verbatim, and an absolute or `..` member name, a hard link to anything outside the package, a relative symlink that resolves outside the layer, and a member written through a symlink are refused with `CHILD_LAYER_SYSTEM_PACKAGE_UNPACK_FAILED`.
10
+
3
11
  ## 1.118.4
4
12
 
5
13
  - BOT-3565: a host daemon running two stack jobs no longer claims a lease's reap while that lease's provision, which failed before its driver started, is still settling. From just before that failed receipt is sent until the job settles, the daemon pauses its claims (after any claim already in flight). The no-execution settlement then finds the reap still queued, closes it and reaps the lease in seconds. Before, the claimed reap made the server refuse the settlement and the host stayed `recovery_blocked / accepted_receipt_finalization_pending` until the 15-minute stale-claim requeue. A provision whose driver started, and a one-job host, never pause.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.118.4",
3
- "source_commit": "6cee4152102739dddeddefbd440fc65b4f91a99a",
4
- "source_sha256": "64c8ffc2c217664a4275d4eea7290f45bfa22e7e901ff84464edc23f3f8b207b",
2
+ "release_version": "1.120.0",
3
+ "source_commit": "f74c27186b6b5cca981bbdef34dc0b12b0ed8beb",
4
+ "source_sha256": "5f4042252d77e5d4674141b007ca2795de1746ef882706a8e4359a6457c66758",
5
5
  "target": "darwin-arm64",
6
- "sha256": "0bb3fd8b2f04797e23d509209fbf6c9642f84a7d4a64edf696941ab6c3e56f68"
6
+ "sha256": "9a890a6e9a6a2c9b12bea0c94af1060060318da6a85ddbf8eca41a858a9ae280"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.118.4",
3
- "source_commit": "6cee4152102739dddeddefbd440fc65b4f91a99a",
4
- "source_sha256": "64c8ffc2c217664a4275d4eea7290f45bfa22e7e901ff84464edc23f3f8b207b",
2
+ "release_version": "1.120.0",
3
+ "source_commit": "f74c27186b6b5cca981bbdef34dc0b12b0ed8beb",
4
+ "source_sha256": "5f4042252d77e5d4674141b007ca2795de1746ef882706a8e4359a6457c66758",
5
5
  "target": "linux-x64",
6
- "sha256": "383e8c5e3475680e60eeb7d7be776beeabb1c8e9461f5adabec5dc978904b9c5"
6
+ "sha256": "05c25c0f04482e067786d4bbca3935868f8df650bf302dd6371971c6e3735911"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.118.4",
4
- "source_commit": "6cee4152102739dddeddefbd440fc65b4f91a99a",
5
- "source_sha256": "64c8ffc2c217664a4275d4eea7290f45bfa22e7e901ff84464edc23f3f8b207b",
3
+ "release_version": "1.120.0",
4
+ "source_commit": "f74c27186b6b5cca981bbdef34dc0b12b0ed8beb",
5
+ "source_sha256": "5f4042252d77e5d4674141b007ca2795de1746ef882706a8e4359a6457c66758",
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": "0bb3fd8b2f04797e23d509209fbf6c9642f84a7d4a64edf696941ab6c3e56f68",
11
+ "sha256": "9a890a6e9a6a2c9b12bea0c94af1060060318da6a85ddbf8eca41a858a9ae280",
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": "383e8c5e3475680e60eeb7d7be776beeabb1c8e9461f5adabec5dc978904b9c5",
18
+ "sha256": "05c25c0f04482e067786d4bbca3935868f8df650bf302dd6371971c6e3735911",
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.118.4",
3
+ "version": "1.120.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
package/src/commands.mjs CHANGED
@@ -21,6 +21,7 @@ import { cmdTest } from "./test-lane.mjs";
21
21
  import { cmdEvidence } from "./evidence.mjs";
22
22
  import { cmdFeedback } from "./feedback.mjs";
23
23
  import { cmdReleaseNotes } from "./release-notes.mjs";
24
+ import { cmdReport } from "./report.mjs";
24
25
  import { cmdStatusBand, installStatusBand, statusBandLine } from "./status-band.mjs";
25
26
  import { runWait } from "./wait.mjs";
26
27
  import { SETUP_BLOCK } from "./setup-block.mjs";
@@ -67,7 +68,7 @@ export function shouldCheckForUpdates(argv) {
67
68
  export const LOCAL_HELP_COMMANDS = Object.freeze([
68
69
  "wait", "stack", "pw", "docker", "run", "mcp", "login", "setup", "doctor", "host",
69
70
  "staging-pool", "daemon", "evidence", "feedback", "usage", "telemetry", "allocation",
70
- "release-notes", "status-band", "push",
71
+ "release-notes", "report", "status-band", "push",
71
72
  ]);
72
73
  const HELP_WORDS = new Set(["help", "--help", "-h"]);
73
74
 
@@ -163,6 +164,8 @@ export async function run(argv, {
163
164
  case "feedback": return cmdFeedback(args);
164
165
  // BOT-3156: governed release notes (submit one note through submit_release_note).
165
166
  case "release-notes": return cmdReleaseNotes(args);
167
+ // BOT-3569: store one HTML report in the tenant report store.
168
+ case "report": return cmdReport(args);
166
169
  // BOT-3152: the bb-status band's host side (read/relay) and its Claude Code install.
167
170
  case "status-band": return cmdStatusBand(args);
168
171
  case "test-ingest": return cmdTestIngest(args);
@@ -365,6 +368,8 @@ ${bold("EVIDENCE")} (${cyan("bb help evidence")})
365
368
  release-notes tags [group|add|retire|view]
366
369
  List or manage the tenant's release-note tag groups
367
370
  release-notes keys|origins Viewer keys and allowed origins for your own app (owners)
371
+ report upload <file.html> --type <type> --title <title>
372
+ Store one HTML report for your tenant and print its BotBuddy link
368
373
  status-band install Install the bb-status band into Claude Code (bb setup does it)
369
374
  status-band read|relay The band's own reads and live wake (run by the mod)
370
375
  evidence require <file> Record an exact-head evidence disposition → botbuddy/ready
package/src/report.mjs ADDED
@@ -0,0 +1,248 @@
1
+ // BOT-3569: `bb report upload <file.html>` — store one HTML report in the
2
+ // tenant's private report store and print its BotBuddy link.
3
+ //
4
+ // The CLI is a client of the MCP tools (ADR 2026-11-20): begin_report_upload
5
+ // records the pending report and returns one signed PUT URL, the CLI PUTs the
6
+ // file's bytes straight to Storage (they never pass through a function), and
7
+ // finalize_report_upload has the server read the stored bytes back and check
8
+ // their size, sha256 and HTML shape. The server is the only validator; the CLI
9
+ // measures the file and prints the receipt or the named refusal with its limit
10
+ // and fix. The tenant is the authenticated agent's, never a flag.
11
+ import { createHash } from "node:crypto";
12
+ import { execFileSync } from "node:child_process";
13
+ import { readFile } from "node:fs/promises";
14
+ import { basename } from "node:path";
15
+ import { CALL_EXIT, callToolJson, resolveCallAuth } from "./api.mjs";
16
+
17
+ export const REPORT_TYPES = Object.freeze(["sg_analysis", "architecture", "impact", "release_tour"]);
18
+ export const REPORT_LIMIT_BYTES = 5_242_880;
19
+ const LIMIT_LINE = `Limit: one HTML file (.html or .htm, UTF-8, with a <title> or a body), at most ${REPORT_LIMIT_BYTES.toLocaleString("en-US")} bytes (5 MB).`;
20
+
21
+ export const REPORT_USAGE = `Usage: bb report upload <file.html> --type <type> --title <title>
22
+ [--source-key <key>] [--ticket <KEY>]... [--pr <n>]... [--release <tag>]...
23
+ [--repository <owner/name>] [--json]
24
+
25
+ Stores one HTML report in your tenant's private report store and prints its
26
+ link, <app>/reports/stored/<id>, where a member of your tenant opens it.
27
+
28
+ --type sg_analysis | architecture | impact | release_tour
29
+ --title the report's title (1–200 characters)
30
+ --source-key optional stable key (for example the ticket the report is about)
31
+ --ticket a ticket the report belongs to (repeatable)
32
+ --pr a pull request number (repeatable); its repository is
33
+ --repository, or this checkout's origin remote
34
+ --release a release tag (repeatable)
35
+ --json print the receipt or refusal as JSON
36
+
37
+ ${LIMIT_LINE}
38
+ The viewer runs no script and loads nothing from outside the file: inline
39
+ images, fonts and styles as data: URLs. Links open in a new tab.
40
+
41
+ Example:
42
+ bb report upload docs/analysis/stored-reports.html --type sg_analysis \\
43
+ --title "Stored reports analysis" --ticket BOT-3569 --pr 1999
44
+
45
+ Refusals (exit 1, nothing stored): report_not_html, report_too_large,
46
+ report_type_unknown, report_digest_mismatch, scope_missing (the key needs the
47
+ write scope, or a tenant owner). Uploading needs an agent key with the write
48
+ scope (bb login --tenant, then bb mcp setup). Guide: docs/stored-reports.md.`;
49
+
50
+ const BEGIN = "begin_report_upload";
51
+ const FINALIZE = "finalize_report_upload";
52
+
53
+ /** owner/name of this checkout's origin remote, or null. */
54
+ export function originRepository({ cwd = process.cwd(), git = defaultGit } = {}) {
55
+ const remote = git(cwd, ["remote", "get-url", "origin"]);
56
+ return remote?.match(/github\.com[:/]([^/\s]+\/[^/\s]+?)(?:\.git)?\/?$/i)?.[1]?.toLowerCase() ?? null;
57
+ }
58
+
59
+ function defaultGit(cwd, args) {
60
+ try {
61
+ return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5_000 }).trim() || null;
62
+ } catch {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ const VALUE_FLAGS = new Set(["--type", "--title", "--source-key", "--ticket", "--pr", "--release", "--repository"]);
68
+ const REPEATABLE = new Set(["--ticket", "--pr", "--release"]);
69
+
70
+ export function parseUploadArgs(argv) {
71
+ const out = { file: null, json: false, ticket: [], pr: [], release: [] };
72
+ for (let i = 0; i < argv.length; i += 1) {
73
+ const a = argv[i];
74
+ if (a === "--json") { out.json = true; continue; }
75
+ const eq = a.startsWith("--") ? a.indexOf("=") : -1;
76
+ const flag = eq > 0 ? a.slice(0, eq) : a;
77
+ if (VALUE_FLAGS.has(flag)) {
78
+ const value = eq > 0 ? a.slice(eq + 1) : argv[++i];
79
+ if (value === undefined || value === "" || (eq < 0 && value.startsWith("--"))) return { error: `${flag} needs a value.` };
80
+ const key = flag.slice(2).replace("-", "_");
81
+ if (REPEATABLE.has(flag)) out[key].push(value);
82
+ else if (out[key] !== undefined) return { error: `${flag} was given twice.` };
83
+ else out[key] = value;
84
+ continue;
85
+ }
86
+ if (a.startsWith("-")) return { error: `Unknown option ${a}.` };
87
+ if (out.file) return { error: "Upload one file at a time." };
88
+ out.file = a;
89
+ }
90
+ if (!out.file) return { error: "Name the HTML file to upload." };
91
+ return out;
92
+ }
93
+
94
+ function sha256Hex(bytes) {
95
+ return createHash("sha256").update(bytes).digest("hex");
96
+ }
97
+
98
+ async function callTool(tool, args, { resolveAuth, call }) {
99
+ try {
100
+ const resolved = await resolveAuth({ toolName: tool, preferSession: true });
101
+ if (resolved?.error || !resolved?.auth) return { ok: false, auth: true };
102
+ return await call(tool, args, { auth: resolved.auth, signal: AbortSignal.timeout(60_000) });
103
+ } catch {
104
+ return { ok: false, status: null };
105
+ }
106
+ }
107
+
108
+ function printRefusal(data, { json, log, errorLog }) {
109
+ const refusal = {
110
+ ok: false,
111
+ error: data.error,
112
+ message: data.message ?? null,
113
+ ...(data.field ? { field: data.field } : {}),
114
+ limit_bytes: data.limit_bytes ?? REPORT_LIMIT_BYTES,
115
+ ...(data.fix ? { fix: data.fix } : {}),
116
+ };
117
+ if (json) log(JSON.stringify(refusal));
118
+ errorLog(`✗ ${refusal.error}${refusal.field ? ` (${refusal.field})` : ""}: ${refusal.message ?? "Nothing was stored."}`);
119
+ errorLog(LIMIT_LINE);
120
+ if (refusal.fix) errorLog(`Fix: ${refusal.fix}`);
121
+ return CALL_EXIT.ERROR;
122
+ }
123
+
124
+ function printTransport(result, what, { json, log, errorLog }) {
125
+ if (result?.auth) {
126
+ if (json) log(JSON.stringify({ ok: false, error: "authentication_failed" }));
127
+ errorLog("✗ BotBuddy could not authenticate this command. Run bb doctor --fix in this worktree (or bb login --tenant <slug>, then bb mcp setup), then retry. Nothing was stored.");
128
+ return CALL_EXIT.AUTH;
129
+ }
130
+ if (json) log(JSON.stringify({ ok: false, error: "transport_unavailable" }));
131
+ errorLog(`✗ BotBuddy did not answer ${what}. Retry the same command; nothing was stored.`);
132
+ return CALL_EXIT.TRANSPORT;
133
+ }
134
+
135
+ export async function cmdReport(args, {
136
+ read = readFile,
137
+ resolveAuth = resolveCallAuth,
138
+ call = callToolJson,
139
+ fetchImpl = fetch,
140
+ git = defaultGit,
141
+ cwd = process.cwd(),
142
+ log = console.log,
143
+ errorLog = console.error,
144
+ } = {}) {
145
+ if (args.length === 0 || ["help", "--help", "-h"].includes(args[0])) {
146
+ (args.length === 0 ? errorLog : log)(REPORT_USAGE);
147
+ return args.length === 0 ? 2 : CALL_EXIT.OK;
148
+ }
149
+ if (args[0] !== "upload") {
150
+ errorLog(`Unknown report command ${args[0]}.\n\n${REPORT_USAGE}`);
151
+ return 2;
152
+ }
153
+ if (args.slice(1).some((a) => ["help", "--help", "-h"].includes(a))) {
154
+ log(REPORT_USAGE);
155
+ return CALL_EXIT.OK;
156
+ }
157
+ const parsed = parseUploadArgs(args.slice(1));
158
+ if (parsed.error) {
159
+ errorLog(`${parsed.error}\n\n${REPORT_USAGE}`);
160
+ return 2;
161
+ }
162
+ const { json } = parsed;
163
+ const out = { json, log, errorLog };
164
+
165
+ let bytes;
166
+ try {
167
+ bytes = await read(parsed.file);
168
+ } catch {
169
+ errorLog(`Could not read ${parsed.file}; nothing was stored.`);
170
+ return 2;
171
+ }
172
+
173
+ const links = [
174
+ ...parsed.ticket.map((ref) => ({ kind: "ticket", ref })),
175
+ ...parsed.release.map((ref) => ({ kind: "release", ref })),
176
+ ];
177
+ if (parsed.pr.length) {
178
+ const repository = parsed.repository ?? originRepository({ cwd, git });
179
+ if (!repository) {
180
+ errorLog("--pr needs a repository: pass --repository <owner/name>, or run from a checkout whose origin is on GitHub. Nothing was stored.");
181
+ return 2;
182
+ }
183
+ for (const ref of parsed.pr) links.push({ kind: "pr", ref: ref.replace(/^#/, ""), repository });
184
+ }
185
+
186
+ const begin = await callTool(BEGIN, {
187
+ filename: basename(parsed.file),
188
+ type: parsed.type ?? "",
189
+ title: parsed.title ?? "",
190
+ size_bytes: bytes.length,
191
+ sha256: sha256Hex(bytes),
192
+ ...(parsed.source_key ? { source_key: parsed.source_key } : {}),
193
+ ...(links.length ? { links } : {}),
194
+ route: "cli",
195
+ }, { resolveAuth, call });
196
+ const b = begin?.data;
197
+ if (begin?.ok && b?.ok === false && typeof b.error === "string") return printRefusal(b, out);
198
+ if (!begin?.ok || b?.ok !== true || typeof b.report_id !== "string" || typeof b.upload?.url !== "string") {
199
+ return printTransport(begin, "the upload start", out);
200
+ }
201
+
202
+ let put;
203
+ try {
204
+ put = await fetchImpl(b.upload.url, {
205
+ method: "PUT",
206
+ headers: { "content-type": "text/html", "x-upsert": "false" },
207
+ body: bytes,
208
+ signal: AbortSignal.timeout(120_000),
209
+ });
210
+ } catch (err) {
211
+ if (json) log(JSON.stringify({ ok: false, error: "upload_failed", report_id: b.report_id }));
212
+ errorLog(`✗ The upload did not reach storage (${err?.message ?? err}). Retry the same command; the unused pending upload is removed after 6 hours.`);
213
+ return CALL_EXIT.TRANSPORT;
214
+ }
215
+ if (!put.ok) {
216
+ const detail = (await put.text().catch(() => "")).slice(0, 300);
217
+ if (json) log(JSON.stringify({ ok: false, error: "upload_failed", status: put.status, report_id: b.report_id }));
218
+ errorLog(`✗ Storage refused the upload (HTTP ${put.status}${detail ? `: ${detail}` : ""}). Nothing was stored.`);
219
+ errorLog(LIMIT_LINE);
220
+ return CALL_EXIT.ERROR;
221
+ }
222
+
223
+ const fin = await callTool(FINALIZE, { report_id: b.report_id, route: "cli" }, { resolveAuth, call });
224
+ const f = fin?.data;
225
+ if (fin?.ok && f?.ok === false && typeof f.error === "string") return printRefusal(f, out);
226
+ if (!fin?.ok || f?.ok !== true || typeof f.url !== "string") {
227
+ return printTransport(fin, `the finalize of report ${b.report_id} (retry: bb call finalize_report_upload --json '{"report_id":"${b.report_id}"}')`, out);
228
+ }
229
+
230
+ const receipt = {
231
+ ok: true,
232
+ report_id: f.report_id,
233
+ tenant: f.tenant,
234
+ type: f.type,
235
+ title: f.title,
236
+ size_bytes: f.size_bytes,
237
+ sha256: f.sha256,
238
+ revision: f.revision,
239
+ links: Array.isArray(f.links) ? f.links : [],
240
+ url: f.url,
241
+ };
242
+ if (json) log(JSON.stringify(receipt));
243
+ else {
244
+ log(`Stored report ${receipt.report_id} in ${receipt.tenant}: ${receipt.title} (${receipt.type}, ${Number(receipt.size_bytes).toLocaleString("en-US")} bytes, sha256 ${receipt.sha256}).`);
245
+ log(receipt.url);
246
+ }
247
+ return CALL_EXIT.OK;
248
+ }