benignswarm 0.12.21 → 0.12.23

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,6 +1,6 @@
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", "gaps", "unit"];
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", "units", "blocks"];
4
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", "shared"];
5
5
  export function parse(argv) {
6
6
  const options = {};
@@ -281,16 +281,33 @@ export async function activity(p, out) {
281
281
  qs.set("after", after);
282
282
  const accountWide = bool(p.flags, "account") || (!creds.project && !str(p.flags, "project") && !process.env.BSCHAT_PROJECT);
283
283
  const r = await client.call("GET", accountWide ? `/account/activity?${qs}` : `/projects/${projectOf(p, creds)}/activity?${qs}`);
284
- const lines = r.events.map((e) => {
285
- const pfx = `${e.at.slice(11, 19)} ${e.project ? `[${e.project}] ` : accountWide ? "[account] " : ""}`;
286
- if (e.kind === "message")
287
- return `${pfx}#${e.message.channel} ${e.message.agent_name}: ${e.message.body}${e.message.reply_to_seq ? ` (reply to #${e.message.reply_to_seq})` : ""}`;
288
- if (e.kind === "status")
289
- return `${pfx}${e.status.agent_name} status: ${e.status.state ?? "-"}${e.status.goal ? ` goal="${e.status.goal}"` : ""}${e.status.branch ? ` ${e.status.branch}@${e.status.head ?? "?"}` : ""}`;
290
- return `${pfx}${e.evidence.agent_name} posted evidence ${e.evidence.filename} (evidence:${e.evidence.id})`;
291
- });
284
+ // --json is the server's record as it came; it never depends on the text formatter (a newer
285
+ // event kind once crashed it before anything was printed, reported by mr-jennings).
286
+ if (out.json) {
287
+ out.print("", r);
288
+ return;
289
+ }
290
+ const lines = r.events.map((e) => formatActivityEvent(e, accountWide));
292
291
  out.print(lines.length ? `${lines.join("\n")}\ncursor: ${r.cursor}` : "(no activity)", r);
293
292
  }
293
+ /** One line per timeline event. A kind this CLI does not know is printed as such, never guessed at. */
294
+ export function formatActivityEvent(e, accountWide) {
295
+ const pfx = `${String(e.at ?? "").slice(11, 19)} ${e.project ? `[${e.project}] ` : accountWide ? "[account] " : ""}`;
296
+ switch (e.kind) {
297
+ case "message": return `${pfx}#${e.message.channel} ${e.message.agent_name}: ${e.message.body}${e.message.reply_to_seq ? ` (reply to #${e.message.reply_to_seq})` : ""}`;
298
+ case "status": return `${pfx}${e.status.agent_name} status: ${e.status.state ?? "-"}${e.status.goal ? ` goal="${e.status.goal}"` : ""}${e.status.branch ? ` ${e.status.branch}@${e.status.head ?? "?"}` : ""}`;
299
+ case "evidence": return `${pfx}${e.evidence.agent_name} posted evidence ${e.evidence.filename} (evidence:${e.evidence.id})`;
300
+ case "work_unit": {
301
+ const w = e.work_unit;
302
+ return `${pfx}WU #${w.number} ${String(w.type).replace(/_/g, " ")} by ${w.actor_name}: ${w.title}${w.note ? ` (${w.note.length > 160 ? `${w.note.slice(0, 160)}…` : w.note})` : ""} [${w.status}]`;
303
+ }
304
+ case "summary": {
305
+ const first = String(e.summary.body ?? "").split("\n").find((l) => l.trim()) ?? "";
306
+ return `${pfx}${e.summary.scope} summary ${String(e.summary.period_start).slice(11, 16)} to ${String(e.summary.period_end).slice(11, 16)} UTC: ${first.slice(0, 200)}`;
307
+ }
308
+ default: return `${pfx}${e.kind} event (this CLI version does not know this kind; bschat activity --json shows the full record, and a newer CLI may format it)`;
309
+ }
310
+ }
294
311
  /** The feed: activity collapsed into stories (units, chat runs, status runs, evidence runs, steward summaries). */
295
312
  export async function feed(p, out) {
296
313
  const { client, creds } = agentClient(p);
@@ -508,9 +508,10 @@ export async function milestone(p, out) {
508
508
  const met = bool(p.flags, "met");
509
509
  const gaps = str(p.flags, "gaps");
510
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 ".."]');
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" [--units n,m] [--note ".."] (--units: the units that address the gaps, wherever they live; the slice is reviewed again when they close)');
512
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 ?? "" });
513
+ const units = (str(p.flags, "units") ?? "").split(",").map((x) => Number(x.trim().replace(/^#/, ""))).filter((n) => Number.isInteger(n) && n > 0);
514
+ const r = await client.call("POST", `/projects/${project}/milestones/${key}/verdict`, { met, note: str(p.flags, "note") ?? "", evidence, gaps: gaps ?? "", units });
514
515
  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
516
  return;
516
517
  }
@@ -573,3 +574,17 @@ export async function lock(p, out) {
573
574
  ? `You hold ${lockName}${r.lock.machine ? ` on ${r.lock.machine}` : " (shared)"}${unit ? ` for WU #${unit}` : ""}. Release it when done: bschat unlock ${lockName}`
574
575
  : `${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);
575
576
  }
577
+ /** bschat ask-operator "question" [--blocks "what waits"]: a decision only the operator can make, on the record and reported to them. */
578
+ export async function askOperator(p, out) {
579
+ const name = resolveAgentName(str(p.flags, "as"));
580
+ const creds = loadAgent(name);
581
+ const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name), { effort: str(p.flags, "effort") });
582
+ const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
583
+ if (!project)
584
+ throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
585
+ const text = (p.positionals.slice(1).join(" ") || str(p.flags, "question") || "").trim();
586
+ if (!text)
587
+ throw new CliError("usage", 'ask-operator "the decision only the operator can make" [--blocks "what waits on it"]');
588
+ const r = await client.call("POST", `/projects/${project}/ask-operator`, { text, blocks: str(p.flags, "blocks") ?? "" });
589
+ out.print(`Asked the operator; it is on their console banner and reported to them. You will be @mentioned with the decision. Carry on with what does not depend on it.`, r);
590
+ }
package/dist/help.js CHANGED
@@ -54,7 +54,7 @@ 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
57
+ bschat milestone verdict <key> --met --note ".." [--evidence a,b] | --gaps ".." [--units n,m] the closure reviewer judges the exit against the evidence; gap units re-trigger the review when they close
58
58
  bschat milestone review <key> assigner or operator: request a closure review now (the steward does it when the last unit closes)
59
59
  bschat lock <name> [--unit n] [--note ..] [--shared] take this machine's <name> (build slot, scratch) or queue; --shared for a project-wide resource (a test board)
60
60
  bschat unlock <name> | bschat locks release it (also released when your unit closes); see holders and queues
@@ -72,6 +72,7 @@ Agent commands
72
72
  bschat wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
73
73
  bschat wu wait <n> --on <m> | --clear owner or assigner: this unit cannot move until #m closes; reminders pause meanwhile
74
74
  bschat wu scope <n> --scope ".." --note ".." assigner or operator: amend what a unit covers; recorded and announced
75
+ bschat ask-operator "question" [--blocks ".."] a decision only the operator can make: on their console banner and reported to them; never ask in chat
75
76
  bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
76
77
  bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies the sha is on the target; removes the unit's clean worktree
77
78
  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, lock } from "./commands/wu.js";
13
+ import { processCmd, record, wu, milestones, milestone, lock, askOperator } 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";
@@ -54,6 +54,7 @@ const COMMANDS = {
54
54
  lock,
55
55
  unlock: lock,
56
56
  locks: lock,
57
+ "ask-operator": askOperator,
57
58
  worktrees,
58
59
  follow: a.followCmd,
59
60
  unfollow: a.followCmd,
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.21";
1
+ export const CLI_VERSION = "0.12.23";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.21",
3
+ "version": "0.12.23",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {