mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Add the Dead Code skill with hash-matched keep rows and one tool per language
AI Assisted
This commit is contained in:
1 parent
7891c06642
commit
a584c45dfd
43 files changed
+3398
-49
No files matched your search
@@ -76,7 +76,7 @@ export function check(srcDir) {
|
||||
if (!note) problems.push(`${file}: names no <D>/notes/<workflow>.md file`);
|
||||
else if (!fs.existsSync(path.join(notesDir, `${note[1]}.md`))) problems.push(`${file}: notes file ${note[1]}.md is not in src/web-console/notes/`);
|
||||
}
|
||||
if (seen !== 18) problems.push(`expected 18 skills with a console opening, found ${seen}`);
|
||||
if (seen !== 19) problems.push(`expected 19 skills with a console opening, found ${seen}`);
|
||||
return problems;
|
||||
}
|
||||
|
||||
@@ -87,5 +87,5 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
|
||||
for (const p of problems) console.error(` FAIL ${p}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("All 18 console openings share their sentences.");
|
||||
console.log("All 19 console openings share their sentences.");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{"reason":"compiler-artifact","package_id":"demo 0.1.0","target":{"name":"demo"}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"function `old_helper` is never used","spans":[{"file_name":"src/lib.rs","line_start":8,"line_end":8,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"function `old_helper` is never used","spans":[{"file_name":"src/lib.rs","line_start":8,"line_end":8,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"unused_imports","explanation":null},"level":"warning","message":"unused import: `std::io`","spans":[{"file_name":"src/main.rs","line_start":1,"line_end":1,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"E0425","explanation":"..."},"level":"error","message":"cannot find value `x` in this scope","spans":[{"file_name":"src/main.rs","line_start":5,"line_end":5,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":null,"level":"warning","message":"1 warning emitted","spans":[]}}
|
||||
{"reason":"build-finished","success":true}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"unused_imports","explanation":null},"level":"warning","message":"unused imports: `fmt` and `io`","spans":[{"file_name":"src/net.rs","line_start":2,"line_end":2,"column_start":11,"column_end":14,"is_primary":true,"text":[{"text":"use std::{fmt, io};","highlight_start":11,"highlight_end":14}]},{"file_name":"src/net.rs","line_start":2,"line_end":2,"column_start":16,"column_end":18,"is_primary":true,"text":[{"text":"use std::{fmt, io};","highlight_start":16,"highlight_end":18}]}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"multiple fields are never read","spans":[{"file_name":"src/model.rs","line_start":3,"line_end":3,"column_start":5,"column_end":9,"is_primary":false,"text":[{"text":"pub struct Model {","highlight_start":12,"highlight_end":17}]},{"file_name":"src/model.rs","line_start":4,"line_end":4,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" name: String,","highlight_start":5,"highlight_end":9}]},{"file_name":"src/model.rs","line_start":5,"line_end":5,"column_start":5,"column_end":8,"is_primary":true,"text":[{"text":" age: u32,","highlight_start":5,"highlight_end":8}]}]}}
|
||||
{"reason":"compiler-message", broken
|
||||
@@ -0,0 +1,3 @@
|
||||
internal/report/format.go:12:6: unreachable func: formatLegacy
|
||||
cmd/tool/main.go:40:6: unreachable func: (*server).shutdownOld
|
||||
not a deadcode line
|
||||
@@ -0,0 +1 @@
|
||||
{"files":["src/old.ts"],"issues":[{"file":"src/utils.ts","dependencies":[],"devDependencies":[],"files":[],"exports":[{"name":"formatDate","line":12,"col":17,"pos":250}],"types":[{"name":"Options","line":3,"col":13,"pos":40}],"enumMembers":{"Color":[{"name":"Purple","line":20,"col":3,"pos":400}]},"classMembers":{"Cache":[{"name":"flush","line":31,"col":3,"pos":600}]},"duplicates":[[{"name":"parse","line":40,"col":17},{"name":"default","line":44,"col":1}]]},{"file":"src/dead.ts","files":true,"exports":[],"types":[]},{"file":"src/broken.ts","exports":[{"line":2}]}]}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
||||
"version": "2.1.0",
|
||||
"runs": [
|
||||
{
|
||||
"tool": { "driver": { "name": "PMD", "version": "7.29.0" } },
|
||||
"results": [
|
||||
{
|
||||
"ruleId": "UnusedPrivateMethod",
|
||||
"message": { "text": "Avoid unused private methods such as 'helper(String)'." },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Service.java" }, "region": { "startLine": 42 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedPrivateField",
|
||||
"message": { "text": "Avoid unused private fields such as 'cache'." },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Store.java" }, "region": { "startLine": 7 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UseUtilityClass",
|
||||
"message": { "text": "This utility class has a non-private constructor" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Util.java" }, "region": { "startLine": 3 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedLocalVariable",
|
||||
"message": { "text": "Avoid unused local variables such as 'tmp'." }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"runs": [
|
||||
{
|
||||
"tool": { "driver": { "name": "Psalm", "version": "7.2.0" } },
|
||||
"results": [
|
||||
{
|
||||
"ruleId": "PossiblyUnusedMethod",
|
||||
"message": { "text": "Cannot find any calls to method App\\Mailer::sendLater" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "file:///ROOT/src/Mailer.php" }, "region": { "startLine": 18 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedClass",
|
||||
"message": { "text": "Class `App\\Legacy` is never used" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/Legacy.php" }, "region": { "startLine": 5 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnreachableCode",
|
||||
"message": { "text": "Unreachable code" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/Flow.php" }, "region": { "startLine": 30 } } }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
app/models.py:3: unused import 'os' (90% confidence)
|
||||
app/models.py:14: unused function 'legacy_total' (60% confidence)
|
||||
app/views.py:22: unused variable 'retries' (60% confidence, 1 line)
|
||||
app/views.py:40: unreachable code after 'return' (100% confidence)
|
||||
this line is mangled
|
||||
@@ -58,7 +58,7 @@ test("a wrong workflow name or a missing notes file is reported", () => {
|
||||
test("a skill that loses its opening is caught by the count", () => {
|
||||
const dir = copySrc();
|
||||
fs.rmSync(path.join(dir, "plan2code-pr-prep.md"));
|
||||
assert.match(check(dir).join("\n"), /expected 18 skills with a console opening, found 17/);
|
||||
assert.match(check(dir).join("\n"), /expected 19 skills with a console opening, found 18/);
|
||||
});
|
||||
|
||||
test("helpers", () => {
|
||||
@@ -66,6 +66,7 @@ test("helpers", () => {
|
||||
assert.equal(workflowOf("plan2code-1b-revise-plan"), "revise-plan");
|
||||
assert.equal(workflowOf("plan2code-3-implement-review"), "implement-review");
|
||||
assert.equal(workflowOf("plan2code-pr-prep"), "pr-prep");
|
||||
assert.equal(workflowOf("plan2code-dead-code"), "dead-code");
|
||||
});
|
||||
|
||||
test("the CLI exits 1 on drift", () => {
|
||||
|
||||
@@ -29,6 +29,7 @@ export const BUDGETS = {
|
||||
// Each topic file under notes/, read when its workflow starts.
|
||||
notes: {
|
||||
"changelog.md": 1400,
|
||||
"dead-code.md": 4250,
|
||||
"diagnose.md": 2700,
|
||||
"document.md": 400,
|
||||
"finalize.md": 2000,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"test-line-endings.mjs",
|
||||
"test-script-changelog.mjs",
|
||||
"test-script-coverage.mjs",
|
||||
"test-script-dead-code.mjs",
|
||||
"test-script-finalize.mjs",
|
||||
"test-script-git.mjs",
|
||||
"test-script-pathfinder.mjs",
|
||||
@@ -27,6 +28,8 @@
|
||||
"test-set-version.mjs",
|
||||
"test-skill-scripts.mjs",
|
||||
"test-skill-test-runs.mjs",
|
||||
"test-spec-carry-page.mjs",
|
||||
"test-spec-carry.mjs",
|
||||
"test-us-english.mjs",
|
||||
"test-web-console-agents-doc.mjs",
|
||||
"test-web-console-git-board.mjs",
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -70,11 +70,15 @@ test("every script a SKILL.md (or a reference it ships) runs exists beside it, a
|
||||
});
|
||||
|
||||
test("scripts are self-contained: built-ins and siblings only", () => {
|
||||
for (const dir of [path.join(ROOT, "src", "skill-scripts"), ...fs.readdirSync(path.join(ROOT, "src")).filter((n) => n.endsWith("-scripts")).map((n) => path.join(ROOT, "src", n))]) {
|
||||
const shared = path.join(ROOT, "src", "skill-scripts");
|
||||
for (const dir of [shared, ...fs.readdirSync(path.join(ROOT, "src")).filter((n) => n.endsWith("-scripts")).map((n) => path.join(ROOT, "src", n))]) {
|
||||
for (const f of fs.readdirSync(dir).filter((n) => n.endsWith(".mjs"))) {
|
||||
const t = fs.readFileSync(path.join(dir, f), "utf8");
|
||||
for (const m of t.matchAll(/^import .* from "([^"]+)";$/gm)) {
|
||||
const sibling = /^\.\/[\w-]+\.mjs$/.test(m[1]) && fs.existsSync(path.join(dir, m[1]));
|
||||
// A skill's own script may import a shared script too: the build lays
|
||||
// both in one scripts/ folder, and the check below holds the skill to
|
||||
// shipping it.
|
||||
const sibling = /^\.\/[\w-]+\.mjs$/.test(m[1]) && (fs.existsSync(path.join(dir, m[1])) || fs.existsSync(path.join(shared, m[1])));
|
||||
assert.ok(m[1].startsWith("node:") || m[1] === "./common.mjs" || sibling, `${f} imports ${m[1]}`);
|
||||
}
|
||||
assert.ok(!/[\u0000-\u0008]/.test(t), `${f} contains a control character (an escape lost in an edit?)`);
|
||||
|
||||
@@ -2085,8 +2085,8 @@ test("workspace cursor never moves backwards, and only changes past it are pendi
|
||||
}
|
||||
});
|
||||
|
||||
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"]) {
|
||||
test("subagents: only the sixteen 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", "dead-code"]) {
|
||||
assert.equal(offered(w), true, w);
|
||||
assert.ok(defaultInstruction(w).length > 0, `${w} has a default instruction`);
|
||||
}
|
||||
@@ -2094,7 +2094,7 @@ test("subagents: only the fifteen opted-in workflows offer the switch", () => {
|
||||
assert.equal(offered(w), false, String(w));
|
||||
assert.equal(defaultInstruction(w), "");
|
||||
}
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 15);
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 16);
|
||||
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"));
|
||||
@@ -2384,14 +2384,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, "pr-prep": 1, test: 1,
|
||||
"git-commits": 0, "git-conflict": 1, changelog: 1, xray: 1, diagnose: 1, "pr-prep": 1, test: 1, "dead-code": 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",
|
||||
"pr-prep": "PR Prep started", test: "Test started", "dead-code": "Dead Code started",
|
||||
});
|
||||
assert.deepEqual({ ...RUN_LABELS }, {
|
||||
"pathfinder-chart": "Pathfinder map written", "pathfinder-question": "Pathfinder question settled",
|
||||
@@ -2401,7 +2401,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",
|
||||
"pr-prep": "PR Prep run", test: "Test run", "dead-code": "Dead Code run",
|
||||
});
|
||||
for (const t of [WEIGHTS, LAUNCH_LABELS, RUN_LABELS]) assert.ok(Object.isFrozen(t));
|
||||
});
|
||||
|
||||
@@ -212,11 +212,15 @@ test("picking Start from scratch instead of a spec grays Document, and a launch
|
||||
const document = lightOf(main, "/plan2code-2-document");
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
assert.equal(await document.isEnabled(), true, "Document is lit for the drafted spec");
|
||||
// The top bar names the picked spec beside the meter, and drops it from scratch.
|
||||
const specTag = main.page().locator("#spec-tag");
|
||||
assert.ok(await until(async () => (await specTag.isVisible()) && (await specTag.textContent()) === "demo"), "the top bar names the spec demo");
|
||||
|
||||
// From scratch there is no draft to document: the card grays.
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.equal(await document.isDisabled(), true, "Document is grayed with no spec picked");
|
||||
assert.ok(await until(() => specTag.isHidden()), "the top bar's spec name goes from scratch");
|
||||
assert.equal(await chipFor(main, "demo").getAttribute("aria-current"), "false");
|
||||
|
||||
// Back on the spec it is lit again; then from scratch once more to launch.
|
||||
@@ -232,6 +236,40 @@ test("picking Start from scratch instead of a spec grays Document, and a launch
|
||||
assert.ok(!launch.spec, `a launch from scratch names no spec: ${JSON.stringify(launch)}`);
|
||||
});
|
||||
|
||||
// What a person would see break: the Dead Code card missing from Useful any
|
||||
// time, drawn without its skull, grayed for want of a spec it never takes, or
|
||||
// launching with the picked spec riding along.
|
||||
test("the Dead Code card sits in Useful any time with its skull, is lit with or without a spec, and launches with no spec", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project: tempProject(DRAFT_PROJECT) });
|
||||
const main = await toTheMenu(s);
|
||||
await hideUnavailable(main, false);
|
||||
const card = lightOf(main, "/plan2code-dead-code");
|
||||
await card.waitFor();
|
||||
|
||||
const group = main.locator("section.dash-group").filter({ has: s.page.locator("h3", { hasText: /^Useful any time$/ }) });
|
||||
assert.equal(await group.locator("code", { hasText: /^\/plan2code-dead-code$/ }).count(), 1, "the card is in the Useful any time group");
|
||||
assert.match(await textOf(card), /Utility/i, "it wears the Utility chip (drawn in capitals)");
|
||||
assert.match(await textOf(card), /Clear out dead code/, "it has its title");
|
||||
assert.equal(await card.locator("use").getAttribute("href"), "#ci-dead-code", "its icon is the skull");
|
||||
assert.equal(await s.page.locator("symbol#ci-dead-code").count(), 1, "the skull symbol is drawn in the icon sheet");
|
||||
|
||||
// Lit with no spec picked, and with one.
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.equal(await card.isEnabled(), true, "lit with no spec picked");
|
||||
await chipFor(main, "demo").click();
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
assert.equal(await card.isEnabled(), true, "lit with a spec picked");
|
||||
|
||||
// A launch with the spec still picked names no spec: Dead Code takes none.
|
||||
await card.click();
|
||||
await main.getByRole("button", { name: "Start Clear out dead code" }).click();
|
||||
const launch = collect(s).actions.find((a) => a.i === "__launch");
|
||||
assert.ok(launch, "the send carries a launch");
|
||||
assert.deepEqual({ skill: launch.skill, workflow: launch.workflow }, { skill: "plan2code-dead-code", workflow: "dead-code" });
|
||||
assert.ok(!launch.spec, `a Dead Code launch names no spec: ${JSON.stringify(launch)}`);
|
||||
});
|
||||
|
||||
// What a person would see break: a spec not documented yet offers nothing to
|
||||
// read, or its Map and Plan draft tabs stay up for a spec that has an
|
||||
// overview (or for no spec at all).
|
||||
|
||||
@@ -947,13 +947,13 @@ test("the Subagents dialog looks as it did before Preferences moved to tabs", as
|
||||
// seven pickable cues, Planny's snoring and waking keeping plain boxes.
|
||||
const PICK_EVENTS = ["startSkill", "sessionStart", "skillReady", "sessionEnd", "question", "chatReply", "newTab"];
|
||||
const PICK_DEFAULTS = {
|
||||
startSkill: "sound-01",
|
||||
sessionStart: "sound-02",
|
||||
skillReady: "sound-03",
|
||||
sessionEnd: "sound-02",
|
||||
question: "sound-03",
|
||||
chatReply: "sound-03",
|
||||
newTab: "sound-04",
|
||||
startSkill: "sound-14",
|
||||
sessionStart: "sound-07",
|
||||
skillReady: "sound-16",
|
||||
sessionEnd: "sound-15",
|
||||
question: "sound-14",
|
||||
chatReply: "sound-06",
|
||||
newTab: "sound-05",
|
||||
};
|
||||
const pickSelect = (s, event) => s.page.locator(`select[data-sound-file="${event}"]`);
|
||||
|
||||
@@ -1017,7 +1017,7 @@ test("the sound picker: a pick plays once and persists across a reload, and Play
|
||||
await drawn(s.page);
|
||||
await openSoundsTab(s);
|
||||
assert.equal(await pickSelect(s, "question").inputValue(), "sound-07", "the pick did not survive a reload");
|
||||
assert.equal(await pickSelect(s, "newTab").inputValue(), "sound-04", "an untouched cue kept its default");
|
||||
assert.equal(await pickSelect(s, "newTab").inputValue(), "sound-05", "an untouched cue kept its default");
|
||||
});
|
||||
|
||||
test("the sound picker: Play sounds off disables the selects and play buttons, and Back to default restores the defaults", async (t) => {
|
||||
@@ -1039,7 +1039,7 @@ test("the sound picker: Play sounds off disables the selects and play buttons, a
|
||||
assert.equal(await pickSelect(s, "newTab").isDisabled(), false, "switching sounds on enables the select again");
|
||||
|
||||
await s.page.click("#looks-reset");
|
||||
await s.page.waitForFunction(() => document.querySelector('select[data-sound-file="newTab"]').value === "sound-04");
|
||||
await s.page.waitForFunction(() => document.querySelector('select[data-sound-file="newTab"]').value === "sound-05");
|
||||
for (const event of PICK_EVENTS) {
|
||||
assert.equal(await pickSelect(s, event).inputValue(), PICK_DEFAULTS[event], `${event} is back on its default`);
|
||||
}
|
||||
@@ -1078,7 +1078,7 @@ test("the sound picker: a preview is dropped behind a ranked cue that is still p
|
||||
await s.page.evaluate(() => (window.__audible = false));
|
||||
await s.page.locator('[data-sound-play="newTab"]').click();
|
||||
await s.page.waitForFunction(() => window.__played.length === 2);
|
||||
assert.match((await played(s))[1], /\/sounds\/sound-04\.mp3$/, "the preview played once the cue had stopped");
|
||||
assert.match((await played(s))[1], /\/sounds\/sound-05\.mp3$/, "the preview played once the cue had stopped");
|
||||
});
|
||||
|
||||
test("the sound picker: Tab reaches Play from the select, and a row stacks inside the dialog at a narrow width", async (t) => {
|
||||
|
||||
@@ -614,7 +614,7 @@ test("the chime files are served as audio", async () => {
|
||||
// names a real event, and every event's file is served. A box with no event
|
||||
// saves a setting nothing reads; an event with no box can never be muted.
|
||||
test("every sound event has a preference box and a served file", async () => {
|
||||
assert.equal(SOUND_EVENTS.startSkill.file, "sounds/sound-01", "starting a skill has its own sound");
|
||||
assert.equal(SOUND_EVENTS.startSkill.file, "sounds/sound-14", "starting a skill has its own default sound");
|
||||
const html = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "index.html"), "utf8");
|
||||
const boxes = [...html.matchAll(/data-sound="(\w+)"/g)].map((m) => m[1]);
|
||||
assert.deepEqual([...boxes].sort(), Object.keys(SOUND_EVENTS).sort());
|
||||
@@ -1574,6 +1574,53 @@ test("the page reads older { from, md } thread entries", () => {
|
||||
assert.equal(threadText({ who: "agent" }), "");
|
||||
});
|
||||
|
||||
/* --------------------------------- the Dead Code findings page (notes/dead-code.md) */
|
||||
|
||||
test("Dead Code's findings page: one multi in three groups with All Safe and None presets is accepted, two recommended stay refused", () => {
|
||||
const opened = cli(["open", "--file", payload("dead-code-open.json", BASE), "--no-open"]);
|
||||
const s = opened.json;
|
||||
try {
|
||||
const findings = {
|
||||
id: "findings",
|
||||
kind: "multi",
|
||||
title: "What to remove",
|
||||
required: false,
|
||||
body: "- Safe to remove: 2\n- Check first: 1\n- Warning: 1\n\nNothing is removed until you send.",
|
||||
options: [
|
||||
{ k: "1", text: "formatDate in src/dates.js:14", detail: "Safe. Knip (exports): no caller found." },
|
||||
{ k: "2", text: "src/old/legacy.js", detail: "Safe. Knip (files): no caller found." },
|
||||
{ k: "3", text: "parseRow in src/csv.js:40", detail: "Check first. Own search only." },
|
||||
{ k: "4", text: "onLoad in src/plugin.js:8", detail: "Warning. A framework hook: the host calls it by name." },
|
||||
],
|
||||
presets: [{ label: "All Safe", ks: ["1", "2"] }, { label: "None", ks: [] }],
|
||||
};
|
||||
const ok = cli(["post", "--session", s.sid, "--file", payload("dead-code-findings.json", { items: [findings] })]);
|
||||
assert.equal(ok.status, 0, ok.stderr);
|
||||
const item = readState(s.session).items.find((i) => i.id === "findings");
|
||||
assert.ok(item, "the findings card is on the page");
|
||||
assert.deepEqual(item.options.map((o) => o.k), ["1", "2", "3", "4"], "Safe, Check first, Warning, in order");
|
||||
assert.deepEqual(item.presets, findings.presets, "both presets are kept for the page");
|
||||
assert.ok(!item.answer, "nothing starts ticked");
|
||||
|
||||
const twice = cli(
|
||||
["post", "--session", s.sid, "--file", payload("dead-code-twice.json", {
|
||||
items: [{ id: "method", kind: "choice", title: "How to look", body: "Which?", options: [{ text: "Knip", recommended: true }, { text: "Own search", recommended: true }] }],
|
||||
})],
|
||||
{ expectFail: true }
|
||||
);
|
||||
assert.equal(twice.status, 3, "a second recommended option is still refused");
|
||||
assert.match(twice.stderr, /recommended/);
|
||||
} finally {
|
||||
cli(["stop", "--session", s.sid, "--force"]);
|
||||
}
|
||||
// The budget is read as text: importing the budgets suite would run its tests here too.
|
||||
const budgets = fs.readFileSync(path.join(ROOT, "scripts", "test-console-wire-budgets.mjs"), "utf8");
|
||||
const budget = Number((budgets.match(/"dead-code\.md": (\d+)/) || [])[1]);
|
||||
assert.ok(budget > 0, "notes/dead-code.md has a byte budget");
|
||||
const bytes = fs.statSync(path.join(ROOT, "src", "web-console", "notes", "dead-code.md")).size;
|
||||
assert.ok(bytes <= budget, `notes/dead-code.md is ${bytes} bytes, over its ${budget} budget`);
|
||||
});
|
||||
|
||||
/* --------------------------------- output shape at each exit code (FR-1 to FR-3) */
|
||||
|
||||
test("the shape of every exit: 0 for an answer and a launch, 10, 30, 3 and 2", async (t) => {
|
||||
|
||||
@@ -399,7 +399,7 @@ test("Implement's card launches Implement + Review when Review is ticked", () =>
|
||||
assert.equal(launchVariant(quick, true), quick, "a card with no Review box is unchanged");
|
||||
});
|
||||
|
||||
test("helper-strength.md ships in the fifteen skills that start helpers, and in no other", () => {
|
||||
test("helper-strength.md ships in the sixteen skills that start helpers, 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" });
|
||||
@@ -414,6 +414,7 @@ test("helper-strength.md ships in the fifteen skills that start helpers, and in
|
||||
"plan2code-3-implement",
|
||||
"plan2code-3-implement-review",
|
||||
"plan2code-4-finalize",
|
||||
"plan2code-dead-code",
|
||||
"plan2code-diagnose",
|
||||
"plan2code-init",
|
||||
"plan2code-init-update",
|
||||
|
||||
@@ -302,6 +302,18 @@ const CARDS = {
|
||||
built: { on: true },
|
||||
unrecognized: { on: true },
|
||||
},
|
||||
"plan2code-dead-code": {
|
||||
"none": { on: true },
|
||||
diagnosed: { on: true },
|
||||
fixed: { on: true },
|
||||
exploring: { on: true },
|
||||
mapped: { on: true },
|
||||
planned: { on: true },
|
||||
documented: { on: true },
|
||||
building: { on: true },
|
||||
built: { on: true },
|
||||
unrecognized: { on: true },
|
||||
},
|
||||
"plan2code-changelog": {
|
||||
"none": { on: true },
|
||||
diagnosed: { on: true },
|
||||
|
||||
@@ -498,7 +498,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", "pr-prep": "pr-prep", test: "test",
|
||||
diagnose: "diagnose", "pr-prep": "pr-prep", test: "test", "dead-code": "dead-code",
|
||||
};
|
||||
const skills = fs.readdirSync(path.join(ROOT, "src")).filter((f) => /^plan2code(-.*)?\.md$/.test(f));
|
||||
for (const f of skills) {
|
||||
|
||||
Reference in new issue
Block a user