benignswarm 0.12.71 → 0.12.72

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/dist/args.js CHANGED
@@ -1,18 +1,35 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { CliError } from "./errors.js";
3
+ // These options accept comma-separated collections, so repeating them should
4
+ // append another collection instead of discarding earlier values.
5
+ export const LIST_FLAGS = ["tags", "projects", "evidence", "statuses", "depends-on", "units", "waits-on", "needs", "exclude", "remove", "post", "harness", "variant"];
3
6
  export const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "unacked-after", "category", "command", "follow-delay", "env", "scope", "pr", "note", "add", "remove", "merged", "tag", "activity", "max-unanswered", "to", "replay-of", "branch", "effort", "by", "target", "milestone", "file", "exit", "depends-on", "source", "by", "on", "question", "ruling", "gaps", "unit", "units", "blocks", "sla", "takeover", "max-open", "max-in-progress", "require-scope", "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit", "require-pushed", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email", "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on", "sandbox", "thread", "turn-timeout", "session", "plain", "if-yes", "if-no", "ssh", "variant", "count", "needs", "min-ram", "exclude", "carry", "from", "to-ssh", "wait", "writable"];
4
7
  export const BOOL_FLAGS = ["latest", "no-restart", "json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind", "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive", "approve", "turn", "service", "print-hooks", "create", "rotate", "codex-userns", "bwrap-userns", "print-apparmor"];
5
8
  export function parse(argv) {
6
9
  const options = {};
7
10
  for (const f of STRING_FLAGS)
8
- options[f] = { type: "string" };
11
+ options[f] = { type: "string", ...(LIST_FLAGS.includes(f) ? { multiple: true } : {}) };
9
12
  for (const f of BOOL_FLAGS)
10
13
  options[f] = { type: "boolean" };
11
14
  try {
15
+ const seen = new Set();
16
+ for (const arg of argv) {
17
+ if (!arg.startsWith("--"))
18
+ continue;
19
+ const name = arg.slice(2).split("=", 1)[0].replace(/^no-/, "");
20
+ if (!(name in options) || LIST_FLAGS.includes(name))
21
+ continue;
22
+ if (seen.has(name))
23
+ throw new CliError("usage", `--${name} was repeated; it may only be given once`);
24
+ seen.add(name);
25
+ }
12
26
  const { values, positionals } = parseArgs({ args: argv, options, allowPositionals: true, strict: true });
13
- return { positionals, flags: values };
27
+ const flags = values;
28
+ return { positionals, flags: Object.fromEntries(Object.entries(flags).map(([k, v]) => [k, Array.isArray(v) ? v.join(",") : v])) };
14
29
  }
15
30
  catch (e) {
31
+ if (e instanceof CliError)
32
+ throw e;
16
33
  throw new CliError("usage", e.message, "Run: bschat --help");
17
34
  }
18
35
  }
@@ -127,7 +127,13 @@ export async function harnessStart(p, out, harness) {
127
127
  // The result goes to a file the watcher reads when the turn ends: Claude Code can exit 0 with is_error set.
128
128
  : `${shq(bin)} -p {text} ${[...settings, "--resume", session, "--output-format", "json"].map(shq).join(" ")} > ${shq(claudeResultFile(ref))}`;
129
129
  const watcherOut = [];
130
- installWatcherService(ref, exec, interval, Number(str(p.flags, "follow-delay") ?? "300"), {}, undefined, { json: false, print: (h) => watcherOut.push(h) }, bool(p.flags, "prune"), { harness, session, timeout: turnTimeout });
130
+ // Scratch space beside the checkout, not the system's /tmp: on a machine the checkout lives on the
131
+ // work volume, the folder is inside what the sandbox may write, and it survives a reboot. Learned
132
+ // from ronald, whose root volume filled with agents' builds under /tmp (46 GB) while the work
133
+ // volume had 750 GB free, and which empties /tmp at every boot.
134
+ const tmp = sessionTmpDir(process.cwd(), creds.agent);
135
+ mkdirSync(tmp, { recursive: true });
136
+ installWatcherService(ref, exec, interval, Number(str(p.flags, "follow-delay") ?? "300"), { TMPDIR: tmp }, undefined, { json: false, print: (h) => watcherOut.push(h) }, bool(p.flags, "prune"), { harness, session, timeout: turnTimeout });
131
137
  const wl = watcherOut.join("\n").split("\n");
132
138
  lines.push(wl[0].replace(/^Wrote /, "Watcher: wrote "), ...wl.filter((l) => l.startsWith("Linger is off")));
133
139
  // 5. Hooks.
@@ -187,6 +193,8 @@ export function codexSettings(sandbox, model, effort, cwd, bschatHome, extraWrit
187
193
  : []),
188
194
  ];
189
195
  }
196
+ /** A session's scratch folder: `<checkout's parent>/.tmp/<agent>`, on the checkout's volume. */
197
+ export const sessionTmpDir = (cwd, agent) => joinPath(dirname(cwd), ".tmp", agent);
190
198
  /**
191
199
  * The agent's own linked-worktree git folder (<clone>/.git/worktrees/<name>), when it runs in one.
192
200
  * Codex's sandbox makes the git folder of the directory it runs in read-only, and for a linked
@@ -125,7 +125,7 @@ export async function gatherUpdates(name, opts) {
125
125
  const proj = creds.project ? "" : "--project <project> ";
126
126
  const footer = [];
127
127
  if (messages.length)
128
- footer.push(`These agents addressed you directly. Answer them in chat: bschat send ${proj}<channel> --reply-to <seq> "...". A one-line acknowledgement is enough when there is nothing to add.`);
128
+ footer.push(`These agents addressed you directly. Answer them in chat: bschat send ${proj}<channel> --reply-to <seq> "...".`);
129
129
  if (followed.length && !messages.length)
130
130
  footer.push(`Nobody addressed you. Reply in chat only if you have something to contribute: bschat send ${proj}<channel> --reply-to <seq> "...".`);
131
131
  if (messages.length || followed.length)
@@ -29,8 +29,9 @@ function writeMachineState(s) {
29
29
  /**
30
30
  * Bumped when `bschat start` builds a session's settings differently, so every session is started
31
31
  * again once with them. 2: the agent's own worktree git folder is writable under workspace-write.
32
+ * 3: turns get TMPDIR beside the checkout instead of the system's /tmp.
32
33
  */
33
- const START_REV = 2;
34
+ const START_REV = 3;
34
35
  export const sessionFingerprint = (s, writable = []) => JSON.stringify([s.harness, s.dir, s.sandbox, s.model, s.effort, s.turn_timeout, ...(writable.length ? [writable] : []), ...(START_REV > 1 ? [`rev${START_REV}`] : [])]);
35
36
  export const watchLabelOf = (ref) => `${WATCH_LABEL_PREFIX}${ref.replace("/", ".")}`;
36
37
  /** The `bschat start` arguments that bring a session up (adopting its thread or session when known). */
@@ -23,10 +23,25 @@ import { table } from "../output.js";
23
23
  * bschat wu done <n> --merged <sha> after approval; the sha is checked against the target branch
24
24
  * bschat wu abandon <n> [--note ...]
25
25
  * bschat wu note <n> --note "..." [--evidence id]
26
+ * bschat wu evidence replace <n> <old> <new> [--note "why"]
26
27
  * bschat wu list [--all] [--status s] [--tag t] [--agent name]
27
28
  * bschat wu show <n>
28
29
  * bschat process vocabulary, who reviews what, requirements, agreements
29
30
  */
31
+ export function parseEvidenceReplacement(positionals) {
32
+ if (positionals[2] !== "replace")
33
+ throw new CliError("usage", "wu evidence replace <n> <old> <new> [--note \"why\"]");
34
+ const unit = Number(positionals[3]);
35
+ const oldId = positionals[4]?.replace(/^evidence:/, "");
36
+ const newId = positionals[5]?.replace(/^evidence:/, "");
37
+ if (!Number.isInteger(unit) || unit < 1 || !oldId || !newId)
38
+ throw new CliError("usage", "wu evidence replace <n> <old> <new> [--note \"why\"]");
39
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(newId))
40
+ throw new CliError("usage", `${JSON.stringify(newId)} is not a replacement evidence id (expected the uuid from bschat evidence post)`);
41
+ if (oldId === newId)
42
+ throw new CliError("usage", "the replacement evidence id must differ from the old id");
43
+ return { unit, oldId, newId };
44
+ }
30
45
  export async function wu(p, out) {
31
46
  const sub = p.positionals[1];
32
47
  const name = resolveAgentName(str(p.flags, "as"));
@@ -294,6 +309,12 @@ export async function wu(p, out) {
294
309
  out.print(fmt(r.unit) + cleanupUnitWorktree(r.unit.worktree, await processDef(), !!p.flags["keep-worktree"]), r);
295
310
  return;
296
311
  }
312
+ case "evidence": {
313
+ const { unit, oldId, newId } = parseEvidenceReplacement(p.positionals);
314
+ const r = await client.call("POST", `${base}/${unit}/evidence/replace`, { old: oldId, new: newId, note: str(p.flags, "note") ?? "" });
315
+ out.print(fmt(r.unit), r);
316
+ return;
317
+ }
297
318
  case "note": {
298
319
  const r = await client.call("POST", `${base}/${num()}/note`, { note: str(p.flags, "note") ?? "", evidence: list("evidence") });
299
320
  out.print(fmt(r.unit), r);
@@ -474,14 +495,18 @@ function prepareWorktree(n, unit, def, p, exclude = []) {
474
495
  const path = resolve(parent, `${name}-wu${n}`);
475
496
  // A replay starts from the target branch as it was when the original was opened: the same ground, none of the original's work.
476
497
  if (unit.replay?.created_at) {
477
- const at = commitAtTime(target, unit.replay.created_at);
498
+ const at = replayBaseRef(baseRef, unit.replay.created_at);
478
499
  if (!at)
479
- throw new CliError("no_base", `cannot find ${target} as of ${unit.replay.created_at} for the replay`, `git fetch origin ${target}:${target} then try again`);
500
+ throw new CliError("no_base", `cannot find ${baseRef} as of ${unit.replay.created_at} for the replay`, `git fetch origin ${target} then try again`);
480
501
  baseRef = at;
481
502
  }
482
503
  ensureWorktree(path, branch, baseRef, process.cwd(), log, exclude);
483
504
  return { mode: "fresh", path, branch };
484
505
  }
506
+ /** Select the replay commit from the same target ref used to create its worktree. */
507
+ export function replayBaseRef(baseRef, createdAt, cwd = process.cwd()) {
508
+ return commitAtTime(baseRef, createdAt, cwd);
509
+ }
485
510
  /** The plan's slices: readiness, dependencies, unit counts. */
486
511
  export async function milestones(p, out) {
487
512
  const name = resolveAgentName(str(p.flags, "as"));
package/dist/config.js CHANGED
@@ -144,8 +144,22 @@ export function resolveAgentName(asFlag, env = process.env, cwd = process.cwd())
144
144
  const vendor = detectVendor(env);
145
145
  if (file && vendor) {
146
146
  const entry = readIdentityFile(file).agents[vendor];
147
- if (entry)
148
- name = entry.project !== undefined ? `${entry.project ?? ACCOUNT_SCOPE}/${entry.name}` : entry.name;
147
+ if (entry) {
148
+ const mapped = entry.project !== undefined ? `${entry.project ?? ACCOUNT_SCOPE}/${entry.name}` : entry.name;
149
+ // Other saved identities of this vendor in the same project are the agents that could be
150
+ // sharing this checkout. The project comes from the identity file, so this works before
151
+ // the mapped agent's own credentials are saved (login, setup).
152
+ const scope = entry.project !== undefined ? (entry.project ?? ACCOUNT_SCOPE) : null;
153
+ const others = listSaved("agents", env).filter((ref) => {
154
+ if (ref === mapped || scope === null || splitRef(ref).scope !== scope)
155
+ return false;
156
+ return loadAgent(ref, env).vendor === vendor;
157
+ });
158
+ if (others.length) {
159
+ throw new CliError("ambiguous_vendor_identity", `this checkout maps ${vendor} to ${mapped}, but other saved ${vendor} identities also exist: ${others.join(", ")}`, `Say which agent you are on every call: --as <project>/<name>, or set BSCHAT_AGENT=<project>/<name> in the harness's persistent environment. An export in one tool call does not reach the next.`);
160
+ }
161
+ name = mapped;
162
+ }
149
163
  }
150
164
  }
151
165
  if (!name) {
package/dist/help.js CHANGED
@@ -30,7 +30,7 @@ Agent commands
30
30
  bschat follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
31
31
  other channels appear as a one-line unread digest
32
32
  bschat process the project's process: tag vocabulary, who reviews what, requirements, agreements
33
- bschat wu open "<title>" --scope "..." [--tags a,b] [--evidence id] [--target <branch>] [--here] open a work unit in its own
33
+ bschat wu open "<title>" --scope "..." [--tags a,b] [--evidence id[,id...] ...] [--target <branch>] [--here] open a work unit in its own
34
34
  worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
35
35
  process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
36
36
  bschat wu assign "<title>" --to <agent|auto|queue> --scope ".." [--tags a,b] [--replay-of n] hand out a unit (assigner roles);
@@ -64,7 +64,7 @@ Agent commands
64
64
  bschat unlock <name> | bschat locks release it (also released when your unit closes); see holders and queues
65
65
  (refused while it has units not done); milestone reopen <key> undoes it
66
66
  Global: --effort <high|medium|low|...> reasoning effort to report (else BSCHAT_EFFORT, CLAUDE_EFFORT, codex model_reasoning_effort)
67
- bschat wu submit <n> [--evidence id] [--pr url] ask for review; routed to whoever is qualified for the tags (in review: refreshes the head, approvals cleared)
67
+ bschat wu submit <n> [--evidence id[,id...] ...] [--pr url] ask for review; repeat --evidence or pass comma-separated ids; routed to whoever is qualified for the tags (in review: refreshes the head, approvals cleared)
68
68
  bschat wu review <n> reviewer's checkout: fetch the submitted branch from origin and open
69
69
  ../<repo>-review-wu<n> detached at the submitted head (refused if origin differs)
70
70
  bschat wu approve <n> --note ".." your approval covers the tags your role reviews; classify <n> --tags a,b
@@ -87,6 +87,7 @@ Agent commands
87
87
  bschat wu explain <n> "..." the same for a unit's question waiting on the operator
88
88
  --propose: your recommended answer, phrased so they can approve it as written
89
89
  bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
90
+ bschat wu evidence replace <n> <old> <new> [--note ".."] owner replaces attached evidence; old id is retained in the unit history
90
91
  bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies the sha is on the target; removes the unit's clean worktree
91
92
  bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
92
93
  bschat worktrees prune [--yes] [--archive] remove clean worktrees whose work landed or whose unit is closed (dry run without --yes);
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.71";
1
+ export const CLI_VERSION = "0.12.72";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.71",
3
+ "version": "0.12.72",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {