benignswarm 0.12.39 → 0.12.40

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.
@@ -6,6 +6,7 @@ import { hostname } from "node:os";
6
6
  import { spawnSync } from "node:child_process";
7
7
  import { CliError } from "../errors.js";
8
8
  import { table } from "../output.js";
9
+ import { milestoneWith, milestonesWith } from "./wu.js";
9
10
  import { accountAdmin, answerAdmin, keysAdmin, needsAdmin, notifierAdmin, processAdmin, skillAdmin, tagList, worktreeAdmin } from "./operator.js";
10
11
  function adminClient(p) {
11
12
  return Client.forAdmin(loadAdmin(resolveAdminName(str(p.flags, "admin"))));
@@ -66,6 +67,18 @@ export async function admin(p, out) {
66
67
  return keysAdmin(action, rest, p, out);
67
68
  case "process":
68
69
  return processAdmin(action, rest, p, out);
70
+ case "milestones": {
71
+ // bschat-admin milestones <project> [export [--out f] | set --file f]
72
+ if (!action)
73
+ throw new CliError("usage", "milestones <project> [export [--out plan.json] | set --file plan.json]");
74
+ return milestonesWith(adminClient(p), action, rest[0], p, out);
75
+ }
76
+ case "milestone": {
77
+ // bschat-admin milestone <project> add|edit|show|close|reopen|review|verdict|gap-units <key> ...
78
+ if (!action)
79
+ throw new CliError("usage", "milestone <project> <add|edit|show|close|reopen|review|verdict|gap-units> <key> ...");
80
+ return milestoneWith(adminClient(p), action, rest[0], rest[1], p, out);
81
+ }
69
82
  case "needs":
70
83
  return needsAdmin(p, out);
71
84
  case "answer":
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { readFileSync } from "node:fs";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
3
  import { bool, str } from "../args.js";
4
4
  import { Client } from "../client.js";
5
5
  import { loadAgent, resolveAgentName, resolveModel } from "../config.js";
@@ -449,7 +449,26 @@ export async function milestones(p, out) {
449
449
  const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
450
450
  if (!project)
451
451
  throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
452
- if (p.positionals[1] === "set") {
452
+ return milestonesWith(client, project, p.positionals[1], p, out);
453
+ }
454
+ /**
455
+ * The plan's milestones, shared by agents (`bschat milestones`) and the operator (`bschat-admin
456
+ * milestones <project>`): list, `export` (the editable JSON list `set` takes) and `set`.
457
+ */
458
+ export async function milestonesWith(client, project, sub, p, out) {
459
+ if (sub === "export") {
460
+ const list = (await client.call("GET", `/projects/${project}/milestones`)).milestones.map((m) => ({ key: m.key, title: m.title, exit: m.exit, ...(m.source ? { source: m.source } : {}), depends_on: m.depends_on }));
461
+ const text = JSON.stringify(list, null, 2) + "\n";
462
+ const file = str(p.flags, "out");
463
+ if (file) {
464
+ writeFileSync(file, text);
465
+ out.print(`Wrote ${list.length} milestone(s) to ${file}; edit it and load it with milestones set --file ${file}`, { file, milestones: list });
466
+ }
467
+ else
468
+ process.stdout.write(text);
469
+ return;
470
+ }
471
+ if (sub === "set") {
453
472
  // Define or replace the plan: a JSON list [{key, title, exit?, depends_on?}] from --file or stdin.
454
473
  // Existing keys keep their status; the server refuses cycles, unknown dependencies and removing a key with units.
455
474
  const file = str(p.flags, "file");
@@ -467,7 +486,7 @@ export async function milestones(p, out) {
467
486
  }
468
487
  const r = await client.call("GET", `/projects/${project}/milestones`);
469
488
  const rows = r.milestones.map((m) => ({ key: m.key, status: m.status === "open" ? (m.ready ? "ready" : `waits on ${m.waiting_on.join(",")}`) : m.status, units: `${m.units.done}/${m.units.total}${m.units.queued ? ` (+${m.units.queued} queued)` : ""}`, "depends on": m.depends_on.join(",") || "-", title: m.title.slice(0, 50) }));
470
- out.print(rows.length ? `${table(rows, ["key", "status", "units", "depends on", "title"])}\nbschat milestone show <key> for the exit criterion; wu open/assign --milestone <key> puts a unit on one.` : "(no milestones defined; the operator or an assigner defines them on the Process page or with bschat milestone set)", r);
489
+ out.print(rows.length ? `${table(rows, ["key", "status", "units", "depends on", "title"])}\nbschat milestone show <key> for the exit criterion; wu open/assign --milestone <key> puts a unit on one.` : "(no milestones defined; the operator defines them on the Process page or with bschat-admin milestones <project> set --file plan.json, an assigner with bschat milestones set --file plan.json)", r);
471
490
  }
472
491
  /** milestone show <key> | milestone close <key> --note ".." [--evidence a,b] [--abandon | --defer] | milestone reopen <key> */
473
492
  export async function milestone(p, out) {
@@ -477,8 +496,10 @@ export async function milestone(p, out) {
477
496
  const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
478
497
  if (!project)
479
498
  throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
480
- const sub = p.positionals[1];
481
- const key = p.positionals[2];
499
+ return milestoneWith(client, project, p.positionals[1], p.positionals[2], p, out);
500
+ }
501
+ /** One milestone, shared by agents (`bschat milestone`) and the operator (`bschat-admin milestone <project>`). */
502
+ export async function milestoneWith(client, project, sub, key, p, out) {
482
503
  if (!key)
483
504
  throw new CliError("usage", 'milestone show <key> | milestone close <key> --note "how the exit criterion was met" [--evidence id,id] [--abandon | --defer] | milestone reopen <key>');
484
505
  if (sub === "add" || sub === "edit") {
package/dist/help.js CHANGED
@@ -177,6 +177,9 @@ bschat-admin login (approve it in your signed-in browser); the session lasts 30
177
177
  bschat-admin process assigners <project> role1,role2 | agreements <project> --file agreements.md
178
178
  bschat-admin process charter <project> --file charter.md how the project weighs trade-offs; sent with every expert question
179
179
  bschat-admin process steward <project> on|off [--quiet m] [--summary m] [--churn n] (--churn: ask the operator when a goal is sent back or handed over n times; 0 off)
180
+ bschat-admin milestones <project> [export [--out plan.json] | set --file plan.json] the plan's slices: list, the editable JSON, or replace it (keys keep their status)
181
+ bschat-admin milestone <project> add|edit <key> --title .. [--exit ..] [--source ..] [--depends-on a,b] one slice in, the rest untouched
182
+ bschat-admin milestone <project> show|review|reopen <key> | close <key> --note .. [--abandon|--defer] | verdict <key> --met|--gaps .. | gap-units <key> --units n,m
180
183
  bschat-admin role edit <name> [--project p] --reviews a,b --works c --trials d which tags a role reviews, works and trials ("*" all, "" none)
181
184
  bschat-admin needs decisions waiting on you (asks, unit questions, broken wake paths, alert failures)
182
185
  bschat-admin answer <key> "decision" answer one; the asker is @mentioned
package/dist/install.js CHANGED
@@ -70,7 +70,10 @@ export function ensureInstall(version, log, npmOverride) {
70
70
  if (got !== version)
71
71
  throw new CliError("install_unverified", `after installing, ${bin} reports ${got ?? "nothing"} instead of ${version}`);
72
72
  }
73
- const rec = { bin, npm, version: binVersion(bin), installed_at: new Date().toISOString() };
73
+ // Record the npm in the global prefix's bin (a stable link, e.g. /opt/homebrew/bin/npm) rather than
74
+ // the resolved runtime path, which names a versioned folder that a Node upgrade removes.
75
+ const stableNpm = join(pre.stdout.trim(), "bin", "npm");
76
+ const rec = { bin, npm: existsSync(stableNpm) ? stableNpm : npm, version: binVersion(bin), installed_at: new Date().toISOString() };
74
77
  mkdirSync(configRoot(), { recursive: true });
75
78
  writeFileSync(installFile(), JSON.stringify(rec, null, 2) + "\n");
76
79
  return rec;
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.39";
1
+ export const CLI_VERSION = "0.12.40";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.39",
3
+ "version": "0.12.40",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {