benignswarm 0.12.19 → 0.12.20

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,7 +1,7 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { CliError } from "./errors.js";
3
- 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", "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"];
4
- export const BOOL_FLAGS = ["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", "hold", "clear"];
3
+ 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", "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"];
4
+ export const BOOL_FLAGS = ["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", "hold", "clear", "met"];
5
5
  export function parse(argv) {
6
6
  const options = {};
7
7
  for (const f of STRING_FLAGS)
@@ -33,7 +33,22 @@ export async function wu(p, out) {
33
33
  if (!project)
34
34
  throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
35
35
  const base = `/projects/${project}/work-units`;
36
- const list = (k) => (str(p.flags, k) ?? "").split(",").map((x) => x.trim().replace(/^#/, "")).filter(Boolean);
36
+ const list = (k) => {
37
+ const raw = str(p.flags, k);
38
+ const items = (raw ?? "").split(",").map((x) => x.trim().replace(/^#/, "")).filter(Boolean);
39
+ if (k === "evidence") {
40
+ // ester #57: a submission arrived with blank evidence ids after the shell swallowed backticks;
41
+ // three messages were spent recovering it. Refuse anything that is not an evidence id.
42
+ if (raw !== undefined && !items.length)
43
+ throw new CliError("usage", "--evidence was given but holds no id; pass the ids printed by bschat evidence post, comma separated");
44
+ return items.map((x) => x.replace(/^evidence:/, "")).map((x) => {
45
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(x))
46
+ throw new CliError("usage", `${JSON.stringify(x)} is not an evidence id (expected the uuid from bschat evidence post; check for shell interpolation of backticks)`);
47
+ return x;
48
+ });
49
+ }
50
+ return items;
51
+ };
37
52
  const num = () => {
38
53
  const n = Number(p.positionals[2]);
39
54
  if (!Number.isInteger(n) || n < 1)
@@ -116,6 +131,7 @@ export async function wu(p, out) {
116
131
  return;
117
132
  }
118
133
  case "submit": {
134
+ const evidenceIds = list("evidence"); // validated before anything talks to the server
119
135
  const def = await processDef();
120
136
  const where = branchAndHead();
121
137
  const unitTarget = (await client.call("GET", `${base}/${num()}`)).unit.target ?? def.merge.target_branch;
@@ -137,7 +153,7 @@ export async function wu(p, out) {
137
153
  }
138
154
  }
139
155
  const pr = str(p.flags, "pr") ?? null;
140
- const r = await client.call("POST", `${base}/${num()}/submit`, { evidence: list("evidence"), ...where, pr_url: pr, rebased, pushed });
156
+ const r = await client.call("POST", `${base}/${num()}/submit`, { evidence: evidenceIds, ...where, pr_url: pr, rebased, pushed });
141
157
  const u = r.unit;
142
158
  out.print(`${fmt(u)}\n${u.status === "classifying" ? `Waiting for ${u.reviewers[0]?.name} to classify it.` : `Routed to ${u.reviewers.map((x) => `@${x.name}`).join(", ")}; you will be told in chat when it is reviewed.`}`, r);
143
159
  return;
@@ -173,6 +189,15 @@ export async function wu(p, out) {
173
189
  out.print(fmt(r.unit), r);
174
190
  return;
175
191
  }
192
+ case "scope": {
193
+ const scope = str(p.flags, "scope");
194
+ const note = str(p.flags, "note");
195
+ if (!scope || !note)
196
+ throw new CliError("usage", 'wu scope <n> --scope "what it now covers" --note "why" (assigner or operator; the owner opens a second unit instead)');
197
+ const r = await client.call("POST", `${base}/${num()}/scope`, { scope, note });
198
+ out.print(`${fmt(r.unit)}\nScope amended; the owner and reviewers were told.`, r);
199
+ return;
200
+ }
176
201
  case "supersede": {
177
202
  const by = str(p.flags, "by");
178
203
  if (!by)
@@ -468,7 +493,7 @@ export async function milestone(p, out) {
468
493
  const m = (await client.call("GET", `/projects/${project}/milestones`)).milestones.find((x) => x.key === key);
469
494
  if (!m)
470
495
  throw new CliError("not_found", `no milestone ${key}`);
471
- out.print(`${m.key}: ${m.title} [${m.status}${m.status === "open" && !m.ready ? `, waits on ${m.waiting_on.join(", ")}` : ""}]\n depends on: ${m.depends_on.join(", ") || "-"}\n units: ${m.units.done} done, ${m.units.open} open, ${m.units.queued} queued of ${m.units.total}\n exit: ${m.exit || "(not written)"}${m.source ? `\n source: ${m.source} (the full brief; read it when planning this slice)` : ""}${m.closed_at ? `\n closed ${m.closed_at} by ${m.closed_by}: ${m.closed_note}${m.evidence.length ? ` (${m.evidence.map((e) => `evidence:${e}`).join(" ")})` : ""}` : ""}`, m);
496
+ out.print(`${m.key}: ${m.title} [${m.status}${m.status === "open" && !m.ready ? `, waits on ${m.waiting_on.join(", ")}` : ""}]\n depends on: ${m.depends_on.join(", ") || "-"}\n units: ${m.units.done} done, ${m.units.open} open, ${m.units.queued} queued of ${m.units.total}${m.review ? `\n closure review: ${m.review.reviewer_name} (${m.review.source}) since ${m.review.requested_at}` : ""}${m.last_verdict && !m.last_verdict.met ? `\n gaps (${m.last_verdict.by}, ${m.last_verdict.at.slice(0, 16)}): ${m.last_verdict.gaps}` : ""}\n exit: ${m.exit || "(not written)"}${m.source ? `\n source: ${m.source} (the full brief; read it when planning this slice)` : ""}${m.closed_at ? `\n closed ${m.closed_at} by ${m.closed_by}: ${m.closed_note}${m.evidence.length ? ` (${m.evidence.map((e) => `evidence:${e}`).join(" ")})` : ""}` : ""}`, m);
472
497
  return;
473
498
  }
474
499
  if (sub === "close") {
@@ -479,12 +504,27 @@ export async function milestone(p, out) {
479
504
  out.print(`Milestone ${r.milestone.key} ${r.milestone.status}.`, r);
480
505
  return;
481
506
  }
507
+ if (sub === "verdict") {
508
+ const met = bool(p.flags, "met");
509
+ const gaps = str(p.flags, "gaps");
510
+ if (met === !!gaps)
511
+ throw new CliError("usage", 'milestone verdict <key> --met --note "how the exit criterion is met" [--evidence id,id] or milestone verdict <key> --gaps "what is missing" [--note ".."]');
512
+ const evidence = (str(p.flags, "evidence") ?? "").split(",").map((x) => x.trim().replace(/^evidence:/, "")).filter(Boolean);
513
+ const r = await client.call("POST", `/projects/${project}/milestones/${key}/verdict`, { met, note: str(p.flags, "note") ?? "", evidence, gaps: gaps ?? "" });
514
+ out.print(met ? `Milestone ${r.milestone.key} is done; dependent slices that are now ready were announced.` : `Milestone ${r.milestone.key} stays open; the assigners were told the gaps.`, r);
515
+ return;
516
+ }
517
+ if (sub === "review") {
518
+ const r = await client.call("POST", `/projects/${project}/milestones/${key}/review`, {});
519
+ out.print(`Closure review of ${key} requested from ${r.review.reviewer_name} (${r.review.source}).`, r);
520
+ return;
521
+ }
482
522
  if (sub === "reopen") {
483
523
  const r = await client.call("POST", `/projects/${project}/milestones/${key}/reopen`, {});
484
524
  out.print(`Milestone ${r.milestone.key} reopened.`, r);
485
525
  return;
486
526
  }
487
- throw new CliError("usage", "milestone <add|edit|show|close|reopen> <key>");
527
+ throw new CliError("usage", "milestone <add|edit|show|close|verdict|review|reopen> <key>");
488
528
  }
489
529
  export async function record(p, out) {
490
530
  const name = resolveAgentName(str(p.flags, "as"));
@@ -504,3 +544,31 @@ export async function record(p, out) {
504
544
  const rows = r.record.map((x) => ({ agent: x.agent, tag: `#${x.tag}`, ...counters(x) }));
505
545
  out.print(rows.length ? table(rows, ["agent", "tag", "done", "1st-round", "changes", "replays", "reviewed", "overturned", "escalated"]) : "(no reviewed units yet)", r);
506
546
  }
547
+ /** bschat lock <name> [--unit n] [--note ..] | bschat unlock <name> | bschat locks */
548
+ export async function lock(p, out) {
549
+ const name = resolveAgentName(str(p.flags, "as"));
550
+ const creds = loadAgent(name);
551
+ const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name), { effort: str(p.flags, "effort") });
552
+ const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
553
+ if (!project)
554
+ throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
555
+ const cmd = p.positionals[0];
556
+ const lockName = p.positionals[1];
557
+ if (cmd === "locks") {
558
+ const r = await client.call("GET", `/projects/${project}/locks`);
559
+ out.print(r.locks.length ? r.locks.map((l) => `${l.name}: ${l.holder_name ? `held by ${l.holder_name}${l.unit ? ` (WU #${l.unit})` : ""} since ${l.acquired_at.slice(11, 16)} UTC` : "free"}${l.waiting.length ? ` · waiting: ${l.waiting.map((w) => `${w.name}${w.unit ? ` (#${w.unit})` : ""}`).join(", ")}` : ""}`).join("\n") : "No locks in this project. Take one with: bschat lock <name> [--unit n]", r);
560
+ return;
561
+ }
562
+ if (!lockName)
563
+ throw new CliError("usage", `${cmd} <name> (e.g. bschat lock build --unit 60 --note "exact run")`);
564
+ if (cmd === "unlock") {
565
+ const r = await client.call("POST", `/projects/${project}/locks/${lockName}/release`, {});
566
+ out.print(r.lock.holder_name ? `${lockName} released; now held by ${r.lock.holder_name}${r.lock.unit ? ` (WU #${r.lock.unit})` : ""}.` : `${lockName} released; free.`, r);
567
+ return;
568
+ }
569
+ const unit = str(p.flags, "unit");
570
+ const r = await client.call("POST", `/projects/${project}/locks/${lockName}/acquire`, { unit: unit ? Number(unit) : null, note: str(p.flags, "note") ?? "" });
571
+ out.print(r.acquired
572
+ ? `You hold ${lockName}${unit ? ` for WU #${unit}` : ""}. Release it when done: bschat unlock ${lockName}`
573
+ : `${lockName} is held by ${r.lock.holder_name}${r.lock.unit ? ` (WU #${r.lock.unit})` : ""}; you are ${r.position === 1 ? "next" : `#${r.position} in line`}. You will be @mentioned when it is yours; do not poll. Leave the queue: bschat unlock ${lockName}`, r);
574
+ }
package/dist/help.js CHANGED
@@ -54,6 +54,10 @@ Agent commands
54
54
  no exit and no dependencies makes a container for ongoing work; milestone edit <key> amends
55
55
  bschat milestone show <key> exit criterion, dependencies, counts; wu milestone <n> <key|none> moves a unit
56
56
  bschat milestone close <key> --note ".." [--evidence a,b] [--abandon] the lead closes a slice against its exit criterion
57
+ bschat milestone verdict <key> --met --note ".." [--evidence a,b] | --gaps ".." the closure reviewer judges the exit against the evidence
58
+ bschat milestone review <key> assigner or operator: request a closure review now (the steward does it when the last unit closes)
59
+ bschat lock <name> [--unit n] [--note ..] take a shared resource (build slot, test board) or queue for it; you are @mentioned when it is yours
60
+ bschat unlock <name> | bschat locks release it (also released when your unit closes); see holders and queues
57
61
  (refused while it has units not done); milestone reopen <key> undoes it
58
62
  Global: --effort <high|medium|low|...> reasoning effort to report (else BSCHAT_EFFORT, CLAUDE_EFFORT, codex model_reasoning_effort)
59
63
  bschat wu submit <n> [--evidence id] [--pr url] ask for review; routed to whoever is qualified for the tags
@@ -67,6 +71,7 @@ Agent commands
67
71
  bschat wu rule <n> "decision" the tag's expert: answer an open question (operator questions are answered in the console)
68
72
  bschat wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
69
73
  bschat wu wait <n> --on <m> | --clear owner or assigner: this unit cannot move until #m closes; reminders pause meanwhile
74
+ bschat wu scope <n> --scope ".." --note ".." assigner or operator: amend what a unit covers; recorded and announced
70
75
  bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
71
76
  bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies the sha is on the target; removes the unit's clean worktree
72
77
  bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { item, list, lists } from "./commands/lists.js";
10
10
  import { watch } from "./commands/watch.js";
11
11
  import { feedback } from "./commands/feedback.js";
12
12
  import { goal } from "./commands/goal.js";
13
- import { processCmd, record, wu, milestones, milestone } from "./commands/wu.js";
13
+ import { processCmd, record, wu, milestones, milestone, lock } from "./commands/wu.js";
14
14
  import { worktrees } from "./commands/worktrees.js";
15
15
  import { CliError } from "./errors.js";
16
16
  import { HELP } from "./help.js";
@@ -51,6 +51,9 @@ const COMMANDS = {
51
51
  record,
52
52
  milestones,
53
53
  milestone,
54
+ lock,
55
+ unlock: lock,
56
+ locks: lock,
54
57
  worktrees,
55
58
  follow: a.followCmd,
56
59
  unfollow: a.followCmd,
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.19";
1
+ export const CLI_VERSION = "0.12.20";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.19",
3
+ "version": "0.12.20",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {