mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Update the workflow prompts and skill scripts for the orchestrator, and add the shared test-runs reference
AI Assisted
This commit is contained in:
1 parent
1f80fa6a7c
commit
2468027a5a
32 files changed
+289
-221
No files matched your search
@@ -208,7 +208,7 @@ test("pathfinder gate: mechanical checks and hard caps", () => {
|
||||
assert.equal(g.mechanicalPass, false);
|
||||
const failed = g.checks.filter((c) => !c.pass).map((c) => c.id);
|
||||
assert.deepEqual(failed, ["no-open-claimed-blocked", "fog-empty", "hard-caps", "scores-at-least-18"]);
|
||||
assert.ok(g.caps.some((c) => c.dimension === "Requirements" && /not resolved/.test(c.why)));
|
||||
assert.ok(!g.caps.some((c) => c.dimension === "Requirements"), "testing is Plan's question, so no testing cap");
|
||||
assert.ok(g.caps.some((c) => c.dimension === "Risk" && /Export format records no consequences/.test(c.why)));
|
||||
assert.equal(g.planDraftPath, "specs/audit-export/PLAN-DRAFT-20260803.md");
|
||||
// Settle everything.
|
||||
@@ -312,19 +312,15 @@ test("pathfinder reconcile: rows stay in place among grouping lines, a re-opened
|
||||
assert.match(map, /### Group two\n\n- \[ \] \[Export format\]\(\.\/questions\/01-export-format\.md\)\n/, "the group heading keeps its place and the row its old tail is gone");
|
||||
});
|
||||
|
||||
test("pathfinder gate: testing posture by keyword (never from Rejected), research-style consequences count", () => {
|
||||
test("pathfinder gate: research-style consequences count", () => {
|
||||
const { root, pf } = mapFixture();
|
||||
const qd = path.join(root, pf, "questions");
|
||||
const P = (...a) => runScript("plan2code-0-pathfinder", "pathfinder.mjs", [...a, "--root", root]);
|
||||
fs.writeFileSync(path.join(qd, "03-testing-posture.md"), q("Testing posture", { state: "resolved", resolved: "2026-08-02", answer: "Unit + integration, run after each phase, moderate coverage.\n\n**Gist:** Unit." }));
|
||||
fs.writeFileSync(path.join(qd, "01-export-format.md"), q("Export format", { state: "resolved", resolved: "2026-08-02", locked: "yes", answer: "### What this implies\n\n- Excel only.\n\n**Gist:** CSV." }));
|
||||
P("reconcile", "audit-export");
|
||||
let caps = P("gate", "audit-export").json.caps;
|
||||
const caps = P("gate", "audit-export").json.caps;
|
||||
assert.ok(!caps.some((c) => c.dimension === "Requirements"), JSON.stringify(caps));
|
||||
assert.ok(!caps.some((c) => c.dimension === "Risk"), JSON.stringify(caps));
|
||||
fs.writeFileSync(path.join(qd, "03-testing-posture.md"), q("Testing posture", { state: "resolved", resolved: "2026-08-02", answer: "Unit tests.\n\n**Rejected**\n\n- Run after each phase with Moderate coverage: too slow.\n\n**Gist:** Unit." }));
|
||||
caps = P("gate", "audit-export").json.caps;
|
||||
assert.ok(caps.some((c) => c.dimension === "Requirements" && /cadence/.test(c.why)), "a cadence named only as rejected does not count");
|
||||
});
|
||||
|
||||
test("pathfinder: Form C needs a frontier; names come from the rows; NN is never handed out twice", () => {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
// Skill text for targeted test runs: the wording that tells Plan, Pathfinder,
|
||||
// Document and the build skills which tests to run and who asks about them.
|
||||
// Run with: node --test scripts/test-skill-test-runs.mjs
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const src = (...p) => fs.readFileSync(path.join(ROOT, "src", ...p), "utf8");
|
||||
|
||||
test("Plan offers the cadence and full-suite answers and checks old drafts for them", () => {
|
||||
const plan = src("plan2code-1-plan.md");
|
||||
assert.match(plan, /Phase testing\*\*: Targeted per phase.*Dedicated phase only.*None/);
|
||||
assert.match(plan, /Full suite\*\*: Offered at Finalize.*At Phase N.*Never/);
|
||||
assert.match(plan, /Before going on with any existing draft.*Deferred to Plan.*Not discussed.*Full Suite/, "the progress check names a deferred, empty or undiscussed 2.4");
|
||||
assert.match(plan, /skip testing' writes `None` and `Never`/);
|
||||
assert.match(plan, /Full Suite/, "2.4 carries a Full Suite row");
|
||||
});
|
||||
|
||||
test("Pathfinder hands testing to Plan and no longer gates on it", () => {
|
||||
const dir = path.join(ROOT, "src");
|
||||
const files = [];
|
||||
for (const entry of fs.readdirSync(dir)) {
|
||||
if (!entry.startsWith("plan2code-0-pathfinder")) continue;
|
||||
const full = path.join(dir, entry);
|
||||
if (fs.statSync(full).isDirectory()) {
|
||||
for (const f of fs.readdirSync(full)) if (f.endsWith(".md")) files.push(path.join(full, f));
|
||||
} else if (entry.endsWith(".md")) files.push(full);
|
||||
}
|
||||
assert.ok(files.length > 3, "found the Pathfinder prompts");
|
||||
assert.ok(src("plan2code-0-pathfinder-references", "handoff.md").includes("Deferred to Plan"), "the handoff writes Deferred to Plan");
|
||||
for (const f of files) {
|
||||
if (path.basename(f) === "handoff.md") continue;
|
||||
assert.doesNotMatch(fs.readFileSync(f, "utf8"), /testing posture|Run after each phase/i, `${path.basename(f)} asks no testing question`);
|
||||
}
|
||||
assert.ok(!src("plan2code-0-pathfinder-scripts", "pathfinder.mjs").includes("CADENCE_RE"), "the gate has no testing cap");
|
||||
});
|
||||
|
||||
test("Document writes Targeted, Quick checks and Full suite lines and reads test-runs.md", () => {
|
||||
const doc = src("plan2code-2-document.md");
|
||||
for (const line of ["Targeted:", "Quick checks:", "Full suite:", "test-runs.md"]) assert.ok(doc.includes(line), `Document names ${line}`);
|
||||
assert.match(doc, /only to the phase named by "At Phase N"/);
|
||||
assert.match(doc, /no Full Suite row: ask/);
|
||||
});
|
||||
|
||||
test("test-runs.md ships in the six skills that run, write or offer tests, and in no other", () => {
|
||||
// npm test has just built skills/; a direct run builds it so the check never reads a stale tree.
|
||||
if (process.env.npm_lifecycle_event !== "test") {
|
||||
execFileSync(process.execPath, [path.join(ROOT, "install.js"), "--build-skills"], { stdio: "ignore" });
|
||||
}
|
||||
const built = path.join(ROOT, "skills");
|
||||
const having = fs.readdirSync(built).filter((dir) => fs.existsSync(path.join(built, dir, "references", "test-runs.md")));
|
||||
assert.deepEqual(having.sort(), [
|
||||
"plan2code-2-document",
|
||||
"plan2code-3-implement",
|
||||
"plan2code-3-implement-review",
|
||||
"plan2code-4-finalize",
|
||||
"plan2code-quick-task",
|
||||
"plan2code-review",
|
||||
]);
|
||||
});
|
||||
|
||||
test("test-runs.md names no runner as the default and asks when unsure", () => {
|
||||
const rule = src("shared-references", "test-runs.md");
|
||||
assert.match(rule, /Ask when unsure/);
|
||||
assert.doesNotMatch(rule.replace(/`npm test`/g, ""), /\b(jest|vitest|pytest|mocha|cargo test)\b/i);
|
||||
assert.ok(rule.length < 3200, "the shared rule stays short");
|
||||
});
|
||||
|
||||
test("Implement and Implement + Review say the same targeted rule", () => {
|
||||
const impl = src("plan2code-3-implement.md");
|
||||
const both = src("plan2code-3-implement-review.md");
|
||||
for (const text of [impl, both]) {
|
||||
assert.match(text, /after each task (run )?the tests covering what it touched/);
|
||||
assert.match(text, /the phase file's `## Phase Testing` lines plus tests for any other file the phase changed/);
|
||||
assert.match(text, /never the full suite unless the phase file lists a `Full suite:` line/);
|
||||
assert.match(text, /Read `references\/test-runs\.md` before the first test run of a phase/);
|
||||
}
|
||||
assert.doesNotMatch(impl, /Run tests ONLY if/);
|
||||
assert.doesNotMatch(both, /explicitly listed as a phase task/);
|
||||
});
|
||||
|
||||
test("Implement's sign-off offers a wider run for shared ground and asks when unsure", () => {
|
||||
const impl = src("plan2code-3-implement.md");
|
||||
assert.match(impl, /changed shared ground the plan did not foresee/);
|
||||
assert.match(impl, /offer the full suite or a wider set as a choice beside approval/);
|
||||
assert.match(impl, /Unsure whether it is shared ground\? Ask\./);
|
||||
assert.match(src("web-console", "building.md"), /\| Shared ground touched \| `choice` \|/);
|
||||
});
|
||||
|
||||
test("Quick Task and Review name the tests covering the changed files", () => {
|
||||
const quick = src("plan2code-quick-task.md");
|
||||
assert.match(quick, /\[Targeted: the command and the tests covering the changed files\]/);
|
||||
assert.ok(quick.includes("**Write the test first?**"), "the test-first question stays");
|
||||
assert.ok(quick.includes("references/test-runs.md"), "Quick Task reads the shared rule");
|
||||
assert.match(src("plan2code-review.md"), /\*\*Verify\*\* -- build and run the tests covering the fixed files \(per `references\/test-runs\.md`/);
|
||||
});
|
||||
|
||||
test("the loop prompt points at the tests the task or phase file lists", () => {
|
||||
const tpl = fs.readFileSync(path.join(ROOT, "plan2code-loop", "src", "prompt", "templates.ts"), "utf8");
|
||||
assert.equal(tpl.split("run the tests the task or phase file lists").length - 1, 2);
|
||||
assert.ok(!tpl.includes("if applicable"));
|
||||
});
|
||||
|
||||
test("Finalize offers the full suite, skips it for Never and records the four outcomes", () => {
|
||||
const fin = src("plan2code-4-finalize.md");
|
||||
assert.ok(fin.includes("Run the full suite now?"), "Finalize asks the question");
|
||||
assert.match(fin, /`Never`: skip the offer; record `not planned`/);
|
||||
assert.ok(fin.includes("references/test-runs.md"), "Finalize reads the shared rule");
|
||||
assert.match(fin, /Never forced/);
|
||||
for (const outcome of ["passed", "failed (N)", "skipped (your choice)", "not planned"]) {
|
||||
assert.ok(fin.includes(outcome), `Finalize records ${outcome}`);
|
||||
}
|
||||
assert.match(fin, /Full suite: \[passed \/ failed \(N\) \/ skipped \(your choice\) \/ not planned\]/, "the summary template carries the line");
|
||||
assert.doesNotMatch(fin, /Test Validation \(if defined\)/);
|
||||
const notes = src("web-console", "notes", "finalize.md");
|
||||
assert.match(notes, /`confirm` "Run the full suite" \(`yesLabel` "Run it", `noLabel` "Skip it"/);
|
||||
assert.match(notes, /a failure is the building notes' `choice`/);
|
||||
});
|
||||
|
||||
test("test-runs.md says to ask when a check or its tests are unclear", () => {
|
||||
const rule = src("shared-references", "test-runs.md");
|
||||
assert.match(rule, /which tests cover a file, ask the person\. Never guess/);
|
||||
});
|
||||
|
||||
test("Init and Init-update keep a test map beside the single-test command", () => {
|
||||
const init = src("plan2code-init.md");
|
||||
assert.match(init, /run single test \(and beside it a short \*\*Test map\*\*: `area -> tests or command`/);
|
||||
assert.match(init, /which checks are quick/);
|
||||
const upd = src("plan2code-init-update.md");
|
||||
assert.match(upd, /\*\*4\. Testing\*\* - .*the test map and quick checks/);
|
||||
assert.match(upd, /\| Testing \| Commands\? Test map and quick checks stale\?/);
|
||||
});
|
||||
Reference in new issue
Block a user