benignswarm 0.12.44 → 0.12.45

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.
@@ -41,6 +41,7 @@ export async function setup(p, out) {
41
41
  const vendor = normalizeVendor(str(p.flags, "vendor") ?? creds.vendor);
42
42
  const root = str(p.flags, "dir") ?? repoRoot();
43
43
  const model = resolveModel(str(p.flags, "model"), process.env, process.cwd(), ref);
44
+ assertVendorMatchesRepo(root, creds.agent, vendor, bool(p.flags, "replace"));
44
45
  if (harnessList(p, vendor).includes("claude-code") && !bool(p.flags, "replace")) {
45
46
  const owner = claudeCheckoutOwner(root);
46
47
  if (owner && owner !== ref && owner !== creds.agent)
@@ -76,6 +77,7 @@ export async function join(p, out) {
76
77
  // A second agent of the same vendor in one worktree must not steal the repo mapping. With
77
78
  // --no-bind the credentials are saved and the agent is addressed per call instead.
78
79
  const noBind = bool(p.flags, "no-bind");
80
+ assertVendorMatchesRepo(root, name, vendor, bool(p.flags, "replace"));
79
81
  // --no-bind keeps the repo's mapping, but for Claude Code the hook still runs as the bound agent
80
82
  // in every session here: a second Claude Code agent needs its own worktree, not --no-bind.
81
83
  if (vendor === "claude-code" && !bool(p.flags, "replace")) {
@@ -114,7 +116,7 @@ export async function join(p, out) {
114
116
  ? `Joined project "${json.project.name}" as agent "${name}" (${vendor})${json.agent.role_name ? ` with role ${json.agent.role_name}` : ""}.`
115
117
  : `Joined as account-wide agent "${name}" (${vendor}) with role ${json.agent.role_name}. Project commands take --project <name>; see them with: bschat me`,
116
118
  `Credentials saved to ${path} (private to this machine).`,
117
- `bschat ${inst.version} is installed for this machine at ${inst.bin}; the hook, the repo instructions and watchers all use it. Upgrade with: bschat install --latest`,
119
+ `bschat ${inst.version} is installed for this machine at ${inst.bin}; the hook, the repo instructions and watchers all use it. Upgrade with: bschat update`,
118
120
  noBind
119
121
  ? `This repo's ${vendor} identity was left as is. Address yourself on every call: \`bschat --as ${ref} <command>\` or \`BSCHAT_AGENT=${ref} bschat <command>\`. Never run bare bschat here as ${name}.`
120
122
  : `This repo now maps ${vendor} -> ${ref} in ${idPath}, so bschat commands here know who you are, even after a reboot.`,
@@ -150,6 +152,20 @@ function verifyClaudeHook(root, ref) {
150
152
  }
151
153
  return `Hook verified: ran "${cmd}" successfully as ${ref}.`;
152
154
  }
155
+ /**
156
+ * Refuses when this repo's identity file already says the agent runs in another harness than the
157
+ * one detected (or passed). Learned from fabricbios: sol-reviewer, mapped as the Codex agent in the
158
+ * repo, was saved as Claude Code by a join run where Claude Code's environment was set, so it got
159
+ * no watcher and no thread binding and stalled with three reviews waiting.
160
+ */
161
+ export function assertVendorMatchesRepo(root, name, vendor, replace) {
162
+ const p = findIdentityFile(root);
163
+ if (!p || !p.startsWith(root) || replace)
164
+ return;
165
+ const mapped = Object.entries(readIdentityFile(p).agents).filter(([v, a]) => a.name === name && v !== vendor).map(([v]) => v);
166
+ if (mapped.length)
167
+ throw new CliError("vendor_mismatch", `${p} says ${name} runs in ${mapped.join(" and ")} here, but this command detected ${vendor}`, `If ${name} runs in ${mapped[0]}, run this from that harness or pass --vendor ${mapped[0]}. If the file is wrong, pass --replace.`);
168
+ }
153
169
  /** This machine's one install, at least this CLI's version (installed or upgraded when needed). */
154
170
  function machineInstall() {
155
171
  return ensureInstall(CLI_VERSION, (m) => process.stderr.write(`bschat: ${m}\n`));
@@ -151,6 +151,10 @@ export async function wu(p, out) {
151
151
  pushed = remote === null ? (fetchRef(where.branch) ? false : null) : remote === local;
152
152
  if (pushed === false && def.merge.require_pushed)
153
153
  throw new CliError("not_pushed", `${where.branch} is not pushed at ${local?.slice(0, 9)} (origin has ${remote ? remote.slice(0, 9) : "no such branch"})`, `git push -u origin ${where.branch}, then submit again`);
154
+ // Not required here, but a reviewer working from origin (bschat wu review, another machine)
155
+ // cannot fetch it, unless the commit is already on the target (then the branch adds nothing).
156
+ if (pushed === false && !def.merge.require_pushed && isAncestor("HEAD", fetchRef(unitTarget) ? "FETCH_HEAD" : `origin/${unitTarget}`) !== true)
157
+ process.stderr.write(`bschat: ${where.branch} is not on origin at ${local?.slice(0, 9)}: bschat wu review and reviewers on other machines cannot fetch it. git push -u origin ${where.branch}\n`);
154
158
  }
155
159
  }
156
160
  const pr = str(p.flags, "pr") ?? null;
@@ -304,17 +308,33 @@ export async function wu(p, out) {
304
308
  const parent = repoParent();
305
309
  if (!name || !parent)
306
310
  throw new CliError("not_a_repo", "run wu review from a checkout of the project's repository");
307
- if (!fetchRef(unit.branch))
308
- throw new CliError("fetch_failed", `cannot fetch ${unit.branch} from origin`, `Is it pushed? Ask ${unit.owner_name}: git push -u origin ${unit.branch}`);
309
- const remote = fullSha("FETCH_HEAD");
310
- if (!remote)
311
- throw new CliError("fetch_failed", `fetched ${unit.branch} but found no commit`);
312
- if (!remote.startsWith(unit.head))
313
- throw new CliError("head_mismatch", `origin/${unit.branch} is at ${remote.slice(0, 9)} but WU #${n} was submitted at ${unit.head}`, `Either the owner pushed more since submitting (ask for a resubmit) or has not pushed the submitted commit.`);
311
+ // A unit that added no commits (an audit or a diagnosis whose output is evidence) was
312
+ // submitted at a commit already on origin's target: review that commit, no branch needed.
313
+ // Learned from fabricbios: three audits sat behind "cannot fetch the branch" though their
314
+ // head was already on origin/main.
315
+ const target = unit.target ?? (await processDef()).merge.target_branch;
316
+ let remote = null;
317
+ let onTarget = false;
318
+ if (fetchRef(target)) {
319
+ const head = fullSha(unit.head);
320
+ if (head && isAncestor(head, "FETCH_HEAD")) {
321
+ remote = head;
322
+ onTarget = true;
323
+ }
324
+ }
325
+ if (!remote) {
326
+ if (!fetchRef(unit.branch))
327
+ throw new CliError("fetch_failed", `cannot fetch ${unit.branch} from origin`, `Is it pushed? Ask ${unit.owner_name}: git push -u origin ${unit.branch}`);
328
+ remote = fullSha("FETCH_HEAD");
329
+ if (!remote)
330
+ throw new CliError("fetch_failed", `fetched ${unit.branch} but found no commit`);
331
+ if (!remote.startsWith(unit.head))
332
+ throw new CliError("head_mismatch", `origin/${unit.branch} is at ${remote.slice(0, 9)} but WU #${n} was submitted at ${unit.head}`, `Either the owner pushed more since submitting (ask for a resubmit) or has not pushed the submitted commit.`);
333
+ }
314
334
  const path = resolve(parent, `${name}-review-wu${n}`);
315
335
  const made = ensureReviewWorktree(path, remote);
316
336
  const ev = unit.evidence.map((e) => `evidence:${e}`).join(" ") || "(none)";
317
- out.print(`${fmt(unit)}\nReview checkout: ${path} (detached at ${remote.slice(0, 9)}${made.created ? "" : ", already there"})\n cd ${path}\nEvidence: ${ev} (bschat evidence get <id>)\nVerdict: bschat wu approve ${n} --note "..." | bschat wu changes ${n} --note "..."\nWhen finished: git worktree remove ${path}`, { unit, worktree: path, head: remote });
337
+ out.print(`${fmt(unit)}\nReview checkout: ${path} (detached at ${remote.slice(0, 9)}${made.created ? "" : ", already there"})${onTarget ? `\nThe submitted commit is already on origin/${target}: the unit added no commits, so its evidence is the work.` : ""}\n cd ${path}\nEvidence: ${ev} (bschat evidence get <id>)\nVerdict: bschat wu approve ${n} --note "..." | bschat wu changes ${n} --note "..."\nWhen finished: git worktree remove ${path}`, { unit, worktree: path, head: remote });
318
338
  return;
319
339
  }
320
340
  case "show": {
package/dist/help.js CHANGED
@@ -100,6 +100,7 @@ Agent commands
100
100
  --env A,B copies those variables from this shell into the LaunchAgent (Antigravity needs
101
101
  ANTIGRAVITY_LS_ADDRESS,ANTIGRAVITY_CSRF_TOKEN). --full queues the text itself. --once / --launchd.
102
102
  Codex: bschat watch --exec "codex queue --thread <id> --message {summary}" --launchd
103
+ bschat update the same as install --latest: upgrade this machine's bschat and restart its watchers
103
104
  bschat install [<version> | --latest] make or upgrade this machine's one bschat (join does it once) and restart
104
105
  the watchers on it; hooks, repo instructions and watchers all run its path
105
106
  bschat doctor every bschat on this machine and who runs which (PATH, npx caches, this repo's
package/dist/index.js CHANGED
@@ -54,6 +54,8 @@ const COMMANDS = {
54
54
  antigravity,
55
55
  codex,
56
56
  install,
57
+ // `update` is the word people reach for: the same as install, latest unless a version is named.
58
+ update: (p, out) => install(p.positionals[1] ? p : { ...p, flags: { ...p.flags, latest: true } }, out),
57
59
  doctor,
58
60
  wu,
59
61
  process: processCmd,
package/dist/update.js CHANGED
@@ -39,5 +39,5 @@ export function noteServerVersions(headers, agent) {
39
39
  catch {
40
40
  /* unwritable state dir: notice simply repeats next time */
41
41
  }
42
- process.stderr.write(`[bschat] CLI ${CLI_VERSION} is installed, ${latest} is available: bschat install --latest (updates this machine's one install and restarts its watchers)\n`);
42
+ process.stderr.write(`[bschat] CLI ${CLI_VERSION} is installed, ${latest} is available: bschat update (upgrades this machine's one install and restarts its watchers)\n`);
43
43
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.44";
1
+ export const CLI_VERSION = "0.12.45";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.44",
3
+ "version": "0.12.45",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {