benignswarm 0.12.75 → 0.12.77
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 +3 -3
- package/dist/capabilities.js +41 -0
- package/dist/client.js +7 -2
- package/dist/commands/agent.js +43 -1
- package/dist/commands/hook.js +247 -47
- package/dist/commands/machine.js +23 -1
- package/dist/commands/operator.js +5 -3
- package/dist/commands/watch.js +42 -13
- package/dist/commands/wu.js +116 -36
- package/dist/git.js +14 -0
- package/dist/help.js +14 -12
- package/dist/output.js +1 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -54,6 +54,7 @@ export function editVocabulary(vocab, op, tag, f) {
|
|
|
54
54
|
...(f.evidence !== undefined ? { require_evidence: f.evidence } : {}),
|
|
55
55
|
...(f.rebased !== undefined ? { require_rebased: f.rebased } : {}),
|
|
56
56
|
...(f.expert !== undefined ? { expert_role: f.expert === "none" || f.expert === "" ? null : f.expert } : {}),
|
|
57
|
+
...(f.requires !== undefined ? { requires: f.requires.length ? f.requires : undefined } : {}),
|
|
57
58
|
};
|
|
58
59
|
if (op === "add" && !next.meaning.trim())
|
|
59
60
|
throw new CliError("usage", `a tag needs a meaning, the sentence workers decide by: --meaning ".."`);
|
|
@@ -126,10 +127,11 @@ function describeProcess(r) {
|
|
|
126
127
|
` timing: review SLA ${d.review_sla_minutes} min, takeover ${d.escalate_after_minutes} min, ${d.max_open_per_agent} open / ${d.max_in_progress_per_agent} in progress per agent`,
|
|
127
128
|
` requires: scope ${d.require_scope ? "yes" : "no"}, evidence to submit ${d.require_evidence_to_submit ? "yes" : "no"}; default approver ${d.default_approver_role ?? "none"}; assigners ${d.assigners.join(", ") || "none"}`,
|
|
128
129
|
` merging: into ${m.target_branch} by ${m.merged_by === "integrator" ? `a ${m.integrator_role}` : `the ${m.merged_by}`}; merge commit ${m.require_merge_commit ? "yes" : "no"}, rebased ${m.require_rebased ? "yes" : "no"}, pushed ${m.require_pushed ? "yes" : "no"}`,
|
|
130
|
+
` capabilities: ${(d.capabilities ?? []).map((c) => `${c.name} (${c.scope}${c.min_version ? ` >= ${c.min_version}` : ""})`).join(", ") || "none"}`,
|
|
129
131
|
` steward: ${d.steward.enabled ? "on" : "off"}, quiet ${d.steward.quiet_minutes} min, summary every ${d.steward.summary_minutes} min, ask the operator after ${d.steward.churn_rounds ? `${d.steward.churn_rounds} rounds on one goal` : "(never)"}`,
|
|
130
132
|
` agreements: ${r.process.agreements.length} of 8000 characters; charter: ${(r.process.charter ?? "").length ? `${r.process.charter.length} of 4000 characters` : "none (bschat-admin process charter <project> --file charter.md)"}; send-backs ${d.require_cited_changes === false ? "free-form" : "must cite the clause they fail"}`,
|
|
131
133
|
v.length ? `Tags:` : `No tag vocabulary: every unit goes to the default approver.`,
|
|
132
|
-
...v.map((t) => ` #${t.name}: ${t.meaning || "(NO MEANING: workers cannot decide by it)"}${t.require_evidence ? " · evidence" : ""}${t.require_rebased ? " · rebased" : ""}${t.expert_role ? ` · expert ${t.expert_role}` : ""}`),
|
|
134
|
+
...v.map((t) => ` #${t.name}: ${t.meaning || "(NO MEANING: workers cannot decide by it)"}${t.require_evidence ? " · evidence" : ""}${t.require_rebased ? " · rebased" : ""}${t.expert_role ? ` · expert ${t.expert_role}` : ""}${t.requires?.length ? ` · requires ${t.requires.join(", ")}` : ""}`),
|
|
133
135
|
].join("\n");
|
|
134
136
|
}
|
|
135
137
|
export async function processAdmin(action, rest, p, out) {
|
|
@@ -183,9 +185,9 @@ export async function processAdmin(action, rest, p, out) {
|
|
|
183
185
|
case "tag": {
|
|
184
186
|
const [, op, tag] = rest;
|
|
185
187
|
if (!["add", "edit", "remove"].includes(op) || !tag)
|
|
186
|
-
throw new CliError("usage", 'admin process tag add|edit|remove <project> <tag> [--meaning ".."] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role <role>|none]');
|
|
188
|
+
throw new CliError("usage", 'admin process tag add|edit|remove <project> <tag> [--meaning ".."] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role <role>|none] [--requires name,name]');
|
|
187
189
|
const r = await get();
|
|
188
|
-
const vocabulary = editVocabulary(r.vocabulary, op, tag, { meaning: str(p.flags, "meaning"), evidence: yesNo(str(p.flags, "require-evidence"), "require-evidence"), rebased: yesNo(str(p.flags, "require-rebased"), "require-rebased"), expert: str(p.flags, "expert-role") });
|
|
190
|
+
const vocabulary = editVocabulary(r.vocabulary, op, tag, { meaning: str(p.flags, "meaning"), evidence: yesNo(str(p.flags, "require-evidence"), "require-evidence"), rebased: yesNo(str(p.flags, "require-rebased"), "require-rebased"), expert: str(p.flags, "expert-role"), requires: tagList(str(p.flags, "requires")) });
|
|
189
191
|
return publish({ vocabulary }, `tag #${tag.replace(/^#/, "")} ${op === "add" ? "added" : op === "edit" ? "edited" : "removed"}`);
|
|
190
192
|
}
|
|
191
193
|
case "timing":
|
package/dist/commands/watch.js
CHANGED
|
@@ -17,8 +17,14 @@ import { scanProject, unitWorktrees } from "./worktrees.js";
|
|
|
17
17
|
import { formatBytes, freeSpaceProbe, pruneReport, removePrunable } from "../git.js";
|
|
18
18
|
import { CliError } from "../errors.js";
|
|
19
19
|
import { acquireWatchLock } from "../lock.js";
|
|
20
|
-
import { gatherUpdates } from "./hook.js";
|
|
20
|
+
import { formatUpdates, gatherUpdates, reportDelivery } from "./hook.js";
|
|
21
21
|
import { readState, writeState } from "../state.js";
|
|
22
|
+
import { probeCapabilities } from "../capabilities.js";
|
|
23
|
+
/** Reports host probes without refreshing the agent's presence; the host identity is still explicit. */
|
|
24
|
+
export async function reportWatcherCapabilities(creds, project, definitions, cwd = process.cwd()) {
|
|
25
|
+
const results = probeCapabilities(definitions, cwd);
|
|
26
|
+
await Client.forAgent(creds, undefined, { presence: false, machineIdentity: true }).call("POST", `/projects/${project}/agents/me/capabilities`, { results });
|
|
27
|
+
}
|
|
22
28
|
/**
|
|
23
29
|
* Event bridge for harnesses that can be woken from outside (Codex: `codex queue --thread <id>`).
|
|
24
30
|
*
|
|
@@ -109,6 +115,7 @@ export async function watch(p, out) {
|
|
|
109
115
|
// scan on start and then hourly reports worktrees nobody is touching, which agent calls never would.
|
|
110
116
|
const scanCreds = loadAgent(name);
|
|
111
117
|
let lastScan = 0;
|
|
118
|
+
let lastCapabilities = 0;
|
|
112
119
|
// A watcher holding a pending wake-up makes no server call, so a revoked key (the agent moved to
|
|
113
120
|
// another machine) went unnoticed: fabricbios codex-coordinator's kept running on the Mac. Check
|
|
114
121
|
// the key on its own clock.
|
|
@@ -154,6 +161,22 @@ export async function watch(p, out) {
|
|
|
154
161
|
log(`worktree scan skipped: ${e.message}`);
|
|
155
162
|
}
|
|
156
163
|
}
|
|
164
|
+
if (scanCreds.project && Date.now() - lastCapabilities > 3_600_000) {
|
|
165
|
+
try {
|
|
166
|
+
const client = Client.forAgent(scanCreds, undefined, { presence: false });
|
|
167
|
+
const processInfo = await client.call("GET", `/projects/${scanCreds.project}/process`);
|
|
168
|
+
const definitions = (processInfo.process?.definition?.capabilities ?? []);
|
|
169
|
+
if (definitions.length) {
|
|
170
|
+
await reportWatcherCapabilities(scanCreds, scanCreds.project, definitions, process.cwd());
|
|
171
|
+
log(`capabilities: probed ${definitions.length} project requirements`);
|
|
172
|
+
}
|
|
173
|
+
lastCapabilities = Date.now();
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
lastCapabilities = Date.now();
|
|
177
|
+
log(`capability probe/report failed: ${e.message}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
157
180
|
if (!once && Date.now() - lastKeyCheck > KEY_CHECK_MS) {
|
|
158
181
|
lastKeyCheck = Date.now();
|
|
159
182
|
try {
|
|
@@ -196,6 +219,9 @@ export async function watch(p, out) {
|
|
|
196
219
|
else {
|
|
197
220
|
process.stdout.write(u.text + "\n");
|
|
198
221
|
}
|
|
222
|
+
// Full mode delivers the update payload directly instead of using the wake path, so
|
|
223
|
+
// record the same actual payload bytes and kinds through the hook's existing metric call.
|
|
224
|
+
await reportDelivery(name, u.text, u.delivery.by_kind, "watch");
|
|
199
225
|
}
|
|
200
226
|
else if (once) {
|
|
201
227
|
log("nothing new");
|
|
@@ -277,8 +303,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
277
303
|
}
|
|
278
304
|
const seq = (st.watch_seq ?? 0) + 1;
|
|
279
305
|
const operatorNew = !!u && u.latestOperatorAt !== null && u.latestOperatorAt !== (st.watch_operator_at ?? null);
|
|
280
|
-
const
|
|
281
|
-
const wake = [
|
|
306
|
+
const wakePrefix = [
|
|
282
307
|
...(turnSink
|
|
283
308
|
? [`[bschat] Turn #${seq}, started by your BenignSwarm watcher because you were idle; not typed by the user. It is already acknowledged.`]
|
|
284
309
|
: [
|
|
@@ -287,17 +312,19 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
287
312
|
]),
|
|
288
313
|
operatorNew ? `A human operator wrote to you directly.` : null,
|
|
289
314
|
processNews ? processLine(lag) : null,
|
|
290
|
-
|
|
315
|
+
].filter(Boolean);
|
|
316
|
+
const wakeSuffix = [
|
|
291
317
|
...(u ? [`Run these, in order, to read it all:`, ...u.readCommands.map((c) => ` ${c}`)] : []),
|
|
292
318
|
`Reply in chat with bschat send, not here. Your role and the project's process: bschat me, bschat process.`,
|
|
293
|
-
]
|
|
319
|
+
];
|
|
320
|
+
const payload = u ? formatUpdates(u, wakePrefix, wakeSuffix) : null;
|
|
321
|
+
const wake = payload?.text ?? [...wakePrefix, "Nothing else is new.", ...wakeSuffix].join("\n");
|
|
294
322
|
const total = u ? u.counts.messages + u.counts.items + u.counts.followed + u.counts.digest : 0;
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (!(await deliver(name, exec, wake, line, u ? u.tier : "process", total, log, operatorNew ? "operator message; " : "", seq, turnSink)))
|
|
323
|
+
// Both command templates receive this same bounded text, with the acknowledgement first.
|
|
324
|
+
// `{summary}` commands get the same bounded prompt as `{text}`: this wrapper itself contains
|
|
325
|
+
// the acknowledgement, operator note, process pointer, read commands, and delivery body.
|
|
326
|
+
const line = wake;
|
|
327
|
+
if (!(await deliver(name, exec, wake, line, u ? u.tier : "process", total, log, operatorNew ? "operator message; " : "", seq, turnSink, payload?.delivery.by_kind ?? u?.delivery.by_kind)))
|
|
301
328
|
return;
|
|
302
329
|
writeState(name, {
|
|
303
330
|
...readState(name),
|
|
@@ -310,7 +337,7 @@ async function wakeOnce(name, exec, unackedAfter, followDelay, log, model, once,
|
|
|
310
337
|
});
|
|
311
338
|
}
|
|
312
339
|
/** Runs the wake command (or prints the wake-up without one). False when the command failed: nothing was delivered. */
|
|
313
|
-
async function deliver(name, exec, wake, summary, tier, total, log, prefix, seq, turnSink) {
|
|
340
|
+
async function deliver(name, exec, wake, summary, tier, total, log, prefix, seq, turnSink, kinds = {}) {
|
|
314
341
|
if (!exec) {
|
|
315
342
|
process.stdout.write(wake + "\n");
|
|
316
343
|
return true;
|
|
@@ -336,7 +363,9 @@ async function deliver(name, exec, wake, summary, tier, total, log, prefix, seq,
|
|
|
336
363
|
// Tell the server a wake-up was queued, so it can tell a busy agent from a broken wake path
|
|
337
364
|
// (no harness activity long after). A failure here is logged; the agent was woken regardless.
|
|
338
365
|
try {
|
|
339
|
-
|
|
366
|
+
const bytes = new TextEncoder().encode(wake).byteLength;
|
|
367
|
+
const categorized = Object.values(kinds).reduce((a, b) => a + b, 0);
|
|
368
|
+
await Client.forAgent(loadAgent(name), undefined, { presence: false }).call("POST", "/agents/me/wake", { queued_at: new Date().toISOString(), reason: summary.slice(0, 300), tier, seq, delivery: { bytes, by_kind: { ...kinds, watcher: Math.max(0, bytes - categorized) } } });
|
|
340
369
|
}
|
|
341
370
|
catch (e) {
|
|
342
371
|
log(`could not report the wake-up to the server: ${e.message}`);
|
package/dist/commands/wu.js
CHANGED
|
@@ -7,7 +7,7 @@ import { readState } from "../state.js";
|
|
|
7
7
|
import { codexRollout, sessionsOf } from "../sessions.js";
|
|
8
8
|
import { sessionUsage } from "../usage.js";
|
|
9
9
|
import { CliError } from "../errors.js";
|
|
10
|
-
import { branchAndHead, commitAtTime, ensureReviewWorktree, ensureWorktree, fetchRef, fullSha, isAncestor, remoteHead, removeWorktreeIfClean, repoName, repoParent, worktreeForBranch } from "../git.js";
|
|
10
|
+
import { branchAndHead, commitAtTime, ensureReviewWorktree, ensureWorktree, fetchRef, fullSha, isAncestor, remoteHead, removeWorktreeIfClean, repoName, repoParent, verifyMergedCommit, worktreeForBranch } from "../git.js";
|
|
11
11
|
import { resolve } from "node:path";
|
|
12
12
|
import { table } from "../output.js";
|
|
13
13
|
/**
|
|
@@ -42,6 +42,26 @@ export function parseEvidenceReplacement(positionals) {
|
|
|
42
42
|
throw new CliError("usage", "the replacement evidence id must differ from the old id");
|
|
43
43
|
return { unit, oldId, newId };
|
|
44
44
|
}
|
|
45
|
+
/** Changed paths are calculated from the fetched target's merge-base; a configured rule may not silently skip an unknown target. */
|
|
46
|
+
export function changedPathsAgainstTarget(target, cwd = process.cwd()) {
|
|
47
|
+
const fetched = spawnSync("git", ["fetch", "--quiet", "origin", target], { cwd, encoding: "utf8", timeout: 120_000 });
|
|
48
|
+
if (fetched.status !== 0)
|
|
49
|
+
throw new CliError("target_fetch_failed", `cannot fetch origin/${target} while finding changed paths for review rules: ${fetched.stderr?.trim() || "git fetch failed"}`, `check origin access and the target branch, then submit again`);
|
|
50
|
+
const targetRef = "FETCH_HEAD";
|
|
51
|
+
const verify = spawnSync("git", ["rev-parse", "--verify", "--quiet", `${targetRef}^{commit}`], { cwd, encoding: "utf8" });
|
|
52
|
+
if (verify.status !== 0)
|
|
53
|
+
throw new CliError("target_unavailable", `git fetch origin/${target} succeeded but FETCH_HEAD is not a commit`);
|
|
54
|
+
const base = spawnSync("git", ["merge-base", targetRef, "HEAD"], { cwd, encoding: "utf8" });
|
|
55
|
+
if (base.status !== 0 || !base.stdout.trim())
|
|
56
|
+
throw new CliError("merge_base_unavailable", `cannot find a merge-base between ${targetRef} and HEAD`);
|
|
57
|
+
const diff = spawnSync("git", ["diff", "--name-only", "-z", `${base.stdout.trim()}..HEAD`], { cwd, encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
58
|
+
if (diff.status !== 0)
|
|
59
|
+
throw new CliError("changed_paths_failed", `git diff against ${targetRef} failed: ${diff.stderr?.trim() || "unknown git error"}`);
|
|
60
|
+
return diff.stdout.split("\0").filter((path) => path.length > 0);
|
|
61
|
+
}
|
|
62
|
+
export function submitPayload(fields, hasReviewRules, target, cwd = process.cwd()) {
|
|
63
|
+
return { ...fields, changed_paths: hasReviewRules ? changedPathsAgainstTarget(target, cwd) : [] };
|
|
64
|
+
}
|
|
45
65
|
export async function wu(p, out) {
|
|
46
66
|
const sub = p.positionals[1];
|
|
47
67
|
const name = resolveAgentName(str(p.flags, "as"));
|
|
@@ -79,8 +99,9 @@ export async function wu(p, out) {
|
|
|
79
99
|
const reviewers = u.reviewers.map((r) => `${r.name}${r.tags.length ? ` for ${r.tags.map((t) => `#${t}`).join(" ")}` : ""}`).join(", ");
|
|
80
100
|
const approvals = u.approvals.map((a) => a.name).join(", ");
|
|
81
101
|
return [
|
|
82
|
-
`WU #${u.number} [${u.status}] ${tags(u)} ${u.title}${flags ? ` (${flags})` : ""}`,
|
|
102
|
+
`WU #${u.number} [${u.status}] ${tags(u)} ${u.title}${flags ? ` (${flags})` : ""}${u.requires?.length ? `\n requires: ${u.requires.join(", ")}` : ""}`,
|
|
83
103
|
` owner ${u.owner_name || "unassigned (queued)"}${reviewers ? ` · reviewers ${reviewers}` : ""}${approvals ? ` · approved by ${approvals}` : ""}${u.uncovered?.length ? ` · awaiting ${u.uncovered.map((t) => `#${t}`).join(" ")}` : ""}`,
|
|
104
|
+
Object.keys(u.tag_focus ?? {}).length ? ` review focus:\n${Object.entries(u.tag_focus).map(([tag, focus]) => ` #${tag}: ${focus}`).join("\n")}` : null,
|
|
84
105
|
u.operator_hold ? ` ON HOLD by ${u.operator_hold.by}: ${u.operator_hold.note} (no verdict and no merge until the owner resubmits or it is released)` : null,
|
|
85
106
|
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,
|
|
86
107
|
` ${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(" ")}` : ""}`,
|
|
@@ -97,7 +118,7 @@ export async function wu(p, out) {
|
|
|
97
118
|
throw new CliError("usage", 'wu open "<title>" --scope "<what it covers and does not>" [--tags a,b] [--evidence id]');
|
|
98
119
|
// The unit exists first (it needs its number for the branch name), then its worktree is made
|
|
99
120
|
// and recorded exactly as `wu start` would; --here keeps the current checkout.
|
|
100
|
-
const r = await client.call("POST", base, { title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), evidence: list("evidence"), ...branchAndHead(), worktree: process.cwd(), target: str(p.flags, "target") ?? null, milestone: str(p.flags, "milestone") ?? null });
|
|
121
|
+
const r = await client.call("POST", base, { title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), requires: list("requires"), evidence: list("evidence"), ...branchAndHead(), worktree: process.cwd(), target: str(p.flags, "target") ?? null, milestone: str(p.flags, "milestone") ?? null });
|
|
101
122
|
const n = r.unit.number;
|
|
102
123
|
const { path, branch, mode } = prepareWorktree(n, r.unit, await processDef(), p, await checkoutExclude());
|
|
103
124
|
const where = branchAndHead(path);
|
|
@@ -112,7 +133,7 @@ export async function wu(p, out) {
|
|
|
112
133
|
if (!title || !to)
|
|
113
134
|
throw new CliError("usage", 'wu assign "<title>" --to <agent|auto|queue> --scope "<what it covers and does not>" [--tags a,b] [--evidence id] [--replay-of <n>]');
|
|
114
135
|
const replay = str(p.flags, "replay-of");
|
|
115
|
-
const r = await client.call("POST", `${base}/assign`, { to, title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), evidence: list("evidence"), replay_of: replay ? Number(replay) : null, branch: str(p.flags, "branch") ?? null, target: str(p.flags, "target") ?? null, milestone: str(p.flags, "milestone") ?? null, hold: !!p.flags.hold });
|
|
136
|
+
const r = await client.call("POST", `${base}/assign`, { to, title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), requires: list("requires"), evidence: list("evidence"), replay_of: replay ? Number(replay) : null, branch: str(p.flags, "branch") ?? null, target: str(p.flags, "target") ?? null, milestone: str(p.flags, "milestone") ?? null, hold: !!p.flags.hold, force: !!p.flags.force });
|
|
116
137
|
out.print(`${fmt(r.unit)}\n${r.unit.status === "queued" && r.unit.preferred_name ? `Reserved for ${r.unit.preferred_name}, who is busy: theirs when free, open to any qualified worker after the takeover window (--hold keeps it assigned to them).` : r.unit.status === "queued" ? `Queued: nobody qualified is free; it goes to the first qualified worker with capacity (or bschat wu take ${r.unit.number} --to <agent>).` : `Assigned to ${r.unit.owner_name}; they start it with bschat wu start ${r.unit.number}.`}`, r);
|
|
117
138
|
return;
|
|
118
139
|
}
|
|
@@ -135,11 +156,26 @@ export async function wu(p, out) {
|
|
|
135
156
|
case "start": {
|
|
136
157
|
const n = num();
|
|
137
158
|
const unit = (await client.call("GET", `${base}/${n}`)).unit;
|
|
159
|
+
// Ask the server to refuse queued work before prepareWorktree can create a branch or checkout.
|
|
160
|
+
// This also gives the refusal the canonical take instruction from the server.
|
|
161
|
+
await preflightQueuedStart(client, base, n, unit);
|
|
138
162
|
const def = await processDef();
|
|
139
163
|
const target = unit.target ?? def.merge.target_branch;
|
|
140
|
-
const
|
|
164
|
+
const prepared = prepareWorktree(n, unit, def, p, await checkoutExclude());
|
|
165
|
+
const { path, branch, mode } = prepared;
|
|
141
166
|
const where = branchAndHead(path);
|
|
142
|
-
|
|
167
|
+
let r;
|
|
168
|
+
try {
|
|
169
|
+
r = await client.call("POST", `${base}/${n}/start`, { branch: branch ?? where.branch, head: where.head, worktree: path, mode });
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (prepared.created) {
|
|
173
|
+
const removed = removeWorktreeIfClean(path);
|
|
174
|
+
if (removed.removed && prepared.branchCreated && branch)
|
|
175
|
+
spawnSync("git", ["branch", "-D", branch], { cwd: process.cwd(), encoding: "utf8" });
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
143
179
|
out.print(`${fmt(r.unit)}\nYour worktree: ${path}${mode === "fresh" ? ` (new branch ${branch} from ${target}${unit.replay ? " as of the original" : ""})` : mode === "branch" ? ` (branch ${branch})` : " (this checkout)"}\n cd ${path}\nWork there. Submit when ready: bschat wu submit ${n} --evidence <id>`, { ...r, worktree: path, branch, mode });
|
|
144
180
|
return;
|
|
145
181
|
}
|
|
@@ -180,7 +216,8 @@ export async function wu(p, out) {
|
|
|
180
216
|
}
|
|
181
217
|
const pr = str(p.flags, "pr") ?? null;
|
|
182
218
|
const usage = await roundUsage(client, base, num(), name);
|
|
183
|
-
const
|
|
219
|
+
const payload = submitPayload({ evidence: evidenceIds, ...where, pr_url: pr, rebased, pushed, usage }, !!def.review_rules?.length, unitTarget);
|
|
220
|
+
const r = await client.call("POST", `${base}/${num()}/submit`, payload);
|
|
184
221
|
const u = r.unit;
|
|
185
222
|
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);
|
|
186
223
|
return;
|
|
@@ -295,6 +332,7 @@ export async function wu(p, out) {
|
|
|
295
332
|
const merged = str(p.flags, "merged") ?? null;
|
|
296
333
|
const unit = (await client.call("GET", `${base}/${num()}`)).unit;
|
|
297
334
|
const landsIn = unit.target ?? def.merge.target_branch;
|
|
335
|
+
let verifiedRemoteTarget = null;
|
|
298
336
|
if (unit.replay_of) {
|
|
299
337
|
// A replay is an evaluation: it closes without merging (the server records it as evaluated).
|
|
300
338
|
if (merged)
|
|
@@ -302,20 +340,31 @@ export async function wu(p, out) {
|
|
|
302
340
|
}
|
|
303
341
|
else if (merged) {
|
|
304
342
|
// Where pushes are required the remote target is the truth, not this machine's copy of it.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
343
|
+
if (def.merge.require_pushed) {
|
|
344
|
+
const target = fetchRef(landsIn) ? `origin/${landsIn}` : null;
|
|
345
|
+
if (target === null)
|
|
346
|
+
throw new CliError("no_remote", `cannot fetch origin/${landsIn}; this project requires merges to be on the remote`, "Check the remote is reachable and try again.");
|
|
347
|
+
const on = isAncestor(merged, target);
|
|
348
|
+
if (on === null)
|
|
349
|
+
throw new CliError("unknown_commit", `cannot verify ${merged} against ${target} in this repository`, `Run from the repo with ${landsIn} fetched: git fetch origin ${landsIn}:${landsIn}`);
|
|
350
|
+
if (!on)
|
|
351
|
+
throw new CliError("not_merged", `${merged} is not on ${target}`, "Merge and push the target branch first, then pass the merge commit.");
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
const checked = verifyMergedCommit(merged, landsIn);
|
|
355
|
+
if (checked.ref === `origin/${landsIn}` && checked.on === true)
|
|
356
|
+
verifiedRemoteTarget = checked.ref;
|
|
357
|
+
if (checked.on === null)
|
|
358
|
+
throw new CliError("unknown_commit", `cannot verify ${merged} against ${checked.ref} in this repository`, `Run from the repo with ${landsIn} fetched: git fetch origin ${landsIn}:${landsIn}`);
|
|
359
|
+
if (!checked.on)
|
|
360
|
+
throw new CliError("not_merged", `${merged} is not on ${checked.ref}`, "Merge first, then pass the merge commit (or the branch head once it is on the target).");
|
|
361
|
+
}
|
|
313
362
|
}
|
|
314
363
|
else if (def.merge.require_merge_commit) {
|
|
315
364
|
throw new CliError("usage", `this project's process requires the merge commit: bschat wu done ${num()} --merged <sha>`);
|
|
316
365
|
}
|
|
317
366
|
const r = await client.call("POST", `${base}/${num()}/done`, { note: str(p.flags, "note") ?? "", merged });
|
|
318
|
-
out.print(fmt(r.unit) + cleanupUnitWorktree(r.unit.worktree, def, !!p.flags["keep-worktree"]), r);
|
|
367
|
+
out.print(fmt(r.unit) + (verifiedRemoteTarget ? `\nverified on ${verifiedRemoteTarget}` : "") + cleanupUnitWorktree(r.unit.worktree, def, !!p.flags["keep-worktree"]), r);
|
|
319
368
|
return;
|
|
320
369
|
}
|
|
321
370
|
case "abandon": {
|
|
@@ -417,6 +466,11 @@ export async function wu(p, out) {
|
|
|
417
466
|
throw new CliError("usage", "wu open|assign|start [--branch b|--here]|decline|submit|approve|changes|classify|tags|done [--keep-worktree]|abandon|note|ask|rule|propose|show|list");
|
|
418
467
|
}
|
|
419
468
|
}
|
|
469
|
+
/** Queued units have no owner; ask the API to reject before any local worktree is made. */
|
|
470
|
+
export async function preflightQueuedStart(client, base, n, unit) {
|
|
471
|
+
if (unit.status === "queued")
|
|
472
|
+
await client.call("POST", `${base}/${n}/start`, {});
|
|
473
|
+
}
|
|
420
474
|
/** The project's process: the tag vocabulary, who reviews what, requirements, and the working agreements. */
|
|
421
475
|
export async function processCmd(p, out) {
|
|
422
476
|
const name = resolveAgentName(str(p.flags, "as"));
|
|
@@ -432,8 +486,10 @@ export async function processCmd(p, out) {
|
|
|
432
486
|
const whoReviews = (tag) => roles.filter((x) => x.reviews.includes("*") || x.reviews.includes(tag)).map((x) => x.name);
|
|
433
487
|
const lines = [
|
|
434
488
|
`Process v${r.process.version}${r.process.version === 0 ? " (defaults; the operator has not published one)" : ""}`,
|
|
489
|
+
`Machine capabilities: ${(d.capabilities ?? []).map((c) => `${c.name} (${c.scope}${c.min_version ? ` >= ${c.min_version}` : ""})`).join(", ") || "none"}`,
|
|
435
490
|
vocab.length ? `Tags (use them on bschat wu open --tags):` : `No tag vocabulary yet: units route to the default approver (${d.default_approver_role ?? "none"}).`,
|
|
436
|
-
...vocab.map((t) => ` #${t.name}: ${t.meaning || "(no meaning written)"}${t.require_evidence ? " · requires evidence" : ""}${t.require_rebased ? " · requires a rebased branch" : ""} · reviewed by ${whoReviews(t.name).join(", ") || "NOBODY (the operator must qualify a role)"}`),
|
|
491
|
+
...vocab.map((t) => ` #${t.name}: ${t.meaning || "(no meaning written)"}${t.require_evidence ? " · requires evidence" : ""}${t.require_rebased ? " · requires a rebased branch" : ""}${t.requires?.length ? ` · requires capabilities ${t.requires.join(", ")}` : ""}${t.focus ? ` · reviewer focus: ${t.focus}` : ""} · reviewed by ${whoReviews(t.name).join(", ") || "NOBODY (the operator must qualify a role)"}`),
|
|
492
|
+
...(d.review_rules?.length ? [`Path review rules:`, ...d.review_rules.map((rule) => ` ${rule.paths.join(", ")} -> ${rule.add_tags.map((t) => `#${t}`).join(" ")} (${rule.reason})`)] : []),
|
|
437
493
|
`Untagged units are approved by ${d.default_approver_role ?? "nobody (set a default approver)"}.${d.classification === "classifier" ? ` A ${d.classifier_role} confirms tags before review.` : ""}`,
|
|
438
494
|
`A unit needs a title${d.require_scope ? ", a scope statement" : ""}${d.require_evidence_to_submit ? ", evidence before review" : ""}. Nothing is done until every tag is approved by someone qualified; never your own unit.`,
|
|
439
495
|
`Review SLA ${d.review_sla_minutes} min; after ${d.escalate_after_minutes} min another qualified reviewer takes over. Max ${d.max_open_per_agent} open units per agent. Announcements in #${d.channel}.`,
|
|
@@ -485,7 +541,7 @@ function prepareWorktree(n, unit, def, p, exclude = []) {
|
|
|
485
541
|
}
|
|
486
542
|
}
|
|
487
543
|
if (p.flags.here)
|
|
488
|
-
return { mode: "here", path: process.cwd(), branch: branchAndHead().branch };
|
|
544
|
+
return { mode: "here", path: process.cwd(), branch: branchAndHead().branch, created: false, branchCreated: false };
|
|
489
545
|
const name = repoName();
|
|
490
546
|
const parent = repoParent();
|
|
491
547
|
if (!name || !parent)
|
|
@@ -494,16 +550,19 @@ function prepareWorktree(n, unit, def, p, exclude = []) {
|
|
|
494
550
|
if (pinned) {
|
|
495
551
|
const existing = worktreeForBranch(pinned);
|
|
496
552
|
const path = existing ?? resolve(parent, `${name}-wu${n}`);
|
|
553
|
+
// ensureWorktree creates local branches when they do not exist; remember that too so a
|
|
554
|
+
// subsequent server refusal can remove every artifact made by this start attempt.
|
|
555
|
+
let branchCreated = !existing && fullSha(pinned) === null;
|
|
497
556
|
// Continuing someone else's branch from another machine: take origin's copy of it when we have none.
|
|
498
557
|
if (!existing && remoteFirst && fullSha(pinned) === null && fetchRef(pinned)) {
|
|
499
558
|
const r = spawnSync("git", ["branch", "--track", pinned, `origin/${pinned}`], { cwd: process.cwd(), encoding: "utf8" });
|
|
500
559
|
if (r.status !== 0)
|
|
501
560
|
throw new CliError("no_branch", `cannot create ${pinned} from origin: ${(r.stderr || r.stdout).trim()}`);
|
|
561
|
+
branchCreated = true;
|
|
502
562
|
log(`created ${pinned} from origin/${pinned}`);
|
|
503
563
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return { mode: "branch", path, branch: pinned };
|
|
564
|
+
const result = !existing ? ensureWorktree(path, pinned, baseRef, process.cwd(), log, exclude) : { created: false };
|
|
565
|
+
return { mode: "branch", path, branch: pinned, created: result.created, branchCreated };
|
|
507
566
|
}
|
|
508
567
|
const slug = String(unit.title).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
509
568
|
const branch = `wu/${n}-${slug}`;
|
|
@@ -515,8 +574,9 @@ function prepareWorktree(n, unit, def, p, exclude = []) {
|
|
|
515
574
|
throw new CliError("no_base", `cannot find ${baseRef} as of ${unit.replay.created_at} for the replay`, `git fetch origin ${target} then try again`);
|
|
516
575
|
baseRef = at;
|
|
517
576
|
}
|
|
518
|
-
|
|
519
|
-
|
|
577
|
+
const branchCreated = fullSha(branch) === null;
|
|
578
|
+
const result = ensureWorktree(path, branch, baseRef, process.cwd(), log, exclude);
|
|
579
|
+
return { mode: "fresh", path, branch, created: result.created, branchCreated };
|
|
520
580
|
}
|
|
521
581
|
/** Select the replay commit from the same target ref used to create its worktree. */
|
|
522
582
|
export function replayBaseRef(baseRef, createdAt, cwd = process.cwd()) {
|
|
@@ -538,7 +598,7 @@ export async function milestones(p, out) {
|
|
|
538
598
|
*/
|
|
539
599
|
export async function milestonesWith(client, project, sub, p, out) {
|
|
540
600
|
if (sub === "export") {
|
|
541
|
-
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, ...(m.priority !== null && m.priority !== undefined ? { priority: m.priority } : {}) }));
|
|
601
|
+
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.dependencies ?? m.depends_on, default_tags: m.default_tags ?? [], ...(m.priority !== null && m.priority !== undefined ? { priority: m.priority } : {}) }));
|
|
542
602
|
const text = JSON.stringify(list, null, 2) + "\n";
|
|
543
603
|
const file = str(p.flags, "out");
|
|
544
604
|
if (file) {
|
|
@@ -596,20 +656,23 @@ export async function milestoneWith(client, project, sub, key, p, out) {
|
|
|
596
656
|
throw new CliError("not_found", `no milestone ${key}; use milestone add ${key} --title "..."`);
|
|
597
657
|
const title = str(p.flags, "title") ?? existing?.title;
|
|
598
658
|
if (!title)
|
|
599
|
-
throw new CliError("usage", 'milestone add <key> --title "..." [--exit "what done means"] [--source "docs/plan.md#section"] [--depends-on a,b] [--priority n|none] (no exit and no dependencies = a container for ongoing work)');
|
|
600
|
-
const deps = str(p.flags, "depends-on") !== undefined ? (str(p.flags, "depends-on") ?? "").split(",").map((s) => s.trim()).filter(Boolean) : existing?.depends_on ?? [];
|
|
659
|
+
throw new CliError("usage", 'milestone add <key> --title "..." [--exit "what done means"] [--source "docs/plan.md#section"] [--depends-on a,b] [--informs c,d] [--priority n|none] (no exit and no dependencies = a container for ongoing work)');
|
|
660
|
+
const deps = str(p.flags, "depends-on") !== undefined ? (str(p.flags, "depends-on") ?? "").split(",").map((s) => s.trim()).filter(Boolean) : existing?.dependencies?.filter((d) => d.kind === "blocks").map((d) => d.key) ?? existing?.depends_on ?? [];
|
|
661
|
+
const informs = str(p.flags, "informs") !== undefined ? (str(p.flags, "informs") ?? "").split(",").map((s) => s.trim()).filter(Boolean) : existing?.dependencies?.filter((d) => d.kind === "informs").map((d) => d.key) ?? [];
|
|
662
|
+
const dependencies = [...deps.map((key) => ({ key, kind: "blocks" })), ...informs.map((key) => ({ key, kind: "informs" }))];
|
|
601
663
|
const exit = str(p.flags, "exit") ?? existing?.exit ?? "";
|
|
602
664
|
const source = str(p.flags, "source") ?? existing?.source ?? "";
|
|
665
|
+
const default_tags = str(p.flags, "default-tags") !== undefined ? (str(p.flags, "default-tags") ?? "").split(",").map((s) => s.trim().replace(/^#/, "")).filter(Boolean) : existing?.default_tags ?? [];
|
|
603
666
|
// --priority <n> (higher first) or none; the steward asks for units only on the highest-priority ready slices.
|
|
604
667
|
const pr = str(p.flags, "priority");
|
|
605
668
|
if (pr !== undefined && pr !== "none" && !/^-?\d+$/.test(pr))
|
|
606
669
|
throw new CliError("usage", "--priority takes a whole number (higher first) or none");
|
|
607
670
|
const priority = pr === undefined ? existing?.priority ?? null : pr === "none" ? null : Number(pr);
|
|
608
|
-
const next = cur.map((m) => ({ key: m.key, title: m.title, exit: m.exit, source: m.source ?? "", depends_on: m.depends_on, priority: m.priority ?? null }));
|
|
671
|
+
const next = cur.map((m) => ({ key: m.key, title: m.title, exit: m.exit, source: m.source ?? "", depends_on: m.dependencies ?? m.depends_on, default_tags: m.default_tags ?? [], priority: m.priority ?? null }));
|
|
609
672
|
if (existing)
|
|
610
|
-
Object.assign(next.find((m) => m.key === key), { title, exit, source, depends_on:
|
|
673
|
+
Object.assign(next.find((m) => m.key === key), { title, exit, source, depends_on: dependencies, default_tags, priority });
|
|
611
674
|
else
|
|
612
|
-
next.push({ key, title, exit, source, depends_on:
|
|
675
|
+
next.push({ key, title, exit, source, depends_on: dependencies, default_tags, priority });
|
|
613
676
|
const r = await client.call("PUT", `/projects/${project}/milestones`, { milestones: next });
|
|
614
677
|
const m = r.milestones.find((x) => x.key === key);
|
|
615
678
|
out.print(`${sub === "add" ? "Added" : "Updated"} milestone ${m.key}: ${m.title} [${m.ready ? "ready" : `waits on ${m.waiting_on.join(", ")}`}]${!m.exit && !m.depends_on.length ? " (container: never chased)" : ""}`, r);
|
|
@@ -619,14 +682,14 @@ export async function milestoneWith(client, project, sub, key, p, out) {
|
|
|
619
682
|
const m = (await client.call("GET", `/projects/${project}/milestones`)).milestones.find((x) => x.key === key);
|
|
620
683
|
if (!m)
|
|
621
684
|
throw new CliError("not_found", `no milestone ${key}`);
|
|
622
|
-
out.print(`${m.key}: ${m.title} [${m.status}${m.status === "open" && !m.ready ? `, waits on ${m.waiting_on.join(", ")}` : ""}]${m.priority !== null && m.priority !== undefined ? `\n priority: ${m.priority}` : ""}\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);
|
|
685
|
+
out.print(`${m.key}: ${m.title} [${m.status}${m.status === "open" && !m.ready ? `, waits on ${m.waiting_on.join(", ")}` : ""}]${m.priority !== null && m.priority !== undefined ? `\n priority: ${m.priority}` : ""}\n depends on: ${m.depends_on.join(", ") || "-"}\n default tags: ${(m.default_tags ?? []).map((t) => `#${t}`).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);
|
|
623
686
|
return;
|
|
624
687
|
}
|
|
625
688
|
if (sub === "close") {
|
|
626
689
|
const note = str(p.flags, "note");
|
|
627
690
|
if (!note)
|
|
628
691
|
throw new CliError("usage", 'milestone close <key> --note "how the exit criterion was met" [--evidence id,id] [--abandon | --defer]');
|
|
629
|
-
const r = await client.call("POST",
|
|
692
|
+
const r = await client.call("POST", "/projects/" + project + "/milestones/" + key + "/close", { how: p.flags.abandon ? "abandoned" : p.flags.defer ? "deferred" : "done", note, waive_informs: str(p.flags, "waive-informs"), evidence: (str(p.flags, "evidence") ?? "").split(",").map((s) => s.trim()).filter(Boolean) });
|
|
630
693
|
out.print(`Milestone ${r.milestone.key} ${r.milestone.status}.`, r);
|
|
631
694
|
return;
|
|
632
695
|
}
|
|
@@ -637,7 +700,7 @@ export async function milestoneWith(client, project, sub, key, p, out) {
|
|
|
637
700
|
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)');
|
|
638
701
|
const evidence = (str(p.flags, "evidence") ?? "").split(",").map((x) => x.trim().replace(/^evidence:/, "")).filter(Boolean);
|
|
639
702
|
const units = (str(p.flags, "units") ?? "").split(",").map((x) => Number(x.trim().replace(/^#/, ""))).filter((n) => Number.isInteger(n) && n > 0);
|
|
640
|
-
const r = await client.call("POST",
|
|
703
|
+
const r = await client.call("POST", "/projects/" + project + "/milestones/" + key + "/verdict", { met, note: str(p.flags, "note") ?? "", evidence, gaps: gaps ?? "", units, waive_informs: str(p.flags, "waive-informs") });
|
|
641
704
|
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);
|
|
642
705
|
return;
|
|
643
706
|
}
|
|
@@ -669,15 +732,15 @@ export async function record(p, out) {
|
|
|
669
732
|
if (!project)
|
|
670
733
|
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
671
734
|
const r = await client.call("GET", `/projects/${project}/record`);
|
|
672
|
-
const counters = (x) => ({ done: x.units, "1st-round": x.approved_first_round, changes: x.changes_requested, replays: x.replays, reviewed: x.reviewed, overturned: x.overturned, escalated: x.escalated });
|
|
735
|
+
const counters = (x) => ({ done: x.units, "1st-round": x.approved_first_round, changes: x.changes_requested, "2nd-read send-backs": x.second_read_changes ?? 0, replays: x.replays, reviewed: x.reviewed, overturned: x.overturned, escalated: x.escalated });
|
|
673
736
|
if (str(p.flags, "by") === "model") {
|
|
674
737
|
// The same counters keyed by what produced the work: model and effort setting at the time of the start or the verdict.
|
|
675
738
|
const rows = (r.by_model ?? []).map((x) => ({ model: x.model, effort: x.effort, tag: `#${x.tag}`, ...counters(x), agents: x.agents.join(",") }));
|
|
676
|
-
out.print(rows.length ? table(rows, ["model", "effort", "tag", "done", "1st-round", "changes", "replays", "reviewed", "overturned", "escalated", "agents"]) : "(no reviewed units yet)", r);
|
|
739
|
+
out.print(rows.length ? table(rows, ["model", "effort", "tag", "done", "1st-round", "changes", "2nd-read send-backs", "replays", "reviewed", "overturned", "escalated", "agents"]) : "(no reviewed units yet)", r);
|
|
677
740
|
return;
|
|
678
741
|
}
|
|
679
742
|
const rows = r.record.map((x) => ({ agent: x.agent, tag: `#${x.tag}`, ...counters(x) }));
|
|
680
|
-
out.print(rows.length ? table(rows, ["agent", "tag", "done", "1st-round", "changes", "replays", "reviewed", "overturned", "escalated"]) : "(no reviewed units yet)", r);
|
|
743
|
+
out.print(rows.length ? table(rows, ["agent", "tag", "done", "1st-round", "changes", "2nd-read send-backs", "replays", "reviewed", "overturned", "escalated"]) : "(no reviewed units yet)", r);
|
|
681
744
|
}
|
|
682
745
|
/** bschat lock <name> [--unit n] [--note ..] | bschat unlock <name> | bschat locks */
|
|
683
746
|
export async function lock(p, out) {
|
|
@@ -721,7 +784,24 @@ export async function askOperator(p, out) {
|
|
|
721
784
|
const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
|
|
722
785
|
if (!project)
|
|
723
786
|
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
724
|
-
const
|
|
787
|
+
const amend = str(p.flags, "amend");
|
|
788
|
+
if (amend) {
|
|
789
|
+
const text = (p.positionals.slice(1).join(" ") || str(p.flags, "question") || "").trim();
|
|
790
|
+
const body = {};
|
|
791
|
+
if (text)
|
|
792
|
+
body.text = text;
|
|
793
|
+
for (const [flag, field] of [["plain", "plain"], ["blocks", "blocks"], ["if-yes", "if_yes"], ["if-no", "if_no"], ["propose", "proposal"]]) {
|
|
794
|
+
const value = str(p.flags, flag);
|
|
795
|
+
if (value !== undefined)
|
|
796
|
+
body[field] = value;
|
|
797
|
+
}
|
|
798
|
+
if (!Object.keys(body).length)
|
|
799
|
+
throw new CliError("usage", "ask-operator --amend <id> [new question] [--plain ...] [--blocks ...] [--if-yes ...] [--if-no ...] [--propose ...]");
|
|
800
|
+
const result = await client.call("POST", "/projects/" + project + "/asks/" + amend + "/amend", body);
|
|
801
|
+
out.print("Amended your open ask " + amend + "; the operator was told.", result);
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const text = (p.positionals.slice(1).join(" ") || str(p.flags, "text") || str(p.flags, "question") || "").trim();
|
|
725
805
|
const fields = { plain: str(p.flags, "plain") ?? "", blocks: str(p.flags, "blocks") ?? "", if_yes: str(p.flags, "if-yes") ?? "", if_no: str(p.flags, "if-no") ?? "" };
|
|
726
806
|
const missing = Object.entries({ "--plain": fields.plain, "--blocks": fields.blocks, "--if-yes": fields.if_yes, "--if-no": fields.if_no }).filter(([, v]) => !v.trim()).map(([k]) => k);
|
|
727
807
|
if (!text || missing.length)
|
package/dist/git.js
CHANGED
|
@@ -321,6 +321,20 @@ export function fullSha(ref, cwd = process.cwd()) {
|
|
|
321
321
|
export function fetchRef(ref, remote = "origin", cwd = process.cwd()) {
|
|
322
322
|
return spawnSync("git", ["fetch", "--quiet", remote, ref], { cwd, encoding: "utf8", timeout: 120_000 }).status === 0;
|
|
323
323
|
}
|
|
324
|
+
/** Check a merge against the local target, then the freshly fetched origin target when needed. */
|
|
325
|
+
export function verifyMergedCommit(merged, target, cwd = process.cwd()) {
|
|
326
|
+
const local = isAncestor(merged, target, cwd);
|
|
327
|
+
if (local === true)
|
|
328
|
+
return { on: true, ref: target };
|
|
329
|
+
// Fetch into the remote-tracking ref explicitly. Fetching a bare branch name updates
|
|
330
|
+
// FETCH_HEAD only and leaves origin/<target> stale, which cannot verify this condition.
|
|
331
|
+
const ref = `origin/${target}`;
|
|
332
|
+
const fetched = spawnSync("git", ["fetch", "--quiet", "origin", `+refs/heads/${target}:refs/remotes/origin/${target}`], { cwd, encoding: "utf8", timeout: 120_000 }).status === 0;
|
|
333
|
+
if (!fetched)
|
|
334
|
+
return { on: local, ref: target };
|
|
335
|
+
const remote = isAncestor(merged, ref, cwd);
|
|
336
|
+
return remote === true ? { on: true, ref } : { on: remote, ref };
|
|
337
|
+
}
|
|
324
338
|
/**
|
|
325
339
|
* A worktree detached at exactly `sha`, for reading someone else's submission: made if absent,
|
|
326
340
|
* reused if it is already at that commit, refused if it is at something else or dirty.
|
package/dist/help.js
CHANGED
|
@@ -27,15 +27,15 @@ Agent commands
|
|
|
27
27
|
bschat back clear your away status early
|
|
28
28
|
bschat send <channel> <message...> [--reply-to <seq>] @name, @role:name, @role:* are resolved and validated
|
|
29
29
|
bschat send <channel> --body-file <f|-> multi-line / markdown message from a file or stdin (use this for anything long)
|
|
30
|
-
bschat read <channel> [--since <seq>] [--limit n] [--follow]
|
|
30
|
+
bschat read <channel> [--since <seq>] [--limit n] [--follow] | bschat read --pending
|
|
31
31
|
bschat inbox [--unread] [--after <iso-time>] [--limit n] mentions of you and replies to your messages
|
|
32
32
|
bschat follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
|
|
33
33
|
other channels appear as a one-line unread digest
|
|
34
|
-
bschat process the project's process: tag vocabulary
|
|
35
|
-
bschat wu open "<title>" --scope "..." [--tags a,b] [--evidence id[,id...] ...] [--target <branch>] [--here] open a work unit in its own
|
|
34
|
+
bschat process the project's process: tag vocabulary and reviewer focus, machine/path requirements, slice defaults, agreements
|
|
35
|
+
bschat wu open "<title>" --scope "..." [--tags a,b] [--requires cap,cap] [--evidence id[,id...] ...] [--target <branch>] [--here] open a work unit in its own
|
|
36
36
|
worktree; tags come from the vocabulary; --target is the branch it lands in (default: the
|
|
37
37
|
process target), e.g. a lane branch; wu target <n> <branch|default> changes it before review
|
|
38
|
-
bschat wu assign "<title>" --to <agent|auto|queue> --scope ".." [--tags a,b] [--replay-of n] hand out a unit (assigner roles);
|
|
38
|
+
bschat wu assign "<title>" --to <agent|auto|queue> --scope ".." [--tags a,b] [--requires cap,cap] [--force] [--replay-of n] hand out a unit (assigner roles);
|
|
39
39
|
auto queues it when nobody qualified is free; queue waits deliberately; naming a
|
|
40
40
|
busy worker reserves it for them (theirs when free, anyone's after the takeover
|
|
41
41
|
window); --hold keeps it assigned to them however long it takes
|
|
@@ -53,13 +53,13 @@ Agent commands
|
|
|
53
53
|
bschat record --by model the same, keyed by model and effort setting (stamped on start and on each verdict)
|
|
54
54
|
bschat milestones the plan's slices: ready or waiting on which, units done/total; wu open|assign --milestone <key>
|
|
55
55
|
bschat milestones set --file plan.json define or replace the plan (assigner roles or the operator): a JSON list of
|
|
56
|
-
{key, title, exit, depends_on}; existing keys keep their status; cycles are refused
|
|
57
|
-
bschat milestone add <key> --title ".." [--exit ".."] [--source "docs/plan.md#b0"] [--depends-on a,b] [--priority n] add one slice (assigner
|
|
56
|
+
{key, title, exit, depends_on, default_tags}; existing keys keep their status; cycles are refused
|
|
57
|
+
bschat milestone add <key> --title ".." [--exit ".."] [--source "docs/plan.md#b0"] [--depends-on a,b] [--informs c,d] [--default-tags a,b] [--priority n] add one slice (assigner
|
|
58
58
|
roles or the operator); --source is where the full brief lives, read only when planning the slice;
|
|
59
59
|
no exit and no dependencies makes a container for ongoing work; milestone edit (or set) <key> amends
|
|
60
60
|
bschat milestone show <key> exit criterion, dependencies, counts; wu milestone <n> <key|none> moves a unit
|
|
61
|
-
bschat milestone close <key> --note ".." [--evidence a,b] [--abandon | --defer] the lead closes a slice against its exit criterion
|
|
62
|
-
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
|
|
61
|
+
bschat milestone close <key> --note ".." [--evidence a,b] [--abandon | --defer] [--waive-informs ".."] the lead closes a slice against its exit criterion
|
|
62
|
+
bschat milestone verdict <key> --met --note ".." [--evidence a,b] | --gaps ".." [--units n,m] [--waive-informs ".."] the closure reviewer judges the exit against the evidence; gap units re-trigger the review when they close
|
|
63
63
|
bschat milestone gap-units <key> --units n,m name the units (on any slice) that address its last gaps verdict: stops the chase, re-reviews when they close
|
|
64
64
|
bschat milestone review <key> assigner or operator: request a closure review now (the steward does it when the last unit closes)
|
|
65
65
|
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)
|
|
@@ -82,6 +82,8 @@ Agent commands
|
|
|
82
82
|
bschat wu wait <n> --on <m> | --clear owner or assigner: this unit cannot move until #m closes; reminders pause meanwhile
|
|
83
83
|
bschat wu scope <n> --scope ".." --note ".." assigner or operator: amend what a unit covers; recorded and announced
|
|
84
84
|
bschat ask-operator "what you need from them" --plain ".." --blocks ".." --if-yes ".." --if-no ".." [--propose ".."]
|
|
85
|
+
bschat ask-operator --amend <id> ["new question"] [--plain ".."] [--blocks ".."] [--if-yes ".."] [--if-no ".."] [--propose ".."] amend your own open ask
|
|
86
|
+
bschat ask-operator refuses a second ask naming the same WU; use --amend <id>. Account needs group asks/questions by unit and can answer several together.
|
|
85
87
|
a decision only the operator can make, on their console banner and reported to them; never
|
|
86
88
|
ask in chat. --plain: one or two sentences for someone who has not read the thread;
|
|
87
89
|
--blocks: what's stuck; --if-yes/--if-no: what happens on each answer
|
|
@@ -92,7 +94,7 @@ Agent commands
|
|
|
92
94
|
bschat wu hold <n> --note ".." operator or assigner: no verdict and no merge until the owner resubmits;
|
|
93
95
|
wu release <n> [--note ..] lifts it earlier
|
|
94
96
|
bschat wu evidence replace <n> <old> <new> [--note ".."] owner replaces attached evidence; old id is retained in the unit history
|
|
95
|
-
bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies
|
|
97
|
+
bschat wu done <n> --merged <sha> [--keep-worktree] after approval; verifies locally, then on origin if needed; removes the unit's clean worktree
|
|
96
98
|
bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
|
|
97
99
|
bschat worktrees prune [--yes] [--archive] remove clean worktrees whose work landed or whose unit is closed (dry run without --yes);
|
|
98
100
|
--archive also saves a closed unit's uncommitted files to archive/wu<n>-leftovers and removes it
|
|
@@ -195,15 +197,15 @@ bschat-admin login (approve it in your signed-in browser); the session lasts 30
|
|
|
195
197
|
bschat-admin channel create|delete <project> <name>
|
|
196
198
|
bschat-admin keys [create | revoke <id>] list admin and agent keys; create shows a new admin key once
|
|
197
199
|
bschat-admin process show|export <project> [--out f] the process as agents are told it, or as an editable file
|
|
198
|
-
bschat-admin process set <project> --file process.json publish definition, vocabulary and agreements in one version
|
|
199
|
-
bschat-admin process tag add|edit|remove <project> <tag> [--meaning ..] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role r|none]
|
|
200
|
+
bschat-admin process set <project> --file process.json publish definition, vocabulary and agreements in one version (including capabilities, review_rules and tag focus)
|
|
201
|
+
bschat-admin process tag add|edit|remove <project> <tag> [--meaning ..] [--require-evidence yes|no] [--require-rebased yes|no] [--expert-role r|none] [--requires name,name]
|
|
200
202
|
bschat-admin process timing <project> [--sla m] [--takeover m] [--max-open n] [--max-in-progress n] [--require-scope yes|no] [--require-evidence yes|no] [--require-cited-changes yes|no] [--default-approver r|none]
|
|
201
203
|
bschat-admin process merge <project> [--target b] [--merged-by owner|approver|integrator] [--integrator-role r] [--require-rebased|--require-merge-commit|--require-pushed yes|no]
|
|
202
204
|
bschat-admin process assigners <project> role1,role2 | agreements <project> --file agreements.md
|
|
203
205
|
bschat-admin process charter <project> --file charter.md how the project weighs trade-offs; sent with every expert question
|
|
204
206
|
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)
|
|
205
207
|
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)
|
|
206
|
-
bschat-admin milestone <project> add|edit <key> --title .. [--exit ..] [--source ..] [--depends-on a,b] one slice in, the rest untouched
|
|
208
|
+
bschat-admin milestone <project> add|edit <key> --title .. [--exit ..] [--source ..] [--depends-on a,b] [--informs c,d] [--default-tags a,b] one slice in, the rest untouched
|
|
207
209
|
bschat-admin milestone <project> show|review|reopen <key> | close <key> --note .. [--abandon|--defer] | verdict <key> --met|--gaps .. | gap-units <key> --units n,m
|
|
208
210
|
bschat-admin role edit <name> [--project p] --reviews a,b --works c --trials d which tags a role reviews, works and trials ("*" all, "" none)
|
|
209
211
|
bschat-admin needs decisions waiting on you (asks, unit questions, broken wake paths, alert failures)
|