Compare commits

...
8 Commits
Author SHA1 Message Date
jparkerweb 80ae3decdd Merge pull request #12 from jparkerweb/docs-git-board
Show the git board on the docs site, and fix a test that failed under a global core.autocrlf
2026-10-14 20:57:33 -07:00
jparkerweb caef9a0ee3 Release v2.8.1: the docs site shows the git board, and npm test passes under a global core.autocrlf
AI Assisted
2026-10-14 20:51:52 -07:00
jparkerweb 72c827dddf Scrub git config for the whole test process in skill-script-helpers, so fixtures, imported modules and spawned scripts always agree
AI Assisted
2026-10-14 20:30:35 -07:00
jparkerweb 498e09bb15 Run test fixtures' git under the scripts' scrubbed config, so a global core.autocrlf no longer fails git plan switch
AI Assisted
2026-10-14 20:17:18 -07:00
jparkerweb 68d1f82a2e Show the git board on the docs site, with a git shot in the screenshot script that stages a real sample repository
AI Assisted
2026-10-14 20:14:24 -07:00
jparkerweb fdf43b197f Sync upstream into v2.8.0: the git board splits into Changes, Branches and Sync tabs that open on the next step (ticket-free)
AI Assisted
2026-10-14 20:03:09 -07:00
jparkerweb 7e2c824d4f Merge pull request #11 from jparkerweb/finalize-fix
Ask about open manual steps one by one in Implement instead of saying…
2026-10-12 16:29:05 -07:00
jparkerweb 8890c3ad13 Ask about open manual steps one by one in Implement instead of saying nothing is left, so Finalize unlocks once they are checked off 2026-10-12 16:26:47 -07:00
32 changed files with 2820 additions and 821 deletions

No files matched your search

+3 -2
View File
@@ -178,10 +178,11 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
| `console.mjs` | the CLI the agent drives: `open`, `post`, `wait`, `chat` (the instant Quick question check), `keep` (copy a cited note attachment into `specs/<idea>/attachments/`), `status`, `stop`, `help` (a compact summary for an agent that found the binary but not `console.md`; `help <topic>` prints one contract file, `help topics` lists them). `post --wait <N>` posts and waits in one command |
| `server.mjs` | HTTP server, spawned **detached** by `open` (never as a harness background task, which get killed on compaction and at assorted timeouts) |
| `lib.mjs` | session paths, atomic writes, the patch merge, `validate()` (which also allows `templates` only as `"idea"` on a `text` item; anything else exits 3), `attachmentName()` (the kept-file name `<slug>-<id8>.<ext>`: the same upload always gets the same name), `repoRoots()` (returns `{ project, worktree, branch }`), `readOverview()`, and the three sweeps `open` runs fire-and-forget after it prints (see the cleanup design point below): `sweepUploads()`, `staleSessions()` / `removeSessions()` and `staleScratch()` / `removeScratch()`; plus `cleanupFindings()` / `removeCleanup()` for User Preferences → Cleanup |
| `public/` | `index.html`, `app.js`, `answers.js`, `labels.js`, `boot.js`, `chat.js`, `help.js`, `starters.js`, `workspace.js`, `meter.js`, `subagents.js`, `mentions.js`, `favicon.js`, `git-board.js`, `pr-url.js`, `app.css`, `render.js`, `palette.js`, `favicon.svg` (Planny peeking up from the tab bar, served as `image/svg+xml`) with `favicon.png` (the same icon at 192 px, served as `image/png`) as the fallback, `vendor/marked.esm.js`, the chimes (`start-skill.mp3`, `bootup.mp3`, `start-stop.mp3`, `next.mp3`, `insert.mp3`, `sleeping.mp3`; which moment plays which is `SOUND_EVENTS` in `palette.js`, one switch per event saved in `looks.json`), and a `package.json` that only says `"type": "module"`, so Node (the server and the tests import `answers.js`, `palette.js`, `labels.js`, `boot.js`, `chat.js`, `help.js` and `starters.js`) parses them as ES modules without a reparse warning |
| `public/` | `index.html`, `app.js`, `answers.js`, `labels.js`, `boot.js`, `chat.js`, `help.js`, `starters.js`, `workspace.js`, `meter.js`, `subagents.js`, `mentions.js`, `favicon.js`, `git-board.js`, `git-board-view.js`, `pr-url.js`, `app.css`, `render.js`, `palette.js`, `favicon.svg` (Planny peeking up from the tab bar, served as `image/svg+xml`) with `favicon.png` (the same icon at 192 px, served as `image/png`) as the fallback, `vendor/marked.esm.js`, the chimes (`start-skill.mp3`, `bootup.mp3`, `start-stop.mp3`, `next.mp3`, `insert.mp3`, `sleeping.mp3`; which moment plays which is `SOUND_EVENTS` in `palette.js`, one switch per event saved in `looks.json`), and a `package.json` that only says `"type": "module"`, so Node (the server and the tests import `answers.js`, `palette.js`, `labels.js`, `boot.js`, `chat.js`, `help.js` and `starters.js`) parses them as ES modules without a reparse warning |
| `public/help.js` | the Help dialog's PURE rules: `HELP_TABS` (18 tabs: ids, order, labels, diagram flags; every tab uses the chosen highlight color; The git board sits right after Watching a build), `helpTabFor()` (which tab opens, FR-8 order, first match wins: finished → Stopping and finishing, server gone or agent adrift → When something looks stuck, opened from the Workspace dialog → Your workspace, then Ask, the Subagents tab → Helpers (subagents), a red-meter dashboard → Session meter, dashboard, a doc or the Overview, a git session → The git board, a build, else What this page is) and `helpKeyTarget()` (roving arrow keys, Home, End, wrapping). No module-scope DOM, so `node --test` covers it |
| `git-repo.mjs` | the one read-only reader of a git repository: the worktree status (`countPending()`, behind `pendingFiles()`), the branch table, the default branch, a merge or rebase in progress, the remotes and their web addresses, the last fetch and the pull-request link; `snapshot()` is what `open` and every `reread` store as `state.git`. Every git call carries `GIT_OPTIONAL_LOCKS=0`, so a background look never takes the index lock. Imported by `console.mjs` and `lib.mjs`; the git skill's `git.mjs` reaches it through `common.mjs` |
| `public/git-board.js` | PURE, one import (`pr-url.js`): the git board's rules from a `state.git` snapshot: branch order and the Remote only fold at `REMOTE_FOLD` 50, whether a new branch name is free, which buttons show and are enabled, whether the board still waits on the agent (`boardAwaiting()`: from a click until the agent's next post, not just until `wait` collects it), the plain sentence each click sends as `reply`, the "Last refreshed" line, which files start ticked in the commit dialog, and the pull-request link. `app.js` only renders what it says |
| `public/git-board.js` | PURE, one import (`pr-url.js`): the git board's rules from a `state.git` snapshot: branch order and the Remote only fold at `REMOTE_FOLD` 50, whether a new branch name is free, which buttons show and are enabled, whether the board still waits on the agent (`boardAwaiting()`: from a click until the agent's next post, not just until `wait` collects it), the plain sentence each click sends as `reply`, the "Last refreshed" line, which files start ticked in the commit dialog, and the pull-request link; the next step (ten rules, `nextStep()`), the tab that owns it, per-tab badges (`tabBadges()`), the busy mode and per-control gate (`busyMode()`, `controlAllowed()`), the tab to show (`pickTab()`), and the create-panel sources and clean-up groups. `app.js` only renders what it says |
| `public/git-board-view.js` | No DOM access of its own: `drawGitBoard(ctx)` draws the tabbed board (header, tab strip with Done with git, the card slot, step strip, Changes / Branches / Sync) from the helpers it is handed (`el`, `md`, `copyButton`), every control through one gate; `app.js` hosts it, and `scripts/test-web-console-git-board.mjs` drives it with a recording fake `el` |
| `public/pr-url.js` | PURE, no imports: `prUrl()`, the "open a pull request" link for the GitHub, GitLab, Azure DevOps and Bitbucket shapes (`null` for an unknown kind, no web address, or a non-https result). `git-repo.mjs` re-exports it, and the board's base picker rebuilds the link in the browser with the same code |
| `public/workspace.js` | PURE, no imports: the Workspace's name rules (`nameProblem()`, `NAME_MAX`, `defaultName()`, `freeName()` for the `-2` suggestion), the footer label and its width tiers (`footerLabel()`, `FOOTER_TIERS`) and `changeLine()`, the `Workspace: …` reply line an agent is handed per change. Imported by the server, `console.mjs`, `lib.mjs` and the page |
| `public/meter.js` | PURE, no imports: the session meter. `WEIGHTS` (the one place per-event points live; its keys are also `RUN_EVENTS`, the `run` events `post` accepts), `LAUNCH_COUNTED` (workflows whose launch itself scores), the built-phase sizing (`TASK_EVENTS`, the keys of `TASK_BONUS`: `implement-phase` +0 and `implement-review-phase` +1; `isTaskCount()` accepts a whole `tasks` from 1 to `MAX_TASKS` 999; `runPoints()` scores such a run `ceil(tasks / TASKS_PER_POINT)` (3) plus its bonus, and any other run its `WEIGHTS` value), `ANSWERS_PER_POINT` 2 (`answer` entries score per skill run, `floor(count / 2)`), `breakdownFrom()` (the click-the-ring list: one row per scoring entry plus one answers row per skill run), `pointsFrom()` (the count, its sum, folded from `ledger.ndjson` and deduplicated by id, never stored), `levelFor()` with `YELLOW_AT` 5 / `RED_AT` 10, `ringFraction()` (full at `RING_FULL` 15), `WORDS`, `tooltipFor()`, `RED_BANNER` and `meterView()` |
+1 -1
View File
@@ -1 +1 @@
U0VOQwFAFRnj5vy/mnmGUHUOrq/i1kg2DXIDYOvtqs3nU3Zr6vo320sUGDuFT2Bicjmgrzt+z9L/byaoHJlHgsY7t7OIRAp0wLV2zlNhr6E0rkAdx6ZZf7kYjh9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nt0RMTeMsFkYo2q+pOAzZ/R4IqtEM92XvKkd2ShwvPdeyRoHfKwdmVFjp9nWBK//dNpxMx+Yl+vYIPXwyuS+4lbUqPbYVIs6QlBCXuos0bYJJdjslbjImyhKn92DxkZCtmNH42c4mScpHNV2XoZd5F2Cul4AdzLine truncated
+7 -6
View File
@@ -194,12 +194,13 @@ A page opens with every skill laid out as cards — the setup pair, the pipeline
in order, and the utilities alongside — with a note about what it made of your
project (no AGENTS.md yet, a spec waiting on Phase 2) and a *Suggested* flag on
the card it would pick. **Git** is among the utilities, always available: it opens
the git board, with your branches, pull, push and commits on one page (Help's
*The git board* topic walks through it), and asks before every push, publish and
delete. In a folder that is not a git repository its card says *Not a git
repository yet: it offers to start one*, and clicking it still works. Click
one and Planny flies while it gets ready; a few seconds later the same page
is that skill's console, already running. No command names to remember.
the git board, three tabs — Changes, Branches and Sync — that open on the
likely next step (Help's *The git board* topic walks through it), and asks
before every push, publish and delete. In a folder that is not a git
repository its card says *Not a git repository yet: it offers to start one*,
and clicking it still works. Click one and Planny flies while it gets ready;
a few seconds later the same page is that skill's console, already running. No
command names to remember.
A freshly opened dashboard starts with Planny asleep in the middle of the page.
Click to wake him: he snores once while he gets a gentle shake side to side,
+3 -2
View File
@@ -42,8 +42,7 @@ Details: [Architecture](./.agents-docs/AGENTS-architecture.md) (see Status Line
## Web Console
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) bundled into every skill via `additionalReferences`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), a built-in 18-topic Help, a first-run Welcome, User Preferences (gear) and a bug/idea link to GitHub issues. On opted-in skills (builds, review, Pathfinder) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`); the agent hears of it as a standing instruction only when it changes, and reports its helpers in a **Subagents** tab beside Ask (contract in `console-subagents.md`). The agent contract is read in pieces: `console.md` once per conversation, then a topic file (`console-*.md`, `notes/<workflow>.md`, `building*.md`) only when its moment comes; the server never writes into a project.
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) bundled into every skill via `additionalReferences`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review), build progress, the living document, an **Ask** chat, a read-only **Workspace** of extra folders (remembered per folder and spec in `~/.plan2code/console/workspaces.json`), a session meter, a **git board** for the `git` workflow (three tabs, Changes, Branches and Sync, opening on the likely next step; branches, pull, push, commits and pull-request links, drawn from `state.git`; contract in `notes/git.md`), a built-in 18-topic Help, a first-run Welcome, User Preferences (gear) and a bug/idea link to GitHub issues. On opted-in skills (builds, review, Pathfinder) a **Subagents** button in the top bar turns helpers on or off per project and skill (on by default for those skills until switched off, saved in `~/.plan2code/console/subagents.json`); the agent hears of it as a standing instruction only when it changes, and reports its helpers in a **Subagents** tab beside Ask (contract in `console-subagents.md`). The agent contract is read in pieces: `console.md` once per conversation, then a topic file (`console-*.md`, `notes/<workflow>.md`, `building*.md`) only when its moment comes; the server never writes into a project.
Details: [Architecture](./.agents-docs/AGENTS-architecture.md) (see Web Console section) and [.readme/web-console.md](./.readme/web-console.md)
## Skill Scripts
@@ -98,4 +97,6 @@ When you make a mistake, get corrected, or discover something about this codebas
- Keep plan2code's ticket-free `commit-msg.mjs` (`<subject>`, `AI Assisted`) in every `/sync-repo`: upstream's ticket-from-branch rule was ported by mistake once and removed in v2.6.0.
- When a new first-run dialog is added to the web console, set its seen flag in `scripts/capture-screenshots.mjs`'s `looks.json` too: the Welcome dialog once covered the regenerated dashboard screenshots until `welcomeSeen: true` was added.
- After a sync, grep for the upstream brand word on its own too, not only the full product name: the rebrand map misses a bare brand word inside identifiers and fixtures (a `KEPT_<BRAND>_ENTRIES` constant, a `<brand>Dir` option, a `"<brand>"` test folder, an owner slug in a git remote URL), and v2.7.0's sync let all four through until the residual grep caught them.
- After a sync, grep for the upstream ticket key followed by anything, not only by digits: v2.8.0's git board fixtures built branch names as `` `feature/<KEY>-${11000 + i}-…` `` template literals, which a digits-only rewrite to `ABC-<n>` misses.
- Import `scripts/skill-script-helpers.mjs` in any test that builds git fixtures for a skill script or `git-repo.mjs`: it scrubs the whole test process's git config, so fixtures, imported modules and spawned scripts agree. Mixed configs broke `git plan switch` once (a global `core.autocrlf=true` checked fixtures out with CRLF the scrubbed script read as changed).
- Before deleting a test file that upstream split or removed, diff plan2code's copy against the rebranded upstream base and port the plan2code-only tests: v2.7.0's split of the web console suite would otherwise have dropped seven hardening tests (now in `scripts/test-web-console-hardening.mjs`).
+30
View File
@@ -2,6 +2,36 @@
All notable changes to Plan2Code will be documented in this file.
## v2.8.1
### 📚 Documentation
- **docs**: the docs site now shows the git board, with a light and dark screenshot under the pipeline's "Any time" cards: the Changes, Branches and Sync tabs, opening on the likely next step, the tab badges, the single block for a stopped rebase or merge, and asking before every push, publish or delete.
- **docs**: `scripts/capture-screenshots.mjs` gains a `git` shot. It builds a sample repository with a pushed feature branch and three changes to commit, so `node scripts/capture-screenshots.mjs --only git` regenerates the images.
### 🐛 Fixed
- **tests**: `npm test` no longer fails `git plan switch` on a machine with a global `core.autocrlf=true`. `scripts/skill-script-helpers.mjs` now strips back the git config for the whole test process, so test fixtures, imported modules and the scripts under test always use the same settings.
## v2.8.0
### 🔧 Changed
- **git**: the web console's git board is now three tabs, **Changes**, **Branches** and **Sync**, and opens on the tab holding the likely next step. Ten fixed rules pick that step from the repository's state (fix or continue a stopped rebase or merge, make the first commit, make a branch on a detached HEAD, commit or start a branch for your changes, pull, push, publish, open a pull request, clean up branches) and show it as one main button with at most one quieter one beside it. Each tab badges what is waiting on it, and the other tabs say "Next step is on ‹tab›" with a link to it. Your own click moves you to the next step's tab once it lands; a refresh or a commit from the terminal leaves you where you are, and a reload keeps your tab.
- **git**: held-back files (secrets, files over 5 MB) no longer keep Commit as the next step forever. They get a quiet "held back" line and an **Add … to .gitignore** offer, which commits only `.gitignore`.
- **git**: a busy board is read-only. While a git command runs or the agent has not picked up your last click, every button, tick and picker greys out (switching tabs, search and folds still work), and what is running shows where the next step usually sits. Plan2Code's questions now appear under the tab strip.
- **git**: a rebase or merge stopped on conflicts shows one block on Sync with the files marked *markers left* or *resolved*, one main button and **Abort** once; Changes and Branches wait until it is finished or aborted.
- **git**: **Done with git** is a normal button at the right of the tab strip. It greys while a git command runs (Stop session in the top bar still works), and while one of Plan2Code's questions waits it cancels that question and finishes.
- **web-console**: Help → *The git board* is rewritten for the tabs, badges, the next step, the busy rules and Done with git. Handoff is described as packing the current session, not this conversation.
- **docs**: the docs site's "Any time" skills now list **Changelog** and **Git** beside Quick task, Review and Handoff.
- **tests**: `scripts/test-web-console-git-board.mjs` checks every sample repository state's next step, tab and badges, proves no control on a busy board is clickable, and that every board function is reachable on some tab.
## v2.7.1
### 🐛 Fixed
- **implement**: Implement no longer says there is nothing left to do while the dashboard keeps Finalize greyed out. When every phase is approved but tasks under them are still open (usually manual steps an agent could not do, left blocked `[!]` with a "User action"), `specs.mjs status` now returns a `checkoff` verdict listing them, and Implement asks about each one in turn: "Is this done?" in the terminal, or a **Done, check it off** / **Not yet** card in the web console. A yes runs the new `specs.mjs tick <spec> --task <id>`, which marks the task `[x]` and adds a "Confirmed done by the user on <date>" line under it. Once nothing is left open, Implement points to `/plan2code-4-finalize` and the dashboard shows the spec as ready to finalize.
## v2.7.0
### ✨ Added
+14 -1
View File
@@ -306,7 +306,20 @@ footer a { color: inherit; }
<div class="utils">
<div class="util"><span class="chip">Any time</span><h3>Quick task</h3><p>Too small for the full process? A quick plan, then it just builds it.</p></div>
<div class="util"><span class="chip">Any time</span><h3>Review</h3><p>A second opinion on the changes. Problems ranked, and you pick what gets fixed.</p></div>
<div class="util"><span class="chip">Any time</span><h3>Handoff</h3><p>Pack this conversation into a document a fresh session can pick up cold.</p></div>
<div class="util"><span class="chip">Any time</span><h3>Handoff</h3><p>Pack the current session into a document a fresh session can pick up cold.</p></div>
<div class="util"><span class="chip">Any time</span><h3>Changelog</h3><p>Picks the next version and drafts the entries, which you edit before Git commits them.</p></div>
<div class="util"><span class="chip">Any time</span><h3>Git</h3><p>A board for branches, pull, push and commits that opens on the likely next step.</p></div>
</div>
<div class="row" id="git-board">
<picture class="shot">
<source media="(prefers-color-scheme: dark)" srcset="screenshots/git-dark.webp">
<img src="screenshots/git-light.webp" width="2560" height="1600" loading="lazy" alt="The git board on feature/task-endpoints: the Changes tab, badged 3, opens on a Next step card reading Commit 3 files, above the three changed files ticked for the commit. Branches and Sync tabs and a Done with git button sit beside it.">
</picture>
<div>
<h3>The git board</h3>
<p>Three tabs, <strong>Changes</strong>, <strong>Branches</strong> and <strong>Sync</strong>, and it opens on the one holding your likely next step: commit, pull, push, publish, open a pull request or tidy up branches. That step is one main button. Each tab badges what is waiting on it, a stopped rebase or merge gets one block with every file marked, and nothing is pushed, published or deleted without asking. It never force-pushes.</p>
</div>
</div>
</div>
</section>
Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "plan2code",
"version": "2.7.0",
"version": "2.8.1",
"private": true,
"bin": {
"plan2code-install": "./install.js"
@@ -8,7 +8,7 @@
"scripts": {
"prepare": "husky",
"build:skills": "node install.js --build-skills",
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-script-pathfinder.mjs scripts/test-launcher.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-script-handoff.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs"
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node --test scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-script-pathfinder.mjs scripts/test-launcher.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-script-handoff.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs"
},
"devDependencies": {
"husky": "^9.0.0"
+49 -5
View File
@@ -13,7 +13,7 @@
// The shots use the console's Ocean highlight rather than its default orange:
// it is the console's nearest to the Plan2Code blue the site and README use.
//
// Shots: dashboard, dashboard-utilities, question, doc, build, signoff, finish, ask.
// Shots: dashboard, dashboard-utilities, question, doc, build, signoff, finish, ask, git.
//
// Needs puppeteer-core (`npm i --no-save puppeteer-core`, never added to
// package.json) and a local Chrome or Edge. Writes nothing outside its temp
@@ -67,6 +67,9 @@ const SHOTS = {
signoff: { workflow: "implement", posts: ["signoff"] },
finish: { workflow: "implement", posts: ["signoff", "finish"] },
ask: { workflow: "plan", posts: ["question"], ask: "Where are tasks paged?" },
// The git board draws itself from a real repository, so this shot runs in
// its own git sample project; the post only hands the board back to you.
git: { workflow: "git", posts: ["git"], repo: true },
};
// On Windows the temp dir sits under the user's profile, and the page can
@@ -166,6 +169,46 @@ function makeSampleProject() {
return project;
}
function git(cwd, ...gitArgs) {
const r = spawnSync("git", gitArgs, { cwd, env: ENV, encoding: "utf8" });
if (r.status !== 0) throw new Error(`git ${gitArgs.join(" ")} failed: ${(r.stderr || "").trim()}`);
}
// The git shot's project: the same sample in a repository whose feature branch
// is pushed to a local bare "origin" and has three changes to commit, so the
// board opens on Changes with Commit as the next step. It sits in its own
// folder so the other shots never see a repository.
let GIT_PROJECT = null;
function makeGitProject() {
if (GIT_PROJECT) return GIT_PROJECT;
const parent = path.join(SCRATCH, "git");
fs.mkdirSync(parent, { recursive: true });
const origin = path.join(parent, "origin.git");
git(parent, "init", "--bare", "--initial-branch=main", origin);
const prev = SCRATCH;
SCRATCH = parent;
const project = makeSampleProject();
SCRATCH = prev;
const id = ["-c", "user.name=Sam Rivera", "-c", "user.email=sam@example.com", "-c", "commit.gpgsign=false"];
git(project, "init", "--initial-branch=main");
git(project, "remote", "add", "origin", origin);
git(project, "add", "-A");
git(project, ...id, "commit", "-m", "Scaffold the task API and its specs");
git(project, "push", "-u", "origin", "main");
git(project, "switch", "-c", "feature/task-endpoints");
fs.writeFileSync(path.join(project, "src", "tasks", "routes.js"), "// The /tasks routes.\nexport default async function routes(app) {}\n");
git(project, "add", "-A");
git(project, ...id, "commit", "-m", "Register the /tasks routes plugin");
git(project, "push", "-u", "origin", "feature/task-endpoints");
// A fetch stamps FETCH_HEAD, so the board says "Last refreshed" rather than "Never".
git(project, "fetch", "origin");
fs.appendFileSync(path.join(project, "src", "tasks", "paginate.js"), "\nexport const MAX_LIMIT = 50;\n");
fs.writeFileSync(path.join(project, "src", "tasks", "schema.js"), "// The Zod schema for a task.\nexport const taskSchema = {};\n");
fs.appendFileSync(path.join(project, "specs", "task-api", "phase-3.md"), "\n<!-- Task 3.1 in progress -->\n");
GIT_PROJECT = project;
return project;
}
function cli(cwd, ...cliArgs) {
const r = spawnSync(process.execPath, [CONSOLE_CLI, ...cliArgs], { cwd, env: ENV, encoding: "utf8" });
const line = (r.stdout || "").trim().split("\n").pop() || "";
@@ -194,7 +237,7 @@ function stage(project, shot) {
// (the dashboard's wake-up is the longest).
async function settle(page) {
await page.waitForNetworkIdle({ idleTime: 500, timeout: 15000 }).catch(() => {});
await page.waitForSelector(".dash-card, .card, .handoff, .ask-pane, .doc", { timeout: 15000 }).catch(() => {});
await page.waitForSelector(".dash-card, .card, .handoff, .ask-pane, .doc, .git-board", { timeout: 15000 }).catch(() => {});
await sleep(3500);
}
@@ -348,12 +391,13 @@ async function main() {
args: ["--no-first-run", "--no-default-browser-check", "--mute-audio"],
});
for (const name of names) {
const { sid, url } = stage(project, name);
const where = SHOTS[name].repo ? makeGitProject() : project;
const { sid, url } = stage(where, name);
try {
if (SHOTS[name].ask) await captureAsk(browser, project, sid, url, SHOTS[name].ask);
if (SHOTS[name].ask) await captureAsk(browser, where, sid, url, SHOTS[name].ask);
else await capture(browser, url, name, SHOTS[name]);
} finally {
cli(project, "stop", "--session", sid);
cli(where, "stop", "--session", sid);
}
}
} finally {
+360
View File
@@ -0,0 +1,360 @@
// Git board fixture: canned state.git snapshots, one per journey step and edge case.
//
// A copy of specs/git-board-redesign/pathfinder/sketch-00/states.js, the repo
// states every Pathfinder sketch moved between. Shape follows
// src/web-console/git-repo.mjs snapshot(). `expect` is [primary op, secondary
// op] under the agreed next-step rules (nextStep() in git-board.js), and
// `expectTab` the tab that owns that step. Times are relative to a fixed NOW,
// so ages read the same on every run.
export const NOW = Date.parse("2026-10-14T12:00:00Z");
const ago = (mins) => new Date(NOW - mins * 60000).toISOString();
const ORIGIN = {
name: "origin",
url: "git@github.com:jparkerweb/plan2code.git",
host: "github.com",
web: "https://github.com/jparkerweb/plan2code",
kind: "github",
};
const pr = (head) => `https://github.com/jparkerweb/plan2code/compare/main...${head}?expand=1`;
const last = (subject, author, mins) => ({ subject, author, at: ago(mins) });
function local(name, extra = {}) {
return {
name,
current: false,
default: name === "main",
remote: null,
upstream: `origin/${name}`,
upstreamRemote: "origin",
ahead: 0,
behind: 0,
gone: false,
merged: false,
last: last("Update README", "Justin Parker", 60 * 24),
...extra,
};
}
function remoteOnly(name, subject, author, mins) {
return { name, current: false, default: false, remote: "origin", upstream: null, upstreamRemote: null, ahead: null, behind: null, gone: false, merged: false, last: last(subject, author, mins) };
}
// The branches every journey shares; `current` and the current row's tracking are set per state.
function branches(current, row = {}) {
const rows = [
local("main", { last: last("Release 4.12.0", "Justin Parker", 60 * 5) }),
local("feature/ABC-12001-export-csv", { last: last("Add CSV export button to the audit view", "Justin Parker", 40) }),
local("feature/ABC-11980-audit-filter", { last: last("Filter audit events by actor", "Priya Raman", 60 * 26) }),
local("fix/ABC-11890-null-ticket", { merged: true, last: last("Guard against a null ticket id", "Sam Okafor", 60 * 24 * 6) }),
local("chore/bump-deps", { merged: true, last: last("Bump dev dependencies", "Justin Parker", 60 * 24 * 9) }),
remoteOnly("feature/ABC-12010-sso-banner", "Show SSO expiry banner", "Dana Whitfield", 60 * 3),
remoteOnly("docs/readme-console", "Document the console's Ask tab", "Priya Raman", 60 * 24 * 2),
];
if (!rows.some((b) => b.name === current)) rows.splice(1, 0, local(current, { upstream: null, upstreamRemote: null, ahead: null, behind: null }));
return rows.map((b) => (b.name === current && !b.remote ? { ...b, current: true, ...row } : b));
}
const NO_CHANGES = { count: 0, heldBack: 0, files: [], untrackedDirs: [] };
const DIRTY_FEATURE = {
count: 4,
heldBack: 1,
files: [
{ path: "src/web-console/public/audit-export.js", state: "modified", staged: false, risky: false },
{ path: "src/web-console/public/app.css", state: "modified", staged: false, risky: false },
{ path: ".env.local", state: "new", staged: false, risky: true },
],
untrackedDirs: [{ path: "scripts/fixtures/audit/", files: 6 }],
};
const DIRTY_MAIN = {
count: 2,
heldBack: 0,
files: [
{ path: "src/web-console/public/login.js", state: "modified", staged: false, risky: false },
{ path: "scripts/test-login.mjs", state: "new", staged: false, risky: false },
],
untrackedDirs: [],
};
function snap({ branch, ahead = 0, behind = 0, upstream, gone = false, changes = NO_CHANGES, inProgress = null, conflicted = [], lastFetch = ago(5), remotes = [ORIGIN], rows, prUrl = null, hasCommits = true, detached = null, rebasing }) {
const up = upstream === undefined ? (branch ? `origin/${branch}` : null) : upstream;
return {
at: new Date(NOW).toISOString(),
repo: true,
hasCommits,
head: { branch, detached, ...(rebasing ? { rebasing } : {}), upstream: up, gone, ahead: up ? ahead : null, behind: up ? behind : null },
defaultBranch: "main",
inProgress,
conflicted,
changes,
remotes,
lastFetch,
refreshFailed: false,
branches: rows || branches(branch, { upstream: up, upstreamRemote: up ? "origin" : null, ahead: up ? ahead : null, behind: up ? behind : null, gone }),
prUrl,
};
}
const EXPORT = "feature/ABC-12001-export-csv";
const LOGIN = "fix/ABC-12044-login-redirect";
const FILTER = "feature/ABC-11980-audit-filter";
/** The three journeys, in click order. */
export const JOURNEYS = [
{ id: "commit-push", title: "Commit & push", states: ["cp-dirty", "cp-committing", "cp-ahead", "cp-pushing", "cp-pushed"] },
{ id: "new-branch", title: "Start a new branch", states: ["nb-main-dirty", "nb-creating", "nb-unpublished", "nb-publishing", "nb-published"] },
{ id: "pull-conflict", title: "Recover from a pull conflict", states: ["pc-diverged", "pc-pulling", "pc-conflict", "pc-resolved", "pc-continuing", "pc-rebased", "pc-pushing", "pc-pushed"] },
];
/**
* Every state: `git` (the snapshot), `journey` and `step` (or "edge"), `title`,
* `expect` (primary op, secondary op or null), `expectTab` (the tab owning the
* next step), `expectLine` where the line itself is pinned, `busy` (what is
* running, when a git command is), `result` (the git-result notice after the
* last action), and `on` (board op -> next state id) for the clicks a journey
* takes.
*/
export const STATES = {
/* Commit & push, on a published feature branch */
"cp-dirty": {
journey: "commit-push", step: 1, title: "4 changes on a feature branch (one held back)",
git: snap({ branch: EXPORT, changes: DIRTY_FEATURE, prUrl: pr(EXPORT) }),
expect: ["commit", "pr"],
expectTab: "changes",
on: { commit: "cp-committing" },
},
"cp-committing": {
journey: "commit-push", step: 2, title: "Committing (busy)", busy: "Committing 3 files on feature/ABC-12001-export-csv",
git: snap({ branch: EXPORT, changes: DIRTY_FEATURE, prUrl: pr(EXPORT) }),
expect: ["commit", "pr"],
expectTab: "changes",
on: { done: "cp-ahead" },
},
"cp-ahead": {
journey: "commit-push", step: 3, title: "Committed, 1 to push",
result: { title: "Committed 3 files", body: "`9f3c2ab` Add CSV export button to the audit view. `.env.local` was held back." },
git: snap({ branch: EXPORT, ahead: 1, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { push: "cp-pushing" },
},
"cp-pushing": {
journey: "commit-push", step: 4, title: "Pushing (busy)", busy: "Pushing 1 commit to origin",
git: snap({ branch: EXPORT, ahead: 1, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { done: "cp-pushed" },
},
"cp-pushed": {
journey: "commit-push", step: 5, title: "Pushed, pull request ready",
result: { title: "Pushed 1 commit to origin/feature/ABC-12001-export-csv", body: `\`9f3c2ab\`. [Open pull request](${pr(EXPORT)})` },
git: snap({ branch: EXPORT, changes: { count: 1, heldBack: 1, files: [DIRTY_FEATURE.files[2]], untrackedDirs: [] }, prUrl: pr(EXPORT) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Start a new branch, from changes made on main */
"nb-main-dirty": {
journey: "new-branch", step: 1, title: "2 changes on main",
git: snap({ branch: "main", changes: DIRTY_MAIN }),
expect: ["create-commit", "commit"],
expectTab: "changes",
on: { "create-commit": "nb-creating", create: "nb-creating" },
},
"nb-creating": {
journey: "new-branch", step: 2, title: "Creating the branch and committing (busy)", busy: "Creating fix/ABC-12044-login-redirect from origin/main, then committing 2 files",
git: snap({ branch: "main", changes: DIRTY_MAIN }),
expect: ["create-commit", "commit"],
expectTab: "changes",
on: { done: "nb-unpublished" },
},
"nb-unpublished": {
journey: "new-branch", step: 3, title: "New branch with 1 commit, not published",
result: { title: "Created fix/ABC-12044-login-redirect and committed 2 files", body: "`4e7d1c0` Redirect to the login page after SSO expiry." },
git: snap({ branch: LOGIN, upstream: null }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: { publish: "nb-publishing" },
},
"nb-publishing": {
journey: "new-branch", step: 4, title: "Publishing (busy)", busy: "Publishing fix/ABC-12044-login-redirect to origin",
git: snap({ branch: LOGIN, upstream: null }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: { done: "nb-published" },
},
"nb-published": {
journey: "new-branch", step: 5, title: "Published, pull request ready",
result: { title: "Published fix/ABC-12044-login-redirect to origin", body: `[Open pull request](${pr(LOGIN)})` },
git: snap({ branch: LOGIN, prUrl: pr(LOGIN) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Recover from a pull conflict */
"pc-diverged": {
journey: "pull-conflict", step: 1, title: "1 ahead, 3 behind",
git: snap({ branch: FILTER, ahead: 1, behind: 3, prUrl: pr(FILTER) }),
expect: ["pull", "push"],
expectTab: "sync",
on: { pull: "pc-pulling" },
},
"pc-pulling": {
journey: "pull-conflict", step: 2, title: "Pulling (busy)", busy: "Pulling origin/feature/ABC-11980-audit-filter (rebase)",
git: snap({ branch: FILTER, ahead: 1, behind: 3, prUrl: pr(FILTER) }),
expect: ["pull", "push"],
expectTab: "sync",
on: { done: "pc-conflict" },
},
"pc-conflict": {
journey: "pull-conflict", step: 3, title: "Rebase stopped on 2 conflicts, 1 with markers left",
result: { title: "Pull stopped on 2 conflicts", body: "Replaying `b81e9d4` Filter audit events by actor (1 of 1). Plan2Code resolved `src/web-console/public/audit.js`; `src/web-console/public/audit.css` still has markers." },
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: true },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["fix", "abort"],
expectTab: "sync",
on: { continue: "pc-conflict", abort: "pc-diverged", fix: "pc-resolved" },
},
"pc-resolved": {
journey: "pull-conflict", step: 4, title: "Every conflict resolved",
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: false },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["continue", "abort"],
expectTab: "sync",
on: { continue: "pc-continuing", abort: "pc-diverged" },
},
"pc-continuing": {
journey: "pull-conflict", step: 5, title: "Continuing the rebase (busy)", busy: "Continuing the rebase",
git: snap({
branch: null, detached: "b81e9d4", rebasing: FILTER, upstream: null, inProgress: "rebase",
conflicted: [
{ path: "src/web-console/public/audit.js", markers: false },
{ path: "src/web-console/public/audit.css", markers: false },
],
rows: branches(FILTER, { ahead: 1, behind: 3 }),
}),
expect: ["continue", "abort"],
expectTab: "sync",
on: { done: "pc-rebased" },
},
"pc-rebased": {
journey: "pull-conflict", step: 6, title: "Rebased, 1 to push",
result: { title: "Pull finished", body: "1 commit replayed on top of origin. Resolved `audit.js` (kept both filters) and `audit.css` (you fixed it). 1 commit ready to push." },
git: snap({ branch: FILTER, ahead: 1, prUrl: pr(FILTER) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { push: "pc-pushing" },
},
"pc-pushing": {
journey: "pull-conflict", step: 7, title: "Pushing (busy)", busy: "Pushing 1 commit to origin",
git: snap({ branch: FILTER, ahead: 1, prUrl: pr(FILTER) }),
expect: ["push", "pr"],
expectTab: "sync",
on: { done: "pc-pushed" },
},
"pc-pushed": {
journey: "pull-conflict", step: 8, title: "Pushed, pull request ready",
result: { title: `Pushed 1 commit to origin/${FILTER}`, body: `\`c42d7e1\`. [Open pull request](${pr(FILTER)})` },
git: snap({ branch: FILTER, prUrl: pr(FILTER) }),
expect: ["pr", "cleanup"],
expectTab: "sync",
on: {},
},
/* Edges that break layouts */
"e-caught-up": {
journey: "edge", title: "All caught up on main",
git: snap({ branch: "main", rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "All caught up on main · checked 5 min. ago",
on: {},
},
"e-stale": {
journey: "edge", title: "All caught up, but last checked 3 hours ago",
git: snap({ branch: "main", lastFetch: ago(180), rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "All caught up on main · checked 3 hr. ago",
on: { refresh: "e-caught-up" },
},
"e-held-only": {
journey: "edge", title: "Caught up except a held-back file",
git: snap({ branch: "main", changes: { count: 1, heldBack: 1, files: [{ path: ".env.local", state: "new", staged: false, risky: true }], untrackedDirs: [] }, rows: branches("main").map((b) => ({ ...b, merged: false })) }),
expect: [null, "ignore"],
expectTab: "changes",
on: {},
},
"e-gone": {
journey: "edge", title: "Remote copy deleted",
git: snap({ branch: "feature/ABC-11702-old-banner", gone: true }),
expect: ["publish", "cleanup"],
expectTab: "sync",
on: {},
},
"e-no-remote": {
journey: "edge", title: "No remote at all",
git: snap({ branch: "main", upstream: null, remotes: [], lastFetch: null, rows: [local("main", { current: true, upstream: null, upstreamRemote: null, ahead: null, behind: null })] }),
expect: [null, "create"],
expectTab: "sync",
expectLine: "Nothing to commit on main · no remote yet",
on: {},
},
"e-first-commit": {
journey: "edge", title: "No commits yet",
git: snap({
branch: "main", hasCommits: false, upstream: null, remotes: [], lastFetch: null, rows: [],
changes: { count: 3, heldBack: 0, files: [{ path: "README.md", state: "new", staged: false, risky: false }, { path: "package.json", state: "new", staged: false, risky: false }], untrackedDirs: [{ path: "src/", files: 12 }] },
}),
expect: ["commit", null],
expectTab: "changes",
on: {},
},
"e-detached": {
journey: "edge", title: "Detached at a commit",
git: snap({ branch: null, detached: "a1b2c3d", upstream: null, rows: branches("main").map((b) => ({ ...b, current: false })) }),
expect: ["create", "cleanup"],
expectTab: "branches",
on: {},
},
"e-many-branches": {
journey: "edge", title: "300 branches, 40 merged",
git: snap({
branch: "main",
rows: [
local("main", { current: true }),
...Array.from({ length: 120 }, (_, i) =>
local(`feature/ABC-${11000 + i}-${["export", "filter", "banner", "login", "audit", "sso"][i % 6]}-${i}`, {
merged: i < 40,
ahead: i % 7 === 0 ? 2 : 0,
behind: i % 5 === 0 ? 4 : 0,
last: last(`Work on ABC-${11000 + i}`, ["Justin Parker", "Priya Raman", "Sam Okafor", "Dana Whitfield"][i % 4], 60 * (i + 1)),
}),
),
...Array.from({ length: 179 }, (_, i) => remoteOnly(`feature/ABC-${12100 + i}-remote-${i}`, `Remote work ${i}`, "Dana Whitfield", 60 * 24 + i * 30)),
],
}),
expect: ["cleanup", null],
expectTab: "branches",
on: {},
},
};
+1
View File
@@ -13,6 +13,7 @@ and dark WebP images in `docs/screenshots/`.
| `build.json` | A phase being built: the progress bar, the task list and the current task |
| `signoff.json` | The completion report and the sign-off card |
| `finish.json` | The finished screen after sign-off (posted after `signoff.json`) |
| `git.json` | The git board, handed back to you in a sample repository with three changes to commit (the script builds the repository) |
Refresh every image with `node scripts/capture-screenshots.mjs`, or one with
`--only <shot>`.
+5
View File
@@ -0,0 +1,5 @@
{
"reread": true,
"board": { "describe": "task-schema-and-paging" },
"agent": { "status": "waiting" }
}
+8 -1
View File
@@ -57,6 +57,13 @@ export function scrubbedEnv(extra = {}) {
return { ...e, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: EMPTY_GITCONFIG, ...extra };
}
// Every git in a test process that imports this file runs under that same
// scrubbed config: fixture commands, the modules a test imports and the
// scripts it spawns. Mixed configs disagree: a global core.autocrlf=true once
// checked fixtures out with CRLF that the scrubbed scripts read as changed.
for (const k of AMBIENT_GIT_ENV) delete process.env[k];
Object.assign(process.env, { GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: EMPTY_GITCONFIG });
export function runScript(skill, script, args, { cwd, env } = {}) {
const r = spawnSync(process.execPath, [path.join(SKILLS, skill, "scripts", script), ...args], {
cwd: cwd || ROOT,
@@ -83,7 +90,7 @@ export function write(root, rel, content) {
export const read = (root, rel) => fs.readFileSync(path.join(root, rel), "utf8");
/** A git runner for `dir`. */
/** A git runner for `dir`, under the scrubbed config set beside `scrubbedEnv`. */
export const gitIn = (dir) => (...a) => execFileSync("git", a, { cwd: dir, stdio: "pipe", encoding: "utf8" });
export function gitInit(dir, branch = "main") {
+41 -3
View File
@@ -152,8 +152,46 @@ test("specs status: the implement selection table", () => {
assert.ok(next("x", "x", "/", "/").warning, "all options already [/] warns about duplicated work");
assert.equal(next("x", " ", " ", " ").action, "auto-start");
assert.equal(next("x", "x", "x", " ").action, "auto-start");
assert.equal(next("x", "x", "x", "x").action, "none");
assert.equal(next("x", "x", "x", "x").reason, "every phase is complete");
assert.equal(next("x", "x", "x", "x").action, "checkoff", "approved phases with open tasks are not finished");
assert.deepEqual(next("x", "x", "x", "x").tasks.map((t) => t.id), ["2.2", "3.1", "3.2", "3.2a", "3.4", "4.1"]);
});
test("specs: open tasks under approved phases are a checkoff, and tick checks them off one at a time", () => {
const root = specFixture();
write(root, "specs/lunch-vote/overview.md", OVERVIEW.replace(/- \[[ /]\] /g, "- [x] "));
write(root, "specs/lunch-vote/phase-2.md", phase(2, "Complete", [["x", "2.1"], ["x", "2.2"]]));
write(root, "specs/lunch-vote/phase-3.md", phase(3, "Complete", [["x", "3.1"], ["x", "3.2"], ["x", "3.3"]]));
write(
root,
"specs/lunch-vote/phase-4.md",
phase(4, "Complete", [["!", "4.1"], [" ", "4.2"], ["x", "4.3"]]).replace("**Task 4.1:** Do 4.1", "**Task 4.1:** Create the Okta app\n > BLOCKED: needs admin. User action: create it.\n")
);
const S = (...a) => runScript("plan2code-3-implement", "specs.mjs", [...a, "--root", root]);
const j = S("status", "lunch-vote").json;
assert.equal(j.next.action, "checkoff");
assert.match(j.next.reason, /2 tasks are still open/);
assert.deepEqual(j.next.tasks.map((t) => [t.id, t.marker]), [["4.1", "[!]"], ["4.2", "[ ]"]]);
assert.equal(j.next.tasks[0].text, "Create the Okta app");
assert.match(j.next.tasks[0].detail, /User action: create it/);
assert.equal(S("list").json.specs.find((s) => s.name === "lunch-vote").state, "building", "the dashboard agrees: not built yet");
assert.equal(S("tick", "lunch-vote", "--task", "4.1", "--dry-run").json.changed, true);
assert.match(read(root, "specs/lunch-vote/phase-4.md"), /- \[!\] \*\*Task 4\.1/, "dry-run writes nothing");
const one = S("tick", "lunch-vote", "--task", "4.1");
assert.equal(one.code, 0, one.stderr);
assert.deepEqual(one.json.remaining, ["4.2"]);
assert.equal(one.json.next, "checkoff");
const text = read(root, "specs/lunch-vote/phase-4.md");
assert.match(text, /- \[x\] \*\*Task 4\.1:\*\* Create the Okta app\n > BLOCKED: needs admin\. User action: create it\.\n > Confirmed done by the user on \d{4}-\d{2}-\d{2}\.\n/);
assert.equal(S("tick", "lunch-vote", "--task", "4.1").json.changed, false, "ticking a done task is a no-op");
const last = S("tick", "lunch-vote", "--task", "4.2");
assert.deepEqual(last.json.remaining, []);
assert.equal(last.json.next, "none");
assert.equal(S("status", "lunch-vote").json.next.reason, "every phase is complete");
assert.equal(S("list").json.specs.find((s) => s.name === "lunch-vote").state, "built", "Finalize lights up on the dashboard");
assert.equal(S("tick", "lunch-vote", "--task", "4.9").code, 3);
assert.equal(S("tick", "lunch-vote", "--task", "nope").code, 2);
});
test("specs status: drift between the checklist and the phase files is an error", () => {
@@ -397,7 +435,7 @@ test("specs: group ranges expand, chains are not parallel, [?] phases count as d
assert.deepEqual(runScript("plan2code-3-implement", "specs.mjs", ["status", "lunch-vote", "--root", root]).json.parallelGroups, []);
write(root, "specs/lunch-vote/overview.md", OVERVIEW.replace("- [/] [Phase 2", "- [?] [Phase 2").replace("- [ ] **Phase 3", "- [?] **Phase 3").replace("- [ ] [Phase 4", "- [?] [Phase 4"));
const done = runScript("plan2code-3-implement", "specs.mjs", ["status", "lunch-vote", "--root", root]).json;
assert.equal(done.next.reason, "every phase is complete");
assert.equal(done.next.action, "checkoff", "[?] phases count as done; their open tasks still need checking off");
assert.deepEqual(done.pending, []);
write(root, "specs/lunch-vote/overview.md", OVERVIEW.replace("- [/] [Phase 2", "- [!] [Phase 2"));
const skip = runScript("plan2code-3-implement", "specs.mjs", ["status", "lunch-vote", "--root", root]).json.next;
+538
View File
@@ -0,0 +1,538 @@
// Web console tests, the tabbed git board's rules: next step, tabs, badges, busy.
// Run with: node --test scripts/test-web-console-git-board.mjs
//
// Every sample repo state the Pathfinder sketches moved between lives in
// scripts/fixtures/git-board-states.mjs, each with the next step it must
// produce. The rules are pure (git-board.js), so no browser is needed.
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import { JOURNEYS, NOW, STATES } from "./fixtures/git-board-states.mjs";
import {
BRANCH_TYPES,
GIT_TABS,
busyMode,
commitTicks,
controlAllowed,
createSources,
gitReply,
nextStep,
pickTab,
tabBadges,
} from "../src/web-console/public/git-board.js";
import { drawGitBoard } from "../src/web-console/public/git-board-view.js";
const VIEW_SRC = fs.readFileSync(new URL("../src/web-console/public/git-board-view.js", import.meta.url), "utf8");
const MODES = ["offline", "running", "card", "idle"];
const ROLES = ["nav", "action", "done"];
const TAB_IDS = GIT_TABS.map((t) => t.id);
const step = (id) => nextStep(STATES[id].git, { now: NOW });
const badges = (id) => {
const s = step(id);
return tabBadges(STATES[id].git, { now: NOW, stepTab: s.tab });
};
test("git board rules: every sample state gives its expected primary, secondary and tab", () => {
for (const [id, s] of Object.entries(STATES)) {
const n = nextStep(s.git, { now: NOW });
const got = [n.primary ? n.primary.op : null, n.secondary[0] ? n.secondary[0].op : null];
assert.deepEqual(got, s.expect, `${id}: primary and secondary`);
assert.equal(n.tab, s.expectTab, `${id}: owning tab`);
if (s.expectLine) assert.equal(n.line, s.expectLine, `${id}: line`);
assert.ok(n.secondary.length <= (n.primary ? 1 : 2), `${id}: at most one secondary beside a primary`);
for (const st of [n.primary, ...n.secondary].filter(Boolean)) assert.ok(TAB_IDS.includes(st.tab), `${id}: ${st.op} has a tab`);
}
});
test("git board rules: every journey names states that exist", () => {
for (const j of JOURNEYS) for (const id of j.states) assert.ok(STATES[id], `${j.id} names ${id}`);
});
test("git board rules: held-back files never drive the step, and fill an empty secondary with the ignore offer", () => {
const held = step("e-held-only");
assert.equal(held.primary, null);
assert.deepEqual(held.secondary.map((s) => s.op), ["ignore", "refresh"]);
assert.equal(held.secondary[0].label, "Add `.env.local` to .gitignore");
assert.deepEqual(held.secondary[0].files, [".env.local"]);
assert.equal(held.held, "`.env.local` held back");
assert.equal(held.tab, "changes");
const dirty = step("cp-dirty");
assert.equal(dirty.primary.label, "Commit 3 files", "4 changes minus the held-back .env.local");
assert.equal(dirty.held, "`.env.local` held back");
const two = nextStep({
...STATES["e-held-only"].git,
changes: {
count: 2,
heldBack: 2,
files: [
{ path: ".env.local", state: "new", risky: true },
{ path: "dump.sql", state: "new", risky: true },
],
untrackedDirs: [],
},
}, { now: NOW });
assert.equal(two.held, "2 files held back");
assert.equal(two.secondary[0].label, "Add 2 held-back files to .gitignore");
assert.equal(two.secondary[0].why, "Keep them out of every commit.");
assert.equal(held.secondary[0].why, "Keep it out of every commit.");
});
test("git board rules: no default branch means no clean-up step or badge, as boardActions() offers none", () => {
const git = STATES["e-gone"].git;
assert.equal(step("e-gone").secondary[0].op, "cleanup");
const noDefault = { ...git, defaultBranch: null, branches: git.branches.map((b) => ({ ...b, default: false, merged: false, gone: b.current ? b.gone : b.name === "chore/bump-deps" })) };
const n = nextStep(noDefault, { now: NOW });
assert.ok(![n.primary, ...n.secondary].some((s) => s && s.op === "cleanup"));
assert.equal(tabBadges(noDefault, { now: NOW, stepTab: n.tab }).branches, null);
});
test("git board badges: no 'not published' badge before the first commit, even with a remote", () => {
const git = { ...STATES["e-first-commit"].git, remotes: STATES["cp-dirty"].git.remotes, lastFetch: STATES["cp-dirty"].git.lastFetch };
const n = nextStep(git, { now: NOW });
assert.equal(n.primary.op, "commit");
assert.equal(tabBadges(git, { now: NOW, stepTab: n.tab }).sync, null);
});
test("git board rules: the stale line never changes the step, and needs a remote", () => {
const fresh = step("e-caught-up");
const stale = step("e-stale");
assert.equal(fresh.stale, null);
assert.equal(stale.stale, "Checked 3 hr. ago — Refresh?");
assert.deepEqual(stale.primary, fresh.primary);
assert.deepEqual(stale.secondary.map((s) => s.op), fresh.secondary.map((s) => s.op));
assert.equal(step("e-no-remote").stale, null);
const never = nextStep({ ...STATES["e-caught-up"].git, lastFetch: null }, { now: NOW });
assert.equal(never.stale, "Never checked — Refresh?");
});
test("git board rules: no remote reads 'Nothing to commit … no remote yet', and still offers Refresh", () => {
const n = step("e-no-remote");
assert.equal(n.line, "Nothing to commit on main · no remote yet");
assert.deepEqual(n.secondary.map((s) => [s.op, s.label]), [["create", "New branch"], ["refresh", "Refresh"]]);
});
test("git board rules: a pushed branch on an unknown host gets no pull request step", () => {
const git = STATES["pc-pushed"].git;
const unknown = { ...git, remotes: git.remotes.map((r) => ({ ...r, kind: null })) };
assert.equal(step("pc-pushed").primary.op, "pr");
assert.ok(step("pc-pushed").primary.url.startsWith("https://"));
const n = nextStep(unknown, { now: NOW });
assert.notEqual(n.primary && n.primary.op, "pr");
assert.ok(![n.primary, ...n.secondary].some((s) => s && s.op === "pr"));
});
test("git board rules: mid-operation, Fix the files while markers remain, then Continue, Abort once", () => {
const fix = step("pc-conflict");
assert.equal(fix.primary.label, "Fix the files");
assert.equal(fix.secondary[0].label, "Abort the rebase");
assert.equal(step("pc-resolved").primary.op, "continue");
const am = nextStep({ ...STATES["pc-resolved"].git, inProgress: "am" }, { now: NOW });
assert.equal(am.secondary[0].label, "Abort the git am");
});
test("git board rules: on the default branch, a branch is suggested and committing there is the secondary", () => {
const n = step("nb-main-dirty");
assert.equal(n.primary.label, "Start a branch for 2 files");
assert.equal(n.secondary[0].label, "Commit on main");
assert.equal(n.secondary[0].tab, "changes");
});
test("git board badges: each tab badges what it has waiting, and the next step's tab is filled", () => {
const dirty = badges("cp-dirty");
assert.deepEqual([dirty.changes.text, dirty.changes.kind, dirty.changes.next], ["3", "count", true]);
assert.equal(dirty.changes.label, "3 waiting, next step");
assert.equal(dirty.branches.text, "2");
assert.equal(dirty.branches.next, false);
assert.equal(dirty.sync, null);
const held = badges("e-held-only");
assert.deepEqual([held.changes.kind, held.changes.text, held.changes.next], ["dot", "·", false], "no primary, so no filled badge");
assert.equal(badges("e-many-branches").branches.text, "40");
assert.equal(badges("pc-diverged").sync.text, "↑1 ↓3");
assert.equal(badges("pc-diverged").sync.label, "1 to push, 3 to pull, next step");
assert.equal(badges("nb-unpublished").sync.text, "↑");
assert.equal(badges("e-gone").sync.text, "↑");
assert.equal(badges("e-stale").sync.text, "?");
assert.equal(badges("e-caught-up").sync, null);
const conflict = badges("pc-conflict");
assert.equal(conflict.sync.kind, "warn");
assert.equal(conflict.sync.text, "!");
assert.equal(conflict.changes, null);
assert.equal(conflict.branches, null);
});
test("git board badges: a tab owning the step with nothing of its own gets a filled dot", () => {
const b = badges("cp-pushed");
assert.deepEqual([b.sync.kind, b.sync.text, b.sync.next], ["dot", "·", true]);
assert.equal(b.sync.label, "next step");
});
test("git board busy: offline beats running beats a waiting card", () => {
for (let bits = 0; bits < 16; bits++) {
const f = { running: Boolean(bits & 1), cardWaiting: Boolean(bits & 2), gone: Boolean(bits & 4), pending: Boolean(bits & 8) };
const want = f.gone || f.pending ? "offline" : f.running ? "running" : f.cardWaiting ? "card" : "idle";
assert.equal(busyMode(f), want, JSON.stringify(f));
}
assert.equal(busyMode(), "idle");
});
test("git board busy: nav always works, actions only when idle, Done with git while idle or a card waits", () => {
const want = {
nav: { offline: true, running: true, card: true, idle: true },
action: { offline: false, running: false, card: false, idle: true },
done: { offline: false, running: false, card: true, idle: true },
};
for (const role of ROLES) for (const mode of MODES) assert.equal(controlAllowed(mode, role), want[role][mode], `${role} in ${mode}`);
assert.equal(controlAllowed("idle", "nonsense"), false);
});
test("git board tabs: a landed click and arriving go to the step's tab; reload and background keep yours", () => {
for (const current of ["changes", "branches", "sync"]) {
assert.equal(pickTab({ current, stepTab: "branches", reason: "landed" }), "branches");
assert.equal(pickTab({ current, stepTab: "branches", reason: "arrival" }), "branches");
assert.equal(pickTab({ current, stepTab: "branches", reason: "reload" }), current);
assert.equal(pickTab({ current, stepTab: "branches", reason: "background" }), current);
}
for (const current of [null, "nonsense"]) {
assert.equal(pickTab({ current, stepTab: "changes", reason: "reload" }), "changes");
assert.equal(pickTab({ current, stepTab: "changes", reason: "background" }), "changes");
}
assert.equal(pickTab({ current: null, stepTab: null, reason: "arrival" }), "sync");
});
/* ------------------------------------------------------------ the view */
// The node API git-board-view.js may use (its header comment, phase 2 Task
// 2.1), and nothing else: touching any other property throws, so the view
// cannot drift onto something the real DOM has and this fake does not.
const NODE_API = new Set([
"appendChild", "append", "replaceChildren", "setAttribute", "removeAttribute", "addEventListener", "classList",
"className", "id", "type", "value", "checked", "disabled", "textContent", "placeholder", "title", "open", "href",
"target", "rel", "tabIndex",
]);
// What the test itself reads off a recorded node.
const TEST_ONLY = new Set(["tag", "children", "attrs", "listeners", "parent", "classes", "text"]);
function fakeNode(tag) {
const n = {
tag, children: [], attrs: {}, listeners: {}, parent: null, classes: new Set(), text: "",
id: "", type: "", value: "", checked: false, disabled: false, placeholder: "", title: "", open: false,
href: "", target: "", rel: "", tabIndex: 0,
appendChild(c) {
c.parent = proxy;
n.children.push(c);
return c;
},
append(...cs) {
for (const c of cs) proxy.appendChild(c);
},
replaceChildren(...cs) {
n.children = [];
n.text = "";
proxy.append(...cs);
},
setAttribute(k, v) {
n.attrs[k] = String(v);
},
removeAttribute(k) {
delete n.attrs[k];
},
addEventListener(type, fn) {
(n.listeners[type] ||= []).push(fn);
},
classList: {
add: (...c) => c.forEach((x) => n.classes.add(x)),
remove: (...c) => c.forEach((x) => n.classes.delete(x)),
toggle: (c, force) => {
const on = force === undefined ? !n.classes.has(c) : Boolean(force);
if (on) n.classes.add(c);
else n.classes.delete(c);
return on;
},
contains: (c) => n.classes.has(c),
},
};
const proxy = new Proxy(n, {
get(t, key) {
if (typeof key !== "string" || TEST_ONLY.has(key)) return t[key];
if (!NODE_API.has(key)) throw new Error(`the view used .${key}, which is not in its node API`);
if (key === "className") return [...t.classes].join(" ");
if (key === "textContent") return t.text + t.children.map((c) => c.textContent).join("");
return t[key];
},
set(t, key, v) {
if (typeof key === "string" && !NODE_API.has(key) && !TEST_ONLY.has(key)) throw new Error(`the view set .${key}, which is not in its node API`);
if (key === "className") t.classes = new Set(String(v || "").split(/\s+/).filter(Boolean));
else if (key === "textContent") {
t.children = [];
t.text = v == null ? "" : String(v);
} else t[key] = v;
return true;
},
});
return proxy;
}
/** The helpers the view is handed, recording every node made. */
function fakeH() {
const all = [];
const el = (tag, className, text) => {
const n = fakeNode(tag);
if (className) n.className = className;
if (text != null) n.textContent = text;
all.push(n);
return n;
};
return { el, md: (text, cls) => el("div", cls, text), copyButton: (text, cls) => el("button", cls, "Copy"), all };
}
/** ctx.on, recording every call as [name, ...args]. */
function fakeOn() {
const calls = [];
const rec = (name) => (...args) => calls.push([name, ...args]);
return {
calls,
send: rec("send"), redraw: rec("redraw"), pickTab: rec("pickTab"), openPanel: rec("openPanel"),
closePanel: rec("closePanel"), pickPrHost: rec("pickPrHost"), persist: rec("persist"),
};
}
// The Create prompt's fields as openCreate() in app.js seeds them.
const seedCreate = (git, commit = false) => ({
from: createSources(git, commit).preset,
type: BRANCH_TYPES[0],
description: "",
name: null,
commit,
files: commit ? [...commitTicks(git.changes)] : null,
ignore: [],
});
// The panels each tab can draw; "create-commit" is the create panel in commit mode, on Changes.
const PANELS = { changes: [null, "commit", "create-commit"], branches: [null, "create", "cleanup"], sync: [null] };
function draw(id, { mode = "idle", tab = null, panel = null, create = null } = {}) {
const s = STATES[id];
const git = s.git;
const step = nextStep(git, { now: NOW });
const badges = tabBadges(git, { now: NOW, stepTab: step.tab });
const board = {
tab,
panel: panel === "create-commit" ? "create" : panel,
create: create || (panel === "create" ? seedCreate(git) : panel === "create-commit" ? seedCreate(git, true) : null),
ticks: null, ignore: new Set(), sweep: null, query: "", showAll: false, remoteOpen: null, base: null,
};
const h = fakeH();
const on = fakeOn();
const out = drawGitBoard({
git, board, now: NOW, mode, step, badges, notice: s.result || null, activity: s.busy || null,
hasCard: false, offlineReason: "gone", h, on,
});
return { ...out, h, on, board, step };
}
function walk(node, out = []) {
out.push(node);
for (const c of node.children) walk(c, out);
return out;
}
const isControl = (n) => ["button", "input", "select"].includes(n.tag) || (["a", "span"].includes(n.tag) && n.classes.has("git-pr-open"));
const controls = (node) => walk(node).filter(isControl);
const isOff = (n) => (n.tag === "span" ? n.attrs["aria-disabled"] === "true" : Boolean(n.disabled));
// A control's words: its own text, or for a bare box, the label around it.
const words = (n) => n.textContent.trim() || (n.parent && n.parent.tag === "label" ? n.parent.textContent.trim() : "");
function* everyRender(modes = ["idle", "running", "card", "offline"]) {
for (const id of Object.keys(STATES)) {
for (const mode of modes) {
for (const tab of TAB_IDS) for (const panel of PANELS[tab]) yield { id, mode, tab, panel, r: draw(id, { mode, tab, panel }) };
}
}
}
test("git board view: no control leaks the busy lock, in any state, mode, tab or panel", () => {
let checked = 0;
for (const { id, mode, tab, panel, r } of everyRender()) {
const where = `${id} · ${mode} · ${tab} · ${panel}`;
const all = controls(r.node);
for (const c of all) {
const gate = c.attrs["data-gate"];
assert.ok(["nav", "action", "done"].includes(gate), `${where}: "${words(c)}" (${c.tag}) has no data-gate`);
const own = c.attrs["data-own"] === "true";
if (!controlAllowed(mode, gate)) assert.ok(isOff(c), `${where}: "${words(c)}" is live while busy`);
else assert.equal(isOff(c), own, `${where}: "${words(c)}" is ${isOff(c) ? "greyed with no reason of its own" : "live despite its own reason"}`);
checked++;
}
const done = all.filter((c) => c.textContent === "Done with git");
assert.equal(done.length, 1, `${where}: exactly one Done with git`);
assert.equal(!done[0].disabled, mode === "idle" || mode === "card", `${where}: Done with git live only while idle or a card waits`);
}
assert.ok(checked > 1000, "the guard looked at the board's controls");
});
test("git board view: every function of today's board is reachable on some tab", () => {
const texts = new Set();
const ids = { select: new Set(), input: new Set() };
const take = (r) => {
for (const c of controls(r.node)) {
texts.add(words(c));
if (c.id && ids[c.tag]) ids[c.tag].add(c.id);
}
};
for (const { r } of everyRender(["idle"])) take(r);
// A name that is taken offers Switch to it.
take(draw("cp-dirty", { tab: "branches", panel: "create", create: { ...seedCreate(STATES["cp-dirty"].git), name: "main" } }));
// Exact, except the labels that carry a count ("Commit 3 files", "Show all 179").
const has = (want, prefix = false) => [...texts].some((t) => t === want || (prefix && t.startsWith(`${want} `)));
for (const want of [
"Add to .gitignore", "Create branch", "New branch", "Create", "Switch", "Delete", "Choose which to clean up…",
"Refresh", "Pull", "Publish", "Open pull request", "Copy", "Abort the rebase", "Continue", "Done with git",
"Switch to it",
]) {
assert.ok(has(want), `"${want}" is drawn somewhere`);
}
for (const want of ["Commit", "Show all", "Clean up", "Push"]) assert.ok(has(want, true), `"${want} …" is drawn somewhere`);
for (const id of ["git-pr-base", "git-new-from", "git-new-type"]) assert.ok(ids.select.has(id), `select #${id}`);
for (const id of ["git-search", "git-new-desc", "git-new-name"]) assert.ok(ids.input.has(id), `input #${id}`);
for (const [id, s] of Object.entries(STATES)) {
const head = draw(id).node.children.find((c) => c.tag === "header");
if (s.git.head.branch) assert.ok(head.textContent.includes(s.git.head.branch), `${id}: the header names the branch`);
}
assert.ok(draw("e-no-remote").node.children[0].textContent.includes("git remote add origin <url>"));
});
test("git board view: pins on its source and on a few states", () => {
for (const word of ["document", "window", "querySelector", "getBoundingClientRect", ".style"]) {
assert.ok(!VIEW_SRC.includes(word), `git-board-view.js never names ${word}`);
}
const imports = [...VIEW_SRC.matchAll(/\bfrom\s+["']([^"']+)["']/g)].map((m) => m[1]);
assert.deepEqual(imports, ["./git-board.js"], "it imports only ./git-board.js");
assert.doesNotMatch(VIEW_SRC, /\bimport\s*\(/, "and nothing dynamically");
const conflict = controls(draw("pc-conflict").node).filter((c) => c.textContent.startsWith("Abort"));
assert.equal(conflict.length, 1, "mid-rebase, Abort is offered once");
const held = draw("e-held-only", { tab: "changes" });
const strip = walk(held.node).find((n) => n.classes.has("git-step"));
assert.ok(strip, "the step strip is on Changes");
assert.ok(walk(strip).find((n) => n.classes.has("git-held")).textContent.includes("`.env.local` held back"));
assert.ok(controls(strip).some((c) => c.textContent === "Add `.env.local` to .gitignore"), "the ignore offer is the secondary");
const away = draw("cp-dirty", { tab: "sync" });
const hint = walk(away.node).find((n) => n.classes.has("git-hint"));
assert.ok(hint, "a tab that does not own the step points at it");
assert.ok(hint.textContent.includes("Commit 3 files"));
assert.ok(hint.textContent.startsWith("Next step is on Changes:"));
});
const click = (n) => n.listeners.click.forEach((fn) => fn());
const stepButtons = (r) => controls(walk(r.node).find((n) => n.classes.has("git-step")));
test("git board view: each step's click goes out as the board offers it", () => {
const held = draw("e-held-only");
click(stepButtons(held).find((c) => c.textContent.startsWith("Add ")));
assert.deepEqual(held.on.calls, [["openPanel", "commit", { ignore: [".env.local"], ticks: [] }]]);
const unpublished = draw("nb-unpublished");
click(stepButtons(unpublished).find((c) => c.textContent === "Publish"));
assert.deepEqual(unpublished.on.calls, [["send", "publish", { remote: "origin" }]]);
const main = draw("nb-main-dirty");
const [branch, onMain] = stepButtons(main);
click(branch);
click(onMain);
assert.deepEqual(main.on.calls, [["openPanel", "create", { commit: true }], ["openPanel", "commit"]]);
const away = draw("pc-conflict", { tab: "changes" });
click(walk(away.node).find((n) => n.classes.has("git-hint")));
assert.deepEqual(away.on.calls, [["pickTab", "sync"]]);
const op = draw("pc-conflict");
const opButtons = controls(walk(op.node).find((n) => n.classes.has("git-op")));
opButtons.forEach(click);
assert.deepEqual(op.on.calls, [["send", "continue", {}, { operation: "rebase" }], ["send", "abort", {}, { operation: "rebase" }]]);
});
test("git board view: a .gitignore-only pick commits just .gitignore, and never on a detached HEAD", () => {
const ignoreHeld = (git) => ({ ...git, changes: STATES["e-held-only"].git.changes });
const opened = (git) => {
const step = nextStep(git, { now: NOW });
const board = { tab: "changes", panel: "commit", create: null, ticks: new Set(), ignore: new Set([".env.local"]), sweep: null, query: "", showAll: false, remoteOpen: null, base: null };
const h = fakeH();
const on = fakeOn();
const { node } = drawGitBoard({ git, board, now: NOW, mode: "idle", step, badges: tabBadges(git, { now: NOW, stepTab: step.tab }), notice: null, activity: null, h, on });
return { node, on };
};
const onMain = opened(STATES["e-held-only"].git);
const add = controls(onMain.node).find((c) => c.textContent === "Add 1 to .gitignore");
assert.ok(add && !add.disabled);
click(add);
assert.deepEqual(onMain.on.calls, [["send", "commit", { files: [], ignore: [".env.local"] }]]);
const detached = opened(ignoreHeld(STATES["e-detached"].git));
assert.ok(!controls(detached.node).some((c) => c.textContent === "Add 1 to .gitignore"), "no commit straight onto a detached HEAD");
const make = controls(detached.node).find((c) => c.textContent === "Create branch");
assert.ok(make && !make.disabled, "the branch comes first, .gitignore pick and all");
click(make);
assert.deepEqual(detached.on.calls, [["openPanel", "create", { commit: true, files: [], ignore: [".env.local"] }]]);
assert.equal(gitReply("commit", { files: [], ignore: [".env.local"] }), "Add .env.local to .gitignore and commit just .gitignore.");
assert.equal(
gitReply("create", { name: "fix/x", from: "a1b2c3d", then: "commit", files: [], ignore: [".env.local"] }),
"Create fix/x from a1b2c3d. Then add .env.local to .gitignore and commit just .gitignore."
);
assert.equal(gitReply("commit", { files: ["a.js"], ignore: ["dist/"] }), "Commit this file: a.js. Add dist/ to .gitignore.");
});
test("git board host: app.js draws the board only through drawGitBoard, and the server serves the view", () => {
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
for (const gone of ["gitActionBar", "gitBranches", "smallButton", "gitHeader", "gitCommitPanel"]) {
assert.ok(!app.includes(`function ${gone}(`), `app.js no longer defines ${gone}()`);
}
const drawCalls = [...app.matchAll(/\bdrawGitBoard\(/g)].length;
assert.equal(drawCalls, 1, "one call to drawGitBoard");
const host = app.slice(app.indexOf("function renderGitBoard("), app.indexOf("function rememberGitTabScroll("));
assert.ok(host.includes("drawGitBoard("), "renderGitBoard is the one that calls it");
const server = fs.readFileSync(new URL("../src/web-console/server.mjs", import.meta.url), "utf8");
const servable = server.slice(server.indexOf("const SERVABLE = new Set(["), server.indexOf("]);", server.indexOf("const SERVABLE = new Set([")));
assert.ok(servable.includes('"git-board-view.js"'), "SERVABLE includes git-board-view.js");
});
test("git board host: the always-on commit table keeps the person's ticks, and a click re-seeds them", () => {
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
const send = app.slice(app.indexOf("async function sendGit("), app.indexOf("const gitOn = {"));
assert.match(send, /board\.ticks = null;\s*board\.ignore = new Set\(\);/, "a click drops the old picks");
const commit = app.slice(app.indexOf("function openCommit("), app.indexOf("function openCleanup("));
assert.ok(!commit.includes("commitTicks("), "opening the panel never re-seeds over their ticks");
assert.ok(commit.includes("tablePicks(git)"), "a detached commit carries the table's picks");
const panel = app.slice(app.indexOf("function openPanel("), app.indexOf("const closePanel ="));
assert.match(panel, /opts\.commit && !opts\.files\) return openCreate\(git, \{ \.\.\.opts, \.\.\.tablePicks\(git\) \}\)/, "Start a branch takes what is ticked");
});
test("git board docs: the agent prose, Help topic and readme describe the tabbed board", () => {
const read = (p) => fs.readFileSync(new URL(p, import.meta.url), "utf8");
const notes = read("../src/web-console/notes/git.md");
const finishing = notes.slice(notes.indexOf("**Finishing**"));
assert.ok(finishing.includes("Done with git"), "notes/git.md Finishing names Done with git");
assert.ok(finishing.includes("cancel"), "notes/git.md Finishing cancels an open card");
assert.ok(!finishing.includes('"settle": ["<id>"]'), "the cancel rule never settles a card nothing was sent to");
assert.ok(notes.includes("`files[]` may be empty"), "notes/git.md allows a .gitignore-only commit");
assert.ok(read("../src/plan2code-git.md").includes("Done with git"), "plan2code-git.md names Done with git");
const html = read("../src/web-console/public/index.html");
const start = html.indexOf('<section class="help-panel" data-tab="git">');
const help = html.slice(start, html.indexOf("</section>", start));
for (const word of ["Changes", "Branches", "Sync", "Done with git"]) assert.ok(help.includes(word), `Help's git topic mentions ${word}`);
for (const old of ["one board", "one page"]) assert.ok(!help.includes(old), `Help's git topic no longer says "${old}"`);
assert.ok(!read("../.readme/web-console.md").includes("commits on one page"), "the readme no longer says commits on one page");
});
+7 -3
View File
@@ -327,7 +327,8 @@ test("git: the board stays locked from a click until the agent's next post, not
assert.equal(boardAwaiting({ sentAt, cardsAwaiting: 1, adrift: true }), false, "an agent gone quiet releases the lock");
const app = fs.readFileSync(new URL("../src/web-console/public/app.js", import.meta.url), "utf8");
assert.match(app, /const gitLocked = \(\) =>[^;]*gitAwaiting\(\)/, "gitLocked includes gitAwaiting()");
assert.match(app, /const gitMode = \(\) =>[^;]*gitAwaiting\(\)/, "the busy mode includes gitAwaiting()");
assert.match(app, /const gitLocked = \(\) => gitMode\(\) !== "idle";/, "gitLocked is anything but idle");
const send = app.slice(app.indexOf("async function sendGit("), app.indexOf("function renderGitBoard("));
assert.match(send, /local\.gitSentAt = Date\.now\(\);\s*save\(\);/, "a board click records when it was sent, and saves it");
assert.match(app, /sentAt: local\.gitSentAt[\s\S]{0,80}updatedAt: S\.updatedAt[\s\S]{0,80}cardsAwaiting: awaitingReply\(\)\.length/);
@@ -563,15 +564,18 @@ test("git board: the page draws it from git-board.js, with no inline styles", ()
const dir = path.join(path.dirname(CONSOLE_CLI), "public");
const app = fs.readFileSync(path.join(dir, "app.js"), "utf8");
const html = fs.readFileSync(path.join(dir, "index.html"), "utf8");
const view = fs.readFileSync(path.join(dir, "git-board-view.js"), "utf8");
assert.match(app, /^import [^;]+ from "\.\/git-board\.js";/m, "app.js imports git-board.js");
for (const m of ["git-board.js", "pr-url.js"]) assert.ok(html.includes(`rel="modulepreload" href="/${m}"`), `the page preloads ${m}`);
assert.match(app, /^import [^;]+ from "\.\/git-board-view\.js";/m, "app.js imports git-board-view.js");
for (const m of ["git-board.js", "git-board-view.js", "pr-url.js"]) assert.ok(html.includes(`rel="modulepreload" href="/${m}"`), `the page preloads ${m}`);
assert.match(app, /const isGitBoard = \(\) => S && S\.workflow === "git" && S\.git;/);
assert.match(app, /i: "__git", type: "git", op/, "a click is one __git action");
assert.match(app, /a\.rel = "noopener"/, "the PR link opens with rel=noopener");
assert.match(view, /a\.rel = "noopener"/, "the PR link opens with rel=noopener");
const start = app.indexOf("/* ------------------------------------------------------------ git board */");
const end = app.indexOf("/* ------------------------------------------------------------- welcome */");
assert.ok(start > 0 && end > start);
assert.doesNotMatch(app.slice(start, end), /setAttribute\(\s*["']style["']|\.style\./, "the board sets no inline styles");
assert.doesNotMatch(view, /setAttribute\(\s*["']style["']|\.style\./, "nor does its view");
});
// The board's every click is one `__git` action; the agent reads it off the
+6 -5
View File
@@ -220,11 +220,12 @@ test("a build's own count wins, 0 done included; a question workflow still fills
test("the git board: Publish names a remote only when there is one, and an open card holds the board", () => {
const js = app();
const action = js.slice(js.indexOf("function gitAction("), js.indexOf("/* The branch table */"));
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
const action = view.slice(view.indexOf("function runStep("), view.indexOf("function stepButton("));
assert.match(action, /remotes\.length === 1/);
const at = js.indexOf("const gitLocked = ");
const at = js.indexOf("const gitMode = ");
assert.match(js.slice(at, js.indexOf(";", at)), /myTurn\(\)\.some\(\(i\) => i\.kind !== "notice"\)/);
const banner = js.slice(js.indexOf("function gitOpBanner("), js.indexOf("function gitActionBar("));
const banner = view.slice(view.indexOf("function opBlock("), view.indexOf("function prBlock("));
assert.ok(!/if \(conflicted\.every/.test(banner), "Continue is always offered; plan continue checks the files itself");
});
@@ -343,7 +344,7 @@ test("keep names a copy from the upload's real path, so an 8.3 spelling reuses t
test("the cleanup confirm is red only when a gone branch holds commits found nowhere else", () => {
const src = fs.readFileSync(path.join(ROOT, "src", "plan2code-git-scripts", "git.mjs"), "utf8");
assert.match(src, /danger: x\.some\(\(b\) => deleteCheck\(s, localBranch\(s, b\)\)\.onlyHere\.count > 0\)/);
const js = app();
const groups = js.slice(js.indexOf("function cleanupGroups("), js.indexOf("function openCleanup("));
const rules = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board.js"), "utf8");
const groups = rules.slice(rules.indexOf("export function cleanupGroups("), rules.indexOf("export function boardActions("));
assert.match(groups, /b\.merged && !b\.gone/, "gone wins on the page too, as cleanup-list has it");
});
+12 -10
View File
@@ -550,7 +550,7 @@ test("a wait with nothing open leaves a working agent working", () => {
test("the git board lets go of a working agent that went adrift", () => {
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const at = js.indexOf("const gitLocked = ");
const at = js.indexOf("const gitMode = ");
const line = js.slice(at, js.indexOf(";", at));
assert.ok(line.includes("(agentWorking() && !agentAdrift())"), line);
});
@@ -649,8 +649,8 @@ test("a finish ends the working stretch, and resuming a pause starts a fresh one
test("a card with a note box over the git board flows at its own height, never shrunk under the board", () => {
const css = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.css"), "utf8");
const rule = css.slice(css.indexOf(".main:has(> .git-board) > .card,"), css.indexOf("{", css.indexOf(".main:has(> .git-board) > .card,")));
assert.ok(rule.includes(".main:has(> .git-board) > .card.is-primary.has-grow"), "the board's natural-height rule outranks .has-grow");
const rule = css.slice(css.indexOf(".git-cards > .card,"), css.indexOf("{", css.indexOf(".git-cards > .card,")));
assert.ok(rule.includes(".git-cards > .card.is-primary.has-grow"), "the board's natural-height rule outranks .has-grow");
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function markGrowBox("), js.indexOf("function naturalHeight("));
assert.ok(fn.includes("isGitBoard()"), "no box grows over the board");
@@ -668,16 +668,18 @@ test("long task lines, long words, a narrow board and a narrow Ask pane never wi
assert.match(rule(".main > .git-board"), /grid-template-columns: minmax\(0, 1fr\)/);
assert.match(rule(".git-table-wrap"), /overflow-x: auto/, "the branch table scrolls on its own");
assert.match(rule(".ask-actions"), /flex-wrap: wrap/, "the Ask pane's Send never clips");
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function branchTable("), js.indexOf("/* The panels */"));
assert.ok(fn.includes('el("div", "git-table-wrap")'), "branchTable wraps its table");
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
const fn = view.slice(view.indexOf("function branchTable("), view.indexOf("function createPanel("));
assert.ok(fn.includes('h.el("div", "git-table-wrap")'), "branchTable wraps its table");
});
test("over the git board a note box grows with its text, and the no-repo note only points above when a card is there", () => {
const css = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.css"), "utf8");
assert.match(css, /\.main:has\(> \.git-board\) > \.card textarea \{ field-sizing: content; max-height: 50vh; \}/);
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
const fn = js.slice(js.indexOf("function renderGitBoard("), js.indexOf("function rememberGitScroll("));
assert.ok(fn.includes('main.querySelector(":scope > .card")'), "the note checks for a card first");
assert.match(css, /\.git-cards > \.card textarea \{ field-sizing: content; max-height: 50vh; \}/);
const view = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "git-board-view.js"), "utf8");
const fn = view.slice(view.indexOf("export function drawGitBoard("), view.indexOf("function header("));
assert.ok(fn.includes("ctx.hasCard"), "the note checks for a card first");
assert.ok(fn.includes("will ask what to do here in a moment"));
const js = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "app.js"), "utf8");
assert.match(js, /hasCard: Boolean\(card\)/, "the host says whether a card is in the slot");
});
+12
View File
@@ -72,10 +72,22 @@ Never reset `[/]` to `[ ]`. Started work stays marked for conscious resume decis
| `choose` | Show a selection prompt listing each of `options` with its status. TIP: run another agent on a different phase simultaneously. Relay `warning` (all already `[/]`: duplicated work) when present. |
| `ask-resume` | Prompt: "Phase X is in progress. Resume? (yes/no)" Relay `warning` when present. |
| `auto-start` | Mark it `[/]` and begin. Relay `warning` when present. |
| `checkoff` | Every phase is approved but tasks in them are still open (manual steps, blockers). Never say "nothing left to do": run Manual Check-Off below. |
| `none` | Nothing to implement: say why (`reason`). Every phase complete → `/plan2code-4-finalize --web` |
After selection, `mark --to in-progress`, read `phase-X.md`, begin.
### Manual Check-Off
`next.tasks` lists each open task (`id`, `marker`, `text`, `detail` with any BLOCKED / User action note). The spec is not built, and Finalize stays unavailable on the dashboard, until each is `[x]`. Say so in one line, then ask about them **one at a time**, in order:
1. Show the task: id, `text`, and what `detail` says the person must do or check.
2. Ask: "Is this done? (yes / not yet)". Console: a `confirm` item (`yesLabel` "Done, check it off", `noLabel` "Not yet"), posted with `--wait`, a new id per task.
3. Yes → `node "<S>/specs.mjs" tick <spec> --task <id>` (writes `[x]` and a "Confirmed done by the user" line). Not yet → leave it as it stands. A note asking for help: help, then ask again.
4. Next task.
After the last one: `tick`'s `remaining` empty (`next` is `none`) → "NEXT STEP: Start NEW conversation and run: `/plan2code-4-finalize --web`". Otherwise list what is still open, say Finalize opens once they are checked off, and that rerunning Implement asks again. Never tick a task the person did not confirm.
## Code Consistency Rules
| Rule | Description |
+2 -2
View File
@@ -8,7 +8,7 @@ Careful git operator. Read where the repository stands, do what the person asks
## Interface
An instruction in the argument (`/plan2code-git switch to main`, `/plan2code-git commit and push`, a commit subject) runs in the terminal at once: do not ask about the console. With no argument, the FIRST thing you do, before anything else in this file, before reading the repository: ask **web console** (browser page, suggested) or **terminal**? Console → run `node "<D>/console.mjs" open --workflow git` before reading (<D>: references/web-console/ beside this SKILL.md, ~/.agents/skills/plan2code-git/references/web-console/ globally, or the dir in ~/.plan2code/console/console-dir), then read <D>/console.md and <D>/notes/git.md. Switchable anytime. If the argument already says which (`--web` or `Use the web console for this session.`) take it and do not ask; drop the flag. Launched by the dashboard, or by a **Commit it now** or Changelog hand-off? Its session is already open: resume it with `--workflow git` (console-launches.md). Handed off to commit (Commit it now, Changelog's yes): post `reread`, then run the Commit flow from step 1 over every changed file (risky ones left out and named), its cards above the board; afterwards the board is theirs with Push lit. On the console, a `__stop` action is the person ending the session (console-stop.md); at every session end post `finish` BEFORE `stop`.
An instruction in the argument (`/plan2code-git switch to main`, `/plan2code-git commit and push`, a commit subject) runs in the terminal at once: do not ask about the console. With no argument, the FIRST thing you do, before anything else in this file, before reading the repository: ask **web console** (browser page, suggested) or **terminal**? Console → run `node "<D>/console.mjs" open --workflow git` before reading (<D>: references/web-console/ beside this SKILL.md, ~/.agents/skills/plan2code-git/references/web-console/ globally, or the dir in ~/.plan2code/console/console-dir), then read <D>/console.md and <D>/notes/git.md. Switchable anytime. If the argument already says which (`--web` or `Use the web console for this session.`) take it and do not ask; drop the flag. Launched by the dashboard, or by a **Commit it now** or Changelog hand-off? Its session is already open: resume it with `--workflow git` (console-launches.md). Handed off to commit (Commit it now, Changelog's yes): post `reread`, then run the Commit flow from step 1 over every changed file (risky ones left out and named), its cards on the board; afterwards the board is theirs with Push lit. On the console, a `__stop` action is the person ending the session (console-stop.md); at every session end post `finish` BEFORE `stop`.
## Project context
@@ -74,7 +74,7 @@ On a non-zero exit, save git's stderr to the session folder, run `classify-error
- **commit** commits only the paths in `files`. With `ignore[]`, first propose those `.gitignore` lines as a doc plus a `review` card (approve / change), write them on approve, and add `.gitignore` to the commit.
- **abort**, **continue**: `plan abort` / `plan continue`, then `reread`.
- **pr-host**: the server already saved the answer; post `reread` only.
- **done**: Session End.
- **done** (Done with git): Session End; a card of yours still open is cancelled first (notes/git.md).
- Deleting a branch on the remote is never offered and never run.
## Conflict help
+94 -9
View File
@@ -6,7 +6,8 @@
// a spec's PLAN-DRAFT says, which phases are open, how many tasks are done.
// Those have one correct answer, so this script computes them instead of each
// prompt re-deriving them by hand. It also performs the two mechanical writes
// (a Phase Checklist marker, the archive move), with --dry-run.
// (a Phase Checklist marker, a task the user confirmed, the archive move),
// with --dry-run.
//
// Shell listing only matters to people: specs/ is gitignored, so editor search
// tools skip it. This script reads the disk directly and does not care.
@@ -26,7 +27,8 @@ specs.mjs: spec state for the Plan2Code pipeline skills. JSON on stdout.
node specs.mjs status <spec> [--root <dir>]
One spec in full: the overview's Phase Checklist, Parallel Execution
Groups, per-phase task counts by marker, task-numbering problems,
completion, the implement phase-selection verdict ("next"), the pending
completion, the implement phase-selection verdict ("next": choose,
ask-resume, auto-start, checkoff or none), the pending
phases, and consistency checks. <spec> is specs/<name>, <name>, or a path
to its overview.md.
@@ -49,6 +51,13 @@ specs.mjs: spec state for the Plan2Code pipeline skills. JSON on stdout.
Status line. Refuses a phase with duplicate checklist rows, and refuses
in-progress -> open (started work stays marked).
node specs.mjs tick <spec> --task <N.M> [--dry-run]
Check off one task the user confirmed is done: its marker becomes [x]
and a "> Confirmed done by the user on <date>." line goes under it.
Prints the tasks still open under approved phases ("remaining") and the
new phase-selection verdict ("next"). For the manual steps that
status's "checkoff" verdict lists.
node specs.mjs archive <spec> [--dry-run]
Move specs/<name>/ to specs--completed/<name>/. Refuses if the target
exists, or if <spec> is not a folder directly under specs/.
@@ -206,6 +215,21 @@ function firstSentence(text) {
return (m ? m[1] : t).slice(0, 240);
}
// The lines under a task (its file path, notes, a BLOCKED / User action
// blockquote), up to the next heading or checkbox: what a person needs to
// judge whether a task they are asked about is done. taskBody is the index
// just past its last non-blank line.
function taskBody(lines, i) {
let end = i + 1;
while (end < lines.length && !/^#{1,6}\s/.test(lines[end]) && !CHECKBOX_RE.test(lines[end])) end++;
while (end > i + 1 && !lines[end - 1].trim()) end--;
return end;
}
function taskDetail(lines, i) {
return lines.slice(i + 1, taskBody(lines, i)).map((l) => l.trim()).filter(Boolean).join("\n").slice(0, 800);
}
function parsePhaseFile(file, number) {
const text = readText(file) || "";
const lines = text.split(/\r?\n/);
@@ -224,7 +248,8 @@ function parsePhaseFile(file, number) {
const state = MARKERS[t[1]] || "unknown";
counts[state]++;
const named = !/^\d+$/.test(t[3]);
tasks.push({ id: `${t[2]}.${t[3]}${t[4]}`, phase: Number(t[2]), seq: named ? null : Number(t[3]), named, suffix: t[4], marker: t[1], state, line: i + 1 });
const said = plainText(line.slice(t[0].length)).replace(/^:\s*/, "").slice(0, 240);
tasks.push({ id: `${t[2]}.${t[3]}${t[4]}`, phase: Number(t[2]), seq: named ? null : Number(t[3]), named, suffix: t[4], marker: t[1], state, line: i + 1, text: said, detail: taskDetail(lines, i) });
return;
}
// A line that looks like a task but is not counted as one (Task 1.4A,
@@ -306,6 +331,10 @@ function specStatus(spec) {
}
const phases = [];
// Tasks still open under a phase the user already approved: the manual
// steps an agent could not do (blocked [!]) or left unticked. Nothing is left
// to build, but the spec is not built until someone checks them off.
const leftovers = [];
const numbers = new Set([...checklist.phases.map((p) => p.number), ...files.keys()]);
for (const number of [...numbers].sort((a, b) => a - b)) {
const row = checklist.phases.find((p) => p.number === number) || null;
@@ -339,6 +368,11 @@ function specStatus(spec) {
}
const done = parsed.counts.complete + parsed.counts.assumed;
const rowDone = row && (row.state === "complete" || row.state === "assumed");
if (rowDone) {
for (const t of parsed.tasks.filter((t) => ["pending", "in-progress", "blocked", "unknown"].includes(t.state))) {
leftovers.push({ phase: number, id: t.id, marker: `[${t.marker}]`, state: t.state, file: `${spec.rel}/${file}`, line: t.line, text: t.text, detail: t.detail });
}
}
// A phase may be approved with blocked [!] tasks left (Implementation
// Mode's self-review allows "[x] or blocked [!]"); only unfinished work is an error.
if (rowDone && parsed.unfinished > 0) {
@@ -382,7 +416,7 @@ function specStatus(spec) {
totals: { ...totals, completed, incomplete: totals.pending + totals["in-progress"] + totals.unknown },
completion: completion === null ? null : Number(completion.toFixed(4)),
completionPercent: completion === null ? null : Math.round(completion * 100),
next: nextPhase(phases, groups.groups, checklist.found),
next: nextPhase(phases, groups.groups, checklist.found, leftovers),
pending: phases
.filter((p) => p.checklist && p.checklist !== "complete" && p.checklist !== "assumed")
.map((p) => ({ number: p.number, name: p.name, state: p.checklist, tasks: p.tasks ? p.tasks.total : null, open: p.tasks ? p.tasks.open : null, goal: p.goal })),
@@ -393,14 +427,24 @@ function specStatus(spec) {
/**
* Implementation Mode's phase-selection table, applied mechanically.
* 2+ workable phases in the same parallel group, consecutive -> choose (warn if all [/])
* a single [/] -> ask-resume · a single [ ] -> auto-start · nothing workable -> none
* a single [/] -> ask-resume · a single [ ] -> auto-start
* nothing workable, every phase approved, tasks still open in them -> checkoff
* nothing workable otherwise -> none
*/
function nextPhase(phases, groups, haveChecklist) {
function nextPhase(phases, groups, haveChecklist, leftovers = []) {
if (!haveChecklist) return { action: "none", reason: "no Phase Checklist in overview.md" };
const ordered = phases.filter((p) => p.checklist);
const isDone = (p) => p.checklist === "complete" || p.checklist === "assumed";
const workable = ordered.filter((p) => p.checklist === "pending" || p.checklist === "in-progress");
if (!workable.length) {
if (ordered.length && ordered.every(isDone) && leftovers.length) {
const n = leftovers.length;
return {
action: "checkoff",
reason: `every phase is approved, but ${n} task${n === 1 ? " is" : "s are"} still open in them (${leftovers.map((t) => t.id).join(", ")}); the spec is not built until ${n === 1 ? "it is" : "they are"} checked off`,
tasks: leftovers,
};
}
return { action: "none", reason: ordered.length && ordered.every(isDone) ? "every phase is complete" : "no [ ] or [/] phase in the Phase Checklist" };
}
const first = workable[0];
@@ -611,6 +655,47 @@ async function cmdMark(args) {
});
}
// Check off one task the user confirmed is done (a manual step left open under
// an approved phase). The marker changes, and one line under the task says who
// confirmed it, so the file never claims the agent verified it.
async function cmdTick(args) {
const root = path.resolve(args.root || ".");
const spec = resolveSpec(root, args._[1]);
const id = String(args.task || "");
const m = id.match(/^(\d+)\.(\d+|[A-Za-z]+)([a-z]*)$/);
if (!m) fail(EXIT.USAGE, "bad-task", "--task needs a task id.", "Example: --task 2.3");
const number = Number(m[1]);
const file = phaseFiles(spec.dir).get(number);
if (!file) fail(EXIT.NOT_FOUND, "no-phase-file", `${spec.rel} has no phase-${number}.md.`, "Run `specs.mjs status` to see the phases.");
const phasePath = path.join(spec.dir, file);
const text = readText(phasePath) || "";
const hits = parsePhaseFile(phasePath, number).tasks.filter((t) => t.id === id);
if (!hits.length) fail(EXIT.NOT_FOUND, "no-task", `${file} has no Task ${id}.`, "Use an id from `specs.mjs status` (next.tasks).");
if (hits.length > 1) fail(EXIT.REFUSED, "duplicate-task", `Task ${id} appears ${hits.length} times in ${file} (lines ${hits.map((t) => t.line).join(", ")}); ticking one would be a guess.`, "Renumber the duplicate, then rerun.");
const task = hits[0];
const changes = [];
if (task.state !== "complete") {
const lines = text.split(/\r?\n/);
const idx = task.line - 1;
lines[idx] = lines[idx].replace(/\[(.)\]/, "[x]");
const indent = `${(lines[idx].match(/^\s*/) || [""])[0]} `;
lines.splice(taskBody(lines, idx), 0, `${indent}> Confirmed done by the user on ${isoDate()}.`);
changes.push({ file: `${spec.rel}/${file}`, line: task.line, from: `[${task.marker}]`, to: "[x]" });
if (!args["dry-run"]) fs.writeFileSync(phasePath, lines.join(eol(text)));
}
const after = args["dry-run"] ? null : specStatus(spec);
out({
ok: true,
spec: spec.rel,
task: id,
phase: number,
dryRun: !!args["dry-run"],
changed: changes.length > 0,
changes,
...(after ? { remaining: after.next.action === "checkoff" ? after.next.tasks.map((t) => t.id) : [], next: after.next.action } : {}),
});
}
function listRel(dir, base = dir) {
const outList = [];
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
@@ -668,9 +753,9 @@ async function cmdArchive(args) {
}
run(USAGE, async (argv) => {
const args = parseArgs(argv, { booleans: ["dry-run"], values: ["root", "step", "phase", "to"], lists: ["set"] });
const args = parseArgs(argv, { booleans: ["dry-run"], values: ["root", "step", "phase", "to", "task"], lists: ["set"] });
const cmd = args._[0];
const commands = { list: cmdList, status: cmdStatus, metrics: cmdMetrics, mark: cmdMark, archive: cmdArchive };
if (!commands[cmd]) fail(EXIT.USAGE, "unknown-command", cmd ? `Unknown command "${cmd}".` : "No command given.", "Commands: list, status, metrics, mark, archive. Run with --help.");
const commands = { list: cmdList, status: cmdStatus, metrics: cmdMetrics, mark: cmdMark, tick: cmdTick, archive: cmdArchive };
if (!commands[cmd]) fail(EXIT.USAGE, "unknown-command", cmd ? `Unknown command "${cmd}".` : "No command given.", "Commands: list, status, metrics, mark, tick, archive. Run with --help.");
await commands[cmd](args);
});
+17 -12
View File
@@ -6,8 +6,8 @@ Open with `--workflow git` (launched from the dashboard, or by a **Commit it
now** or Changelog hand-off: resume the session instead). Like the dashboard,
the main column is drawn by the page itself: the git board, from `state.git`,
which `open` and every `reread` snapshot through `git-repo.mjs`. **You never
post `git`** (exit 3: `state.git` is the console's own). Your cards sit above
the board in the usual card slot.
post `git`** (exit 3: `state.git` is the console's own). Your cards sit in
the board's card slot, under its tab strip.
**A click** arrives as one session action, one per send, and the board locks
until your next post lands:
@@ -27,7 +27,7 @@ until your next post lands:
| `switch`, `delete` | `branch` (a remote-only row is `<remote>/<name>`) |
| `create` | `name`, `from`; `then: "commit"` with `files` (and `ignore`, when any) when it came from the commit panel's branch offer |
| `cleanup` | `branches[]` |
| `commit` | `files[]` (paths and untracked folders), `ignore[]` (folders to add to `.gitignore`) |
| `commit` | `files[]` (paths and untracked folders), `ignore[]` (folders to add to `.gitignore`). `files[]` may be empty when `ignore[]` is not: the board's held-back offer (**Add … to .gitignore**). Then add the paths to `.gitignore` and commit only `.gitignore`. |
| `pr-host` | `host`, `kind` (already saved by the page's `POST /pr-host`) |
`reply` is the plain instruction the terminal would get, so it reads like any
@@ -108,12 +108,17 @@ Post `run: { "event": "git-commits", "id": "<first short hash>", "commits": N }`
after each commit step (N commits made), and `run: { "event": "git-conflict",
"id": "conflict-<n>" }` once per conflict help, resolved or aborted.
**Finishing** (`console-finish.md`). Done (`op: "done"`) with something done
this session: a `finish` with a headline, the commits with hashes, pushes and
branches created or deleted in `body`, no `command`, and `"dashboard": true`;
keep waiting for the press. Done with nothing done: no finish screen — resume
as `dashboard` at once (`open --resume <sid> --no-open --workflow dashboard`),
read the dashboard skill (`~/.agents/skills/plan2code/SKILL.md`), post its
`menu` with `--wait` and carry on from its "Coming back from another skill". A
stop's finish is a pause, headline "Paused …", the bare `/plan2code-git`,
then `stop`.
**Finishing** (`console-finish.md`). **Done with git** (`op: "done"`). A `done`
that arrives while one of your cards is still open is the person cancelling it:
record that card as cancelled (`{ "items": [{ "id": "<id>", "status":
"answered", "answer": { "text": "Cancelled by Done with git" } }] }`, not
`settle`, which refuses a card nothing was sent to) in the same post as the
finish, or, with nothing done, before resuming as the dashboard. Never run what
the card was asking for. With something done this session: a `finish` with a
headline, the commits with hashes, pushes and branches created or deleted in
`body`, no `command`, and `"dashboard": true`; keep waiting for the press. Done
with nothing done: no finish screen — resume as `dashboard` at once (`open
--resume <sid> --no-open --workflow dashboard`), read the dashboard skill
(`~/.agents/skills/plan2code/SKILL.md`), post its `menu` with `--wait` and
carry on from its "Coming back from another skill". A stop's finish is a pause,
headline "Paused …", the bare `/plan2code-git`, then `stop`.
+25
View File
@@ -139,6 +139,31 @@ own (`building-review.md`).
---
## Manual check-off (`next.action` is `checkoff`)
No phase to build: the open tasks under approved phases are asked about one
at a time, one `confirm` item each, posted with `--wait`:
```jsonc
{
"headline": { "stage": "Manual check-off", "cleared": 0, "total": 2 },
"items": [{
"id": "checkoff-3.4", "kind": "confirm", "title": "Task 3.4",
"body": "**Configure the SSO app in Okta**\n\nBLOCKED: needs admin access. User action: create the app and paste its client id into `.env`.\n\nIs this done?",
"yesLabel": "Done, check it off", "noLabel": "Not yet"
}]
}
```
`yes` → `specs.mjs tick`, then `"headline": { "cleared": N }` with the next
item. When the last one is answered, post the finish: `command` is
`/plan2code-4-finalize specs/<feature>/overview.md` when `tick` said
`remaining` is empty, otherwise the same `/plan2code-3-implement` command,
and `body` lists what is still open. No `run` (nothing was built), no
`commit` unless a body prints one.
---
## Implement + Review (`implement-review`)
The same build, then Stage 2 publishes the findings exactly as
+1 -1
View File
@@ -686,7 +686,7 @@ export const SKILL_CATALOG = [
group: "extra",
chip: "Utility",
title: "Handoff",
blurb: "Pack this conversation into a document a fresh session can pick up cold.",
blurb: "Pack the current session into a document a fresh session can pick up cold.",
about:
"Writes down everything a new session would need, as a single document: what was decided, what is done, what is left. Use it when a conversation got long, a machine changed, or tomorrow-you deserves the context today-you has.",
},
+113 -29
View File
@@ -959,8 +959,8 @@ h1 {
}
/* 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. */
exception, below: its card sits in the board's card slot, so the column
takes the scroll there and card and board 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
@@ -3652,9 +3652,9 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
/* ------------------------------------------------------------ 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
/* The git workflow's main column holds the board, and the agent's card sits
inside it, in the card slot under the tab strip. A card that scrolled inside
a scrolling board 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;
@@ -3664,17 +3664,17 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
/* 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,
.git-cards > .card,
.git-cards > .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; }
/* In the board's card slot 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. */
.git-cards > .card textarea { field-sizing: content; max-height: 50vh; }
.main > .git-board {
padding-right: 32px;
display: grid;
@@ -3684,8 +3684,98 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
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. */
/* The board is sized by its column, not the window: the narrow layout keys
off the board's own width. */
.git-board { container-type: inline-size; container-name: git-board; }
/* Plan2Code's card, between the tab strip and the tab's content. */
.git-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.git-cards:empty { display: none; }
/* The tab strip: three tabs, Done with git on the right. */
.git-tab-bar {
display: flex;
align-items: flex-end;
gap: 8px;
border-bottom: 1px solid var(--rule);
}
.git-tabs { display: flex; gap: 2px; }
.git-tab {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 14px;
border: 0;
border-bottom: 3px solid transparent;
border-radius: 6px 6px 0 0;
background: transparent;
color: var(--ink-2);
font: inherit;
font-size: 14px;
cursor: pointer;
}
.git-tab:hover { background: var(--panel-2); color: var(--ink); }
.git-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.git-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.git-tab-badge {
min-width: 18px;
padding: 0 6px;
border: 1px solid var(--rule-2);
border-radius: 999px;
font-family: var(--mono);
font-size: 11.5px;
line-height: 17px;
text-align: center;
color: var(--ink-2);
}
.git-tab-badge.is-dot { min-width: 0; font-weight: 700; }
.git-tab-badge.is-warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.git-tab-badge.is-next { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.git-tab-badge.is-warn.is-next { color: var(--accent-ink); background: var(--warn); border-color: var(--warn); }
.git-done { margin: 0 0 6px auto; }
/* The next step: one primary button, at most one quieter one. */
.git-step {
display: grid;
gap: 6px;
padding: 14px 18px;
background: var(--panel);
border: 1px solid var(--accent-line);
border-left-width: 4px;
border-radius: var(--radius);
}
.git-step.is-warn { border-color: var(--stage); background: var(--stage-soft); }
.git-step.is-calm { border-color: var(--ok); background: var(--ok-soft); }
.git-step-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.git-step.is-calm .git-step-kicker { color: var(--ok); }
.git-step-title, .git-op-title { margin: 0; font: 600 18px/1.25 var(--serif); }
.git-step-why, .git-step-label { margin: 0; font-size: 14px; color: var(--ink-2); }
.git-step-label { font-weight: 600; color: var(--ink); }
.git-step-actions, .git-sync-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.git-hint {
justify-self: start;
padding: 8px 12px;
border: 1px dashed var(--accent-line);
border-radius: var(--radius);
background: transparent;
color: var(--accent);
font: inherit;
font-size: 14px;
cursor: pointer;
}
.git-hint:hover { background: var(--accent-soft); }
.git-hint:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.git-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 13.5px; color: var(--stage); }
.git-held { font-size: 13.5px; color: var(--ink-2); }
.git-held .md-p { margin: 0; }
.git-wait { margin: 0; font-size: 13.5px; color: var(--stage); }
.git-fresh { margin: 0; font-size: 13px; color: var(--ink-3); }
.git-fresh.is-stale { color: var(--stage); }
.git-panel-tab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.git-changes, .git-sync { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.git-sweep-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--ink-2); }
.git-pr-open.is-disabled { opacity: 0.5; cursor: not-allowed; }
/* The board's header is a section lead, not a card: the framed elements are
the agent's card in the slot and the next step under it. */
.git-head {
display: grid;
gap: 6px;
@@ -3735,22 +3825,6 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
.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;
@@ -3811,3 +3885,13 @@ a.icon-btn { box-sizing: border-box; text-decoration: none; }
.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); }
/* Last on purpose: the narrow layout overrides the board rules above it. */
@container git-board (max-width: 720px) {
.git-tab-bar { flex-wrap: wrap; }
.git-tabs { flex-wrap: wrap; }
.git-done { margin: 0 0 6px; }
.git-head-meta { flex-direction: column; align-items: flex-start; }
.git-step-actions, .git-sync-actions, .git-op-actions, .git-panel-actions { flex-wrap: wrap; }
.git-step-actions .btn, .git-op-actions .btn { flex: 1 1 auto; }
}
File diff suppressed because it is too large. Load diff
+902
View File
@@ -0,0 +1,902 @@
// Plan2Code Web Console - the tabbed git board's drawing.
//
// drawGitBoard(ctx) builds the whole board -- header, tab strip, card slot,
// step strip and the Changes, Branches and Sync bodies -- from what
// git-board.js decides and what the host hands it. It decides nothing new:
// a rule belongs in git-board.js, a click goes out through ctx.on.
//
// No DOM access: every node comes from `ctx.h` (el, md, copyButton); the page
// and `node --test` both import this file. On what h.el returns, the view uses
// only: appendChild, append, replaceChildren, setAttribute, removeAttribute,
// addEventListener, classList.add/remove/toggle, and the properties
// className, id, type, value, checked, disabled, textContent, placeholder,
// title, open, href, target, rel, tabIndex. Text runs are h.el("span", null, text).
//
// Every button, input and select is made through control(), which greys it
// out whenever controlAllowed(mode, role) says no and stamps data-gate with
// its role; one disabled for a reason of the view's own also carries
// data-own. The guard test in scripts/test-web-console-git-board.mjs holds
// every control to that.
import {
BRANCH_TYPES,
GIT_TABS,
PR_HOST_LABELS,
boardActions,
boardPrLink,
cleanupGroups,
commitTicks,
composeBranchName,
controlAllowed,
createSources,
currentRow,
filterBranches,
foldRemote,
nameStatus,
orderBranches,
refreshedLine,
relativeAge,
} from "./git-board.js";
const OP_WORDS = { rebase: "A rebase", am: "A git am", merge: "A merge", "cherry-pick": "A cherry-pick", revert: "A revert" };
const TAB_IDS = new Set(GIT_TABS.map((t) => t.id));
const list = (v) => (Array.isArray(v) ? v : []);
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
const opName = (op) => (op === "am" ? "git am" : op || "operation");
/* ------------------------------------------------------------ the gate */
// The one way the view makes an interactive control. `disabled` is the view's
// own reason (mid-operation, nothing ticked, a name that is taken); the busy
// gate is applied on top of it, always.
function control(ctx, tag, className, label, { role = "action", onClick, onInput, onChange, disabled = false, title } = {}) {
const node = ctx.h.el(tag, className, label);
if (tag === "button") node.type = "button";
node.disabled = Boolean(disabled) || !controlAllowed(ctx.mode, role);
node.setAttribute("data-gate", role);
if (disabled) node.setAttribute("data-own", "true");
if (title) node.title = title;
if (onClick) node.addEventListener("click", onClick);
if (onInput) node.addEventListener("input", onInput);
if (onChange) node.addEventListener("change", onChange);
return node;
}
// A copy button is a control like any other: greyed while busy.
function copy(ctx, text, cls, codeEl) {
const b = ctx.h.copyButton(text, cls, codeEl);
b.setAttribute("data-gate", "action");
b.disabled = !controlAllowed(ctx.mode, "action");
return b;
}
// "Open pull request": a link while it can open, an inert look-alike while busy.
function prLink(ctx, url, cls = "btn small primary") {
const label = "Open pull request";
if (!controlAllowed(ctx.mode, "action")) {
const span = ctx.h.el("span", `${cls} git-pr-open is-disabled`, label);
span.setAttribute("aria-disabled", "true");
span.setAttribute("data-gate", "action");
return span;
}
const a = ctx.h.el("a", `${cls} git-pr-open`, label);
if (typeof url === "string" && /^https:\/\//i.test(url)) a.href = url;
a.target = "_blank";
a.rel = "noopener";
a.setAttribute("data-gate", "action");
return a;
}
/* ------------------------------------------------------------ the board */
/** The tab to draw: the remembered one when it is a real tab, else the one owning the next step. */
export function activeTab(ctx) {
const tab = ctx.board && ctx.board.tab;
return TAB_IDS.has(tab) ? tab : ctx.step.tab;
}
/**
* The whole board: `{ node, cardSlot }`. `node` is div.git-board holding the
* header, the result line, the tab strip, `cardSlot` (empty, for the host's
* cards) and the active tab's panel.
*/
export function drawGitBoard(ctx) {
const { git, h } = ctx;
const node = h.el("div", "git-board");
const cardSlot = h.el("div", "git-cards");
if (git.error) {
node.appendChild(cardSlot);
const warn = h.el("div", "git-warn", git.error);
warn.setAttribute("role", "alert");
node.appendChild(warn);
return { node, cardSlot };
}
if (git.repo === false) {
// "Above" only once there is a card above: before the agent's first post
// the slot is empty, and the note would point at nothing.
node.appendChild(cardSlot);
node.appendChild(
h.el(
"p",
"git-note",
ctx.hasCard
? "This folder is not a git repository yet, so there is no board. Plan2Code asks above what to do."
: "This folder is not a git repository yet, so there is no board. Plan2Code will ask what to do here in a moment."
)
);
return { node, cardSlot };
}
const tab = activeTab(ctx);
node.appendChild(header(ctx));
if (ctx.notice) node.appendChild(resultLine(ctx, ctx.notice));
node.appendChild(tabStrip(ctx, tab));
node.appendChild(cardSlot);
node.appendChild(tabPanel(ctx, tab));
return { node, cardSlot };
}
/* -------------------------------------------------------------- header */
function header(ctx) {
const { git, h } = ctx;
const head = git.head || {};
const remotes = list(git.remotes);
const cur = currentRow(git);
const box = h.el("header", "git-head");
const row = h.el("div", "git-head-row");
// Mid-rebase HEAD is detached, but the person is still on their branch.
const title = head.branch || (head.rebasing ? `${head.rebasing} · rebasing` : `Not on a branch (at ${head.detached || "an unknown commit"})`);
row.appendChild(h.el("h2", "git-branch", title));
if (head.branch) {
row.appendChild(
h.el("span", "git-track", head.upstream && head.gone ? "remote copy deleted" : head.upstream ? `↑${head.ahead || 0} ↓${head.behind || 0}` : "not published")
);
if (remotes.length > 1 && cur && cur.upstreamRemote) row.appendChild(h.el("span", "badge", cur.upstreamRemote));
}
box.appendChild(row);
const meta = h.el("div", "git-head-meta");
if (!remotes.length) {
meta.appendChild(h.el("span", "git-noremote", "No remote"));
const cmd = "git remote add origin <url>";
const code = h.el("code", "md-code", cmd);
meta.appendChild(code);
meta.appendChild(copy(ctx, cmd, "btn small", code));
} else meta.appendChild(h.el("span", "git-refreshed", refreshedLine(git, ctx.now)));
if (ctx.mode === "running" && ctx.activity) meta.appendChild(h.el("span", "git-activity", ctx.activity));
box.appendChild(meta);
return box;
}
function resultLine(ctx, notice) {
const box = ctx.h.el("div", "git-result");
box.setAttribute("role", "status");
if (notice.title) box.appendChild(ctx.h.el("strong", "git-result-title", notice.title));
if (notice.body) box.appendChild(ctx.h.md(notice.body, "md git-result-body"));
return box;
}
/* ----------------------------------------------------------- tab strip */
function tabStrip(ctx, active) {
const { h } = ctx;
const bar = h.el("div", "git-tab-bar");
const strip = h.el("div", "git-tabs");
strip.setAttribute("role", "tablist");
strip.setAttribute("aria-label", "Git board");
for (const t of GIT_TABS) {
const on = t.id === active;
const b = control(ctx, "button", "git-tab" + (on ? " is-active" : ""), null, { role: "nav", onClick: () => ctx.on.pickTab(t.id) });
b.setAttribute("role", "tab");
b.id = `git-tab-${t.id}`;
b.setAttribute("aria-controls", `git-panel-${t.id}`);
b.setAttribute("aria-selected", on ? "true" : "false");
b.tabIndex = on ? 0 : -1;
b.appendChild(h.el("span", "git-tab-label", t.label));
const badge = ctx.badges && ctx.badges[t.id];
if (badge) {
b.appendChild(h.el("span", `git-tab-badge is-${badge.kind}${badge.next ? " is-next" : ""}`, badge.text));
if (badge.label) b.setAttribute("aria-label", `${t.label}, ${badge.label}`);
}
strip.appendChild(b);
}
bar.appendChild(strip);
const done = control(ctx, "button", "btn small git-done", "Done with git", { role: "done", onClick: () => ctx.on.send("done") });
if (ctx.mode === "offline") done.title = ctx.offlineReason === "pending" ? "Your last click is still being picked up." : "Not connected right now.";
bar.appendChild(done);
return bar;
}
/* ---------------------------------------------------------- tab panels */
function tabPanel(ctx, id) {
const panel = ctx.h.el("section", "git-panel-tab");
panel.setAttribute("role", "tabpanel");
panel.id = `git-panel-${id}`;
panel.setAttribute("aria-labelledby", `git-tab-${id}`);
const strip = stepStrip(ctx, id);
if (strip) panel.appendChild(strip);
panel.appendChild(id === "changes" ? changesBody(ctx) : id === "branches" ? branchesBody(ctx) : syncBody(ctx));
return panel;
}
/* ---------------------------------------------------------- step strip */
// One step's click, as the board offers it.
function runStep(ctx, s) {
const { git, on } = ctx;
switch (s.op) {
case "commit":
return on.openPanel("commit");
case "create-commit":
return on.openPanel("create", { commit: true });
case "create":
return on.openPanel("create");
case "cleanup":
return on.openPanel("cleanup");
// No ignore op exists: the commit panel opens with nothing ticked and the
// held-back paths set to Add to .gitignore, and its button sends `commit`.
case "ignore":
return on.openPanel("commit", { ignore: list(s.files), ticks: [] });
case "fix":
return on.pickTab("sync");
case "publish": {
// Named only when there is one to name: with two or more, the agent's
// `plan publish` asks which.
const remotes = list(git.remotes);
return on.send("publish", remotes.length === 1 && remotes[0].name ? { remote: remotes[0].name } : {});
}
default:
return on.send(s.op, {}, { operation: git.inProgress });
}
}
function stepButton(ctx, s, cls) {
if (s.op === "pr") return prLink(ctx, s.url, cls);
return control(ctx, "button", cls, s.label, { onClick: () => runStep(ctx, s) });
}
function stepStrip(ctx, id) {
const { git, h, step } = ctx;
const p = step.primary;
if (id !== step.tab) {
if (!p) return null;
const where = GIT_TABS.find((t) => t.id === step.tab);
return control(ctx, "button", "git-hint", `Next step is on ${where ? where.label : step.tab}: ${p.label} →`, {
role: "nav",
onClick: () => ctx.on.pickTab(step.tab),
});
}
// Mid-operation, Sync's own block is the step (syncBody).
if (id === "sync" && git.inProgress) return null;
const box = h.el("div", "git-step" + (git.inProgress ? " is-warn" : "") + (p ? "" : " is-calm"));
box.appendChild(h.el("div", "git-step-kicker", p ? "Next step" : "Nothing to do"));
box.appendChild(h.el("h3", "git-step-title", p ? p.label : step.line));
if (p && p.why) box.appendChild(h.el("p", "git-step-why", p.why));
if (step.stale) box.appendChild(staleLine(ctx, step.stale));
if (step.held) {
const held = h.el("div", "git-held");
held.appendChild(h.md(step.held, "md git-held-body"));
box.appendChild(held);
}
if (ctx.mode === "running") {
box.appendChild(h.el("p", "git-activity", ctx.activity || "Plan2Code is working on it."));
return box;
}
const actions = h.el("div", "git-step-actions");
if (p) {
actions.appendChild(stepButton(ctx, p, "btn primary"));
const second = step.secondary[0];
if (second) actions.appendChild(stepButton(ctx, second, "btn ghost"));
} else {
for (const s of step.secondary) actions.appendChild(stepButton(ctx, s, "btn small"));
}
box.appendChild(actions);
return box;
}
// "Checked 3 hr. ago — Refresh?", its Refresh word a button.
function staleLine(ctx, text) {
const line = ctx.h.el("p", "git-stale");
const word = "Refresh?";
line.appendChild(ctx.h.el("span", null, text.endsWith(word) ? text.slice(0, -word.length) : `${text} `));
line.appendChild(control(ctx, "button", "btn small ghost git-stale-refresh", word, { onClick: () => ctx.on.send("refresh") }));
return line;
}
/* -------------------------------------------------------------- panels */
function panelFrame(ctx, title, { closable = true, disabled = false } = {}) {
const p = ctx.h.el("section", "git-panel");
const head = ctx.h.el("div", "git-panel-head");
head.appendChild(ctx.h.el("h3", "git-panel-title", title));
if (closable) head.appendChild(control(ctx, "button", "btn small ghost", "Close", { disabled, onClick: () => ctx.on.closePanel() }));
p.appendChild(head);
return p;
}
// Mid-operation, Changes and Branches only show what is there.
const waitLine = (ctx) => ctx.h.el("p", "git-wait", `Everything here waits until the ${opName(ctx.git.inProgress)} is finished or aborted.`);
/* ------------------------------------------------------------- Changes */
function changesBody(ctx) {
const { git, board, h } = ctx;
const body = h.el("div", "git-changes");
const frozen = Boolean(git.inProgress);
if (frozen) body.appendChild(waitLine(ctx));
if (board.panel === "create" && board.create && board.create.commit) {
body.appendChild(createPanel(ctx, frozen));
return body;
}
const ch = git.changes || {};
const any = list(ch.files).length || list(ch.untrackedDirs).length;
if (!any) {
body.appendChild(h.el("p", "git-empty", `No changes. Nothing to commit on ${(git.head || {}).branch || "this commit"}.`));
return body;
}
body.appendChild(commitPanel(ctx, frozen));
return body;
}
function commitPanel(ctx, frozen) {
const { git, board, h, on } = ctx;
const ch = git.changes || {};
const first = git.hasCommits === false;
const opened = board.panel === "commit";
const p = panelFrame(ctx, first ? "Make the first commit" : "Commit", { closable: opened, disabled: frozen });
const ticks = board.ticks || (board.ticks = commitTicks(ch));
const ignored = board.ignore || (board.ignore = new Set());
const table = h.el("table", "git-table git-files");
const thead = h.el("thead");
const hr = h.el("tr");
for (const label of ["", "File", "State"]) hr.appendChild(h.el("th", null, label));
thead.appendChild(hr);
table.appendChild(thead);
const tbody = h.el("tbody");
const tickBox = (id, path) => {
const box = control(ctx, "input", null, null, {
disabled: frozen,
onChange: () => {
if (box.checked) {
ticks.add(path);
ignored.delete(path);
} else ticks.delete(path);
on.redraw();
},
});
box.type = "checkbox";
box.id = id;
box.checked = ticks.has(path);
box.setAttribute("aria-label", `Commit ${path}`);
return box;
};
const ignoreToggle = (id, path) => {
const label = h.el("label", "git-ignore");
const box = control(ctx, "input", null, null, {
disabled: frozen,
onChange: () => {
if (box.checked) {
ignored.add(path);
ticks.delete(path);
} else ignored.delete(path);
on.redraw();
},
});
box.type = "checkbox";
box.id = id;
box.checked = ignored.has(path);
label.append(box, h.el("span", null, " Add to .gitignore"));
return label;
};
list(ch.files).forEach((f, i) => {
const tr = h.el("tr", f.risky ? "is-held" : null);
const cell = h.el("td");
cell.appendChild(tickBox(`git-tick-f${i}`, f.path));
tr.appendChild(cell);
tr.appendChild(h.el("td", "git-path", f.path));
const state = h.el("td", "git-state", f.state || "");
if (f.risky) {
state.appendChild(h.el("span", "badge git-badge is-held", "held back"));
state.appendChild(ignoreToggle(`git-ignore-f${i}`, f.path));
}
tr.appendChild(state);
tbody.appendChild(tr);
});
list(ch.untrackedDirs).forEach((d, i) => {
const tr = h.el("tr");
const cell = h.el("td");
cell.appendChild(tickBox(`git-tick-d${i}`, d.path));
tr.appendChild(cell);
tr.appendChild(h.el("td", "git-path", d.path));
const state = h.el("td", "git-state", `untracked folder · ${plural(d.files, "file", "files")} `);
state.appendChild(ignoreToggle(`git-ignore-d${i}`, d.path));
tr.appendChild(state);
tbody.appendChild(tr);
});
table.appendChild(tbody);
p.appendChild(table);
const known = new Set([...list(ch.files), ...list(ch.untrackedDirs)].map((f) => f.path));
const files = [...ticks].filter((path) => known.has(path));
const ignore = [...ignored].filter((path) => known.has(path));
const send = () => on.send("commit", { files, ignore });
const actions = h.el("div", "git-panel-actions");
const head = git.head || {};
const detached = !first && !head.branch;
if (detached) {
// No branch to commit on: the commit makes one, .gitignore-only picks included.
actions.appendChild(
control(ctx, "button", "btn small primary", "Create branch", {
disabled: frozen || (!files.length && !ignore.length),
onClick: () => on.openPanel("create", { commit: true, files, ignore }),
})
);
} else if (!files.length && ignore.length) {
// Only .gitignore picks: the commit takes .gitignore alone.
actions.appendChild(control(ctx, "button", "btn small primary", `Add ${ignore.length} to .gitignore`, { disabled: frozen, onClick: send }));
} else if (!first && head.branch && head.branch === git.defaultBranch) {
actions.appendChild(h.el("p", "git-offer", `You're on ${head.branch}. Make a branch for this?`));
actions.appendChild(
control(ctx, "button", "btn small primary", "Create branch", {
disabled: frozen || !files.length,
onClick: () => on.openPanel("create", { commit: true, files, ignore }),
})
);
actions.appendChild(control(ctx, "button", "btn small", `Commit on ${head.branch}`, { disabled: frozen || !files.length, onClick: send }));
} else {
actions.appendChild(
control(ctx, "button", "btn small primary", `Commit ${plural(files.length, "file", "files")}`, { disabled: frozen || !files.length, onClick: send })
);
}
if (opened) actions.appendChild(control(ctx, "button", "btn small ghost", "Cancel", { disabled: frozen, onClick: () => on.closePanel() }));
p.appendChild(actions);
return p;
}
/* ------------------------------------------------------------ Branches */
function branchesBody(ctx) {
const { git, board, h, on } = ctx;
const body = h.el("section", "git-branches");
const frozen = Boolean(git.inProgress);
if (frozen) body.appendChild(waitLine(ctx));
const tools = h.el("div", "git-tools");
const search = control(ctx, "input", "git-search", null, {
role: "nav",
disabled: frozen,
onInput: () => {
board.query = search.value;
on.redraw();
},
});
search.type = "search";
search.id = "git-search";
search.placeholder = "Search branches";
search.setAttribute("aria-label", "Search branches");
search.value = board.query || "";
tools.appendChild(search);
// Not mid-operation, and not before the first commit, when there is nothing to branch from.
const first = git.hasCommits === false;
const nb = control(ctx, "button", "btn small", "New branch", {
disabled: frozen || first,
title: first ? "Make the first commit, then you can branch from it." : frozen ? "Finish or abort what is in progress first." : undefined,
onClick: () => on.openPanel("create"),
});
tools.appendChild(nb);
body.appendChild(tools);
if (board.panel === "create" && board.create && !board.create.commit) body.appendChild(createPanel(ctx, frozen));
const { merged, gone } = cleanupGroups(git);
const sweep = git.defaultBranch ? merged.length + gone.length : 0;
if (board.panel === "cleanup" && sweep) body.appendChild(cleanupPanel(ctx, frozen));
else if (sweep) {
const offer = h.el("p", "git-sweep-offer");
offer.appendChild(h.el("span", null, `${plural(sweep, "branch", "branches")} merged or gone on the remote. `));
offer.appendChild(control(ctx, "button", "btn small ghost", "Choose which to clean up…", { disabled: frozen, onClick: () => on.openPanel("cleanup") }));
body.appendChild(offer);
}
// Mid-rebase HEAD is detached, but the branch being rebased is still the
// one they are on: it keeps its current badge, and never offers Delete.
const rebasing = git.head && git.head.rebasing;
const rows = list(git.branches).map((b) => (rebasing && !b.remote && b.name === rebasing ? { ...b, current: true } : b));
const { top, remoteOnly } = orderBranches(rows);
const locals = filterBranches(top, board.query);
if (locals.length) body.appendChild(branchTable(ctx, locals, frozen));
else body.appendChild(h.el("p", "git-empty", board.query ? "No local branch matches." : "No local branches yet."));
if (remoteOnly.length) {
const fold = foldRemote(remoteOnly, { showAll: board.showAll, query: board.query });
const det = h.el("details", "git-remote-only");
det.setAttribute("data-gate", "nav");
// null remoteOpen takes the fold's default (open under a search); a
// manual toggle wins over it. The toggle event fires for the programmatic
// open too, so only a change away from what was drawn counts as theirs.
const drawnOpen = board.remoteOpen ?? Boolean(fold.open);
det.open = drawnOpen;
det.addEventListener("toggle", () => {
if (det.open !== drawnOpen) board.remoteOpen = det.open;
});
det.appendChild(h.el("summary", null, `Remote only (${board.query ? fold.shown.length : remoteOnly.length})`));
if (fold.shown.length) det.appendChild(branchTable(ctx, fold.shown, frozen));
else det.appendChild(h.el("p", "git-empty", "No remote branch matches."));
if (fold.hidden) {
det.appendChild(
control(ctx, "button", "btn small ghost", `Show all ${remoteOnly.length}`, {
role: "nav",
disabled: frozen,
onClick: () => {
board.showAll = true;
on.redraw();
},
})
);
}
body.appendChild(det);
}
return body;
}
function branchTable(ctx, rows, frozen) {
const { h, on } = ctx;
const table = h.el("table", "git-table");
const thead = h.el("thead");
const hr = h.el("tr");
for (const label of ["Branch", "Ahead / behind", "Last commit", ""]) hr.appendChild(h.el("th", null, label));
thead.appendChild(hr);
table.appendChild(thead);
const tbody = h.el("tbody");
for (const b of rows) {
const tr = h.el("tr", b.current ? "is-current" : null);
const name = h.el("td", "git-cell-name");
name.appendChild(h.el("span", "git-name", b.remote ? `${b.remote}/${b.name}` : b.name));
const badges = [
[b.current, "current", "is-current"],
[b.default, "default", "is-default"],
[b.merged, "Merged", "is-merged"],
[b.gone, "Remote copy deleted", "is-gone"],
];
for (const [shown, label, cls] of badges) if (shown) name.appendChild(h.el("span", `badge git-badge ${cls}`, label));
tr.appendChild(name);
let track = "not published";
if (b.remote) track = "remote only";
else if (b.gone) track = "—";
else if (b.upstream) track = `↑${b.ahead || 0} ↓${b.behind || 0}`;
tr.appendChild(h.el("td", "git-cell-track", track));
const last = h.el("td", "git-cell-last");
const l = b.last || {};
last.appendChild(h.el("span", "git-subject", l.subject || ""));
const by = [l.author, relativeAge(l.at, ctx.now)].filter(Boolean).join(" · ");
if (by) last.appendChild(h.el("span", "git-by", by));
tr.appendChild(last);
const acts = h.el("td", "git-cell-actions");
const branch = b.remote ? `${b.remote}/${b.name}` : b.name;
// Mid-operation a row's Switch or Delete would ask for a second git op on top of the first.
if (!b.current) acts.appendChild(control(ctx, "button", "btn small", "Switch", { disabled: frozen, onClick: () => on.send("switch", { branch }) }));
if (!b.remote && !b.current && !b.default) {
acts.appendChild(control(ctx, "button", "btn small danger", "Delete", { disabled: frozen, onClick: () => on.send("delete", { branch: b.name }) }));
}
tr.appendChild(acts);
tbody.appendChild(tr);
}
table.appendChild(tbody);
// The table scrolls sideways on its own when the column is narrower than
// its no-wrap cells, so the search row and the buttons above it stay put.
const wrap = h.el("div", "git-table-wrap");
wrap.appendChild(table);
return wrap;
}
function createPanel(ctx, frozen) {
const { git, board, h, on } = ctx;
const c = board.create;
const p = panelFrame(ctx, c.commit ? "New branch for this commit" : "New branch", { disabled: frozen });
const src = createSources(git, c.commit);
const option = (value) => {
const o = h.el("option", null, value);
o.value = value;
return o;
};
const fromRow = h.el("div", "git-field-row");
const fromLabel = h.el("label", "git-field", "From ");
const from = control(ctx, "select", null, null, {
disabled: frozen,
onChange: () => {
c.from = from.value;
on.redraw();
},
});
from.id = "git-new-from";
for (const o of src.options) from.appendChild(option(o));
from.value = c.from;
fromLabel.appendChild(from);
fromRow.appendChild(fromLabel);
if (src.here && c.from !== src.here) {
fromRow.appendChild(
control(ctx, "button", "btn small ghost", `From ${src.here}`, {
disabled: frozen,
onClick: () => {
c.from = src.here;
on.redraw();
},
})
);
}
p.appendChild(fromRow);
const parts = h.el("div", "git-field-row");
const typeLabel = h.el("label", "git-field", "Type ");
const type = control(ctx, "select", null, null, {
disabled: frozen,
onChange: () => {
c.type = type.value;
refresh();
},
});
type.id = "git-new-type";
for (const t of BRANCH_TYPES) type.appendChild(option(t));
type.value = c.type;
typeLabel.appendChild(type);
const descLabel = h.el("label", "git-field is-wide", "Short description ");
const desc = control(ctx, "input", null, null, {
disabled: frozen,
onInput: () => {
c.description = desc.value;
refresh();
},
});
desc.id = "git-new-desc";
desc.placeholder = "export csv";
desc.value = c.description || "";
descLabel.appendChild(desc);
parts.append(typeLabel, descLabel);
p.appendChild(parts);
const nameLabel = h.el("label", "git-field is-wide", "Branch name ");
const name = control(ctx, "input", "git-new-name", null, {
disabled: frozen,
onInput: () => {
c.name = name.value;
refresh();
},
});
name.id = "git-new-name";
nameLabel.appendChild(name);
p.appendChild(nameLabel);
const status = h.el("p", "git-name-status");
status.setAttribute("aria-live", "polite");
p.appendChild(status);
// The name mirrors the two fields until it is edited directly.
const currentName = () => (c.name == null ? composeBranchName(c) : c.name);
const actions = h.el("div", "git-panel-actions");
const go = control(ctx, "button", "btn small primary", "Create", {
disabled: true,
onClick: () => {
const fields = { name: currentName(), from: c.from };
if (c.commit) Object.assign(fields, { then: "commit", files: c.files || [] });
if (c.commit && c.ignore && c.ignore.length) fields.ignore = c.ignore;
on.send("create", fields);
},
});
actions.appendChild(go);
actions.appendChild(control(ctx, "button", "btn small ghost", "Cancel", { disabled: frozen, onClick: () => on.closePanel() }));
p.appendChild(actions);
// Typing updates the name box, the status line and Create in place, never a redraw.
const noFiles = c.commit && !list(c.files).length && !list(c.ignore).length;
const refresh = () => {
const value = currentName();
if (name.value !== value) name.value = value;
const st = nameStatus(value, git);
nameLine(ctx, status, st, frozen);
if (noFiles) status.appendChild(h.el("span", null, " Nothing is ticked to commit."));
const own = frozen || st.kind !== "free" || noFiles;
go.disabled = own || !controlAllowed(ctx.mode, "action");
if (own) go.setAttribute("data-own", "true");
else go.removeAttribute("data-own");
};
refresh();
return p;
}
function nameLine(ctx, line, st, frozen) {
const { h, on } = ctx;
line.replaceChildren();
line.className = "git-name-status is-" + st.kind;
const say = (text) => line.appendChild(h.el("span", null, text));
const switchTo = (branch) =>
line.appendChild(control(ctx, "button", "btn small", "Switch to it", { disabled: frozen, onClick: () => on.send("switch", { branch }) }));
if (st.kind === "empty") say("Fill in the fields above, or type a name.");
else if (st.kind === "invalid") say(st.reason);
else if (st.kind === "free") say("That name is free.");
else if (st.kind === "local") {
say(`${st.branch} already exists here. `);
switchTo(st.branch);
} else if (st.kind === "remote") {
say(`${st.remote}/${st.branch} already exists on ${st.remote}. `);
switchTo(`${st.remote}/${st.branch}`);
} else if (st.kind === "nested") say(`It clashes with ${st.clash}: one branch cannot be a folder of another.`);
}
function cleanupPanel(ctx, frozen) {
const { git, board, h, on } = ctx;
const p = panelFrame(ctx, "Clean up branches", { disabled: frozen });
const { merged, gone } = cleanupGroups(git);
const sweep = board.sweep || (board.sweep = new Set([...merged, ...gone].map((b) => b.name)));
const group = (title, rows, key) => {
if (!rows.length) return;
p.appendChild(h.el("h4", "git-group-title", title));
const ul = h.el("ul", "git-sweep");
rows.forEach((b, i) => {
const li = h.el("li");
const label = h.el("label");
const box = control(ctx, "input", null, null, {
disabled: frozen,
onChange: () => {
if (box.checked) sweep.add(b.name);
else sweep.delete(b.name);
on.redraw();
},
});
box.type = "checkbox";
box.id = `git-sweep-${key}${i}`;
box.checked = sweep.has(b.name);
label.append(box, h.el("span", null, " " + b.name));
li.appendChild(label);
ul.appendChild(li);
});
p.appendChild(ul);
};
group(`Merged into ${git.defaultBranch}`, merged, "m");
group("Remote copy deleted", gone, "g");
const known = new Set([...merged, ...gone].map((b) => b.name));
const branches = [...sweep].filter((n) => known.has(n));
const actions = h.el("div", "git-panel-actions");
actions.appendChild(
control(ctx, "button", "btn small danger", `Delete ${plural(branches.length, "branch", "branches")}`, {
disabled: frozen || !branches.length,
onClick: () => on.send("cleanup", { branches }),
})
);
actions.appendChild(control(ctx, "button", "btn small ghost", "Cancel", { disabled: frozen, onClick: () => on.closePanel() }));
p.appendChild(actions);
return p;
}
/* ---------------------------------------------------------------- Sync */
function syncBody(ctx) {
const { git, h } = ctx;
const body = h.el("div", "git-sync");
if (git.inProgress) {
body.appendChild(opBlock(ctx));
return body;
}
const pr = prBlock(ctx);
if (pr) body.appendChild(pr);
const acts = boardActions(git, { busy: ctx.mode !== "idle" });
const row = h.el("div", "git-sync-actions");
const primaryOp = ctx.step.primary && ctx.step.primary.op;
for (const key of ["refresh", "pull", "push", "publish"]) {
const a = acts[key];
if (!a.shown) continue;
row.appendChild(
control(ctx, "button", "btn small" + (key === primaryOp ? " primary" : ""), a.label, {
disabled: ctx.mode === "idle" && !a.enabled,
title: a.title,
onClick: () => runStep(ctx, { op: key }),
})
);
}
body.appendChild(row);
if (list(git.remotes).length) {
body.appendChild(h.el("p", "git-fresh" + (ctx.step.stale ? " is-stale" : ""), ctx.step.stale || refreshedLine(git, ctx.now)));
} else body.appendChild(h.el("p", "git-fresh", "No remote yet, so nothing to sync. Add one with the line at the top."));
return body;
}
// Mid-operation: one block that is the step, its files and its two buttons.
function opBlock(ctx) {
const { git, h, on, step } = ctx;
const box = h.el("div", "git-op git-step is-warn");
box.setAttribute("role", "alert");
box.appendChild(h.el("div", "git-step-kicker", "Next step"));
box.appendChild(h.el("h3", "git-op-title", `${OP_WORDS[git.inProgress] || "An operation"} is in progress`));
if (step.primary) {
box.appendChild(h.el("p", "git-step-label", step.primary.label));
if (step.primary.why) box.appendChild(h.el("p", "git-step-why", step.primary.why));
}
const conflicted = list(git.conflicted);
if (conflicted.length) {
const ul = h.el("ul", "git-op-files");
for (const c of conflicted) {
const li = h.el("li");
li.appendChild(h.el("code", "md-code", c.path));
li.appendChild(h.el("span", c.markers ? "git-op-left" : "git-op-clear", c.markers ? " · markers left" : " · resolved"));
ul.appendChild(li);
}
box.appendChild(ul);
}
const actions = h.el("div", "git-op-actions");
const wording = { operation: git.inProgress };
// Always offered: the file states are a snapshot from the agent's last
// look, and someone who fixed a file in their editor has no other way to
// say so. `plan continue` checks the files on disk itself.
const clean = conflicted.every((c) => c.markers === false);
actions.appendChild(
control(ctx, "button", clean ? "btn primary" : "btn", "Continue", {
title: clean ? undefined : "Fixed them in your editor? Plan2Code checks the files again before it continues.",
onClick: () => on.send("continue", {}, wording),
})
);
const abort = step.secondary.find((s) => s.op === "abort");
actions.appendChild(
control(ctx, "button", "btn danger", abort ? abort.label : `Abort the ${opName(git.inProgress)}`, {
onClick: () => on.send("abort", {}, wording),
})
);
box.appendChild(actions);
return box;
}
function prBlock(ctx) {
const { git, board, h, on } = ctx;
const cur = currentRow(git);
const bases = list(git.branches)
.filter((b) => b && !b.remote && (!cur || b.name !== cur.name))
.map((b) => b.name);
// One base for both the link and the picker, so they can never disagree: a
// pick that has since gone falls back to the default, and a default that is
// only on the remote is still offered.
const base = bases.includes(board.base) ? board.base : git.defaultBranch;
if (base && !bases.includes(base)) bases.unshift(base);
const link = boardPrLink(git, base);
if (!link) return null;
const box = h.el("div", "git-pr");
if (link.needsKind) {
if (!link.host) return null;
box.appendChild(h.el("span", "git-pr-ask", `Which host is ${link.host}?`));
for (const [kind, label] of Object.entries(PR_HOST_LABELS)) {
box.appendChild(control(ctx, "button", "btn small", label, { onClick: () => on.pickPrHost(link.host, kind) }));
}
return box;
}
if (!link.url || !/^https:\/\//i.test(link.url)) return null;
box.appendChild(prLink(ctx, link.url));
box.appendChild(copy(ctx, link.url, "btn small"));
if (bases.length) {
const label = h.el("label", "git-pr-base", "into ");
const sel = control(ctx, "select", null, null, {
onChange: () => {
board.base = sel.value;
on.redraw();
},
});
sel.id = "git-pr-base";
for (const name of bases) {
const o = h.el("option", null, name);
o.value = name;
sel.appendChild(o);
}
sel.value = base;
label.appendChild(sel);
box.appendChild(label);
}
return box;
}
+274 -5
View File
@@ -1,13 +1,16 @@
// Plan2Code Web Console - the git board's rules: branch order, names, buttons and replies.
// Plan2Code Web Console - the git board's rules: branch order, names, buttons, replies, next step and tabs.
//
// 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
// list is ordered and folded, whether a new branch name is free and where a
// new branch can start, which branches the clean-up offers, 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.
// commit dialog, the pull-request link, the suggested next step and the tab
// that owns it, each tab's badge, and how busy the board is and which
// controls that allows. 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";
@@ -148,6 +151,40 @@ export function nameStatus(name, git) {
return { kind: "free" };
}
/**
* Where a new branch can start: `{ preset, here, options }`. origin/<default>
* when that remote branch exists, else the local default, else the current
* branch (or, detached, the commit). A commit from a detached HEAD belongs on
* the commit it was made at.
*/
export function createSources(git, commit = false) {
const g = git || {};
const def = g.defaultBranch;
const rows = list(g.branches).filter(Boolean);
const h = g.head || {};
const originDef =
def && rows.some((b) => (b.remote === "origin" && b.name === def) || (!b.remote && b.upstream === `origin/${def}`))
? `origin/${def}`
: null;
const localDef = def && rows.some((b) => !b.remote && b.name === def) ? def : null;
const here = h.branch || h.detached || null;
const preset = (commit && h.detached) || originDef || localDef || here || "HEAD";
return { preset, here, options: [...new Set([originDef, localDef, here, preset].filter(Boolean))] };
}
/* ------------------------------------------------------------- cleanup */
/**
* The clean-up panel's groups, `{ merged, gone }`: local branches merged into
* the default, and those whose remote copy is deleted. Never the current or
* the default branch; a branch in both shows once, under gone, the way the
* confirm that follows (cleanup-list) names it.
*/
export function cleanupGroups(git) {
const locals = list(git && git.branches).filter((b) => b && !b.remote && !b.current && !b.default);
return { merged: locals.filter((b) => b.merged && !b.gone), gone: locals.filter((b) => b.gone) };
}
/* ------------------------------------------------------------- buttons */
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
@@ -259,6 +296,9 @@ function filePhrase(files, count) {
return n === 1 ? `this file${shown}` : `these ${n} files${shown}`;
}
// Nothing ticked, only .gitignore picks: the commit takes .gitignore alone.
const ignoreOnly = (f) => !names(f.files).length && !Number(f.count) && names(f.ignore).length > 0;
/** The plain instruction a board button sends the agent, one sentence per op. */
export function gitReply(op, fields = {}) {
const f = fields || {};
@@ -278,6 +318,7 @@ export function gitReply(op, fields = {}) {
const start = `Create ${f.name} from ${f.from}.`;
if (f.then !== "commit") return start;
const ignore = names(f.ignore);
if (ignoreOnly(f)) return `${start} Then add ${ignore.join(", ")} to .gitignore and commit just .gitignore.`;
const tail = ignore.length ? ` Add ${ignore.join(", ")} to .gitignore.` : "";
return `${start} Then commit ${filePhrase(names(f.files), f.count)}.${tail}`;
}
@@ -290,6 +331,7 @@ export function gitReply(op, fields = {}) {
}
case "commit": {
const ignore = names(f.ignore);
if (ignoreOnly(f)) return `Add ${ignore.join(", ")} to .gitignore and commit just .gitignore.`;
const tail = ignore.length ? ` Add ${ignore.join(", ")} to .gitignore.` : "";
return `Commit ${filePhrase(names(f.files), f.count)}.${tail}`;
}
@@ -380,3 +422,230 @@ export function boardPrLink(git, base) {
host: remote.host || null,
};
}
/* ----------------------------------------------------------- next step */
export const GIT_TABS = Object.freeze([
Object.freeze({ id: "changes", label: "Changes" }),
Object.freeze({ id: "branches", label: "Branches" }),
Object.freeze({ id: "sync", label: "Sync" }),
]);
const TAB_IDS = new Set(GIT_TABS.map((t) => t.id));
// The tab each suggested step lives on. Anything not listed is Sync's.
const STEP_TAB = Object.freeze({
commit: "changes",
"create-commit": "changes",
ignore: "changes",
create: "branches",
cleanup: "branches",
});
const tabOf = (step) => (step && STEP_TAB[step.op]) || "sync";
const STALE_MS = 60 * 60 * 1000;
const files = (n) => plural(n, "file", "files");
const branchCount = (n) => plural(n, "branch", "branches");
// Held-back (risky) paths: secrets and big files, never counted toward Commit.
const heldPaths = (git) => list(git.changes && git.changes.files).filter((f) => f && f.risky && typeof f.path === "string").map((f) => f.path);
// Local branches merged into the default or gone upstream, never the current or default one.
// None without a default branch: boardActions() offers no Clean up then.
const sweepable = (git) =>
git.defaultBranch ? list(git.branches).filter((b) => b && !b.remote && !b.current && !b.default && (b.merged || b.gone)) : [];
// Every step whose rule matches, in rule order (first match wins).
function matches(git) {
const head = git.head || {};
const held = heldPaths(git).length;
const count = Math.max(0, (Number(git.changes && git.changes.count) || 0) - held);
const cur = currentRow(git);
const onDefault = Boolean(head.branch) && head.branch === git.defaultBranch;
const hasRemote = list(git.remotes).length > 0;
const live = Boolean(head.upstream) && !head.gone;
const remoteName = (cur && cur.upstreamRemote) || "the remote";
const out = [];
// 1. An operation stopped part-way.
if (git.inProgress) {
const left = list(git.conflicted).filter((c) => c && c.markers).length;
out.push(
left
? { op: "fix", label: "Fix the files", why: `${files(left)} still ${left === 1 ? "has" : "have"} conflict markers.` }
: { op: "continue", label: "Continue", why: "Every conflict is resolved." }
);
out.push({ op: "abort", label: `Abort the ${git.inProgress === "am" ? "git am" : git.inProgress}`, why: "Put everything back as it was." });
return out;
}
// 2. Nothing committed yet.
if (git.hasCommits === false) {
out.push({ op: "commit", label: "Make the first commit", why: `Nothing saved yet. ${files(count)} ready.` });
return out;
}
// 3. Detached HEAD.
if (!head.branch) out.push({ op: "create", label: "Make a branch here", why: `You're on commit ${head.detached || "an unknown commit"}, not a branch.` });
// 4. Uncommitted changes, held-back files left out.
if (count > 0) {
if (onDefault) {
out.push({ op: "create-commit", label: `Start a branch for ${files(count)}`, why: `You're on ${head.branch}. Work usually goes on its own branch.` });
out.push({ op: "commit", label: `Commit on ${head.branch}`, why: "Commit straight to the default branch.", forced: true });
} else {
out.push({ op: "commit", label: `Commit ${files(count)}`, why: `${files(count)} changed on ${head.branch || "this commit"}.` });
}
}
// 5. Behind, 6. ahead.
const behind = Number(head.behind) || 0;
const ahead = Number(head.ahead) || 0;
if (live && behind > 0) out.push({ op: "pull", label: "Pull", why: `${remoteName === "the remote" ? "The remote" : remoteName} has ${plural(behind, "commit", "commits")} you don't.` });
if (live && ahead > 0) out.push({ op: "push", label: `Push ${ahead}`, why: `${plural(ahead, "commit", "commits")} not on ${remoteName} yet.` });
// 7. Never published, or its remote copy was deleted.
if (head.branch && hasRemote && !live) {
out.push({ op: "publish", label: "Publish", why: head.gone ? `${head.branch}'s remote copy was deleted.` : `${head.branch} isn't on the remote yet.` });
}
// 8. Pushed, not the default branch, and a link that can open.
if (live && !onDefault) {
const link = boardPrLink(git, git.defaultBranch);
if (link && link.url) out.push({ op: "pr", label: "Open pull request", why: "Pushed. Ready for review?", url: link.url });
}
// 9. Branches to clean up.
const sweep = sweepable(git).length;
if (sweep) out.push({ op: "cleanup", label: `Clean up ${branchCount(sweep)}`, why: `${branchCount(sweep)} already merged or deleted on the remote.` });
return out;
}
// The held-back line and the .gitignore offer that fills an empty secondary slot.
function heldOut(git) {
const held = heldPaths(git);
if (!held.length) return { held: null, ignore: null };
const what = held.length === 1 ? "`" + held[0] + "`" : `${held.length} held-back files`;
return {
held: held.length === 1 ? `${what} held back` : `${held.length} files held back`,
ignore: { op: "ignore", label: `Add ${what} to .gitignore`, why: `Keep ${held.length === 1 ? "it" : "them"} out of every commit.`, files: held },
};
}
// "Checked 3 hr. ago — Refresh?" when a remote exists and the last fetch is over an hour old or unknown.
function staleLine(git, now) {
if (!list(git.remotes).length) return null;
const at = Date.parse(git.lastFetch);
if (!Number.isNaN(at) && now - at <= STALE_MS) return null;
const age = git.lastFetch ? relativeAge(git.lastFetch, now) : "";
return age ? `Checked ${age} — Refresh?` : "Never checked — Refresh?";
}
const withTab = (step) => (step ? { ...step, tab: tabOf(step) } : step);
/**
* The board's suggested next step: `{ primary, secondary, stale, held, line,
* tab }`. `primary` is the first matching rule or null; `secondary` an array
* with at most one quieter step (the default-branch commit, else the next
* match, else the held-back .gitignore offer), or the two quiet actions when
* there is no primary. `stale` never changes the step. Every step carries the
* `tab` it lives on, and `tab` is the one that owns the suggestion.
*/
export function nextStep(git, { now = Date.now() } = {}) {
const g = git || {};
const all = matches(g);
const { held, ignore } = heldOut(g);
const head = g.head || {};
const stale = staleLine(g, now);
if (!all.length) {
const branch = head.branch || "this commit";
const checked = g.lastFetch ? relativeAge(g.lastFetch, now) : "";
const line = list(g.remotes).length
? `All caught up on ${branch}${checked ? ` · checked ${checked}` : ""}`
: `Nothing to commit on ${branch} · no remote yet`;
const secondary = [ignore || { op: "create", label: "New branch" }, { op: "refresh", label: "Refresh" }].map(withTab);
return { primary: null, secondary, stale, held, line, tab: ignore ? "changes" : "sync" };
}
const [first, ...rest] = all;
const primary = withTab(first);
const second = rest.find((s) => s.forced) || rest[0] || ignore;
return { primary, secondary: second ? [withTab(second)] : [], stale, held, line: primary.why, tab: primary.tab };
}
/* -------------------------------------------------------------- badges */
/**
* What each tab has waiting: `{ changes, branches, sync }`, each null or
* `{ kind, text, label, next }` (kind "count", "dot" or "warn"; `label` is
* for the tab's accessible name). `next` marks the tab owning the next step
* when there is a primary; that tab always carries a badge. Mid-operation
* only Sync is badged, with a warning.
*/
export function tabBadges(git, { now = Date.now(), stepTab = null } = {}) {
const g = git || {};
const head = g.head || {};
const out = { changes: null, branches: null, sync: null };
if (g.inProgress) {
out.sync = { kind: "warn", text: "!", label: "operation in progress", next: false };
} else {
const held = heldPaths(g).length;
const count = Math.max(0, (Number(g.changes && g.changes.count) || 0) - held);
if (count) out.changes = { kind: "count", text: String(count), label: `${count} waiting`, next: false };
else if (held) out.changes = { kind: "dot", text: "·", label: "held-back files", next: false };
const sweep = sweepable(g).length;
if (sweep) out.branches = { kind: "count", text: String(sweep), label: `${sweep} to clean up`, next: false };
const live = Boolean(head.upstream) && !head.gone;
const ahead = Number(head.ahead) || 0;
const behind = Number(head.behind) || 0;
if (live && (ahead || behind)) {
const text = [ahead ? `↑${ahead}` : null, behind ? `↓${behind}` : null].filter(Boolean).join(" ");
const label = [ahead ? `${ahead} to push` : null, behind ? `${behind} to pull` : null].filter(Boolean).join(", ");
out.sync = { kind: "count", text, label, next: false };
} else if (list(g.remotes).length && head.branch && !live && g.hasCommits !== false) {
out.sync = { kind: "count", text: "↑", label: "not published", next: false };
} else if (staleLine(g, now)) {
out.sync = { kind: "count", text: "?", label: "not checked lately", next: false };
}
}
const step = nextStep(g, { now });
const owner = TAB_IDS.has(stepTab) ? stepTab : step.tab;
if (step.primary && TAB_IDS.has(owner)) {
const b = out[owner] || { kind: "dot", text: "·", label: "" };
out[owner] = { ...b, next: true, label: b.label ? `${b.label}, next step` : "next step" };
}
return out;
}
/* ---------------------------------------------------------------- busy */
/**
* How busy the board is, most restrictive first: "offline" (the server is
* gone, or the last click is not picked up yet), "running" (a git command or
* the agent's turn), "card" (a question of Plan2Code's waits), "idle".
*/
export function busyMode({ running = false, cardWaiting = false, gone = false, pending = false } = {}) {
if (gone || pending) return "offline";
if (running) return "running";
if (cardWaiting) return "card";
return "idle";
}
/**
* Whether a control of `role` works in `mode`: "nav" (switching tabs, search,
* folds) always; "action" (anything that sends, ticks, picks, copies or opens
* a panel) only when idle; "done" (Done with git) when idle or a card waits.
*/
export function controlAllowed(mode, role) {
if (role === "nav") return true;
if (role === "action") return mode === "idle";
if (role === "done") return mode === "idle" || mode === "card";
return false;
}
/**
* The tab to show. A click of theirs that landed, and arriving at the board,
* go to the next step's tab; a reload and a change they did not click for
* keep the tab they had.
*/
export function pickTab({ current = null, stepTab, reason } = {}) {
const step = TAB_IDS.has(stepTab) ? stepTab : "sync";
if (reason === "landed" || reason === "arrival") return step;
return TAB_IDS.has(current) ? current : step;
}
+93 -55
View File
@@ -25,6 +25,7 @@
<link rel="modulepreload" href="/mentions.js" />
<link rel="modulepreload" href="/favicon.js" />
<link rel="modulepreload" href="/git-board.js" />
<link rel="modulepreload" href="/git-board-view.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" />
@@ -1570,7 +1571,7 @@
<ul>
<li><strong>Quick task.</strong> Too small for the full process? A quick plan, then it just builds it.</li>
<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>Handoff.</strong> Pack the current session 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.</strong> Branches, pull, push and commits on one board, asking before anything leaves your machine. See "The git board".</li>
</ul>
@@ -1733,86 +1734,123 @@
<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.
The Git card opens a board for your repository: three tabs — Changes,
Branches and Sync — and the next step on top. 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>
The branch you are on, and how far it is ahead of (↑) or behind (↓)
its remote copy, or that it is not published yet.
</li>
<li>With more than one remote, a badge names the one your branch follows.</li>
<li>
With no remote at all, a <strong>No remote</strong> line shows the
command that adds one, with a copy button.
</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.
fetched. If a refresh fails, the line says so.
</li>
</ul>
<h4>The branch table</h4>
<h4>The tabs</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>.
<strong>Changes</strong> lists your uncommitted files, ready to
commit. Its badge counts them, or shows a dot when the only files
left are held back (secrets and very large files).
</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.
<strong>Branches</strong> lists your branches with Switch and Delete,
plus new branch and clean-up. Its badge counts branches already
merged, or whose remote copy is gone, that can be cleaned up.
Branches that exist only on the remote sit under <strong>Remote
only</strong>, showing the first
<span data-fact="remoteFold">50</span>; <strong>Search
branches</strong> filters both lists.
</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.
<strong>Sync</strong> holds pull, push and publish. Its badge shows
↑ and ↓ counts, ↑ alone when the branch is unpublished, or ? when the
remotes have not been checked lately. During a rebase or merge it
shows <strong>!</strong> instead. Once your branch is pushed, Sync
also offers <strong>Open pull request</strong>, into the default
branch or the one you pick beside it; the first time a host is
unknown, it asks which kind it is and remembers the answer.
</li>
<li><strong>Search branches</strong> filters both lists by name or last commit.</li>
<li>A filled badge marks the tab where the next step is.</li>
</ul>
<h4>What asks first</h4>
<h4>The next step</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.
The tab that holds it opens with one main button and, at most, one
quieter one beside it: Commit, Push, Publish, Open pull request, and
so on.
</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.
On the other tabs, a line reads <strong>Next step is on
‹tab›</strong>; click it to go there.
</li>
<li>
<strong>Commit</strong> opens a list of your changed files to tick,
and you approve the message before anything is committed.
Held-back files never count toward the next step. The board offers
to add them to <code>.gitignore</code> instead.
</li>
<li>
When the remotes were last checked over an hour ago, it says
<strong>Checked … — Refresh?</strong>.
</li>
<li>
With nothing to do it says <strong>All caught up</strong>, or
<strong>Nothing to commit … no remote yet</strong> when there is no
remote.
</li>
<li>
Push, Publish, Delete and Clean up always show exactly what will
happen and wait for your yes. Nothing is ever force-pushed, and a
remote branch is never deleted.
</li>
<li>A remote branch is never deleted, and nothing is ever force-pushed.</li>
</ul>
<h4>One action at a time</h4>
<h4>Moving between tabs</h4>
<ul>
<li>
Once a click of yours has landed, the board moves to the tab of the
next step. Anything else that changes leaves you where you are.
</li>
<li>Reloading the page keeps the tab you were on.</li>
<li>The arrow keys move between tabs, and Home and End jump to the first and last.</li>
</ul>
<h4>While something is running</h4>
<ul>
<li>
Everything greys out except switching tabs, searching and opening
folds, so nothing queues up behind the running command.
</li>
<li>What is running shows where the next step usually sits.</li>
<li>Plan2Code's questions appear under the tab strip.</li>
<li>
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.
</li>
</ul>
<h4>Mid-rebase or merge</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.
A rebase or merge that stopped on conflicts shows one block on Sync,
with the files still to fix. <strong>Continue</strong> becomes the main
button once no conflict markers are left; a single <strong>Abort</strong>
puts everything back as it was. The other tabs wait until it is
finished or aborted.
</p>
<h4>Done</h4>
<h4>Done with git</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.
<strong>Done with git</strong> ends the board. 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. It greys while a command runs and
comes back when it is done; if Plan2Code stops checking in,
<strong>Stop session</strong> in the top bar ends the session instead.
While a question of Plan2Code's waits, it cancels that question and
finishes.
</p>
</section>
+1
View File
@@ -250,6 +250,7 @@ const SERVABLE = new Set([
"mentions.js",
"favicon.js",
"git-board.js",
"git-board-view.js",
"pr-url.js",
"start-stop.mp3",
"next.mp3",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "Plan2Code",
"version": "2.7.0",
"version": "2.8.1",
"description": "A structured 4-step workflow methodology for AI-assisted software development",
"keywords": [
"ai",
@@ -17,6 +17,6 @@
"url": "https://github.com/jparkerweb/plan2code"
},
"homepage": "https://github.com/jparkerweb/plan2code",
"releaseDate": "2026-10-11",
"releaseDate": "2026-10-14",
"mode": "utility"
}