benignswarm 0.12.18 → 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 +2 -2
- package/dist/commands/watch.js +66 -22
- package/dist/commands/wu.js +98 -6
- package/dist/help.js +9 -0
- package/dist/index.js +4 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
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"];
|
|
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"];
|
|
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)
|
package/dist/commands/watch.js
CHANGED
|
@@ -139,9 +139,22 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, maxUnanswered, lo
|
|
|
139
139
|
}
|
|
140
140
|
const u = await gatherUpdates(name, { force: true, model, delivery: "watch", dryRun: true });
|
|
141
141
|
const st = readState(name);
|
|
142
|
+
// A process change is news too. Watched harnesses never see the Claude Code hook re-deliver the
|
|
143
|
+
// standing rules, so the watcher compares the version the agent last read with the current one.
|
|
144
|
+
const idleLag = u ? null : await processLag(name, st, false, log);
|
|
142
145
|
if (!u) {
|
|
143
146
|
if (st.watch_followed_since)
|
|
144
147
|
writeState(name, { ...st, watch_followed_since: undefined });
|
|
148
|
+
if (idleLag && st.watch_process_woken !== idleLag.version && !st.watch_pending) {
|
|
149
|
+
const lag = idleLag;
|
|
150
|
+
// Not recorded as pending: reading the process moves no cursor, and a pending wake-up would
|
|
151
|
+
// hold back the next real one until the requeue timeout.
|
|
152
|
+
const summary = `process changed to v${lag.version}; read it: bschat process`;
|
|
153
|
+
const wake = [`[bschat] Wake-up from your BenignSwarm watcher, not typed by the user.`, processLine(lag), `Nothing else is new. Reply in chat with bschat send, not here.`].join("\n");
|
|
154
|
+
if (await deliver(name, exec, wake, summary, "process", 0, log, ""))
|
|
155
|
+
writeState(name, { ...readState(name), watch_process_woken: lag.version });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
145
158
|
if (once)
|
|
146
159
|
log("nothing new");
|
|
147
160
|
return;
|
|
@@ -183,39 +196,23 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, maxUnanswered, lo
|
|
|
183
196
|
return;
|
|
184
197
|
}
|
|
185
198
|
}
|
|
199
|
+
const lag = await processLag(name, readState(name), true, log);
|
|
186
200
|
const summary = u.text.split("\n")[0].replace(/^\[bschat\] (Delivered by your BenignSwarm watcher, not typed by the user\. )?/, "");
|
|
187
201
|
const wake = [
|
|
188
202
|
`[bschat] Wake-up from your BenignSwarm watcher, not typed by the user.`,
|
|
189
203
|
operatorNew ? `A human operator wrote to you directly.` : null,
|
|
204
|
+
lag ? processLine(lag) : null,
|
|
190
205
|
`New since you last looked: ${summary}`,
|
|
191
206
|
`Run these, in order, to read it all:`,
|
|
192
207
|
...u.readCommands.map((c) => ` ${c}`),
|
|
193
208
|
`Reply in chat with bschat send, not here. Your role and the project's process: bschat me, bschat process.`,
|
|
194
209
|
].filter(Boolean).join("\n");
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
log(`${operatorNew ? "operator message; " : stale ? "re-waking after timeout; " : ""}[${u.tier}] queueing wake-up: ${summary}`);
|
|
199
|
-
const code = await run(cmd, wake, { BSCHAT_TEXT: wake, BSCHAT_SUMMARY: summary, BSCHAT_COUNT: String(total) });
|
|
200
|
-
if (code !== 0) {
|
|
201
|
-
// The agent was NOT woken. Leave nothing pending so the next poll tries again.
|
|
202
|
-
log(`wake command exited ${code}; will retry next poll. If this repeats, the harness needs environment the LaunchAgent lacks (see --env).`);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
// Tell the server a wake-up was queued, so it can tell a busy agent from a broken wake path
|
|
206
|
-
// (no harness activity long after). Best effort: a failure here must not block waking.
|
|
207
|
-
try {
|
|
208
|
-
await Client.forAgent(loadAgent(name), undefined, { presence: false }).call("POST", "/agents/me/wake", { queued_at: new Date().toISOString(), reason: summary.slice(0, 300), tier: u.tier });
|
|
209
|
-
}
|
|
210
|
-
catch (e) {
|
|
211
|
-
log(`could not report the wake-up to the server: ${e.message}`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
process.stdout.write(wake + "\n");
|
|
216
|
-
}
|
|
210
|
+
const total = u.counts.messages + u.counts.items + u.counts.followed + u.counts.digest;
|
|
211
|
+
if (!(await deliver(name, exec, wake, summary, u.tier, total, log, operatorNew ? "operator message; " : stale ? "re-waking after timeout; " : "")))
|
|
212
|
+
return;
|
|
217
213
|
writeState(name, {
|
|
218
214
|
...readState(name),
|
|
215
|
+
...(lag ? { watch_process_woken: lag.version } : {}),
|
|
219
216
|
watch_pending: { at: Date.now(), inbox_after: st.inbox_after, channel_read: st.channel_read ?? {} },
|
|
220
217
|
watch_operator_at: u.latestOperatorAt ?? st.watch_operator_at,
|
|
221
218
|
watch_followed_since: undefined,
|
|
@@ -224,6 +221,53 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, maxUnanswered, lo
|
|
|
224
221
|
if (stale && unanswered + 1 >= maxUnanswered)
|
|
225
222
|
log(`${unanswered + 1} consecutive wake-ups unanswered; one more timeout and this watcher goes dormant until the agent reads`);
|
|
226
223
|
}
|
|
224
|
+
/** Runs the wake command (or prints the wake-up without one). False when the command failed: nothing was delivered. */
|
|
225
|
+
async function deliver(name, exec, wake, summary, tier, total, log, prefix) {
|
|
226
|
+
if (!exec) {
|
|
227
|
+
process.stdout.write(wake + "\n");
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
const cmd = exec.replaceAll("{count}", String(total)).replaceAll("{summary}", shellQuote(summary)).replaceAll("{text}", shellQuote(wake));
|
|
231
|
+
log(`${prefix}[${tier}] queueing wake-up: ${summary}`);
|
|
232
|
+
const code = await run(cmd, wake, { BSCHAT_TEXT: wake, BSCHAT_SUMMARY: summary, BSCHAT_COUNT: String(total) });
|
|
233
|
+
if (code !== 0) {
|
|
234
|
+
// The agent was NOT woken. Leave nothing pending so the next poll tries again.
|
|
235
|
+
log(`wake command exited ${code}; will retry next poll. If this repeats, the harness needs environment the LaunchAgent lacks (see --env).`);
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
// Tell the server a wake-up was queued, so it can tell a busy agent from a broken wake path
|
|
239
|
+
// (no harness activity long after). A failure here is logged; the agent was woken regardless.
|
|
240
|
+
try {
|
|
241
|
+
await Client.forAgent(loadAgent(name), undefined, { presence: false }).call("POST", "/agents/me/wake", { queued_at: new Date().toISOString(), reason: summary.slice(0, 300), tier });
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
log(`could not report the wake-up to the server: ${e.message}`);
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
const processLine = (lag) => `The project process changed: it is version ${lag.version} now and ${lag.seen ? `you last read version ${lag.seen}` : "you have not read it"}. Read it first: bschat process`;
|
|
249
|
+
const PROCESS_CHECK_MS = 5 * 60_000;
|
|
250
|
+
/**
|
|
251
|
+
* The current process version and the one this agent last read (GET /me), when the agent is
|
|
252
|
+
* behind. Checked at most every five minutes, and fresh whenever a wake-up is about to go out.
|
|
253
|
+
* Account-scoped agents have no project process and are never behind.
|
|
254
|
+
*/
|
|
255
|
+
async function processLag(name, st, fresh, log) {
|
|
256
|
+
let p = st.watch_process;
|
|
257
|
+
if (fresh || !p || Date.now() - p.checked_at > PROCESS_CHECK_MS) {
|
|
258
|
+
try {
|
|
259
|
+
const me = await Client.forAgent(loadAgent(name), undefined, { presence: false }).call("GET", "/me");
|
|
260
|
+
const proc = me.process;
|
|
261
|
+
p = proc ? { version: proc.version, seen: proc.seen_version, checked_at: Date.now() } : { version: 0, seen: null, checked_at: Date.now() };
|
|
262
|
+
writeState(name, { ...readState(name), watch_process: p });
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
log(`could not check the process version: ${e.message}`);
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return p.version > 0 && (p.seen ?? 0) < p.version ? { version: p.version, seen: p.seen } : null;
|
|
270
|
+
}
|
|
227
271
|
function shellQuote(s) {
|
|
228
272
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
229
273
|
}
|
package/dist/commands/wu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { str } from "../args.js";
|
|
3
|
+
import { bool, str } from "../args.js";
|
|
4
4
|
import { Client } from "../client.js";
|
|
5
5
|
import { loadAgent, resolveAgentName, resolveModel } from "../config.js";
|
|
6
6
|
import { CliError } from "../errors.js";
|
|
@@ -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) =>
|
|
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)
|
|
@@ -42,12 +57,13 @@ export async function wu(p, out) {
|
|
|
42
57
|
};
|
|
43
58
|
const tags = (u) => (u.tags.length ? u.tags.map((t) => `#${t}`).join(" ") : "(untagged)");
|
|
44
59
|
const fmt = (u) => {
|
|
45
|
-
const flags = [u.assigned_by ? `assigned by ${u.assigned_by}` : null, u.preferred_name ? `reserved for ${u.preferred_name}` : null, u.hold ? "held" : null, u.milestone ? `milestone ${u.milestone}` : null, u.target ? `lands in ${u.target}` : null, u.replay_of ? "REPLAY" : null, u.trial_tags?.length ? `trial on ${u.trial_tags.map((t) => `#${t}`).join(" ")}` : null].filter(Boolean).join(" · ");
|
|
60
|
+
const flags = [u.assigned_by ? `assigned by ${u.assigned_by}` : null, u.preferred_name ? `reserved for ${u.preferred_name}` : null, u.hold && u.status === "assigned" ? "held" : null, u.waiting_on ? `waits on #${u.waiting_on}` : null, u.milestone ? `milestone ${u.milestone}` : null, u.target ? `lands in ${u.target}` : null, u.replay_of ? "REPLAY" : null, u.trial_tags?.length ? `trial on ${u.trial_tags.map((t) => `#${t}`).join(" ")}` : null].filter(Boolean).join(" · ");
|
|
46
61
|
const reviewers = u.reviewers.map((r) => `${r.name}${r.tags.length ? ` for ${r.tags.map((t) => `#${t}`).join(" ")}` : ""}`).join(", ");
|
|
47
62
|
const approvals = u.approvals.map((a) => a.name).join(", ");
|
|
48
63
|
return [
|
|
49
64
|
`WU #${u.number} [${u.status}] ${tags(u)} ${u.title}${flags ? ` (${flags})` : ""}`,
|
|
50
65
|
` owner ${u.owner_name || "unassigned (queued)"}${reviewers ? ` · reviewers ${reviewers}` : ""}${approvals ? ` · approved by ${approvals}` : ""}${u.uncovered?.length ? ` · awaiting ${u.uncovered.map((t) => `#${t}`).join(" ")}` : ""}`,
|
|
66
|
+
u.question ? ` QUESTION for ${u.question.level === "expert" ? `a ${u.question.roles.join(" or ")}` : "the operator"} (asked by ${u.question.asked_by}${u.question.passed_by ? `, passed up by ${u.question.passed_by}` : ""}): ${u.question.text}` : null,
|
|
51
67
|
` ${u.branch ? `${u.branch}${u.head ? ` @ ${u.head}` : ""}` : "no branch recorded"}${u.worktree ? ` in ${u.worktree.replace(/^\/(Users|home)\/[^/]+\//, "~/")}` : ""}${u.pr_url ? ` · ${u.pr_url}` : ""}${u.merged_sha ? ` · merged ${u.merged_sha}` : ""}${u.evidence.length ? ` · evidence ${u.evidence.map((e) => `evidence:${e}`).join(" ")}` : ""}`,
|
|
52
68
|
u.scope ? ` scope: ${u.scope}` : null,
|
|
53
69
|
].filter(Boolean).join("\n");
|
|
@@ -115,6 +131,7 @@ export async function wu(p, out) {
|
|
|
115
131
|
return;
|
|
116
132
|
}
|
|
117
133
|
case "submit": {
|
|
134
|
+
const evidenceIds = list("evidence"); // validated before anything talks to the server
|
|
118
135
|
const def = await processDef();
|
|
119
136
|
const where = branchAndHead();
|
|
120
137
|
const unitTarget = (await client.call("GET", `${base}/${num()}`)).unit.target ?? def.merge.target_branch;
|
|
@@ -136,7 +153,7 @@ export async function wu(p, out) {
|
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
const pr = str(p.flags, "pr") ?? null;
|
|
139
|
-
const r = await client.call("POST", `${base}/${num()}/submit`, { evidence:
|
|
156
|
+
const r = await client.call("POST", `${base}/${num()}/submit`, { evidence: evidenceIds, ...where, pr_url: pr, rebased, pushed });
|
|
140
157
|
const u = r.unit;
|
|
141
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);
|
|
142
159
|
return;
|
|
@@ -149,6 +166,38 @@ export async function wu(p, out) {
|
|
|
149
166
|
out.print(`${fmt(r.unit)}\nReopened: continue on the same branch and resubmit this unit.`, r);
|
|
150
167
|
return;
|
|
151
168
|
}
|
|
169
|
+
case "ask":
|
|
170
|
+
case "rule": {
|
|
171
|
+
const text = (p.positionals.slice(3).join(" ") || str(p.flags, sub === "ask" ? "question" : "ruling") || "").trim();
|
|
172
|
+
if (!text)
|
|
173
|
+
throw new CliError("usage", sub === "ask" ? 'wu ask <n> "the decision this unit cannot move without"' : 'wu rule <n> "what was decided"');
|
|
174
|
+
const r = await client.call("POST", `${base}/${num()}/${sub}`, sub === "ask" ? { question: text } : { ruling: text });
|
|
175
|
+
const q = r.unit.question;
|
|
176
|
+
out.print(`${fmt(r.unit)}\n${sub === "rule" ? "Ruled; the asker, owner and reviewers were told." : q.level === "expert" ? `Asked a ${q.roles.join(" or ")}; it goes to the operator if nobody rules in time.` : "Asked the operator."}`, r);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
case "escalate": {
|
|
180
|
+
const r = await client.call("POST", `${base}/${num()}/question/escalate`, { note: str(p.flags, "note") ?? "" });
|
|
181
|
+
out.print(`${fmt(r.unit)}\nPassed to the operator.`, r);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
case "wait": {
|
|
185
|
+
const on = str(p.flags, "on");
|
|
186
|
+
if (!on && !bool(p.flags, "clear"))
|
|
187
|
+
throw new CliError("usage", 'wu wait <n> --on <m> [--note ".."] (or --clear)');
|
|
188
|
+
const r = await client.call("POST", `${base}/${num()}/wait`, { on: on ? Number(on) : null, note: str(p.flags, "note") ?? "" });
|
|
189
|
+
out.print(fmt(r.unit), r);
|
|
190
|
+
return;
|
|
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
|
+
}
|
|
152
201
|
case "supersede": {
|
|
153
202
|
const by = str(p.flags, "by");
|
|
154
203
|
if (!by)
|
|
@@ -444,7 +493,7 @@ export async function milestone(p, out) {
|
|
|
444
493
|
const m = (await client.call("GET", `/projects/${project}/milestones`)).milestones.find((x) => x.key === key);
|
|
445
494
|
if (!m)
|
|
446
495
|
throw new CliError("not_found", `no milestone ${key}`);
|
|
447
|
-
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);
|
|
448
497
|
return;
|
|
449
498
|
}
|
|
450
499
|
if (sub === "close") {
|
|
@@ -455,12 +504,27 @@ export async function milestone(p, out) {
|
|
|
455
504
|
out.print(`Milestone ${r.milestone.key} ${r.milestone.status}.`, r);
|
|
456
505
|
return;
|
|
457
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
|
+
}
|
|
458
522
|
if (sub === "reopen") {
|
|
459
523
|
const r = await client.call("POST", `/projects/${project}/milestones/${key}/reopen`, {});
|
|
460
524
|
out.print(`Milestone ${r.milestone.key} reopened.`, r);
|
|
461
525
|
return;
|
|
462
526
|
}
|
|
463
|
-
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>");
|
|
464
528
|
}
|
|
465
529
|
export async function record(p, out) {
|
|
466
530
|
const name = resolveAgentName(str(p.flags, "as"));
|
|
@@ -480,3 +544,31 @@ export async function record(p, out) {
|
|
|
480
544
|
const rows = r.record.map((x) => ({ agent: x.agent, tag: `#${x.tag}`, ...counters(x) }));
|
|
481
545
|
out.print(rows.length ? table(rows, ["agent", "tag", "done", "1st-round", "changes", "replays", "reviewed", "overturned", "escalated"]) : "(no reviewed units yet)", r);
|
|
482
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
|
|
@@ -63,6 +67,11 @@ Agent commands
|
|
|
63
67
|
bschat wu proceed <n> --note ".." reviewer: this step is good, carry on; back to the owner, NOT an approval
|
|
64
68
|
bschat wu reopen <n> --note ".." owner or reviewer: withdraw an unmerged approval (verification failed); resubmit the same unit
|
|
65
69
|
bschat wu supersede <n> --by <m> owner or assigner: this unit continues as #m; anyone blocked on #n now waits on #m
|
|
70
|
+
bschat wu ask <n> "question" owner, reviewer or assigner: a decision this unit cannot move without (tag expert first, then the operator)
|
|
71
|
+
bschat wu rule <n> "decision" the tag's expert: answer an open question (operator questions are answered in the console)
|
|
72
|
+
bschat wu escalate <n> [--note ..] the tag's expert: pass the question to the operator
|
|
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
|
|
66
75
|
bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
|
|
67
76
|
bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies the sha is on the target; removes the unit's clean worktree
|
|
68
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.
|
|
1
|
+
export const CLI_VERSION = "0.12.20";
|