@mmerterden/multi-agent-pipeline 21.0.0 → 21.1.1
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/CHANGELOG.md +28 -0
- package/README.md +8 -6
- package/README.tr.md +8 -6
- package/docs/architecture.md +3 -3
- package/docs/ecosystem.md +12 -12
- package/docs/facts.json +10 -9
- package/docs/features.md +1 -1
- package/install/claude.mjs +8 -1
- package/install/templates/claude-hooks.json +12 -1
- package/manifest.json +57 -41
- package/package.json +1 -1
- package/pipeline/agents/plan-critic.md +1 -1
- package/pipeline/commands/multi-agent/address-review/SKILL.md +183 -0
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/commands/multi-agent/update/SKILL.md +6 -4
- package/pipeline/multi-agent-refs/cross-cli-contract.md +4 -4
- package/pipeline/multi-agent-refs/features/approach-choice.md +61 -0
- package/pipeline/multi-agent-refs/features/root-cause.md +98 -0
- package/pipeline/multi-agent-refs/features/usage-reporting.md +1 -1
- package/pipeline/multi-agent-refs/features/visual-evidence.md +14 -0
- package/pipeline/multi-agent-refs/help/en.md +3 -2
- package/pipeline/multi-agent-refs/help/tr.md +3 -2
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +6 -4
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +2 -0
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/debugging.md +10 -7
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/rules/tdd.md +4 -7
- package/pipeline/schemas/agent-state.schema.json +91 -0
- package/pipeline/schemas/prefs.schema.json +13 -1
- package/pipeline/schemas/toolkit-path-params.json +79 -1
- package/pipeline/scripts/_stack-routing.mjs +2 -0
- package/pipeline/scripts/approach-choice.mjs +232 -0
- package/pipeline/scripts/gate-ledger.mjs +30 -1
- package/pipeline/scripts/pr-threads.mjs +537 -0
- package/pipeline/scripts/pr-write-guard.mjs +139 -0
- package/pipeline/scripts/pr-write-guard.sh +34 -0
- package/pipeline/scripts/root-cause-gate.mjs +354 -0
- package/pipeline/skills/.skill-manifest.json +17 -5
- package/pipeline/skills/.skills-index.json +35 -2
- package/pipeline/skills/shared/README.md +8 -5
- package/pipeline/skills/shared/core/multi-agent-address-review/SKILL.md +44 -0
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/shared/core/multi-agent-update/SKILL.md +6 -4
- package/pipeline/skills/shared/external/humanizer/SKILL.md +48 -6
- package/pipeline/skills/shared/external/humanizer/evals/evals.json +13 -0
- package/pipeline/skills/shared/external/humanizer/references/turkish.md +88 -0
- package/pipeline/skills/shared/external/store-screenshots/SKILL.md +252 -0
- package/pipeline/skills/shared/external/store-screenshots/evals/evals.json +47 -0
- package/pipeline/skills/shared/external/thesis-writing/SKILL.md +140 -0
- package/pipeline/skills/shared/external/thesis-writing/evals/evals.json +40 -0
- package/pipeline/skills/shared/external/thesis-writing/references/review-checklist.md +33 -0
- package/pipeline/skills/shared/external/thesis-writing/references/turkish-thesis-conventions.md +65 -0
- package/pipeline/skills/skills-index.md +4 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* approach-choice.mjs - a free-text task with no analysis document behind
|
|
4
|
+
* it picks its approach from two or three written alternatives before the
|
|
5
|
+
* plan is decomposed, and the choice is recorded with its reason.
|
|
6
|
+
*
|
|
7
|
+
* The file is `<worktree>/.pipeline/approaches.json`:
|
|
8
|
+
*
|
|
9
|
+
* { "recommended": "<id>",
|
|
10
|
+
* "approaches": [{ "id": "kebab-id", "title": "...", "summary": "...",
|
|
11
|
+
* "pros": ["..."], "cons": ["..."],
|
|
12
|
+
* "modules": ["path or module"], "estFiles": 3 }] }
|
|
13
|
+
*
|
|
14
|
+
* or, when exploration found one sensible way only:
|
|
15
|
+
*
|
|
16
|
+
* { "skip": { "reason": "why there is no real alternative" } }
|
|
17
|
+
*
|
|
18
|
+
* check Shape: two or three approaches, unique ids, a title, a summary, at
|
|
19
|
+
* least one pro and one con each, the modules touched, an estimated
|
|
20
|
+
* file count, and a `recommended` id among them. Approaches with the
|
|
21
|
+
* same module set and file count are the same approach twice.
|
|
22
|
+
* options The picker options, recommended first, labels in outputLanguage.
|
|
23
|
+
* choose Records the pick in `state.approachChoice` (chosen, rejected, who
|
|
24
|
+
* chose, why). Quality gates active (autopilot): only the recommended
|
|
25
|
+
* approach may be taken, `--why` is required, and the choice is added
|
|
26
|
+
* to `decisions[]` so the PR and the report show it.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* approach-choice.mjs check --file <approaches.json> [--json]
|
|
30
|
+
* approach-choice.mjs options --file <approaches.json>
|
|
31
|
+
* approach-choice.mjs choose --file <approaches.json> --pick <id> [--why <text>]
|
|
32
|
+
* [--state <agent-state.json>] [--json]
|
|
33
|
+
*
|
|
34
|
+
* Exit: 0 valid or recorded · 1 invalid or refused · 2 skip (one sensible
|
|
35
|
+
* approach; the reason is printed) · 3 usage or unreadable file.
|
|
36
|
+
*
|
|
37
|
+
* @module pipeline/scripts/approach-choice
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
41
|
+
|
|
42
|
+
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
43
|
+
import { ArgsError, parseArgs, unknownSubcommand } from "../lib/args.mjs";
|
|
44
|
+
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
45
|
+
import { decisionEntry, withDecision } from "../lib/decisions.mjs";
|
|
46
|
+
import { messages, outputLanguage } from "../lib/user-facing.mjs";
|
|
47
|
+
import { gateContext, updateState } from "./gate-ledger.mjs";
|
|
48
|
+
|
|
49
|
+
exitOnHelp(import.meta.url);
|
|
50
|
+
|
|
51
|
+
const ID = /^[a-z0-9][a-z0-9-]*$/;
|
|
52
|
+
|
|
53
|
+
const TEXT = {
|
|
54
|
+
en: {
|
|
55
|
+
recommended: "(Recommended)",
|
|
56
|
+
files: (n) => `~${n} files`,
|
|
57
|
+
costIfWrong: "the plan is built on the other approach and is re-planned at approval or review",
|
|
58
|
+
},
|
|
59
|
+
tr: {
|
|
60
|
+
recommended: "(Önerilen)",
|
|
61
|
+
files: (n) => `~${n} dosya`,
|
|
62
|
+
costIfWrong: "plan diğer yaklaşım üzerine kurulur; onayda ya da review'da yeniden planlanır",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
class UsageError extends Error {}
|
|
67
|
+
|
|
68
|
+
const text = (v) => (typeof v === "string" ? v.trim() : "");
|
|
69
|
+
const list = (v) => (Array.isArray(v) ? v.map(text).filter(Boolean) : []);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Problems with an approaches document; empty passes. A `skip` document is
|
|
73
|
+
* valid when its reason is written.
|
|
74
|
+
*/
|
|
75
|
+
export function checkApproaches(doc) {
|
|
76
|
+
if (!doc || typeof doc !== "object" || Array.isArray(doc)) return ["not a JSON object"];
|
|
77
|
+
if (doc.skip !== undefined) {
|
|
78
|
+
return text(doc.skip?.reason) ? [] : ["skip needs a reason"];
|
|
79
|
+
}
|
|
80
|
+
const problems = [];
|
|
81
|
+
const items = Array.isArray(doc.approaches) ? doc.approaches : [];
|
|
82
|
+
if (items.length < 2 || items.length > 3) problems.push("two or three approaches are needed");
|
|
83
|
+
const ids = new Set();
|
|
84
|
+
const shapes = new Set();
|
|
85
|
+
items.forEach((a, i) => {
|
|
86
|
+
const at = `approaches[${i}]`;
|
|
87
|
+
if (!ID.test(a?.id ?? "")) problems.push(`${at}.id must be kebab-case`);
|
|
88
|
+
else if (ids.has(a.id)) problems.push(`${at}.id ${a.id} repeats`);
|
|
89
|
+
else ids.add(a.id);
|
|
90
|
+
if (!text(a?.title)) problems.push(`${at}.title is empty`);
|
|
91
|
+
if (!text(a?.summary)) problems.push(`${at}.summary is empty`);
|
|
92
|
+
if (!list(a?.pros).length) problems.push(`${at} needs at least one pro`);
|
|
93
|
+
if (!list(a?.cons).length) problems.push(`${at} needs at least one con`);
|
|
94
|
+
if (!list(a?.modules).length) problems.push(`${at}.modules is empty`);
|
|
95
|
+
if (!Number.isInteger(a?.estFiles) || a.estFiles < 1)
|
|
96
|
+
problems.push(`${at}.estFiles must be a positive integer`);
|
|
97
|
+
const shape = `${[...list(a?.modules)].sort().join("|")}#${a?.estFiles}`;
|
|
98
|
+
if (shapes.has(shape))
|
|
99
|
+
problems.push(`${at} touches the same modules and files as another approach`);
|
|
100
|
+
shapes.add(shape);
|
|
101
|
+
});
|
|
102
|
+
if (!ids.has(doc.recommended)) problems.push("recommended must name one of the approaches");
|
|
103
|
+
return problems;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Picker options, recommended first. */
|
|
107
|
+
export function pickerOptions(doc, t) {
|
|
108
|
+
const items = [...doc.approaches].sort(
|
|
109
|
+
(a, b) => (b.id === doc.recommended) - (a.id === doc.recommended),
|
|
110
|
+
);
|
|
111
|
+
return items.map((a) => ({
|
|
112
|
+
id: a.id,
|
|
113
|
+
label: a.id === doc.recommended ? `${a.title} ${t.recommended}` : a.title,
|
|
114
|
+
description: `${a.summary} + ${list(a.pros).join("; ")} - ${list(a.cons).join("; ")} (${t.files(a.estFiles)})`,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The record `choose` writes. */
|
|
119
|
+
export function choiceRecord(doc, pick, { by, why, path, at = new Date().toISOString() }) {
|
|
120
|
+
const chosen = doc.approaches.find((a) => a.id === pick);
|
|
121
|
+
return {
|
|
122
|
+
chosen: { id: chosen.id, title: chosen.title },
|
|
123
|
+
rejected: doc.approaches
|
|
124
|
+
.filter((a) => a.id !== pick)
|
|
125
|
+
.map((a) => ({ id: a.id, title: a.title, cons: list(a.cons) })),
|
|
126
|
+
recommended: doc.recommended,
|
|
127
|
+
by,
|
|
128
|
+
why,
|
|
129
|
+
path,
|
|
130
|
+
at,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function readDoc(path) {
|
|
135
|
+
if (!path) throw new UsageError("--file is required");
|
|
136
|
+
if (!existsSync(path)) throw new UsageError(`no file at ${path}`);
|
|
137
|
+
try {
|
|
138
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
139
|
+
} catch (err) {
|
|
140
|
+
throw new UsageError(`unreadable: ${err.message}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function run(sub, flags, emit) {
|
|
145
|
+
const t = messages(TEXT, outputLanguage());
|
|
146
|
+
const doc = readDoc(flags.file);
|
|
147
|
+
const problems = checkApproaches(doc);
|
|
148
|
+
if (problems.length) {
|
|
149
|
+
emit({ ok: false, problems }, problems.map((p) => ` - ${p}`).join("\n"));
|
|
150
|
+
return 1;
|
|
151
|
+
}
|
|
152
|
+
if (doc.skip !== undefined) {
|
|
153
|
+
emit({ ok: true, skip: true, reason: text(doc.skip.reason) }, `skip: ${text(doc.skip.reason)}`);
|
|
154
|
+
return 2;
|
|
155
|
+
}
|
|
156
|
+
if (sub === "check") {
|
|
157
|
+
emit({ ok: true, approaches: doc.approaches.length, recommended: doc.recommended }, "ok");
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
if (sub === "options") {
|
|
161
|
+
emit(pickerOptions(doc, t), JSON.stringify(pickerOptions(doc, t), null, 2));
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
if (sub === "choose") {
|
|
165
|
+
const pick = text(flags.pick);
|
|
166
|
+
if (!doc.approaches.some((a) => a.id === pick))
|
|
167
|
+
throw new UsageError(`--pick ${pick} is not an approach`);
|
|
168
|
+
const ctx = gateContext({ statePath: flags.state || null, repo: process.cwd() });
|
|
169
|
+
const why = text(flags.why);
|
|
170
|
+
if (ctx.active) {
|
|
171
|
+
if (pick !== doc.recommended) {
|
|
172
|
+
emit(
|
|
173
|
+
{ ok: false, reason: "unattended" },
|
|
174
|
+
"approach-choice: unattended runs take the recommended approach",
|
|
175
|
+
);
|
|
176
|
+
return 1;
|
|
177
|
+
}
|
|
178
|
+
if (!why) throw new UsageError("--why is required when the run chooses for itself");
|
|
179
|
+
}
|
|
180
|
+
const rec = choiceRecord(doc, pick, {
|
|
181
|
+
by: ctx.active ? "derived" : "user",
|
|
182
|
+
why: why || null,
|
|
183
|
+
path: flags.file,
|
|
184
|
+
});
|
|
185
|
+
if (ctx.statePath) {
|
|
186
|
+
await updateState(ctx.statePath, (s) => {
|
|
187
|
+
const next = { ...s, approachChoice: rec };
|
|
188
|
+
if (!ctx.active) return next;
|
|
189
|
+
return withDecision(
|
|
190
|
+
next,
|
|
191
|
+
decisionEntry({
|
|
192
|
+
what: `Took the approach "${rec.chosen.title}" over ${rec.rejected.map((r) => `"${r.title}"`).join(", ")}`,
|
|
193
|
+
why,
|
|
194
|
+
costIfWrong: t.costIfWrong,
|
|
195
|
+
phase: 1,
|
|
196
|
+
at: rec.at,
|
|
197
|
+
}),
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
emit(rec, `approach: ${rec.chosen.id} (${rec.by})`);
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
throw unknownSubcommand(sub, ["check", "options", "choose"]);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
208
|
+
const [sub, ...rest] = argv;
|
|
209
|
+
let flags;
|
|
210
|
+
try {
|
|
211
|
+
({ flags } = parseArgs(rest, {
|
|
212
|
+
booleans: ["json"],
|
|
213
|
+
strings: ["file", "pick", "why", "state"],
|
|
214
|
+
unknown: "error",
|
|
215
|
+
positionals: false,
|
|
216
|
+
}));
|
|
217
|
+
} catch (e) {
|
|
218
|
+
if (!(e instanceof ArgsError)) throw e;
|
|
219
|
+
process.stderr.write(`approach-choice: ${e.message}\n`);
|
|
220
|
+
return 3;
|
|
221
|
+
}
|
|
222
|
+
const emit = (obj, line) =>
|
|
223
|
+
process.stdout.write(`${flags.json ? JSON.stringify(obj, null, 2) : line}\n`);
|
|
224
|
+
try {
|
|
225
|
+
return await run(sub, flags, emit);
|
|
226
|
+
} catch (e) {
|
|
227
|
+
process.stderr.write(`approach-choice: ${e.message}\n`);
|
|
228
|
+
return 3;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (invokedDirectly(import.meta.url)) main().then((code) => process.exit(code));
|
|
@@ -205,10 +205,32 @@ export function attendedEvidenceGaps(state, sha, { sameTree, currentDigest = nul
|
|
|
205
205
|
wanted.includes(e?.gate),
|
|
206
206
|
);
|
|
207
207
|
const { latest } = evidenceFor(asked, { sha, currentDigest, sameTree });
|
|
208
|
-
|
|
208
|
+
const gaps = wanted.filter((g) => {
|
|
209
209
|
const e = latest.get(g);
|
|
210
210
|
return !e || !PASSING.has(e.verdict);
|
|
211
211
|
});
|
|
212
|
+
if (rootCauseGap(state)) gaps.push("root-cause");
|
|
213
|
+
return gaps;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Why a bugfix run may not commit yet on its root-cause record, or null. Read
|
|
218
|
+
* from `state.rootCause` (root-cause-gate.mjs): the record must exist, its
|
|
219
|
+
* check must pass, and it must not be escalated after three failed fixes.
|
|
220
|
+
* Any other task type is null.
|
|
221
|
+
*
|
|
222
|
+
* @param {object} state
|
|
223
|
+
* @returns {string|null}
|
|
224
|
+
*/
|
|
225
|
+
export function rootCauseGap(state) {
|
|
226
|
+
if (state?.taskType !== "bugfix") return null;
|
|
227
|
+
const rc = state.rootCause;
|
|
228
|
+
if (!rc || typeof rc !== "object") return "no root-cause record (root-cause-gate.mjs check)";
|
|
229
|
+
if (rc.escalated === true) {
|
|
230
|
+
return "three failed fixes in a row: waiting on the design question (root-cause-gate.mjs reset)";
|
|
231
|
+
}
|
|
232
|
+
if (rc.verdict !== "pass") return "the root-cause check has not passed";
|
|
233
|
+
return null;
|
|
212
234
|
}
|
|
213
235
|
|
|
214
236
|
/** The mode that applies: an explicit off/warn/block, else block for a bound run. */
|
|
@@ -694,6 +716,10 @@ export function checkCommit(
|
|
|
694
716
|
else if (!e) missing.push(g);
|
|
695
717
|
else if (!PASSING.has(e.verdict)) failing.push(e);
|
|
696
718
|
}
|
|
719
|
+
const rootCause = rootCauseGap(state);
|
|
720
|
+
if (rootCause) {
|
|
721
|
+
failing.push({ gate: "root-cause", verdict: "fail", detail: { reason: rootCause } });
|
|
722
|
+
}
|
|
697
723
|
const ok = missing.length === 0 && failing.length === 0 && stale.length === 0;
|
|
698
724
|
return { ok, missing, failing, stale, sha };
|
|
699
725
|
}
|
|
@@ -830,6 +856,9 @@ async function main(argv) {
|
|
|
830
856
|
`${[
|
|
831
857
|
`pre-commit-check: ${verb}: the run's gate ledger (${path}) has no passing ${missing.join(" / ")} for HEAD ${sha.slice(0, 12)} and the source as it is now; an edit after the build or the tests makes their verdict stale.`,
|
|
832
858
|
" Run the build and the tests through evidence-gate.mjs (Phase 2 Gate 1), and in the commit phase the review verdict (review-decision-gate.mjs), so the commit rests on recorded evidence.",
|
|
859
|
+
...(missing.includes("root-cause")
|
|
860
|
+
? [` root-cause: ${rootCauseGap(state)} (multi-agent-refs/features/root-cause.md).`]
|
|
861
|
+
: []),
|
|
833
862
|
gateMode === "block"
|
|
834
863
|
? " This session drives the run, so the commit waits for the evidence; prefs.global.attendedCommitGate.mode warn lets it through."
|
|
835
864
|
: " The commit goes ahead; prefs.global.attendedCommitGate.mode block refuses it instead.",
|