Sync upstream into v2.7.0: the git board skill replaces git-commit (ticket-free), and console docs and tests are split up

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-11 16:39:25 -07:00
1 parent 6114914dd6
commit f328406bb5
103 files changed
+17636 -9991

No files matched your search

+61 -24
View File
@@ -40,6 +40,18 @@ export function recordedAnswer(item) {
return { ...(s || {}), ...(a || {}) };
}
/**
* True when the agent wrote in the item's thread after the person's last send
* and has not settled it: the question is being asked again, so what they sent
* belongs back on the form rather than gone.
*/
export function agentRepliedAfterSend(item) {
const s = item && item.submitted;
if (!s || typeof s !== "object" || (item.answer && typeof item.answer === "object")) return false;
const thread = Array.isArray(item.thread) ? item.thread : [];
return thread.some((m) => m && threadWho(m) === "agent" && (!s.at || !m.at || m.at >= s.at));
}
/**
* A send the person made that the agent never settled, still sitting on an
* OPEN question.
@@ -103,10 +115,19 @@ export function threadText(m) {
/* -------------------------------------------------------------- labels */
// A key worth showing: one or two letters or digits (A, 2) a person can say
// back in the terminal. A word key (commit-first, yes) is an id for the agent,
// and as a chip beside its own label it is noise.
export function showKey(k, text) {
if (k == null) return false;
const key = String(k);
return /^[A-Za-z0-9]{1,2}$/.test(key) && key.toLowerCase() !== String(text || "").trim().toLowerCase();
}
export function optionLabel(item, k) {
const o = ((item && item.options) || []).find((x) => x.k === k);
if (!o) return String(k);
return o.k ? `${o.k} · ${o.text}` : o.text;
return showKey(o.k, o.text) ? `${o.k} · ${o.text}` : o.text;
}
export function verdictLabel(item, id) {
@@ -247,7 +268,7 @@ export const WORKFLOW_LABEL = {
"quick-task": "Quick task",
finalize: "Wrapping up",
handoff: "Handoff",
"git-commit": "Git commit",
git: "Git",
changelog: "Changelog",
};
@@ -273,7 +294,7 @@ export const CONSOLE_WORKFLOWS = [
"/plan2code-review",
"/plan2code-4-finalize",
"/plan2code-handoff",
"/plan2code-git-commit",
"/plan2code-git",
"/plan2code-changelog",
];
@@ -383,14 +404,16 @@ const HOME_TITLES = {
* adrift: then it comes back, and a second press is safe because the server
* refuses a duplicate while the first is uncollected.
*/
export function homeButtonState({ workflow, finished = false, stopping = false, homeward = false, adrift = false, ...turn } = {}) {
export function homeButtonState({ workflow, finished = false, stopping = false, homeward = false, adrift = false, warned = false, ...turn } = {}) {
if (!workflow || workflow === "dashboard" || finished || stopping) return { hidden: true, disabled: true, title: "" };
if (homeward && !adrift) return { hidden: false, disabled: true, title: "Opening the dashboard…" };
const gate = turnGate(turn);
return {
hidden: false,
disabled: Boolean(gate),
title: gate ? HOME_TITLES[gate] : "Back to the dashboard. Your place is saved first.",
// With a stop warning up, the work since the last save is what leaving
// loses: the tooltip says so rather than promising a saved place.
title: gate ? HOME_TITLES[gate] : warned ? "Back to the dashboard. Work since the last save is not kept." : "Back to the dashboard. Your place is saved first.",
};
}
@@ -438,8 +461,8 @@ export function resumeCommand({ workflow, specDir } = {}) {
return withOverview("/plan2code-4-finalize");
case "handoff":
return "/plan2code-handoff";
case "git-commit":
return "/plan2code-git-commit";
case "git":
return "/plan2code-git";
case "changelog":
return "/plan2code-changelog";
default:
@@ -456,7 +479,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.";
export const COMMIT_REPLY = "Commit what was just built: open Git's commit flow, 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.
@@ -475,7 +498,7 @@ export function dashboardOffer(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
* command; the press starts Git's commit flow in the same session, as the dashboard's
* card does. A pause never offers it.
*/
export function commitOffer(fin) {
@@ -495,6 +518,16 @@ export function reviewOffer(fin) {
return { label: label || "Review what was just built" };
}
/**
* One offer button on a finish (review, done, commit, dashboard). 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.
*/
export function afterFinishButton(afterBuild, kind, pendingResult) {
return { asked: afterBuild === kind, disabled: Boolean(afterBuild) || Boolean(pendingResult) };
}
/* ------------------------------------------------------- the dashboard */
// The skills the dashboard offers, in the order it offers them. The page owns
@@ -666,18 +699,18 @@ export const SKILL_CATALOG = [
title: "Changelog",
blurb: "Checks the CHANGELOG version against the main branch and suggests entries for what is new.",
about:
"Works out the right version from the default branch, then compares your branch with the latest CHANGELOG entry and suggests the entries it is missing. You edit them before anything is written, it keeps package.json in step, and it offers to run Git commit next. If the newest version is not released or on another branch yet, it adds to that entry instead of starting a new one.",
"Works out the right version from the default branch, then compares your branch with the latest CHANGELOG entry and suggests the entries it is missing. You edit them before anything is written, it keeps package.json in step, and it offers to commit the result in Git. If the newest version is not released or on another branch yet, it adds to that entry instead of starting a new one.",
},
{
skill: "plan2code-git-commit",
command: "/plan2code-git-commit",
workflow: "git-commit",
skill: "plan2code-git",
command: "/plan2code-git",
workflow: "git",
group: "extra",
chip: "Utility",
title: "Git commit",
blurb: "Commits your changes with a clear message, suggests a split when it is really two jobs, and offers to push.",
title: "Git",
blurb: "Branches, pull, push and commits on one board that stays open while you work.",
about:
"Reads what changed and drafts the commit message for you to approve. On the main branch it offers a new one first, and when the work is really two jobs it suggests splitting it into separate commits. It asks before every commit and every push, and never force-pushes.",
"Shows your branch, what is ahead or behind, and every local and remote branch. Switch, create, delete or clean up branches, pull (rebasing when they have split, with help on conflicts), push or publish, and commit with a clear message. It asks before every push, publish and delete, and never force-pushes.",
},
];
@@ -701,7 +734,7 @@ export const START_POSES = [
"quick-task",
"review",
"handoff",
"git-commit",
"git",
"changelog",
];
@@ -743,7 +776,6 @@ 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 });
@@ -775,12 +807,10 @@ export function cardAvailability(entry, scan, sel) {
case "plan2code-handoff":
case "plan2code-changelog":
return ON;
case "plan2code-git-commit":
case "plan2code-git":
// Never greyed: a clean tree still has branches to switch, pull and push.
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) };
}
if (scan && Number.isInteger(scan.pending) && scan.pending > 0) return { on: true, note: pendingNote(scan.pending) };
return ON;
case "plan2code-0-pathfinder":
if (!state || state === "exploring") return { ...ON, next };
@@ -982,6 +1012,13 @@ export function noteAction(id, text, attachments) {
return action;
}
// Typed text past its first line, indented, so only a real entry ever starts a
// reply line: a typed "Idea name: foo" or " Image: C:\x" must not read as an
// answer or an attachment. Chat's lines already do this.
export function indentReply(text, pad = " ") {
return String(text).replace(/\r?\n/g, "\n" + pad);
}
// A note as `reply` lines, one indented `Image:` or `File:` line per
// attachment in the order attached, so the agent can open each path with its
// file-read tool. An image-only note reads exactly as it always did.
@@ -990,7 +1027,7 @@ export function noteReplyLines(title, text, attachments) {
const anyFile = list.some((a) => attachmentKind(a) === "file");
const said = text || (list.length ? (anyFile ? "(attachments only)" : "(images only)") : "");
return [
`Note on ${title}: ${said}`,
`Note on ${title}: ${indentReply(said)}`,
...list.map((a) => ` ${attachmentKind(a) === "file" ? "File" : "Image"}: ${a.path} (${a.name})`),
];
}
+223 -28
View File
@@ -303,6 +303,12 @@ h1 {
.progress-block { flex: 1 1 260px; min-width: 200px; max-width: 460px; margin-left: auto; }
/* When the progress block is hidden (the dashboard, the git board) nothing
grows to fill the row, so the icon buttons would sit beside the title. The
first takes the slack instead; with the block shown its flex already eats
the space, so this costs nothing. */
#btn-about { margin-left: auto; }
.progress-label {
display: flex;
justify-content: space-between;
@@ -690,13 +696,13 @@ h1 {
}
.wake.dormant .wake-hint { opacity: 1; }
/* Skip: muted, bottom right, so it never competes with the animation. */
/* Skip: bottom right, out of the animation's way but big enough to find. */
.wake-skip {
position: absolute; right: 14px; bottom: 14px;
padding: 4px 12px; border: 1px solid var(--ink-3); border-radius: 4px;
background: transparent; color: var(--ink-3);
font: inherit; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
cursor: pointer; opacity: 0.7;
position: absolute; right: 24px; bottom: 24px;
min-width: 120px; padding: 10px 26px; border: 1.5px solid var(--ink-2); border-radius: 6px;
background: var(--panel-2); color: var(--ink-2);
font: inherit; font-size: 1rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
cursor: pointer; opacity: 0.9;
}
.wake-skip:hover, .wake-skip:focus-visible { opacity: 1; color: var(--ink); border-color: var(--ink); }
@@ -878,6 +884,11 @@ h1 {
padding: 6px 13px;
border-radius: 99px;
cursor: pointer;
/* A doc titled with a sentence keeps the tab row to one line. */
max-width: 22ch;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.view-tab:hover { background: var(--panel-2); color: var(--ink); }
.view-tab[aria-current="true"] {
@@ -947,12 +958,20 @@ h1 {
padding-right: 32px;
}
/* The column itself never scrolls; the card does. */
/* The column itself never scrolls; the card does. The git board is the one
exception, below: it stacks a card over the board, so the column takes the
scroll there and both flow through it at natural height. */
.main > .card:not(.is-primary) { flex-shrink: 100; min-height: 104px; }
.main > .card.is-primary { flex-shrink: 1; min-height: 0; }
/* A card with a growing answer box takes the column's full height above the
pager, and still scrolls its own contents. app.js sizes the box to fill it. */
.main > .card.is-primary.has-grow { flex: 1 1 auto; }
/* More below the fold (app.js markMore): the bottom edge fades, so a card
cut by the window never reads as finished. */
.main > .card.has-more {
-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 56px), transparent);
mask-image: linear-gradient(to bottom, #000 calc(100% - 56px), transparent);
}
.pager { flex: none; }
/* A document is read top to bottom and has no pinned furniture, so it goes back
@@ -1069,7 +1088,7 @@ h1 {
}
.ask-about-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-about-chip .attach-remove { position: static; flex: none; }
.ask-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ask-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
/* + Add context and its menu. It opens upward, over the list: the composer
sits at the bottom of a pane that clips anything hanging below it. */
.ask-context { position: relative; }
@@ -1754,6 +1773,7 @@ input[type="text"].invalid { border-color: var(--warn); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.danger { border-color: var(--warn); color: var(--warn); }
.btn.danger.is-on { background: var(--warn); color: #fff; }
.btn.small { padding: 7px 13px; font-size: 13.5px; }
/* Available, but not the step. Reads as a button, does not shout like one. */
.btn.standby {
@@ -1954,7 +1974,10 @@ input[type="text"].invalid { border-color: var(--warn); }
/* ----------------------------------------------------------- markdown */
.md { max-width: 68ch; }
/* A word or path longer than the line breaks instead of widening the page;
code blocks and tables keep their own scroll. */
.md { max-width: 68ch; overflow-wrap: anywhere; }
.md pre, .md .md-table { overflow-wrap: normal; }
.md-h { font-family: var(--serif); font-weight: 600; margin: 22px 0 9px; line-height: 1.25; }
h2.md-h { font-size: 21px; }
h3.md-h { font-size: 17.5px; }
@@ -1964,9 +1987,12 @@ h4.md-h, h5.md-h, h6.md-h { font-size: 15px; }
.md-li { margin-bottom: 5px; }
.md-task { display: inline-block; width: 16px; color: var(--ink-3); font-weight: 700; }
.md-task.is-done { color: var(--ok); }
.md-task.is-blocked { color: var(--warn); }
.md-task.is-doing { color: var(--accent); }
.md-task.is-assumed { color: var(--stage); }
.md-li.is-task {
list-style: none; margin-left: -18px;
display: grid; grid-template-columns: 16px 1fr; column-gap: 4px; align-items: baseline;
display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 4px; align-items: baseline;
}
.md-li.is-task > :not(.md-task) { grid-column: 2; }
.md-li.is-task > .md-p:last-child { margin-bottom: 0; }
@@ -2000,23 +2026,17 @@ h4.md-h, h5.md-h, h6.md-h { font-size: 15px; }
transition: opacity 0.12s;
}
.md-pre-wrap:hover .md-copy, .md-copy:focus { opacity: 1; }
/* Run it, on git blocks: Copy's twin, tucked under it so the wider
"Press Ctrl+C" fallback label can never collide. */
.md-run {
position: absolute; top: 34px; right: 8px;
font: 600 11.5px var(--sans);
background: var(--panel); color: var(--ink-2);
border: 1px solid var(--rule-2); border-radius: 6px;
padding: 4px 9px; cursor: pointer; opacity: 0;
transition: opacity 0.12s;
}
.md-pre-wrap:hover .md-run, .md-run:focus { opacity: 1; }
/* The muted nudge on other command-looking blocks, a caption under the block. */
/* The muted nudge on command-looking blocks, a caption under the block. */
.md-run-hint {
margin: -6px 2px 0;
margin: 4px 2px 0;
font: 11px var(--sans); color: var(--ink-3);
opacity: 0.8;
}
/* No "paste it into the Ask tab" nudge where the command is the card's own
action (a confirm's consequences, a finished screen's commit beside its
Commit it now button). */
.is-consequences .md-run-hint,
.handoff .md-run-hint { display: none; }
.md-hr { border: 0; border-top: 1px solid var(--rule); margin: 20px 0; }
.md-table-wrap { overflow-x: auto; margin: 0 0 13px; }
.md-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
@@ -2065,6 +2085,7 @@ h4.md-h, h5.md-h, h6.md-h { font-size: 15px; }
.footer.is-dash .footer-summary,
.footer.is-dash .footer-actions { display: none; }
.footer.is-dash .footer-where { grid-column: 2; }
.footer.is-dash-done .footer-actions { display: none; }
.hint { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 7px; }
/* A label, not a sentence: the full reason rides in the hint's tooltip, and
the dock already carries the ticking clock this would otherwise repeat. */
@@ -2165,6 +2186,9 @@ button.waiting-jump:hover { text-decoration-color: var(--accent); }
.icon-btn:hover .ab-dot { fill: var(--accent); }
a.icon-btn { box-sizing: border-box; text-decoration: none; }
/* A link in a dialog (the update modal's release, Help's version) keeps the
accent once visited: the browser's purple is unreadable on the dark theme. */
.modal a:not(.btn), .modal a:not(.btn):visited { color: var(--accent); }
.icon-btn .mg-body { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linejoin: round; }
.icon-btn .mg-line { fill: none; stroke: var(--ink-2); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover .mg-body, .icon-btn:hover .mg-line { stroke: var(--accent); }
@@ -2629,6 +2653,14 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
@media (max-width: 720px) {
.looks-row { grid-template-columns: 1fr; }
}
/* User Preferences itself (not the dialogs borrowing .looks): wider, and only
the body scrolls, so Back to default and Done never leave the screen. */
.modal.prefs { max-width: 880px; }
.modal.prefs[open] { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.prefs-body { overflow-y: auto; min-height: 0; flex: 1 1 auto; margin-right: -12px; padding-right: 12px; padding-top: 10px; }
/* A line scrolled up under the title fades out rather than being sliced. */
.prefs-body { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px); mask-image: linear-gradient(to bottom, transparent 0, #000 12px); }
.modal.prefs .modal-actions { flex: none; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
/* The Workspace dialog: one entry per folder, the original first, then the
Add row. Wide enough for a real path; the list scrolls, the Add row and the
@@ -2972,13 +3004,14 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
padding-top: 10px;
border-top: 1px solid var(--rule);
}
/* Wraps at the dashes rather than cut off: a command missing its end
("/plan2code-3-implement-revi…") is no command at all. */
.dash-card-cmd {
font-family: var(--mono);
font-size: 11.5px;
color: var(--ink-3);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
overflow-wrap: anywhere;
}
.dash-card-go { color: var(--accent); font-weight: 700; transition: transform 0.15s ease; }
.dash-card:hover:not(:disabled) .dash-card-go { transform: translateX(3px); }
@@ -3474,8 +3507,8 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
100% { transform: translateX(8px); opacity: 0; }
}
/* Git commit -- the arm reaches out and a new commit settles onto the branch
line in step with it. */
/* Git -- the arm reaches out and a new commit settles onto the branch line in
step with it. */
.pose .gc-reach { transform-origin: 0% 50%; animation: gc-reach 2.4s ease-in-out infinite; }
@keyframes gc-reach {
0%, 100% { transform: scaleX(0.9); }
@@ -3616,3 +3649,165 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
}
.status-help:hover { text-decoration-thickness: 2px; }
.status-help:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
/* ------------------------------------------------------------ git board */
/* The git workflow's main column stacks two things where every other view
holds one: the agent's card on top and the board under it. Stacked children
that each scrolled would put a scrollbar inside a scrollbar, so here the
column takes the one scroll and both flow through it at natural height. */
.main:has(> .git-board) {
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
}
/* Listed with .is-primary.has-grow too: that rule (a card with a growing note
box takes the column's height and shrinks into it) outranks a plain .card
here, and a card shrunk under the board spilled its buttons beneath it. */
.main:has(> .git-board) > .card,
.main:has(> .git-board) > .card.is-primary.has-grow,
.main:has(> .git-board) > .git-board {
flex: none;
overflow-y: visible;
min-height: 0;
}
/* Over the board a card's boxes cannot fill the column (it flows, it does not
stretch), so a note box grows with what is typed instead, where the browser
can, rather than scrolling inside a 96px box. */
.main:has(> .git-board) > .card textarea { field-sizing: content; max-height: 50vh; }
.main > .git-board {
padding-right: 32px;
display: grid;
/* minmax(0, …): the column never takes the branch table's no-wrap width. */
grid-template-columns: minmax(0, 1fr);
align-content: start;
gap: 14px;
max-width: var(--card-width);
}
/* The board's header is a section lead, not a second card: the agent's card
above is the column's only framed element. */
.git-head {
display: grid;
gap: 6px;
padding: 0 0 10px;
border-bottom: 1px solid var(--rule);
}
.git-head-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.git-branch { margin: 0; font: 600 22px/1.2 var(--serif); overflow-wrap: anywhere; }
.git-track { font-family: var(--mono); font-size: 14px; color: var(--ink-2); }
.git-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13.5px; color: var(--ink-2); }
.git-noremote { font-weight: 600; color: var(--stage); }
.git-activity { color: var(--accent); }
.git-pr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 6px; border-top: 1px solid var(--rule); }
.git-pr-open { text-decoration: none; }
.git-pr-ask { font-size: 14px; color: var(--ink); }
.git-pr-base { font-size: 13.5px; color: var(--ink-2); }
.git-pr-base select, .git-field select, .git-field input, .git-search {
font: inherit;
font-size: 14px;
padding: 6px 10px;
color: var(--ink);
background: var(--panel);
border: 1px solid var(--rule-2);
border-radius: 8px;
}
.git-warn, .git-op {
padding: 12px 16px;
border: 1px solid var(--warn);
border-left-width: 4px;
border-radius: var(--radius);
background: var(--warn-soft);
color: var(--ink);
}
.git-op { display: grid; gap: 8px; border-color: var(--stage); background: var(--stage-soft); }
.git-op-files { margin: 0; padding-left: 20px; font-size: 13.5px; }
.git-op-left { color: var(--warn); }
.git-op-clear { color: var(--ok); }
.git-op-actions, .git-panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.git-note { margin: 0; color: var(--ink-2); }
.git-result {
padding: 10px 16px;
border: 1px solid var(--accent-line);
border-radius: var(--radius);
background: var(--accent-soft);
font-size: 14px;
}
.git-result-body .md-p { margin: 4px 0 0; }
/* The result box is the line length here: git's stderr runs the full width. */
.git-result-body.md { max-width: none; }
/* Pinned to the pane's bottom while the board scrolls past: the column is
the scroller on this view, and the bar is the board's last child, so
bottom: 0 holds it on screen until the board's end comes up to dock it.
Opaque so the table slips underneath, bordered so the seam reads. */
.git-bar {
position: sticky;
bottom: 0;
z-index: 6;
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 10px 0 8px;
background: var(--bg);
border-top: 1px solid var(--rule);
}
.git-done { margin-left: auto; }
.git-panel {
display: grid;
gap: 10px;
padding: 14px 18px;
background: var(--panel);
border: 1px solid var(--accent-line);
border-radius: var(--radius);
}
.git-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.git-panel-title { margin: 0; font-size: 16px; }
.git-group-title { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); }
.git-field-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.git-field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.git-field.is-wide { flex: 1 1 16em; }
.git-new-name { font-family: var(--mono); }
.git-name-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; color: var(--ink-2); }
.git-name-status.is-free { color: var(--ok); }
.git-name-status.is-invalid, .git-name-status.is-nested { color: var(--warn); }
.git-name-status.is-local, .git-name-status.is-remote { color: var(--stage); }
.git-offer { margin: 0 auto 0 0; font-size: 14px; }
.git-sweep { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-family: var(--mono); font-size: 13.5px; }
.git-ignore { margin-left: 8px; white-space: nowrap; }
.git-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.git-search { flex: 1 1 auto; }
.git-branches { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.git-table-wrap { overflow-x: auto; }
.git-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.git-table th {
text-align: left;
font-size: 11.5px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
color: var(--ink-3);
padding: 6px 8px;
border-bottom: 1px solid var(--rule);
}
.git-table td { padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.git-table tr.is-current td { background: var(--accent-soft); }
.git-table tr.is-held td { color: var(--ink-2); }
.git-cell-name { overflow-wrap: anywhere; }
/* A branch name stays whole beside its badges (feature/export-csv never splits
as feature/export- / csv), and the headers stay on one line: a narrow column
scrolls the table sideways instead. */
.git-cell-name .git-name { white-space: nowrap; }
.git-table th { white-space: nowrap; }
.git-name, .git-path { font-family: var(--mono); }
.git-badge { margin-left: 6px; font-size: 10px; padding: 2px 6px; }
.git-badge.is-merged { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
.git-badge.is-gone, .git-badge.is-held { color: var(--stage); background: var(--stage-soft); border-color: var(--stage); }
.git-cell-track { font-family: var(--mono); white-space: nowrap; color: var(--ink-2); }
/* Stacked with blocks, not `display: grid`: a grid <td> stops being a table
cell, and its row's separator no longer lines up with the others. */
.git-cell-last > span { display: block; }
.git-cell-last > .git-by { margin-top: 2px; }
.git-by { font-size: 12px; color: var(--ink-3); }
.git-cell-actions { white-space: nowrap; text-align: right; }
.git-cell-actions .btn + .btn { margin-left: 6px; }
.git-remote-only summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 4px 0; }
.git-empty { margin: 0; font-size: 13.5px; color: var(--ink-3); }
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -31,7 +31,7 @@ function answeredFlags(messages) {
for (let i = messages.length - 1; i >= 0; i--) {
const m = messages[i];
if (m.from === "agent") replyLater = true;
else if (m.kind === "message") flags.set(m.seq, replyLater);
else if (m.kind === "message" || m.kind === "decision") flags.set(m.seq, replyLater);
}
return flags;
}
@@ -63,7 +63,7 @@ export function chatView(frameChat, ui = {}) {
decided: decisions.get(m.id) || null,
});
} else if (m.kind === "decision") {
rows.push({ kind: "decision", decision: m.decision, text: m.text || "", re: m.re });
rows.push({ kind: "decision", decision: m.decision, text: m.text || "", re: m.re, done: Boolean(answered.get(m.seq)) });
} else if (m.kind === "message") {
const row = {
kind: "person",
+382
View File
@@ -0,0 +1,382 @@
// Plan2Code Web Console - the git board's rules: branch order, names, buttons and replies.
//
// Everything the board decides from a state.git snapshot (git-repo.mjs ->
// snapshot()) lives here so it is tested without a browser: how the branch
// list is ordered and folded, whether a new branch name is free, which action
// buttons show and which are enabled, the plain sentence each button sends
// the agent, the "Last refreshed" line, which files start ticked in the
// commit dialog and the pull-request link. app.js only renders what these
// say. No DOM access at module scope and only one import: the page and
// `node --test` both import this file.
import { prUrl } from "./pr-url.js";
export const BRANCH_TYPES = Object.freeze(["feature", "fix", "chore", "docs", "refactor", "test"]);
export const REMOTE_FOLD = 50;
// Matches under a search are capped too, or one fold draws thousands of rows.
const QUERY_CAP = 200;
export const UNTRACKED_TICK_LIMIT = 200;
export const PR_HOST_LABELS = Object.freeze({
github: "GitHub",
gitlab: "GitLab",
bitbucket: "Bitbucket",
azure: "Azure DevOps",
none: "None",
});
const list = (v) => (Array.isArray(v) ? v : []);
const blank = (v) => typeof v !== "string" || v.trim() === "";
// Milliseconds of a row's last commit; -Infinity when missing or unreadable, so it sorts last.
function lastTime(row) {
const t = Date.parse(row && row.last && row.last.at);
return Number.isNaN(t) ? -Infinity : t;
}
const newestFirst = (a, b) => {
const ta = lastTime(a);
const tb = lastTime(b);
if (ta === tb) return 0;
return tb > ta ? 1 : -1;
};
/** The local row for the checked-out branch, or null. */
export function currentRow(git) {
return list(git && git.branches).find((b) => b && b.current && !b.remote) || null;
}
/* ------------------------------------------------------------ branches */
/**
* `{ top, remoteOnly }`: local rows with the current branch first, then the
* default branch (once, when it is also the current one), then the rest by
* last commit, newest first; remote-only rows newest first. Never mutates.
*/
export function orderBranches(branches) {
const rows = list(branches).filter(Boolean);
const local = rows.filter((b) => !b.remote);
const current = local.find((b) => b.current) || null;
const def = local.find((b) => b.default && b !== current) || null;
const rest = local.filter((b) => b !== current && b !== def).sort(newestFirst);
const top = [...(current ? [current] : []), ...(def ? [def] : []), ...rest];
const remoteOnly = rows.filter((b) => b.remote).sort(newestFirst);
return { top, remoteOnly };
}
/** Rows whose name, `remote/name` (remote-only rows) or last subject contain `query`, ignoring case. */
export function filterBranches(rows, query) {
if (blank(query)) return rows;
const q = query.trim().toLowerCase();
return list(rows).filter((b) => {
const fields = [b.name, b.remote ? `${b.remote}/${b.name}` : "", b.last && b.last.subject];
return fields.some((f) => typeof f === "string" && f.toLowerCase().includes(q));
});
}
/**
* The remote-only section: `{ shown, hidden, open }`. Without a query the
* first REMOTE_FOLD rows show (all with showAll) and `hidden` counts the
* rest; a query shows every match and opens the section.
*/
export function foldRemote(rows, { showAll = false, query = "" } = {}) {
const all = list(rows);
if (!blank(query)) {
// A query also caps what it draws: a monorepo remote can match thousands.
const matches = filterBranches(all, query);
const shown = showAll ? matches : matches.slice(0, QUERY_CAP);
return { shown, hidden: matches.length - shown.length, open: true };
}
const shown = showAll ? all.slice() : all.slice(0, REMOTE_FOLD);
return { shown, hidden: all.length - shown.length, open: false };
}
/* ---------------------------------------------------------- new branch */
/** `<type>/<desc>`; "" with no description. */
export function composeBranchName({ type, description } = {}) {
const kind = blank(type) ? "feature" : type.trim();
const desc = String(description || "")
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
return desc ? `${kind}/${desc}` : "";
}
// The first rule `git check-ref-format --branch` would break, as a sentence; null when none.
function refFormatProblem(name) {
if (name === "@") return 'A branch cannot be named just "@".';
// git refuses it as a branch name (git switch -c HEAD), as branch-check does.
if (name === "HEAD") return 'A branch cannot be named "HEAD".';
if (name.startsWith("-")) return "Branch names cannot start with a dash.";
if (name.includes(" ")) return "Branch names cannot contain spaces.";
if (name.includes("..")) return 'Branch names cannot contain "..".';
if (name.includes("@{")) return 'Branch names cannot contain "@{".';
if (name.includes("\\")) return "Branch names cannot contain a backslash.";
const special = name.match(/[~^:?*[]/);
if (special) return `Branch names cannot contain "${special[0]}".`;
if ([...name].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)) {
return "Branch names cannot contain control characters.";
}
if (name.endsWith("/")) return 'Branch names cannot end with "/".';
if (name.endsWith(".")) return 'Branch names cannot end with ".".';
const parts = name.split("/");
if (parts.some((p) => p === "")) return 'Branch names cannot start with "/" or contain "//".';
if (parts.some((p) => p.startsWith("."))) return 'No part of a branch name can start with ".".';
if (parts.some((p) => p.endsWith(".lock"))) return 'No part of a branch name can end with ".lock".';
return null;
}
/**
* Whether `name` can be created: the first of empty, invalid (with a
* reason), local (already a local branch), remote (a remote-only branch),
* nested (it and a local branch would be folders of each other) or free.
*/
export function nameStatus(name, git) {
if (blank(name)) return { kind: "empty" };
const reason = refFormatProblem(name);
if (reason) return { kind: "invalid", reason };
const rows = list(git && git.branches).filter(Boolean);
const locals = rows.filter((b) => !b.remote);
const local = locals.find((b) => b.name === name);
if (local) return { kind: "local", branch: local.name };
// The board shows a remote-only branch as origin/name, so that is taken too.
const remote = rows.find((b) => b.remote && (b.name === name || `${b.remote}/${b.name}` === name));
if (remote) return { kind: "remote", remote: remote.remote, branch: remote.name };
const nested = locals.find((b) => name.startsWith(`${b.name}/`) || b.name.startsWith(`${name}/`));
if (nested) return { kind: "nested", clash: nested.name };
return { kind: "free" };
}
/* ------------------------------------------------------------- buttons */
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
const button = (shown, enabled, label, title) => ({ shown, enabled: shown && enabled, label, ...(title ? { title } : {}) });
/**
* Every board button as `{ shown, enabled, label, title? }`. Pull is enabled
* only with an upstream to pull from; Push shows with an upstream, Publish
* without one. `busy` greys everything out but Done; an operation in
* progress hides everything but Done (its banner carries Abort / Continue).
*/
export function boardActions(git, { busy = false } = {}) {
const g = git || {};
const head = g.head || {};
const changes = g.changes || {};
const count = Number(changes.count) || 0;
const heldBack = Number(changes.heldBack) || 0;
const hasCommits = g.hasCommits !== false;
const hasRemote = list(g.remotes).length > 0;
const detached = hasCommits && !head.branch;
const ahead = Number(head.ahead) || 0;
const free = !busy;
const done = button(true, true, "Done");
const hidden = (label) => button(false, false, label);
if (g.inProgress) {
return {
refresh: hidden("Refresh"),
pull: hidden("Pull"),
push: hidden("Push"),
publish: hidden("Publish"),
commit: hidden("Commit"),
cleanup: hidden("Clean up"),
done,
};
}
const commitLabel = !hasCommits
? "Make the first commit"
: `Commit ${plural(count, "file", "files")}${heldBack > 0 ? ` · ${heldBack} held back` : ""}`;
const commit = button(count > 0, free, commitLabel);
if (!hasCommits) {
return {
refresh: button(true, free, "Refresh", "Look at this folder again"),
pull: hidden("Pull"),
push: hidden("Push"),
publish: hidden("Publish"),
commit,
cleanup: hidden("Clean up"),
done,
};
}
const notOnBranch = "Not on a branch: switch to one first";
// Shown without a remote too: it is how edits made outside reach the board
// (the agent re-reads the folder; with a remote it fetches first).
const refresh = button(true, free, "Refresh", hasRemote ? undefined : "Look at this folder again");
// An upstream whose remote copy was deleted is no upstream: nothing to pull
// from or push to, and Publish (which plan publish allows again) is the way.
const live = Boolean(head.upstream) && !head.gone;
let pull;
if (detached) pull = button(hasRemote, false, "Pull", notOnBranch);
else if (head.upstream && head.gone) pull = button(hasRemote, false, "Pull", "Its remote copy was deleted: publish it again");
else if (!head.upstream) pull = button(hasRemote, false, "Pull", "Nothing to pull from yet: publish first");
else pull = button(hasRemote, free, "Pull");
const showPush = hasRemote && live && !detached;
const push =
ahead > 0
? button(showPush, free, `Push · ${ahead} to push`)
: button(showPush, false, "Push", "Nothing to push");
const showPublish = hasRemote && !live;
const publish = detached ? button(showPublish, false, "Publish", notOnBranch) : button(showPublish, free, "Publish");
const cleanable = list(g.branches).some((b) => b && !b.remote && !b.current && !b.default && (b.merged || b.gone));
const cleanup = button(!!g.defaultBranch && cleanable, free, "Clean up");
return { refresh, pull, push, publish, commit, cleanup, done };
}
/**
* Whether the board is still waiting on the agent: a card send not yet
* settled, or a board click at `sentAt` (ms) with no agent post since
* (`updatedAt`, the state's last post, ISO). Collecting a click takes
* milliseconds, so "uncollected" alone leaves the bar live while the agent
* runs git. An agent gone quiet (`adrift`) releases the lock.
*/
export function boardAwaiting({ sentAt = null, updatedAt = null, cardsAwaiting = 0, adrift = false } = {}) {
if (adrift) return false;
if (cardsAwaiting > 0) return true;
if (!sentAt) return false;
const posted = Date.parse(updatedAt);
return !(posted > sentAt);
}
/* ------------------------------------------------------------- replies */
const names = (v) => list(v).filter((s) => typeof s === "string" && s);
// "these 3 files: a, b, c" or "this file: a".
function filePhrase(files, count) {
const n = Number.isInteger(count) ? count : files.length;
const shown = files.length ? `: ${files.join(", ")}` : "";
return n === 1 ? `this file${shown}` : `these ${n} files${shown}`;
}
/** The plain instruction a board button sends the agent, one sentence per op. */
export function gitReply(op, fields = {}) {
const f = fields || {};
switch (op) {
case "refresh":
return "Refresh.";
case "pull":
return "Pull.";
case "push":
return "Push.";
case "publish":
// No remote named: there are several, and the agent asks which.
return f.remote ? `Publish to ${f.remote}.` : "Publish.";
case "switch":
return `Switch to ${f.branch}.`;
case "create": {
const start = `Create ${f.name} from ${f.from}.`;
if (f.then !== "commit") return start;
const ignore = names(f.ignore);
const tail = ignore.length ? ` Add ${ignore.join(", ")} to .gitignore.` : "";
return `${start} Then commit ${filePhrase(names(f.files), f.count)}.${tail}`;
}
case "delete":
return `Delete ${f.branch}.`;
case "cleanup": {
const branches = names(f.branches);
const n = Number.isInteger(f.count) ? f.count : branches.length;
return `Clean up ${plural(n, "branch", "branches")}${branches.length ? `: ${branches.join(", ")}` : ""}.`;
}
case "commit": {
const ignore = names(f.ignore);
const tail = ignore.length ? ` Add ${ignore.join(", ")} to .gitignore.` : "";
return `Commit ${filePhrase(names(f.files), f.count)}.${tail}`;
}
case "abort":
return `Abort the ${f.operation === "am" ? "git am" : f.operation || "rebase"}.`;
case "continue":
return `Continue the ${f.operation === "am" ? "git am" : f.operation || "rebase"}.`;
case "pr-host":
if (f.kind === "none" || !Object.hasOwn(PR_HOST_LABELS, f.kind)) return "This host is none of those.";
return `This host is ${PR_HOST_LABELS[f.kind]}.`;
case "done":
return "I'm done.";
default:
return `${op}.`;
}
}
/* ---------------------------------------------------------------- time */
const UNITS = [
["year", 365 * 24 * 3600],
["month", 30 * 24 * 3600],
["week", 7 * 24 * 3600],
["day", 24 * 3600],
["hour", 3600],
["minute", 60],
];
let rtf = null;
/** "2 hr. ago" style age of `iso`, in its largest whole unit; "" for an unreadable date. */
export function relativeAge(iso, now = Date.now()) {
const t = typeof iso === "number" ? iso : Date.parse(iso);
if (iso === null || iso === undefined || iso === "" || Number.isNaN(t) || !Number.isFinite(Number(now))) return "";
rtf = rtf || new Intl.RelativeTimeFormat("en", { numeric: "auto", style: "short" });
const seconds = (t - Number(now)) / 1000;
const unit = UNITS.find(([, size]) => Math.abs(seconds) >= size);
if (!unit) return rtf.format(0, "second");
return rtf.format(Math.round(seconds / unit[1]), unit[0]);
}
/** The board's footer line: when the remotes were last fetched, and whether the last try failed. */
export function refreshedLine(git, now = Date.now()) {
const g = git || {};
const age = g.lastFetch ? relativeAge(g.lastFetch, now) : "";
const line = age ? `Last refreshed ${age}` : "Never refreshed";
return g.refreshFailed ? `${line} · refresh failed` : line;
}
/* -------------------------------------------------------------- commit */
/**
* The paths ticked when the commit dialog opens. Staged files win: when any
* file is staged, exactly those. Otherwise every file that is not risky,
* plus each untracked folder of at most UNTRACKED_TICK_LIMIT files.
*/
export function commitTicks(changes) {
const files = list(changes && changes.files).filter((f) => f && typeof f.path === "string");
const staged = files.filter((f) => f.staged);
if (staged.length) return new Set(staged.map((f) => f.path));
const ticks = new Set(files.filter((f) => !f.risky).map((f) => f.path));
for (const dir of list(changes && changes.untrackedDirs)) {
if (dir && typeof dir.path === "string" && Number(dir.files) <= UNTRACKED_TICK_LIMIT) ticks.add(dir.path);
}
return ticks;
}
/* ------------------------------------------------------- pull requests */
/**
* The pull-request link for the current branch into `base` (the default
* branch unless the picker chose another): `{ url, needsKind, host }`, where
* needsKind means the host's kind is unknown and the person must name it
* (url is null then). null when the branch is not pushed, is gone upstream,
* is the default branch, or its remote or the base is missing.
*/
export function boardPrLink(git, base) {
const cur = currentRow(git);
if (!cur || !cur.upstream || cur.gone || cur.default) return null;
const target = base || (git && git.defaultBranch);
if (!target) return null;
const remote = list(git.remotes).find((r) => r && r.name === cur.upstreamRemote);
if (!remote) return null;
const needsKind = remote.kind === null || remote.kind === undefined;
return {
url: needsKind ? null : prUrl(remote, { base: target, head: cur.name }),
needsKind,
host: remote.host || null,
};
}
+2
View File
@@ -20,6 +20,7 @@ export const HELP_TABS = Object.freeze([
tab("dashboard", "The dashboard", true),
tab("meter", "Session meter", false),
tab("build", "Watching a build", false),
tab("git", "The git board", false),
tab("subagents", "Helpers (subagents)", false),
tab("ask", "Ask a quick question", false),
tab("finishing", "Stopping and finishing", false),
@@ -44,6 +45,7 @@ export function helpTabFor({ view, dashboard, gone, adrift, finished, workflow,
if (dashboard && meterRed) return "meter";
if (dashboard) return "dashboard";
if (v === "overview" || v.startsWith("doc:")) return "docs";
if (workflow === "git") return "git";
if (HELP_BUILD_WORKFLOWS.has(workflow)) return "build";
return "about";
}
+209 -101
View File
@@ -24,6 +24,8 @@
<link rel="modulepreload" href="/subagents.js" />
<link rel="modulepreload" href="/mentions.js" />
<link rel="modulepreload" href="/favicon.js" />
<link rel="modulepreload" href="/git-board.js" />
<link rel="modulepreload" href="/pr-url.js" />
<link rel="modulepreload" href="/vendor/marked.esm.js" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/png" sizes="192x192" href="/favicon.png" />
@@ -37,8 +39,8 @@
rail drawing that powers on centre stage, then glides into the rail.
Hidden unless boot.js is playing it; placed entirely by app.css,
because the CSP refuses style attributes. -->
<div class="wake" id="wake" hidden aria-hidden="true">
<svg class="wake-bot" viewBox="0 0 22 30" focusable="false">
<div class="wake" id="wake" hidden>
<svg class="wake-bot" viewBox="0 0 22 30" focusable="false" aria-hidden="true">
<g class="body">
<rect class="foot f1" x="5.7" y="27.1" width="3.6" height="1.7" rx="0.85" />
<rect class="foot f2" x="12.7" y="27.1" width="3.6" height="1.7" rx="0.85" />
@@ -58,7 +60,7 @@
</g>
</svg>
<p class="wake-hint">Click to wake Planny</p>
<button class="wake-skip" type="button">Skip</button>
<button class="wake-skip" type="button" aria-label="Skip the intro">Skip</button>
</div>
<header class="topbar">
@@ -565,13 +567,15 @@
</g>
</g>
</svg>
<!-- Git commit: saving a step. Beside a branch line with two commits on
it, one arm reaches to set a third commit onto the line. -->
<svg class="pose pose-git-commit" data-pose="git-commit" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
<!-- Git: minding the branches. Beside a branch line with a second branch
forking off it, one arm reaches to set a new commit onto the line. -->
<svg class="pose pose-git" data-pose="git" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
<ellipse class="shadow" cx="126" cy="198" rx="44" ry="5" />
<g class="prop">
<line class="lt gc-line" x1="204" y1="62" x2="204" y2="172" />
<path class="lt" d="M204 152 Q226 140 226 112 L226 72" />
<circle class="ac" cx="204" cy="82" r="7" />
<circle class="ac" cx="226" cy="92" r="6" />
<circle class="ac" cx="204" cy="112" r="7" />
<circle class="ac gc-dot" cx="204" cy="142" r="7" />
</g>
@@ -649,6 +653,12 @@
<rect x="3" y="9" width="18" height="6" rx="3" />
<path d="M6 12h7" />
</symbol>
<symbol id="hi-git" viewBox="0 0 24 24" fill="none">
<circle cx="6" cy="5" r="2" />
<circle cx="6" cy="19" r="2" />
<circle cx="18" cy="7" r="2" />
<path d="M6 7v10M18 9a7 7 0 0 1-7 7H6" />
</symbol>
<symbol id="hi-subagents" viewBox="0 0 24 24" fill="none">
<circle cx="7" cy="12" r="3.5" />
<circle cx="18" cy="5" r="2" />
@@ -737,8 +747,9 @@
<p>
<strong>It stays up while this tab is open.</strong> Close the tab and
it shuts itself down <span data-fact="closedTabMinutes">2</span> minutes
later, and after <span data-fact="maxLifeHours">4</span> hours
regardless. Reopening the same link brings everything back: nothing you
later. It also stops after <span data-fact="idleMinutes">30</span>
minutes without hearing from anyone, and after
<span data-fact="maxLifeHours">4</span> hours regardless. Reopening the same link brings everything back: nothing you
typed is kept in the browser alone.
</p>
<h4>Two halves, both running</h4>
@@ -782,7 +793,7 @@
<ol class="help-rows">
<li class="help-row">
<dl>
<dt>You see</dt><dd>The line beside Planny stays quiet for a minute or two while it is working.</dd>
<dt>You see</dt><dd>The line beside Planny stays quiet for half a minute or more while it is working.</dd>
<dt>Likely cause</dt><dd>A permission prompt is waiting in your terminal.</dd>
<dt>Do this</dt><dd>Switch to the terminal and answer it.</dd>
</dl>
@@ -798,7 +809,7 @@
<dl>
<dt>You see</dt><dd><strong>Not connected</strong> (Planny faded, his star shut).</dd>
<dt>Likely cause</dt><dd>The program behind this page shut itself down.</dd>
<dt>Do this</dt><dd>Ask Plan2Code to resume the session, and use the new link.</dd>
<dt>Do this</dt><dd>Ask Plan2Code to resume the session (or run the command again), and use the new link.</dd>
</dl>
</li>
<li class="help-row">
@@ -1561,7 +1572,7 @@
<li><strong>Review.</strong> A second opinion on the changes. Problems ranked, and you pick what gets fixed.</li>
<li><strong>Handoff.</strong> Pack this conversation into a document a fresh session can pick up cold.</li>
<li><strong>Changelog.</strong> Checks the CHANGELOG version against the main branch and suggests entries for what is new.</li>
<li><strong>Git commit.</strong> Commits your changes with a clear message, suggests a split when it is really two jobs, and offers to push.</li>
<li><strong>Git.</strong> Branches, pull, push and commits on one board, asking before anything leaves your machine. See "The git board".</li>
</ul>
<h4>Picking a spec</h4>
<p>
@@ -1718,7 +1729,94 @@
</p>
</section>
<!-- Tab 13: Helpers (subagents) -->
<!-- Tab 13: The git board -->
<section class="help-panel" data-tab="git">
<h3>The git board</h3>
<p class="help-lead">
The Git card opens one board for your repository: branches, pull,
push and commits in one place. Every button is a request to
Plan2Code, which runs the git commands and says what each one did.
</p>
<h4>The header</h4>
<ul>
<li>The branch you are on, and how far it is ahead of or behind its remote copy.</li>
<li>
<strong>Last refreshed</strong> says when the remotes were last
fetched. <strong>Refresh</strong> fetches again; if that fails, the
line says so.
</li>
<li>
Once your branch is pushed, <strong>Open pull request</strong> opens
your host's new pull request page, into the default branch or the
one you pick beside it. The first time a host is unknown, the board
asks which kind it is and remembers the answer.
</li>
</ul>
<h4>The branch table</h4>
<ul>
<li>
The branch you are on and the default branch come first, then the
rest, newest commit first, each with <strong>Switch</strong> and
<strong>Delete</strong>.
</li>
<li>
<strong>Merged</strong> marks a branch already merged into the
default branch, and <strong>Remote copy deleted</strong> one whose
remote copy is gone. <strong>Clean up</strong> offers to delete those
local branches in one go.
</li>
<li>
Branches that exist only on the remote sit under
<strong>Remote only</strong>, showing the first
<span data-fact="remoteFold">50</span>; <strong>Show all</strong>
lists the rest.
</li>
<li><strong>Search branches</strong> filters both lists by name or last commit.</li>
</ul>
<h4>What asks first</h4>
<ul>
<li>
<strong>Push</strong>, <strong>Publish</strong>,
<strong>Delete</strong> and <strong>Clean up</strong> always show
exactly what will happen and wait for your yes. Deleting a branch
that is not merged is a red confirm.
</li>
<li>
Switching with uncommitted changes asks first: <strong>Switch and
bring them</strong>, <strong>Commit first</strong> or
<strong>Cancel</strong>. A pull that would touch your changes asks
the same way.
</li>
<li>
<strong>Commit</strong> opens a list of your changed files to tick,
and you approve the message before anything is committed.
</li>
<li>A remote branch is never deleted, and nothing is ever force-pushed.</li>
</ul>
<h4>One action at a time</h4>
<p>
While Planny works on a click, the bar is locked, so nothing queues
up behind it. When it is done, a result line says what happened, with
the commit hashes, and the board redraws from the repository as it now
stands.
</p>
<h4>Done</h4>
<p>
<strong>Done</strong> ends the session. If anything happened, the last
screen lists the commits, pushes and branches created or deleted, with
<strong>Back to the dashboard</strong>. If nothing did, the page goes
straight back to the dashboard.
</p>
<h4>In the terminal</h4>
<p>
The same skill takes plain instructions, such as
<code>/plan2code-git switch to main</code> or
<code>/plan2code-git commit and push</code>, and asks the same
questions before every push, publish and delete.
</p>
</section>
<!-- Tab 14: Helpers (subagents) -->
<section class="help-panel" data-tab="subagents">
<h3>Helpers (subagents)</h3>
<p>
@@ -1773,7 +1871,7 @@
</ul>
</section>
<!-- Tab 14: Ask a quick question -->
<!-- Tab 15: Ask a quick question -->
<section class="help-panel" data-tab="ask">
<h3>Ask a quick question</h3>
<p class="help-lead">
@@ -1864,7 +1962,7 @@
</p>
</section>
<!-- Tab 15: Stopping and finishing -->
<!-- Tab 16: Stopping and finishing -->
<section class="help-panel" data-tab="finishing">
<h3>Stopping and finishing</h3>
<p class="help-lead">
@@ -1938,15 +2036,16 @@
A finished screen (never a paused one) has a <strong>Back to the
dashboard</strong> button. It turns this page back into the cards, in
the same conversation, so the next step starts right here.
Plan2Code listens for it for about ten minutes after the end. After
that, or once the session has closed, the button becomes the
<code>/plan2code</code> command to run in a new conversation instead.
Plan2Code listens for it for as long as the session is open.
Once the session has closed, the button becomes the
<code>/plan2code</code> command to run in a new conversation
instead.
After a long step, a new conversation is the better choice anyway: it
starts with a clean slate.
</p>
</section>
<!-- Tab 16: Keyboard and preferences -->
<!-- Tab 17: Keyboard and preferences -->
<section class="help-panel" data-tab="prefs">
<h3>Keyboard and preferences</h3>
<p class="help-lead">
@@ -2032,6 +2131,9 @@
lists what Plan2Code doesn't need in your
<code>~/.plan2code</code> folder: sessions nobody has opened for
30 days, and files or folders that ended up there by mistake. It
also lists this project's <code>specs--completed/</code> folders
nobody has touched for 30 days; deleting one is permanent, since
that folder is usually gitignored and git can't restore it. It
shows each one with its size, and <strong>Delete these</strong>
removes exactly that list. Your preferences, saved folders, models,
the launcher and the session you are in always stay.
@@ -2062,7 +2164,7 @@
</ul>
</section>
<!-- Tab 17: Privacy and where things are saved -->
<!-- Tab 18: Privacy and where things are saved -->
<section class="help-panel" data-tab="privacy">
<h3>Privacy and where things are saved</h3>
<p class="help-lead">
@@ -2127,90 +2229,93 @@
</section>
</template>
<dialog class="modal looks" id="looks-modal" aria-labelledby="looks-title">
<dialog class="modal looks prefs" id="looks-modal" aria-labelledby="looks-title">
<h2 id="looks-title">User Preferences</h2>
<p class="modal-blurb">
Kept on this machine, for every session you open here. Role only puts the
starter templates most useful to you first; it never changes the questions
you're asked.
</p>
<fieldset class="modal-ranges looks-row looks-role">
<legend>Role</legend>
<select id="looks-role" aria-label="Role"></select>
<p class="help">Only puts the starter templates most useful to you first.</p>
</fieldset>
<fieldset class="modal-ranges looks-row">
<legend>Theme</legend>
<label><input type="radio" name="looks-theme" value="system" checked /> <span>Follow my system</span></label>
<label><input type="radio" name="looks-theme" value="light" /> <span>Light</span></label>
<label><input type="radio" name="looks-theme" value="dark" /> <span>Dark</span></label>
</fieldset>
<fieldset class="modal-ranges looks-row">
<legend>Card width</legend>
<label><input type="radio" name="looks-width" value="narrow" /> <span>Narrow</span></label>
<label><input type="radio" name="looks-width" value="comfortable" checked /> <span>Comfortable</span></label>
<label><input type="radio" name="looks-width" value="wide" /> <span>Wide</span></label>
<p class="help">How wide the question and documents are. On a smaller window they fit the space there is.</p>
</fieldset>
<fieldset class="modal-ranges looks-accents">
<legend>Highlight color</legend>
<div class="swatches" id="looks-swatches"></div>
<p class="help">
Your highlight color marks what is yours to do, and Planny's
star uses it while he works. Green, amber and red also mean done,
staged and careful, so a highlight close to one of those can blur
which is which.
<div class="prefs-body">
<p class="modal-blurb">
Kept on this machine, for every session you open here. Role only puts the
starter templates most useful to you first; it never changes the questions
you're asked.
</p>
</fieldset>
<fieldset class="modal-ranges looks-sounds">
<legend>Sounds</legend>
<label><input type="checkbox" id="looks-sound" checked /> <span>Play sounds</span></label>
<div class="looks-row looks-sound-events" id="looks-sound-events">
<label><input type="checkbox" data-sound="snore" checked /> <span>Planny snoring</span></label>
<label><input type="checkbox" data-sound="bootup" checked /> <span>Planny waking up</span></label>
<label><input type="checkbox" data-sound="startSkill" checked /> <span>Starting a skill</span></label>
<label><input type="checkbox" data-sound="sessionStart" checked /> <span>Session opens</span></label>
<label><input type="checkbox" data-sound="skillReady" checked /> <span>Skill is ready</span></label>
<label><input type="checkbox" data-sound="sessionEnd" checked /> <span>Session ends</span></label>
<label><input type="checkbox" data-sound="question" checked /> <span>New questions for you</span></label>
<label><input type="checkbox" data-sound="chatReply" checked /> <span>Reply on the Ask tab</span></label>
<label><input type="checkbox" data-sound="newTab" checked /> <span>New tab added</span></label>
</div>
<p class="help">Ticking one plays it. Play sounds switches them all off at once and keeps your picks for when you switch back on.</p>
</fieldset>
<fieldset class="modal-ranges looks-cleanup">
<legend>Cleanup</legend>
<p class="help">Finds what Plan2Code doesn't need in your <code>~/.plan2code</code> folder: sessions nobody has opened for 30 days, and files or folders that ended up there by mistake. You see the list before anything is deleted. Your preferences, saved folders, models, the launcher and this session always stay.</p>
<div class="cleanup-list" id="cleanup-list" aria-label="What would be deleted"></div>
<div class="models-actions">
<button type="button" class="btn small" id="cleanup-scan">Find files to clean up</button>
<button type="button" class="btn small danger" id="cleanup-delete" hidden>Delete these</button>
<span class="help" id="cleanup-status" role="status"></span>
</div>
</fieldset>
<fieldset class="modal-ranges looks-models">
<legend>Models</legend>
<div class="models-tabs" role="group" aria-label="Which agent">
<button type="button" class="btn small ghost" id="models-tab-claude" aria-pressed="true">Claude</button>
<button type="button" class="btn small ghost" id="models-tab-devin" aria-pressed="false">Devin</button>
</div>
<div class="models-note">
<p><strong>You usually don't need to change this.</strong> Plan2Code ships an up-to-date model list with every release. Add a model here only when a new one comes out before Plan2Code has been updated.</p>
<ul>
<li>Restart <code>plan2code</code> to see a change in its model menu.</li>
<li>At any time, run <code>plan2code --model &lt;id&gt;</code>, or pick your model inside your agent before running a skill.</li>
<li>Updating Plan2Code refreshes the built-in list. Models you added stay, unless the built-in list now includes them.</li>
<li>Devin models are limited to Low, Medium and High effort.</li>
</ul>
</div>
<div class="models-list" id="models-shipped" aria-label="Built-in models"></div>
<div class="models-list" id="models-user" aria-label="Models you added"></div>
<div class="models-actions">
<button type="button" class="btn small" id="models-add">Add a model</button>
<button type="button" class="btn small ghost" id="models-reset">Reset to default</button>
<span class="help" id="models-status" role="status"></span>
</div>
</fieldset>
<fieldset class="modal-ranges looks-row looks-role">
<legend>Role</legend>
<select id="looks-role" aria-label="Role"></select>
<p class="help">Only puts the starter templates most useful to you first.</p>
</fieldset>
<fieldset class="modal-ranges looks-row">
<legend>Theme</legend>
<label><input type="radio" name="looks-theme" value="system" checked /> <span>Follow my system</span></label>
<label><input type="radio" name="looks-theme" value="light" /> <span>Light</span></label>
<label><input type="radio" name="looks-theme" value="dark" /> <span>Dark</span></label>
</fieldset>
<fieldset class="modal-ranges looks-row">
<legend>Card width</legend>
<label><input type="radio" name="looks-width" value="narrow" /> <span>Narrow</span></label>
<label><input type="radio" name="looks-width" value="comfortable" checked /> <span>Comfortable</span></label>
<label><input type="radio" name="looks-width" value="wide" /> <span>Wide</span></label>
<p class="help">How wide the question and documents are. On a smaller window they fit the space there is.</p>
</fieldset>
<fieldset class="modal-ranges looks-accents">
<legend>Highlight color</legend>
<div class="swatches" id="looks-swatches"></div>
<p class="help">
Your highlight color marks what is yours to do, and Planny's
star uses it while he works. Green, amber and red also mean done,
staged and careful, so a highlight close to one of those can blur
which is which.
</p>
</fieldset>
<fieldset class="modal-ranges looks-sounds">
<legend>Sounds</legend>
<label><input type="checkbox" id="looks-sound" checked /> <span>Play sounds</span></label>
<div class="looks-row looks-sound-events" id="looks-sound-events">
<label><input type="checkbox" data-sound="snore" checked /> <span>Planny snoring</span></label>
<label><input type="checkbox" data-sound="bootup" checked /> <span>Planny waking up</span></label>
<label><input type="checkbox" data-sound="startSkill" checked /> <span>Starting a skill</span></label>
<label><input type="checkbox" data-sound="sessionStart" checked /> <span>Session opens</span></label>
<label><input type="checkbox" data-sound="skillReady" checked /> <span>Skill is ready</span></label>
<label><input type="checkbox" data-sound="sessionEnd" checked /> <span>Session ends</span></label>
<label><input type="checkbox" data-sound="question" checked /> <span>New questions for you</span></label>
<label><input type="checkbox" data-sound="chatReply" checked /> <span>Reply on the Ask tab</span></label>
<label><input type="checkbox" data-sound="newTab" checked /> <span>New tab added</span></label>
</div>
<p class="help">Ticking one plays it. Play sounds switches them all off at once and keeps your picks for when you switch back on.</p>
</fieldset>
<fieldset class="modal-ranges looks-cleanup">
<legend>Cleanup</legend>
<p class="help">Finds what Plan2Code doesn't need in your <code>~/.plan2code</code> folder: sessions nobody has opened for 30 days, and files or folders that ended up there by mistake. It also lists this project's <code>specs--completed/</code> folders nobody has touched for 30 days; deleting one is permanent, since that folder is usually gitignored and git can't restore it. You see the list before anything is deleted. Your preferences, saved folders, models, the launcher and this session always stay.</p>
<div class="cleanup-list" id="cleanup-list" aria-label="What would be deleted"></div>
<div class="models-actions">
<button type="button" class="btn small" id="cleanup-scan">Find files to clean up</button>
<button type="button" class="btn small danger" id="cleanup-delete" hidden>Delete these</button>
<span class="help" id="cleanup-status" role="status"></span>
</div>
</fieldset>
<fieldset class="modal-ranges looks-models">
<legend>Models</legend>
<div class="models-tabs" role="group" aria-label="Which agent">
<button type="button" class="btn small ghost" id="models-tab-claude" aria-pressed="true">Claude</button>
<button type="button" class="btn small ghost" id="models-tab-devin" aria-pressed="false">Devin</button>
<button type="button" class="btn small ghost" id="models-tab-codex" aria-pressed="false">Codex</button>
</div>
<div class="models-note">
<p><strong>You usually don't need to change this.</strong> Plan2Code ships an up-to-date model list with every release. Add a model here only when a new one comes out before Plan2Code has been updated.</p>
<ul>
<li>Restart <code>plan2code</code> to see a change in its model menu.</li>
<li>At any time, run <code>plan2code --model &lt;id&gt;</code>, or pick your model inside your agent before running a skill.</li>
<li>Updating Plan2Code refreshes the built-in list. Models you added stay, unless the built-in list now includes them.</li>
<li>Devin models are limited to Low, Medium and High effort.</li>
</ul>
</div>
<div class="models-list" id="models-shipped" aria-label="Built-in models"></div>
<div class="models-list" id="models-user" aria-label="Models you added"></div>
<div class="models-actions">
<button type="button" class="btn small" id="models-add">Add a model</button>
<button type="button" class="btn small ghost" id="models-reset">Reset to default</button>
<span class="help" id="models-status" role="status"></span>
</div>
</fieldset>
</div>
<div class="modal-actions">
<button type="button" class="btn ghost" id="looks-reset">Back to default</button>
<button type="button" class="btn primary" id="looks-done">Done</button>
@@ -2436,6 +2541,9 @@
<li>
Run this in your terminal (not in this page or your agent):
<div class="update-command" id="update-command"></div>
It opens the installer's menu. Back at your prompt with no output at all? npm
could not reach the repository and hid the reason: run
<code>git ls-remote https://github.com/jparkerweb/plan2code.git</code> to see it.
</li>
<li>When it finishes, close this console and start <code>plan2code</code> again.</li>
</ol>
+37 -6
View File
@@ -25,17 +25,27 @@ export const WEIGHTS = Object.freeze({
"init-update": 2,
finalize: 1,
handoff: 0,
"git-commit": 1,
git: 1,
// Scores 0 itself: Git's commits are tallied per run (COMMITS_PER_POINT).
"git-commits": 0,
"git-conflict": 1,
changelog: 1,
});
// Workflows whose launch itself scores WEIGHTS[workflow]. Pathfinder,
// implement and implement-review score only through the agent's `run`
// reports; dashboard and handoff never score; git-commit and changelog score 1 on launch.
// reports; dashboard and handoff never score; git and changelog score 1 on
// launch (Git then adds its commit tally and conflict help).
export const LAUNCH_COUNTED = Object.freeze(
new Set(["plan", "revise-plan", "document", "review", "quick-task", "init", "init-update", "finalize", "git-commit", "changelog"])
new Set(["plan", "revise-plan", "document", "review", "quick-task", "init", "init-update", "finalize", "git", "changelog"])
);
// Git's commits weigh what they add up to: each `git-commits` run carries
// `commits`, and a skill run scores one point per COMMITS_PER_POINT commits,
// rounded down. MAX_COMMITS is the most one run may report. Tune here.
export const COMMITS_PER_POINT = 2;
export const MAX_COMMITS = 999;
const weightOf = (key) => (Object.prototype.hasOwnProperty.call(WEIGHTS, key) ? WEIGHTS[key] : 0);
// The event names an agent may report in `run`.
@@ -128,7 +138,7 @@ const WORKFLOW_NAMES = Object.freeze({
"init-update": "Init update",
finalize: "Finalize",
handoff: "Handoff",
"git-commit": "Git commit",
git: "Git",
changelog: "Changelog",
});
@@ -145,7 +155,7 @@ const LAUNCH_LABELS = Object.freeze({
init: "Init started",
"init-update": "Init update started",
finalize: "Finalize started",
"git-commit": "Git commit started",
git: "Git started",
changelog: "Changelog started",
});
const RUN_LABELS = Object.freeze({
@@ -163,7 +173,9 @@ const RUN_LABELS = Object.freeze({
"init-update": "Init update run",
finalize: "Finalize run",
handoff: "Handoff written",
"git-commit": "Git commit run",
git: "Git run",
"git-commits": "Commits in Git",
"git-conflict": "Git conflict help",
changelog: "Changelog run",
});
@@ -180,6 +192,7 @@ export function breakdownFrom(entries) {
const seen = new Set();
const rows = [];
const answers = new Map(); // launch id -> { row, count, workflow }
const commits = new Map(); // launch id -> { row, count }
const builds = new Map(); // launch id -> the row of the build in progress
const reviewed = new Set(); // launch ids whose built-in review has scored
for (const entry of Array.isArray(entries) ? entries : []) {
@@ -188,6 +201,20 @@ export function breakdownFrom(entries) {
if (seen.has(entry.id)) continue;
seen.add(entry.id);
}
// A click on the git board is not back-and-forth: Git's answers score nothing.
if (entry.kind === "answer" && entry.workflow === "git") continue;
if (entry.kind === "run" && entry.event === "git-commits") {
if (!Number.isInteger(entry.commits) || entry.commits < 1) continue;
const launch = launchOf(entry.id);
let tally = commits.get(launch);
if (!tally) {
tally = { row: { label: "", points: 0 }, count: 0 };
commits.set(launch, tally);
rows.push(tally.row);
}
tally.count += entry.commits;
continue;
}
if (entry.kind === "answer") {
const launch = launchOf(entry.id);
let tally = answers.get(launch);
@@ -255,6 +282,10 @@ export function breakdownFrom(entries) {
const where = WORKFLOW_NAMES[workflow] ? ` in ${WORKFLOW_NAMES[workflow]}` : "";
row.label = `${count} ${count === 1 ? "answer" : "answers"}${where}`;
}
for (const { row, count } of commits.values()) {
row.points = Math.floor(count / COMMITS_PER_POINT);
row.label = `${count} ${count === 1 ? "commit" : "commits"} in Git`;
}
return rows.filter((row) => row.points > 0).map(({ label, points }) => ({ label, points }));
}
+36
View File
@@ -0,0 +1,36 @@
// Plan2Code Web Console - the pull-request link for a branch.
//
// One pure builder for the four host shapes in the git-dashboard spec
// (overview.md -> Pull-request URL shapes). git-repo.mjs re-exports it for the
// snapshot, and the board's base picker rebuilds the link in the browser with
// the same code. No DOM access at module scope and no imports: the server,
// git-repo.mjs, the page and `node --test` all import this file.
// GitHub's compare path keeps the "/" in a branch name; each segment is
// encoded on its own.
const segments = (branch) => branch.split("/").map(encodeURIComponent).join("/");
const q = encodeURIComponent;
const SHAPES = {
github: (web, base, head) => `${web}/compare/${segments(base)}...${segments(head)}?quick_pull=1`,
gitlab: (web, base, head) =>
`${web}/-/merge_requests/new?merge_request%5Bsource_branch%5D=${q(head)}&merge_request%5Btarget_branch%5D=${q(base)}`,
azure: (web, base, head) => `${web}/pullrequestcreate?sourceRef=${q(head)}&targetRef=${q(base)}`,
bitbucket: (web, base, head) => `${web}/pull-requests/new?source=${q(head)}&dest=${q(base)}`,
};
/**
* The "open a pull request" link for `head` into `base` on a remote, or null
* when the host has no known shape (kind null or "none"), the remote has no
* web address, or the result would not be an https: link.
*/
export function prUrl({ web, kind } = {}, { base, head } = {}) {
const shape = SHAPES[kind];
if (!shape || !web || !base || !head) return null;
const url = shape(String(web).replace(/\/+$/, ""), base, head);
try {
return new URL(url).protocol === "https:" ? url : null;
} catch {
return null;
}
}
+68 -15
View File
@@ -20,9 +20,54 @@ import { marked } from "./vendor/marked.esm.js";
// read the same way) is protocol-relative and would not, so it is refused.
const SAFE_PROTOCOL = /^(https?:|mailto:|#|\/(?![/\\]))/i;
// A note attachment kept into the spec (`console.mjs keep`) is cited by a
// relative path ending in attachments/<slug>-<id8>.<ext>; the server serves
// exactly those from the session's spec, so the link and the image work.
const KEPT_ATTACHMENT = /^(?:\.{0,2}\/)*(?:[\w.-]+\/)*attachments\/([a-z0-9-]{1,40}-[0-9a-f-]{8}\.[a-z0-9]{1,5})$/i;
// A link or image the page cannot follow (a relative path into the project,
// a remote image the CSP refuses) still says where it points.
function unreachable(parent, href) {
const where = String(href || "").trim();
if (!where || /^(javascript|data|vbscript):/i.test(where)) return;
parent.appendChild(document.createTextNode(" ("));
parent.appendChild(el("code", null, where));
parent.appendChild(document.createTextNode(")"));
}
// An html token that is only an HTML comment: it renders as nothing, as it
// would in any markdown viewer. Anything else html stays literal text.
function isComment(t) {
return t.type === "html" && /^\s*<!--[\s\S]*?-->\s*$/.test(String(t.raw ?? t.text ?? ""));
}
const TASK_MARKERS = {
"/": { mark: "◐", label: "in progress", cls: "is-doing" },
"!": { mark: "!", label: "blocked", cls: "is-blocked" },
"?": { mark: "?", label: "assumed", cls: "is-assumed" },
};
// A list item opening with one of TASK_MARKERS: the marker comes off its
// first text token (so it is not drawn twice) and its look comes back.
function takeMarker(item) {
const first = item.tokens && item.tokens[0];
const leaf = first && Array.isArray(first.tokens) && first.tokens[0];
const m = /^\[([/!?])\]\s+/.exec((first && first.text) || "");
if (!m || !leaf || leaf.type !== "text" || !String(leaf.text || "").startsWith(m[0])) return null;
first.text = first.text.slice(m[0].length);
leaf.text = leaf.text.slice(m[0].length);
if (typeof leaf.raw === "string" && leaf.raw.startsWith(m[0])) leaf.raw = leaf.raw.slice(m[0].length);
if (Array.isArray(leaf.tokens) && leaf.tokens[0] && leaf.tokens[0].type === "text") {
leaf.tokens[0].text = String(leaf.tokens[0].text || "").replace(m[0], "");
}
return TASK_MARKERS[m[1]];
}
function safeHref(href) {
if (!href) return null;
const trimmed = String(href).trim();
const kept = KEPT_ATTACHMENT.exec(trimmed);
if (kept) return "/attachments/" + kept[1].toLowerCase();
// Blocks javascript: and data: hrefs before they can reach the DOM, and a
// protocol-relative `//host` (or `/\host`), which leaves the page for another site.
return SAFE_PROTOCOL.test(trimmed) ? trimmed : null;
@@ -74,6 +119,7 @@ function inlineInto(parent, tokens) {
const href = safeHref(t.href);
if (!href) {
inlineInto(parent, t.tokens);
unreachable(parent, t.href);
break;
}
const a = el("a");
@@ -87,8 +133,12 @@ function inlineInto(parent, tokens) {
}
case "image": {
const src = safeHref(t.href);
if (!src) {
// Only same-origin images load (the CSP's img-src is 'self'), so a
// remote one gets the text-and-path treatment rather than a broken
// image and a console error.
if (!src || /^https?:/i.test(src)) {
parent.appendChild(document.createTextNode(t.text || ""));
unreachable(parent, t.href);
break;
}
const img = el("img", "md-img");
@@ -98,6 +148,8 @@ function inlineInto(parent, tokens) {
break;
}
default:
// A comment is a note to tools (a spec's METRICS_JSON), never shown.
if (isComment(t)) break;
// Includes `html`: rendered as literal text, never parsed.
parent.appendChild(document.createTextNode(t.raw ?? t.text ?? ""));
}
@@ -105,11 +157,9 @@ function inlineInto(parent, tokens) {
}
// What a fenced code block offers beside Copy, from its first non-empty line:
// `'run'` gets a Run it button (git commands — the one kind a person keeps
// copying into Ask by hand), `'hint'` a muted note that pasting it into Ask
// may get the agent to run it, and `null` nothing extra. A leading `/` is a
// skill command for a new conversation, never a terminal command, so it gets
// neither.
// `'hint'` a muted note that pasting it into Ask may get the agent to run it,
// and `null` nothing extra. A leading `/` is a skill command for a new
// conversation, never a terminal command, so it gets nothing.
const COMMAND_WORDS =
/^(git|node|npm|npx|pnpm|yarn|bun|deno|python3?|pip3?|brew|curl|wget|docker|kubectl|terraform|make|cmake|cargo|go|java|mvn|gradle|gh|aws|az|gcloud|jq|ssh|scp|rsync|chmod|chown|mkdir|cp|mv|rm|ls|cd|cat|echo|export|source|bash|sh|zsh|fish|pwsh|powershell|cmd|systemctl|service|apt|apt-get|dnf|yum|pacman|tar|unzip|zip)\b/i;
@@ -119,7 +169,6 @@ export function runHint(text) {
.map((line) => line.trim())
.find((line) => line.length > 0);
if (!firstLine || firstLine.startsWith("/")) return null;
if (/^git(\s|$)/.test(firstLine)) return "run";
if (firstLine.startsWith("#!")) return "hint";
return COMMAND_WORDS.test(firstLine) ? "hint" : null;
}
@@ -161,14 +210,8 @@ function blockInto(parent, tokens) {
// textContent, so a fenced block containing markup is inert.
pre.appendChild(el("code", null, t.text));
wrap.appendChild(copyButton(t.text, "md-copy"));
const hint = runHint(t.text);
if (hint === "run") {
const run = el("button", "md-run", "Run it");
run.type = "button";
wrap.appendChild(run);
}
wrap.appendChild(pre);
if (hint === "hint") {
if (runHint(t.text) === "hint") {
wrap.appendChild(el("p", "md-run-hint", "The agent may be able to run this — paste it into the Ask tab"));
}
parent.appendChild(wrap);
@@ -181,12 +224,21 @@ function blockInto(parent, tokens) {
const list = el(t.ordered ? "ol" : "ul", "md-list");
if (t.ordered && typeof t.start === "number" && t.start !== 1) list.start = t.start;
for (const item of t.items || []) {
const li = el("li", "md-li" + (item.task ? " is-task" : ""));
// The spec's other task markers ([/] in progress, [!] blocked,
// [?] assumed), which marked does not know: drawn like a task box
// rather than left as a bullet reading "[!]".
const other = !item.task && takeMarker(item);
const li = el("li", "md-li" + (item.task || other ? " is-task" : ""));
if (item.task) {
const box = el("span", "md-task" + (item.checked ? " is-done" : ""));
box.textContent = item.checked ? "✓" : "·";
box.setAttribute("aria-label", item.checked ? "done" : "not done");
li.appendChild(box);
} else if (other) {
const box = el("span", "md-task " + other.cls);
box.textContent = other.mark;
box.setAttribute("aria-label", other.label);
li.appendChild(box);
}
blockInto(li, item.tokens);
list.appendChild(li);
@@ -224,6 +276,7 @@ function blockInto(parent, tokens) {
break;
}
default: {
if (isComment(t)) break;
// Unknown or raw html block: show the source, do not interpret it.
const p = el("p", "md-p");
p.textContent = t.raw ?? t.text ?? "";
+1 -1
View File
@@ -88,7 +88,7 @@ export function cleanSetting(input) {
// The non-editable part of every "on" block (FR-8).
export const FRAME_LINES = Object.freeze([
"Hand independent work to helpers if your tools allow it; otherwise carry on alone.",
"Report each helper on the page (console.md → Standing instructions); questions for the person stay with you.",
"Report each helper on the page (console-subagents.md); questions for the person stay with you.",
'If your tools cannot start helpers at all, report one "working alone" entry for this skill run instead; a real helper report removes it.',
]);