mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20: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
@@ -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