mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add the Test skill: find untested code and write tests in the project's style
AI Assisted
This commit is contained in:
1 parent
88c72dc2ce
commit
6cd7a7ff80
21 files changed
+753
-16
No files matched your search
@@ -6,7 +6,7 @@ A local page where the person answers your questions, reads your drafts and appr
|
||||
|
||||
## Start
|
||||
|
||||
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
|
||||
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
|
||||
|
||||
Keep `sid`: every later command takes `--session <sid>`. `open` failing: carry on in the terminal. When `open` adds `remote` and a `note`, give the link, ask whether it opened, and move to the terminal if not. Tell the person the link (with `"inApp":true`, never print it: only how many questions are waiting) and end every terminal message with the latest `terminalLine`, verbatim.
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# Test
|
||||
|
||||
## Scope
|
||||
|
||||
Every run, one `choice`, `--wait`:
|
||||
|
||||
```jsonc
|
||||
{"title":"Write missing tests","headline":{"stage":"Scope","cleared":0,"total":5},"items":[{"id":"scope","kind":"choice","title":"Where to look","allowOther":false,"body":"Which code should I look for missing tests in?","options":[{"text":"This branch's changes","recommended":true},{"text":"A folder or file","detail":"You name it next."},{"text":"The whole project"}]}]}
|
||||
```
|
||||
|
||||
"A folder or file" gets a follow-up `text`, `--wait`: `{"id":"scope-path","kind":"text","title":"Which folder","body":"Which folder or file should I look in?","placeholder":"src/billing"}`.
|
||||
|
||||
## Commands and the built-in runner
|
||||
|
||||
With no test map: one `confirm` listing each command found and the folders it covers, `--wait`, before anything runs. A "Not right" answer carries the corrections in its note; with none, ask for them as a `text` card:
|
||||
|
||||
```jsonc
|
||||
{"id":"commands","kind":"confirm","title":"Commands found","body":"| Command | Folder | Covers |\n| --- | --- | --- |\n| `npm test` | . | everything |\n\nWrite and run tests with these?","yesLabel":"Use these","noLabel":"Not right"}
|
||||
```
|
||||
|
||||
No runner at all and a `builtin` found: one `confirm` naming the runner and the command it adds, `--wait`: `{"id":"builtin","kind":"confirm","title":"No test runner","body":"This project has no test runner. Node has one built in: I would add `\"test\": \"node --test\"` to `package.json` and nothing else. Use it?","yesLabel":"Add it","noLabel":"No"}`. No runner and no `builtin`: no card; the finish says why nothing was written.
|
||||
|
||||
## Coverage
|
||||
|
||||
Only when `discover` lists a `coverage` entry for a runner in scope. One `confirm`, `--wait`, naming the command and what it covers; never run without a yes:
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Gaps","cleared":2},"items":[{"id":"coverage","kind":"confirm","title":"Run coverage","body":"This project already has coverage: `npx jest --coverage --coverageReporters=lcov` in `.` covers every Jest test. Run it to find files the tests barely touch? Without it I match files to tests by name, folder and imports only.","yesLabel":"Run it","noLabel":"Skip it"}]}
|
||||
```
|
||||
|
||||
The output file goes in the `session` folder `open` printed.
|
||||
|
||||
## Size
|
||||
|
||||
Only past a limit (8 source files, 8 new test files, 2 runners). One `choice`, `--wait`, the counts in `body`:
|
||||
|
||||
```jsonc
|
||||
{"id":"size","kind":"choice","title":"A big job","allowOther":false,"body":"- Source files: 14/8\n- New test files: 11/8\n- Runners: 1/2\n\nContinue with the top 8 gaps this run, or write a plan draft and plan it properly?","options":[{"text":"Continue","detail":"The top 8 gaps by rank, this run only.","recommended":true},{"text":"Escalate","detail":"Writes a PLAN-DRAFT for Plan."}]}
|
||||
```
|
||||
|
||||
Escalate: a `text` card for the kebab-case name (`pattern` `^[a-z0-9]+(-[a-z0-9]+)*$`, `patternHint` "kebab-case, like billing-tests"), then the finish below.
|
||||
|
||||
## The plan
|
||||
|
||||
Doc `plan`: one `md` block per runner group (`id` `group-1`, `group-2` ...), each opening with its "How this project writes tests" notes, then its gaps (method, test file, cases marked unit or integration). Then one `review` over it, `--wait`:
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Plan","cleared":3},"docs":[{"id":"plan","title":"Test plan","blocks":[{"id":"group-1","md":"## node --test\n\n### How this project writes tests\n\n- Folder: `scripts/`\n- ...\n\n### Gaps\n\n| File | Found by | Test file | Cases |\n| --- | --- | --- | --- |\n| `src/a.js` | matching | `scripts/test-a.mjs` (new) | unit: ... |"}]}],"items":[{"id":"plan-ok","kind":"review","title":"Approve the plan","doc":"plan","body":"Check the style notes and the plan together. Nothing is written until you approve.","verdicts":[{"id":"approve","label":"Write these tests"},{"id":"changes","label":"I want changes"}],"nothingYet":"Nothing is written until you approve."}]}
|
||||
```
|
||||
|
||||
`changes`: revise the doc, reopen the item with a `thread` reply.
|
||||
|
||||
## Writing and running
|
||||
|
||||
One progress post per runner group's run, no `--wait`, with `quietMinutes` sized to its timeout (600 s is 10 minutes, plus a margin):
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Running","cleared":4},"agent":{"status":"working","activity":"Running the new launcher tests","quietMinutes":12}}
|
||||
```
|
||||
|
||||
Logs go in `<session>/runs/<n>.log`. Run the `chat` check between runs, as a build does.
|
||||
|
||||
## A real bug
|
||||
|
||||
Per bug, one `confirm`, `--wait`: `{"id":"bug-1","kind":"confirm","title":"Found a bug","body":"`scripts/test-a.mjs` › *rounds totals* fails because `src/a.js` truncates instead of rounding. Keep the test as the reproduction for Diagnose, or remove it?","yesLabel":"Keep it","noLabel":"Remove it"}`.
|
||||
|
||||
## Test map
|
||||
|
||||
`confirm`, `--wait`: `title` "Save a test map", the rows as a table in `body`, `yesLabel` "Save it", `noLabel` "No".
|
||||
|
||||
## The finish
|
||||
|
||||
`headline` the tests added and their results ("6 tests added, all passing"); `body` the summary (scope, coverage run or skipped, files written, gaps left), ending "Commit the new tests with `/plan2code-git`."; `"dashboard":true`; no `commit`. `command` `/plan2code-diagnose` when a bug was kept (its file and case in `body`), `/plan2code-1-plan` when escalated (the PLAN-DRAFT's path in `body`), else none.
|
||||
|
||||
A stop before anything was written: `body` says no tests were written, `"command":"/plan2code-test"`.
|
||||
@@ -428,6 +428,12 @@
|
||||
<path d="M9 2.5h6a1 1 0 0 1 1 1V5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1z" />
|
||||
<path d="m9 13.5 2 2 4-4.5" />
|
||||
</symbol>
|
||||
<!-- Write missing tests: a test tube. -->
|
||||
<symbol id="ci-test" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M9 3h6" />
|
||||
<path d="M10 3v14.5a2 2 0 0 0 4 0V3" />
|
||||
<path d="M10 12h4" />
|
||||
</symbol>
|
||||
<!-- Changelog: a version tag. -->
|
||||
<symbol id="ci-changelog" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M3 4a1 1 0 0 1 1-1h7.6a2 2 0 0 1 1.4.6l7.4 7.4a2 2 0 0 1 0 2.8l-5.6 5.6a2 2 0 0 1-2.8 0L4.6 12a2 2 0 0 1-.6-1.4z" />
|
||||
@@ -866,6 +872,33 @@
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Test: writing the missing tests. He holds up a test tube, bubbles
|
||||
rise through its liquid and a star bubble floats out of the top,
|
||||
his star looking up after it before the next one forms. -->
|
||||
<svg class="pose pose-test" data-pose="test" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
|
||||
<ellipse class="shadow" cx="126" cy="198" rx="44" ry="5" />
|
||||
<g class="bob">
|
||||
<g class="ts-tube">
|
||||
<path class="ac" d="M189 116 L189 146 A7 7 0 0 0 203 146 L203 116 Z" />
|
||||
<circle class="ts-bub ts-b1" cx="194" cy="146" r="2" />
|
||||
<circle class="ts-bub ts-b2" cx="199" cy="144" r="1.6" />
|
||||
<circle class="ts-bub ts-b3" cx="196" cy="148" r="1.4" />
|
||||
<path class="lt" d="M186 76 L186 146 A10 10 0 0 0 206 146 L206 76" />
|
||||
<line class="lt" x1="181" y1="76" x2="211" y2="76" />
|
||||
<g class="ts-star"><path class="ac" transform="translate(196 60) scale(0.45) translate(-126 -99)" d="M126 86 L129.64 94.98 L139.31 95.67 L131.9 101.92 L134.23 111.33 L126 106.2 L117.77 111.33 L120.1 101.92 L112.69 95.67 L122.36 94.98 Z" /></g>
|
||||
</g>
|
||||
<g transform="translate(-14 0)">
|
||||
<rect class="fl foot f1" x="94" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="fl foot f2" x="126" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="sh" x="80" y="72" width="80" height="108" rx="16" />
|
||||
<path class="ln" d="M80 126 L66 150" /><circle class="fl" cx="66" cy="150" r="5.5" />
|
||||
<g class="ts-look"><path class="ey blink" d="M126 86 L129.64 94.98 L139.31 95.67 L131.9 101.92 L134.23 111.33 L126 106.2 L117.77 111.33 L120.1 101.92 L112.69 95.67 L122.36 94.98 Z" /></g>
|
||||
<path class="es" d="M110 120 Q122 129 134 120" />
|
||||
<line class="ln" x1="160" y1="126" x2="198" y2="134" />
|
||||
<circle class="fl" cx="200" cy="134" r="5.5" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Agent setup: waving hello at a terminal window, its prompt waiting
|
||||
for the command line that brings an agent. -->
|
||||
<svg class="pose pose-setup" data-pose="setup" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
|
||||
|
||||
@@ -404,6 +404,28 @@ export const SKILLS = Object.freeze([
|
||||
"Before you open a pull request. PR Prep reads what changed on the branch and picks the checks that cover it from the project's test map (or from its config files when there is no map), each with a reason. You untick what to skip, then it runs the rest and says Ready, Ready with notes or Not ready. It writes a PR description to copy, following the repo's template when there is one, and gives the link to open the PR. It never commits, pushes or opens the PR for you.",
|
||||
},
|
||||
}),
|
||||
skill({
|
||||
skill: "plan2code-test",
|
||||
workflow: "test",
|
||||
label: "Testing",
|
||||
name: "Test",
|
||||
pose: "test",
|
||||
builds: false, phased: false, metered: true, templates: false,
|
||||
weight: 1, started: "Test started", ran: "Test run", resume: null,
|
||||
subagents: "Use helpers to read the nearest tests and runner configs for each runner group. Keep the gaps, the plan, the style block, every question and the writing of tests with you. Light strength, low effort.",
|
||||
states: "any",
|
||||
greyed: null,
|
||||
card: {
|
||||
group: "extra",
|
||||
chip: "Utility",
|
||||
title: "Write missing tests",
|
||||
icon: "test",
|
||||
blurb: "Finds code with no tests and writes them in your project's own style.",
|
||||
help: "Finds untested files, shows a test plan in the project's style, then writes and runs unit and integration tests.",
|
||||
about:
|
||||
"When parts of the code have no tests. Test asks where to look (the branch's changes, one folder or the whole project) and finds the files no test covers, and offers a real coverage run when the project already has a coverage tool. It shows a plan that opens with how this project writes tests, so the new tests match the old ones, then writes and runs unit and integration tests. It never changes source code: a test that finds a real bug is handed to Diagnose.",
|
||||
},
|
||||
}),
|
||||
skill({
|
||||
skill: "plan2code-changelog",
|
||||
workflow: "changelog",
|
||||
|
||||
@@ -449,6 +449,30 @@
|
||||
50%, 88% { transform: translate(4px, 2px); }
|
||||
}
|
||||
|
||||
/* Test -- bubbles rise through the tube's liquid, then a star bubble floats
|
||||
out of the top and fades; his star looks up after it. */
|
||||
.pose .ts-bub { fill: var(--panel-2); }
|
||||
.pose .ts-b1 { animation: ts-rise 2.4s ease-in infinite; }
|
||||
.pose .ts-b2 { animation: ts-rise 2.4s ease-in 0.8s infinite; }
|
||||
.pose .ts-b3 { animation: ts-rise 2.4s ease-in 1.6s infinite; }
|
||||
@keyframes ts-rise {
|
||||
0% { transform: translateY(0); opacity: 0; }
|
||||
15%, 80% { opacity: 1; }
|
||||
100% { transform: translateY(-26px); opacity: 0; }
|
||||
}
|
||||
.pose .ts-star { animation: ts-float 4.8s ease-out infinite; }
|
||||
@keyframes ts-float {
|
||||
0%, 30% { transform: translateY(14px) scale(0.4); opacity: 0; }
|
||||
40% { opacity: 1; }
|
||||
85% { transform: translateY(-26px) scale(1); opacity: 1; }
|
||||
100% { transform: translateY(-34px) scale(1); opacity: 0; }
|
||||
}
|
||||
.pose .ts-look { animation: ts-look 4.8s ease-in-out infinite; }
|
||||
@keyframes ts-look {
|
||||
0%, 30%, 100% { transform: translate(4px, 0); }
|
||||
60%, 85% { transform: translate(4px, -4px); }
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.dash { padding-top: 0; }
|
||||
.launch-stage { height: 140px; }
|
||||
|
||||
Reference in new issue
Block a user