mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add the PR Prep skill: check plan, readiness verdict and PR description
AI Assisted
This commit is contained in:
1 parent
82298d256c
commit
88c72dc2ce
20 files changed
+932
-85
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`. 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`. 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.
|
||||
|
||||
|
||||
@@ -451,6 +451,36 @@ export function readRemotes(root, prHosts = {}) {
|
||||
return remotes;
|
||||
}
|
||||
|
||||
export const PR_LINK_CODES = new Set(["detached", "unknown-branch", "no-base", "is-base", "not-pushed"]);
|
||||
|
||||
function prLinkError(code, message, next, branch = null) {
|
||||
throw Object.assign(new Error(message), { code, next, branch });
|
||||
}
|
||||
|
||||
/**
|
||||
* The create-a-pull-request link for `branch` (default: the current branch)
|
||||
* into `base` (default: the default branch). Returns { url, host, kind,
|
||||
* needsKind, branch, base, ahead }; ahead is the branch's commits not yet on
|
||||
* its upstream. Throws an Error tagged { code, message, next, branch }, code
|
||||
* one of PR_LINK_CODES, when there is no link to give.
|
||||
*/
|
||||
export function prLink(root, { branch, base, prHosts = {} } = {}) {
|
||||
const parsed = parseStatusV2(git(["status", "--porcelain=v2", "-z", "--branch", "--untracked-files=no"], root, { raw: true }).out);
|
||||
const refs = readRefs(root);
|
||||
const def = refs.length ? defaultBranchFromRefs(refs, parsed) : defaultBranch(root, parsed);
|
||||
const b = (branch || "").trim() || parsed.branch;
|
||||
if (!b) prLinkError("detached", "HEAD is detached, so there is no branch to open a pull request for.", "Switch to a branch, or pass --branch.");
|
||||
const row = branchesFromRefs(refs, root, { current: parsed.branch, defaultName: def.name }).find((r) => !r.remote && r.name === b);
|
||||
if (!row) prLinkError("unknown-branch", `There is no local branch named "${b}".`, "Pick a branch from the list.", b);
|
||||
const into = (base || "").trim() || def.name;
|
||||
if (!into) prLinkError("no-base", "There is no default branch to open the pull request against.", "Pass --base <branch>.", b);
|
||||
// A pull request from a branch into itself is no pull request (a push to main).
|
||||
if (into === b) prLinkError("is-base", `${b} is the branch pull requests go into, so there is nothing to open.`, "Post no link for this push.", b);
|
||||
const remote = row.upstream && !row.gone ? readRemotes(root, prHosts).find((r) => r.name === row.upstreamRemote) : null;
|
||||
if (!remote) prLinkError("not-pushed", `${b} is not on a remote yet.`, "Publish it first (plan publish).", b);
|
||||
return { url: prUrl(remote, { base: into, head: b }), host: remote.host, kind: remote.kind, needsKind: !!remote.host && !remote.kind, branch: b, base: into, ahead: row.ahead };
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- snapshot and the count */
|
||||
|
||||
const MARKER = /^(<{7}|={7}|>{7})( |$)/m;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# PR Prep
|
||||
|
||||
## Uncommitted changes
|
||||
|
||||
Only when review-scope lists `staged`, `unstaged` or `untracked` files. One `choice`, `--wait`, the files in `body`:
|
||||
|
||||
```jsonc
|
||||
{"title":"Get a PR ready","headline":{"stage":"Changes","cleared":0,"total":4},"items":[{"id":"uncommitted","kind":"choice","title":"Uncommitted work","allowOther":false,"body":"These files are not committed yet:\n\n- `src/a.js` (unstaged)\n- `notes.txt` (untracked)\n\nRun the checks with them, or commit first?","options":[{"text":"Include them in this run","recommended":true},{"text":"Commit first","detail":"The git skill commits them; then run PR Prep again."}]}]}
|
||||
```
|
||||
|
||||
## Commands, 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| `npm run lint` | . | lint |\n\nRun checks with these?","yesLabel":"Use these","noLabel":"Not right"}
|
||||
```
|
||||
|
||||
## The check plan
|
||||
|
||||
One `multi`, each check's reason in `detail`, "picked by the agent" on judged ones, and one preset "All of them" naming every check: a card cannot open with its boxes ticked, so the preset is the one press that keeps the whole plan. With more than one runner, group in `body` (a short list per runner) and prefix each option's `text` with its runner. `--wait`:
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Check plan","cleared":1},"items":[{"id":"plan","kind":"multi","title":"Checks to run","body":"Tick the checks to run, or press All of them. Anything left unticked is skipped and named in the report. Nothing runs until you send.","options":[{"k":"1","text":"Launcher tests","detail":"`node --test scripts/test-launcher.mjs`: covers src/launcher/plan2code.js."},{"k":"2","text":"Lint","detail":"`npm run lint`: project check."}],"presets":[{"label":"All of them","ks":["1","2"]}]}]}
|
||||
```
|
||||
|
||||
A send with nothing ticked runs nothing: every check is trimmed.
|
||||
|
||||
## Running
|
||||
|
||||
One progress post per check, no `--wait`, with `quietMinutes` sized to its timeout (600 s is 10 minutes, plus a margin):
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Running","cleared":2},"agent":{"status":"working","activity":"Check 2 of 5: the launcher tests","quietMinutes":12}}
|
||||
```
|
||||
|
||||
Logs go in `<session>/checks/<n>.log`. Run the `chat` check between checks, as a build does.
|
||||
|
||||
## The report and the description
|
||||
|
||||
Doc `report`: one `md` block with the verdict first (Ready, Ready with notes or Not ready), then the checks grouped by runner (outcome, seconds, reason), then the notes. Doc `description`: one `md` block holding a single ` ```markdown ` fence, so its copy button copies the raw Markdown; the create-a-PR link (or the not-pushed line) goes in a second block under it, outside the fence. With `needsKind` (an unknown host) that block says the link cannot be built here and names `/plan2code-git`, whose board asks the host's kind once and remembers it; this page cannot save it.
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Ready","cleared":4},"docs":[{"id":"report","title":"Readiness","blocks":[{"id":"verdict","md":"## Ready with notes\n\n..."}]},{"id":"description","title":"PR description","blocks":[{"id":"text","md":"```markdown\n## Summary\n\n...\n```"},{"id":"link","md":"[Open the pull request](https://...)"}]}]}
|
||||
```
|
||||
|
||||
## The offers
|
||||
|
||||
Each a `confirm`, `--wait`, `"doc":"report"`:
|
||||
|
||||
- Save: `title` "Save the report", `body` naming `specs/<feature>/PR-READINESS-<date>.md` (and that a same-day file is replaced), `yesLabel` "Save it", `noLabel` "No". `how: "ask"` first asks which folder as a `choice` (one option per candidate, plus "None").
|
||||
- Hand-off when not pushed: `title` "Not pushed yet", `yesLabel` "Open Git", `noLabel` "Not now". Yes: the finish carries `/plan2code-git` instead of `/plan2code-review`.
|
||||
- Test map: `title` "Save a test map", the rows as a table in `body`, `yesLabel` "Save it", `noLabel` "No".
|
||||
|
||||
## The finish
|
||||
|
||||
`headline` is the verdict ("Ready with notes"), `body` the summary and what was saved, `command` `/plan2code-review`, `doc` `report`, `"dashboard":true`, no `commit`. Mention `/plan2code-test` in `body` when untested files were noted.
|
||||
|
||||
A stop before the run: `body` says nothing ran and nothing was saved, `"command":"/plan2code-pr-prep"`.
|
||||
@@ -422,6 +422,12 @@
|
||||
<path d="m6 17.5-2.5 1.5" />
|
||||
<path d="m18 17.5 2.5 1.5" />
|
||||
</symbol>
|
||||
<!-- Get a PR ready: a clipboard with a tick. -->
|
||||
<symbol id="ci-pr-prep" viewBox="0 0 24 24" fill="none">
|
||||
<rect x="5" y="4" width="14" height="17" rx="2" />
|
||||
<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>
|
||||
<!-- 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" />
|
||||
@@ -832,6 +838,34 @@
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- PR prep: getting a branch ready for review. He holds up a clipboard
|
||||
and its three checks tick off one by one, his star following them
|
||||
down the list, then all three hold before the list starts again. -->
|
||||
<svg class="pose pose-pr-prep" data-pose="pr-prep" 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="pp-board">
|
||||
<rect class="sh" x="176" y="64" width="48" height="108" rx="6" />
|
||||
<rect class="fl" x="188" y="56" width="24" height="12" rx="4" />
|
||||
<path class="as pp-t1" d="M184 92 L188 96 L195 87" />
|
||||
<line class="lt" x1="201" y1="92" x2="216" y2="92" />
|
||||
<path class="as pp-t2" d="M184 118 L188 122 L195 113" />
|
||||
<line class="lt" x1="201" y1="118" x2="216" y2="118" />
|
||||
<path class="as pp-t3" d="M184 144 L188 148 L195 139" />
|
||||
<line class="lt" x1="201" y1="144" x2="212" y2="144" />
|
||||
</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="pp-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="190" y2="134" />
|
||||
<circle class="fl" cx="190" 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">
|
||||
|
||||
@@ -382,6 +382,28 @@ export const SKILLS = Object.freeze([
|
||||
"Something is broken and nobody knows why. Diagnose asks what goes wrong and how to see it, then builds a command that fails on the bug before it forms a theory. It narrows the cause down to a file and a function, says how sure it is, and sizes the fix. The write-up lands in a spec folder, and the dashboard then offers Quick Task to fix it, or Plan when the fix is big. It never changes code.",
|
||||
},
|
||||
}),
|
||||
skill({
|
||||
skill: "plan2code-pr-prep",
|
||||
workflow: "pr-prep",
|
||||
label: "PR prep",
|
||||
name: "PR Prep",
|
||||
pose: "pr-prep",
|
||||
builds: false, phased: false, metered: true, templates: false,
|
||||
weight: 1, started: "PR Prep started", ran: "PR Prep run", resume: null,
|
||||
subagents: "Use helpers to read the files behind changes no test map row covers, and to draft the Changes by area section of the description. Keep the check plan, the runs, the verdict and every question with you. Light strength, low effort.",
|
||||
states: "any",
|
||||
greyed: null,
|
||||
card: {
|
||||
group: "extra",
|
||||
chip: "Utility",
|
||||
title: "Get a PR ready",
|
||||
icon: "pr-prep",
|
||||
blurb: "Runs the checks your branch needs, says if it is ready, and writes the PR description.",
|
||||
help: "Picks and runs the checks a branch needs, gives a readiness verdict and writes a PR description to copy.",
|
||||
about:
|
||||
"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-changelog",
|
||||
workflow: "changelog",
|
||||
|
||||
@@ -422,6 +422,33 @@
|
||||
44%, 88% { transform: translate(4px, 1px); }
|
||||
}
|
||||
|
||||
/* PR prep -- the clipboard's three checks tick off one by one, all three hold,
|
||||
then they clear for the next pass; his star follows the ticks down. */
|
||||
.pose .pp-t1 { animation: pp-t1 4.8s ease-out infinite; }
|
||||
@keyframes pp-t1 {
|
||||
0%, 8% { opacity: 0; }
|
||||
14%, 88% { opacity: 1; }
|
||||
96%, 100% { opacity: 0; }
|
||||
}
|
||||
.pose .pp-t2 { animation: pp-t2 4.8s ease-out infinite; }
|
||||
@keyframes pp-t2 {
|
||||
0%, 26% { opacity: 0; }
|
||||
32%, 88% { opacity: 1; }
|
||||
96%, 100% { opacity: 0; }
|
||||
}
|
||||
.pose .pp-t3 { animation: pp-t3 4.8s ease-out infinite; }
|
||||
@keyframes pp-t3 {
|
||||
0%, 44% { opacity: 0; }
|
||||
50%, 88% { opacity: 1; }
|
||||
96%, 100% { opacity: 0; }
|
||||
}
|
||||
.pose .pp-look { animation: pp-look 4.8s ease-in-out infinite; }
|
||||
@keyframes pp-look {
|
||||
0%, 100% { transform: translate(4px, -2px); }
|
||||
32% { transform: translate(4px, 0); }
|
||||
50%, 88% { transform: translate(4px, 2px); }
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.dash { padding-top: 0; }
|
||||
.launch-stage { height: 140px; }
|
||||
|
||||
Reference in new issue
Block a user