mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Show pending files on the Git commit card, add Commit it now, and default Subagents to on
AI Assisted
This commit is contained in:
1 parent
3414a19ce6
commit
3dfd44ba88
12 files changed
+242
-26
No files matched your search
@@ -208,7 +208,7 @@ Key design points:
|
||||
- **Month-old sessions are deleted whole.** `open` lists `staleSessions()` (directories matching the session-id pattern whose `state.json` mtime is older than 30 days, never the sid being opened — no exceptions for paused sessions or unread sends) and `staleScratch()` (top-level regular `.json` / `.mjs` files in the console folder older than 30 days, never `looks.json` or `console-dir` — `PROTECTED_CONSOLE_FILES` — never a directory or symlink) before it prints, and removes them after; `removeSessions()` / `removeScratch()` re-check every name against the session-id pattern / the scratch-name rule before deleting — not the age, the skipped sid or the file type, which the `stale*` listing already decided, so never hand them names that did not come from it. `console.md` tells agents to write temporary payload files into the session's own folder so they go with it.
|
||||
- **User Preferences → Cleanup deletes on demand, from a list the server makes.** `POST /cleanup` (origin-checked) with `{ scan: true }` returns `cleanupFindings()`: `{ items: [{ id, where, name, kind, bytes }], bytes }`, ids `session:<sid>` (the `staleSessions()` rule, and every file in the folder that old too, never the serving sid), `console:<name>` (anything at the top of the console home but `PROTECTED_CONSOLE_FILES`, `sessions` and `runtime`, directories too) and `root:<name>` (anything at the top of `~/.plan2code` but `KEPT_PLAN2CODE_ENTRIES`: `console`, `bin`, `launcher.json`, `models.json`). Both stray kinds must be untouched for `STRAY_GRACE_MS` (an hour, by the newest `lstat` mtime anywhere inside, since rewriting a file never moves its folder's mtime; unreadable reads as fresh): the same folders hold `workspaces.json.lock` and `writeJsonAtomic()`'s `<file>.<pid>.tmp`, which live for milliseconds. `root:` is only scanned when the console home is `<PLAN2CODE_MODELS_DIR or ~/.plan2code>/console`, so a test or dev home never reaches the real folder. Paths never go to the page. `{ delete: [id] }` runs `removeCleanup()`, which re-scans and removes only ids still on the fresh list (symlinks unlinked, never followed), returning `{ removed, bytes, failed }`. The page always shows the list before **Delete these**.
|
||||
- **The console's path is stated, not searched for.** Each Interface line names `references/web-console/` beside the SKILL.md and the `~/.plan2code/console/console-dir` fallback; the prompts with room (all but pathfinder, plan, document and finalize, which sit near the char limit) also name the canonical global install path `~/.agents/skills/<skill>/references/web-console/` (the skills CLI's real store; every agent dir links into it), and every `console.mjs open` writes `HERE` to `~/.plan2code/console/console-dir` (only `open`, so a `help` or dev run from `src/` never repoints it) so a later session can read the path from a fixed place. Without these the agent hunts the skill install dirs on every session.
|
||||
- **The dashboard scan knows whether the folder is a git repository.** `scanProject()` returns `{ hasAgents, isGit, specs }`; `isGit` comes from `insideGitRepo()`, the same filesystem walk `findRoots()` does (no `git` process, linked worktrees and submodules count, a set `GIT_DIR` / `GIT_WORK_TREE` / `GIT_COMMON_DIR` counts as a repo). When it is `false` the Git commit card stays clickable and shows `GIT_INIT_NOTE` ("Not a git repository yet: it offers to start one") as its detail line; a scan with no `isGit` counts as a repo.
|
||||
- **The dashboard scan knows whether the folder is a git repository.** `scanProject()` returns `{ hasAgents, isGit, pending, specs }`; `isGit` comes from `insideGitRepo()`, the same filesystem walk `findRoots()` does (no `git` process, linked worktrees and submodules count, a set `GIT_DIR` / `GIT_WORK_TREE` / `GIT_COMMON_DIR` counts as a repo). When it is `false` the Git commit card stays clickable and shows `GIT_INIT_NOTE` ("Not a git repository yet: it offers to start one") as its detail line; a scan with no `isGit` counts as a repo. In a repo, `pending` is `pendingFiles()` in `lib.mjs`: one `git status --porcelain -z` (3 second timeout, `null` when git cannot say) counting modified, staged, deleted and untracked paths. At `0` the card greys out with `GIT_CLEAN_REASON`; above it the detail line is `pendingNote(n)` ("3 files to commit"); `null` leaves it clickable. A finish with `commit: true` puts a **Commit it now** button on the finished screen (`commitOffer()`, `renderCommitOffer()`); its `__commit` press makes the agent resume as `git-commit` in the same session. A confirm item may carry `files: [{ path, state }]`, drawn as a collapsed table by `filesTable()`. Subagents is **on** by default for the five opted-in skills (`defaultSetting()`); a saved Off stays off.
|
||||
- **`open` needs no payload, and runs first.** `--file` and `--title` are optional (the title defaults to the folder name). Every skill's Interface line puts `node "<D>/console.mjs" open --workflow <w>` BEFORE reading console.md or the project, and a test (`every skill opens the console before it reads anything`) keeps it that way; a blank session renders a starting screen ("Starting Pathfinder", Planny in flight) until the first post. Every skill replaces the flight with its own animated pose (init — init-update borrows it — pathfinder, plan — revise-plan borrows it — document, implement — implement-review borrows it — finalize, quick-task, review, handoff; only the dashboard keeps the flight), cloned by `startStage()` in `app.js` from `<template id="start-poses">` in `index.html` and animated under `.pose` in `app.css`; `START_POSES`/`startPose()` in `answers.js` is the list, and a test keeps the template in sync with it and every catalog workflow mapped to a pose. The same pose stands above the waiting pane (`.waiting-pane`, agent working with an `activity` and nothing to ask). `posePane()` keeps the pane on screen across renders when the pose is unchanged — `renderMain()` holds any `:scope > [data-pose]` child back from the clear — so the SVG never leaves the DOM, its animations never restart on a state frame, and Planny carries unbroken from launching → starting → waiting. The dashboard's launch hand-off resumes first and reads the launched skill's file after.
|
||||
- **The start path is timed, and `open` is built around it.** Measure with `node scripts/bench-web-console.mjs` (`--browser-delay 900` for a real Chrome launch, `--roundtrip` for Send→agent and post→page, `PLAN2CODE_CONSOLE_TRACE=1` on `open` for a step timeline). Four things make it fast, and each is load-bearing:
|
||||
- **No git process.** `repoRoots()` in `lib.mjs` finds the common dir and worktree top by walking to `.git` (following `gitdir:` and `commondir` files) — each `git rev-parse` cost 150ms+ on Windows. It asks git only when `GIT_DIR`/`GIT_WORK_TREE`/`GIT_COMMON_DIR` relocate the repo, and uses the native realpath so an 8.3 short name keys the same project git would.
|
||||
|
||||
@@ -367,7 +367,7 @@ Pathfinder, the agent can hand independent pieces of work to helpers
|
||||
run at once (1 to 20; your agent's own limit still applies). **Save** sends
|
||||
it; the agent hears of it at its next check-in, as a setting, not as
|
||||
something you typed.
|
||||
- **Saved per project and per skill**, off by default, in
|
||||
- **Saved per project and per skill**, on until switched off, in
|
||||
`~/.plan2code/console/subagents.json`. The next session of the same skill
|
||||
in the same folder starts the same way.
|
||||
- **The Subagents tab.** With the first helper the agent reports, a tab
|
||||
|
||||
@@ -9,10 +9,14 @@ All notable changes to Plan2Code will be documented in this file.
|
||||
- **web-console**: the breakdown question's "Anything else about this breakdown?" field has a **No changes** button. One click fills the box with "no changes", so you no longer type it. The old "(type 'no changes' if none)" hint is gone from the label.
|
||||
- **git-commit**: a new `/plan2code-git-commit` skill and dashboard card. It reads what changed, drafts the commit message for your approval, offers a new branch first on the default branch, suggests splitting work that is really two jobs, and asks before every commit and push (never a force-push). Outside a git repository it offers to start one.
|
||||
- **changelog**: a new `/plan2code-changelog` skill and dashboard card, just left of Git commit. It reads the default branch's latest version, classifies the branch's work and picks the version. When the branch already owns a version that is not released and not on another branch, it adds to that entry instead of starting a new one. It compares the branch with the newest entry, suggests the entries that are missing for you to edit, keeps `package.json` aligned, and offers to run Git commit next. The facts come from `changelog-state.mjs`, with tests in `scripts/test-script-changelog.mjs`.
|
||||
- **web-console**: the Git commit card counts the files waiting ("3 files to commit") and greys out on a clean tree, from a bounded `git status` the scan runs when the dashboard opens. If git cannot answer, the card stays clickable.
|
||||
- **web-console**: the Commit this? question in Git commit has a collapsed **Show the N files** table of every path and its state, so "15 files" can be read before you say yes.
|
||||
- **web-console**: a finished quick task or phase build gets a **Commit it now** button beside the printed git command. It starts Git commit in the same session, as if you had clicked its dashboard card.
|
||||
- **web-console**: the dashboard scan reports `isGit`, found from the filesystem without spawning git (linked worktrees count). The Git commit card stays clickable outside a repository and says "Not a git repository yet: it offers to start one". The skill has its own Planny pose and a Help entry.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **web-console**: Subagents is now on by default for the skills that offer it, until you turn it off for a project and skill. A saved Off is kept.
|
||||
- **commits**: every commit Plan2Code suggests is now `<subject>`, a blank line, then `AI Assisted`. `commit-msg.mjs` no longer reads a ticket from the branch name and rejects `--ticket`.
|
||||
- **build**: `skills/` is no longer tracked. It is gitignored build output, rebuilt by the installer and `npm run build:skills`, as upstream does. `npm test` now runs `install.js --build-skills` instead of `--verify-skills`, so it fails on a broken source entry rather than on drift. `--verify-skills` stays as a diagnostic.
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
DONE_REPLY,
|
||||
finishPaused,
|
||||
fitWithin,
|
||||
GIT_CLEAN_REASON,
|
||||
GIT_INIT_NOTE,
|
||||
handoffShape,
|
||||
handoffText,
|
||||
@@ -67,6 +68,8 @@ import {
|
||||
recordedAnswer,
|
||||
resumeCommand,
|
||||
REVIEW_REPLY,
|
||||
commitOffer,
|
||||
pendingNote,
|
||||
reviewOffer,
|
||||
SKILL_CATALOG,
|
||||
SPEC_STATE_LABELS,
|
||||
@@ -187,6 +190,7 @@ import {
|
||||
handOff,
|
||||
initialWorkspace,
|
||||
insideGitRepo,
|
||||
pendingFiles,
|
||||
latestOpenCaps,
|
||||
parseArgs,
|
||||
pendingWorkspaceChanges,
|
||||
@@ -2444,6 +2448,20 @@ test("a finish can carry the dashboard flag, and only as a boolean", () => {
|
||||
assert.match(bad.stderr, /"finish\.dashboard" must be true or false \(or left out: no dashboard button\)/);
|
||||
});
|
||||
|
||||
// The Commit it now button is the same kind of opt-in.
|
||||
test("a finish can carry the commit flag, and only as a boolean", () => {
|
||||
const base = { headline: "The task is built", command: "git add -A && git commit -m \"x\" -m \"AI Assisted\"" };
|
||||
for (const commit of [true, false]) {
|
||||
const res = cli(["post", "--session", sid, "--file", payload("fin-commit.json", { finish: { ...base, commit } })]);
|
||||
assert.equal(res.json.ok, true);
|
||||
}
|
||||
const bad = cli(["post", "--session", sid, "--file", payload("fin-commit-bad.json", { finish: { ...base, commit: "yes" } })], {
|
||||
expectFail: true,
|
||||
});
|
||||
assert.equal(bad.status, 3);
|
||||
assert.match(bad.stderr, /"finish.commit" must be true or false/);
|
||||
});
|
||||
|
||||
// Taking the review up is the agent posting `"finish": null`: the session goes
|
||||
// back to work, so the page must stop saying it is over.
|
||||
test("a finish can be taken back, which puts the session back to work", () => {
|
||||
@@ -3089,6 +3107,55 @@ test("the Git commit card stays clickable outside a repository and says what hap
|
||||
assert.equal(cardPresentation(entry, withSpec, withSpec.specs[0], menu).detail, "Two changes ready");
|
||||
});
|
||||
|
||||
test("the Git commit card shows the pending count and greys out on a clean tree", () => {
|
||||
const entry = SKILL_CATALOG.find((e) => e.skill === "plan2code-git-commit");
|
||||
const clean = cardAvailability(entry, { hasAgents: true, isGit: true, pending: 0 }, null);
|
||||
assert.equal(clean.on, false);
|
||||
assert.equal(clean.reason, GIT_CLEAN_REASON);
|
||||
const dirty = cardAvailability(entry, { hasAgents: true, isGit: true, pending: 3 }, null);
|
||||
assert.deepEqual(dirty, { on: true, note: "3 files to commit" });
|
||||
assert.equal(pendingNote(1), "1 file to commit");
|
||||
// git could not say: stay clickable, and no repository still offers git init.
|
||||
assert.deepEqual(cardAvailability(entry, { hasAgents: true, isGit: true, pending: null }, null), { on: true });
|
||||
assert.equal(cardAvailability(entry, { hasAgents: true, isGit: false, pending: 0 }, null).note, GIT_INIT_NOTE);
|
||||
});
|
||||
|
||||
test("pendingFiles counts changed and untracked paths, and says null outside a repository", () => {
|
||||
const base = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-pending-"));
|
||||
const git = (...a) => spawnSync("git", a, { cwd: repo, encoding: "utf8" });
|
||||
const repo = path.join(base, "repo");
|
||||
const plain = path.join(base, "plain");
|
||||
fs.mkdirSync(repo);
|
||||
fs.mkdirSync(plain);
|
||||
try {
|
||||
if (git("init", "-q").status !== 0) return; // no git on this machine
|
||||
git("config", "user.email", "t@example.com");
|
||||
git("config", "user.name", "T");
|
||||
assert.equal(pendingFiles(repo), 0, "an empty repository is clean");
|
||||
fs.writeFileSync(path.join(repo, "a.txt"), "a");
|
||||
git("add", "a.txt");
|
||||
git("commit", "-q", "-m", "first");
|
||||
assert.equal(pendingFiles(repo), 0);
|
||||
fs.writeFileSync(path.join(repo, "a.txt"), "changed");
|
||||
fs.writeFileSync(path.join(repo, "b.txt"), "new");
|
||||
assert.equal(pendingFiles(repo), 2, "one modified, one untracked");
|
||||
git("add", "b.txt");
|
||||
assert.equal(pendingFiles(repo), 2, "staged counts too");
|
||||
assert.equal(scanProject(repo).pending, 2);
|
||||
assert.equal(scanProject(plain).pending, null, "no repository, no count");
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("the commit offer is read from finish.commit and a pause never carries it", () => {
|
||||
assert.equal(commitOffer({ headline: "Done", commit: true }), true);
|
||||
assert.equal(commitOffer({ headline: "Done", commit: false }), false);
|
||||
assert.equal(commitOffer({ headline: "Done" }), false);
|
||||
assert.equal(commitOffer({ headline: "Paused here", commit: true }), false);
|
||||
assert.equal(commitOffer(null), false);
|
||||
});
|
||||
|
||||
test("a verdict's button text never renders blank", () => {
|
||||
assert.equal(verdictText({ id: "approve", label: "Approve it" }), "Approve it");
|
||||
assert.equal(verdictText({ id: "approve", text: "Approve it" }), "Approve it");
|
||||
@@ -5268,7 +5335,8 @@ test("subagents: only the five opted-in workflows offer the switch", () => {
|
||||
assert.equal(defaultInstruction(w), "");
|
||||
}
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 5);
|
||||
assert.deepEqual(defaultSetting("review"), { workflow: "review", on: false, instruction: null, max: 3 });
|
||||
assert.deepEqual(defaultSetting("review"), { workflow: "review", on: true, instruction: null, max: 3 });
|
||||
assert.equal(defaultSetting("plan").on, false, "a skill without the switch is never on");
|
||||
assert.equal(effectiveInstruction({ workflow: "review", instruction: " " }), defaultInstruction("review"));
|
||||
assert.equal(effectiveInstruction({ workflow: "review", instruction: " Mine " }), "Mine");
|
||||
});
|
||||
@@ -5441,7 +5509,7 @@ test("subagents: the store round-trips per project and workflow under the consol
|
||||
if (process.platform === "win32" || process.platform === "darwin") {
|
||||
assert.deepEqual(out.otherCase, out.saved, "a different-case path reads the same entry");
|
||||
}
|
||||
assert.deepEqual(out.unsaved, { on: false, instruction: null, max: 3 });
|
||||
assert.deepEqual(out.unsaved, { on: true, instruction: null, max: 3 }, "nothing saved means on");
|
||||
assert.ok(!fs.existsSync(path.join(home, "subagents.json.lock")), "the lock is released");
|
||||
} finally {
|
||||
fs.rmSync(home, { recursive: true, force: true });
|
||||
@@ -5880,6 +5948,11 @@ test("subagents: a change reaches the next pickup once, last in reply, edits nam
|
||||
const s = subagentsSession();
|
||||
const extra = tempFolder();
|
||||
try {
|
||||
// Nothing saved means on, and open already told the agent. Turn it off and
|
||||
// let that be said, so the rest of the test starts from an off agent.
|
||||
assert.equal((await setSubagents(s, { ...ON3, on: false })).status, 200);
|
||||
assert.equal(subagentLines((await submitAndWait(s)).json.reply).length, 1, "off is said to an agent told on");
|
||||
|
||||
const on = await setSubagents(s, ON3);
|
||||
assert.equal(on.status, 200);
|
||||
assert.equal(on.body.ok, true);
|
||||
@@ -5935,7 +6008,11 @@ test("subagents: a change reaches the next pickup once, last in reply, edits nam
|
||||
});
|
||||
|
||||
test("subagents: never on means never a line, and chat hands a pending block over on its own", async () => {
|
||||
const s = subagentsSession();
|
||||
// A project that saved "off" starts its next session off and untold.
|
||||
const first = subagentsSession();
|
||||
assert.equal((await setSubagents(first, { on: false, instruction: null, max: 4 })).status, 200);
|
||||
cli(["stop", "--session", first.sid]);
|
||||
const s = subagentsSession({}, { keepStore: true });
|
||||
try {
|
||||
const off = await setSubagents(s, { on: false, instruction: null, max: 4 });
|
||||
assert.equal(off.status, 200);
|
||||
@@ -6044,14 +6121,14 @@ test("subagents: a save that matches this session still becomes the project's se
|
||||
let c = null;
|
||||
try {
|
||||
const before = (await frameSubagents(b)).revision;
|
||||
assert.equal((await setSubagents(a, ON3)).status, 200, "another session turns it on for the project");
|
||||
const same = await setSubagents(b, { ...ON3, on: false });
|
||||
assert.equal((await setSubagents(a, { ...ON3, on: false })).status, 200, "another session turns it off for the project");
|
||||
const same = await setSubagents(b, ON3);
|
||||
assert.equal(same.status, 200);
|
||||
assert.equal(same.body.setting.revision, before, "nothing changed for this session's agent");
|
||||
assert.equal("subagents" in (await submitAndWait(b)).json, false);
|
||||
|
||||
c = subagentsSession({}, { keepStore: true });
|
||||
assert.equal((await frameSubagents(c)).on, false, "the next session starts from the person's latest pick");
|
||||
assert.equal((await frameSubagents(c)).on, true, "the next session starts from the person's latest pick");
|
||||
} finally {
|
||||
for (const s of [a, b, c]) if (s) cli(["stop", "--session", s.sid]);
|
||||
}
|
||||
|
||||
@@ -236,12 +236,18 @@ says, and `stop`:
|
||||
"body": "9 of 9 tasks, all on disk.\n\n| Phase | Tasks | Goal |\n| --- | --- | --- |\n| Phase 4: ... | 6 | ... |\n\nCommit it with:\n\n```\ngit add -A && git commit -m \"...\" -m \"AI Assisted\"\n```",
|
||||
"command": "/plan2code-3-implement specs/lunch-vote/overview.md",
|
||||
"doc": "report",
|
||||
"commit": true,
|
||||
"dashboard": true
|
||||
},
|
||||
"agent": { "status": "waiting" }
|
||||
}
|
||||
```
|
||||
|
||||
`"commit": true` is there because the body prints a git command: the finished
|
||||
screen gets a **Commit it now** button, and its `__commit` press is handled as
|
||||
console.md → Finishing says (resume as `git-commit`, same session). Leave it out
|
||||
when the body prints no commit.
|
||||
|
||||
`finish.command` is the next pipeline step, the same one the terminal names:
|
||||
the next `/plan2code-3-implement`, or `/plan2code-4-finalize` after the last
|
||||
phase. An `implement` finish never carries `review`: the offer was on the
|
||||
@@ -464,8 +470,9 @@ with the count of completed tasks.
|
||||
in the project's commit format (AGENTS.md), with
|
||||
`"where": "When you are happy with it, commit it from your terminal:"`, and
|
||||
`review` on offer — the **Review it now** button, since a quick task has no
|
||||
sign-off card to put it on — and `"dashboard": true`, so the finished screen
|
||||
also offers **Back to the dashboard**. Both are required: a finish without
|
||||
sign-off card to put it on — `"commit": true` (the **Commit it now** button;
|
||||
console.md → Finishing) and `"dashboard": true`, so the finished screen
|
||||
also offers **Back to the dashboard**. Review and dashboard are required: a finish without
|
||||
`dashboard` leaves the person on a dead end. Keep waiting for whichever
|
||||
button is pressed, and everything after that is "The review, mid-session"
|
||||
above.
|
||||
|
||||
@@ -652,7 +652,7 @@ for permission is not a failure; report only a read that failed after it.
|
||||
On the skills that offer it (`implement`, `implement-review`, `quick-task`,
|
||||
`review`, `pathfinder`), the person can turn **helpers** (subagents) on or off
|
||||
from the top bar's Subagents button. Their pick is saved per project and per
|
||||
skill, off by default, and reaches you as a standing instruction, only when it
|
||||
skill, on until switched off, and reaches you as a standing instruction, only when it
|
||||
changes.
|
||||
|
||||
### What arrives
|
||||
@@ -776,13 +776,15 @@ where its real work starts.
|
||||
|
||||
The menu itself is the page's own list — you never send it. The page knows
|
||||
the repo too: `open` scans `AGENTS.md` and `specs/` into `state.scan`
|
||||
(`{ hasAgents, isGit, specs: [{ dir, name, state, detail, touched }] }`), and the
|
||||
(`{ hasAgents, isGit, pending, specs: [{ dir, name, state, detail, touched }] }`), and the
|
||||
picker at the top of the menu greys the cards that do not fit the selected
|
||||
spec's pipeline stage — or hides them outright while the **Hide unavailable
|
||||
workflows** switch under the picker is on (the default; kept in `looks.json`
|
||||
as `hideUnavailable`). The scan is a snapshot of that `open` — a spec created
|
||||
mid-session appears the next time the session resumes as a dashboard, not
|
||||
live. What a dashboard posts is what it knows about this project:
|
||||
live. `pending` is how many files a commit would take (modified, staged, deleted
|
||||
and untracked, `null` when git cannot say): the Git commit card greys out at 0
|
||||
and shows the count above it. What a dashboard posts is what it knows about this project:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
@@ -902,7 +904,7 @@ card per step, each asked only when the step needs it:
|
||||
| Step | On the page |
|
||||
| --- | --- |
|
||||
| Branch offer | A `choice`, "Which branch?": the suggested `<type>/<name>` (recommended), "Another name" (`allowOther` with a `pattern` for a branch name's shape; run what they type through `branch-check`) and "Stay on the current branch". |
|
||||
| One commit | A `text` card whose `placeholder` is the drafted subject and whose `pattern` caps it at 100 characters, then a `confirm` "Commit this?" with the files in `consequences`. With the subject given as the argument there is no card. |
|
||||
| One commit | A `text` card whose `placeholder` is the drafted subject and whose `pattern` caps it at 100 characters, then a `confirm` "Commit this?" with the files in `consequences` and, as `files: [{ "path": "src/a.js", "state": "modified" }]` (states: modified, new, deleted, renamed), a collapsed **Show the N files** table on the card. With the subject given as the argument there is no card. |
|
||||
| A split | The groups as a doc (`id: "commits"`: each group's subject and files, and any file that mixes concerns) plus a `review` card with verdicts `approve`, `change` and `single` ("One commit instead"). Asked even when the subject came as the argument. |
|
||||
| Push | A `confirm` with `push.command` and the commit list in `consequences`. |
|
||||
| `git init` | A `confirm` naming the folder (`danger: false`). |
|
||||
@@ -1333,6 +1335,7 @@ The same closer you are about to print in the terminal, as data:
|
||||
| `where` | optional | Overrides "Run this in the terminal where you started Plan2Code, in a new conversation:". |
|
||||
| `doc` | optional | Id of the document to offer as a Markdown download on the way out. Defaults to the first one. |
|
||||
| `console` | optional | Whether the copied text asks the next session to use the web console. Leave it out: it follows from the command. |
|
||||
| `commit` | optional | `true` on a finished `quick-task` or `implement` whose finish prints a git command puts a **Commit it now** button on the finished screen. The press arrives as `__commit` (below). |
|
||||
| `review` | optional | A finished `quick-task` only: `true` or `{ "label": "..." }` puts a **Review it now** button on the finished screen. `implement` offers the review on its sign-off card instead — before approval, where it can still change the outcome. See `building.md`. |
|
||||
|
||||
**Write the bare command.** Every Plan2Code skill has a console — the
|
||||
@@ -1379,6 +1382,7 @@ usual slices for up to about ten minutes:
|
||||
| --- | --- |
|
||||
| An action `{ "i": "__dashboard", "type": "dashboard" }` | `open --resume <sid> --no-open --workflow dashboard` (the resume re-runs the project scan), then ONE post with `"finish": null`, the `menu` payload and `"agent": { "status": "waiting" }`. Then read the dashboard skill (`~/.agents/skills/plan2code/SKILL.md`) and carry on as the dashboard from its "The menu" section, in this same conversation. The same action can also arrive before any finish, from the top bar's triangle: see Stop requests → "Back to the dashboard, mid-workflow". |
|
||||
| An action `__review` or `__done` | As `building.md` says (quick task only). |
|
||||
| An action `{ "i": "__commit", "type": "commit" }` | Commit it now: `open --resume <sid> --no-open --workflow git-commit` (no `finish`, no `stop`), then open `~/.agents/skills/plan2code-git-commit/SKILL.md` with your file-read tool and follow it from the top, as if the dashboard's Git commit card had been clicked. Leave the commit command you printed in the finish where it is for the terminal. |
|
||||
| `wait` exit `20` | The server is gone, not necessarily the tab. `open --resume <sid> --no-open --workflow <yours>`, then keep waiting: their Ask messages and the dashboard button still need you. Give up only when the resume itself fails. |
|
||||
| Nothing after about ten minutes | `stop` the server. The page swaps the button for the `/plan2code` command. |
|
||||
|
||||
|
||||
+36
-2
@@ -358,6 +358,34 @@ export function insideGitRepo(dir) {
|
||||
}
|
||||
}
|
||||
|
||||
// How many paths git would commit from `dir`: modified, staged, deleted and
|
||||
// untracked (an untracked folder counts once), from one bounded `git status`.
|
||||
// null when git cannot say (not installed, not a repository, too slow), which
|
||||
// the page reads as "unknown", never as a clean tree. --no-optional-locks keeps
|
||||
// this background look from taking the index lock out from under a commit.
|
||||
export function pendingFiles(dir) {
|
||||
try {
|
||||
const out = execFileSync("git", ["--no-optional-locks", "status", "--porcelain", "-z"], {
|
||||
cwd: dir,
|
||||
encoding: "utf8",
|
||||
timeout: 3000,
|
||||
windowsHide: true,
|
||||
maxBuffer: 8 * 1024 * 1024,
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
const parts = out.split("\0").filter(Boolean);
|
||||
let n = 0;
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
n++;
|
||||
// A rename or copy carries its old path as one more field.
|
||||
if (/^[RC]/.test(parts[i])) i++;
|
||||
}
|
||||
return n;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function projectRoot(cwd = process.cwd()) {
|
||||
return repoRoots(cwd).project;
|
||||
}
|
||||
@@ -871,7 +899,8 @@ function isDir(p) {
|
||||
* Scan <root>/specs into picker entries, most recently touched first.
|
||||
* `touched` is the newest file mtime inside the folder — last write wins,
|
||||
* which is the honest reading of "the one you were working on".
|
||||
* `isGit` says whether `root` sits inside a git repository (no git process).
|
||||
* `isGit` says whether `root` sits inside a git repository (no git process);
|
||||
* `pending` is how many paths a commit would take, or null when unknown.
|
||||
*/
|
||||
export function scanProject(root) {
|
||||
const specsDir = path.join(root, "specs");
|
||||
@@ -900,10 +929,12 @@ export function scanProject(root) {
|
||||
});
|
||||
}
|
||||
specs.sort((a, b) => b.touched - a.touched || a.name.localeCompare(b.name));
|
||||
const isGit = insideGitRepo(root);
|
||||
return {
|
||||
at: nowIso(),
|
||||
hasAgents: fs.existsSync(path.join(root, "AGENTS.md")),
|
||||
isGit: insideGitRepo(root),
|
||||
isGit,
|
||||
pending: isGit ? pendingFiles(root) : null,
|
||||
specs,
|
||||
};
|
||||
}
|
||||
@@ -1467,6 +1498,9 @@ export function validate(state) {
|
||||
if (fin.dashboard != null && typeof fin.dashboard !== "boolean") {
|
||||
problems.push('"finish.dashboard" must be true or false (or left out: no dashboard button)');
|
||||
}
|
||||
if (fin.commit != null && typeof fin.commit !== "boolean") {
|
||||
problems.push('"finish.commit" must be true or false (or left out: no commit button)');
|
||||
}
|
||||
// The review offer on a finished build: true, or an object carrying the
|
||||
// button's heading. The heading is read by the person, so it faces the
|
||||
// same vocabulary check as a title.
|
||||
|
||||
@@ -456,6 +456,7 @@ export const REVIEW_REPLY =
|
||||
"Review what was just built before I go: run the focused code review on this session's changes, here on the page.";
|
||||
export const DONE_REPLY = "No review, thanks. I am done: close the session.";
|
||||
export const DASHBOARD_REPLY = "Take me back to the dashboard, right here in this session.";
|
||||
export const COMMIT_REPLY = "Commit what was just built: start Git commit, right here in this session.";
|
||||
|
||||
// Shown under the Back to the dashboard button: the press picks up in the same
|
||||
// conversation, which carries a long skill's context into the next one.
|
||||
@@ -471,6 +472,16 @@ export function dashboardOffer(fin) {
|
||||
return Boolean(fin && fin.dashboard === true && !finishPaused(fin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a finish offers to commit what was just built from this page. The
|
||||
* agent opts in with `finish.commit: true` on a build that ended with a git
|
||||
* command; the press starts Git commit in the same session, as the dashboard's
|
||||
* card does. A pause never offers it.
|
||||
*/
|
||||
export function commitOffer(fin) {
|
||||
return Boolean(fin && fin.commit === true && !finishPaused(fin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a finish carries the offer to review what was just built. The agent
|
||||
* posts `finish.review` as `true` or as `{ "label": "..." }` on a finished
|
||||
@@ -732,12 +743,14 @@ const NEXT_FOR_STATE = {
|
||||
|
||||
const ON = { on: true };
|
||||
export const GIT_INIT_NOTE = "Not a git repository yet: it offers to start one";
|
||||
export const GIT_CLEAN_REASON = "Nothing to commit: no changed or new files";
|
||||
export const pendingNote = (n) => `${n} file${n === 1 ? "" : "s"} to commit`;
|
||||
const off = (reason) => ({ on: false, reason });
|
||||
|
||||
/**
|
||||
* Whether a catalog card is clickable for the current picker selection.
|
||||
*
|
||||
* `scan` is the server's project scan ({ hasAgents, isGit, specs }); `sel` is the
|
||||
* `scan` is the server's project scan ({ hasAgents, isGit, pending, specs }); `sel` is the
|
||||
* picked spec object or null for "start from scratch". A spec whose files
|
||||
* match no pipeline shape ("unrecognized") behaves like no spec at all for
|
||||
* availability — but its folder still goes along on a Pathfinder or Plan
|
||||
@@ -763,7 +776,12 @@ export function cardAvailability(entry, scan, sel) {
|
||||
case "plan2code-changelog":
|
||||
return ON;
|
||||
case "plan2code-git-commit":
|
||||
return scan && scan.isGit === false ? { on: true, note: GIT_INIT_NOTE } : ON;
|
||||
if (scan && scan.isGit === false) return { on: true, note: GIT_INIT_NOTE };
|
||||
// `pending` is null when git could not say: stay clickable then.
|
||||
if (scan && scan.isGit && Number.isInteger(scan.pending)) {
|
||||
return scan.pending === 0 ? off(GIT_CLEAN_REASON) : { on: true, note: pendingNote(scan.pending) };
|
||||
}
|
||||
return ON;
|
||||
case "plan2code-0-pathfinder":
|
||||
if (!state || state === "exploring") return { ...ON, next };
|
||||
return off("This spec is already past the questions");
|
||||
|
||||
@@ -1248,6 +1248,21 @@ h1 {
|
||||
.card .md, .card .prompt { max-width: none; }
|
||||
.card .prompt p:first-child { margin-top: 0; }
|
||||
|
||||
.card-files {
|
||||
margin-top: 10px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.card-files summary {
|
||||
cursor: pointer;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
.card-files table {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.card-files td:last-child {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.card-note {
|
||||
background: var(--accent-soft);
|
||||
border: 1px solid var(--accent-line);
|
||||
|
||||
@@ -26,7 +26,9 @@ import {
|
||||
choiceAnswer,
|
||||
DASHBOARD_COMMAND,
|
||||
DASHBOARD_NOTE,
|
||||
COMMIT_REPLY,
|
||||
DASHBOARD_REPLY,
|
||||
commitOffer,
|
||||
dashboardOffer,
|
||||
DONE_REPLY,
|
||||
finishPaused,
|
||||
@@ -567,7 +569,7 @@ let cardMarks = null;
|
||||
function fresh() {
|
||||
// `stopping` is set once a stop request has been accepted, and kept here so
|
||||
// a reload in the middle of wrapping up comes back to the same screen.
|
||||
// `afterBuild` is "review", "done" or "dashboard" once a finished session's
|
||||
// `afterBuild` is "review", "commit", "done" or "dashboard" once a finished session's
|
||||
// offer has been answered, so the buttons do not come back on a reload.
|
||||
// `homeward` is set once the top bar's Back to the dashboard request has
|
||||
// been accepted mid-workflow: { at }. The resume through the dashboard
|
||||
@@ -717,7 +719,7 @@ const selSpec = () => {
|
||||
// the finish goes away, which is the agent taking the review up.
|
||||
function reviewPending() {
|
||||
const fin = finish();
|
||||
if (!fin || !reviewOffer(fin) || local.afterBuild === "done" || local.afterBuild === "dashboard") return null;
|
||||
if (!fin || !reviewOffer(fin) || ["done", "dashboard", "commit"].includes(local.afterBuild)) return null;
|
||||
if (local.afterBuild === "review") return gone ? null : "asked";
|
||||
return gone ? null : "open";
|
||||
}
|
||||
@@ -1667,6 +1669,7 @@ function renderStatus() {
|
||||
// offer has something left to press here, and only while the server is
|
||||
// there to take the press.
|
||||
if (local.afterBuild === "dashboard" && !gone) return say("work", "Opening the dashboard…", "", true);
|
||||
if (local.afterBuild === "commit" && !gone) return say("work", "Opening Git commit…", "", true);
|
||||
const offer = reviewPending();
|
||||
if (dashboardLive(finish()) && !gone && !offer) {
|
||||
return say("point", "Done. Head back to the dashboard, or close this tab.");
|
||||
@@ -2318,10 +2321,15 @@ function renderHandoff(fin) {
|
||||
// A finished build offers its review first, above the next step, because it
|
||||
// is the one thing on this screen that has to happen before they leave.
|
||||
const offer = reviewOffer(fin);
|
||||
if (offer && local.afterBuild !== "done" && local.afterBuild !== "dashboard") {
|
||||
if (offer && !["done", "dashboard", "commit"].includes(local.afterBuild)) {
|
||||
card.appendChild(renderReviewOffer(offer));
|
||||
}
|
||||
|
||||
// The commit, right after the review: one press starts Git commit here.
|
||||
if (commitOffer(fin) && !gone && local.afterBuild !== "done" && local.afterBuild !== "dashboard") {
|
||||
card.appendChild(renderCommitOffer());
|
||||
}
|
||||
|
||||
// Three shapes: a next step to run, a pause with its resume command, or a
|
||||
// session with nothing left to run, which gets a quiet pointer at the
|
||||
// dashboard instead of a Next step block.
|
||||
@@ -2500,6 +2508,31 @@ function renderReviewOffer(offer) {
|
||||
return box;
|
||||
}
|
||||
|
||||
// Commit what was just built without leaving the page. Like the review button
|
||||
// it is a request to an agent still in its wait loop, so it is only drawn
|
||||
// while the server is there; the command printed below stays for the terminal.
|
||||
function renderCommitOffer() {
|
||||
const box = el("section", "review-offer");
|
||||
box.appendChild(el("p", "handoff-label", "Commit it"));
|
||||
box.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"review-offer-text",
|
||||
"Git commit reads what changed, drafts the message and asks before it commits or pushes. " +
|
||||
"It opens right here, the same as the dashboard's Git commit card."
|
||||
)
|
||||
);
|
||||
const asked = local.afterBuild === "commit";
|
||||
const row = el("div", "btn-row");
|
||||
const go = el("button", "btn primary", asked ? "Opening Git commit…" : "Commit it now");
|
||||
go.type = "button";
|
||||
go.disabled = asked || pendingResult;
|
||||
go.addEventListener("click", () => sendAfterBuild("commit"));
|
||||
row.appendChild(go);
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
|
||||
// The way back to the dashboard, on a finished screen whose agent opted in
|
||||
// with `finish.dashboard`. Like the review button it is a request to an agent
|
||||
// still in its wait loop, so once the server is gone it turns into the
|
||||
@@ -2546,9 +2579,9 @@ function textWithCode(tag, className, text) {
|
||||
}
|
||||
|
||||
// Any answer to a finished session's offers, as one send through the ordinary
|
||||
// submit. Like a brief, it names no question: `__review`, `__done` and
|
||||
// `__dashboard` are about the session.
|
||||
const AFTER_FINISH_REPLIES = { review: REVIEW_REPLY, done: DONE_REPLY, dashboard: DASHBOARD_REPLY };
|
||||
// submit. Like a brief, it names no question: `__review`, `__commit`, `__done`
|
||||
// and `__dashboard` are about the session.
|
||||
const AFTER_FINISH_REPLIES = { review: REVIEW_REPLY, done: DONE_REPLY, dashboard: DASHBOARD_REPLY, commit: COMMIT_REPLY };
|
||||
async function sendAfterBuild(kind) {
|
||||
if (gone || pendingResult || local.afterBuild) return;
|
||||
try {
|
||||
@@ -2572,6 +2605,7 @@ async function sendAfterBuild(kind) {
|
||||
const started = {
|
||||
review: "Review requested. It starts here in a moment.",
|
||||
dashboard: "Opening the dashboard. It appears here in a moment.",
|
||||
commit: "Opening Git commit. It appears here in a moment.",
|
||||
}[kind];
|
||||
if (started) {
|
||||
banner(started, "good");
|
||||
@@ -4406,9 +4440,31 @@ function buildConfirm(card, item, staged) {
|
||||
note.appendChild(md(item.consequences, "md"));
|
||||
card.appendChild(note);
|
||||
}
|
||||
if (Array.isArray(item.files) && item.files.length) card.appendChild(filesTable(item.files));
|
||||
commentField(card, item, "Anything to add?");
|
||||
}
|
||||
|
||||
// A collapsed list of the files a confirm is about ({ path, state } rows), so
|
||||
// "15 files" can be opened up and read before the person says yes.
|
||||
function filesTable(files) {
|
||||
const box = el("details", "card-files");
|
||||
box.appendChild(el("summary", "", `Show the ${files.length} file${files.length === 1 ? "" : "s"}`));
|
||||
const table = el("table", "md-table");
|
||||
const head = el("tr");
|
||||
head.appendChild(el("th", "", "State"));
|
||||
head.appendChild(el("th", "", "File"));
|
||||
table.appendChild(head);
|
||||
for (const f of files) {
|
||||
if (!f || typeof f.path !== "string") continue;
|
||||
const row = el("tr");
|
||||
row.appendChild(el("td", "", typeof f.state === "string" ? f.state : ""));
|
||||
row.appendChild(el("td", "", f.path));
|
||||
table.appendChild(row);
|
||||
}
|
||||
box.appendChild(table);
|
||||
return box;
|
||||
}
|
||||
|
||||
function buildRecap(card, item, staged) {
|
||||
// The recap is not optional: a click captured the pick, this captures the
|
||||
// agreement. Rendered as a document so it reads like a summary, not a form.
|
||||
|
||||
@@ -1570,7 +1570,7 @@
|
||||
shipped one back), and say how many may run at once.
|
||||
</li>
|
||||
<li>
|
||||
It is off by default and saved for this project and this skill, so
|
||||
It is on until you turn it off, and saved for this project and this skill, so
|
||||
the next session of the same skill here starts the same way.
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -58,7 +58,8 @@ export function effectiveInstruction(setting) {
|
||||
}
|
||||
|
||||
export function defaultSetting(workflow) {
|
||||
return { workflow, on: false, instruction: null, max: DEFAULT_MAX };
|
||||
// On until the person turns it off, for the workflows that offer the switch.
|
||||
return { workflow, on: offered(workflow), instruction: null, max: DEFAULT_MAX };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user