architecture-harness 0.22.0 → 0.23.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/LICENSE +21 -0
- package/package.json +23 -3
- package/src/cli/bash-command-guard.mjs +44 -5
- package/src/cli/bash-command-guard.test.mjs +35 -1
- package/src/cli/check-commands.mjs +82 -0
- package/src/cli/check-commands.test.mjs +190 -0
- package/src/cli/check.mjs +34 -13
- package/src/cli/ci-template.test.mjs +12 -0
- package/src/cli/cli.test.mjs +17 -1
- package/src/cli/codex-implement.mjs +7 -2
- package/src/cli/codex-implement.test.mjs +29 -0
- package/src/cli/commit-msg.mjs +5 -2
- package/src/cli/commit-msg.test.mjs +12 -0
- package/src/cli/dispatch-reminder.mjs +4 -1
- package/src/cli/dispatch-reminder.test.mjs +5 -1
- package/src/cli/generated-file-guard.mjs +10 -1
- package/src/cli/generated-file-guard.test.mjs +10 -0
- package/src/cli/git-hooks.test.mjs +5 -0
- package/src/cli/post-edit-gate.test.mjs +9 -2
- package/src/cli/pr-check.mjs +15 -2
- package/src/cli/pr-check.test.mjs +19 -9
- package/src/cli/qc.mjs +27 -3
- package/src/cli/screens-discovery.mjs +60 -0
- package/src/cli/screens.mjs +84 -0
- package/src/cli/shell-command.mjs +3 -1
- package/src/cli/stack.mjs +14 -0
- package/src/cli/stop-gate.test.mjs +17 -0
- package/src/cli/work-order-guard.mjs +2 -2
- package/src/config.mjs +15 -0
- package/src/config.test.mjs +33 -1
- package/src/eslint/rules/no-raw-fetch.mjs +42 -2
- package/src/eslint/rules.test.mjs +15 -0
- package/src/gates/audit-append-only.mjs +18 -4
- package/src/gates/audit-append-only.test.mjs +19 -0
- package/src/gates/tenant-predicate.mjs +147 -7
- package/src/gates/tenant-predicate.test.mjs +55 -0
- package/src/gates/tenant-tables.mjs +5 -2
- package/src/gates/tenant-tables.test.mjs +8 -0
- package/src/gates/threshold-ratchet.mjs +12 -9
- package/src/gates/threshold-ratchet.test.mjs +16 -0
- package/src/plugin.test.mjs +28 -0
- package/src/screens/auth-context.test.mjs +41 -0
- package/src/screens/auth-run.test.mjs +147 -0
- package/src/screens/auth.mjs +223 -0
- package/src/screens/auth.test.mjs +76 -0
- package/src/screens/capture-idle.test.mjs +27 -0
- package/src/screens/capture.browser-test.mjs +73 -0
- package/src/screens/capture.mjs +175 -0
- package/src/screens/capture.test.mjs +28 -0
- package/src/screens/catalog.browser-test.mjs +32 -0
- package/src/screens/catalog.mjs +72 -0
- package/src/screens/catalog.test.mjs +36 -0
- package/src/screens/chrome.mjs +21 -0
- package/src/screens/compare.mjs +40 -0
- package/src/screens/compare.test.mjs +30 -0
- package/src/screens/discovery.browser-test.mjs +29 -0
- package/src/screens/discovery.mjs +158 -0
- package/src/screens/discovery.test.mjs +27 -0
- package/src/screens/inventory.mjs +69 -0
- package/src/screens/inventory.test.mjs +10 -0
- package/src/screens/map.mjs +63 -0
- package/src/screens/map.test.mjs +35 -0
- package/src/screens/open.browser-test.mjs +50 -0
- package/src/screens/regions.mjs +137 -0
- package/src/screens/regions.test.mjs +38 -0
- package/src/screens/session-files.mjs +39 -0
- package/src/screens/session-files.test.mjs +39 -0
- package/src/screens/setup.browser-test.mjs +49 -0
- package/src/screens/setup.mjs +78 -0
- package/src/screens/stack-auth.browser-test.mjs +30 -0
- package/src/screens/stack-auth.mjs +106 -0
- package/src/screens/stack-auth.test.mjs +65 -0
- package/src/screens/write-guard.mjs +26 -0
- package/src/stack/stack.mjs +131 -0
- package/src/stack/stack.test.mjs +40 -0
- package/src/stack/supervisor.mjs +30 -0
- package/templates/github/workflows/ci.yml +13 -5
package/src/cli/cli.test.mjs
CHANGED
|
@@ -267,14 +267,30 @@ test("a clean mirror run names every root it judged", async () => {
|
|
|
267
267
|
rmSync(dir, { recursive: true, force: true });
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
-
test("a fresh init repository with the default config passes the hooks check", async
|
|
270
|
+
test("a fresh init repository with the default config passes the hooks check", async t => {
|
|
271
271
|
const dir = repo();
|
|
272
|
+
const globalConfig = process.env.GIT_CONFIG_GLOBAL;
|
|
273
|
+
const fixtureConfig = path.join(dir, ".git", "fixture-global-config");
|
|
274
|
+
writeFileSync(fixtureConfig, "");
|
|
275
|
+
process.env.GIT_CONFIG_GLOBAL = fixtureConfig;
|
|
276
|
+
t.after(() => { if (globalConfig === undefined) delete process.env.GIT_CONFIG_GLOBAL; else process.env.GIT_CONFIG_GLOBAL = globalConfig; });
|
|
272
277
|
await quiet(() => runInit(load(dir)));
|
|
273
278
|
const config = load(dir);
|
|
274
279
|
assert.deepEqual(hookDrift(dir, requiredHooks(config)).problems, []);
|
|
275
280
|
rmSync(dir, { recursive: true, force: true });
|
|
276
281
|
});
|
|
277
282
|
|
|
283
|
+
test("a gate with nothing to judge says skipped and names what is missing, never a bare OK", async () => {
|
|
284
|
+
const dir = repo();
|
|
285
|
+
await quiet(() => runInit(load(dir)));
|
|
286
|
+
const { lines } = await runCheck(load(dir));
|
|
287
|
+
for (const name of ["sql", "claims", "public", "internal", "mirror"]) {
|
|
288
|
+
const line = lines.find((entry) => entry.startsWith(`OK ${name} `));
|
|
289
|
+
assert.match(line ?? "", /skipped: no /, `${name} line: ${line}`);
|
|
290
|
+
}
|
|
291
|
+
rmSync(dir, { recursive: true, force: true });
|
|
292
|
+
});
|
|
293
|
+
|
|
278
294
|
test("a config with only extraExemptHelpers checks the kit defaults and the extra helper", async () => {
|
|
279
295
|
const dir = repo();
|
|
280
296
|
await quiet(() => runInit(load(dir)));
|
|
@@ -40,7 +40,7 @@ export function parseArgs(argv) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const isDone = (progress) => existsSync(progress) && readFileSync(progress, "utf8").
|
|
43
|
+
const isDone = (progress) => existsSync(progress) && readFileSync(progress, "utf8").trimEnd().split(/\r?\n/).at(-1).trim() === DONE_MARKER;
|
|
44
44
|
|
|
45
45
|
const SKILL_PLUGIN = "superpowers@claude-plugins-official";
|
|
46
46
|
const TOOL_OUTPUT_TOKENS = 4000;
|
|
@@ -60,12 +60,17 @@ const LEAN_RULES = [
|
|
|
60
60
|
"- Before the push, run the live database tests of the server code you touched through `npx qc throwaway-db --`. Never use port 5432 or another port the local stack owns.",
|
|
61
61
|
"- Work up to about 200K tokens in a session. Then leave the progress file exact and stop, so a fresh session continues.",
|
|
62
62
|
"- Keep the report under 15 lines.",
|
|
63
|
+
"- These rules never override the brief on commits or pushes. Where the brief says not to commit, make no commit. Where it says not to push, push nothing.",
|
|
63
64
|
].join("\n");
|
|
64
65
|
|
|
65
66
|
function continuationNote(progress) {
|
|
66
67
|
return (
|
|
67
68
|
`\n\n---\nThis may be a fresh session that continues earlier work. Read \`git log --oneline\` and \`git status --short\` ` +
|
|
68
|
-
`in the worktree, and the progress file ${progress}. Continue from the first unfinished task.\n\n
|
|
69
|
+
`in the worktree, and the progress file ${progress}. Continue from the first unfinished task.\n\n` +
|
|
70
|
+
`The runner owns the done marker: ${DONE_MARKER}. The brief never needs to supply it. ` +
|
|
71
|
+
`Done means the last non-empty line of the progress file equals the marker exactly, after trimming whitespace. ` +
|
|
72
|
+
`Write it as the last line, alone, only when the exit criteria hold. ` +
|
|
73
|
+
`Never quote it anywhere else. Never wait for anyone to supply it.\n\n${LEAN_RULES}`
|
|
69
74
|
);
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -21,6 +21,29 @@ function setup(t, { progress = "" } = {}) {
|
|
|
21
21
|
|
|
22
22
|
const quiet = () => {};
|
|
23
23
|
|
|
24
|
+
for (const [name, progress] of [
|
|
25
|
+
["marker in prose", `Do not append ${DONE_MARKER} until the push succeeds.\n`],
|
|
26
|
+
["marker before more lines", `${DONE_MARKER}\nPush remains unfinished.\n`],
|
|
27
|
+
["quoted marker", `"${DONE_MARKER}"\n`],
|
|
28
|
+
["empty progress", "\n \n"],
|
|
29
|
+
]) {
|
|
30
|
+
test(`${name} never ends the job before or after a run`, async (t) => {
|
|
31
|
+
const { argv } = setup(t, { progress });
|
|
32
|
+
let calls = 0;
|
|
33
|
+
const run = async () => {
|
|
34
|
+
calls += 1;
|
|
35
|
+
return { status: 0, tail: "work remains" };
|
|
36
|
+
};
|
|
37
|
+
assert.equal(await runCodexImplement([...argv, "--max-runs", "1"], { run, say: quiet }), 3);
|
|
38
|
+
assert.equal(calls, 1);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
test("the last non-empty line accepts the exact marker with surrounding whitespace", async (t) => {
|
|
43
|
+
const { argv } = setup(t, { progress: `Tasks pushed.\r\n \t${DONE_MARKER}\t \r\n \r\n\t\r\n` });
|
|
44
|
+
assert.equal(await runCodexImplement(argv, { run: async () => assert.fail("no run"), say: quiet }), 0);
|
|
45
|
+
});
|
|
46
|
+
|
|
24
47
|
test("a progress file that already says ALL TASKS DONE exits 0 with no run", async (t) => {
|
|
25
48
|
const { argv } = setup(t, { progress: `task 1 committed\n${DONE_MARKER}\n` });
|
|
26
49
|
let calls = 0;
|
|
@@ -79,11 +102,17 @@ test("every run prompt carries the lean rules after the brief", async (t) => {
|
|
|
79
102
|
assert.equal(seen.length, 2);
|
|
80
103
|
for (const prompt of seen) {
|
|
81
104
|
assert.ok(prompt.startsWith(readFileSync(brief, "utf8")));
|
|
105
|
+
assert.ok(prompt.includes(DONE_MARKER));
|
|
106
|
+
assert.match(prompt, /last non-empty line.*equals.*exactly.*trimming whitespace/i);
|
|
107
|
+
assert.match(prompt, /last line, alone.*only when.*exit criteria/i);
|
|
108
|
+
assert.match(prompt, /never quote.*anywhere else/i);
|
|
109
|
+
assert.match(prompt, /never wait for anyone to supply/i);
|
|
82
110
|
assert.match(prompt, /at most 40 lines/);
|
|
83
111
|
assert.match(prompt, /re-verify/);
|
|
84
112
|
assert.match(prompt, /line ranges/);
|
|
85
113
|
assert.match(prompt, /helper agents/);
|
|
86
114
|
assert.match(prompt, /Then run the local check once, make one commit, and push once\./);
|
|
115
|
+
assert.match(prompt, /never override the brief on commits or pushes/);
|
|
87
116
|
assert.match(prompt, /npx qc gate-slot --/);
|
|
88
117
|
assert.match(prompt, /npx qc throwaway-db --/);
|
|
89
118
|
assert.match(prompt, /Never use port 5432/);
|
package/src/cli/commit-msg.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import { scriptPattern } from "../gates/english-source.mjs";
|
|
|
10
10
|
|
|
11
11
|
export const INSTALL_HINT = "pnpm add -D @commitlint/lint @commitlint/config-conventional";
|
|
12
12
|
const TRAILER = /^co-authored-by:\s*\S/im;
|
|
13
|
+
// `git commit -v` puts the diff under this line, after the comment character, and git drops it all.
|
|
14
|
+
const SCISSORS = /^\S -{24} >8 -{24}\s*$/;
|
|
13
15
|
|
|
14
16
|
const importPath = async (file) => (await import(pathToFileURL(file).href)).default;
|
|
15
17
|
|
|
@@ -58,8 +60,9 @@ export async function loadCommitlint(root) {
|
|
|
58
60
|
* @returns {Promise<{rule: string, detail: string}[]>}
|
|
59
61
|
*/
|
|
60
62
|
export async function checkCommitMessage(raw, options, commitlint) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
+
const lines = raw.split(/\r?\n/);
|
|
64
|
+
const cut = lines.findIndex((line) => SCISSORS.test(line));
|
|
65
|
+
const message = (cut === -1 ? lines : lines.slice(0, cut))
|
|
63
66
|
.filter((line) => !line.startsWith("#"))
|
|
64
67
|
.join("\n")
|
|
65
68
|
.trim();
|
|
@@ -31,6 +31,18 @@ test("a message that is not English fails, whatever commitlint says", async () =
|
|
|
31
31
|
assert.deepEqual(problems.map((problem) => problem.rule), ["english"]);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
test("the diff that git commit -v puts under the scissors line is not part of the message", async () => {
|
|
35
|
+
const commitlint = await loadCommitlint(HARNESS);
|
|
36
|
+
const raw = [
|
|
37
|
+
"fix(ui): save the photo",
|
|
38
|
+
"# ------------------------ >8 ------------------------",
|
|
39
|
+
"# Do not modify or remove the line above.",
|
|
40
|
+
"diff --git a/x.ts b/x.ts",
|
|
41
|
+
`+const label = "写真を保存する"; ${"x".repeat(120)}`,
|
|
42
|
+
].join("\n");
|
|
43
|
+
assert.deepEqual(await checkCommitMessage(raw, {}, commitlint), []);
|
|
44
|
+
});
|
|
45
|
+
|
|
34
46
|
test("with no commitlint installed, the check fails with the install command, unless conventional is off", async (t) => {
|
|
35
47
|
const commitlint = await loadCommitlint(emptyDir(t));
|
|
36
48
|
assert.equal(commitlint, null);
|
|
@@ -32,7 +32,10 @@ export const WORKER_NOTE =
|
|
|
32
32
|
"Write every task in your brief: write the failing test, run only that test file, make it pass, " +
|
|
33
33
|
"and run typecheck and lint on what you touched. Then run the local check once, make one commit, and push once. " +
|
|
34
34
|
"Do not run the full gate (`pnpm check`) or e2e; CI runs them. " +
|
|
35
|
-
"
|
|
35
|
+
"The runner owns the done marker `ALL TASKS DONE`; the brief never needs to supply it. " +
|
|
36
|
+
"Done means the last non-empty line of the progress file equals the marker exactly, after trimming whitespace. " +
|
|
37
|
+
"Write it as the last line, alone, only when the exit criteria hold and every task is pushed. " +
|
|
38
|
+
"Never quote it anywhere else. Never wait for anyone to supply it. " +
|
|
36
39
|
"If your context gets large, write notes to the progress file and end the turn: a fresh session continues.";
|
|
37
40
|
|
|
38
41
|
const ROLES = ["sdd-planner", "sdd-implementer", "sdd-reviewer", "sdd-branch-reviewer"];
|
|
@@ -296,7 +296,11 @@ test("the worker note says to work inline, write every task, check and commit on
|
|
|
296
296
|
/typecheck and lint on what you touched/,
|
|
297
297
|
/Then run the local check once, make one commit, and push once./,
|
|
298
298
|
/Do not run the full gate \(`pnpm check`\) or e2e; CI runs them/,
|
|
299
|
-
/
|
|
299
|
+
/runner owns the done marker `ALL TASKS DONE`/,
|
|
300
|
+
/last non-empty line.*equals.*exactly.*trimming whitespace/,
|
|
301
|
+
/last line, alone, only when the exit criteria hold/,
|
|
302
|
+
/Never quote it anywhere else/,
|
|
303
|
+
/Never wait for anyone to supply it/,
|
|
300
304
|
/context gets large.*end the turn.*fresh session continues/,
|
|
301
305
|
]) {
|
|
302
306
|
assert.match(WORKER_NOTE, phrase);
|
|
@@ -36,6 +36,14 @@ function editsRegion(file, input) {
|
|
|
36
36
|
return edits.some((one) => typeof one?.old_string === "string" && one.old_string !== "" && touchesRegion(text, lf(one.old_string), regions));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** True when a Write of the Markdown file changes or drops a generated region. Text outside them is free. */
|
|
40
|
+
function writesRegion(file, content) {
|
|
41
|
+
if (!existsSync(file) || typeof content !== "string") return false;
|
|
42
|
+
const regionsOf = (text) => generatedRegions(text).map(([start, end]) => text.slice(start, end));
|
|
43
|
+
const after = regionsOf(lf(content));
|
|
44
|
+
return regionsOf(lf(readFileSync(file, "utf8"))).some((region) => !after.includes(region));
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
/** The verdict on one edit. @returns the hook output, or null to let the call run with no message. */
|
|
40
48
|
export function decide(call) {
|
|
41
49
|
const input = call.tool_input ?? {};
|
|
@@ -56,7 +64,8 @@ export function decide(call) {
|
|
|
56
64
|
if (globMatcher(generated.globs)(rel)) {
|
|
57
65
|
return deny(`Generated-file guard: ${rel} is generated. ${rerun}`);
|
|
58
66
|
}
|
|
59
|
-
|
|
67
|
+
const changesRegion = call.tool_name === "Write" ? writesRegion(file, input.content) : editsRegion(file, input);
|
|
68
|
+
if (MARKDOWN.test(rel) && changesRegion) {
|
|
60
69
|
return deny(`Generated-file guard: the edit changes the generated region of ${rel}. ${rerun}`);
|
|
61
70
|
}
|
|
62
71
|
return null;
|
|
@@ -85,6 +85,16 @@ test("an edit whose old_string lies in or across a generated region is denied",
|
|
|
85
85
|
assert.ok(reasonOf(decide({ ...edit(doc, ""), ...multi })));
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
+
test("a Write of the whole doc that changes or drops its generated region is denied, and one that keeps it passes", (t) => {
|
|
89
|
+
const ws = workspace(t);
|
|
90
|
+
const doc = ws.at("docs/enforcement.md");
|
|
91
|
+
const writeOf = (content) => ({ ...write(doc), tool_input: { file_path: doc, content } });
|
|
92
|
+
assert.ok(reasonOf(decide(writeOf(ENFORCEMENT.replace("qc/comment-style", "qc/other")))));
|
|
93
|
+
assert.ok(reasonOf(decide(writeOf("# Enforcement\n"))));
|
|
94
|
+
assert.equal(decide(writeOf(ENFORCEMENT.replace("Hand-written intro.", "A new intro."))), null);
|
|
95
|
+
assert.equal(decide(writeOf(`${ENFORCEMENT}\n<!-- generated: more. pnpm codegen. -->\n<!-- /generated -->\n`)), null);
|
|
96
|
+
});
|
|
97
|
+
|
|
88
98
|
test("an edit outside the generated region passes", (t) => {
|
|
89
99
|
const ws = workspace(t);
|
|
90
100
|
assert.equal(decide(edit(ws.at("docs/enforcement.md"), "Hand-written judgement calls.")), null);
|
|
@@ -15,6 +15,11 @@ function repo(t) {
|
|
|
15
15
|
const root = realpathSync.native(mkdtempSync(path.join(os.tmpdir(), "qc-git-hooks-")));
|
|
16
16
|
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
17
17
|
execFileSync("git", ["init", "-q"], { cwd: root, stdio: "pipe" });
|
|
18
|
+
const globalConfig = process.env.GIT_CONFIG_GLOBAL;
|
|
19
|
+
const fixtureConfig = path.join(root, ".git", "fixture-global-config");
|
|
20
|
+
writeFileSync(fixtureConfig, "");
|
|
21
|
+
process.env.GIT_CONFIG_GLOBAL = fixtureConfig;
|
|
22
|
+
t.after(() => { if (globalConfig === undefined) delete process.env.GIT_CONFIG_GLOBAL; else process.env.GIT_CONFIG_GLOBAL = globalConfig; });
|
|
18
23
|
const git = (...args) => execFileSync("git", args, { cwd: root, stdio: "pipe" });
|
|
19
24
|
const hook = (dir, name, text) => {
|
|
20
25
|
mkdirSync(path.join(root, dir), { recursive: true });
|
|
@@ -35,8 +35,8 @@ function workspace() {
|
|
|
35
35
|
return { project, linked, plain, outside, pluginRoot: path.join(base, "plugin"), ranIn, cleanup: () => rmSync(base, { recursive: true, force: true }) };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function runHook(ws, file) {
|
|
39
|
-
const featureFile = path.join(file,
|
|
38
|
+
function runHook(ws, file, featureDir = "features") {
|
|
39
|
+
const featureFile = path.join(file, featureDir, "tasks", "index.ts");
|
|
40
40
|
mkdirSync(path.dirname(featureFile), { recursive: true });
|
|
41
41
|
writeFileSync(featureFile, "export {};\n");
|
|
42
42
|
return spawnSync("bash", [HOOK], {
|
|
@@ -74,6 +74,13 @@ test("a feature file in the session's own project is checked from the project",
|
|
|
74
74
|
assert.deepEqual(ws.ranIn(), [ws.project]);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
test("a file under a layout with no features folder is checked too, since featureDir is the repository's own", (t) => {
|
|
78
|
+
const ws = workspace();
|
|
79
|
+
t.after(ws.cleanup);
|
|
80
|
+
assert.equal(runHook(ws, path.join(ws.project, "src"), "modules"), 2);
|
|
81
|
+
assert.deepEqual(ws.ranIn(), [ws.project]);
|
|
82
|
+
});
|
|
83
|
+
|
|
77
84
|
test("a checkout with its own installed harness is checked by that copy, not the plugin's", (t) => {
|
|
78
85
|
const ws = workspace();
|
|
79
86
|
t.after(ws.cleanup);
|
package/src/cli/pr-check.mjs
CHANGED
|
@@ -46,17 +46,26 @@ export async function checkPullRequest(event, { gh = runGh, hasToken, ci = false
|
|
|
46
46
|
notes: [],
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
// The CI template sets GH_TOKEN, so a CI run without one had it removed, and would pass unread.
|
|
50
|
+
if (!hasToken) {
|
|
51
|
+
return ci
|
|
52
|
+
? { problems: ["no GH_TOKEN, so the issues cannot be looked up. Set GH_TOKEN for this step."], notes: [] }
|
|
53
|
+
: { problems: [], notes: ["no GH_TOKEN, so the issues were not looked up"] };
|
|
54
|
+
}
|
|
50
55
|
|
|
51
56
|
const problems = [];
|
|
52
57
|
const notes = [];
|
|
58
|
+
let unseen = 0;
|
|
53
59
|
for (const { repo, number } of references) {
|
|
54
60
|
const name = `${repo}#${number}`;
|
|
55
61
|
const result = await gh(["issue", "view", String(number), "-R", repo, "--json", "createdAt"]);
|
|
56
62
|
if (!result.ok) {
|
|
57
63
|
const stderr = result.stderr ?? "";
|
|
58
64
|
if (NO_ISSUE.test(stderr)) problems.push(`${name} does not exist. Open the issue, then reference it.`);
|
|
59
|
-
else if (NO_REPOSITORY.test(stderr))
|
|
65
|
+
else if (NO_REPOSITORY.test(stderr)) {
|
|
66
|
+
unseen++;
|
|
67
|
+
notes.push(`the token cannot see ${repo}, so ${name} was not looked up`);
|
|
68
|
+
}
|
|
60
69
|
else if (ci && result.missing) problems.push(`gh is not installed, so ${name} cannot be checked`);
|
|
61
70
|
else {
|
|
62
71
|
const message = `could not reach GitHub for ${name}: ${stderr.trim().split("\n")[0]}`;
|
|
@@ -69,6 +78,10 @@ export async function checkPullRequest(event, { gh = runGh, hasToken, ci = false
|
|
|
69
78
|
problems.push(`${name} was opened after the pull request. Register the work before it starts.`);
|
|
70
79
|
}
|
|
71
80
|
}
|
|
81
|
+
// A reference the token cannot read proves nothing, so a body of only those names no issue.
|
|
82
|
+
if (unseen === references.length) {
|
|
83
|
+
problems.push(`pull request #${pr.number} names only issues the token cannot see. Also name an issue in ${event.repository?.full_name}.`);
|
|
84
|
+
}
|
|
72
85
|
return { problems, notes };
|
|
73
86
|
}
|
|
74
87
|
|
|
@@ -74,19 +74,30 @@ test("in CI a failed call to GitHub fails and quotes the first stderr line", asy
|
|
|
74
74
|
assert.deepEqual(result.notes, []);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
test("in CI with no token the check
|
|
77
|
+
test("in CI with no token the check fails and names GH_TOKEN", async () => {
|
|
78
78
|
const result = await checkPullRequest(event("Fixes #12"), { gh: missingGh, hasToken: false, ci: true });
|
|
79
|
-
assert.
|
|
80
|
-
assert.match(result.notes.join(), /no GH_TOKEN/);
|
|
79
|
+
assert.match(result.problems.join(), /no GH_TOKEN/);
|
|
81
80
|
});
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
/** Knows acme/app#12, and cannot see acme/private at all. */
|
|
83
|
+
const ghWithPrivate = async (args) =>
|
|
84
|
+
args.includes("acme/private")
|
|
85
|
+
? { ok: false, stderr: "GraphQL: Could not resolve to a Repository with the name 'acme/private'. (repository)" }
|
|
86
|
+
: ghKnowing({ "acme/app#12": "2026-05-01T00:00:00Z" })(args);
|
|
87
|
+
|
|
88
|
+
test("in CI a repository the token cannot see is a note beside an issue it can see", async () => {
|
|
89
|
+
const result = await checkPullRequest(event("Fixes #12. Refs acme/private#5"), { gh: ghWithPrivate, hasToken: true, ci: true });
|
|
86
90
|
assert.deepEqual(result.problems, []);
|
|
87
91
|
assert.match(result.notes.join(), /the token cannot see acme.private/);
|
|
88
92
|
});
|
|
89
93
|
|
|
94
|
+
test("a body that names only issues the token cannot see fails, in CI and outside it", async () => {
|
|
95
|
+
for (const ci of [true, false]) {
|
|
96
|
+
const result = await checkPullRequest(event("Refs acme/private#5"), { gh: ghWithPrivate, hasToken: true, ci });
|
|
97
|
+
assert.match(result.problems.join(), /names only issues the token cannot see\. Also name an issue in acme\/app/);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
90
101
|
test("CI=false is not CI", () => {
|
|
91
102
|
assert.equal(isCi({ CI: "true" }), true);
|
|
92
103
|
assert.equal(isCi({ CI: "1" }), true);
|
|
@@ -97,9 +108,8 @@ test("CI=false is not CI", () => {
|
|
|
97
108
|
});
|
|
98
109
|
|
|
99
110
|
test("a repository the token cannot see is a note, never a missing issue", async () => {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
assert.deepEqual(result.problems, []);
|
|
111
|
+
const result = await checkPullRequest(event("Fixes #12. Refs acme/private#5"), { gh: ghWithPrivate, hasToken: true });
|
|
112
|
+
assert.doesNotMatch(result.problems.join(), /does not exist/);
|
|
103
113
|
assert.match(result.notes.join(), /the token cannot see acme.private/);
|
|
104
114
|
});
|
|
105
115
|
|
package/src/cli/qc.mjs
CHANGED
|
@@ -24,11 +24,16 @@ const USAGE = `qc — architecture gates
|
|
|
24
24
|
qc decisions [id] where decisions are cited; --squash closes the gaps
|
|
25
25
|
qc ledger [--cost] [branch] the workflow ledger: dispatches, stops, verdicts, merges, issue updates; --cost totals tokens and tool calls
|
|
26
26
|
qc codex-implement --brief <file> --worktree <path> --progress <file> [--log <file>] [--max-runs <n>]
|
|
27
|
-
run a brief through codex exec as an implementer
|
|
27
|
+
run a brief through codex exec as an implementer; done means the last non-empty progress line equals ALL TASKS DONE after trimming whitespace
|
|
28
|
+
the runner supplies the marker; write it as the last line, alone, only when the exit criteria hold; never quote it elsewhere or wait for it; exit 2 on a Codex limit
|
|
28
29
|
qc gate-slot [--slots <n>] -- <command...>
|
|
29
30
|
run a heavy local command in one of the machine's gate slots; --status lists them
|
|
30
31
|
qc watch [--pr <n>]... [--codex <wrapper.log>]... [--run <workflow>@<branch>]... [--max <minutes>] [--repo <owner/name>] [--interval <seconds>]
|
|
31
32
|
block until the first event among the items, print one EVENT line; exit 0 done, 4 bound (default 55 minutes), 5 failed, 6 queued past 15 minutes
|
|
33
|
+
qc screens --map <json> --targets <left,right> --out <dir> [--only <names>] [--changed <target>]
|
|
34
|
+
capture authenticated screen pairs, compare pixels, and write a static gallery
|
|
35
|
+
qc stack up|down|status [names...] [--timeout <milliseconds>]
|
|
36
|
+
run repository plugins from ~/.qc/stacks.json
|
|
32
37
|
qc plan-check <plan.md> each task names files, a test step and a commit step, within the tool-call budget
|
|
33
38
|
qc tokens [--session <id>] [--project <dir>] [--claude-dir <dir>] [--json]
|
|
34
39
|
one session's tokens and cache hit rate per agent type, from its transcripts
|
|
@@ -54,6 +59,22 @@ Every gate reads qc.config.json. A key it does not set keeps the reference defau
|
|
|
54
59
|
|
|
55
60
|
async function main() {
|
|
56
61
|
const [command, ...rest] = process.argv.slice(2);
|
|
62
|
+
if (command === "stack") {
|
|
63
|
+
const { runStack } = await import("./stack.mjs");
|
|
64
|
+
process.exit(await runStack(rest));
|
|
65
|
+
}
|
|
66
|
+
if (command === "screens") {
|
|
67
|
+
// The screen packages are optional peers: only this command needs them, so a repository installs them for it.
|
|
68
|
+
try {
|
|
69
|
+
const { runScreens } = await import("./screens.mjs");
|
|
70
|
+
process.exit(await runScreens(rest));
|
|
71
|
+
} catch (error) {
|
|
72
|
+
const missing = /Cannot find package '(playwright|pixelmatch|pngjs)'/.exec(error?.message ?? "");
|
|
73
|
+
if (error?.code !== "ERR_MODULE_NOT_FOUND" || !missing) throw error;
|
|
74
|
+
console.error(`qc screens needs the ${missing[1]} package. Install the screen packages: pnpm add -D playwright pixelmatch pngjs`);
|
|
75
|
+
process.exit(2);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
57
78
|
// A broken qc.config.json must not keep a lease in place, so the lease runs before the load.
|
|
58
79
|
if (command === "lease") {
|
|
59
80
|
const { runLease } = await import("./lease.mjs");
|
|
@@ -80,8 +101,9 @@ async function main() {
|
|
|
80
101
|
case "check": {
|
|
81
102
|
const { files, listed } = await checkFiles(rest);
|
|
82
103
|
// An empty list means nothing staged to check, not the full check.
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
const { problems, lines } = listed && files.length === 0
|
|
105
|
+
? { problems: [], lines: [] }
|
|
106
|
+
: await runCheck(config, files);
|
|
85
107
|
if (problems.length > 0) {
|
|
86
108
|
for (const problem of problems) {
|
|
87
109
|
console.error(`FAIL ${problem.feature ?? problem.path} ${problem.rule}: ${problem.detail}`);
|
|
@@ -90,6 +112,8 @@ async function main() {
|
|
|
90
112
|
process.exit(1);
|
|
91
113
|
}
|
|
92
114
|
for (const line of lines) console.log(line);
|
|
115
|
+
const { runCheckCommands } = await import("./check-commands.mjs");
|
|
116
|
+
process.exitCode = await runCheckCommands(config);
|
|
93
117
|
return;
|
|
94
118
|
}
|
|
95
119
|
case "init": {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { discover, pairStates, catalogCoverage, scaffoldEntry } from "../screens/discovery.mjs";
|
|
4
|
+
import { targetSession } from "../screens/stack-auth.mjs";
|
|
5
|
+
|
|
6
|
+
/** Trigger: discovery artifacts drive pairing, coverage, and catalog scaffolds. */
|
|
7
|
+
export async function runDiscovery(command, map, values, { chromium, say }) {
|
|
8
|
+
const out = path.resolve(values.out ?? ".");
|
|
9
|
+
mkdirSync(out, { recursive: true });
|
|
10
|
+
const read = name => JSON.parse(readFileSync(path.join(out, `discovered-${name}.json`), "utf8"));
|
|
11
|
+
if (command === "discover") {
|
|
12
|
+
const target = map.targets[values.target];
|
|
13
|
+
if (!target) throw new Error("Choose --target from the map");
|
|
14
|
+
const timeout = Number(values.timeout ?? 15000);
|
|
15
|
+
const depth = Number(values.depth ?? 4);
|
|
16
|
+
const maxStates = Number(values["max-states"] ?? 500);
|
|
17
|
+
if (!Number.isInteger(depth) || depth < 0 || !Number.isInteger(maxStates) || maxStates < 1) throw new Error("Invalid depth or state bound");
|
|
18
|
+
const session = await targetSession(chromium, target, { timeout, signInTimeout: Number(values["sign-in-timeout"] ?? 180000), targetName: values.target, say });
|
|
19
|
+
try {
|
|
20
|
+
const routes = [...new Map(map.screens.flatMap(screen => screen.targets[values.target]?.path ? [screen.targets[values.target].path] : []).map(route => [route, route])).values()];
|
|
21
|
+
const result = await discover(session, { ...target, routes: target.routes ?? routes }, { out, targetName: values.target, widths: map.widths, depth, timeout, maxStates, allowWrites: values["allow-writes"], say });
|
|
22
|
+
say(JSON.stringify({ target: result.target, states: result.states.length, counts: result.counts, errors: result.errors.length, unresolvedRoutes: result.unresolvedRoutes, blockedRequests: result.blockedRequests, complete: result.complete }));
|
|
23
|
+
return result.complete ? 0 : 1;
|
|
24
|
+
} finally { await session.close(); }
|
|
25
|
+
}
|
|
26
|
+
if (command === "pair") {
|
|
27
|
+
const names = values.targets?.split(",");
|
|
28
|
+
if (names?.length !== 2) throw new Error("pair requires --targets <legacy,mono>");
|
|
29
|
+
const pairs = pairStates(read(names[0]).states, read(names[1]).states);
|
|
30
|
+
const result = { targets: names, pairs, counts: Object.fromEntries(["paired", "legacy-only", "mono-only"].map(kind => [kind, pairs.filter(item => item.kind === kind).length])) };
|
|
31
|
+
writeFileSync(path.join(out, "pairs.json"), JSON.stringify(result, null, 2));
|
|
32
|
+
say(JSON.stringify(result.counts));
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
const names = values.target ? [values.target] : readdirSync(out).filter(name => /^discovered-.+\.json$/.test(name)).map(name => name.slice(11, -5));
|
|
36
|
+
if (!names.length) throw new Error("No discoveries found");
|
|
37
|
+
if (command === "coverage") {
|
|
38
|
+
const rows = names.map(name => {
|
|
39
|
+
const discovered = read(name);
|
|
40
|
+
return { target: name, complete: discovered.complete, ...catalogCoverage(discovered.states, map.screens, map.excluded, name) };
|
|
41
|
+
});
|
|
42
|
+
writeFileSync(path.join(out, "coverage.json"), JSON.stringify(rows, null, 2));
|
|
43
|
+
for (const row of rows) say(JSON.stringify({ target: row.target, complete: row.complete, covered: row.covered, total: row.total, missing: row.missing.length }));
|
|
44
|
+
return rows.some(row => !row.complete || row.missing.length) ? 1 : 0;
|
|
45
|
+
}
|
|
46
|
+
const directory = path.resolve(values["catalog-out"] ?? path.join(out, "catalog"));
|
|
47
|
+
mkdirSync(directory, { recursive: true });
|
|
48
|
+
let written = 0;
|
|
49
|
+
for (const name of names) {
|
|
50
|
+
const family = map.targets[name]?.family ?? name.split("-")[0];
|
|
51
|
+
for (const state of read(name).states) {
|
|
52
|
+
const file = path.join(directory, `${name}-${state.id}.ts`);
|
|
53
|
+
if (existsSync(file)) continue;
|
|
54
|
+
writeFileSync(file, scaffoldEntry(state, family), { flag: "wx" });
|
|
55
|
+
written++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
say(JSON.stringify({ directory, written }));
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { loadMap } from "../screens/map.mjs";
|
|
4
|
+
import { captureScreens } from "../screens/capture.mjs";
|
|
5
|
+
import { authStatus, targetSession } from "../screens/stack-auth.mjs";
|
|
6
|
+
import { applyCatalog, openScreen } from "../screens/catalog.mjs";
|
|
7
|
+
import { runDiscovery } from "./screens-discovery.mjs";
|
|
8
|
+
import { setupLocal } from "../screens/setup.mjs";
|
|
9
|
+
import { installWriteGuard } from "../screens/write-guard.mjs";
|
|
10
|
+
|
|
11
|
+
export const USAGE = `qc screens [run [names...]|list|open <name>|auth status|auth <target> --headed|setup]
|
|
12
|
+
qc screens discover|pair|coverage|scaffold --map <json> --out <dir>
|
|
13
|
+
--map <json> [--targets <left,right>] [--target <name>] [--out <dir>]
|
|
14
|
+
[--only <names>] [--changed <target>] [--height <pixels>]
|
|
15
|
+
[--timeout <milliseconds>] [--sign-in-timeout <milliseconds>]
|
|
16
|
+
[--depth <levels>] [--max-states <count>] [--allow-writes] [--catalog-out <dir>]
|
|
17
|
+
|
|
18
|
+
Chrome must be installed. Sessions stay in ~/.qc/screens.
|
|
19
|
+
Catalog modules live outside the kit. open waits until you close its window.`;
|
|
20
|
+
|
|
21
|
+
/** Trigger: screen commands share the same catalog, sessions, and map. */
|
|
22
|
+
export async function runScreens(argv, { say = console.error, sessionFactory = targetSession } = {}) {
|
|
23
|
+
let values, positionals;
|
|
24
|
+
const command = argv[0]?.startsWith("--") || !argv.length ? "run" : argv.shift();
|
|
25
|
+
const authTarget = command === "auth" ? argv.shift() : undefined;
|
|
26
|
+
const authCommand = command === "auth" && authTarget === "status";
|
|
27
|
+
try {
|
|
28
|
+
({ values, positionals } = parseArgs({ args: argv, allowPositionals: true, strict: true, options: { map: { type: "string" }, targets: { type: "string" }, target: { type: "string" }, out: { type: "string" }, only: { type: "string" }, changed: { type: "string" }, height: { type: "string" }, timeout: { type: "string" }, "sign-in-timeout": { type: "string" }, depth: { type: "string" }, "max-states": { type: "string" }, "allow-writes": { type: "boolean" }, "catalog-out": { type: "string" }, headed: { type: "boolean" }, help: { type: "boolean" } } }));
|
|
29
|
+
if (values.help) { say(USAGE); return 0; }
|
|
30
|
+
if (!values.map) throw new Error("--map is required");
|
|
31
|
+
for (const field of ["height", "timeout", "sign-in-timeout"]) if (values[field] !== undefined && (!Number.isInteger(Number(values[field])) || Number(values[field]) < 1)) throw new Error(`--${field} must be a positive integer`);
|
|
32
|
+
const selectedTargets = values.targets?.split(",") ?? (values.target ? [values.target] : command === "auth" && !authCommand && authTarget ? [authTarget] : command === "list" ? [] : undefined);
|
|
33
|
+
const map = await applyCatalog(loadMap(path.resolve(values.map), { targets: selectedTargets }), path.resolve(values.map));
|
|
34
|
+
if (command === "list") {
|
|
35
|
+
for (const item of map.screens) say(`${item.name}\t${Object.keys(item.targets).join(", ")}`);
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
const { chromium } = await import("playwright");
|
|
39
|
+
if (command === "setup") {
|
|
40
|
+
const target = map.targets[values.target];
|
|
41
|
+
if (!target) throw new Error("Choose --target from the map");
|
|
42
|
+
say(JSON.stringify(await setupLocal(target, values.target, { chromium, timeout: Number(values.timeout ?? 15000), signInTimeout: Number(values["sign-in-timeout"] ?? 180000), say })));
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
if (["discover", "pair", "coverage", "scaffold"].includes(command)) return await runDiscovery(command, map, values, { chromium, say });
|
|
46
|
+
const timeout = Number(values.timeout ?? 15000);
|
|
47
|
+
const signInTimeout = Number(values["sign-in-timeout"] ?? 180000);
|
|
48
|
+
if (authCommand) {
|
|
49
|
+
const targets = values.target ? { [values.target]: map.targets[values.target] } : map.targets;
|
|
50
|
+
if (Object.values(targets).some(target => !target)) throw new Error("Unknown target");
|
|
51
|
+
for (const row of await authStatus(chromium, targets, { timeout })) say(JSON.stringify(row));
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if (command === "auth") {
|
|
55
|
+
const target = map.targets[authTarget];
|
|
56
|
+
if (!target || !values.headed) throw new Error("Choose auth <target> --headed from the map");
|
|
57
|
+
const session = await targetSession(chromium, target, { timeout, signInTimeout, say, targetName: authTarget, allowInteractive: true, headed: true });
|
|
58
|
+
await session.close();
|
|
59
|
+
say(`${authTarget}: signed in`);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (command === "open") {
|
|
63
|
+
const target = map.targets[values.target];
|
|
64
|
+
const item = map.screens.find(item => item.name === positionals[0]);
|
|
65
|
+
const route = item?.targets[values.target];
|
|
66
|
+
if (!target || !route) throw new Error("Choose a screen name and --target from the map");
|
|
67
|
+
const allowWrites = values["allow-writes"] === true;
|
|
68
|
+
const session = await sessionFactory(chromium, target, { timeout, signInTimeout, say, targetName: values.target, headed: true, allowWrites });
|
|
69
|
+
try {
|
|
70
|
+
await installWriteGuard(session.context, target, { allowWrites });
|
|
71
|
+
await session.page.setViewportSize({ width: map.widths[0], height: Number(values.height ?? 900) });
|
|
72
|
+
if (route.open) await openScreen(session.page, target, route, { targetName: values.target, screenName: item.name, out: path.resolve(values.out ?? "."), timeout });
|
|
73
|
+
else await session.page.goto(new URL(route.path, target.baseUrl).href, { timeout });
|
|
74
|
+
await new Promise(resolve => session.page.once("close", resolve));
|
|
75
|
+
} finally { await session.close().catch(() => {}); }
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
if (command !== "run") throw new Error(`Unknown screens command ${command}`);
|
|
79
|
+
if (!values.targets || !values.out) throw new Error("--targets and --out are required");
|
|
80
|
+
const report = await captureScreens(map, { targets: values.targets.split(",").map(name => name.trim()), out: path.resolve(values.out), only: positionals.length ? positionals.join(",") : values.only, changed: values.changed, height: Number(values.height ?? 900), timeout, signInTimeout, allowWrites: values["allow-writes"] === true }, { chromium, say });
|
|
81
|
+
for (const row of report) say(JSON.stringify(row));
|
|
82
|
+
return report.some(row => row.error) ? 1 : 0;
|
|
83
|
+
} catch (error) { say(error.exitCode === 4 ? error.message : `qc screens: ${error.message}`); return error.exitCode === 4 ? 4 : 1; }
|
|
84
|
+
}
|
|
@@ -253,7 +253,9 @@ export function gitCall(segment) {
|
|
|
253
253
|
explicitDir = true;
|
|
254
254
|
i++;
|
|
255
255
|
} else if (/^--(git-dir|work-tree)=/.test(word)) explicitDir = true;
|
|
256
|
-
else if (word === "-c") configs.push(words[++i]);
|
|
256
|
+
else if (word === "-c" || word === "--config-env") configs.push(words[++i]);
|
|
257
|
+
// `--config-env=name=VAR` sets `name` from a variable, so it is a `-c` whose value hides in the environment.
|
|
258
|
+
else if (word.startsWith("--config-env=")) configs.push(word.slice("--config-env=".length));
|
|
257
259
|
else if (!word.startsWith("-")) return { sub: word, dirs, explicitDir, configs, args: words.slice(i + 1) };
|
|
258
260
|
}
|
|
259
261
|
return { sub: null, dirs, explicitDir, configs, args: [] };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { stackAction } from "../stack/stack.mjs";
|
|
3
|
+
|
|
4
|
+
/** Trigger: a repository plugin owns each stack's lifecycle. */
|
|
5
|
+
export async function runStack(argv, { say = console.log } = {}) {
|
|
6
|
+
try {
|
|
7
|
+
const [action, ...rest] = argv;
|
|
8
|
+
const { values, positionals } = parseArgs({ args: rest, allowPositionals: true, options: { timeout: { type: "string", default: "120000" } } });
|
|
9
|
+
const timeout = Number(values.timeout);
|
|
10
|
+
if (!Number.isInteger(timeout) || timeout < 1) throw new Error("--timeout must be a positive integer");
|
|
11
|
+
for (const row of await stackAction(action, positionals, { timeout })) say(JSON.stringify(row));
|
|
12
|
+
return 0;
|
|
13
|
+
} catch (error) { say(`qc stack: ${error.message}`); return 1; }
|
|
14
|
+
}
|
|
@@ -441,6 +441,23 @@ test("a new commit makes the next stop run the full gate", (t) => {
|
|
|
441
441
|
assert.equal(ws.ran().length, 2);
|
|
442
442
|
});
|
|
443
443
|
|
|
444
|
+
test("a new installed harness on an unchanged checkout makes the next stop run the full gate", (t) => {
|
|
445
|
+
const ws = gitWorkspace(t);
|
|
446
|
+
ws.run();
|
|
447
|
+
writeFileSync(path.join(ws.repo, "node_modules", "architecture-harness", "package.json"), '{"version":"9.9.9"}');
|
|
448
|
+
ws.run();
|
|
449
|
+
assert.equal(ws.ran().length, 2);
|
|
450
|
+
ws.run();
|
|
451
|
+
assert.equal(ws.ran().length, 2);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
test("a new extra stop step on an unchanged checkout makes the next stop run the full gate", (t) => {
|
|
455
|
+
const ws = gitWorkspace(t);
|
|
456
|
+
ws.run();
|
|
457
|
+
ws.run({}, { QC_STOP_EXTRA: "true" });
|
|
458
|
+
assert.equal(ws.ran().length, 2);
|
|
459
|
+
});
|
|
460
|
+
|
|
444
461
|
test("a red first run stores nothing, so the next stop runs the full gate again", (t) => {
|
|
445
462
|
const ws = gitWorkspace(t, { codes: { check: 1 }, withDoctor: false });
|
|
446
463
|
assert.equal(ws.run().status, 2);
|
|
@@ -175,9 +175,9 @@ export async function run(root) {
|
|
|
175
175
|
return decide(call, root);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/** The verdict on one Write or
|
|
178
|
+
/** The verdict on one Write, Edit, MultiEdit or NotebookEdit call. @returns a deny payload, or null to allow it. */
|
|
179
179
|
export async function decide(call, root) {
|
|
180
|
-
const file = call.tool_input?.file_path;
|
|
180
|
+
const file = call.tool_input?.file_path ?? call.tool_input?.notebook_path;
|
|
181
181
|
if (!file) return null;
|
|
182
182
|
const absolute = path.resolve(root, file);
|
|
183
183
|
const rel = path.relative(root, absolute).split(path.sep).join("/");
|