benignswarm 0.11.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/hook.js +1 -1
- package/dist/commands/wu.js +67 -49
- package/dist/help.js +5 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/hook.js
CHANGED
|
@@ -182,7 +182,7 @@ export async function hook(p) {
|
|
|
182
182
|
const lines = [
|
|
183
183
|
`[bschat] ${compacted ? "Your context was compacted; here is what must survive it." : "Your standing role and process."}`,
|
|
184
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}:
|
|
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
186
|
proc.agreements ? `Working agreements:\n${proc.agreements}` : null,
|
|
187
187
|
].filter(Boolean);
|
|
188
188
|
standing = lines.join("\n");
|
package/dist/commands/wu.js
CHANGED
|
@@ -5,19 +5,21 @@ import { CliError } from "../errors.js";
|
|
|
5
5
|
import { branchAndHead, isAncestor } from "../git.js";
|
|
6
6
|
import { table } from "../output.js";
|
|
7
7
|
/**
|
|
8
|
-
* Work units under the project's process.
|
|
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.
|
|
9
10
|
*
|
|
10
|
-
* bschat wu open "<title>" --scope "<what it covers and does not>" [--
|
|
11
|
-
* bschat wu submit <n> [--evidence id,id]
|
|
12
|
-
* bschat wu approve <n> --note "..."
|
|
13
|
-
* bschat wu changes <n> --note "..."
|
|
14
|
-
* bschat wu
|
|
15
|
-
* bschat wu
|
|
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
|
|
16
18
|
* bschat wu abandon <n> [--note ...]
|
|
17
19
|
* bschat wu note <n> --note "..." [--evidence id]
|
|
18
|
-
* bschat wu list [--all] [--status s] [--
|
|
20
|
+
* bschat wu list [--all] [--status s] [--tag t] [--agent name]
|
|
19
21
|
* bschat wu show <n>
|
|
20
|
-
* bschat process
|
|
22
|
+
* bschat process vocabulary, who reviews what, requirements, agreements
|
|
21
23
|
*/
|
|
22
24
|
export async function wu(p, out) {
|
|
23
25
|
const sub = p.positionals[1];
|
|
@@ -28,41 +30,49 @@ export async function wu(p, out) {
|
|
|
28
30
|
if (!project)
|
|
29
31
|
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
30
32
|
const base = `/projects/${project}/work-units`;
|
|
31
|
-
const list = (k) => (str(p.flags, k) ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
33
|
+
const list = (k) => (str(p.flags, k) ?? "").split(",").map((x) => x.trim().replace(/^#/, "")).filter(Boolean);
|
|
32
34
|
const num = () => {
|
|
33
35
|
const n = Number(p.positionals[2]);
|
|
34
36
|
if (!Number.isInteger(n) || n < 1)
|
|
35
37
|
throw new CliError("usage", `wu ${sub} <number>`);
|
|
36
38
|
return n;
|
|
37
39
|
};
|
|
38
|
-
const
|
|
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;
|
|
39
52
|
switch (sub) {
|
|
40
53
|
case "open": {
|
|
41
54
|
const title = p.positionals.slice(2).join(" ").trim();
|
|
42
55
|
if (!title)
|
|
43
|
-
throw new CliError("usage", 'wu open "<title>" --scope "<what it covers and does not>" [--
|
|
44
|
-
const r = await client.call("POST", base, { title, scope: str(p.flags, "scope") ?? "",
|
|
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() });
|
|
45
58
|
out.print(`${fmt(r.unit)}\nSubmit for review when ready: bschat wu submit ${r.unit.number} --evidence <id>`, r);
|
|
46
59
|
return;
|
|
47
60
|
}
|
|
48
61
|
case "submit": {
|
|
49
|
-
|
|
50
|
-
// the CLI checks it here and tells the server what it found. No check, no claim.
|
|
51
|
-
const proc = (await client.call("GET", `/projects/${project}/process`)).process.definition;
|
|
62
|
+
const def = await processDef();
|
|
52
63
|
const where = branchAndHead();
|
|
53
64
|
let rebased = null;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
rebased = isAncestor(
|
|
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");
|
|
58
69
|
if (rebased === null)
|
|
59
|
-
|
|
60
|
-
if (!rebased)
|
|
61
|
-
throw new CliError("not_rebased", `${where.branch ?? "HEAD"} does not contain ${proc.merge.target_branch}; the process requires it before review`, `git rebase ${proc.merge.target_branch} (or merge it in), re-run your checks, then: bschat wu submit ${num()}`);
|
|
70
|
+
rebased = null;
|
|
62
71
|
}
|
|
63
72
|
const pr = str(p.flags, "pr") ?? null;
|
|
64
73
|
const r = await client.call("POST", `${base}/${num()}/submit`, { evidence: list("evidence"), ...where, pr_url: pr, rebased });
|
|
65
|
-
|
|
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);
|
|
66
76
|
return;
|
|
67
77
|
}
|
|
68
78
|
case "approve":
|
|
@@ -74,27 +84,31 @@ export async function wu(p, out) {
|
|
|
74
84
|
out.print(fmt(r.unit), r);
|
|
75
85
|
return;
|
|
76
86
|
}
|
|
77
|
-
case "
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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") ?? "" });
|
|
83
98
|
out.print(fmt(r.unit), r);
|
|
84
99
|
return;
|
|
85
100
|
}
|
|
86
101
|
case "done": {
|
|
87
|
-
|
|
88
|
-
const proc = (await client.call("GET", `/projects/${project}/process`)).process.definition;
|
|
102
|
+
const def = await processDef();
|
|
89
103
|
const merged = str(p.flags, "merged") ?? null;
|
|
90
104
|
if (merged) {
|
|
91
|
-
const on = isAncestor(merged,
|
|
105
|
+
const on = isAncestor(merged, def.merge.target_branch);
|
|
92
106
|
if (on === null)
|
|
93
|
-
throw new CliError("unknown_commit", `cannot verify ${merged} against ${
|
|
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}`);
|
|
94
108
|
if (!on)
|
|
95
|
-
throw new CliError("not_merged", `${merged} is not 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).");
|
|
96
110
|
}
|
|
97
|
-
else if (
|
|
111
|
+
else if (def.merge.require_merge_commit) {
|
|
98
112
|
throw new CliError("usage", `this project's process requires the merge commit: bschat wu done ${num()} --merged <sha>`);
|
|
99
113
|
}
|
|
100
114
|
const r = await client.call("POST", `${base}/${num()}/done`, { note: str(p.flags, "note") ?? "", merged });
|
|
@@ -113,7 +127,7 @@ export async function wu(p, out) {
|
|
|
113
127
|
}
|
|
114
128
|
case "show": {
|
|
115
129
|
const r = await client.call("GET", `${base}/${num()}`);
|
|
116
|
-
const events = r.events.map((e) => ` ${e.at.slice(0, 16).replace("T", " ")} ${e.type.padEnd(18)} ${e.actor_name}${e.note ? `: ${e.note}` : ""}`).join("\n");
|
|
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");
|
|
117
131
|
out.print(`${fmt(r.unit)}\n${events}`, r);
|
|
118
132
|
return;
|
|
119
133
|
}
|
|
@@ -122,19 +136,19 @@ export async function wu(p, out) {
|
|
|
122
136
|
const qs = new URLSearchParams();
|
|
123
137
|
if (p.flags.all)
|
|
124
138
|
qs.set("all", "1");
|
|
125
|
-
for (const k of ["status", "
|
|
139
|
+
for (const k of ["status", "tag", "agent"])
|
|
126
140
|
if (str(p.flags, k))
|
|
127
141
|
qs.set(k, str(p.flags, k));
|
|
128
142
|
const r = await client.call("GET", `${base}${qs.size ? `?${qs}` : ""}`);
|
|
129
|
-
const rows = r.units.map((u) => ({ n: `#${u.number}`, status: u.status,
|
|
130
|
-
out.print(rows.length ? table(rows, ["n", "status", "
|
|
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);
|
|
131
145
|
return;
|
|
132
146
|
}
|
|
133
147
|
default:
|
|
134
|
-
throw new CliError("usage", "wu open|submit|approve|changes|
|
|
148
|
+
throw new CliError("usage", "wu open|submit|approve|changes|classify|tags|done|abandon|note|show|list");
|
|
135
149
|
}
|
|
136
150
|
}
|
|
137
|
-
/** The project's process:
|
|
151
|
+
/** The project's process: the tag vocabulary, who reviews what, requirements, and the working agreements. */
|
|
138
152
|
export async function processCmd(p, out) {
|
|
139
153
|
const name = resolveAgentName(str(p.flags, "as"));
|
|
140
154
|
const creds = loadAgent(name);
|
|
@@ -142,18 +156,22 @@ export async function processCmd(p, out) {
|
|
|
142
156
|
const project = creds.project ?? str(p.flags, "project") ?? process.env.BSCHAT_PROJECT;
|
|
143
157
|
if (!project)
|
|
144
158
|
throw new CliError("no_project", `${creds.agent} is an account-scoped agent; pass --project <name>`);
|
|
145
|
-
const r = await client.call("GET", `/projects/${project}/process`);
|
|
159
|
+
const [r, b] = await Promise.all([client.call("GET", `/projects/${project}/process`), client.call("GET", `/projects/${project}/work-units/board`)]);
|
|
146
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);
|
|
147
164
|
const lines = [
|
|
148
165
|
`Process v${r.process.version}${r.process.version === 0 ? " (defaults; the operator has not published one)" : ""}`,
|
|
149
|
-
`
|
|
150
|
-
|
|
151
|
-
`
|
|
152
|
-
`
|
|
153
|
-
`
|
|
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>)" : ""}.`,
|
|
154
172
|
r.process.agreements ? `\nWorking agreements:\n${r.process.agreements}` : null,
|
|
155
173
|
].filter(Boolean);
|
|
156
|
-
out.print(lines.join("\n"), r);
|
|
174
|
+
out.print(lines.join("\n"), { ...r, roles });
|
|
157
175
|
if (creds.project && r.process.version > 0)
|
|
158
176
|
await client.call("POST", `/projects/${project}/process/ack`, { version: r.process.version });
|
|
159
177
|
}
|
package/dist/help.js
CHANGED
|
@@ -28,10 +28,11 @@ 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:
|
|
32
|
-
bschat wu open "<title>" --scope "..." [--
|
|
33
|
-
bschat wu submit <n> [--evidence id] [--pr url] ask for review;
|
|
34
|
-
bschat wu approve|changes <n> --note ".."
|
|
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)
|
|
35
36
|
bschat wu done <n> --merged <sha> after approval; the CLI verifies the sha is on the target branch
|
|
36
37
|
bschat wu abandon <n> [--note ..] wu list [--all] / wu show <n> for state and timeline
|
|
37
38
|
bschat goal [set "<text>" [--state s] | achieved | paused | stalled | abandoned | clear]
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.
|
|
1
|
+
export const CLI_VERSION = "0.12.0";
|