mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Tighten PR Prep and Test after their first runs
AI Assisted
This commit is contained in:
1 parent
ff1c793633
commit
bf23d7eeea
22 files changed
+261
-109
No files matched your search
@@ -36,12 +36,14 @@ export const BUDGETS = {
|
||||
"handoff.md": 300,
|
||||
"implement.md": 5700,
|
||||
"init.md": 300,
|
||||
"loop.md": 11100,
|
||||
"loop.md": 11600,
|
||||
"pathfinder.md": 2400,
|
||||
"plan.md": 700,
|
||||
"pr-prep.md": 4500,
|
||||
"quick-task.md": 4000,
|
||||
"review.md": 1000,
|
||||
"revise-plan.md": 1200,
|
||||
"test.md": 5400,
|
||||
"xray.md": 2500,
|
||||
},
|
||||
// One printed line each, for a session with one choice card.
|
||||
|
||||
@@ -135,6 +135,16 @@ test("coverage read --go-func: functions grouped by file, the module path droppe
|
||||
});
|
||||
});
|
||||
|
||||
test("coverage read --go-func: a nested module's files read from its own folder", () => {
|
||||
const dir = tmp("cov-go-nested");
|
||||
write(dir, "go.mod", "module example.com/shop\n\ngo 1.22\n");
|
||||
write(dir, "tools/go.mod", "module example.com/shop/tools\n\ngo 1.22\n");
|
||||
write(dir, "cover.txt", "example.com/shop/tools/gen/gen.go:5:\t\tRun\t\t50.0%\nexample.com/shop/cart/cart.go:3:\t\tAdd\t\t100.0%\n");
|
||||
const r = C(dir, "read", "--go-func", "cover.txt");
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.deepEqual(r.json.files.map((f) => f.file), ["cart/cart.go", "tools/gen/gen.go"]);
|
||||
});
|
||||
|
||||
test("coverage read: a missing file is exit 3", () => {
|
||||
const dir = tmp("cov-missing");
|
||||
const r = C(dir, "read", "--lcov", "nope.info");
|
||||
|
||||
@@ -50,6 +50,11 @@ test("run-check: not-started for a made-up command and for a missing --cwd", ()
|
||||
assert.equal(c.code, 0, c.stderr);
|
||||
assert.equal(c.json.outcome, "not-started");
|
||||
assert.equal(c.json.reason, "cwd-missing");
|
||||
const folder = tmp("check-log-dir");
|
||||
const l = runScript("plan2code-pr-prep", "run-check.mjs", ["--cmd", `${NODE} -e "process.exit(0)"`, "--log", folder]);
|
||||
assert.equal(l.code, 0, l.stderr);
|
||||
assert.equal(l.json.outcome, "not-started", "a --log that is a folder stops the check with JSON, not a crash");
|
||||
assert.equal(l.json.reason, "log-unwritable");
|
||||
});
|
||||
|
||||
test("run-check: timeout kills the whole process tree", async () => {
|
||||
|
||||
@@ -23,7 +23,7 @@ test("npm project: suite, lint, types and build checks", () => {
|
||||
{ kind: "types", cmd: "npm run typecheck" },
|
||||
{ kind: "build", cmd: "npm run build" },
|
||||
]);
|
||||
assert.deepEqual(r.coverage, [{ runner: "node", cmd: "node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=<out>", cwd: ".", reads: "lcov" }]);
|
||||
assert.deepEqual(r.coverage, [{ runner: "node", cmd: "node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=\"<out>\"", cwd: ".", reads: "lcov" }]);
|
||||
assert.equal(r.builtin, null);
|
||||
});
|
||||
|
||||
@@ -75,6 +75,14 @@ test("pnpm workspace: packages lines and the { packages } form", () => {
|
||||
{ cmd: "pnpm test", cwd: "libs/core", covers: ["libs/core/**"] },
|
||||
], "a ! line excludes its folders");
|
||||
assert.deepEqual(r.coverage, [{ runner: "jest", cmd: "npx jest --coverage --coverageReporters=lcov", cwd: "libs/core", reads: "lcov" }]);
|
||||
const inline = discover({
|
||||
"package.json": { name: "root" },
|
||||
"pnpm-lock.yaml": "",
|
||||
"pnpm-workspace.yaml": "packages: ['apps/*', \"!apps/skip\"]\n",
|
||||
"apps/web/package.json": { scripts: { test: "vitest" } },
|
||||
"apps/skip/package.json": { scripts: { test: "vitest" } },
|
||||
});
|
||||
assert.deepEqual(inline.runners, [{ cmd: "pnpm test", cwd: "apps/web", covers: ["apps/web/**"] }], "an inline packages list works too");
|
||||
const obj = discover({ "package.json": { workspaces: { packages: ["pkgs/*"] } }, "pkgs/x/package.json": { scripts: { test: "t" } } });
|
||||
assert.deepEqual(obj.runners, [{ cmd: "npm test", cwd: "pkgs/x", covers: ["pkgs/x/**"] }]);
|
||||
});
|
||||
@@ -85,7 +93,7 @@ test("Go module with a nested second module", () => {
|
||||
{ cmd: "go test ./...", cwd: ".", covers: ["**"] },
|
||||
{ cmd: "go test ./...", cwd: "tools", covers: ["tools/**"] },
|
||||
]);
|
||||
assert.deepEqual(r.coverage[0], { runner: "go", cmd: "go test -coverprofile=<out> ./... && go tool cover -func=<out>", cwd: ".", reads: "go-func" });
|
||||
assert.deepEqual(r.coverage[0], { runner: "go", cmd: "go test -coverprofile=\"<out>\" ./... && go tool cover -func=\"<out>\"", cwd: ".", reads: "go-func" });
|
||||
assert.equal(r.builtin, null);
|
||||
});
|
||||
|
||||
@@ -127,10 +135,10 @@ test("coverage is listed only with its add-on present", () => {
|
||||
assert.deepEqual(vitest({}).coverage, []);
|
||||
|
||||
const pytest = (deps) => discover({ "pyproject.toml": `[project]\ndependencies = [${deps}]\n` });
|
||||
assert.deepEqual(pytest('"pytest", "pytest-cov"').coverage, [{ runner: "pytest", cmd: "python -m pytest --cov --cov-report=lcov:<out>", cwd: ".", reads: "lcov" }]);
|
||||
assert.deepEqual(pytest('"pytest", "pytest-cov"').coverage, [{ runner: "pytest", cmd: "python -m pytest --cov --cov-report=lcov:\"<out>\"", cwd: ".", reads: "lcov" }]);
|
||||
assert.deepEqual(pytest('"pytest"').coverage, []);
|
||||
const nested = discover({ "requirements-dev.txt": "pytest-cov\n", "svc/setup.cfg": "[tool:pytest]\n" });
|
||||
assert.deepEqual(nested.coverage, [{ runner: "pytest", cmd: "python -m pytest --cov --cov-report=lcov:<out>", cwd: "svc", reads: "lcov" }], "pytest-cov listed in a folder above the runner");
|
||||
assert.deepEqual(nested.coverage, [{ runner: "pytest", cmd: "python -m pytest --cov --cov-report=lcov:\"<out>\"", cwd: "svc", reads: "lcov" }], "pytest-cov listed in a folder above the runner");
|
||||
|
||||
const dotnet = (ref) => discover({ "App.Tests/App.Tests.csproj": `<Project><ItemGroup>${ref}</ItemGroup></Project>` });
|
||||
assert.deepEqual(dotnet('<PackageReference Include="coverlet.collector" Version="6" />').coverage, [{ runner: "dotnet", cmd: 'dotnet test --collect:"XPlat Code Coverage"', cwd: "App.Tests", reads: "lcov" }]);
|
||||
|
||||
@@ -59,6 +59,24 @@ test("test-map read: a section linking to .agents-docs/AGENTS-test-map.md reads
|
||||
assert.equal(r.json.rows[0].area, "Launcher", "follows exactly one link, never a link from the linked file");
|
||||
const bare = project("## Test map\n\nSee [map](.agents-docs/AGENTS-test-map.md).\n", { ".agents-docs/AGENTS-test-map.md": TABLE });
|
||||
assert.equal(T(bare, ["read"]).json.source, ".agents-docs/AGENTS-test-map.md", "the ](.agents-docs/...) form works too");
|
||||
const nested = project("## Test map\n\nSee [map](./.agents-docs/testing/map.md).\n", { ".agents-docs/testing/map.md": TABLE });
|
||||
const n = T(nested, ["read"]);
|
||||
assert.equal(n.json.source, ".agents-docs/testing/map.md", "a link into a subfolder of .agents-docs/ is inside it");
|
||||
assert.deepEqual(n.json.problems, []);
|
||||
const escape = project("## Test map\n\nSee [map](./.agents-docs/../docs/map.md).\n", { "docs/map.md": TABLE });
|
||||
assert.match(T(escape, ["read"]).json.problems[0], /outside \.agents-docs\//, "a link that climbs out is still outside");
|
||||
const prose = project("## Test map\n\nSee [contributing](./CONTRIBUTING.md), then [map](./.agents-docs/AGENTS-test-map.md).\n", { ".agents-docs/AGENTS-test-map.md": TABLE });
|
||||
const p = T(prose, ["read"]);
|
||||
assert.equal(p.json.source, ".agents-docs/AGENTS-test-map.md", "a prose link before the docs link does not hide it");
|
||||
assert.deepEqual(p.json.problems, []);
|
||||
});
|
||||
|
||||
test("test-map write: a new nested linked file links back to AGENTS.md from its own depth", () => {
|
||||
const dir = project("## Test map\n\nSee [map](./.agents-docs/testing/map.md).\n");
|
||||
rowsFile(dir, ROWS);
|
||||
const w = T(dir, ["write", "--rows", "rows.json"]);
|
||||
assert.equal(w.code, 0, w.stderr);
|
||||
assert.match(read(dir, ".agents-docs/testing/map.md"), /\[AGENTS\.md\]\(\.\.\/\.\.\/AGENTS\.md\)/);
|
||||
});
|
||||
|
||||
test("test-map read and write: a link outside .agents-docs/ is a problem, and write refuses", () => {
|
||||
@@ -176,6 +194,10 @@ test("test-map write: a heading with no table gets one after its first paragraph
|
||||
rowsFile(bare, ROWS);
|
||||
assert.equal(T(bare, ["write", "--rows", "rows.json"]).code, 0);
|
||||
assert.match(read(bare, "AGENTS.md"), /^## Test map\n\n\| Area [\s\S]*\| yes \|\n\n## Next\n$/, "directly under a heading with no paragraph");
|
||||
const tag = project("## Test map\n\n#123 tracks this.\n\n## Next\n");
|
||||
rowsFile(tag, ROWS);
|
||||
assert.equal(T(tag, ["write", "--rows", "rows.json"]).code, 0);
|
||||
assert.match(read(tag, "AGENTS.md"), /^## Test map\n\n#123 tracks this\.\n\n\| Area /, "a line like #123 is a paragraph, not a heading");
|
||||
});
|
||||
|
||||
test("test-map write: an existing table is replaced in place, every other line byte-identical", () => {
|
||||
@@ -236,6 +258,16 @@ test("test-map write: invalid rows are exit 4 with the row index; no AGENTS.md i
|
||||
assert.equal(T(none, ["write", "--rows", "rows.json"]).code, 3);
|
||||
assert.ok(!fs.existsSync(path.join(none, "AGENTS.md")));
|
||||
assert.equal(T(dir, ["write"]).code, 2, "--rows is required");
|
||||
for (const [row, why] of [
|
||||
[{ area: "A", paths: ["src/[ab]/**"], run: "x", shared: false }, /unsupported glob/],
|
||||
[{ area: "A", paths: ["src/**"], run: "npm `t`", shared: false }, /backtick or line break/],
|
||||
[{ area: "A\nB", paths: ["src/**"], run: "x", shared: false }, /backtick or line break/],
|
||||
]) {
|
||||
rowsFile(dir, [row]);
|
||||
const w = T(dir, ["write", "--rows", "rows.json"]);
|
||||
assert.equal(w.code, 4);
|
||||
assert.match(w.json.message, why);
|
||||
}
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------ glob */
|
||||
|
||||
@@ -113,6 +113,10 @@ test("test-match covers --stdin: real review-scope.mjs output", () => {
|
||||
assert.deepEqual(r.json.matched.map((m) => m.area), ["Launcher"]);
|
||||
assert.deepEqual(r.json.unmatched, [{ file: "src/app/util.js", tests: ["src/app/util.test.js"], method: "name" }]);
|
||||
assert.equal(runScript("plan2code-pr-prep", "test-match.mjs", ["covers", "--stdin"], { cwd: dir, input: "not json" }).code, 2);
|
||||
const odd = runScript("plan2code-pr-prep", "test-match.mjs", ["covers", "--stdin"], { cwd: dir, input: JSON.stringify({ files: [{}, null, { path: "src/launcher/a.js" }] }) });
|
||||
assert.equal(odd.code, 0, odd.stderr);
|
||||
assert.deepEqual(odd.json.unmatched, [], "an entry with no path is dropped, never read as a file named undefined");
|
||||
assert.deepEqual(odd.json.matched[0].files, ["src/launcher/a.js"]);
|
||||
assert.equal(runScript("plan2code-pr-prep", "test-match.mjs", ["covers"], { cwd: dir }).code, 2);
|
||||
});
|
||||
|
||||
@@ -165,6 +169,10 @@ test("test-match gaps --scope path and --scope branch", () => {
|
||||
const p = runScript("plan2code-pr-prep", "test-match.mjs", ["gaps", "--scope", "path", "--path", "src/sub"], { cwd: dir });
|
||||
assert.equal(p.code, 0, p.stderr);
|
||||
assert.deepEqual(p.json.gaps.map((x) => x.file), ["src/sub/c.js"]);
|
||||
const all = runScript("plan2code-pr-prep", "test-match.mjs", ["gaps", "--scope", "all"], { cwd: dir });
|
||||
const dot = runScript("plan2code-pr-prep", "test-match.mjs", ["gaps", "--scope", "path", "--path", "."], { cwd: dir });
|
||||
assert.equal(dot.code, 0, dot.stderr);
|
||||
assert.deepEqual(dot.json.gaps, all.json.gaps, "--path . is the whole project");
|
||||
assert.equal(runScript("plan2code-pr-prep", "test-match.mjs", ["gaps", "--scope", "path"], { cwd: dir }).code, 2, "--scope path needs --path");
|
||||
|
||||
gitIn(dir)("checkout", "-q", "-b", "feature");
|
||||
@@ -205,6 +213,17 @@ test("test-match gaps: any matching row with a run covers a file; a row without
|
||||
assert.equal(r.json.covered, 2, "x.js by the second row, m.ts by its .mts test");
|
||||
});
|
||||
|
||||
test("test-match gaps: a test in another language never covers a file by name", () => {
|
||||
const dir = tmp("match-lang");
|
||||
write(dir, "src/foo.js", "f\n");
|
||||
write(dir, "src/foo.test.py", "t\n");
|
||||
write(dir, "src/bar.ts", "b\n");
|
||||
write(dir, "src/bar.test.js", "t\n");
|
||||
const r = runScript("plan2code-pr-prep", "test-match.mjs", ["gaps", "--scope", "all"], { cwd: dir });
|
||||
assert.equal(r.code, 0, r.stderr);
|
||||
assert.deepEqual(r.json.gaps.map((g) => g.file), ["src/foo.js"], "foo.test.py does not cover foo.js; a JS test still covers a TS file");
|
||||
});
|
||||
|
||||
test("test-match gaps: capped at 2,000 source files", () => {
|
||||
const dir = tmp("match-cap");
|
||||
for (let i = 0; i < 2005; i++) write(dir, `src/f${String(i).padStart(4, "0")}.js`, "x\n");
|
||||
|
||||
@@ -2019,8 +2019,8 @@ test("workspace cursor never moves backwards, and only changes past it are pendi
|
||||
}
|
||||
});
|
||||
|
||||
test("subagents: only the thirteen opted-in workflows offer the switch", () => {
|
||||
for (const w of ["init", "init-update", "pathfinder", "plan", "revise-plan", "document", "implement", "implement-review", "quick-task", "review", "finalize", "xray", "diagnose"]) {
|
||||
test("subagents: only the fifteen opted-in workflows offer the switch", () => {
|
||||
for (const w of ["init", "init-update", "pathfinder", "plan", "revise-plan", "document", "implement", "implement-review", "quick-task", "review", "finalize", "xray", "diagnose", "pr-prep", "test"]) {
|
||||
assert.equal(offered(w), true, w);
|
||||
assert.ok(defaultInstruction(w).length > 0, `${w} has a default instruction`);
|
||||
}
|
||||
@@ -2028,7 +2028,7 @@ test("subagents: only the thirteen opted-in workflows offer the switch", () => {
|
||||
assert.equal(offered(w), false, String(w));
|
||||
assert.equal(defaultInstruction(w), "");
|
||||
}
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 13);
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 15);
|
||||
assert.deepEqual(defaultSetting("review"), { workflow: "review", on: true, instruction: null, max: 3, strength: "balanced" });
|
||||
assert.equal(defaultSetting("changelog").on, false, "a skill without the switch is never on");
|
||||
assert.equal(effectiveInstruction({ workflow: "review", instruction: " " }), defaultInstruction("review"));
|
||||
@@ -2318,13 +2318,14 @@ test("meter: the weights and labels built from the skill list are the ones writt
|
||||
"pathfinder-chart": 2, "pathfinder-question": 0, "pathfinder-research": 1,
|
||||
plan: 2, "revise-plan": 1, document: 2, "implement-phase": 2, "implement-review-phase": 3,
|
||||
review: 2, "quick-task": 1, init: 2, "init-update": 2, finalize: 1, handoff: 0, git: 1,
|
||||
"git-commits": 0, "git-conflict": 1, changelog: 1, xray: 1, diagnose: 1,
|
||||
"git-commits": 0, "git-conflict": 1, changelog: 1, xray: 1, diagnose: 1, "pr-prep": 1, test: 1,
|
||||
});
|
||||
assert.deepEqual({ ...LAUNCH_LABELS }, {
|
||||
plan: "Plan started", "revise-plan": "Revise plan started", document: "Document started",
|
||||
review: "Review started", "quick-task": "Quick task started", init: "Init started",
|
||||
"init-update": "Init update started", finalize: "Finalize started", git: "Git started",
|
||||
changelog: "Changelog started", xray: "X-ray started", diagnose: "Diagnose started",
|
||||
"pr-prep": "PR Prep started", test: "Test started",
|
||||
});
|
||||
assert.deepEqual({ ...RUN_LABELS }, {
|
||||
"pathfinder-chart": "Pathfinder map written", "pathfinder-question": "Pathfinder question settled",
|
||||
@@ -2334,6 +2335,7 @@ test("meter: the weights and labels built from the skill list are the ones writt
|
||||
"quick-task": "Quick task built", init: "Init run", "init-update": "Init update run",
|
||||
finalize: "Finalize run", handoff: "Handoff written", git: "Git run", "git-commits": "Commits in Git",
|
||||
"git-conflict": "Git conflict help", changelog: "Changelog run", xray: "X-ray run", diagnose: "Diagnose run",
|
||||
"pr-prep": "PR Prep run", test: "Test run",
|
||||
});
|
||||
for (const t of [WEIGHTS, LAUNCH_LABELS, RUN_LABELS]) assert.ok(Object.isFrozen(t));
|
||||
});
|
||||
|
||||
@@ -481,7 +481,7 @@ test("every console workflow has its notes, and its skill's Interface reads them
|
||||
init: "init", "init-update": "init", pathfinder: "pathfinder", plan: "plan", "revise-plan": "revise-plan",
|
||||
document: "document", implement: "implement", "implement-review": "implement", "quick-task": "quick-task",
|
||||
review: "review", finalize: "finalize", handoff: "handoff", changelog: "changelog", git: "git", xray: "xray",
|
||||
diagnose: "diagnose",
|
||||
diagnose: "diagnose", "pr-prep": "pr-prep", test: "test",
|
||||
};
|
||||
const skills = fs.readdirSync(path.join(ROOT, "src")).filter((f) => /^plan2code(-.*)?\.md$/.test(f));
|
||||
for (const f of skills) {
|
||||
@@ -750,7 +750,7 @@ test("long task lines, long words, a narrow board and a narrow Ask pane never wi
|
||||
|
||||
test("over the git board a note box grows with its text, and the no-repo note only points above when a card is there", () => {
|
||||
const css = joinedCss();
|
||||
assert.match(css, /\.git-cards > \.card textarea \{ field-sizing: content; max-height: 50vh; \}/);
|
||||
assert.match(css, /\.git-cards > \.card \.md-host \{ min-height: 0; max-height: 50vh; \}/);
|
||||
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
|
||||
const fn = view.slice(view.indexOf("export function drawGitBoard("), view.indexOf("function header("));
|
||||
assert.ok(fn.includes("ctx.hasCard"), "the note checks for a card first");
|
||||
|
||||
Reference in new issue
Block a user