mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Add Continue here, Update CHANGELOG first and Ask prompt blocks to the web console
AI Assisted
This commit is contained in:
1 parent
f8b54ef708
commit
d32925cccf
25 files changed
+454
-28
No files matched your search
@@ -203,7 +203,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `workspace.mjs` | the session's extra folders, and the folders remembered per project and spec |
|
||||
| `public/app.js` | the page's entry and the only page file that starts anything: the start-up block. `index.html` loads it; it imports `screens/core.js` and the screens beside it |
|
||||
| `public/doc-files.js` | a document as the page shows it, and as a file: blocks, Markdown and HTML download |
|
||||
| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, or into Git); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` |
|
||||
| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, into Git, or from one skill into another off a finished screen, but never out of Git or into Review); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` |
|
||||
| `public/looks.js` | how the page looks and sounds: the saved looks, their sync, and the preferences dialog's swatches |
|
||||
| `public/mention-box.js` | the @name suggestions popover under a text box |
|
||||
| `public/net.js` | the page talking to its own server |
|
||||
@@ -316,6 +316,7 @@ Key design points:
|
||||
- **A build tells the page how long silence is normal.** The page calls a working agent stuck after two minutes without a post, which is right for a conversation and wrong for a twenty-minute build task. `agent.quietMinutes` (1 to 60, counted only while `working`) stretches the stuck, adrift and Send-grace thresholds; `quietLimitMs()` in `answers.js` is the one rule.
|
||||
- **A finished quick task's review button is a request through the wait loop**, like the brief: `{ "i": "__review" }` or `{ "i": "__done" }`. The agent keeps waiting after posting a finish that carries `review`, and takes the review up by posting `"finish": null`, which puts the session back to work. Implementation's review needs no such machinery: it is a verdict on the sign-off card, asked before approval, so the session never left work to take it up.
|
||||
- **Back to the dashboard is the same kind of post-finish request.** A finish with `finish.dashboard: true` shows the button; a press arrives as `{ "i": "__dashboard", "type": "dashboard" }`, and the agent runs `open --resume <sid> --no-open --workflow dashboard` then posts `"finish": null` with a fresh `menu`. The agent waits ~10 minutes after the finish for it (alongside `__review` / `__done` on a quick task); after that the page swaps the button for the `/plan2code` command. `finish.command` is optional — without one the page shows the "All done" line — and `validate()` rejects a `<placeholder>` command and a non-boolean `dashboard`. The session-level actions are therefore `__brief`, `__stop`, `__launch`, `__review`, `__done` and `__dashboard`; a new post-finish button should copy this precedent.
|
||||
- **Continue here, Update CHANGELOG first and Ask prompt blocks.** Three small additions on the same pattern. **Continue here** is page-only: `continueOffer(fin)` (`public/answers.js`) reads `finish.command`, and when it starts with a Plan2Code skill (and the finish is not a pause) `screens/ending.js` draws a button beside the Next step block, hidden when the session meter is red; the press is the dashboard's own `{ "i": "__launch", ... }` through `sendAfterBuild("launch", offer)`, so the agent writes nothing new (`startsClean()` cleans the page for the hop, except out of Git and into Review; a same-skill next step keeps the workflow, so the agent posts `"finish": null`). **Update CHANGELOG first** is `finish.changelog: true`, accepted by `validate()` only on `quick-task` and `finalize` (a paused finish is exempt from that check and the page ignores the flag), and it belongs with `commit: true`; the press is `__changelog`, a `HOP_ACTIONS` entry in `cmd-post-wait.mjs` that resumes as `changelog`, whose "Commit this now?" yes carries on to Git. **Ask prompt blocks** are contract only (`console-chat.md` → Prompts to carry away): the page already draws a Copy button on every fenced block.
|
||||
- **`__dashboard` also arrives mid-workflow.** A left-pointing triangle (`#btn-home`, filled with `--accent`) sits left of Stop session on every non-dashboard page. Its state comes from the pure `homeButtonState()` in `answers.js`: hidden on the dashboard, on a finish and during a stop, and otherwise gated by the same `turnGate()` Stop now uses (the person's turn, unless the agent has gone adrift). The confirm (`#home-modal`) reuses `stopWarning()`, and the submit carries the staged answers plus `__dashboard`, with `HOME_REPLY`. With no finish on the page, the agent treats it as a stop that lands on the menu: it saves its place as for `__stop`, then resumes as the dashboard with `"finish": null` + `menu`, with no finish and no stop in between (console-stop.md → "Back to the dashboard, mid-workflow"; building.md for builds). `local.homeward` drives Planny's "Saving your place and opening the dashboard…" line until the through-the-dashboard reset clears it.
|
||||
- **Handoffs live outside every repo, in `~/.plan2code/handoffs/`, and the console owns them** (`handoffs.mjs`; the console ships in every skill, so the Stop flow, the Handoff skill and the dashboard all reach it through `console.mjs`). `handoff new --workflow <w> --skill <s> [--spec specs/<x>] [--title <t>] [--from-stop]` claims one for this checkout and prints `{ ok, id, path, meta }` (exit 2 bad usage, 3 a bad value). Off the dashboard the Stop modal offers **Stop with a handoff** (`#stop-handoff`, suggested) above **Just stop and save** (`#stop-go`); the first sends `__stop` with `handoff: true` and `STOP_HANDOFF_REPLY`, and `wait` adds `handoffSkill` (the built Handoff skill's `SKILL.md`, `handoffFor()`); console-stop.md gives the order (answers, save, `handoff new --from-stop`, write, paused finish naming the file, `stop`). On a dashboard, `cmdOpen()` adds `scan.handoffs` (`listHandoffs(worktree)`) and `scan.handoffsDir` after `scanProject()`, which stays handoff-free because `specs.mjs list` shares it. The picker draws them as dashed `.spec-chip.is-handoff` chips after the specs (`specSel = "handoff:<id>"`); a picked one replaces the skill cards with `renderHandoffPreview()`: **Pick it up here**, **Read it all** (`GET /handoff?id=`, served only for an id in the dashboard's own `state.scan.handoffs`), **Copy for a new conversation** (`handoffCopyText()`) and **Delete** (`openHandoffDelete()`, one step). Pick it up sends `{ "i": "__pickup", "type": "pickup", "handoff": <id> }`; `HOP_ACTIONS.pickup` (`pickupHop()`) reads the stored `.json` only, never the page, and falls back to Quick Task with `fallback: true` when the record, its skill or its spec is gone, or the Handoff skill wrote it (resuming that skill would only write another handoff); `markPickedUp()` stamps `usedAt` as the hop is printed, so the next scan drops the chip. Delete sends `__delete` with `handoff` in place of `spec`, and the agent runs `delete-handoff --handoff <id>` (`removeHandoff()`, exit 3 on a refusal, nothing touched). `open` sweeps handoffs untouched for 30 days (`staleHandoffs()`, the `.json`'s mtime, else the `.md`'s), picked up or not, and reports them in `swept.handoffs`; Cleanup never lists the folder (`KEPT_PLAN2CODE_ENTRIES`).
|
||||
- **Notepad: the person's, one per folder, in `~/.plan2code/notepads/`, and never the agent's.** `notepads.mjs` is the store's one owner (`PLAN2CODE_NOTEPADS_DIR` moves it for tests). The folder is the session's worktree, else its project (`notepadRoot()` in `routes.mjs`), keyed `<folder-name>-<12 hex>` by `notepadKey()` (the hash over `foldKey()`, so case-only path differences match on Windows and macOS, and two worktrees get two notepads), and holds `meta.json` (`{ v, folder, created }`, written once), `note.md` and `images/<uuid>.jpg` with `<uuid>.thumb.jpg`. Every write takes the folder's `notepad.lock`; a read never creates a file, so only the person's edits age a notepad. The page reaches it through six routes, placed after `/upload` in `ROUTES` (the shape test pins the order): `GET /notepad` (`{ text, savedAt, images: [{ id, url, thumb }] }`), `POST /notepad/text` (`{ text }`, 1 MB, 413 `too-long`), `POST /notepad/image` and `POST /notepad/thumb?id=<uuid>` (raw `image/jpeg` the page re-encoded with `reencode()`, 4 MB, 200 pictures: 415 `not-jpeg`, 413 `too-large`, 409 `too-many`), `POST /notepad/image/delete` (`{ id }`) and `GET /notepad/images/<uuid>[.thumb].jpg` (matched on the raw request line like `/uploads/`, served through `imagePath()`'s realpath containment, `no-store`); the four POSTs are origin-checked, and every refusal is a `NotepadError` turned into `{ error }`. None of them writes to the session folder or `events.ndjson`, and `console.mjs` never imports `notepads.mjs`, so nothing in a notepad reaches `state.json` or anything `wait` prints. **The CSP workaround.** OverType 2.6.1 (MIT, vendored unchanged as `public/vendor/overtype.esm.js`) adds a `<style>` element and inline `style` attributes, both of which `style-src 'self'` refuses: `screens/notepad.js` sets `OverType.stylesInjected = true` before making the one editor, OverType's own CSS ships at the top of `styles/notepad.css` (in `CSS_ORDER`, so it rides the joined stylesheet), and `withoutStyleAttrs()` strips the attributes from what OverType renders. `scripts/test-web-console-page-notepad.mjs` fails on any `securitypolicyviolation` with the notepad open. **Upgrading OverType:** replace the vendored file from `https://cdn.jsdelivr.net/npm/overtype@<version>/dist/overtype.esm.js`, update its version and sha256 in its files-table row and the version in `HEADER` in `scripts/vendor-overtype.mjs`, run `node scripts/vendor-overtype.mjs` (needs a local Chrome or Edge; it rewrites only what sits above `/* end OverType */` and refuses a `notepad.css` without the marker), recheck the internals listed in the vendored file's row, then run the two notepad test files. **Cleanup.** No sweep at `open` touches a notepad, and `notepads` is in `KEPT_PLAN2CODE_ENTRIES`, so the folder is never a stray. `cleanupFindings()` lists a notepad as one `notepad:<key>` item (with `folder` from `meta.json`, labelled "Notepad for <folder>" by `screens/cleanup.js`, the key when it is missing) only when `staleNotepads()` finds the newest file in it (`newestMtime()` in `files.mjs`) `SESSION_MAX_AGE_MS` (30 days) old or more; `removeCleanup()` removes the whole folder through `removeNotepad()` (key checked against `NOTEPAD_KEY_RE`, contained in `notepadsDir()`, a link refused).
|
||||
|
||||
@@ -179,6 +179,8 @@ review has already reviewed the code, so its card has no review button.
|
||||
</picture>
|
||||
|
||||
The **Ask** tab is a chat beside the cards, for a quick question at any point.
|
||||
When a question is really a new task, the answer ends with a ready-to-paste
|
||||
prompt in a block with a Copy button, to take into a new conversation.
|
||||
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="../docs/screenshots/ask-dark.webp">
|
||||
@@ -521,6 +523,14 @@ chip until it is picked up. **Just stop and save** saves your place and gives
|
||||
the resume command, nothing more; where the step has nothing saved yet it reads
|
||||
*Stop anyway*, under a warning about what is lost.
|
||||
|
||||
When the next step is another Plan2Code skill, the screen also has a
|
||||
**Continue here** button beside it: one press starts that skill in the same
|
||||
conversation, as a dashboard card would. It disappears once the session meter is
|
||||
red, when a fresh conversation is the better choice. A finished Quick Task or
|
||||
Finalize that ends on a commit can also offer **Update CHANGELOG first**, beside
|
||||
**Commit it now**: it opens Changelog right there, and Changelog's yes to
|
||||
*Commit this now?* carries on to Git.
|
||||
|
||||
The first two also carry a **Back to the dashboard** button (beside the next
|
||||
step, or as the main button under "All done"). Press it and the same page turns
|
||||
back into the skill menu, in the same conversation, so the next skill starts
|
||||
|
||||
@@ -8,6 +8,10 @@ All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
- **web console**: a private **Notepad** in the top bar, on every screen. It opens a modal with a Markdown editor that styles as you type (OverType 2.6.1, vendored, MIT) and saves as you go, with pictures: paste, drag and drop or **Add image**, each shrunk to JPEG in the browser, shown as a thumbnail strip with an X that asks before deleting, and a full-screen preview. There is one notepad per project folder, kept in `~/.plan2code/notepads/` (`notepads.mjs`) and never shown to the agent. User Preferences → Cleanup offers a notepad for removal only when its newest file is 30 days old or more, as one item that removes the whole folder; the automatic sweep at open never touches it.
|
||||
|
||||
- **web console**: a finished screen whose next step is a Plan2Code skill has a **Continue here** button beside the Next step block. One press starts that skill in the same session, as a dashboard card would, on a clean page. It is hidden when the session meter is red (a fresh conversation is the better choice), on a pause and for a git command. The page does it alone: the agent only handles the `__launch` the dashboard already sends, and posts `finish: null` first when the next step is the same skill (Implement to Implement).
|
||||
- **web console**: a finished Quick Task or Finalize can offer **Update CHANGELOG first** beside **Commit it now** (`finish.changelog: true`, refused on any other workflow). It hops into Changelog in the same session, and Changelog's yes to *Commit this now?* carries on to Git. The press arrives as `__changelog`.
|
||||
- **web console**: the Ask contract (`console-chat.md`, *Prompts to carry away*) tells the agent to answer a new-task question, or a request for a prompt, with the explanation and one self-contained prompt in a fenced block. The page already gave every fenced block a Copy button, so there is no page change.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **web console**: the dashboard has one Implement card instead of Implement and Implement + Review. Its confirm pane has a Review checkbox, ticked by default, that launches Implement + Review when ticked and plain Implement when not; the command shown follows the box.
|
||||
|
||||
@@ -432,3 +432,17 @@ test("a reply proposing an edit under the running spec is refused; a valid reply
|
||||
cli(["stop", "--session", s.sid]);
|
||||
}
|
||||
});
|
||||
|
||||
// The Ask tab's prompt blocks are contract only: the page already draws Copy on a
|
||||
// fenced block, so the agent has to be told when and how to write one.
|
||||
test("console-chat.md teaches the prompt block: when, what it holds, and not to open it with a command word", () => {
|
||||
const text = fs.readFileSync(path.join(ROOT, "src", "web-console", "console-chat.md"), "utf8");
|
||||
const section = text.split(/^## /m).find((s) => s.startsWith("Prompts to carry away"));
|
||||
assert.ok(section, "console-chat.md has no 'Prompts to carry away' section");
|
||||
assert.match(section, /fenced block/);
|
||||
assert.match(section, /Copy/);
|
||||
assert.match(section, /paste it into the Ask tab/);
|
||||
assert.match(section, /out of scope/);
|
||||
assert.match(section, /files to read/);
|
||||
assert.doesNotMatch(section, /\u2014/, "no em dash in the section");
|
||||
});
|
||||
@@ -63,6 +63,9 @@ import {
|
||||
REVIEW_REPLY,
|
||||
afterFinishButton,
|
||||
commitOffer,
|
||||
changelogOffer,
|
||||
continueOffer,
|
||||
continueReply,
|
||||
pendingNote,
|
||||
reviewOffer,
|
||||
SKILL_CATALOG,
|
||||
@@ -348,12 +351,17 @@ test("the resume command follows the entry's resume kind, and an unknown workflo
|
||||
assert.equal(resumeCommand({}), "/plan2code-0-pathfinder");
|
||||
});
|
||||
|
||||
test("a hop starts the page clean to or from the dashboard and into Git, and nowhere else", () => {
|
||||
test("a hop starts the page clean to or from the dashboard, into Git and between skills, but not out of Git or into Review", () => {
|
||||
assert.equal(startsClean("implement", "dashboard"), true);
|
||||
assert.equal(startsClean("dashboard", "plan"), true);
|
||||
assert.equal(startsClean("changelog", "git"), true);
|
||||
assert.equal(startsClean("finalize", "git"), true);
|
||||
// A launch from a finished screen (Continue here, Update CHANGELOG first)
|
||||
assert.equal(startsClean("plan", "document"), true);
|
||||
assert.equal(startsClean("quick-task", "changelog"), true);
|
||||
assert.equal(startsClean("finalize", "changelog"), true);
|
||||
assert.equal(startsClean("git", "changelog"), false);
|
||||
assert.equal(startsClean("git", "plan"), false);
|
||||
assert.equal(startsClean("implement", "review"), false);
|
||||
assert.equal(startsClean("git", "git"), false);
|
||||
assert.equal(startsClean("dashboard", "dashboard"), false);
|
||||
@@ -1025,6 +1033,48 @@ test("the commit offer is read from finish.commit and a pause never carries it",
|
||||
assert.equal(commitOffer(null), false);
|
||||
});
|
||||
|
||||
test("the changelog offer is read from finish.changelog and a pause never carries it", () => {
|
||||
assert.equal(changelogOffer({ headline: "Done", changelog: true }), true);
|
||||
assert.equal(changelogOffer({ headline: "Done", changelog: false }), false);
|
||||
assert.equal(changelogOffer({ headline: "Done" }), false);
|
||||
assert.equal(changelogOffer({ headline: "Paused here", changelog: true }), false);
|
||||
assert.equal(changelogOffer(null), false);
|
||||
});
|
||||
|
||||
test("Continue here is offered for a skill command, with the spec it names, and never for a pause or a non-skill", () => {
|
||||
const offer = (command, rest = {}) => continueOffer({ headline: "Done", command, ...rest });
|
||||
assert.deepEqual(offer("/plan2code-2-document"), { skill: "plan2code-2-document", workflow: "document", spec: undefined });
|
||||
assert.deepEqual(offer("/plan2code-2-document --web"), { skill: "plan2code-2-document", workflow: "document", spec: undefined });
|
||||
assert.deepEqual(offer("/plan2code-3-implement specs/lunch-vote/overview.md --web"), {
|
||||
skill: "plan2code-3-implement",
|
||||
workflow: "implement",
|
||||
spec: "specs/lunch-vote",
|
||||
});
|
||||
assert.deepEqual(offer("/plan2code-2-document specs/lunch-vote/PLAN-DRAFT-20261019.md"), {
|
||||
skill: "plan2code-2-document",
|
||||
workflow: "document",
|
||||
spec: "specs/lunch-vote",
|
||||
});
|
||||
assert.equal(offer("/plan2code-4-finalize specs--completed/old/overview.md").spec, undefined);
|
||||
assert.equal(offer("/plan2code-3-implement specs/lunch-vote/overview.md", { headline: "Paused at Phase 2" }), null);
|
||||
assert.equal(offer("/plan2code"), null);
|
||||
assert.equal(offer("/plan2code --web"), null);
|
||||
assert.equal(offer("git add -A && git commit -m x -m y"), null);
|
||||
assert.equal(offer("/not-a-plan2code-skill"), null);
|
||||
assert.equal(offer(""), null);
|
||||
assert.equal(continueOffer(null), null);
|
||||
});
|
||||
|
||||
test("the Continue here reply names the skill and its spec like a dashboard launch, in plain words", () => {
|
||||
const reply = continueReply({ skill: "plan2code-3-implement", workflow: "implement", spec: "specs/lunch-vote" });
|
||||
assert.equal(reply, "Start Implement (/plan2code-3-implement) for specs/lunch-vote, right here in this session.");
|
||||
assert.equal(
|
||||
continueReply({ skill: "plan2code-2-document", workflow: "document" }),
|
||||
"Start Document (/plan2code-2-document), right here in this session."
|
||||
);
|
||||
assert.doesNotMatch(reply, /(brief|recap|minutes)/i);
|
||||
});
|
||||
|
||||
test("one press on a finish locks every offer button, even after the agent collects it", () => {
|
||||
// Nothing pressed: live unless a send is still being picked up.
|
||||
assert.deepEqual(afterFinishButton(null, "commit", false), { asked: false, disabled: false });
|
||||
|
||||
@@ -77,6 +77,31 @@ test("a Quick question typed in Ask reaches the agent under chat, and the agent'
|
||||
assert.match(await textOf(s.page.locator(".ask-counter")), /1/);
|
||||
});
|
||||
|
||||
// What a person sees break: a prompt the agent wrote for a new conversation with no
|
||||
// Copy button, or one that tells them to "paste it into the Ask tab" as though it
|
||||
// were a terminal command.
|
||||
test("an Ask reply with a fenced prompt shows Copy and no run hint, while a command block still gets the hint", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openAsk(s);
|
||||
await askQuestion(s, "Give me a prompt for adding the export to the report");
|
||||
const [asked] = messages(collect(s));
|
||||
|
||||
const prompt = "Add the export to the report. Read src/export.js and src/report.js first. Do not touch the importer.";
|
||||
const fence = "```";
|
||||
const md = ["That is a separate job. Paste this into a new Quick Task:", "", fence, prompt, fence, "", "Or run this:", "", fence, "npm test", fence].join("\n");
|
||||
s.post({ chat: { replies: [{ id: "r1", re: asked.seq, conversation: 1, md }] } });
|
||||
const reply = s.page.locator(".ask-row.agent");
|
||||
await reply.getByText("That is a separate job").waitFor();
|
||||
|
||||
const blocks = reply.locator("pre");
|
||||
assert.equal(await blocks.count(), 2);
|
||||
const first = blocks.nth(0).locator("xpath=..");
|
||||
assert.equal(await first.getByRole("button", { name: "Copy" }).count(), 1, "the prompt block has a Copy button");
|
||||
assert.equal(await first.locator(".md-run-hint").count(), 0, "a prompt block gets no run hint");
|
||||
const second = blocks.nth(1).locator("xpath=..");
|
||||
assert.equal(await second.locator(".md-run-hint").count(), 1, "a command block still gets the hint");
|
||||
});
|
||||
|
||||
// What a person sees break: starters that send for them, or that are missing
|
||||
// from an empty conversation.
|
||||
test("an empty Ask offers starters, a click only fills the box, and nothing is sent until Send", async (t) => {
|
||||
|
||||
@@ -93,6 +93,74 @@ test("the finished screen shows the next command with --web, copies it, turns Se
|
||||
);
|
||||
});
|
||||
|
||||
// What a person sees break: no Continue here on a finish that names a skill, one
|
||||
// beside a git command or a pause, one at the red meter level, or a press that
|
||||
// reaches the agent as anything but the dashboard's own launch.
|
||||
test("Continue here shows beside a skill's next step while the meter is not red and sends a launch with the skill and spec", async (t) => {
|
||||
const browser = await suite.browser();
|
||||
const next = { headline: "The plan is documented", command: "/plan2code-3-implement specs/audit-export/overview.md", dashboard: true };
|
||||
const s = await openSession(browser, { t, workflow: "document", payload: { agent: { status: "working", activity: "Writing" } } });
|
||||
s.post({ finish: next });
|
||||
const main = s.page.locator("#main");
|
||||
const go = main.getByRole("button", { name: "Continue here" });
|
||||
await go.waitFor();
|
||||
assert.equal(await go.count(), 1);
|
||||
|
||||
await go.click();
|
||||
const got = collect(s);
|
||||
assert.deepEqual(got.actions, [
|
||||
{ i: "__launch", type: "launch", skill: "plan2code-3-implement", workflow: "implement", spec: "specs/audit-export" },
|
||||
]);
|
||||
assert.equal(got.reply, "Start Implement (/plan2code-3-implement) for specs/audit-export, right here in this session.");
|
||||
// The hop's resume is the dashboard's: the skill's workflow and the spec.
|
||||
assert.match(got.resume, /--workflow implement --spec specs\/audit-export$/);
|
||||
await main.getByRole("button", { name: "Starting the next step…" }).waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Back to the dashboard" }).isDisabled(), true, "one press locks the other buttons");
|
||||
|
||||
// No skill to continue into: a git command, or a pause.
|
||||
const git = await openSession(browser, { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
git.post({ finish: { headline: "Quick task done", command: "git add -A && git commit -m x -m y", dashboard: true } });
|
||||
await git.page.locator("#main").getByRole("heading", { name: "Quick task done" }).waitFor();
|
||||
assert.equal(await git.page.getByRole("button", { name: "Continue here" }).count(), 0, "a git command is not a skill");
|
||||
const paused = await openSession(browser, { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
paused.post({ finish: { headline: "Paused at Phase 2", command: "/plan2code-3-implement specs/audit-export/overview.md" } });
|
||||
await paused.page.locator("#main").getByRole("heading", { name: "Paused at Phase 2" }).waitFor();
|
||||
assert.equal(await paused.page.getByRole("button", { name: "Continue here" }).count(), 0, "a pause is not continued");
|
||||
});
|
||||
|
||||
test("Update CHANGELOG first shows beside Commit it now only when the finish asks for it, and sends __changelog", async (t) => {
|
||||
const browser = await suite.browser();
|
||||
const base = { headline: "Quick task done", command: "git add -A && git commit -m x -m y", commit: true, dashboard: true };
|
||||
const plain = await openSession(browser, { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
plain.post({ finish: base });
|
||||
await plain.page.locator("#main").getByRole("button", { name: "Commit it now" }).waitFor();
|
||||
assert.equal(await plain.page.getByRole("button", { name: "Update CHANGELOG first" }).count(), 0, "no flag, no button");
|
||||
|
||||
const s = await openSession(browser, { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
s.post({ finish: { ...base, changelog: true } });
|
||||
const main = s.page.locator("#main");
|
||||
const go = main.getByRole("button", { name: "Update CHANGELOG first" });
|
||||
await go.waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Commit it now" }).count(), 1);
|
||||
await go.click();
|
||||
assert.deepEqual(collect(s).actions.map(({ i, type }) => ({ i, type })), [{ i: "__changelog", type: "changelog" }]);
|
||||
await main.getByRole("button", { name: "Opening Changelog…" }).waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Commit it now" }).isDisabled(), true, "one press locks the other buttons");
|
||||
});
|
||||
|
||||
test("Continue here is hidden once the session meter is red, and the command and fresh-session advice stay", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
// Ten points: a thirty-task phase scores ten, the red level.
|
||||
s.post({ run: { event: "implement-phase", id: "phase-1", tasks: 30 } });
|
||||
await s.page.locator("#meter-pill[data-level='red']").waitFor();
|
||||
s.post({ finish: { headline: "Phase 1 is done", command: "/plan2code-3-implement specs/audit-export/overview.md", dashboard: true } });
|
||||
const main = s.page.locator("#main");
|
||||
await main.getByRole("heading", { name: "Phase 1 is done" }).waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Continue here" }).count(), 0, "Continue here at red");
|
||||
assert.ok(await main.locator("code").filter({ hasText: /^\/plan2code-3-implement specs\/audit-export\/overview\.md --web$/ }).count(), "the command stays");
|
||||
assert.equal(await closeGuide(s).count(), 1, "the fresh-session advice stays");
|
||||
});
|
||||
|
||||
test("Stop session, confirmed, sends __stop with no handoff", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.click("#btn-stop");
|
||||
|
||||
@@ -36,7 +36,7 @@ import { HELP_TABS, helpTabFor, helpKeyTarget } from "../src/web-console/public/
|
||||
import { RED_AT, YELLOW_AT } from "../src/web-console/public/meter.js";
|
||||
import { REMOTE_FOLD } from "../src/web-console/public/git-board.js";
|
||||
import { readLedger, SESSION_MAX_AGE_MS, sweepUploads, UPLOAD_MAX_AGE_MS } from "../src/web-console/sessions.mjs";
|
||||
import { applyPatch } from "../src/web-console/patches.mjs";
|
||||
import { applyPatch, validate } from "../src/web-console/patches.mjs";
|
||||
import { joinedCss } from "./css-helpers.mjs";
|
||||
import {
|
||||
ROOT,
|
||||
@@ -219,6 +219,41 @@ test("a launch request round-trips with the skill the dashboard resumes as", asy
|
||||
assert.ok(state.items.every((i) => i.id !== "__launch"), "a launch must not become a question");
|
||||
});
|
||||
|
||||
// Continue here sends the same launch from a finished screen, so the hop's
|
||||
// resume names the next skill's workflow and the spec, and the skill file to read.
|
||||
test("a launch sent from a finished screen carries the resume for the next skill and spec", async () => {
|
||||
await post("/submit", {
|
||||
actions: [{ i: "__launch", type: "launch", skill: "plan2code-2-document", workflow: "document", spec: "specs/lunch-vote" }],
|
||||
reply: "Start Document (/plan2code-2-document) for specs/lunch-vote, right here in this session.",
|
||||
});
|
||||
const res = cli(["wait", "--session", sid, "--seconds", "10"]);
|
||||
assert.equal(res.status, 0);
|
||||
assert.equal(res.json.actions[0].i, "__launch");
|
||||
assert.match(res.json.resume, /--no-open --workflow document --spec specs\/lunch-vote$/);
|
||||
});
|
||||
|
||||
// The page tells the person the hop gives the next skill a clean page: a resume
|
||||
// into a different workflow drops the finish it was launched from.
|
||||
test("resuming into another skill after Continue here drops the finish", async () => {
|
||||
const stateFile = path.join(session, "state.json");
|
||||
const readState = () => JSON.parse(fs.readFileSync(stateFile, "utf8"));
|
||||
cli(["post", "--session", sid, "--file", payload("fin-continue.json", {
|
||||
finish: { headline: "The plan is documented", command: "/plan2code-5-changelog", dashboard: true },
|
||||
})]);
|
||||
const snapshot = fs.readFileSync(stateFile, "utf8");
|
||||
await post("/submit", {
|
||||
actions: [{ i: "__launch", type: "launch", skill: "plan2code-changelog", workflow: "changelog" }],
|
||||
reply: "Start Changelog (/plan2code-changelog), right here in this session.",
|
||||
});
|
||||
const res = cli(["wait", "--session", sid, "--seconds", "10"]);
|
||||
assert.equal(res.status, 0);
|
||||
cli(["open", "--resume", sid, "--no-open", "--workflow", "changelog"]);
|
||||
const resumed = readState();
|
||||
assert.equal(resumed.workflow, "changelog");
|
||||
assert.equal(resumed.finish, undefined, "the old finish is gone");
|
||||
fs.writeFileSync(stateFile, snapshot);
|
||||
});
|
||||
|
||||
// A delete from the dashboard's picker is a send like a launch, but no hop:
|
||||
// the agent stays the dashboard, so it carries no resume and no skill file.
|
||||
test("a delete request round-trips with the spec folder and no resume", async () => {
|
||||
@@ -1337,6 +1372,32 @@ test("patches merge by id and append threads", () => {
|
||||
assert.ok(replies[0].at, "the server stamps the time the agent left out");
|
||||
});
|
||||
|
||||
test("finish.changelog is accepted on quick-task and finalize, and refused on implement and on a non-boolean", () => {
|
||||
const problems = (workflow, changelog, headline = "Done") =>
|
||||
validate({ workflow, items: [], finish: { headline, command: "git add -A", commit: true, changelog } });
|
||||
for (const workflow of ["quick-task", "finalize"]) assert.deepEqual(problems(workflow, true), [], workflow);
|
||||
assert.match(problems("implement", true).join(), /only for a finished quick-task or finalize/);
|
||||
assert.match(problems("implement-review", true).join(), /only for a finished quick-task or finalize/);
|
||||
assert.match(problems("quick-task", "yes").join(), /must be true or false/);
|
||||
// false is always fine, and a pause ignores it
|
||||
assert.deepEqual(problems("implement", false), []);
|
||||
assert.deepEqual(problems("implement", true, "Paused at Phase 2"), []);
|
||||
});
|
||||
|
||||
// Update CHANGELOG first is a hop like Commit it now, into Changelog.
|
||||
test("a changelog request from a finished screen carries the resume into the changelog workflow and its skill file", async () => {
|
||||
await post("/submit", {
|
||||
actions: [{ i: "__changelog", type: "changelog" }],
|
||||
reply: "Update the CHANGELOG before I commit: open Changelog, right here in this session.",
|
||||
});
|
||||
const res = cli(["wait", "--session", sid, "--seconds", "10"]);
|
||||
assert.equal(res.status, 0);
|
||||
assert.equal(res.json.actions[0].i, "__changelog");
|
||||
assert.match(res.json.resume, /--no-open --workflow changelog$/);
|
||||
const state = JSON.parse(fs.readFileSync(path.join(session, "state.json"), "utf8"));
|
||||
assert.ok(state.items.every((i) => i.id !== "__changelog"), "a changelog request must not become a question");
|
||||
});
|
||||
|
||||
test("a thread reply in another shape is lifted into { who, text }, and an empty one is refused", () => {
|
||||
const base = { items: [{ id: "n1", kind: "text", title: "Name", status: "open", thread: [{ who: "user", text: "why?", at: "2026-10-05T10:00:00Z" }] }] };
|
||||
const next = applyPatch(base, {
|
||||
|
||||
@@ -380,13 +380,14 @@ test("a pick-up comes with the stored skill's resume command, handoffFile, and f
|
||||
}
|
||||
});
|
||||
|
||||
test("a launch, a dashboard press and Commit it now each come with their resume command", async () => {
|
||||
test("a launch, a dashboard press, Commit it now and Update CHANGELOG first each come with their resume command", async () => {
|
||||
const s = consoleSession(["--workflow", "dashboard"]);
|
||||
try {
|
||||
const cases = [
|
||||
[{ i: "__launch", type: "launch", skill: "plan2code-3-implement", workflow: "implement", spec: "specs/lunch vote" }, "implement", ' --spec "specs/lunch vote"'],
|
||||
[{ i: "__dashboard", type: "dashboard" }, "dashboard", ""],
|
||||
[{ i: "__commit", type: "commit" }, "git", ""],
|
||||
[{ i: "__changelog", type: "changelog" }, "changelog", ""],
|
||||
];
|
||||
for (const [action, workflow, spec] of cases) {
|
||||
assert.equal((await s.send("/submit", { actions: [action], reply: "go" })).status, 200);
|
||||
|
||||
@@ -149,6 +149,6 @@ a question still owed, above the ending itself:
|
||||
commit command for the fixes, in the project's commit format.
|
||||
- `command`: one commit for the whole quick task, its changes and the fixes
|
||||
together, in the project's commit format (not a second command beside the
|
||||
first), with `commit: true` so **Commit it now** is still on offer.
|
||||
first), with `commit: true` so **Commit it now** is still on offer, and `changelog: true` so **Update CHANGELOG first** is too.
|
||||
- `headline`: the quick task's own again, e.g. `{ "cleared": 4, "total": 4 }`.
|
||||
- `doc`: `"review"`.
|
||||
@@ -82,7 +82,7 @@ port, and the filesystem as transport; this CLI is the whole agent surface.
|
||||
Exit 0 may also carry "subagents" (a console setting, not typed
|
||||
by the person, with its "Subagents: ..." lines last in reply); a
|
||||
setting change alone never ends a slice either. A hop
|
||||
(__launch, __dashboard, __commit) carries resume, the exact
|
||||
(__launch, __dashboard, __commit, __changelog) carries resume, the exact
|
||||
open --resume command, and skillFile when installed. Collecting
|
||||
a send sets the page to working; a wait with a question open
|
||||
hands the turn back.
|
||||
|
||||
@@ -574,6 +574,7 @@ const HOP_ACTIONS = {
|
||||
launch: (a) => ({ workflow: a.workflow, spec: a.spec, skill: a.skill }),
|
||||
dashboard: () => ({ workflow: "dashboard", skill: "plan2code" }),
|
||||
commit: () => ({ workflow: "git", skill: "plan2code-git" }),
|
||||
changelog: () => ({ workflow: "changelog", skill: "plan2code-changelog" }),
|
||||
pickup: pickupHop,
|
||||
};
|
||||
|
||||
|
||||
@@ -85,6 +85,34 @@ replied to: treat that as a stop-and-reply.
|
||||
- When `about` is set, answer from that context: the card, doc section or
|
||||
spec the person was looking at.
|
||||
|
||||
## Prompts to carry away
|
||||
|
||||
Some questions are really a new task: the person asks for "a prompt", or the
|
||||
right answer is work for a separate Plan, Quick Task or another skill rather
|
||||
than something to do inside this session. Do not start that work here and do
|
||||
not make them retype your answer. Reply with the explanation first, then ONE
|
||||
self-contained prompt in a fenced block with no info string. The page draws
|
||||
every fenced block with a **Copy** button, so the person copies it into a new
|
||||
conversation.
|
||||
|
||||
A good prompt block:
|
||||
|
||||
- opens with plain prose, never a command word. A block whose first line looks
|
||||
like a terminal command (`git`, `npm`, `node`, `rm` and the like, or `#!`)
|
||||
gets the muted "paste it into the Ask tab" hint, which is wrong for a prompt.
|
||||
The check is case-insensitive and also catches everyday verbs that are shell
|
||||
commands (Make, Go, Source, Export, Service, Cat, Echo, Zip, Tar, Cd, Ls), so
|
||||
"Make the report export..." trips it. Start with "In this repo, ..." or "Using
|
||||
the Quick Task skill, ...". A leading skill command (`/plan2code-quick-task ...`)
|
||||
is fine: it gets none;
|
||||
- names the skill to paste it into, the files to read first, and what to do;
|
||||
- states what is out of scope, so the new conversation does not wander;
|
||||
- stands alone: it assumes nothing said in this session, because the new
|
||||
conversation has none of it.
|
||||
|
||||
One block per reply, and only when the work is likely to move to a new
|
||||
conversation. A plain answer stays a plain answer.
|
||||
|
||||
## Never steer the workflow
|
||||
|
||||
A chat answer never changes a card's answer, a gate, or where the workflow
|
||||
|
||||
@@ -53,8 +53,18 @@ The same closer you are about to print in the terminal, as data:
|
||||
| `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`, `implement`, `implement-review`, `review` or `finalize` whose finish prints a git command puts a **Commit it now** button on the finished screen. The press arrives as `__commit` (below). |
|
||||
| `changelog` | optional | `true` on a finished `quick-task` or `finalize` that also carries `commit: true` puts an **Update CHANGELOG first** button beside **Commit it now**. Refused (exit 3) on any other workflow, `implement` included. The press arrives as `__changelog` (below). |
|
||||
| `review` | optional | A finished `quick-task` only: `true` or `{ "label": "..." }` puts a **Review it now** button on the finished screen (`notes/quick-task.md`, `building-review.md`). `implement` offers the review on its sign-off card instead — before approval, where it can still change the outcome. |
|
||||
|
||||
**Continue here.** Nothing to set: when `command` starts with a Plan2Code skill
|
||||
(`/plan2code-2-document specs/lunch-vote/PLAN-DRAFT-20261019.md`, with or
|
||||
without `--web`) and the finish is not a pause, the page puts a **Continue
|
||||
here** button beside the Next step block, unless the session meter is red
|
||||
(then the fresh-session advice stands alone). A finish whose command is a git
|
||||
commit, or that has none, gets no button. You write nothing new; you only
|
||||
handle the `__launch` it sends (below). The `spec` it carries is the
|
||||
`specs/<name>` folder the command mentions.
|
||||
|
||||
**Write the bare command.** Every Plan2Code skill has a console — the
|
||||
dashboard and every skill behind it — so for any of them the page
|
||||
appends ` --web` to what it shows and copies, so someone who worked here
|
||||
@@ -100,6 +110,8 @@ works like a press a minute later.
|
||||
| What arrives | What you do |
|
||||
| --- | --- |
|
||||
| An action `{ "i": "__dashboard", "type": "dashboard" }` | Run the `resume` it carries (`open --resume <sid> --no-open --workflow dashboard`; it re-runs the project scan and clears the page, the finish included), read the dashboard skill (`skillFile`, or `~/.agents/skills/plan2code/SKILL.md`), then post its `menu` with `--wait` and carry on as the dashboard from its "Coming back from another skill", in this same conversation. |
|
||||
| An action `{ "i": "__changelog", "type": "changelog" }` | Update CHANGELOG first: run the `resume` it carries (`open --resume <sid> --no-open --workflow changelog`; no `finish`, no `stop`; the hop gives Changelog a clean page, the finish included), then open the Changelog skill (`skillFile`, or `~/.agents/skills/plan2code-changelog/SKILL.md`) with your file-read tool and follow it from the top (`notes/changelog.md`). Its "Commit this now?" yes carries on to Git. Leave the commit command you printed in the finish where it is for the terminal. |
|
||||
| An action `{ "i": "__launch", "type": "launch", "skill": ..., "workflow": ..., "spec": ... }` | Continue here: the same hop as a dashboard pick (`console-launches.md` → A pick). Run the `resume` it carries (the hop gives the next skill a clean page, the finish included), read its `skillFile` with your file-read tool (never a skill-invocation tool), and follow it from the top in this same conversation. No `stop`. A hop into a different skill gives it a clean page, the finish included; when the `resume` keeps your own workflow (a phase finish whose next step is the same Implement), nothing clears the page, so your first post of the new run carries `"finish": null`. |
|
||||
| An action `__review` or `__done` | As `building-review.md` says (quick task only). |
|
||||
| An action `{ "i": "__commit", "type": "commit" }` | Commit it now: run the `resume` it carries (`open --resume <sid> --no-open --workflow git`; no `finish`, no `stop`; the resume gives Git a clean page, the finish included, as a dashboard launch does), then open the Git skill (`skillFile`, or `~/.agents/skills/plan2code-git/SKILL.md`) with your file-read tool and follow it, starting with the commit flow over the board (the person pressed Commit it now), then the board with Push lit. Leave the commit command you printed in the finish where it is for the terminal. |
|
||||
| `wait` exit `20` | The server is gone. `open --resume <sid> --workflow <yours>` (it gets a new link: give it to them; the browser opens it), then keep waiting: their Ask messages and the dashboard button still need you. Give up only when the resume itself fails. |
|
||||
|
||||
@@ -19,5 +19,9 @@ the card, resume as `git` (`open --resume <sid> --no-open --workflow git`),
|
||||
then read `~/.agents/skills/plan2code-git/SKILL.md` with your file-read tool
|
||||
and start with its commit flow, in this same session, as a dashboard launch
|
||||
does (`console-launches.md`); the resume clears Changelog's page for it.
|
||||
Entered from **Update CHANGELOG first** on a finished Quick Task or Finalize
|
||||
(`console-finish.md`): the hop is the same as a dashboard launch, and nothing
|
||||
else changes. The yes above is the exit to Git as always, so the person lands in
|
||||
the commit flow with the CHANGELOG already updated.
|
||||
Finish, on a no: `"dashboard": true` and the version and entries in `body`,
|
||||
with no `command`. A stop's finish is the bare `/plan2code-changelog`.
|
||||
@@ -27,6 +27,8 @@ summary write — so a stop's finish just says where it paused and uses
|
||||
the finish's `command` is the suggested commit when Step 4 doc updates landed
|
||||
(with `"where": "When you are happy with it, commit it from your terminal:"`), otherwise leave `command` out.
|
||||
When the finish prints that suggested commit, it also carries `"commit": true`,
|
||||
so the finished screen offers **Commit it now** (`console-finish.md`). The
|
||||
so the finished screen offers **Commit it now** (`console-finish.md`), and
|
||||
`"changelog": true` beside it, for **Update CHANGELOG first** (it hops into
|
||||
Changelog and on to Git). Both only when the finish prints a commit. The
|
||||
completion summary is printed to a terminal the browser user is not watching,
|
||||
so put it in `finish.body`.
|
||||
@@ -90,7 +90,8 @@ Workflow notes for `quick-task`, part of the web console contract
|
||||
`"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 — `"commit": true` (the **Commit it now** button;
|
||||
`console-finish.md`) and `"dashboard": true`, so the finished screen
|
||||
`console-finish.md`), `"changelog": true` (**Update CHANGELOG first**, beside
|
||||
it; it hops into Changelog and on to Git) 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 `building-review.md`.
|
||||
|
||||
@@ -712,6 +712,15 @@ export function validate(state) {
|
||||
if (fin.commit != null && typeof fin.commit !== "boolean") {
|
||||
problems.push('"finish.commit" must be true or false (or left out: no commit button)');
|
||||
}
|
||||
// (The pause test is the page's finishPaused() in public/answers.js: keep them in step.)
|
||||
// Update CHANGELOG first: only the builds that end on a commit and have
|
||||
// no sign-off to put it on. An implementation phase never offers it. A
|
||||
// pause ignores it.
|
||||
if (fin.changelog != null && typeof fin.changelog !== "boolean") {
|
||||
problems.push('"finish.changelog" must be true or false (or left out: no changelog button)');
|
||||
} else if (fin.changelog === true && !/^\s*paused\b/i.test(String(fin.headline || "")) && !["quick-task", "finalize"].includes(state.workflow)) {
|
||||
problems.push('"finish.changelog" is only for a finished quick-task or finalize');
|
||||
}
|
||||
// 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.
|
||||
|
||||
@@ -434,6 +434,7 @@ export const REVIEW_REPLY =
|
||||
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: open Git's commit flow, right here in this session.";
|
||||
export const CHANGELOG_REPLY = "Update the CHANGELOG before I commit: open Changelog, 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.
|
||||
@@ -459,6 +460,42 @@ export function commitOffer(fin) {
|
||||
return Boolean(fin && fin.commit === true && !finishPaused(fin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a finish offers to update the CHANGELOG before the commit. The agent
|
||||
* opts in with `finish.changelog: true` on a finished quick task or finalize;
|
||||
* the press opens Changelog in the same session, whose "Commit this now?" yes
|
||||
* carries on to Git. A pause never offers it.
|
||||
*/
|
||||
export function changelogOffer(fin) {
|
||||
return Boolean(fin && fin.changelog === true && !finishPaused(fin));
|
||||
}
|
||||
|
||||
/**
|
||||
* The skill a finish's next step names, when it is one the page can start in
|
||||
* this session: `{ skill, workflow, spec }`, or null. The agent writes nothing
|
||||
* new for it. The command's leading `/plan2code-...` is looked up in skills.js
|
||||
* (a trailing `--web` and any other argument are ignored), and `spec` is the
|
||||
* `specs/<name>` folder the command mentions, when it does. A pause, the
|
||||
* dashboard's own `/plan2code` and any command that is not a skill (a git
|
||||
* commit) offer nothing.
|
||||
*/
|
||||
export function continueOffer(fin) {
|
||||
if (!fin || finishPaused(fin)) return null;
|
||||
const first = String(fin.command || "").trim().split(/\s+/)[0];
|
||||
if (!first.startsWith("/")) return null;
|
||||
const entry = skillByName(first.slice(1));
|
||||
if (!entry || entry.workflow === "dashboard") return null;
|
||||
const match = /(?:^|[\s"'])(specs\/[A-Za-z0-9][A-Za-z0-9._-]*)(?=[/\s"']|$)/.exec(String(fin.command));
|
||||
return { skill: entry.skill, workflow: entry.workflow, spec: match ? match[1] : undefined };
|
||||
}
|
||||
|
||||
/** What Continue here reaches the agent as: a launch's sentence, naming the skill. */
|
||||
export function continueReply(offer) {
|
||||
const entry = SKILLS.find((s) => s.skill === offer.skill);
|
||||
const card = entry && entry.card ? entry.card.title : entry ? entry.name : offer.skill;
|
||||
return launchReply({ title: card, command: entry ? entry.command : `/${offer.skill}` }, offer.spec ? { dir: offer.spec } : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -473,7 +510,7 @@ export function reviewOffer(fin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* One offer button on a finish (review, done, commit, dashboard). A press of
|
||||
* One offer button on a finish (review, done, commit, changelog, dashboard, launch). A press of
|
||||
* any of them is the session's one answer, so it locks every button until the
|
||||
* finish goes away, not just until the agent collects the send: `asked` is
|
||||
* the pressed one, which keeps its "requested…" label.
|
||||
|
||||
@@ -14,10 +14,17 @@
|
||||
// - Git counts as a launch from anywhere: Commit it now on a finished
|
||||
// screen and Changelog's "Commit this now?" both stand in for its
|
||||
// dashboard card, and a finish left behind would keep the page on the old
|
||||
// ending above the new board.
|
||||
// ending above the new board;
|
||||
// - a launch from a finished screen (Continue here, Update CHANGELOG first)
|
||||
// goes from one skill into another and gets a clean page too, since the
|
||||
// finish it leaves behind would keep the page on the old ending. Two
|
||||
// pairs are not that: out of Git (its board hops into Changelog on its
|
||||
// own and keeps its state) and into Review (a skill's review runs inline
|
||||
// and never switches workflow).
|
||||
// A skill run inline from another (a quick task's review) never switches
|
||||
// workflow, so it keeps the page; nor does a resume into the same workflow.
|
||||
export function startsClean(from, to) {
|
||||
if (typeof from !== "string" || typeof to !== "string" || !from || !to || from === to) return false;
|
||||
return from === "dashboard" || to === "dashboard" || to === "git";
|
||||
if (from === "dashboard" || to === "dashboard" || to === "git") return true;
|
||||
return from !== "git" && to !== "review";
|
||||
}
|
||||
@@ -217,12 +217,13 @@
|
||||
<!-- Notepad: every screen, never hidden. The person's private notes for this
|
||||
folder; nothing in it reaches the agent. -->
|
||||
<button type="button" class="btn ghost small notepad-btn" id="btn-notepad" title="Notepad" aria-label="Notepad">
|
||||
<!-- A notepad: a page bound at the top by three rings, with three lines. -->
|
||||
<!-- A pocket notebook: a closed cover with a spine line and an elastic band. -->
|
||||
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
||||
<rect class="np-page" x="3" y="2.5" width="10" height="12" rx="1.3" />
|
||||
<path class="np-ring" d="M5.5 1.2v2.6M8 1.2v2.6M10.5 1.2v2.6" />
|
||||
<path class="np-line" d="M5.5 7h5M5.5 9.5h5M5.5 12h3.2" />
|
||||
<rect class="np-page" x="3.5" y="1.8" width="9" height="12.4" rx="1.3" />
|
||||
<path class="np-line" d="M10.2 1.8v12.4" />
|
||||
<rect class="np-band" x="9.4" y="6.5" width="1.6" height="3" rx=".5" />
|
||||
</svg>
|
||||
<span class="notepad-label">Notepad</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="views-group">
|
||||
@@ -1175,8 +1176,8 @@
|
||||
</ul>
|
||||
<h4>Your notepad</h4>
|
||||
<p>
|
||||
The <strong>Notepad</strong> button, a page with three rings at the
|
||||
top, sits beside Stop session on every screen. It opens a notepad of
|
||||
The <strong>Notepad</strong> button, a small notebook with an elastic
|
||||
band, sits beside Stop session on every screen. It opens a notepad of
|
||||
your own for this folder, somewhere to jot things down as you go.
|
||||
</p>
|
||||
<ul>
|
||||
@@ -2059,6 +2060,14 @@
|
||||
it is on), and the work carries on meanwhile. Asking never holds up
|
||||
your answers to the cards, and sending those never holds up a question.
|
||||
</p>
|
||||
<h4>Prompts to carry away</h4>
|
||||
<p>
|
||||
When what you ask is really a new task, or you ask for a prompt,
|
||||
the answer ends with a ready-to-paste prompt in a box with a
|
||||
<strong>Copy</strong> button. Copy it into a new conversation: it
|
||||
names the skill to use and the files to read, so nothing said here
|
||||
needs repeating.
|
||||
</p>
|
||||
<h4>What it is about</h4>
|
||||
<p>
|
||||
The box starts with no context, so a question is a general one unless
|
||||
@@ -2225,6 +2234,22 @@
|
||||
After a long step, a new conversation is the better choice anyway: it
|
||||
starts with a clean slate.
|
||||
</p>
|
||||
<h4>Update CHANGELOG first</h4>
|
||||
<p>
|
||||
A finished quick task or finalize that ends on a commit can also show
|
||||
<strong>Update CHANGELOG first</strong> beside <strong>Commit it
|
||||
now</strong>. It opens Changelog right here; when Changelog asks
|
||||
"Commit this now?" and you say yes, it carries on to Git.
|
||||
</p>
|
||||
<h4>Continue here</h4>
|
||||
<p>
|
||||
When the next step is another Plan2Code step, the Next step block also
|
||||
has a <strong>Continue here</strong> button. It starts that step in
|
||||
this same conversation, the way a dashboard card would, with this page
|
||||
turning into the new step. It goes away once the session meter is red,
|
||||
because a long conversation is the reason to start a fresh one: copy
|
||||
the command above into a new conversation instead.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Tab 17: Keyboard and preferences -->
|
||||
@@ -2561,7 +2586,7 @@
|
||||
the editor on open. -->
|
||||
<dialog class="modal notepad" id="notepad-modal" aria-labelledby="notepad-title">
|
||||
<h2 id="notepad-title">Notepad</h2>
|
||||
<p class="modal-blurb">Private to this machine and this folder. Never sent to Plan2Code.</p>
|
||||
<p class="modal-blurb">A private space to keep track of notes, uploaded images related to your in-progress work on this project. Saved on this machine and never shared to the AI Agent.</p>
|
||||
<div class="notepad-editor" id="notepad-editor"></div>
|
||||
<div class="notepad-images" id="notepad-images">
|
||||
<button type="button" class="btn small ghost notepad-add" id="notepad-add">Add image</button>
|
||||
|
||||
@@ -1061,6 +1061,8 @@ export function renderStatus() {
|
||||
// there to take the press.
|
||||
if (page.local.afterBuild === "dashboard" && !page.gone) return say("work", "Opening the dashboard…", "", true);
|
||||
if (page.local.afterBuild === "commit" && !page.gone) return say("work", "Opening Git…", "", true);
|
||||
if (page.local.afterBuild === "changelog" && !page.gone) return say("work", "Opening Changelog…", "", true);
|
||||
if (page.local.afterBuild === "launch" && !page.gone) return say("work", "Starting the next step…", "", true);
|
||||
const offer = reviewPending();
|
||||
if (dashboardLive(finish()) && !page.gone && !offer) {
|
||||
return say("point", "Done. Head back to the dashboard, or close this tab.");
|
||||
|
||||
@@ -5,6 +5,9 @@ import {
|
||||
finishPaused,
|
||||
reviewOffer,
|
||||
commitOffer,
|
||||
changelogOffer,
|
||||
continueOffer,
|
||||
continueReply,
|
||||
handoffShape,
|
||||
ALL_DONE_LEAD,
|
||||
ALL_DONE_REST,
|
||||
@@ -23,6 +26,7 @@ import {
|
||||
DONE_REPLY,
|
||||
DASHBOARD_REPLY,
|
||||
COMMIT_REPLY,
|
||||
CHANGELOG_REPLY,
|
||||
} from "../answers.js";
|
||||
import { hooks, page, saveNow, redraw } from "../state.js";
|
||||
|
||||
@@ -120,11 +124,11 @@ function renderCloseGuide(shape, fin = {}) {
|
||||
return panel;
|
||||
}
|
||||
|
||||
// A review, a commit in Git or the dashboard the person just asked for is starting
|
||||
// A review, a commit in Git, the dashboard or the next step the person just asked for is starting
|
||||
// here, so the page is about to carry on rather than end.
|
||||
function closeGuideHeld() {
|
||||
if (page.gone) return false;
|
||||
return ["review", "commit", "dashboard"].includes(page.local.afterBuild) || reviewPending() === "asked";
|
||||
return ["review", "commit", "changelog", "dashboard", "launch"].includes(page.local.afterBuild) || reviewPending() === "asked";
|
||||
}
|
||||
|
||||
export function renderHandoff(fin) {
|
||||
@@ -136,7 +140,7 @@ export 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 && !["done", "dashboard", "commit"].includes(page.local.afterBuild)) {
|
||||
if (offer && !["done", "dashboard", "commit", "changelog", "launch"].includes(page.local.afterBuild)) {
|
||||
card.appendChild(renderReviewOffer(offer));
|
||||
}
|
||||
|
||||
@@ -145,6 +149,11 @@ export function renderHandoff(fin) {
|
||||
card.appendChild(renderCommitOffer());
|
||||
}
|
||||
|
||||
// Beside it: the CHANGELOG first, which hops into Changelog and on to Git.
|
||||
if (changelogOffer(fin) && !page.gone && page.local.afterBuild !== "done" && page.local.afterBuild !== "dashboard") {
|
||||
card.appendChild(renderChangelogOffer());
|
||||
}
|
||||
|
||||
// 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.
|
||||
@@ -186,6 +195,8 @@ export function renderHandoff(fin) {
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
step.appendChild(row);
|
||||
const next = continueOffer(fin);
|
||||
if (next && continueLive()) step.appendChild(renderContinueOffer(next));
|
||||
if (text !== command) {
|
||||
step.appendChild(
|
||||
el(
|
||||
@@ -355,6 +366,55 @@ function renderCommitOffer() {
|
||||
return box;
|
||||
}
|
||||
|
||||
// Continue here shows while there is a server to carry the press, the person
|
||||
// has not already answered the finish another way, and the session is not red:
|
||||
// at red the agent may start missing things, so the fresh-session advice stands
|
||||
// alone (and this stays true to the meter pill, which reads the same frame).
|
||||
function continueLive() {
|
||||
if (page.gone || ["done", "dashboard"].includes(page.local.afterBuild)) return false;
|
||||
return !(page.meterFrame && page.meterFrame.level === "red");
|
||||
}
|
||||
|
||||
// Start the next step right here, as a dashboard click would: the same
|
||||
// session, resumed under that skill. The command above stays for a new
|
||||
// conversation.
|
||||
function renderContinueOffer(next) {
|
||||
const box = el("div", "continue-offer");
|
||||
const { asked, disabled } = afterFinishButton(page.local.afterBuild, "launch", page.pendingResult);
|
||||
const go = el("button", "btn primary continue-go", asked ? "Starting the next step…" : "Continue here");
|
||||
go.type = "button";
|
||||
go.disabled = disabled;
|
||||
go.addEventListener("click", () => sendAfterBuild("launch", next));
|
||||
box.appendChild(go);
|
||||
box.appendChild(
|
||||
el("p", "handoff-note", "Starts this step in the same conversation, so it carries everything said here.")
|
||||
);
|
||||
return box;
|
||||
}
|
||||
|
||||
// Update the CHANGELOG before committing: like Commit it now, a request to an
|
||||
// agent still in its wait loop, so only drawn while the server is there.
|
||||
function renderChangelogOffer() {
|
||||
const box = el("section", "review-offer");
|
||||
box.appendChild(el("p", "handoff-label", "Update CHANGELOG first"));
|
||||
box.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"review-offer-text",
|
||||
"Changelog works out the version and the entries for this change, then offers to commit. It opens right here."
|
||||
)
|
||||
);
|
||||
const { asked, disabled } = afterFinishButton(page.local.afterBuild, "changelog", page.pendingResult);
|
||||
const row = el("div", "btn-row");
|
||||
const go = el("button", "btn", asked ? "Opening Changelog…" : "Update CHANGELOG first");
|
||||
go.type = "button";
|
||||
go.disabled = disabled;
|
||||
go.addEventListener("click", () => sendAfterBuild("changelog"));
|
||||
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
|
||||
@@ -393,18 +453,20 @@ function renderDashboardOffer(primary) {
|
||||
|
||||
// Any answer to a finished session's offers, as one send through the ordinary
|
||||
// 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 };
|
||||
// and `__dashboard` are about the session. Continue here sends the dashboard's
|
||||
// own `__launch` (`launch`: { skill, workflow, spec }), which already makes the
|
||||
// server hand the agent a `resume`.
|
||||
const AFTER_FINISH_REPLIES = { review: REVIEW_REPLY, done: DONE_REPLY, dashboard: DASHBOARD_REPLY, commit: COMMIT_REPLY, changelog: CHANGELOG_REPLY };
|
||||
|
||||
async function sendAfterBuild(kind) {
|
||||
async function sendAfterBuild(kind, launch = null) {
|
||||
if (page.gone || page.pendingResult || page.local.afterBuild) return;
|
||||
try {
|
||||
const res = await fetch("/submit", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
actions: [{ i: `__${kind}`, type: kind }],
|
||||
reply: AFTER_FINISH_REPLIES[kind],
|
||||
actions: [launch ? { i: "__launch", type: "launch", ...launch } : { i: `__${kind}`, type: kind }],
|
||||
reply: launch ? continueReply(launch) : AFTER_FINISH_REPLIES[kind],
|
||||
}),
|
||||
});
|
||||
if (res.status === 409) {
|
||||
@@ -420,6 +482,8 @@ async function sendAfterBuild(kind) {
|
||||
review: "Review requested. It starts here in a moment.",
|
||||
dashboard: "Opening the dashboard. It appears here in a moment.",
|
||||
commit: "Opening Git. It appears here in a moment.",
|
||||
changelog: "Opening Changelog. It appears here in a moment.",
|
||||
launch: "Starting the next step. It appears here in a moment.",
|
||||
}[kind];
|
||||
if (started) {
|
||||
hooks.banner(started, "good");
|
||||
|
||||
@@ -108,7 +108,7 @@ export const selHandoff = () => {
|
||||
// the finish goes away, which is the agent taking the review up.
|
||||
export function reviewPending() {
|
||||
const fin = finish();
|
||||
if (!fin || !reviewOffer(fin) || ["done", "dashboard", "commit"].includes(page.local.afterBuild)) return null;
|
||||
if (!fin || !reviewOffer(fin) || ["done", "dashboard", "commit", "changelog", "launch"].includes(page.local.afterBuild)) return null;
|
||||
if (page.local.afterBuild === "review") return page.gone ? null : "asked";
|
||||
return page.gone ? null : "open";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
export 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", "commit", "done" or "dashboard" once a finished session's
|
||||
// `afterBuild` is "review", "commit", "changelog", "launch", "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
|
||||
|
||||
Reference in new issue
Block a user