benignswarm 0.10.0 → 0.12.0
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/commands/agent.js +2 -0
- package/dist/commands/hook.js +31 -3
- package/dist/commands/join.js +1 -1
- package/dist/commands/watch.js +28 -6
- package/dist/commands/wu.js +177 -0
- package/dist/git.js +12 -0
- package/dist/harness.js +2 -0
- package/dist/help.js +9 -0
- package/dist/index.js +3 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/agent.js
CHANGED
|
@@ -262,9 +262,11 @@ export async function skill(p, out) {
|
|
|
262
262
|
const dir = str(p.flags, "dir") ?? join(process.cwd(), ".claude", "skills", "bschat");
|
|
263
263
|
const main = await fetchText("/skill/SKILL.md");
|
|
264
264
|
const api = await fetchText("/skill/references/api.md");
|
|
265
|
+
const watchers = await fetchText("/skill/references/watchers.md");
|
|
265
266
|
mkdirSync(join(dir, "references"), { recursive: true });
|
|
266
267
|
writeFileSync(join(dir, "SKILL.md"), main);
|
|
267
268
|
writeFileSync(join(dir, "references", "api.md"), api);
|
|
269
|
+
writeFileSync(join(dir, "references", "watchers.md"), watchers);
|
|
268
270
|
out.print(`Installed skill to ${dir}`, { dir });
|
|
269
271
|
return;
|
|
270
272
|
}
|
package/dist/commands/hook.js
CHANGED
|
@@ -167,6 +167,33 @@ export async function hook(p) {
|
|
|
167
167
|
}
|
|
168
168
|
if (event === "PostModelSwitch")
|
|
169
169
|
return;
|
|
170
|
+
// Standing rules die with the context. On SessionStart (startup, resume, and after a compaction)
|
|
171
|
+
// re-deliver the role description and the project's process when the agent has not seen this
|
|
172
|
+
// version, and record that it was shown.
|
|
173
|
+
let standing = null;
|
|
174
|
+
if (harness === "claude-code" && event === "SessionStart") {
|
|
175
|
+
try {
|
|
176
|
+
const creds = loadAgent(name);
|
|
177
|
+
const client = Client.forAgent(creds, undefined, { presence: false });
|
|
178
|
+
const me = await client.call("GET", "/me");
|
|
179
|
+
const proc = me.process;
|
|
180
|
+
const compacted = input?.source === "compact";
|
|
181
|
+
if (proc && (compacted || proc.seen_version !== proc.version)) {
|
|
182
|
+
const lines = [
|
|
183
|
+
`[bschat] ${compacted ? "Your context was compacted; here is what must survive it." : "Your standing role and process."}`,
|
|
184
|
+
me.role ? `Your role: ${me.role.name}. ${me.role.description}` : `You hold no role in ${me.project?.name ?? "this project"}.`,
|
|
185
|
+
`Process v${proc.version}: work goes through bschat wu open --tags <from the vocabulary> / submit; reviewers are whoever is qualified for the tags; evidence ${proc.definition.require_evidence_to_submit ? "required" : "optional"} before review; max ${proc.definition.max_open_per_agent} open units; nothing is done until every tag is approved. Details: bschat process.`,
|
|
186
|
+
proc.agreements ? `Working agreements:\n${proc.agreements}` : null,
|
|
187
|
+
].filter(Boolean);
|
|
188
|
+
standing = lines.join("\n");
|
|
189
|
+
if (creds.project && proc.version > 0)
|
|
190
|
+
await client.call("POST", `/projects/${creds.project}/process/ack`, { version: proc.version });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
process.stderr.write(`bschat: could not fetch role/process: ${e.message}\n`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
170
197
|
// The hook firing is proof the harness is working; tell the server, at most once a minute.
|
|
171
198
|
// The session goal (/goal) rides along from the transcript, and a change goes out at once.
|
|
172
199
|
if (harness === "claude-code") {
|
|
@@ -185,12 +212,13 @@ export async function hook(p) {
|
|
|
185
212
|
}
|
|
186
213
|
}
|
|
187
214
|
const u = await gatherUpdates(name, { force: !!p.flags.force, model: str(p.flags, "model") });
|
|
188
|
-
|
|
215
|
+
const text = [standing, u?.text].filter(Boolean).join("\n\n");
|
|
216
|
+
if (!text)
|
|
189
217
|
return;
|
|
190
218
|
if (harness === "claude-code") {
|
|
191
|
-
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext:
|
|
219
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: text } }) + "\n");
|
|
192
220
|
}
|
|
193
221
|
else {
|
|
194
|
-
process.stdout.write(
|
|
222
|
+
process.stdout.write(text + "\n");
|
|
195
223
|
}
|
|
196
224
|
}
|
package/dist/commands/join.js
CHANGED
|
@@ -19,7 +19,7 @@ async function fetchSkill(url) {
|
|
|
19
19
|
throw new CliError("fetch_failed", `${url}${p} returned ${res.status}`);
|
|
20
20
|
return res.text();
|
|
21
21
|
};
|
|
22
|
-
return { skill: await get("/skill/SKILL.md"), api: await get("/skill/references/api.md") };
|
|
22
|
+
return { skill: await get("/skill/SKILL.md"), api: await get("/skill/references/api.md"), watchers: await get("/skill/references/watchers.md") };
|
|
23
23
|
}
|
|
24
24
|
function harnessList(p, vendor) {
|
|
25
25
|
const flag = str(p.flags, "harness");
|
package/dist/commands/watch.js
CHANGED
|
@@ -32,6 +32,9 @@ export async function watch(p, out) {
|
|
|
32
32
|
const followDelay = Number(str(p.flags, "follow-delay") ?? "300");
|
|
33
33
|
if (!Number.isInteger(followDelay) || followDelay < 0)
|
|
34
34
|
throw new CliError("usage", "--follow-delay must be a non-negative number of seconds");
|
|
35
|
+
const maxUnanswered = Number(str(p.flags, "max-unanswered") ?? "3");
|
|
36
|
+
if (!Number.isInteger(maxUnanswered) || maxUnanswered < 1)
|
|
37
|
+
throw new CliError("usage", "--max-unanswered must be a positive integer");
|
|
35
38
|
if (bool(p.flags, "launchd")) {
|
|
36
39
|
if (!exec)
|
|
37
40
|
throw new CliError("usage", "--launchd needs --exec so the agent knows what to run");
|
|
@@ -71,7 +74,7 @@ export async function watch(p, out) {
|
|
|
71
74
|
if (activity && heartbeatClient)
|
|
72
75
|
lastSample = await heartbeatIfActive(heartbeatClient, activity, lastSample, interval, log);
|
|
73
76
|
if (!full) {
|
|
74
|
-
await wakeOnce(name, exec, requeueAfter, followDelay, log, str(p.flags, "model"), once);
|
|
77
|
+
await wakeOnce(name, exec, requeueAfter, followDelay, maxUnanswered, log, str(p.flags, "model"), once);
|
|
75
78
|
if (once)
|
|
76
79
|
return;
|
|
77
80
|
await new Promise((r) => setTimeout(r, interval * 1000));
|
|
@@ -100,15 +103,15 @@ export async function watch(p, out) {
|
|
|
100
103
|
await new Promise((r) => setTimeout(r, interval * 1000));
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
|
-
async function wakeOnce(name, exec, requeueAfter, followDelay, log, model, once) {
|
|
106
|
+
async function wakeOnce(name, exec, requeueAfter, followDelay, maxUnanswered, log, model, once) {
|
|
104
107
|
const state = readState(name);
|
|
105
108
|
const pending = state.watch_pending;
|
|
106
109
|
// Did the agent read since we last woke it? Its own CLI calls advance these cursors.
|
|
107
110
|
if (pending) {
|
|
108
111
|
const readSince = state.inbox_after !== pending.inbox_after || JSON.stringify(state.channel_read ?? {}) !== JSON.stringify(pending.channel_read);
|
|
109
112
|
if (readSince) {
|
|
110
|
-
writeState(name, { ...state, watch_pending: undefined });
|
|
111
|
-
log(
|
|
113
|
+
writeState(name, { ...state, watch_pending: undefined, watch_unanswered: 0, watch_dormant_logged_at: undefined });
|
|
114
|
+
log(`agent has read since the last wake-up; pending cleared${state.watch_unanswered ? " (harness is answering again)" : ""}`);
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
const u = await gatherUpdates(name, { force: true, model, delivery: "watch", dryRun: true });
|
|
@@ -123,6 +126,17 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, log, model, once)
|
|
|
123
126
|
const operatorNew = u.latestOperatorAt !== null && u.latestOperatorAt !== (st.watch_operator_at ?? null);
|
|
124
127
|
const stillPending = !!st.watch_pending;
|
|
125
128
|
const stale = stillPending && Date.now() - st.watch_pending.at > requeueAfter * 1000;
|
|
129
|
+
// A thread that has ignored several wake-ups is not sleeping, it is gone (closed session, dead
|
|
130
|
+
// app). Re-queuing forever only hides that. Go dormant and say so once an hour; the agent
|
|
131
|
+
// reading anything (its own cursors moving) ends it, as does an operator writing directly.
|
|
132
|
+
const unanswered = st.watch_unanswered ?? 0;
|
|
133
|
+
if (stale && !operatorNew && unanswered >= maxUnanswered) {
|
|
134
|
+
if (Date.now() - (st.watch_dormant_logged_at ?? 0) > 3_600_000) {
|
|
135
|
+
log(`HARNESS APPEARS DEAD: ${unanswered} wake-ups went unanswered for ${Math.round(requeueAfter / 60)} min each. Not re-queuing. Pending for it: ${u.text.split("\n")[0].slice(0, 160)}. Start a new session for ${name} and re-run bschat watch --launchd with its id, or the agent reads (bschat inbox --unread) to resume.`);
|
|
136
|
+
writeState(name, { ...readState(name), watch_dormant_logged_at: Date.now() });
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
126
140
|
if (stillPending && !operatorNew && !stale) {
|
|
127
141
|
if (once)
|
|
128
142
|
log(`new activity but a wake-up is already pending (${Math.round((Date.now() - st.watch_pending.at) / 1000)}s); not queueing again`);
|
|
@@ -153,7 +167,7 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, log, model, once)
|
|
|
153
167
|
`New since you last looked: ${summary}`,
|
|
154
168
|
`Run these, in order, to read it all:`,
|
|
155
169
|
...u.readCommands.map((c) => ` ${c}`),
|
|
156
|
-
`Reply in chat with bschat send, not here.`,
|
|
170
|
+
`Reply in chat with bschat send, not here. Your role and the project's process: bschat me, bschat process.`,
|
|
157
171
|
].filter(Boolean).join("\n");
|
|
158
172
|
if (exec) {
|
|
159
173
|
const total = u.counts.messages + u.counts.items + u.counts.followed + u.counts.digest;
|
|
@@ -169,7 +183,15 @@ async function wakeOnce(name, exec, requeueAfter, followDelay, log, model, once)
|
|
|
169
183
|
else {
|
|
170
184
|
process.stdout.write(wake + "\n");
|
|
171
185
|
}
|
|
172
|
-
writeState(name, {
|
|
186
|
+
writeState(name, {
|
|
187
|
+
...readState(name),
|
|
188
|
+
watch_pending: { at: Date.now(), inbox_after: st.inbox_after, channel_read: st.channel_read ?? {} },
|
|
189
|
+
watch_operator_at: u.latestOperatorAt ?? st.watch_operator_at,
|
|
190
|
+
watch_followed_since: undefined,
|
|
191
|
+
watch_unanswered: stale ? unanswered + 1 : operatorNew ? unanswered : 0,
|
|
192
|
+
});
|
|
193
|
+
if (stale && unanswered + 1 >= maxUnanswered)
|
|
194
|
+
log(`${unanswered + 1} consecutive wake-ups unanswered; one more timeout and this watcher goes dormant until the agent reads`);
|
|
173
195
|
}
|
|
174
196
|
function shellQuote(s) {
|
|
175
197
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { str } from "../args.js";
|
|
2
|
+
import { Client } from "../client.js";
|
|
3
|
+
import { loadAgent, resolveAgentName, resolveModel } from "../config.js";
|
|
4
|
+
import { CliError } from "../errors.js";
|
|
5
|
+
import { branchAndHead, isAncestor } from "../git.js";
|
|
6
|
+
import { table } from "../output.js";
|
|
7
|
+
/**
|
|
8
|
+
* Work units under the project's process. Work is described by tags from the project's
|
|
9
|
+
* vocabulary; reviewers are whoever is qualified to review those tags.
|
|
10
|
+
*
|
|
11
|
+
* bschat wu open "<title>" --scope "<what it covers and does not>" [--tags ui,embedded] [--evidence id,id]
|
|
12
|
+
* bschat wu submit <n> [--evidence id,id] [--pr url] ask for review; routed by the unit's tags
|
|
13
|
+
* bschat wu approve <n> --note "..." covers the tags you are qualified for
|
|
14
|
+
* bschat wu changes <n> --note "..."
|
|
15
|
+
* bschat wu classify <n> --tags a,b [--note ...] classifier role only, when the process has that step
|
|
16
|
+
* bschat wu tags <n> --add a,b --remove c [--note ...] owner before review, a reviewer during it
|
|
17
|
+
* bschat wu done <n> --merged <sha> after approval; the sha is checked against the target branch
|
|
18
|
+
* bschat wu abandon <n> [--note ...]
|
|
19
|
+
* bschat wu note <n> --note "..." [--evidence id]
|
|
20
|
+
* bschat wu list [--all] [--status s] [--tag t] [--agent name]
|
|
21
|
+
* bschat wu show <n>
|
|
22
|
+
* bschat process vocabulary, who reviews what, requirements, agreements
|
|
23
|
+
*/
|
|
24
|
+
export async function wu(p, out) {
|
|
25
|
+
const sub = p.positionals[1];
|
|
26
|
+
const name = resolveAgentName(str(p.flags, "as"));
|
|
27
|
+
const creds = loadAgent(name);
|
|
28
|
+
const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name));
|
|
29
|
+
const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
|
|
30
|
+
if (!project)
|
|
31
|
+
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
32
|
+
const base = `/projects/${project}/work-units`;
|
|
33
|
+
const list = (k) => (str(p.flags, k) ?? "").split(",").map((x) => x.trim().replace(/^#/, "")).filter(Boolean);
|
|
34
|
+
const num = () => {
|
|
35
|
+
const n = Number(p.positionals[2]);
|
|
36
|
+
if (!Number.isInteger(n) || n < 1)
|
|
37
|
+
throw new CliError("usage", `wu ${sub} <number>`);
|
|
38
|
+
return n;
|
|
39
|
+
};
|
|
40
|
+
const tags = (u) => (u.tags.length ? u.tags.map((t) => `#${t}`).join(" ") : "(untagged)");
|
|
41
|
+
const fmt = (u) => {
|
|
42
|
+
const reviewers = u.reviewers.map((r) => `${r.name}${r.tags.length ? ` for ${r.tags.map((t) => `#${t}`).join(" ")}` : ""}`).join(", ");
|
|
43
|
+
const approvals = u.approvals.map((a) => a.name).join(", ");
|
|
44
|
+
return [
|
|
45
|
+
`WU #${u.number} [${u.status}] ${tags(u)} ${u.title}`,
|
|
46
|
+
` owner ${u.owner_name}${reviewers ? ` · reviewers ${reviewers}` : ""}${approvals ? ` · approved by ${approvals}` : ""}${u.uncovered?.length ? ` · awaiting ${u.uncovered.map((t) => `#${t}`).join(" ")}` : ""}`,
|
|
47
|
+
` ${u.branch ? `${u.branch}${u.head ? ` @ ${u.head}` : ""}` : "no branch recorded"}${u.pr_url ? ` · ${u.pr_url}` : ""}${u.merged_sha ? ` · merged ${u.merged_sha}` : ""}${u.evidence.length ? ` · evidence ${u.evidence.map((e) => `evidence:${e}`).join(" ")}` : ""}`,
|
|
48
|
+
u.scope ? ` scope: ${u.scope}` : null,
|
|
49
|
+
].filter(Boolean).join("\n");
|
|
50
|
+
};
|
|
51
|
+
const processDef = async () => (await client.call("GET", `/projects/${project}/process`)).process.definition;
|
|
52
|
+
switch (sub) {
|
|
53
|
+
case "open": {
|
|
54
|
+
const title = p.positionals.slice(2).join(" ").trim();
|
|
55
|
+
if (!title)
|
|
56
|
+
throw new CliError("usage", 'wu open "<title>" --scope "<what it covers and does not>" [--tags a,b] [--evidence id]');
|
|
57
|
+
const r = await client.call("POST", base, { title, scope: str(p.flags, "scope") ?? "", tags: list("tags"), evidence: list("evidence"), ...branchAndHead() });
|
|
58
|
+
out.print(`${fmt(r.unit)}\nSubmit for review when ready: bschat wu submit ${r.unit.number} --evidence <id>`, r);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
case "submit": {
|
|
62
|
+
const def = await processDef();
|
|
63
|
+
const where = branchAndHead();
|
|
64
|
+
let rebased = null;
|
|
65
|
+
// The rebase requirement may come from the project or from a tag; the server tells us which
|
|
66
|
+
// when it refuses. Check locally whenever we are in a repo so the claim is always a finding.
|
|
67
|
+
if (where.head) {
|
|
68
|
+
rebased = isAncestor(def.merge.target_branch, "HEAD");
|
|
69
|
+
if (rebased === null)
|
|
70
|
+
rebased = null;
|
|
71
|
+
}
|
|
72
|
+
const pr = str(p.flags, "pr") ?? null;
|
|
73
|
+
const r = await client.call("POST", `${base}/${num()}/submit`, { evidence: list("evidence"), ...where, pr_url: pr, rebased });
|
|
74
|
+
const u = r.unit;
|
|
75
|
+
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);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
case "approve":
|
|
79
|
+
case "changes": {
|
|
80
|
+
const note = str(p.flags, "note");
|
|
81
|
+
if (!note)
|
|
82
|
+
throw new CliError("usage", `wu ${sub} <n> --note "what you checked, or what must change"`);
|
|
83
|
+
const r = await client.call("POST", `${base}/${num()}/${sub}`, { note });
|
|
84
|
+
out.print(fmt(r.unit), r);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
case "classify": {
|
|
88
|
+
const r = await client.call("POST", `${base}/${num()}/classify`, { tags: list("tags"), note: str(p.flags, "note") ?? "" });
|
|
89
|
+
out.print(fmt(r.unit), r);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
case "tags": {
|
|
93
|
+
const add = list("add");
|
|
94
|
+
const remove = list("remove");
|
|
95
|
+
if (!add.length && !remove.length)
|
|
96
|
+
throw new CliError("usage", "wu tags <n> --add a,b --remove c [--note ...]");
|
|
97
|
+
const r = await client.call("POST", `${base}/${num()}/tags`, { add, remove, note: str(p.flags, "note") ?? "" });
|
|
98
|
+
out.print(fmt(r.unit), r);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
case "done": {
|
|
102
|
+
const def = await processDef();
|
|
103
|
+
const merged = str(p.flags, "merged") ?? null;
|
|
104
|
+
if (merged) {
|
|
105
|
+
const on = isAncestor(merged, def.merge.target_branch);
|
|
106
|
+
if (on === null)
|
|
107
|
+
throw new CliError("unknown_commit", `cannot verify ${merged} against ${def.merge.target_branch} in this repository`, `Run from the repo with ${def.merge.target_branch} fetched: git fetch origin ${def.merge.target_branch}:${def.merge.target_branch}`);
|
|
108
|
+
if (!on)
|
|
109
|
+
throw new CliError("not_merged", `${merged} is not on ${def.merge.target_branch}`, "Merge first, then pass the merge commit (or the branch head once it is on the target).");
|
|
110
|
+
}
|
|
111
|
+
else if (def.merge.require_merge_commit) {
|
|
112
|
+
throw new CliError("usage", `this project's process requires the merge commit: bschat wu done ${num()} --merged <sha>`);
|
|
113
|
+
}
|
|
114
|
+
const r = await client.call("POST", `${base}/${num()}/done`, { note: str(p.flags, "note") ?? "", merged });
|
|
115
|
+
out.print(fmt(r.unit), r);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
case "abandon": {
|
|
119
|
+
const r = await client.call("POST", `${base}/${num()}/abandon`, { note: str(p.flags, "note") ?? "" });
|
|
120
|
+
out.print(fmt(r.unit), r);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
case "note": {
|
|
124
|
+
const r = await client.call("POST", `${base}/${num()}/note`, { note: str(p.flags, "note") ?? "", evidence: list("evidence") });
|
|
125
|
+
out.print(fmt(r.unit), r);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
case "show": {
|
|
129
|
+
const r = await client.call("GET", `${base}/${num()}`);
|
|
130
|
+
const events = r.events.map((e) => ` ${e.at.slice(0, 16).replace("T", " ")} ${e.type.padEnd(18)} ${e.actor_name}${e.note ? `: ${e.note}` : ""}${e.data?.to && Array.isArray(e.data.to) ? ` -> ${e.data.to.join(", ")}` : ""}`).join("\n");
|
|
131
|
+
out.print(`${fmt(r.unit)}\n${events}`, r);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
case "list":
|
|
135
|
+
case undefined: {
|
|
136
|
+
const qs = new URLSearchParams();
|
|
137
|
+
if (p.flags.all)
|
|
138
|
+
qs.set("all", "1");
|
|
139
|
+
for (const k of ["status", "tag", "agent"])
|
|
140
|
+
if (str(p.flags, k))
|
|
141
|
+
qs.set(k, str(p.flags, k));
|
|
142
|
+
const r = await client.call("GET", `${base}${qs.size ? `?${qs}` : ""}`);
|
|
143
|
+
const rows = r.units.map((u) => ({ n: `#${u.number}`, status: u.status, tags: u.tags.map((t) => `#${t}`).join(" "), owner: u.owner_name, reviewers: u.reviewers.map((x) => x.name).join(",") || "-", awaiting: (u.uncovered ?? []).map((t) => `#${t}`).join(" ") || "-", title: u.title.slice(0, 50) }));
|
|
144
|
+
out.print(rows.length ? table(rows, ["n", "status", "tags", "owner", "reviewers", "awaiting", "title"]) : "(no open work units; bschat wu list --all for closed ones)", r);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
default:
|
|
148
|
+
throw new CliError("usage", "wu open|submit|approve|changes|classify|tags|done|abandon|note|show|list");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The project's process: the tag vocabulary, who reviews what, requirements, and the working agreements. */
|
|
152
|
+
export async function processCmd(p, out) {
|
|
153
|
+
const name = resolveAgentName(str(p.flags, "as"));
|
|
154
|
+
const creds = loadAgent(name);
|
|
155
|
+
const client = Client.forAgent(creds, resolveModel(str(p.flags, "model"), process.env, process.cwd(), name));
|
|
156
|
+
const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
|
|
157
|
+
if (!project)
|
|
158
|
+
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
159
|
+
const [r, b] = await Promise.all([client.call("GET", `/projects/${project}/process`), client.call("GET", `/projects/${project}/work-units/board`)]);
|
|
160
|
+
const d = r.process.definition;
|
|
161
|
+
const vocab = r.vocabulary;
|
|
162
|
+
const roles = b.roles;
|
|
163
|
+
const whoReviews = (tag) => roles.filter((x) => x.reviews.includes("*") || x.reviews.includes(tag)).map((x) => x.name);
|
|
164
|
+
const lines = [
|
|
165
|
+
`Process v${r.process.version}${r.process.version === 0 ? " (defaults; the operator has not published one)" : ""}`,
|
|
166
|
+
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"}).`,
|
|
167
|
+
...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)"}`),
|
|
168
|
+
`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.` : ""}`,
|
|
169
|
+
`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.`,
|
|
170
|
+
`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}.`,
|
|
171
|
+
`Merging: ${d.merge.merged_by === "owner" ? "the owner" : d.merge.merged_by === "approver" ? "an approver" : `a ${d.merge.integrator_role}`} merges approved work into ${d.merge.target_branch}${d.merge.require_rebased ? "; the branch must contain " + d.merge.target_branch + " before review" : ""}${d.merge.require_merge_commit ? "; done carries the merge commit (bschat wu done <n> --merged <sha>)" : ""}.`,
|
|
172
|
+
r.process.agreements ? `\nWorking agreements:\n${r.process.agreements}` : null,
|
|
173
|
+
].filter(Boolean);
|
|
174
|
+
out.print(lines.join("\n"), { ...r, roles });
|
|
175
|
+
if (creds.project && r.process.version > 0)
|
|
176
|
+
await client.call("POST", `/projects/${project}/process/ack`, { version: r.process.version });
|
|
177
|
+
}
|
package/dist/git.js
CHANGED
|
@@ -25,3 +25,15 @@ export function defaultMachine(label) {
|
|
|
25
25
|
const h = hostname();
|
|
26
26
|
return label ? `${h}/${label}` : h;
|
|
27
27
|
}
|
|
28
|
+
/** True when `ancestor` is reachable from `ref` in the repo at cwd; null when either is unknown to git. */
|
|
29
|
+
export function isAncestor(ancestor, ref, cwd = process.cwd()) {
|
|
30
|
+
if (git(["rev-parse", "--verify", "-q", `${ancestor}^{commit}`], cwd) === null || git(["rev-parse", "--verify", "-q", `${ref}^{commit}`], cwd) === null)
|
|
31
|
+
return null;
|
|
32
|
+
const r = spawnSync("git", ["merge-base", "--is-ancestor", ancestor, ref], { cwd, stdio: "ignore" });
|
|
33
|
+
return r.status === 0;
|
|
34
|
+
}
|
|
35
|
+
/** Branch and short head of the worktree at cwd, or nulls outside a repo. */
|
|
36
|
+
export function branchAndHead(cwd = process.cwd()) {
|
|
37
|
+
const a = collectAuto({ model: undefined, machine: "", cwd });
|
|
38
|
+
return { branch: a.branch, head: a.head };
|
|
39
|
+
}
|
package/dist/harness.js
CHANGED
|
@@ -103,6 +103,7 @@ export function installForHarness(root, harness, files, agentName, apiUrl) {
|
|
|
103
103
|
mkdirSync(join(neutral, "references"), { recursive: true });
|
|
104
104
|
writeFileSync(join(neutral, "SKILL.md"), files.skill);
|
|
105
105
|
writeFileSync(join(neutral, "references", "api.md"), files.api);
|
|
106
|
+
writeFileSync(join(neutral, "references", "watchers.md"), files.watchers);
|
|
106
107
|
written.push(join(neutral, "SKILL.md"));
|
|
107
108
|
switch (harness) {
|
|
108
109
|
case "claude-code": {
|
|
@@ -110,6 +111,7 @@ export function installForHarness(root, harness, files, agentName, apiUrl) {
|
|
|
110
111
|
mkdirSync(join(dir, "references"), { recursive: true });
|
|
111
112
|
writeFileSync(join(dir, "SKILL.md"), files.skill);
|
|
112
113
|
writeFileSync(join(dir, "references", "api.md"), files.api);
|
|
114
|
+
writeFileSync(join(dir, "references", "watchers.md"), files.watchers);
|
|
113
115
|
written.push(join(dir, "SKILL.md"));
|
|
114
116
|
const sp = join(root, ".claude", "settings.local.json");
|
|
115
117
|
let settings = {};
|
package/dist/help.js
CHANGED
|
@@ -28,6 +28,13 @@ Agent commands
|
|
|
28
28
|
bschat inbox [--unread] [--after <iso-time>] [--limit n] mentions of you and replies to your messages
|
|
29
29
|
bschat follow <channel> | unfollow <channel> | following followed channels' new messages are injected by the hook;
|
|
30
30
|
other channels appear as a one-line unread digest
|
|
31
|
+
bschat process the project's process: tag vocabulary, who reviews what, requirements, agreements
|
|
32
|
+
bschat wu open "<title>" --scope "..." [--tags a,b] [--evidence id] open a work unit; tags come from the vocabulary
|
|
33
|
+
bschat wu submit <n> [--evidence id] [--pr url] ask for review; routed to whoever is qualified for the tags
|
|
34
|
+
bschat wu approve|changes <n> --note ".." your approval covers the tags your role reviews; classify <n> --tags a,b
|
|
35
|
+
bschat wu tags <n> --add a --remove b retag (owner before review, a reviewer during it; may add a reviewer)
|
|
36
|
+
bschat wu done <n> --merged <sha> after approval; the CLI verifies the sha is on the target branch
|
|
37
|
+
bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
|
|
31
38
|
bschat goal [set "<text>" [--state s] | achieved | paused | stalled | abandoned | clear]
|
|
32
39
|
report your harness's /goal so the board shows what you are held to (Codex app
|
|
33
40
|
threads and DeepSeek keep it where no file shows it; Claude Code's hook reads it itself)
|
|
@@ -40,6 +47,8 @@ Agent commands
|
|
|
40
47
|
--env A,B copies those variables from this shell into the LaunchAgent (Antigravity needs
|
|
41
48
|
ANTIGRAVITY_LS_ADDRESS,ANTIGRAVITY_CSRF_TOKEN). --full queues the text itself. --once / --launchd.
|
|
42
49
|
Codex: bschat watch --exec "codex queue --thread <id> --message {summary}" --launchd
|
|
50
|
+
--max-unanswered N (default 3): after N re-wakes with no read, stop queueing and log
|
|
51
|
+
HARNESS APPEARS DEAD once an hour, until the agent reads or an operator writes.
|
|
43
52
|
Liveness: the watcher reports harness activity (Codex rollout / Antigravity conversation
|
|
44
53
|
found from the session id in --exec, or --activity <file-or-dir>) so you are not shown
|
|
45
54
|
as stale while working. Polls by the watcher or hook never count as "seen".
|
package/dist/index.js
CHANGED
|
@@ -10,6 +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, wu } from "./commands/wu.js";
|
|
13
14
|
import { CliError } from "./errors.js";
|
|
14
15
|
import { HELP } from "./help.js";
|
|
15
16
|
import { CLI_VERSION } from "./version.js";
|
|
@@ -43,6 +44,8 @@ const COMMANDS = {
|
|
|
43
44
|
watch,
|
|
44
45
|
feedback,
|
|
45
46
|
goal,
|
|
47
|
+
wu,
|
|
48
|
+
process: processCmd,
|
|
46
49
|
follow: a.followCmd,
|
|
47
50
|
unfollow: a.followCmd,
|
|
48
51
|
following: a.followCmd,
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.
|
|
1
|
+
export const CLI_VERSION = "0.12.0";
|