mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa6361d39e | ||
|
|
f6790e5cf1 | ||
|
|
a584c45dfd | ||
|
|
7891c06642 | ||
|
|
7856618a4c | ||
|
|
b5089cdc94 | ||
|
|
785a4dc8b9 | ||
|
|
b585eccd5a | ||
|
|
02380fa6fe | ||
|
|
459b840db9 | ||
|
|
f24a254f96 | ||
|
|
1a17578aa9 | ||
|
|
92d4d880bf | ||
|
|
9a23b15fc9 | ||
|
|
d4b604ba7f | ||
|
|
dd86279e88 | ||
|
|
f92af765e7 | ||
|
|
bb66f1d458 | ||
|
|
f5369df090 |
No files matched your search
@@ -5,7 +5,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
|
||||
|
||||
| File | Role |
|
||||
|---|---|
|
||||
| `public/` (other files) | `index.html`, `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 the pure modules) parses them as ES modules without a reparse warning. The stylesheet is the files in `public/styles/`, joined by the server into the one `/app.css` the page asks for |
|
||||
| `public/` (other files) | `index.html`, `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 (`bootup.mp3`, `sleeping.mp3`, and `sounds/sound-01.mp3` to `sounds/sound-19.mp3`, whose first four are today's cues; 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 the pure modules) parses them as ES modules without a reparse warning. The stylesheet is the files in `public/styles/`, joined by the server into the one `/app.css` the page asks for |
|
||||
| `public/md-field.js` | A Markdown answer field on CodeMirror 6: every multiline box the person types into renders its Markdown live. |
|
||||
| `public/md-field.css` | The frame a Markdown field wears inside its shadow root, linked beside `notepad-editor.css`. |
|
||||
| `public/app.js` | the page's entry and the only page file that starts anything: the start-up block. `index.html` loads it; it imports `screens/core.js` and the screens beside it |
|
||||
@@ -19,7 +19,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
|
||||
| `public/selectors.js` | what the page reads off its state: the questions, the finish, the scan, who has the ball |
|
||||
| `public/send-state.js` | whether Send is available, and what its button says |
|
||||
| `public/skills.js` | the skill list: every per-skill fact the console uses (card, order, start pose, launch scoring, subagent opt-in, which spec states light its card), data only, imported by the page and by Node; the older tables (`SKILL_CATALOG`, `START_POSES`, `CONSOLE_WORKFLOWS` and the rest, in `answers.js`) are lookups on it. Each entry also carries `weight` (what its launch and `run` score on the meter, or null), `started` and `ran` (the meter's labels for them, or null), `resume` (`"overview"`, `"folder"` or null: what the resume command takes after the skill's command) and an optional `card.help` (Help's line for the card when it differs from `blurb`). `WORKFLOWS` (every entry's workflow, in order) and `isWorkflow()` are what the CLI checks a `--workflow` against. The meter's `WEIGHTS`, `LAUNCH_LABELS` and `RUN_LABELS`, `resumeCommand()`, Help's card list and `cmd-help`'s workflow list are all derived from it, so a new skill is one entry here, not an edit to each of those |
|
||||
| `public/sound.js` | the sound cues: which plays, one at a time, held until the first click |
|
||||
| `public/sound.js` | the sound cues: which plays, one at a time, held until the first click; seven cues (not Planny snoring or waking) play the file picked in Preferences, saved flat as `soundFile<Event>` (`soundFileQuestion`) out of the 19 files `sound-01` to `sound-19` in `public/sounds/` |
|
||||
| `public/spec-states.js` | the spec states (`diagnosed`, `fixed`, `exploring`, `mapped`, `planned`, `documented`, `building`, `built`, `unrecognized`): each one's picker label, the card it is the natural next step for and its recommendation, data only; which cards a state lights lives in `skills.js`, how a folder maps to a state in `classifySpec()` in `scan.mjs` |
|
||||
| `public/state.js` | the page's shared state (`page.S` the server's truth, `page.local` what is staged) and the `redraw()` / save hooks every screen calls; defines only |
|
||||
| `public/uploads.js` | pictures and documents attached to a note: chips, trays, re-encoding, upload, retry, and the page's shared full-screen picture preview (`openPicview`, the `#picview` dialog every thumbnail opens) |
|
||||
@@ -28,7 +28,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
|
||||
| `public/screens/cleanup.js` | User Preferences' Cleanup section, on the System tab |
|
||||
| `public/screens/core.js` | the core every screen sits inside: connection, the render loop, the page chrome and Send; the only file that imports the screens, and only `app.js` imports it |
|
||||
| `public/screens/dashboard.js` | the dashboard: cards, the spec picker, handoff chips, delete, and the first-open wake-up |
|
||||
| `public/screens/loop-setup.js` | the Implementation Loop's setup screen on the dashboard (app only): the fields, their defaults and read-only facts, the Start checks, and the request to the app. The page locks while `state.loop.driving` is set (`loopDriving()` in `selectors.js`) until the app posts `loopEnd`; Activities, Notebook, Help and Preferences stay usable. `loopEnd.can` accepts `ask` (`LOOP_CAN` in `patches.mjs`); the app adds it first to every stop that offers `resume`, and the stopped screen's **Ask a question** wakes an ordinary agent on the same session |
|
||||
| `public/screens/loop-setup.js` | the Implementation Loop's setup screen on the dashboard (app only): the fields, their defaults and read-only facts, the Start checks, and the request to the app. The **Strength per phase** field (`strengthField`) is a grid: four headed columns (Match my session, Thrifty, Balanced, Best; level 0 to 3) and one `radiogroup` row per phase left, one radio per column (`#loop-strength-<n>-<word>`, `match` for Match my session; an unmapped word's radio is disabled and its header says "(not mapped)"), the cell's dot (`strengthBars`) over the hidden radio, and the model the pick becomes at the row's end. **Set all to** stays a select (`#loop-strength-all`, blank again after use). `drawStrengthLine(grid)` draws the grid's SVG from the checked nodes' measured positions, never from state: a very light dashed `line.col` per column and a thick square-step `path.step` from each row's node to the next (one path fewer than rows, none under two rows or with the toggle off). It redraws on the window's resize, a `ResizeObserver` on the grid (Preferences' page width), fonts loading and every redraw of the section, and stops once the grid is gone. The colors are the `--lvl-0` to `--lvl-3` tokens (`--lvl-0` is the neutral gray of Match my session); tests wait for the drawn state before reading the line. The page locks while `state.loop.driving` is set (`loopDriving()` in `selectors.js`) until the app posts `loopEnd`; Activities, Notebook, Help and Preferences stay usable. `loopEnd.can` accepts `ask` (`LOOP_CAN` in `patches.mjs`); the app adds it first to every stop that offers `resume`, and the stopped screen's **Ask a question** wakes an ordinary agent on the same session |
|
||||
| `public/screens/docs.js` | documents: tabs, blocks, print and download, and the brief button |
|
||||
| `public/screens/ending.js` | how a session ends: the finished screen, its offers, Stop and the way home |
|
||||
| `public/screens/git-host.js` | hosts the git board: tabs, panels and what each click sends |
|
||||
|
||||
@@ -17,6 +17,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `in-app.mjs` | the desktop app's signal to `open`: `inAppSignal()` reads `PLAN2CODE_IN_APP`, `PLAN2CODE_CONSOLE_SID`, `PLAN2CODE_APP_ANNOUNCE` and `PLAN2CODE_APP_TOKEN`; `announcePage()` POSTs the page to that window's loopback endpoint. Under the app `open` never starts a browser, resumes the app's session and announces the page; with the variables unset nothing here runs. Imported by `cmd-open.mjs` |
|
||||
| `open-link.mjs` | the desktop app's webview opens no new windows, so the page there sends links off the console (`linkLeavesPage()` in `public/app-bridge.js`: http or https on another origin, caught in `wireChrome()`) to `POST /open-link`. `linkToOpen()` takes http and https only (400 otherwise); `openLink()` starts the default browser with the link as one argument, never through a shell (`rundll32 url.dll,FileProtocolHandler` on Windows, `open` on macOS, `$BROWSER` or `xdg-open` elsewhere) and skips it under `PLAN2CODE_NO_BROWSER`. When that fails the page shows the link with a Copy button to paste into a browser |
|
||||
| `loop-setup.mjs` | the Implementation Loop's setup, remembered per project in `~/.plan2code/console/loop-setup.json` (one entry per folded project folder, schema 1): defaults, validation and the read and write the `/loop-setup` route uses. The app reads the same file itself for the quick check, so the page never carries that command |
|
||||
| `spec-carry.mjs` | the spec a desktop app's New Session carries to the fresh dashboard: one short-lived `~/.plan2code/console/spec-carry.json` (`{project, spec, at}`), written by `restart_brief::leave_spec` in the app from the old session's `specDir` (or, from a dashboard, its picker's `specSel` in the draft), taken once by `POST /spec-carry` (`takeSpecCarry`: same folded project, under ten minutes old, one folder under `specs/`) and used by `loadSpecCarry()` in `selectors.js` only when the new picker lists that spec |
|
||||
| `cmd-post-wait.mjs` | `post` and `wait`: publish a patch, then collect what the person sent |
|
||||
| `cmd-small.mjs` | the small commands: keep, forget, delete-spec, handoff, delete-handoff, status and stop; `handoff new` refuses an unknown `--workflow` the same way `open` does |
|
||||
| `files.mjs` | where the console's files live, how they are written safely, and the argument parser both command lines share |
|
||||
@@ -43,5 +44,5 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `update-check.mjs` | the dashboard's release check, server-only (never in `SERVABLE`): `compareVersions()` (numeric X.Y.Z, `null` otherwise), `latestTag()` (the highest `refs/tags/vX.Y.Z`, peeled `^{}` and pre-release tags skipped), `checkForUpdate({ installed, cacheFile, now, run })` (never throws) and `runLsRemote()` (`git ls-remote --tags` on the repo: no shell, `GIT_TERMINAL_PROMPT=0`, `GCM_INTERACTIVE=never`, SSH `BatchMode` when `GIT_SSH_COMMAND` is unset, `windowsHide`, killed at 10 s; git authenticates itself, the console never touches a credential). The answer, failures included, is cached for an hour in `~/.plan2code/console/update-check.json` (`UPDATE_CHECK_FILE`, in `PROTECTED_CONSOLE_FILES` so no sweep removes it). `server.mjs` starts it after the ready line and never awaits it; `stateFrame()` carries `update: { installed, latest }` only when a newer release exists (its `latest` is part of `haveKey()`, so a page that connected first still gets it), and `GET /version` returns `{ version, latest }`. Tests seed a fresh cached failure in every console home, so no test server reaches the network. The `plan2code` launcher reads the same cache for its terminal release notice (a copy of this module sits in `~/.plan2code/bin/`) |
|
||||
| `console.md` | the core of the agent-facing contract, read once per conversation (every skill ships the same copy, so a dashboard hop never re-reads it): starting, the turn (`post --wait`, the exit codes, handling a send, `settle`), posting, the payload and its kinds, documents (including `file` blocks), the house rules, and an index of the topic files below with the moment each is read. A test caps it at 24,000 characters |
|
||||
| `console-finish.md` · `console-stop.md` · `console-chat.md` · `console-workspace.md` · `console-subagents.md` · `console-launches.md` · `console-meter.md` · `console-attachments.md` · `console-trouble.md` | topic files, each read only when its moment first comes: finishing (the finish and its buttons), stop requests (the way home mid-workflow, `stopWarning`, resuming a pause), Quick questions, the Workspace, standing instructions and helper reports, dashboard launches and the menu payload, the session meter's `run` events (read only when a `run` is refused: the notes inline every `run`), keeping a cited note attachment, and recovery |
|
||||
| `notes/<workflow>.md` | per-workflow notes (`init` for both inits, `pathfinder` with Briefs, `plan`, `revise-plan`, `document`, `implement` for both builds, `loop` for a build the desktop app's Implementation Loop runs with `--loop` (where it reports a `loopOutcome` instead of asking for sign-off), `quick-task`, `review`, `finalize`, `handoff`, `changelog`, `git`, `xray`, `diagnose`, `pr-prep`, `test`). Each skill's Interface line reads `<D>/console.md` and its own notes file right after `open`; a test checks every skill names one that exists |
|
||||
| `notes/<workflow>.md` | per-workflow notes (`init` for both inits, `pathfinder` with Briefs, `plan`, `revise-plan`, `document`, `implement` for both builds, `loop` for a build the desktop app's Implementation Loop runs with `--loop` (where it reports a `loopOutcome` instead of asking for sign-off), `quick-task`, `review`, `finalize`, `handoff`, `changelog`, `git`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`). Each skill's Interface line reads `<D>/console.md` and its own notes file right after `open`; a test checks every skill names one that exists |
|
||||
| `building.md` · `building-review.md` | the build half of the contract, for `implement`, `implement-review` and `quick-task`: progress posts (`agent.activity`, `agent.quietMinutes`, `file` blocks re-read with `refresh`), the chat check between tasks, questions mid-build and stop requests; `building-review.md` is the review run on the page (the sign-off's `review` verdict, **Review it now**, Implement + Review's Stage 2, Finalize's Step 2.5), read only when asked for |
|
||||
@@ -145,6 +145,7 @@ plan2code/
|
||||
| `plan2code-diagnose.md` | diagnose | Find a bug's cause under the find-the-cause-first habit (`references/building-habits.md`) and write it up as `specs/<bug-name>/DIAGNOSIS-<YYYYMMDD>.md` without fixing it, then offer Quick Task to fix it, or Plan when the fix is big. The dashboard scan reports such a folder as spec state `diagnosed` ("Bug diagnosed"), which lights Quick Task (suggested) and Plan. Once Quick Task marks the diagnosis `Fixed` (nothing past it in the folder) the state is `fixed` ("Bug fixed"): no pipeline card lights, the picker never pre-selects it, and Quick Task offers to archive it with `specs.mjs archive` |
|
||||
| `plan2code-pr-prep.md` | pr-prep | Get a branch ready for review: pick the checks its changes need from the project's `## Test map` (or its config files), let the person trim the plan, run it, give Ready, Ready with notes or Not ready, and write a PR description to copy (following the repo's template) with the create-a-PR link; offers to save `PR-READINESS-<date>.md` into the branch's spec folder; never commits, pushes or opens the PR |
|
||||
| `plan2code-test.md` | test | Write missing tests: ask where to look, find source files no test covers (matching, plus real coverage when the project already has a coverage tool, offered first), show a plan opening with how this project writes tests, then write and run unit and integration tests; escalates past 8 source files, 8 new test files or 2 runners to a PLAN-DRAFT for Plan, hands a real bug to Diagnose, never changes source code |
|
||||
| `plan2code-dead-code.md` | dead-code | Find unused code and dead code: use the project's own dead-code tools, one per language that has files (Knip, vulture, cargo check and others), or search by itself, check every item for callers across the project (`references/caller-search.md`), label each Safe to remove, Check first or Warning, remove only what the person picks, then run the tests and build and put back anything that breaks them; never commits, never installs a tool. Scripts: `dead-code.mjs` (own), `test-map.mjs`, `glob.mjs`, `test-commands.mjs`, `run-check.mjs` |
|
||||
| `plan2code-changelog.md` | changelog | Check the CHANGELOG version against the default branch, suggest editable entries for new work, keep `package.json` aligned, offer to commit the result through Git |
|
||||
| `plan2code-git.md` | git | Branches, pull (with conflict help), push, publish and commits (clear message, suggested splits) on the web console's git board, or plain instructions in the terminal (`switch to main`, `commit and push`); asks before every push, publish and delete |
|
||||
|
||||
|
||||
@@ -17,13 +17,14 @@ Anything a workflow step decides with one correct answer (parsing a spec's check
|
||||
| `specs.mjs` | plan, revise-plan, document, implement, implement-review, review, quick-task, finalize, handoff, diagnose | `list` / `status` (the dashboard state, Phase Checklist, groups, task markers, numbering, the implement selection verdict, consistency checks) / `check` / `check-draft` / `metrics` / `mark` / `tick` / `archive`. `list` imports `scanProject()` from the bundled `web-console/scan.mjs`, and `status` calls `deriveSpecState()` and `pickPhaseFiles()` from `web-console/spec-files.mjs`, the one rule the scan also uses, so the dashboard and the skills never disagree on a spec's state (a phase with only blocked tasks left stays `building`, and `finalizeReady` lights Finalize once each has a written reason). `mark` writes the phase file's Status line on every move (`--to in-progress` too). `check`'s format rules (no Status line, a checkbox under Notes, a task pointing at a line number, a bare `[!]`) warn, and fail only a spec whose overview.md carries `<!-- plan2code-format: 2 -->`. `archive` that has to copy removes the source only once every file name and size at the target matches (`PLAN2CODE_ARCHIVE_FAULT` is its test seam) |
|
||||
| `commit-msg.mjs` | implement(-review), review, quick-task, finalize, init-update, git | The `<subject>` / `AI Assisted` commit command (two `-m` flags), with an optional `git add -- <files>` from `--files`. There is no add-everything option: `--add-all` was retired, and `scripts/test-script-git.mjs` fails if it returns anywhere in `src/` |
|
||||
| `review-scope.mjs` | review, implement(-review), quick-task, finalize, pr-prep, test | Review Mode's git fallback: files, lines, doc share, base branch |
|
||||
| `glob.mjs` | init, init-update, implement(-review), quick-task, finalize, pr-prep, test | The glob subset (`**`, `*`, `?`, `{a,b}`) as a RegExp, and forward-slash path normalizing; imported by `test-map.mjs` and `test-match.mjs` |
|
||||
| `test-map.mjs` | init, init-update, implement(-review), quick-task, finalize, pr-prep, test | `read` / `write` the project test map (one `\| Area \| Paths \| Run \| Shared \|` table under `## Test map` in `AGENTS.md`, or behind one link to `.agents-docs/`); every line outside the table stays byte-identical |
|
||||
| `glob.mjs` | init, init-update, implement(-review), quick-task, finalize, pr-prep, test, dead-code | The glob subset (`**`, `*`, `?`, `{a,b}`) as a RegExp, and forward-slash path normalizing; imported by `test-map.mjs` and `test-match.mjs` |
|
||||
| `test-map.mjs` | init, init-update, implement(-review), quick-task, finalize, pr-prep, test, dead-code | `read` / `write` the project test map (one `\| Area \| Paths \| Run \| Shared \|` table under `## Test map` in `AGENTS.md`, or behind one link to `.agents-docs/`); every line outside the table stays byte-identical |
|
||||
| `test-match.mjs` | implement(-review), quick-task, finalize, pr-prep, test | `covers` (changed files to the map rows and tests that cover them, plus shared-ground hints), `gaps` (source files no test covers, ranked by recent change) and `nearest` (existing tests to read for style) |
|
||||
| `test-commands.mjs` | init, init-update, pr-prep, test | `discover`: the whole-suite command, per-folder runners, lint/types/build checks, coverage commands already present and the language's built-in runner, from config files only |
|
||||
| `run-check.mjs` | implement(-review), quick-task, finalize, pr-prep, test | Run one command with a timeout, kill its process tree on timeout, and classify it `passed`, `failed`, `timeout` or `not-started` with the output's tail |
|
||||
| `test-commands.mjs` | init, init-update, pr-prep, test, dead-code | `discover`: the whole-suite command, per-folder runners, lint/types/build checks, coverage commands already present and the language's built-in runner, from config files only |
|
||||
| `run-check.mjs` | implement(-review), quick-task, finalize, pr-prep, test, dead-code | Run one command with a timeout, kill its process tree on timeout, and classify it `passed`, `failed`, `timeout` or `not-started` with the output's tail |
|
||||
| `pr-prep.mjs` (own) | pr-prep | `template` (the PR template and its headings), `pr-url` (the create-a-PR link through `git-repo.mjs`) and `spec` (the branch's spec folder for the save offer). Read-only |
|
||||
| `coverage.mjs` (own) | test | `read --lcov` / `--go-func`: coverage output as per-file lines, hits and percent, plus the total. Read-only, runs no tool |
|
||||
| `dead-code.mjs` (own) | dead-code | `detect` (the dead-code tools the project already has, languages, file counts), `run --tool` (a tool's output as candidates), `narrow` (folders ranked by candidates), `keep list\|filter\|add\|remove` (the shared keep list, `.plan2code-dead-code/keep.md`; rows matched by file, name and the hash of the item's declaration line, `#n` for the n-th identical line, `file:` for a whole file; `remove` takes `--hash` or `--line` and exits 2 `ambiguous-entry` when two rows share a name), `backup` and `restore --verify` (copies outside the project and a checked put-back), `report write` (`.plan2code-dead-code/reports/DEAD-CODE-<date>.md`; `tool` one id or a list of ids) and `gitignore-check` / `gitignore-add`. Writes only code removals the agent makes, `keep.md` and, on a yes, a report and the `.gitignore` line |
|
||||
| `agents-md.mjs` | init, init-update | AGENTS.md structure, budget, orphans, broken links, always-inline sections. With no AGENTS.md yet (Init's run, so said once), `notices` warns when `.gitignore` keeps `specs--completed/` out of git, since archived specs are then not backed up |
|
||||
| `agent-files.mjs` | init, init-update | Detect and replace other agents' config files with AGENTS.md pointers |
|
||||
| `pathfinder.mjs` (own) | 0-pathfinder | `init` (the map in its Step 5 state from `--destination`, `--scores` and `--fog`; refuses an existing map) and `add` (the next `questions/NN-<slug>.md` plus its map row), with the references' templates kept as the fallback, then `reconcile`, `frontier`, `claim`, `resolve`, `rule-out`, `trail`, `gate` (which also prints the exact PLAN-DRAFT status line `specs.mjs` reads), `lint`, `brief-data`. Writes rows as `[Name](link): tail` with no em dash, and still reads maps written the old way |
|
||||
|
||||
@@ -87,6 +87,7 @@ The fast lane is `npm run test:fast` (`scripts/test-fast.mjs`): it runs the file
|
||||
| One web console area (server routes, chat, git board, workspace, notepad, Implementation Loop...) | that area's `scripts/test-web-console-<area>.mjs` (the loop's is `test-web-console-loop.mjs`), and its `test-web-console-page-<area>.mjs` when the page changed; `node scripts/parse-check.mjs` after editing any browser module under `public/` |
|
||||
| The launcher (`src/launcher/`) | `node --test scripts/test-launcher.mjs` |
|
||||
| A skill's script | `npm run build:skills`, then `node --test scripts/test-script-<skill>.mjs` (and `test-skill-scripts.mjs` for the shared plumbing) |
|
||||
| Dead Code (`src/plan2code-dead-code-scripts/`, `scripts/fixtures/dead-code/`) | `npm run build:skills`, then `node scripts/node-test.mjs scripts/test-script-dead-code.mjs` |
|
||||
| A workflow prompt (`src/plan2code-*.md`) | `node scripts/validate-char-count.js` and `node scripts/check-skill-table.mjs` |
|
||||
| A new skill or console workflow | First update the hand-written tables that list every workflow: the `SUBAGENT_WORKFLOWS` count and the meter's `WEIGHTS`, `LAUNCH_LABELS` and `RUN_LABELS` in `test-web-console-logic.mjs`, `notesFor` in `test-web-console-speed.mjs`, the event list in `src/web-console/console-meter.md` (checked by `test-web-console-chat-stress.mjs`) and a `BUDGETS.notes` entry in `test-console-wire-budgets.mjs`. Then run those four suites plus `test-web-console-skills.mjs` and `test-web-console-spec-states.mjs`; the PR Prep and Test build missed all five tables and only the full suite caught them |
|
||||
| Docs or comments only | `node --test scripts/test-us-english.mjs scripts/test-line-endings.mjs` |
|
||||
|
||||
@@ -30,6 +30,10 @@ A rule stated in six files is read six times and still skipped. The console sees
|
||||
|
||||
Documents are read from `file` blocks rather than pasted so the page and the disk cannot disagree, and a progress post only has to ask for `refresh`. `assumed` and `draft` exist so a half-finished doc is not read as decisions. A doc `version` never goes back because the page keys its "new version" marker on it.
|
||||
|
||||
## Noted questions
|
||||
|
||||
A person's note on an open question may change what it asks, and the agent's reply in the thread does not say what happens to the question. The server therefore records the fact (`noted`) when the note lands, and `validate()` refuses a new open required question until each noted one is reworded, deleted or confirmed with `stands: true`. A thread cannot answer this: it stays true forever after one reply. The page shows the same flag as a tag, and keeps the arrival notice and a New mark until the new question is opened, since eight seconds is easy to miss mid-sentence.
|
||||
|
||||
## console-finish.md and console-stop.md
|
||||
|
||||
- **Finish before stop.** The page tells the person to leave the tab open until the next question appears. Stopping first leaves them looking at a promise about a session that is over, and the one thing they need, a command to run in a terminal they are not looking at, never reaches them. The console refuses a `stop` with no `finish` (`--force` for a dead page).
|
||||
|
||||
@@ -310,7 +310,7 @@ Built for a mixed product and engineering room reading one screen together.
|
||||
|
||||
- **One width variable.** `--card-width` on `:root` in `styles/tokens.css` sets the column the card, the pager and the document tabs share (`max-width: min(var(--card-width), 100%)`, so a narrow window still wins); no fixed `720px` column rule is left outside a media query. Three presets, picked under *Card width* in the looks panel and saved as `looks.width`: `narrow` 720px, `comfortable` 880px (the default, and the variable's own value), `wide` 1080px, applied as `:root[data-width="…"]`. `CARD_WIDTHS` in `palette.js` is the same list for the page's validation and the server's first-paint `data-width`; **`palette.js` and `app.css` must agree**, which is the one place the number is written twice. The dashboard keeps its own 860px layout. Inside the card the `62ch` / `68ch` measure caps come off (`.card .md, .card .prompt { max-width: none; }`) so a wider card is not a narrow column in a wide frame; documents keep `.md`'s 68ch.
|
||||
- **One box grows.** On the primary card, the answer box that is being typed in — a `text` question's box, a choice's *Something else* box once picked, or the note under a verdict / confirm / recap once shown — is `textarea.grow`, and the card takes the column's full height above the pager (`.card.is-primary.has-grow { flex: 1 1 auto; }`). `fitGrowBox()` in `app.js` writes the card's free height as the box's `min-height`, **never under 160px**; a `ResizeObserver` watches the main column rather than the box, so the box growing can never retrigger it, and it writes only on a change over 1px. `resize: vertical` with that moving floor makes the handle taller-only; past the fill the card scrolls. Every other box keeps its ordinary size, and the notes panel is untouched.
|
||||
- **A switch per sound.** Every cue is an event in `SOUND_EVENTS` (`palette.js`), each naming its file and rank: `startSkill` (`start-skill.mp3`, played once the dashboard's **Start** is accepted) 5, `bootup` 4, `sessionStart` / `sessionEnd` (`start-stop.mp3`) 3, `question` / `skillReady` / `chatReply` (`next.mp3`) 2, `newTab` (`insert.mp3`) 1, `snore` (`sleeping.mp3`, looped by the wake-up outside the queue) 0. The queue, the held slot and the one-at-a-time rule in `app.js` work on events, one `Audio` per file shared by the events that use it. User Preferences shows a *Play sounds* master (`looks.sound`) over one box per event, saved flat as `sound<Event>` (`soundStartSkill`, …) because `looks.json` only holds flat values; `soundPrefs()` turns any missing or non-boolean switch on, so a file from before the switches keeps every sound. A cue plays only while the master and its own switch are both on; the master off grays the boxes but keeps their ticks, and ticking a box plays it.
|
||||
- **A switch per sound.** Every cue is an event in `SOUND_EVENTS` (`palette.js`), each naming its file and rank: `startSkill` (`sounds/sound-14.mp3`, played once the dashboard's **Start** is accepted) 5, `bootup` 4, `sessionStart` (`sounds/sound-07.mp3`) / `sessionEnd` (`sounds/sound-15.mp3`) 3, `question` (`sounds/sound-14.mp3`) / `skillReady` (`sounds/sound-16.mp3`) / `chatReply` (`sounds/sound-06.mp3`) 2, `newTab` (`sounds/sound-05.mp3`) 1, `snore` (`sleeping.mp3`, looped by the wake-up outside the queue) 0. The queue, the held slot and the one-at-a-time rule in `app.js` work on events, one `Audio` per file shared by the events that use it. User Preferences shows a *Play sounds* master (`looks.sound`) over one box per event, saved flat as `sound<Event>` (`soundStartSkill`, …) because `looks.json` only holds flat values; `soundPrefs()` turns any missing or non-boolean switch on, so a file from before the switches keeps every sound. A cue plays only while the master and its own switch are both on; the master off grays the boxes but keeps their ticks, and ticking a box plays it. Seven cues (not `snore` or `bootup`) also keep a pick out of the 19 files in `public/sounds/`, saved flat as `soundFile<Event>` (`soundFileQuestion`); `soundFilePrefs()` validates it against `SOUND_FILES` and a missing or unknown value falls back to the event's default, `sound.js` plays it, and the picker's select and Play button call `previewSound()`, which cuts off what is playing and is dropped behind a still-audible ranked cue.
|
||||
- **Send breathes.** `#btn-send:not(:disabled)` runs `send-pulse`, a soft accent ring that spreads and fades every 2.4s; a disabled Send is still, and reduced motion switches it off.
|
||||
- **Per-tab scroll memory.** An in-memory `Map` keyed by view id holds the scroller's position (the main column on a document or the Overview, the card on the questions view, with the item it belonged to), restored when the tab comes back. Page-local, never persisted, cleared when the session turns into or out of the dashboard.
|
||||
- **The Overview tab.** Appears only while `GET /overview` returns a file for the session's spec (on the dashboard: the picker's spec; gone for *start from scratch*), fetched with `no-store` on load, on a spec change and on every tab click, so it always shows the file as it is on disk. On the dashboard, a spec with no overview gets a **Map** tab (`?file=map`, `pathfinder/map.md`) and a **Plan draft** tab (`?file=draft`, the live `PLAN-DRAFT-*.md`) in its place, each while its file exists, fetched and drawn the same way; away from the dashboard only the overview is read, since a session's own map or draft is the work already in front of it. Rendered through the same DOM-only markdown path as every doc, captioned read-only. It never becomes a doc: the page is not the record.
|
||||
|
||||
+16
-8
@@ -55,7 +55,7 @@ Scroll down for the utilities. Outside a git repository the **Git** card says so
|
||||
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="../docs/screenshots/dashboard-utilities-dark.webp">
|
||||
<img src="../docs/screenshots/dashboard-utilities-light.webp" alt="The utility cards: Quick task, Review, Handoff and Git, which notes that the folder is not a git repository yet and offers to start one.">
|
||||
<img src="../docs/screenshots/dashboard-utilities-light.webp" alt="The utility cards: Get a PR ready, Write missing tests, Clear out dead code, Changelog, Git, which notes that the folder is not a git repository yet and offers to start one, and Handoff.">
|
||||
</picture>
|
||||
|
||||
---
|
||||
@@ -150,7 +150,10 @@ Scroll down for the utilities. Outside a git repository the **Git** card says so
|
||||
snoring, Planny waking up, starting a skill, session opens, skill is ready,
|
||||
session ends, new questions, a reply on Ask, a new tab), so you can keep only
|
||||
the ones you want. Ticking a box plays its sound; everything is remembered
|
||||
like the colors.
|
||||
like the colors. Seven of the moments (everything except Planny snoring and
|
||||
waking up) also have a menu of 19 sounds and a Play button, so you can give
|
||||
each its own; picking one plays it, and the sounds you hear today are the
|
||||
defaults.
|
||||
- **Files in your notes.** Show instead of describe: attach a screenshot, a
|
||||
photo or a document to any note or quick question (see *Attachments in notes
|
||||
and questions* below).
|
||||
@@ -232,7 +235,7 @@ and hides it while *Hide unavailable workflows* is on. Its chip has a visible
|
||||
removes the folder (any other spec also asks you to type its name). Click a card 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. Pathfinder, Plan, Quick Task and Revise plan can also
|
||||
command names to remember. Pathfinder, Plan, Quick Task, Diagnose and Revise plan can also
|
||||
start from one of your [Notebook](#your-notebook) tabs: see *Sent from the
|
||||
dashboard* there.
|
||||
|
||||
@@ -319,8 +322,8 @@ command and the app use, so all three agree):
|
||||
system are listed, each with a Copy button, beside an **Install page** link.
|
||||
|
||||
**Check again** re-runs the lookup without restarting anything, so an agent you just installed
|
||||
turns up. Under the list are four starter templates (GitHub Copilot CLI, OpenCode, Gemini CLI,
|
||||
Pi): starting setups for agent CLIs Plan2Code does not ship, which fill in the same form as adding
|
||||
turns up. Under the list are five starter templates (GitHub Copilot CLI, OpenCode, Gemini CLI,
|
||||
Pi, Cursor CLI): starting setups for agent CLIs Plan2Code does not ship, which fill in the same form as adding
|
||||
an agent by hand and save as custom agents. The page's Help has a *Setting up an agent* topic, and
|
||||
signing in to the agent itself is always your own step.
|
||||
|
||||
@@ -1602,8 +1605,13 @@ as your move rather than leaving a stale "starting" line behind.
|
||||
A stopped loop also offers **Ask a question**, first in the row. The app ended
|
||||
its agent when the loop stopped, so the Ask tab says no agent is available;
|
||||
the button wakes an ordinary agent on the same page, without starting the loop
|
||||
or changing anything, and **Resume the loop** is still there afterwards. **Back
|
||||
to the dashboard** ends that agent too.
|
||||
or changing anything, and **Continue building** is still there afterwards; once
|
||||
the agent is up, the button opens the Ask tab instead. **Back to the dashboard**
|
||||
ends that agent too. The stop screen leads with a short reason, puts one line
|
||||
under each button saying what it does, and highlights the one that fits the
|
||||
stop: **Continue building** after a crash, a silence or your own stop, **Fix
|
||||
together with an agent** after a failed check, a blocked task, a refused commit
|
||||
or a question. The phases and uncommitted files sit under **Details**.
|
||||
|
||||
You don't have to finish first. On every skill but the dashboard itself, a
|
||||
small **triangle** pointing left, in your highlight color, sits beside *Stop
|
||||
@@ -1974,7 +1982,7 @@ origin.
|
||||
| `POST /notepad/tab/delete` | `{ id }`. Removes the tab from the index, then its folder (text and pictures); 404 `no-such-tab`. |
|
||||
| `POST /notepad/tab/order` | `{ order: [id] }`, every current id exactly once; 400 `bad` otherwise. |
|
||||
| `POST /notepad/tab/last` | `{ id }`. Remembers the open tab; 404 `no-such-tab`. |
|
||||
| `POST /notepad/tab/sent` | `{ id, workflow, spec? }`. Records that the tab was sent (`workflow` one of `pathfinder`, `plan`, `quick-task`, `revise-plan`; `spec` like `specs/<name>`) as `sent: { workflow, spec?, at }` on its `tabs.json` entry, shown back in `GET /notepad`'s `tabs`. The page posts it only after the Send that carried the filled box; 400 `bad-sent`, 404 `no-such-tab`. |
|
||||
| `POST /notepad/tab/sent` | `{ id, workflow, spec? }`. Records that the tab was sent (`workflow` one of `pathfinder`, `plan`, `quick-task`, `revise-plan`, `diagnose`; `spec` like `specs/<name>`) as `sent: { workflow, spec?, at }` on its `tabs.json` entry, shown back in `GET /notepad`'s `tabs`. The page posts it only after the Send that carried the filled box; 400 `bad-sent`, 404 `no-such-tab`. |
|
||||
| `GET /notepad/images/<tab>/<uuid>.jpg`, `<uuid>.thumb.jpg` | Serves a picture or its thumbnail as `image/jpeg`, only by a tab id and a UUID name, a regular file (never a link) whose real path stays inside `~/.plan2code/notepads/`; anything else is 404. |
|
||||
| `POST /subagents` | `{ on, instruction, max }` (`instruction: null` for the shipped default). Saves the switch for this project and skill and answers `{ ok, setting }`; 400 `not-offered` on a skill without the switch, `bad`, `too-long` (over 2,000 characters) or `max` (outside 1 to 20). |
|
||||
| `GET /agents` | The agents view's data: your custom agents and the shipped built-ins and templates, each entry merged with its lookup result `{ state, path, where, folder }`: `state` is `found` (on PATH), `outside` (saved Windows PATH, npm's global folder or an install folder) or `missing`, and `where` says which search found it. Built-ins carry their `install` lines for the server's OS only. |
|
||||
|
||||
@@ -4,7 +4,7 @@ This file provides guidance to AI coding agents working with code in this reposi
|
||||
|
||||
## Project Overview
|
||||
|
||||
Plan2Code is a structured 4-step workflow methodology for AI-assisted software development. It provides prompt templates (skills) that the `skills` CLI installs globally or per-project into any agent it supports (README's "Supported tools" lists them). The `plan2code` command and the desktop app launch the dashboard directly in the built-in agents of `src/launcher/agents.json` (Claude Code, Devin, Codex); Copilot CLI, OpenCode, Gemini CLI and Pi are starter templates there, and any other agent CLI can be added as a custom agent.
|
||||
Plan2Code is a structured 4-step workflow methodology for AI-assisted software development. It provides prompt templates (skills) that the `skills` CLI installs globally or per-project into any agent it supports (README's "Supported tools" lists them). The `plan2code` command and the desktop app launch the dashboard directly in the built-in agents of `src/launcher/agents.json` (Claude Code, Devin, Codex); Copilot CLI, OpenCode, Gemini CLI, Pi and Cursor CLI are starter templates there, and any other agent CLI can be added as a custom agent.
|
||||
|
||||
**Version:** Check `version.json` for current version
|
||||
**Author:** Justin Parker
|
||||
@@ -36,7 +36,7 @@ Details: [Status line](./.agents-docs/AGENTS-architecture-statusline.md)
|
||||
|
||||
## Web Console
|
||||
|
||||
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) installed once under `~/.plan2code/console/<version>/` (`installSharedConsole` in `install.js`) and reached from every skill through a forwarding stub, `src/web-console-stub/console.mjs`. 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`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (thirteen small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, listed in `public/activities.js` with one module per game under `public/activities/` (Ghoul Rush is its own folder of modules, `public/activities/ghoul-rush/`) and a card line (`blurb`) each, a picker page of game cards once two are listed that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run, Flock Dash's furthest stage), never shown to the agent), a built-in 21-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, Finalize, Changelog, Git and Handoff) 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`), and a Helper strength choice (Balanced, Thrifty, Best, Match my session; rules in `src/shared-references/helper-strength.md`, shipped in the twelve helper skills); 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`). Per-skill facts live inLine truncated
|
||||
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) installed once under `~/.plan2code/console/<version>/` (`installSharedConsole` in `install.js`) and reached from every skill through a forwarding stub, `src/web-console-stub/console.mjs`. 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`), **Stop with a handoff** (handoffs live in `~/.plan2code/handoffs/`, owned by `handoffs.mjs`, swept after 30 days, and offered as dashboard chips to pick up in the same session), a private **Notebook** in the top bar (named tabs of Markdown and pictures, a live-preview CodeMirror editor, one notepad per folder in `~/.plan2code/notepads/`, owned by `notepads.mjs`, private: the agent reads a tab only when you start Pathfinder, Plan, Quick Task or Revise plan from the dashboard with it and send the box it fills (an idea box marked `fill: "note"`, up to five ticked pictures attached), which then marks the tab sent via `POST /notepad/tab/sent`; the agent CLI never imports the store; removed only through Cleanup once a month untouched), **Activities** behind the top bar's die (thirteen small games, Snake, Mini golf, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash, listed in `public/activities.js` with one module per game under `public/activities/` (Ghoul Rush is its own folder of modules, `public/activities/ghoul-rush/`) and a card line (`blurb`) each, a picker page of game cards once two are listed that plays one game at a time (another pick drops the last game's round), driven by `screens/activities.js` (keys, key releases for a game with `release()`, canvas pointer events for a game with `pointer()`, one frame timer), paused whenever the person's turn comes and resumed only by the person (while that pause's banner is up, only by its **Unpause game** button), best scores in flat `activityBest<Id>` keys in `looks.json` (lowest wins for a game that sets `lowerIsBetter`; Mini golf opens on a dashboard of its six 18-hole courses, one file each under `public/activities/golf-course-<id>.js`, and keeps a best per course, `activityBestGolf<Course>`), and one number a game may keep between sessions in `activityMemo<Id>` (Snake's tally of surprises found, Light Trails' furthest arena, Bug Hunt's tally of finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's most stages cleared in a run, Flock Dash's furthest stage), never shown to the agent), a built-in 21-topic Help, the app-only **Implementation Loop** (a dashboard card and a setup screen drawn by the page, `public/screens/loop-setup.js`; the last setup remembered per project in `~/.plan2code/console/loop-setup.json`, owned by `loop-setup.mjs`; a page that locks while `state.loop.driving` is set, until the app posts `loopEnd`; a skill run with `--loop` reports a `loopOutcome` instead of asking for sign-off, per `notes/loop.md`), a first-run Welcome, User Preferences (gear: four tabs, Appearance, Agents & models, System and Sounds & activities, on the `public/tabs.js` helper Help also uses, with `public/prefs.js`, `screens/prefs-dialog.js` and `screens/agents-view.js`), an agent-less **setup** page (the `setup` workflow `plan2code` or the desktop app opens when no agent can run: each built-in's found / outside-PATH / missing state from `agent-lookup.mjs`, install lines, Check again, Use it from here, starter templates and Start, which hands the tab to the new agent through a token-guarded `POST /handover` and a `move` event; the app shows it in its window from a Set up an agent button instead) and a bug/idea link to GitHub issues. On opted-in skills (every workflow but the dashboard, Finalize, Changelog, Git and Handoff) 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`), and a Helper strength choice (Balanced, Thrifty, Best, Match my session; rules in `src/shared-references/helper-strength.md`, shipped in the sixteen helper skills); 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`). Per-skill facts live iLine truncated
|
||||
|
||||
One agent list and one lookup rule serve the launcher, the console and the app: `src/launcher/agents.json` (the built-ins and starter templates with per-OS install data) and `src/web-console/agent-lookup.mjs` (`loadAgentList()` and `findAgent()`, both copied by `install.js` into `~/.plan2code/bin/`); the app carries a Rust twin held to the same cases by `scripts/fixtures/agent-lookup-cases.json`.
|
||||
Building or changing an Activities game: follow the game rules in [Activities](./.agents-docs/AGENTS-architecture-activities.md) ("Building an Activities game": lives in the solid lives pill, the endless-lives code (`cheat(on)`) in every game with lives, banners placed away from the player and see-through over what matters, pausing left to the window).
|
||||
|
||||
@@ -2,6 +2,32 @@
|
||||
|
||||
All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
## v3.0.5
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **web console**: the Implementation Loop's **Strength per phase** setting is now a grid instead of a dropdown per phase: one row per phase, a column each for Match my session, Thrifty, Balanced and Best, and a thick stepped line through each row's pick so the choices read at a glance. The saved picks and the loop's behavior are unchanged.
|
||||
- **desktop app**: the Loop's stopped screen says why it stopped and recommends one button.
|
||||
- **desktop app**: loop webhook notifications arrive as cards (Discord embeds, Slack attachments, Google Chat cards) with a colored bar.
|
||||
- **launcher**: refreshed model menu and agent data: Devin's SWE-2 Flash models replace GPT-5.6 Sol (SWE-2 Flash High is the Loop's Thrifty default), Codex is also found in its Windows install folder, and the Gemini CLI note names the accounts Antigravity replaced.
|
||||
|
||||
### ✨ Added
|
||||
|
||||
- **web console**: Diagnose can now start from a Notebook tab.
|
||||
- **Dead Code**: a new `/plan2code-dead-code` skill (and a dashboard card in Useful any time) finds code nothing uses with the project's own tools, one per language, or a search of its own, checks every item for callers, labels it Safe, Check first or Warning, and removes only what you pick; a shared keep list hides items you mean to keep, matched by their own declaration line so a kept item never hides a same-named one.
|
||||
- **launcher**: a Cursor CLI starter template.
|
||||
- **desktop app**: the app bar shows the model, and effort when it takes one, that the agent was started on.
|
||||
- **web console**: each sound cue can pick from 19 sounds in Preferences.
|
||||
- **web console**: an Always SKIP Intro preference goes straight to the dashboard instead of waking Planny first.
|
||||
- **desktop app**: a New Session keeps the spec you were in, and the top bar names the spec beside the meter.
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
- **web console**: a question you put a note on is now flagged as noted, and the console refuses a new question from the agent until it rewords, deletes or confirms the noted one, so a question a reply made moot no longer sits open while the next one is buried; the page tags the card, keeps the new-question notice up until dismissed, and marks the new question "New" in the list.
|
||||
- **web console**: a finish screen that was left stranded now has a way out, and a pressed Review clears when a different finish replaces it.
|
||||
- **web console**: Quick Task asks for sign-off after its See it running demo.
|
||||
- **web console**: a loop phase whose page does not show now offers a reconnect button.
|
||||
|
||||
## v3.0.4
|
||||
|
||||
### ✨ Added
|
||||
|
||||
@@ -49,6 +49,7 @@ Every command below is what a dashboard card runs. Typed on its own, each one as
|
||||
| diagnose | /plan2code-diagnose | A bug, or none | `DIAGNOSIS-<date>.md` with the cause and its evidence, then Quick Task (or Plan for a big fix) to fix it |
|
||||
| pr-prep | /plan2code-pr-prep | Your branch | A readiness verdict (Ready, Ready with notes, Not ready) and a PR description to copy; no commits, no push |
|
||||
| test | /plan2code-test | An area, or none | New unit and integration tests in the project's style, run; a bug handed to Diagnose; no source changes |
|
||||
| dead-code | /plan2code-dead-code | A folder, or none | Findings labeled Safe, Check first or Warning, then only the removals you pick, checked by the tests and build; no commits, no installs |
|
||||
| changelog | /plan2code-changelog | Your branch | `CHANGELOG.md` entries and the `package.json` version, from the default branch's latest version |
|
||||
| git | /plan2code-git | Your repo | Commits (`<subject>` / `AI Assisted`), branches, pull with conflict help, push, publish |
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ the next engineer all start from the same specs.
|
||||
|
||||
One command opens it, every step is a card, and the terminal is always there if you prefer it.
|
||||
|
||||
Version 3.0.4 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
Version 3.0.5 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
|
||||
---
|
||||
|
||||
@@ -101,8 +101,8 @@ Devin or Codex, and no working custom agent),
|
||||
The page lists each agent as **Found**, **Found outside PATH** or **Not found**, with its install
|
||||
commands for your system, a Copy button per command and an **Install page** link. Install one and
|
||||
press **Check again**: no restart needed. An agent found outside `PATH` gets **Use it from here**,
|
||||
which saves where it was found so you never touch `PATH` yourself. Below the list sit four starter
|
||||
templates (GitHub Copilot CLI, OpenCode, Gemini CLI and Pi) for agents Plan2Code does not ship.
|
||||
which saves where it was found so you never touch `PATH` yourself. Below the list sit five starter
|
||||
templates (GitHub Copilot CLI, OpenCode, Gemini CLI, Pi and Cursor CLI) for agents Plan2Code does not ship.
|
||||
**Start with this agent** carries the run straight on in the same tab, onto the new agent's
|
||||
dashboard. Naming a built-in that is missing with `--cli <name>` opens the same page on that agent
|
||||
(a missing custom agent prints its own steps and exits 127). In the
|
||||
@@ -147,7 +147,7 @@ plain `plan2code` command above, without the app, asks instead, with prompts off
|
||||
GitHub Copilot · Windsurf · Codex · Continue · Codeium · Zed · Amp · OpenCode · Devin · Crush · Pi ·
|
||||
Gemini CLI · Cline · Roo · Kilo · Goose · Trae · Qwen Code.
|
||||
|
||||
**Launched by `plan2code`:** the `plan2code` command and the desktop app open the dashboard directly in Claude Code, Devin and Codex (the built-ins in `src/launcher/agents.json`). GitHub Copilot CLI, OpenCode, Gemini CLI and Pi come as starter templates, and you can add any other agent CLI as a custom agent in User Preferences → Agents & models.
|
||||
**Launched by `plan2code`:** the `plan2code` command and the desktop app open the dashboard directly in Claude Code, Devin and Codex (the built-ins in `src/launcher/agents.json`). GitHub Copilot CLI, OpenCode, Gemini CLI, Pi and Cursor CLI come as starter templates, and you can add any other agent CLI as a custom agent in User Preferences → Agents & models.
|
||||
|
||||
The installer keeps one canonical copy of each skill under `~/.agents/skills/` and links it into
|
||||
agents that maintain their own directory. To update, run `plan2code update` (or re-run the install command); to remove it all, run `plan2code uninstall`.
|
||||
@@ -257,6 +257,7 @@ The dashboard's cards, and when each one lights up for the spec you pick:
|
||||
| Diagnose a bug | Find a bug's cause and write it up, without fixing it. | Always |
|
||||
| Get a PR ready | Runs the checks your branch needs, says if it is ready, and writes the PR description to copy. Never commits, pushes or opens the PR. | Always |
|
||||
| Write missing tests | Finds code with no tests and writes unit and integration tests in your project's own style. Never changes source code. | Always |
|
||||
| Clear out dead code | Finds code nothing uses, says how safe each piece is to remove, and removes only what you pick. Uses the dead-code tools your project already has, and never commits. | Always |
|
||||
| Changelog | Checks the CHANGELOG version against the main branch and suggests entries for what is new. | Always |
|
||||
| Git | Branches, pull, push and commits on one board, asking before anything leaves your machine. | Always (offers to start a repository outside one) |
|
||||
|
||||
@@ -429,6 +430,7 @@ console or the terminal; add `--web` to skip the question and go straight to the
|
||||
| `/plan2code-diagnose` | Find a bug's cause and write it up as `specs/<bug-name>/DIAGNOSIS-<date>.md` without fixing it, then offer `/plan2code-quick-task` to fix it, or `/plan2code-1-plan` when the fix is big |
|
||||
| `/plan2code-pr-prep` | Before you open a pull request. Picks the checks the branch's changes need from the project's `## Test map` (or its config files), runs the ones you keep, says Ready, Ready with notes or Not ready, and writes a PR description to copy with the create-a-PR link; never commits, pushes or opens the PR |
|
||||
| `/plan2code-test` | Parts of the code have no tests. Asks where to look, finds the untested files (plus real coverage when the project already has a coverage tool), shows a plan in the project's own style, then writes and runs unit and integration tests; never changes source code, hands a real bug to `/plan2code-diagnose` |
|
||||
| `/plan2code-dead-code` | Code nothing calls anymore. Uses the project's own dead-code tools, one per language (Knip, vulture, cargo check and others), or searches by itself, checks every item for callers across the project, labels each Safe to remove, Check first or Warning, removes only what you pick, then runs the tests and build and puts back anything that breaks them; never commits, never installs anything |
|
||||
| `/plan2code-changelog` | Check the CHANGELOG version against the default branch, suggest entries for new work you can edit, keep `package.json` aligned, then hand off to Git to commit |
|
||||
| `/plan2code-git` | Branches, pull, push and commits on one board (or plain instructions in the terminal); asks before every push, publish and delete |
|
||||
|
||||
|
||||
+16
-10
@@ -100,7 +100,7 @@ me** under **User Preferences → System → Desktop app** (shown only inside th
|
||||
|
||||
A slim top bar reads, left to right: the project folder's name, a menu holding its full path and
|
||||
**Change project**; **New Session**, whenever an agent exists; the agent's own menu, with a dot for its
|
||||
state, an amber **checks off** badge while permission checks are off, and **Change agent** once it has
|
||||
state, the model (and effort, when it takes one) it was started on, when you picked one, an amber **checks off** badge while permission checks are off, and **Change agent** once it has
|
||||
ended; a short line (why the agent ended, a New Session's brief, or what went wrong); and, at the right
|
||||
end, the one next step for the console or the skills when there is one (**Reconnect the console**,
|
||||
**Update skills**), with "+N more" if anything else is waiting behind it. The console itself, opening inside the
|
||||
@@ -146,7 +146,7 @@ not), so your own edits never end up inside a phase's commit.
|
||||
- **Fix findings**: **Smart pick** (the default) has a fresh agent read the findings and fix only the
|
||||
ones worth fixing, recording every skip. A skipped Critical stops the phase. **By level** fixes the
|
||||
Critical, Warning and Suggestion findings you tick (all three start ticked).
|
||||
- **Strength per phase** (off): turn on **Set strength per phase** to pick **Thrifty**, **Balanced**, **Best** or **Match my session** for each phase still to build (or **Set all to** one pick). A phase you leave untouched runs on the model the app was launched with, as before. A phase whose agent crashes or goes quiet gets its one retry (when the retry tick is on) one step up (Thrifty to Balanced, Balanced to Best; Best stays Best; **Match my session** runs on the launch model and its retry stays there), and the phase's helpers follow the same strength. Which model each word means for your agent is set in User Preferences, **Agents & models**, under **Strengths in the loop**; an agent with nothing mapped shows the toggle off with a link there. The picks are remembered per project and spec, and a pick for a phase that is done or gone is dropped.
|
||||
- **Strength per phase** (off): turn on **Set strength per phase** to see one row per phase still to build under four headed columns, **Match my session**, **Thrifty**, **Balanced** and **Best**, and click a dot in a row to pick (the arrow keys move along a row), or use **Set all to** for one pick. A thick line steps through each row's picked dot, so the choices read at a glance, and the model each pick becomes shows at the end of its row. A phase you leave untouched runs on the model the app was launched with, as before. A phase whose agent crashes or goes quiet gets its one retry (when the retry tick is on) one step up (Thrifty to Balanced, Balanced to Best; Best stays Best; **Match my session** runs on the launch model and its retry stays there), and the phase's helpers follow the same strength. Which model each word means for your agent is set in User Preferences, **Agents & models**, under **Strengths in the loop**; an agent with nothing mapped shows the toggle off with a link there. The picks are remembered per project and spec, and a pick for a phase that is done or gone is dropped.
|
||||
- **When a phase asks something**: **Take the agent's best guess** (the default), which records the
|
||||
assumption as a `[?]` task, **Pause and wait for me**, or **Stop the loop**.
|
||||
- **After the last phase**: **Stop and offer Finalize** (the default) or **Run Finalize automatically**.
|
||||
@@ -163,7 +163,7 @@ not), so your own edits never end up inside a phase's commit.
|
||||
The last setup is remembered per project in `~/.plan2code/console/loop-setup.json`, so the next loop
|
||||
starts from it. The quick check is typed text the page never runs: the app reads it from that file
|
||||
itself and names it in its own window before the loop begins. The notification gets the same treatment,
|
||||
and Resume asks again if either one changed.
|
||||
and Continue building asks again if either one changed.
|
||||
|
||||
**The notification.** The loop says a question is waiting, that it is complete, or why it stopped, and,
|
||||
when you turn on **Also tell me when each phase is complete**, that a phase passed. Nothing is sent when you
|
||||
@@ -176,12 +176,18 @@ Done: 5 tasks, committed "Add votes" (abc1234). Next: Phase 3, Results. Elapsed:
|
||||
| Send to | Request | Where the message goes |
|
||||
| --- | --- | --- |
|
||||
| A web address, query string | GET | A parameter you name (`message` by default), added to the address's own |
|
||||
| Discord webhook | POST JSON | `content`, with mentions turned off |
|
||||
| Slack webhook | POST JSON | `text` |
|
||||
| Discord webhook | POST JSON | An embed with a colored bar, mentions turned off |
|
||||
| Slack webhook | POST JSON | An attachment with a colored bar |
|
||||
| Microsoft Teams webhook | POST JSON | An Adaptive Card, for a Workflows "when a webhook request is received" trigger |
|
||||
| Google Chat webhook | POST JSON | `text` |
|
||||
| Google Chat webhook | POST JSON | A `cardsV2` card |
|
||||
| A web address, JSON body | POST JSON | A field you name (`message` by default) |
|
||||
|
||||
The four chat services get a card, not a line of text: a title with an emoji that says what happened
|
||||
(`✅ Loop complete`, `✅ Phase complete`, `❓ Waiting for you`, `❓ Stopped on a question`, `🛑 Loop stopped`), the
|
||||
message, **Project**, **Spec** and **Elapsed** fields, and a footer. Discord, Slack and Teams color it by outcome
|
||||
(green done, yellow waiting on you, red stopped); Google Chat has no color bar, so the emoji carries it. The
|
||||
two plain web-address choices still get the message exactly as written.
|
||||
|
||||
**Send a test** saves the setup and sends a test message right away, after the app names the address in its
|
||||
own window, so a wrong address shows up before a long run. A name can use letters, digits and `- _ . ~`. Pasting a Discord, Slack, Teams or Google Chat address picks
|
||||
its choice for you, since a plain GET to a Discord webhook answers 200 and posts nothing. The call has 10
|
||||
@@ -227,17 +233,17 @@ evidence, when:
|
||||
- the Smart pick skipped a Critical finding.
|
||||
|
||||
A crashed or silent agent gets exactly one retry per phase when the retry tick is on, and none when it is off.
|
||||
It never retries a real failure. On a stop screen, **Ask a question** (first in the row, offered whenever Resume is) wakes an ordinary agent on the stopped phase on the same page, so the Ask tab answers; it starts no loop and changes nothing, and **Resume the loop** is still there afterwards. **Resume the loop** carries on from the stopped
|
||||
phase and **Fix it by hand** opens an ordinary Implement session on it.
|
||||
It never retries a real failure. On a stop screen, **Ask a question** (first in the row, offered whenever Continue building is) wakes an ordinary agent on the stopped phase on the same page, so the Ask tab answers; it starts no loop and changes nothing, and **Continue building** is still there afterwards (pressing Ask again only opens the Ask tab). **Continue building** carries on unattended from the stopped
|
||||
phase and **Fix together with an agent** opens an ordinary Implement session on it. The stop screen leads with a short reason, puts one line under each button saying what it does, and highlights one: Continue building after a crash, a silence or your own stop, Fix together after a failed check, a blocked task, a refused commit or a question. The phase list and uncommitted files sit under **Details**.
|
||||
|
||||
**The report.** One report follows the whole build, across stops and Resume. For every phase it says what
|
||||
**The report.** One report follows the whole build, across stops and Continue building. For every phase it says what
|
||||
was built and committed, the tests, the findings fixed, the findings it chose not to fix and why, the
|
||||
findings left open, each assumption with its note, and any other decisions the agent reported, plus every
|
||||
retry and stop, in order. The agent writes most of this, so it holds what the agent noticed; the task marks,
|
||||
the quick check and the commits are the app's own. The finish screen counts each kind per phase, and **Read
|
||||
the full report** opens it, saved as `specs/<feature>/LOOP-SUMMARY-<date>.md` (`-2` and so on for another
|
||||
the same day). After a stop, **Read why, and the report so far** shows it on the stop screen. While a build
|
||||
is unfinished it lives in `~/.plan2code/console/loop-reports.json`, not the project, because Resume needs a
|
||||
is unfinished it lives in `~/.plan2code/console/loop-reports.json`, not the project, because Continue building needs a
|
||||
clean tree. The in-app **Help** has a matching topic, **Implementation Loop**, which the loop card links to as "How the loop works".
|
||||
|
||||
## Keep it up to date
|
||||
|
||||
+1
-1
@@ -733,7 +733,7 @@ footer a { color: inherit; }
|
||||
<li>
|
||||
<h3>Start from your Notebook</h3>
|
||||
<div>
|
||||
<p>Start Pathfinder, Plan, Quick Task or Revise plan from a Notebook tab. The agent reads the tab only once you send it.</p>
|
||||
<p>Start Pathfinder, Plan, Quick Task, Diagnose or Revise plan from a Notebook tab. The agent reads the tab only once you send it.</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 117 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 127 KiB |
+17
@@ -388,6 +388,22 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
source: 'plan2code-dead-code.md',
|
||||
stepNumber: 'dead-code',
|
||||
name: 'dead-code',
|
||||
displayName: 'Dead Code Mode',
|
||||
description: 'Find unused code and dead code, show how safe each is to remove, and remove only what you pick',
|
||||
// Shown to the agent in place of the generic header text: when the skill fits and its command.
|
||||
skillDescription: "Use when you want unused code paths and dead code in your project found, labeled by how safe each is to remove, and removed only where you pick. Run it as /plan2code-dead-code.",
|
||||
isUtility: true,
|
||||
scripts: ['test-map.mjs', 'glob.mjs', 'test-commands.mjs', 'run-check.mjs'],
|
||||
additionalReferences: [
|
||||
{ source: 'web-console', target: 'web-console' },
|
||||
{ source: 'plan2code-dead-code-references/caller-search.md', target: 'caller-search.md' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
source: 'plan2code-changelog.md',
|
||||
stepNumber: 'changelog',
|
||||
@@ -440,6 +456,7 @@ function generateStepLabel(prompt) {
|
||||
if (prompt.stepNumber === 'diagnose') return 'Diagnose';
|
||||
if (prompt.stepNumber === 'pr-prep') return 'PR Prep';
|
||||
if (prompt.stepNumber === 'test') return 'Test';
|
||||
if (prompt.stepNumber === 'dead-code') return 'Dead Code';
|
||||
if (prompt.stepNumber === 'changelog') return 'Changelog';
|
||||
if (prompt.stepNumber === 'quick') return 'Quick Task';
|
||||
return `Step ${prompt.stepNumber}`;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"plan2code-install": "./install.js"
|
||||
@@ -12,7 +12,7 @@
|
||||
"play": "node scripts/play.mjs",
|
||||
"pretest": "node scripts/fix-line-endings.mjs",
|
||||
"test:fast": "node scripts/test-fast.mjs",
|
||||
"test": "node scripts/check-test-lanes.mjs && node scripts/validate-char-count.js && node install.js --build-skills && node scripts/check-versions.mjs && node scripts/check-doc-size.mjs && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/check-prompt-wording.mjs && node scripts/check-console-openings.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-coverage.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-pointers.mjs scripts/test-console-wire-budgets.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-web-console-agents-doc.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-flock.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-send-state.mjs scripts/test-web-console-strengths.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs scripts/test-check-test-lanes.mjs scripts/test-check-doc-size.mjs scripts/tLine truncated
|
||||
"test": "node scripts/check-test-lanes.mjs && node scripts/validate-char-count.js && node install.js --build-skills && node scripts/check-versions.mjs && node scripts/check-doc-size.mjs && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/check-prompt-wording.mjs && node scripts/check-console-openings.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-dead-code.mjs scripts/test-script-coverage.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-pointers.mjs scripts/test-console-wire-budgets.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-web-console-agents-doc.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-flock.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-spec-carry.mjs scripts/test-spec-carry-page.mjs scripts/test-web-console-state.mjs scripts/test-web-console-send-state.mjs scripts/test-web-console-strengths.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scriptsLine truncated
|
||||
},
|
||||
"devDependencies": {
|
||||
"gpt-tokenizer": "2.9.0",
|
||||
|
||||
Generated
+2
-2
@@ -757,7 +757,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fake-agent"
|
||||
version = "3.0.4"
|
||||
version = "3.0.5"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"terminal_size",
|
||||
@@ -2371,7 +2371,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.4"
|
||||
version = "3.0.5"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fake-agent"
|
||||
version = "3.0.4"
|
||||
version = "3.0.5"
|
||||
description = "A stand-in agent program for the Plan2Code app's tests"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.12.4",
|
||||
"@xterm/addon-fit": "0.11.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"private": true,
|
||||
"description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.4"
|
||||
version = "3.0.5"
|
||||
description = "Plan2Code desktop app"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
@@ -46,6 +46,13 @@ pub struct AgentSnapshot {
|
||||
/// The running (or last started) agent's permission mode, so the bar's
|
||||
/// note can name it instead of assuming bypass.
|
||||
pub mode: Option<PermissionMode>,
|
||||
/// The model the agent was started on, shown beside its name. `None` when
|
||||
/// it runs on its own default, which the app cannot know.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub model: Option<String>,
|
||||
/// The effort the agent was started with, when its kind takes one.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub effort: Option<String>,
|
||||
/// What the last Restart left for the dashboard, for the bar.
|
||||
#[serde(rename = "briefNote", skip_serializing_if = "Option::is_none")]
|
||||
pub brief_note: Option<String>,
|
||||
@@ -398,9 +405,9 @@ impl AgentManager {
|
||||
lock(&self.shared.inner).replay.clone()
|
||||
}
|
||||
|
||||
/// The model and effort the current (or last) start chose. The bar only
|
||||
/// ever needs `snapshot`'s `kind` and `mode`; this exists so a test can
|
||||
/// confirm Restart keeps the other two of the four just as unchanged.
|
||||
/// The model and effort the current (or last) start chose, the same two
|
||||
/// `snapshot` sends to the bar; a test uses this to confirm Restart keeps
|
||||
/// them unchanged.
|
||||
pub fn model_and_effort(&self) -> (Option<String>, Option<String>) {
|
||||
match &lock(&self.shared.inner).last_start {
|
||||
Some((choice, _)) => (choice.model.clone(), choice.effort.clone()),
|
||||
@@ -482,6 +489,14 @@ impl Shared {
|
||||
.as_ref()
|
||||
.map(|(choice, _)| choice.kind.id().to_string()),
|
||||
mode: inner.last_start.as_ref().map(|(choice, _)| choice.mode),
|
||||
model: inner
|
||||
.last_start
|
||||
.as_ref()
|
||||
.and_then(|(choice, _)| choice.model.clone()),
|
||||
effort: inner
|
||||
.last_start
|
||||
.as_ref()
|
||||
.and_then(|(choice, _)| choice.effort.clone()),
|
||||
generation: self.generation.load(Ordering::SeqCst),
|
||||
brief_note: inner.brief_note.clone(),
|
||||
}
|
||||
|
||||
@@ -1670,7 +1670,7 @@ mod tests {
|
||||
.iter()
|
||||
.map(|e| e.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
["copilot", "opencode", "gemini", "pi"]
|
||||
["copilot", "opencode", "gemini", "pi", "cursor"]
|
||||
);
|
||||
assert!(list
|
||||
.builtins
|
||||
|
||||
@@ -631,7 +631,7 @@ pub fn current_event(slot: &LoopSlot) -> Option<LoopStateEvent> {
|
||||
lock(slot).as_ref().map(state_event)
|
||||
}
|
||||
|
||||
/// What Resume, Fix it by hand and Finalize need after the running record is
|
||||
/// What Resume, Fix together with an agent and Finalize need after the running record is
|
||||
/// gone. Memory only (NFR-5).
|
||||
#[derive(Clone)]
|
||||
pub struct LastLoop {
|
||||
@@ -993,7 +993,7 @@ pub fn stop_line(cause: &StopCause, phase: u32, detail: &str, retried: bool) ->
|
||||
why
|
||||
};
|
||||
format!(
|
||||
"Phase {phase} was not committed: {why}. The work is uncommitted; Resume tries the commit again"
|
||||
"Phase {phase} was not committed: {why}. The work is uncommitted; Continue building tries the commit again"
|
||||
)
|
||||
}
|
||||
StopCause::MarkedNotCommitted(file) => {
|
||||
@@ -1023,7 +1023,7 @@ pub fn stop_line(cause: &StopCause, phase: u32, detail: &str, retried: bool) ->
|
||||
StopCause::WatcherFailed(text) => {
|
||||
let text: String = one_line(text).chars().take(100).collect();
|
||||
format!(
|
||||
"The loop's watcher failed: {text}. Nothing more was committed; Resume starts again"
|
||||
"The loop's watcher failed: {text}. Nothing more was committed; Continue building starts again"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1803,7 +1803,7 @@ pub fn start_phase_with(
|
||||
}
|
||||
}
|
||||
|
||||
/// The prompt behind Fix it by hand: an ordinary Implement session.
|
||||
/// The prompt behind Fix together with an agent: an ordinary Implement session.
|
||||
pub fn fix_prompt(spec: &str) -> String {
|
||||
format!("/plan2code-3-implement {spec}/overview.md --web")
|
||||
}
|
||||
@@ -1825,7 +1825,15 @@ pub fn ask_prompt(spec: &str) -> String {
|
||||
/// Start the Ask agent: `start_with` without the forget step, so the agent's
|
||||
/// `open` joins the session on screen and the stopped screen stays up. The
|
||||
/// prompt is transient, as `start_with`'s is.
|
||||
///
|
||||
/// An agent already running here is the Ask agent from an earlier press (the
|
||||
/// loop's own agent ended with the stop, and Continue building, Fix together
|
||||
/// and Finalize replace the screen), so a second press is answered with it,
|
||||
/// never with the "already running" refusal.
|
||||
pub fn start_asking(agent: &AgentManager, launch: &Launch, prompt: String) -> Result<(), String> {
|
||||
if agent.snapshot().state == crate::agent_manager::AgentState::Running {
|
||||
return Ok(());
|
||||
}
|
||||
let (kind, model, effort, mode) = launch.clone();
|
||||
agent.start_transient(kind, model, effort, mode, prompt)
|
||||
}
|
||||
@@ -3004,7 +3012,7 @@ pub fn evidence_markdown(cause: &StopCause, line: &str, rec: &RunningRecord) ->
|
||||
rec.failure_output.as_deref().unwrap_or("(no output)"),
|
||||
));
|
||||
md.push_str(
|
||||
"\nThe phase was approved, but its changes are not committed. The mark was taken back, so the spec still shows the phase open. Fix what git says, then press Resume to try the commit again.\n",
|
||||
"\nThe phase was approved, but its changes are not committed. The mark was taken back, so the spec still shows the phase open. Fix what git says, then press Continue building to try the commit again.\n",
|
||||
);
|
||||
}
|
||||
StopCause::MarkedNotCommitted(file) => {
|
||||
@@ -3013,7 +3021,7 @@ pub fn evidence_markdown(cause: &StopCause, line: &str, rec: &RunningRecord) ->
|
||||
rec.failure_output.as_deref().unwrap_or("(no output)"),
|
||||
));
|
||||
md.push_str(&format!(
|
||||
"\nThe phase is marked done in `{file}` (and in overview.md), but its changes are not committed, and the mark could not be taken back. Set the phase back to in progress by hand, or press Resume: it checks every done mark against the commit log and builds this phase again.\n"
|
||||
"\nThe phase is marked done in `{file}` (and in overview.md), but its changes are not committed, and the mark could not be taken back. Set the phase back to in progress by hand, or press Continue building: it checks every done mark against the commit log and builds this phase again.\n"
|
||||
));
|
||||
}
|
||||
StopCause::UnsafeFiles(files) => {
|
||||
@@ -3024,7 +3032,7 @@ pub fn evidence_markdown(cause: &StopCause, line: &str, rec: &RunningRecord) ->
|
||||
md.push_str(&format!("- `{file}` ({reason})\n"));
|
||||
}
|
||||
md.push_str(
|
||||
"\nThe phase was approved, but these files were staged and the loop does not commit secrets or files over 5 MB. Nothing was marked done or committed, and everything was taken out of the index again (unless the stop line says otherwise). Remove the files, or add them to `.gitignore`, then press Resume.\n",
|
||||
"\nThe phase was approved, but these files were staged and the loop does not commit secrets or files over 5 MB. Nothing was marked done or committed, and everything was taken out of the index again (unless the stop line says otherwise). Remove the files, or add them to `.gitignore`, then press Continue building.\n",
|
||||
);
|
||||
}
|
||||
StopCause::Refused(_) => {
|
||||
@@ -3046,11 +3054,11 @@ pub fn evidence_markdown(cause: &StopCause, line: &str, rec: &RunningRecord) ->
|
||||
}
|
||||
StopCause::WatcherFailed(_) => {
|
||||
md.push_str(
|
||||
"\nThe loop's own watcher stopped working, so the agent was ended. Whatever was committed stays committed; nothing more was. Press Resume to carry on from the spec.\n",
|
||||
"\nThe loop's own watcher stopped working, so the agent was ended. Whatever was committed stays committed; nothing more was. Press Continue building to carry on from the spec.\n",
|
||||
);
|
||||
}
|
||||
StopCause::Question if rec.setup.on_question == OnQuestion::Guess => {
|
||||
md.push_str("\nBest guess was on, but the phase asked a question it could not guess, so the loop stopped rather than wait. Answer it with Fix it by hand, or settle it in the spec, then press Resume.\n");
|
||||
md.push_str("\nBest guess was on, but the phase asked a question it could not guess, so the loop stopped rather than wait. Answer it with Fix together with an agent, or settle it in the spec, then press Continue building.\n");
|
||||
}
|
||||
StopCause::Question => {
|
||||
md.push_str("\nThe setup says to stop when a phase asks something.\n");
|
||||
@@ -3207,11 +3215,88 @@ fn stop_loop(ctx: &Ctx, cause: StopCause, line: String, can: &[&str]) {
|
||||
"phases": phase_rows(&rec),
|
||||
"uncommitted": uncommitted,
|
||||
"can": stop_can(can),
|
||||
"reason": stop_reason(&cause, rec.phases[at].n, built),
|
||||
"recommend": stop_recommend(&cause, can),
|
||||
"phase": continue_phase(
|
||||
&rec.phases.iter().map(|p| p.n).collect::<Vec<_>>(),
|
||||
at,
|
||||
built
|
||||
),
|
||||
},
|
||||
});
|
||||
post_end(ctx, &rec, &patch);
|
||||
}
|
||||
|
||||
/// The phase Continue building (and Fix together) starts on, for the stop
|
||||
/// screen's button lines: the stopped phase, or, when that phase was already
|
||||
/// built (Stop after this phase), the next one in the run. `numbers` are the
|
||||
/// run's phase numbers in order and `at` the stopped phase's index.
|
||||
pub fn continue_phase(numbers: &[u32], at: usize, built: bool) -> u32 {
|
||||
let next = if built { at + 1 } else { at };
|
||||
numbers
|
||||
.get(next)
|
||||
.or_else(|| numbers.get(at))
|
||||
.copied()
|
||||
.unwrap_or(1)
|
||||
}
|
||||
|
||||
/// The stop screen's heading: one short plain sentence saying where the loop
|
||||
/// stopped and why, with no detail that could run long (the `line` under it
|
||||
/// carries the detail). `built` is a phase already built and recorded.
|
||||
pub fn stop_reason(cause: &StopCause, phase: u32, built: bool) -> String {
|
||||
match cause {
|
||||
StopCause::StoppedByPerson if built => {
|
||||
format!("Phase {phase} is built. The loop stopped there, as you asked.")
|
||||
}
|
||||
StopCause::StoppedByPerson => format!("You stopped the loop during Phase {phase}."),
|
||||
StopCause::Crash => format!("Phase {phase} stopped because the agent crashed."),
|
||||
StopCause::Silence => {
|
||||
format!("Phase {phase} stopped because the agent went quiet for too long.")
|
||||
}
|
||||
StopCause::NoSession => {
|
||||
format!("Phase {phase} stopped because the agent never opened its page.")
|
||||
}
|
||||
StopCause::WatcherFailed(_) => {
|
||||
format!("The loop stopped during Phase {phase} because of an error in the app.")
|
||||
}
|
||||
StopCause::Refused(_) => {
|
||||
format!("Phase {phase} stopped on a problem the loop cannot fix by itself.")
|
||||
}
|
||||
StopCause::QuickCheck => format!("Phase {phase} stopped because the quick check failed."),
|
||||
StopCause::Commit => format!("Phase {phase} is built, but git refused its commit."),
|
||||
StopCause::MarkedNotCommitted(_) => {
|
||||
format!("Phase {phase} is marked done, but its work is not committed.")
|
||||
}
|
||||
StopCause::UnsafeFiles(_) => {
|
||||
format!("Phase {phase} is built, but some files look unsafe to commit.")
|
||||
}
|
||||
StopCause::Question => format!("Phase {phase} stopped to ask you something."),
|
||||
}
|
||||
}
|
||||
|
||||
/// The one button the stop screen recommends, from `can` (the buttons it
|
||||
/// offers). A soft stop (the agent crashed or went quiet, the person stopped
|
||||
/// it, the watcher failed) recommends Continue building: nothing in the work
|
||||
/// needs changing. A hard stop (a refused phase, failing checks, a refused or
|
||||
/// unsafe commit, a question) recommends Fix together with an agent, since
|
||||
/// continuing would meet the same wall. When that button is not offered, the
|
||||
/// first of Continue building, Fix together and Finalize that is.
|
||||
pub fn stop_recommend(cause: &StopCause, can: &[&str]) -> Option<String> {
|
||||
let soft = matches!(
|
||||
cause,
|
||||
StopCause::Crash
|
||||
| StopCause::Silence
|
||||
| StopCause::NoSession
|
||||
| StopCause::StoppedByPerson
|
||||
| StopCause::WatcherFailed(_)
|
||||
);
|
||||
let first = if soft { "resume" } else { "fix" };
|
||||
[first, "resume", "fix", "finalize"]
|
||||
.into_iter()
|
||||
.find(|key| can.contains(key))
|
||||
.map(String::from)
|
||||
}
|
||||
|
||||
fn finish(ctx: &Ctx) {
|
||||
let rec = {
|
||||
let guard = lock(&ctx.slot);
|
||||
@@ -4631,7 +4716,7 @@ second line"
|
||||
);
|
||||
assert_eq!(
|
||||
stop_line(&StopCause::Commit, 4, "lint says no", false),
|
||||
"Phase 4 was not committed: lint says no. The work is uncommitted; Resume tries the commit again"
|
||||
"Phase 4 was not committed: lint says no. The work is uncommitted; Continue building tries the commit again"
|
||||
);
|
||||
assert_eq!(
|
||||
stop_line(
|
||||
@@ -5657,7 +5742,7 @@ second line"
|
||||
assert_eq!(entry.result, EntryResult::Stopped);
|
||||
assert_eq!(
|
||||
entry.line,
|
||||
"Phase 2 was not committed: lint says no. The work is uncommitted; Resume tries the commit again"
|
||||
"Phase 2 was not committed: lint says no. The work is uncommitted; Continue building tries the commit again"
|
||||
);
|
||||
assert_eq!(
|
||||
git_in(&repo, &["log", "-1", "--format=%s"]),
|
||||
@@ -6230,7 +6315,7 @@ second line"
|
||||
fn a_commit_that_gives_no_reason_still_reads_as_a_sentence() {
|
||||
assert_eq!(
|
||||
stop_line(&StopCause::Commit, 2, "", false),
|
||||
"Phase 2 was not committed: git gave no reason. The work is uncommitted; Resume tries the commit again"
|
||||
"Phase 2 was not committed: git gave no reason. The work is uncommitted; Continue building tries the commit again"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6389,7 +6474,7 @@ second line"
|
||||
assert_eq!(entry.result, EntryResult::Stopped);
|
||||
assert_eq!(
|
||||
entry.line,
|
||||
"The loop's watcher failed: boom inside the lock. Nothing more was committed; Resume starts again"
|
||||
"The loop's watcher failed: boom inside the lock. Nothing more was committed; Continue building starts again"
|
||||
);
|
||||
// A new loop can take the slot.
|
||||
*lock(&ctx.slot) = Some(record("specs/lunch", vec![phase(2), phase(3)]));
|
||||
@@ -6878,7 +6963,7 @@ second line"
|
||||
let cause = StopCause::WatcherFailed("index out of bounds".into());
|
||||
assert_eq!(
|
||||
stop_line(&cause, 3, "", false),
|
||||
"The loop's watcher failed: index out of bounds. Nothing more was committed; Resume starts again"
|
||||
"The loop's watcher failed: index out of bounds. Nothing more was committed; Continue building starts again"
|
||||
);
|
||||
assert!(!should_retry(&cause, &setup(), 0));
|
||||
let line = stop_line(&cause, 3, "", false);
|
||||
@@ -7201,6 +7286,85 @@ second line"
|
||||
assert!(!prompt.contains("--workflow implement"), "{prompt}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_soft_stop_recommends_continue_building_and_a_hard_stop_recommends_fixing_together() {
|
||||
let both = ["resume", "fix"];
|
||||
for soft in [
|
||||
StopCause::Crash,
|
||||
StopCause::Silence,
|
||||
StopCause::NoSession,
|
||||
StopCause::StoppedByPerson,
|
||||
StopCause::WatcherFailed("x".into()),
|
||||
] {
|
||||
assert_eq!(
|
||||
stop_recommend(&soft, &both).as_deref(),
|
||||
Some("resume"),
|
||||
"{soft:?}"
|
||||
);
|
||||
}
|
||||
for hard in [
|
||||
StopCause::Refused("1 test failed".into()),
|
||||
StopCause::QuickCheck,
|
||||
StopCause::Commit,
|
||||
StopCause::MarkedNotCommitted("phase-2.md".into()),
|
||||
StopCause::UnsafeFiles(vec![".env".into()]),
|
||||
StopCause::Question,
|
||||
] {
|
||||
assert_eq!(
|
||||
stop_recommend(&hard, &both).as_deref(),
|
||||
Some("fix"),
|
||||
"{hard:?}"
|
||||
);
|
||||
}
|
||||
// Only an offered button is ever recommended.
|
||||
assert_eq!(
|
||||
stop_recommend(&StopCause::Question, &["resume"]).as_deref(),
|
||||
Some("resume")
|
||||
);
|
||||
assert_eq!(
|
||||
stop_recommend(&StopCause::StoppedByPerson, &["finalize"]).as_deref(),
|
||||
Some("finalize")
|
||||
);
|
||||
assert_eq!(stop_recommend(&StopCause::Crash, &[]), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn continue_building_starts_on_the_stopped_phase_or_the_one_after_a_built_phase() {
|
||||
// A run over Phases 2 to 5, stopped in Phase 3: never the last phase.
|
||||
assert_eq!(continue_phase(&[2, 3, 4, 5], 1, false), 3);
|
||||
// Phase 3 built, then stopped as asked: the next phase is where it goes on.
|
||||
assert_eq!(continue_phase(&[2, 3, 4, 5], 1, true), 4);
|
||||
// The last phase built: nothing after it, so the phase itself.
|
||||
assert_eq!(continue_phase(&[2, 3, 4, 5], 3, true), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_stop_reason_is_one_short_sentence_naming_the_phase() {
|
||||
let causes = [
|
||||
StopCause::Crash,
|
||||
StopCause::Silence,
|
||||
StopCause::NoSession,
|
||||
StopCause::StoppedByPerson,
|
||||
StopCause::WatcherFailed("a very long panic text ".repeat(20)),
|
||||
StopCause::Refused("a very long reason ".repeat(20)),
|
||||
StopCause::QuickCheck,
|
||||
StopCause::Commit,
|
||||
StopCause::MarkedNotCommitted("specs/x/phase-3.md".into()),
|
||||
StopCause::UnsafeFiles(vec![".env".into()]),
|
||||
StopCause::Question,
|
||||
];
|
||||
for cause in &causes {
|
||||
let reason = stop_reason(cause, 3, false);
|
||||
assert!(reason.contains("Phase 3"), "{reason}");
|
||||
assert!(reason.chars().count() <= 80, "{reason}");
|
||||
assert!(!reason.contains('\u{2014}'), "{reason}");
|
||||
}
|
||||
assert_eq!(
|
||||
stop_reason(&StopCause::StoppedByPerson, 4, true),
|
||||
"Phase 4 is built. The loop stopped there, as you asked."
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_resumable_stop_offers_ask_first_and_a_finalize_only_stop_does_not() {
|
||||
assert_eq!(
|
||||
@@ -7214,7 +7378,25 @@ second line"
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asking_leaves_the_session_on_screen_and_fix_it_by_hand_still_forgets_it() {
|
||||
fn asking_twice_keeps_the_ask_agent_and_is_never_refused() {
|
||||
let (agent, seen) = fake_agent_manager(Path::new("."));
|
||||
let launch = fake_agent_launch();
|
||||
start_asking(&agent, &launch, ask_prompt("specs/x")).unwrap();
|
||||
wait_until("the Ask agent ready", || {
|
||||
lock(&seen).matches("FAKE-AGENT ready").count() >= 1
|
||||
});
|
||||
// The refusal the stopped screen once showed came from this second press.
|
||||
start_asking(&agent, &launch, ask_prompt("specs/x")).unwrap();
|
||||
assert_eq!(
|
||||
launched_prompts(&seen),
|
||||
vec![ask_prompt("specs/x")],
|
||||
"the running Ask agent answers the second press; no second agent starts"
|
||||
);
|
||||
agent.stop();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asking_leaves_the_session_on_screen_and_fixing_together_still_forgets_it() {
|
||||
let (agent, seen) = fake_agent_manager(Path::new("."));
|
||||
let forgets = Arc::new(Mutex::new(0));
|
||||
let counter = Arc::clone(&forgets);
|
||||
@@ -7228,12 +7410,16 @@ second line"
|
||||
assert_eq!(*lock(&forgets), 0, "Ask must join the session on screen");
|
||||
|
||||
// The Ask agent is still running when the next button is pressed, as in
|
||||
// the app: Fix it by hand replaces it and forgets the session.
|
||||
// the app: Fix together with an agent replaces it and forgets the session.
|
||||
start_with(&agent, &launch, fix_prompt("specs/x")).unwrap();
|
||||
wait_until("the fix agent ready", || {
|
||||
lock(&seen).matches("FAKE-AGENT ready").count() >= 2
|
||||
});
|
||||
assert_eq!(*lock(&forgets), 1, "Fix it by hand must forget the session");
|
||||
assert_eq!(
|
||||
*lock(&forgets),
|
||||
1,
|
||||
"Fix together with an agent must forget the session"
|
||||
);
|
||||
let prompts = launched_prompts(&seen);
|
||||
assert_eq!(
|
||||
prompts,
|
||||
|
||||
@@ -107,6 +107,125 @@ pub fn valid_setup(kind: NotifyKind, url: &str, param: &str) -> bool {
|
||||
valid_url(url) && (!kind.uses_param() || valid_param(param))
|
||||
}
|
||||
|
||||
/// What an outcome looks like on a card.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Tone {
|
||||
Done,
|
||||
Waiting,
|
||||
Stopped,
|
||||
Plain,
|
||||
}
|
||||
|
||||
/// A loop message read into the parts of a card.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Look {
|
||||
pub tone: Tone,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
/// Project, Spec and Elapsed, in that order, each only when the message has it.
|
||||
pub fields: Vec<(&'static str, String)>,
|
||||
}
|
||||
|
||||
impl Tone {
|
||||
fn discord_color(self) -> u32 {
|
||||
match self {
|
||||
Tone::Done => 0x57F287,
|
||||
Tone::Waiting => 0xFEE75C,
|
||||
Tone::Stopped => 0xED4245,
|
||||
Tone::Plain => 0x5865F2,
|
||||
}
|
||||
}
|
||||
|
||||
fn slack_color(self) -> &'static str {
|
||||
match self {
|
||||
Tone::Done => "#2EB67D",
|
||||
Tone::Waiting => "#ECB22E",
|
||||
Tone::Stopped => "#E01E5A",
|
||||
Tone::Plain => "#5865F2",
|
||||
}
|
||||
}
|
||||
|
||||
/// An Adaptive Card text color.
|
||||
fn teams_color(self) -> &'static str {
|
||||
match self {
|
||||
Tone::Done => "Good",
|
||||
Tone::Waiting => "Warning",
|
||||
Tone::Stopped => "Attention",
|
||||
Tone::Plain => "Accent",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const FOOTER: &str = "Plan2Code loop";
|
||||
/// Discord stops an embed's description at 4096 characters.
|
||||
const MAX_DESCRIPTION: usize = 4000;
|
||||
|
||||
/// Read a message the loop wrote (`loop_driver.rs`) into a card: its outcome
|
||||
/// from the words it always uses, and the trailing "Elapsed: ..." as a field.
|
||||
/// A message it does not know stays whole, as a plain card.
|
||||
pub fn look(message: &str) -> Look {
|
||||
// Elapsed ends every message; the last one is the real one, whatever a
|
||||
// commit subject or an agent's line said before it.
|
||||
let (description, elapsed) = match message.rsplit_once("Elapsed: ") {
|
||||
Some((before, after)) => (
|
||||
before.trim(),
|
||||
Some(after.trim().trim_end_matches('.').to_string()).filter(|e| !e.is_empty()),
|
||||
),
|
||||
None => (message.trim(), None),
|
||||
};
|
||||
// The outcome is in the message's leading words, never in the free text
|
||||
// after them (a commit subject, an agent's line).
|
||||
let (tone, title) = if description.starts_with("Plan2Code loop is waiting on") {
|
||||
(Tone::Waiting, "❓ Waiting for you")
|
||||
} else if description.starts_with("Plan2Code loop stopped on") {
|
||||
if description.ends_with("has a question for you to answer.") {
|
||||
(Tone::Waiting, "❓ Stopped on a question")
|
||||
} else {
|
||||
(Tone::Stopped, "🛑 Loop stopped")
|
||||
}
|
||||
} else if description.starts_with("Plan2Code loop complete on") {
|
||||
(Tone::Done, "✅ Loop complete")
|
||||
} else if description.starts_with("Plan2Code loop on") && description.contains(" is complete.")
|
||||
{
|
||||
(Tone::Done, "✅ Phase complete")
|
||||
} else {
|
||||
(Tone::Plain, "📣 Plan2Code loop")
|
||||
};
|
||||
let mut fields = Vec::new();
|
||||
if let Some((project, spec)) = label(message) {
|
||||
if !project.is_empty() {
|
||||
fields.push(("Project", project));
|
||||
}
|
||||
fields.push(("Spec", spec));
|
||||
}
|
||||
fields.extend(elapsed.map(|e| ("Elapsed", e)));
|
||||
Look {
|
||||
tone,
|
||||
title: title.to_string(),
|
||||
description: description.chars().take(MAX_DESCRIPTION).collect(),
|
||||
fields,
|
||||
}
|
||||
}
|
||||
|
||||
/// The "project / spec" the loop's messages name after " on " (`Where::label`
|
||||
/// in `loop_driver.rs`), as (project, spec); the project is empty when the
|
||||
/// folder has no name. None for a message that does not name one.
|
||||
fn label(message: &str) -> Option<(String, String)> {
|
||||
let (_, after) = message.split_once(" on ")?;
|
||||
let end = [": ", " at Phase "]
|
||||
.iter()
|
||||
.filter_map(|stop| after.find(stop))
|
||||
.min()?;
|
||||
let label = after[..end].trim();
|
||||
if label.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(match label.split_once(" / ") {
|
||||
Some((project, spec)) => (project.to_string(), spec.to_string()),
|
||||
None => (String::new(), label.to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
/// Slack treats these three as its own markup in message text.
|
||||
fn slack_escaped(text: &str) -> String {
|
||||
text.replace('&', "&")
|
||||
@@ -124,28 +243,108 @@ pub fn request_for(
|
||||
let body = match kind {
|
||||
NotifyKind::Query => return (target_url(url, param, message), None),
|
||||
NotifyKind::Json => json!({ param: message }),
|
||||
// No mentions, whatever a spec is called: this must never ping a channel.
|
||||
NotifyKind::Discord => json!({ "content": message, "allowed_mentions": { "parse": [] } }),
|
||||
NotifyKind::Slack => json!({ "text": slack_escaped(message) }),
|
||||
NotifyKind::GoogleChat => json!({ "text": message }),
|
||||
// A Teams workflow's "when a webhook request is received" trigger.
|
||||
NotifyKind::Teams => json!({
|
||||
"type": "message",
|
||||
"attachments": [{
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
"contentUrl": null,
|
||||
"content": {
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"body": [{ "type": "TextBlock", "text": message, "wrap": true }],
|
||||
},
|
||||
}],
|
||||
}),
|
||||
NotifyKind::Discord => discord_card(&look(message)),
|
||||
NotifyKind::Slack => slack_card(&look(message)),
|
||||
NotifyKind::GoogleChat => google_chat_card(&look(message)),
|
||||
NotifyKind::Teams => teams_card(&look(message)),
|
||||
};
|
||||
(url.to_string(), Some(body))
|
||||
}
|
||||
|
||||
/// An embed: a colored bar, a title, the message, an Elapsed field and a footer.
|
||||
fn discord_card(look: &Look) -> Value {
|
||||
let mut embed = json!({
|
||||
"title": look.title,
|
||||
"description": look.description,
|
||||
"color": look.tone.discord_color(),
|
||||
"footer": { "text": FOOTER },
|
||||
});
|
||||
if !look.fields.is_empty() {
|
||||
embed["fields"] = look
|
||||
.fields
|
||||
.iter()
|
||||
.map(|(name, value)| json!({ "name": name, "value": value, "inline": true }))
|
||||
.collect();
|
||||
}
|
||||
// No mentions, whatever a spec is called: this must never ping a channel.
|
||||
json!({ "embeds": [embed], "allowed_mentions": { "parse": [] } })
|
||||
}
|
||||
|
||||
/// An attachment: the same parts, in Slack's own markup rules.
|
||||
fn slack_card(look: &Look) -> Value {
|
||||
let mut attachment = json!({
|
||||
"fallback": slack_escaped(&look.description),
|
||||
"color": look.tone.slack_color(),
|
||||
"title": slack_escaped(&look.title),
|
||||
"text": slack_escaped(&look.description),
|
||||
"footer": FOOTER,
|
||||
});
|
||||
if !look.fields.is_empty() {
|
||||
attachment["fields"] = look
|
||||
.fields
|
||||
.iter()
|
||||
.map(|(title, value)| json!({ "title": title, "value": slack_escaped(value), "short": true }))
|
||||
.collect();
|
||||
}
|
||||
json!({ "attachments": [attachment] })
|
||||
}
|
||||
|
||||
/// A Google Chat card has no color bar, so the title's emoji carries the outcome.
|
||||
/// Its text paragraphs read a little HTML, so the message is escaped as for Slack.
|
||||
fn google_chat_card(look: &Look) -> Value {
|
||||
let mut widgets =
|
||||
vec![json!({ "textParagraph": { "text": slack_escaped(&look.description) } })];
|
||||
for (label, value) in &look.fields {
|
||||
widgets
|
||||
.push(json!({ "decoratedText": { "topLabel": label, "text": slack_escaped(value) } }));
|
||||
}
|
||||
json!({
|
||||
"cardsV2": [{
|
||||
"cardId": "plan2code-loop",
|
||||
"card": {
|
||||
"header": { "title": look.title, "subtitle": FOOTER },
|
||||
"sections": [{ "widgets": widgets }],
|
||||
},
|
||||
}],
|
||||
})
|
||||
}
|
||||
|
||||
/// A Teams workflow's "when a webhook request is received" trigger.
|
||||
fn teams_card(look: &Look) -> Value {
|
||||
let mut body = vec![
|
||||
json!({
|
||||
"type": "TextBlock",
|
||||
"text": look.title,
|
||||
"weight": "Bolder",
|
||||
"size": "Medium",
|
||||
"color": look.tone.teams_color(),
|
||||
"wrap": true,
|
||||
}),
|
||||
json!({ "type": "TextBlock", "text": look.description, "wrap": true }),
|
||||
];
|
||||
if !look.fields.is_empty() {
|
||||
let facts: Vec<Value> = look
|
||||
.fields
|
||||
.iter()
|
||||
.map(|(title, value)| json!({ "title": title, "value": value }))
|
||||
.collect();
|
||||
body.push(json!({ "type": "FactSet", "facts": facts }));
|
||||
}
|
||||
json!({
|
||||
"type": "message",
|
||||
"attachments": [{
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
"contentUrl": null,
|
||||
"content": {
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.4",
|
||||
"body": body,
|
||||
},
|
||||
}],
|
||||
})
|
||||
}
|
||||
|
||||
/// The Start confirm's words for what the app will do.
|
||||
pub fn describe(kind: NotifyKind, url: &str, param: &str) -> String {
|
||||
match kind {
|
||||
@@ -320,7 +519,135 @@ mod tests {
|
||||
.contains("content-type: application/json"));
|
||||
let (_, body) = request.split_once("\r\n\r\n").unwrap();
|
||||
let body: Value = serde_json::from_str(body).unwrap();
|
||||
assert_eq!(body["content"], "all done");
|
||||
assert_eq!(body["embeds"][0]["description"], "all done");
|
||||
}
|
||||
|
||||
const DONE: &str =
|
||||
"Plan2Code loop complete on plan2code / lunch: all 4 phases built. Elapsed: 14m.";
|
||||
const PHASE: &str = "Plan2Code loop on plan2code / lunch: Phase 2 of 4 (Setup) is complete. Done: 6 tasks. Next: Phase 3. Elapsed: phase 6m, run 14m.";
|
||||
const ASKED: &str = "Plan2Code loop is waiting on plan2code / lunch: Phase 2 of 4 has a question for you to answer. Elapsed: phase 1m, run 3m.";
|
||||
const ASKED_STOP: &str = "Plan2Code loop stopped on plan2code / lunch: Phase 2 of 4 has a question for you to answer. Elapsed: phase 1m, run 3m.";
|
||||
const STOPPED: &str = "Plan2Code loop stopped on plan2code / lunch at Phase 2 of 4: the agent crashed (exit 1). Elapsed: phase 1m, run 3m.";
|
||||
|
||||
#[test]
|
||||
fn a_message_reads_into_a_tone_a_title_and_an_elapsed_time() {
|
||||
for (message, tone, title, elapsed) in [
|
||||
(DONE, Tone::Done, "✅ Loop complete", "14m"),
|
||||
(PHASE, Tone::Done, "✅ Phase complete", "phase 6m, run 14m"),
|
||||
(
|
||||
ASKED,
|
||||
Tone::Waiting,
|
||||
"❓ Waiting for you",
|
||||
"phase 1m, run 3m",
|
||||
),
|
||||
(
|
||||
ASKED_STOP,
|
||||
Tone::Waiting,
|
||||
"❓ Stopped on a question",
|
||||
"phase 1m, run 3m",
|
||||
),
|
||||
(
|
||||
STOPPED,
|
||||
Tone::Stopped,
|
||||
"🛑 Loop stopped",
|
||||
"phase 1m, run 3m",
|
||||
),
|
||||
] {
|
||||
let got = look(message);
|
||||
assert_eq!(got.tone, tone, "{message}");
|
||||
assert_eq!(got.title, title, "{message}");
|
||||
assert_eq!(
|
||||
got.fields,
|
||||
vec![
|
||||
("Project", "plan2code".to_string()),
|
||||
("Spec", "lunch".to_string()),
|
||||
("Elapsed", elapsed.to_string()),
|
||||
],
|
||||
"{message}"
|
||||
);
|
||||
assert!(!got.description.contains("Elapsed"), "{message}");
|
||||
assert!(got.description.starts_with("Plan2Code loop"), "{message}");
|
||||
}
|
||||
let plain = look("A test message from Plan2Code");
|
||||
assert_eq!(plain.tone, Tone::Plain);
|
||||
assert_eq!(plain.title, "📣 Plan2Code loop");
|
||||
assert_eq!(plain.description, "A test message from Plan2Code");
|
||||
assert!(plain.fields.is_empty());
|
||||
let bare = look("Plan2Code loop complete on lunch: 1 phase built. Elapsed: 2m.");
|
||||
assert_eq!(
|
||||
bare.fields,
|
||||
vec![("Spec", "lunch".to_string()), ("Elapsed", "2m".to_string())],
|
||||
"a spec with no project folder name shows only the spec"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn words_inside_the_message_do_not_change_what_it_is() {
|
||||
// A phase's commit subject is free text: it may say anything.
|
||||
let phase = look(
|
||||
"Plan2Code loop on plan2code / lunch: Phase 1 of 2 is complete. Done: committed \"Fix loop stopped on error: has a question, Elapsed: 3\" (abc1234). Next: Phase 2. Elapsed: phase 1m, run 2m.",
|
||||
);
|
||||
assert_eq!(phase.tone, Tone::Done);
|
||||
assert_eq!(phase.title, "✅ Phase complete");
|
||||
assert!(
|
||||
phase.description.contains("Elapsed: 3"),
|
||||
"{}",
|
||||
phase.description
|
||||
);
|
||||
assert!(phase.description.ends_with("Next: Phase 2."));
|
||||
assert_eq!(
|
||||
phase.fields.last(),
|
||||
Some(&("Elapsed", "phase 1m, run 2m".to_string()))
|
||||
);
|
||||
let crash = look(
|
||||
"Plan2Code loop stopped on plan2code / lunch at Phase 2 of 4: the work is complete. Elapsed: phase 1m, run 3m.",
|
||||
);
|
||||
assert_eq!(crash.tone, Tone::Stopped);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn discord_gets_an_embed_with_a_colored_bar_and_no_pings() {
|
||||
let body = request_for(NotifyKind::Discord, "https://e.com/x", "n", DONE)
|
||||
.1
|
||||
.unwrap();
|
||||
assert_eq!(body["allowed_mentions"], json!({ "parse": [] }));
|
||||
let embed = &body["embeds"][0];
|
||||
assert_eq!(embed["title"], "✅ Loop complete");
|
||||
assert_eq!(embed["color"], 0x57F287);
|
||||
assert_eq!(
|
||||
embed["description"],
|
||||
"Plan2Code loop complete on plan2code / lunch: all 4 phases built."
|
||||
);
|
||||
assert_eq!(
|
||||
embed["fields"],
|
||||
json!([
|
||||
{ "name": "Project", "value": "plan2code", "inline": true },
|
||||
{ "name": "Spec", "value": "lunch", "inline": true },
|
||||
{ "name": "Elapsed", "value": "14m", "inline": true },
|
||||
])
|
||||
);
|
||||
assert_eq!(embed["footer"]["text"], "Plan2Code loop");
|
||||
let stopped = request_for(NotifyKind::Discord, "https://e.com/x", "n", STOPPED)
|
||||
.1
|
||||
.unwrap();
|
||||
assert_eq!(stopped["embeds"][0]["color"], 0xED4245);
|
||||
let mention = request_for(NotifyKind::Discord, "https://e.com/x", "n", "@everyone hi")
|
||||
.1
|
||||
.unwrap();
|
||||
assert_eq!(mention["allowed_mentions"], json!({ "parse": [] }));
|
||||
assert!(mention["embeds"][0].get("fields").is_none());
|
||||
let long = "x".repeat(5000);
|
||||
let body = request_for(NotifyKind::Discord, "https://e.com/x", "n", &long)
|
||||
.1
|
||||
.unwrap();
|
||||
assert!(
|
||||
body["embeds"][0]["description"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.chars()
|
||||
.count()
|
||||
<= 4000
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -331,17 +658,49 @@ mod tests {
|
||||
.unwrap()
|
||||
};
|
||||
assert_eq!(body(NotifyKind::Json, "hi"), json!({ "note": "hi" }));
|
||||
let slack = body(NotifyKind::Slack, "a <b> & c");
|
||||
assert!(slack.get("text").is_none());
|
||||
let attachment = &slack["attachments"][0];
|
||||
assert_eq!(attachment["text"], "a <b> & c");
|
||||
assert_eq!(attachment["fallback"], "a <b> & c");
|
||||
assert_eq!(attachment["title"], "📣 Plan2Code loop");
|
||||
assert_eq!(attachment["color"], "#5865F2");
|
||||
assert_eq!(attachment["footer"], "Plan2Code loop");
|
||||
assert_eq!(
|
||||
body(NotifyKind::Discord, "@everyone hi"),
|
||||
json!({ "content": "@everyone hi", "allowed_mentions": { "parse": [] } }),
|
||||
"a mention in a spec's name pings nobody"
|
||||
body(NotifyKind::Slack, ASKED)["attachments"][0]["color"],
|
||||
"#ECB22E"
|
||||
);
|
||||
assert_eq!(
|
||||
body(NotifyKind::Slack, "a <b> & c"),
|
||||
json!({ "text": "a <b> & c" })
|
||||
body(NotifyKind::Teams, ASKED)["attachments"][0]["content"]["body"][0]["color"],
|
||||
"Warning"
|
||||
);
|
||||
assert_eq!(body(NotifyKind::GoogleChat, "hi"), json!({ "text": "hi" }));
|
||||
let teams = body(NotifyKind::Teams, "hi");
|
||||
assert_eq!(
|
||||
body(NotifyKind::Discord, ASKED)["embeds"][0]["color"],
|
||||
0xFEE75C
|
||||
);
|
||||
let slack = body(NotifyKind::Slack, STOPPED);
|
||||
assert_eq!(slack["attachments"][0]["color"], "#E01E5A");
|
||||
assert_eq!(
|
||||
slack["attachments"][0]["fields"],
|
||||
json!([
|
||||
{ "title": "Project", "value": "plan2code", "short": true },
|
||||
{ "title": "Spec", "value": "lunch", "short": true },
|
||||
{ "title": "Elapsed", "value": "phase 1m, run 3m", "short": true },
|
||||
])
|
||||
);
|
||||
let chat = body(NotifyKind::GoogleChat, PHASE);
|
||||
let card = &chat["cardsV2"][0]["card"];
|
||||
assert_eq!(card["header"]["title"], "✅ Phase complete");
|
||||
let widgets = &card["sections"][0]["widgets"];
|
||||
assert_eq!(
|
||||
widgets[0]["textParagraph"]["text"],
|
||||
"Plan2Code loop on plan2code / lunch: Phase 2 of 4 (Setup) is complete. Done: 6 tasks. Next: Phase 3."
|
||||
);
|
||||
assert_eq!(widgets[1]["decoratedText"]["topLabel"], "Project");
|
||||
assert_eq!(widgets[1]["decoratedText"]["text"], "plan2code");
|
||||
assert_eq!(widgets[3]["decoratedText"]["topLabel"], "Elapsed");
|
||||
assert_eq!(widgets[3]["decoratedText"]["text"], "phase 6m, run 14m");
|
||||
let teams = body(NotifyKind::Teams, DONE);
|
||||
assert_eq!(teams["type"], "message");
|
||||
let attachment = &teams["attachments"][0];
|
||||
assert_eq!(
|
||||
@@ -349,7 +708,22 @@ mod tests {
|
||||
"application/vnd.microsoft.card.adaptive"
|
||||
);
|
||||
assert_eq!(attachment["content"]["type"], "AdaptiveCard");
|
||||
assert_eq!(attachment["content"]["body"][0]["text"], "hi");
|
||||
let card = &attachment["content"]["body"];
|
||||
assert_eq!(card[0]["text"], "✅ Loop complete");
|
||||
assert_eq!(card[0]["color"], "Good");
|
||||
assert_eq!(card[0]["weight"], "Bolder");
|
||||
assert_eq!(
|
||||
card[1]["text"],
|
||||
"Plan2Code loop complete on plan2code / lunch: all 4 phases built."
|
||||
);
|
||||
assert_eq!(
|
||||
card[2]["facts"],
|
||||
json!([
|
||||
{ "title": "Project", "value": "plan2code" },
|
||||
{ "title": "Spec", "value": "lunch" },
|
||||
{ "title": "Elapsed", "value": "14m" },
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
request_for(NotifyKind::Slack, "https://e.com/x", "n", "m").0,
|
||||
"https://e.com/x"
|
||||
|
||||
@@ -56,7 +56,7 @@ struct AppState {
|
||||
// restart ends it (NFR-5).
|
||||
loop_run: LoopSlot,
|
||||
// The last loop's project, spec, launch choice and confirmed quick check,
|
||||
// kept after the running record is gone so Resume, Fix it by hand and
|
||||
// kept after the running record is gone so Resume, Fix together with an agent and
|
||||
// Finalize still work. Memory only.
|
||||
last_loop: Mutex<Option<LastLoop>>,
|
||||
}
|
||||
@@ -265,6 +265,9 @@ fn before_fresh_hook(state: &AppState) -> BeforeFresh {
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|guard| guard.as_ref().map(|sup| sup.session().sid.clone()));
|
||||
if let (Some(sid), Some(home)) = (sid.as_deref(), session_reader::console_home()) {
|
||||
restart_brief::leave_spec(&home, sid, chrono::Utc::now().timestamp_millis());
|
||||
}
|
||||
let note = sid.and_then(|sid| restart_brief::note_for_restart(&sid));
|
||||
if let Ok(guard) = announce.lock() {
|
||||
if let Some(server) = guard.as_ref() {
|
||||
@@ -1257,7 +1260,7 @@ async fn loop_resume(app: tauri::AppHandle, state: State<'_, AppState>) -> Resul
|
||||
start_loop(&app, &state, last.spec, true).await.map(|_| ())
|
||||
}
|
||||
|
||||
// Fix it by hand: an ordinary Implement session on the stopped phase, with no
|
||||
// Fix together with an agent: an ordinary Implement session on the stopped phase, with no
|
||||
// `--loop`, so the person talks to the agent as usual.
|
||||
#[tauri::command]
|
||||
fn loop_fix(state: State<'_, AppState>) -> Result<(), String> {
|
||||
|
||||
@@ -65,6 +65,39 @@ pub fn leave_brief(
|
||||
handoff::write(handoffs, when, &record, &body).map(Some)
|
||||
}
|
||||
|
||||
/// The spec session `sid` was on, if the fresh dashboard's picker can offer
|
||||
/// it: a skill's `specDir`, or, from the dashboard itself, the spec its picker
|
||||
/// had selected (the page's draft keeps it as `specSel`).
|
||||
pub fn spec_in(console_home: &Path, sid: &str) -> Option<String> {
|
||||
let session = session_reader::load(console_home, sid).ok()?;
|
||||
let spec = if text(&session.state, "workflow") == Some("dashboard") {
|
||||
let draft = std::fs::read_to_string(session.dir.join("draft.json")).ok()?;
|
||||
let draft: Value = serde_json::from_str(&draft).ok()?;
|
||||
text(&draft, "specSel")?.to_string()
|
||||
} else {
|
||||
text(&session.state, "specDir")?.to_string()
|
||||
};
|
||||
valid_spec(&spec).then_some(spec)
|
||||
}
|
||||
|
||||
/// Leave the spec session `sid` was on for the next dashboard in the same
|
||||
/// folder (the web console's `spec-carry.mjs` reads and removes it). A hint
|
||||
/// only: nothing here fails a Restart, a failed write loses the preselection.
|
||||
pub fn leave_spec(console_home: &Path, sid: &str, now_ms: i64) {
|
||||
let Some(spec) = spec_in(console_home, sid) else {
|
||||
return;
|
||||
};
|
||||
let Ok(session) = session_reader::load(console_home, sid) else {
|
||||
return;
|
||||
};
|
||||
let Some(worktree) = text(&session.state, "worktree") else {
|
||||
return;
|
||||
};
|
||||
let entry = serde_json::json!({ "project": worktree, "spec": spec, "at": now_ms });
|
||||
let _ = std::fs::create_dir_all(console_home);
|
||||
let _ = std::fs::write(console_home.join("spec-carry.json"), entry.to_string());
|
||||
}
|
||||
|
||||
/// The bar's line for a Restart on session `sid`, written to the real console
|
||||
/// and handoff folders. `None` when there was nothing to leave.
|
||||
pub fn note_for_restart(sid: &str) -> Option<String> {
|
||||
@@ -199,6 +232,44 @@ mod tests {
|
||||
assert!(doc.contains("Phase 5: Restart brief: 4 of 11 done."));
|
||||
}
|
||||
|
||||
fn carried(home: &Path) -> Option<Value> {
|
||||
let text = fs::read_to_string(home.join("spec-carry.json")).ok()?;
|
||||
serde_json::from_str(&text).ok()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_skill_session_carries_its_spec_to_the_next_dashboard() {
|
||||
let (home, project, _) = session("carry-skill", "implement", Some("specs/feature"));
|
||||
leave_spec(&home, "s1", 1234);
|
||||
let entry = carried(&home).expect("a carry file");
|
||||
assert_eq!(entry["spec"], "specs/feature");
|
||||
assert_eq!(entry["project"], project.to_string_lossy().as_ref());
|
||||
assert_eq!(entry["at"], 1234);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dashboard_session_carries_the_spec_its_picker_had() {
|
||||
let (home, _, _) = session("carry-dash", "dashboard", None);
|
||||
let draft = home.join("sessions").join("s1").join("draft.json");
|
||||
fs::write(&draft, r#"{"specSel":"specs/other"}"#).unwrap();
|
||||
leave_spec(&home, "s1", 1);
|
||||
assert_eq!(carried(&home).unwrap()["spec"], "specs/other");
|
||||
// Start from scratch, a handoff pick and an untouched picker carry nothing.
|
||||
for body in [r#"{"specSel":null}"#, r#"{"specSel":"handoff:x"}"#, "{}"] {
|
||||
let _ = fs::remove_file(home.join("spec-carry.json"));
|
||||
fs::write(&draft, body).unwrap();
|
||||
leave_spec(&home, "s1", 1);
|
||||
assert!(carried(&home).is_none(), "{body}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_session_with_no_spec_carries_nothing() {
|
||||
let (home, _, _) = session("carry-none", "quick-task", None);
|
||||
leave_spec(&home, "s1", 1);
|
||||
assert!(carried(&home).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dashboard_session_leaves_nothing() {
|
||||
let (home, _, handoffs) = session("dashboard", "dashboard", None);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Plan2Code",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"identifier": "com.plan2code.desktop",
|
||||
"build": {
|
||||
"frontendDist": "../ui",
|
||||
|
||||
@@ -197,6 +197,49 @@ fn restart_keeps_the_previous_agent_kind_mode_model_and_effort() {
|
||||
h.manager.stop();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_carries_the_model_and_effort_for_the_bar_only_when_known() {
|
||||
let mut h = Harness::new();
|
||||
h.manager
|
||||
.start(
|
||||
Agent::Builtin(builtin_entry("codex").unwrap()),
|
||||
Some("gpt-5".to_string()),
|
||||
Some("high".to_string()),
|
||||
PermissionMode::Checked,
|
||||
None,
|
||||
)
|
||||
.expect("start the fake agent");
|
||||
h.wait_for_output(READY, 1);
|
||||
let known = h.manager.snapshot();
|
||||
assert_eq!(known.model.as_deref(), Some("gpt-5"));
|
||||
assert_eq!(known.effort.as_deref(), Some("high"));
|
||||
let json = serde_json::to_value(&known).unwrap();
|
||||
assert_eq!(json["model"], "gpt-5");
|
||||
assert_eq!(json["effort"], "high");
|
||||
h.manager.stop();
|
||||
|
||||
h.manager
|
||||
.start(
|
||||
Agent::Builtin(builtin_entry("codex").unwrap()),
|
||||
None,
|
||||
None,
|
||||
PermissionMode::Checked,
|
||||
None,
|
||||
)
|
||||
.expect("start the fake agent on its own model");
|
||||
h.wait_for_output(READY, 2);
|
||||
let unknown = h.manager.snapshot();
|
||||
assert_eq!(unknown.model, None);
|
||||
assert_eq!(unknown.effort, None);
|
||||
let json = serde_json::to_value(&unknown).unwrap();
|
||||
assert!(json.get("model").is_none(), "an unknown model is left out");
|
||||
assert!(
|
||||
json.get("effort").is_none(),
|
||||
"an unknown effort is left out"
|
||||
);
|
||||
h.manager.stop();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restart_between_steps_replaces_the_agent_at_once() {
|
||||
let mut h = Harness::new();
|
||||
|
||||
+46
-5
@@ -3,7 +3,7 @@
|
||||
// request) with a drag handle.
|
||||
|
||||
import { mountTerminal } from './terminal.js';
|
||||
import { NEW_RELEASE_COMMAND, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js';
|
||||
import { NEW_RELEASE_COMMAND, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle, helloRetryAction, retryLabel, RETRY_AFTER_SECONDS } from './meter.js';
|
||||
|
||||
const { invoke, Channel } = window.__TAURI__.core;
|
||||
|
||||
@@ -18,6 +18,7 @@ const agentDotEl = document.getElementById('agent-dot');
|
||||
const agentNameEl = document.getElementById('agent-name');
|
||||
const agentEndedEl = document.getElementById('agent-ended');
|
||||
const agentBypassEl = document.getElementById('agent-bypass');
|
||||
const agentModelEl = document.getElementById('agent-model');
|
||||
const agentNoneEl = document.getElementById('agent-none');
|
||||
const agentStatusEl = document.getElementById('agent-status');
|
||||
const restartBtn = document.getElementById('agent-restart');
|
||||
@@ -166,6 +167,12 @@ function applyAgentState(next, { skipReset } = {}) {
|
||||
agentNameEl.textContent = active || ended ? label || 'The agent' : '';
|
||||
agentDotEl.className = `agent-dot${active ? (bypassActive ? ' is-warn' : ' is-ok') : ''}`;
|
||||
agentEndedEl.hidden = !ended;
|
||||
// The model and effort the app started it with, when it knows them: an agent
|
||||
// on its own default model has none to show, and an effort needs a model.
|
||||
const modelText = agent.model ? (agent.effort ? `${agent.model} · ${agent.effort}` : agent.model) : '';
|
||||
agentModelEl.textContent = active || ended ? modelText : '';
|
||||
agentModelEl.hidden = !agentModelEl.textContent;
|
||||
agentModelEl.title = agentModelEl.textContent ? `Started on ${agentModelEl.textContent}` : '';
|
||||
agentBypassEl.hidden = !bypassActive;
|
||||
renderAgentMenuHead(label || 'The agent', { active, ended, bypassActive });
|
||||
if (agentMenu.hidden === false && agentMenuBtn.hidden) closeBarMenus();
|
||||
@@ -910,8 +917,13 @@ async function onNoHello() {
|
||||
if (frameReady || !consoleKnown || restarting) return;
|
||||
// A page that does not answer cannot say it is done needing the person.
|
||||
clearAttention();
|
||||
// The next phase's console is on its way; the poll says so instead.
|
||||
if (loopRunning && loopStep === 'Starting') return;
|
||||
// The next phase's console is on its way; the poll says so instead. Look
|
||||
// again later all the same: dropped for good, a page that never said hello
|
||||
// left its message on screen with no way out once the step moved on.
|
||||
if (helloRetryAction({ loopRunning, loopStep }) === 'rearm') {
|
||||
helloTimer = setTimeout(onNoHello, HELLO_WAIT_MS);
|
||||
return;
|
||||
}
|
||||
let status = null;
|
||||
try {
|
||||
status = await invoke('console_status');
|
||||
@@ -928,7 +940,21 @@ async function onNoHello() {
|
||||
}
|
||||
}
|
||||
|
||||
function showState(text, buttonLabel, onButton, onCancel, { tired = false } = {}) {
|
||||
// A waiting message that offers a way out after a countdown: the button shows
|
||||
// disabled, counting down, then turns into `buttonLabel`'s plain retry.
|
||||
let retryTimer = null;
|
||||
|
||||
function stopRetryCountdown() {
|
||||
clearInterval(retryTimer);
|
||||
retryTimer = null;
|
||||
stateButton.disabled = false;
|
||||
}
|
||||
|
||||
function showState(text, buttonLabel, onButton, onCancel, { tired = false, retryAfter = 0 } = {}) {
|
||||
// The poll repeats the same waiting message every tick: that must not
|
||||
// restart a countdown that is already running (or its button).
|
||||
if (retryAfter > 0 && !stateBox.hidden && stateText.textContent === text && stateButton.textContent.startsWith('Try reconnecting')) return;
|
||||
stopRetryCountdown();
|
||||
hideLaunchCard();
|
||||
hideFirstRun();
|
||||
// statePlannyEl is an <svg>: unlike HTMLElement, it does not reflect the
|
||||
@@ -942,9 +968,20 @@ function showState(text, buttonLabel, onButton, onCancel, { tired = false } = {}
|
||||
stateCancelEl.hidden = !onCancel;
|
||||
stateCancelEl.onclick = onCancel || null;
|
||||
stateBox.hidden = false;
|
||||
if (retryAfter > 0 && buttonLabel) {
|
||||
let left = retryAfter;
|
||||
stateButton.disabled = true;
|
||||
stateButton.textContent = retryLabel(left);
|
||||
retryTimer = setInterval(() => {
|
||||
left -= 1;
|
||||
stateButton.textContent = retryLabel(left);
|
||||
if (left <= 0) stopRetryCountdown();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function hideState() {
|
||||
stopRetryCountdown();
|
||||
stateBox.hidden = true;
|
||||
}
|
||||
|
||||
@@ -983,7 +1020,7 @@ async function pollConsole() {
|
||||
if (action === 'wait-for-phase') {
|
||||
// Covers the old phase's page and its "Lost contact" until the new one
|
||||
// says hello. Never over a question the box is already asking.
|
||||
if (stateCancelEl.hidden) showState(loopDetailEl.textContent);
|
||||
if (stateCancelEl.hidden) showState(loopDetailEl.textContent, 'Try reconnecting', reconnectConsole, undefined, { retryAfter: RETRY_AFTER_SECONDS });
|
||||
return;
|
||||
}
|
||||
markConsoleDead();
|
||||
@@ -1167,6 +1204,7 @@ function applyLoopState(state) {
|
||||
}
|
||||
if (!loopRunning) loopTypingNoted = false;
|
||||
loopRunning = true;
|
||||
const stepBefore = loopStep;
|
||||
loopStep = state.step || '';
|
||||
restartBtn.hidden = true;
|
||||
applyLoopLocks(state);
|
||||
@@ -1176,6 +1214,9 @@ function applyLoopState(state) {
|
||||
// Only a change of words: this is a live region, and screen readers read it out.
|
||||
if (loopTitleEl.textContent !== banner.title) loopTitleEl.textContent = banner.title;
|
||||
if (loopDetailEl.textContent !== banner.detail) loopDetailEl.textContent = banner.detail;
|
||||
// A phase starting: look at the console now, so its waiting message and
|
||||
// countdown begin at once, not at the next status poll.
|
||||
if (loopStep === 'Starting' && stepBefore !== 'Starting' && consoleKnown) void pollConsole();
|
||||
loopHintEl.textContent = banner.hint;
|
||||
loopSpecEl.textContent = state.specName || '';
|
||||
loopPipsEl.replaceChildren(
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
.agent-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #666; }
|
||||
.agent-dot.is-ok { background: #6a9955; }
|
||||
.agent-dot.is-warn { background: #d7ba7d; }
|
||||
#agent-ended { color: var(--ink-3); font-weight: 400; }
|
||||
#agent-ended, #agent-model { color: var(--ink-3); font-weight: 400; }
|
||||
#agent-model { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
#agent-bypass { flex: none; font-size: 11px; font-weight: 600; line-height: 1.3; padding: 0 7px; border-radius: 999px; border: 1px solid #d7ba7d; color: #d7ba7d; }
|
||||
#agent-none { color: var(--ink-3); }
|
||||
#agent-status { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 320px; }
|
||||
@@ -283,7 +284,7 @@
|
||||
<button id="project-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="project-menu" hidden><span id="project-name"></span><span class="bar-caret" aria-hidden="true">▾</span></button>
|
||||
<!-- Whenever an agent exists, running or ended, just left of its menu. -->
|
||||
<button id="agent-restart" hidden>New Session</button>
|
||||
<button id="agent-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="agent-menu" hidden><span id="agent-dot" class="agent-dot" aria-hidden="true"></span><span id="agent-name"></span><span id="agent-ended" hidden>ended</span><span id="agent-bypass" title="Permission checks are off: the agent runs commands and changes files without asking" hidden>checks off</span><span class="bar-caret" aria-hidden="true">▾</span></button>
|
||||
<button id="agent-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="agent-menu" hidden><span id="agent-dot" class="agent-dot" aria-hidden="true"></span><span id="agent-name"></span><span id="agent-model" title="The model and effort this agent was started with" hidden></span><span id="agent-ended" hidden>ended</span><span id="agent-bypass" title="Permission checks are off: the agent runs commands and changes files without asking" hidden>checks off</span><span class="bar-caret" aria-hidden="true">▾</span></button>
|
||||
<span id="agent-none">No agent</span>
|
||||
<span id="agent-status" role="status"></span>
|
||||
<span id="bar-grow"></span>
|
||||
|
||||
@@ -253,6 +253,24 @@ export function deadConsoleAction({ loopRunning, loopStep, frameReady, reconnect
|
||||
return reconnects < limit ? "reconnect" : "offer-button";
|
||||
}
|
||||
|
||||
/**
|
||||
* What the window does when a page's hello did not come in time. While a loop
|
||||
* starts a phase the poll words the wait, so the check is not run now, but it
|
||||
* must be armed again: dropped for good, a page that never says hello left the
|
||||
* center message on screen with no way out once the step moved on.
|
||||
*/
|
||||
export function helloRetryAction({ loopRunning, loopStep }) {
|
||||
return loopRunning && loopStep === "Starting" ? "rearm" : "check";
|
||||
}
|
||||
|
||||
/** Seconds a waiting message stays before it offers Try reconnecting. */
|
||||
export const RETRY_AFTER_SECONDS = 10;
|
||||
|
||||
/** The retry button's label: counting down, then plain. */
|
||||
export function retryLabel(secondsLeft) {
|
||||
return secondsLeft > 0 ? `Try reconnecting in ${secondsLeft}s` : "Try reconnecting";
|
||||
}
|
||||
|
||||
/**
|
||||
* A project folder's own name, for the bar's project menu: the same last
|
||||
* segment the window title uses, or the whole path when there is none (a
|
||||
|
||||
@@ -76,7 +76,7 @@ export function check(srcDir) {
|
||||
if (!note) problems.push(`${file}: names no <D>/notes/<workflow>.md file`);
|
||||
else if (!fs.existsSync(path.join(notesDir, `${note[1]}.md`))) problems.push(`${file}: notes file ${note[1]}.md is not in src/web-console/notes/`);
|
||||
}
|
||||
if (seen !== 18) problems.push(`expected 18 skills with a console opening, found ${seen}`);
|
||||
if (seen !== 19) problems.push(`expected 19 skills with a console opening, found ${seen}`);
|
||||
return problems;
|
||||
}
|
||||
|
||||
@@ -87,5 +87,5 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
|
||||
for (const p of problems) console.error(` FAIL ${p}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("All 18 console openings share their sentences.");
|
||||
console.log("All 19 console openings share their sentences.");
|
||||
}
|
||||
@@ -2054,6 +2054,61 @@
|
||||
"args": [
|
||||
"/skill:plan2code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cursor CLI's shape: a chosen model goes ahead of the prompt",
|
||||
"entry": {
|
||||
"id": "cursor",
|
||||
"name": "Cursor CLI",
|
||||
"command": "agent",
|
||||
"args": [
|
||||
"{model}",
|
||||
"{prompt}"
|
||||
],
|
||||
"prompt": "/plan2code",
|
||||
"bypassArgs": [
|
||||
"--force"
|
||||
],
|
||||
"modelArgs": [
|
||||
"--model",
|
||||
"{model}"
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"model": "sonnet-4",
|
||||
"bypass": false
|
||||
},
|
||||
"args": [
|
||||
"--model",
|
||||
"sonnet-4",
|
||||
"/plan2code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cursor CLI's shape: no model, no model argument",
|
||||
"entry": {
|
||||
"id": "cursor",
|
||||
"name": "Cursor CLI",
|
||||
"command": "agent",
|
||||
"args": [
|
||||
"{model}",
|
||||
"{prompt}"
|
||||
],
|
||||
"prompt": "/plan2code",
|
||||
"bypassArgs": [
|
||||
"--force"
|
||||
],
|
||||
"modelArgs": [
|
||||
"--model",
|
||||
"{model}"
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"bypass": false
|
||||
},
|
||||
"args": [
|
||||
"/plan2code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"ids": [
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{"reason":"compiler-artifact","package_id":"demo 0.1.0","target":{"name":"demo"}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"function `old_helper` is never used","spans":[{"file_name":"src/lib.rs","line_start":8,"line_end":8,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"function `old_helper` is never used","spans":[{"file_name":"src/lib.rs","line_start":8,"line_end":8,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"unused_imports","explanation":null},"level":"warning","message":"unused import: `std::io`","spans":[{"file_name":"src/main.rs","line_start":1,"line_end":1,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"E0425","explanation":"..."},"level":"error","message":"cannot find value `x` in this scope","spans":[{"file_name":"src/main.rs","line_start":5,"line_end":5,"is_primary":true}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":null,"level":"warning","message":"1 warning emitted","spans":[]}}
|
||||
{"reason":"build-finished","success":true}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"unused_imports","explanation":null},"level":"warning","message":"unused imports: `fmt` and `io`","spans":[{"file_name":"src/net.rs","line_start":2,"line_end":2,"column_start":11,"column_end":14,"is_primary":true,"text":[{"text":"use std::{fmt, io};","highlight_start":11,"highlight_end":14}]},{"file_name":"src/net.rs","line_start":2,"line_end":2,"column_start":16,"column_end":18,"is_primary":true,"text":[{"text":"use std::{fmt, io};","highlight_start":16,"highlight_end":18}]}]}}
|
||||
{"reason":"compiler-message","package_id":"demo 0.1.0","message":{"code":{"code":"dead_code","explanation":null},"level":"warning","message":"multiple fields are never read","spans":[{"file_name":"src/model.rs","line_start":3,"line_end":3,"column_start":5,"column_end":9,"is_primary":false,"text":[{"text":"pub struct Model {","highlight_start":12,"highlight_end":17}]},{"file_name":"src/model.rs","line_start":4,"line_end":4,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" name: String,","highlight_start":5,"highlight_end":9}]},{"file_name":"src/model.rs","line_start":5,"line_end":5,"column_start":5,"column_end":8,"is_primary":true,"text":[{"text":" age: u32,","highlight_start":5,"highlight_end":8}]}]}}
|
||||
{"reason":"compiler-message", broken
|
||||
@@ -0,0 +1,3 @@
|
||||
internal/report/format.go:12:6: unreachable func: formatLegacy
|
||||
cmd/tool/main.go:40:6: unreachable func: (*server).shutdownOld
|
||||
not a deadcode line
|
||||
@@ -0,0 +1 @@
|
||||
{"files":["src/old.ts"],"issues":[{"file":"src/utils.ts","dependencies":[],"devDependencies":[],"files":[],"exports":[{"name":"formatDate","line":12,"col":17,"pos":250}],"types":[{"name":"Options","line":3,"col":13,"pos":40}],"enumMembers":{"Color":[{"name":"Purple","line":20,"col":3,"pos":400}]},"classMembers":{"Cache":[{"name":"flush","line":31,"col":3,"pos":600}]},"duplicates":[[{"name":"parse","line":40,"col":17},{"name":"default","line":44,"col":1}]]},{"file":"src/dead.ts","files":true,"exports":[],"types":[]},{"file":"src/broken.ts","exports":[{"line":2}]}]}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
||||
"version": "2.1.0",
|
||||
"runs": [
|
||||
{
|
||||
"tool": { "driver": { "name": "PMD", "version": "7.29.0" } },
|
||||
"results": [
|
||||
{
|
||||
"ruleId": "UnusedPrivateMethod",
|
||||
"message": { "text": "Avoid unused private methods such as 'helper(String)'." },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Service.java" }, "region": { "startLine": 42 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedPrivateField",
|
||||
"message": { "text": "Avoid unused private fields such as 'cache'." },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Store.java" }, "region": { "startLine": 7 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UseUtilityClass",
|
||||
"message": { "text": "This utility class has a non-private constructor" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/main/java/app/Util.java" }, "region": { "startLine": 3 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedLocalVariable",
|
||||
"message": { "text": "Avoid unused local variables such as 'tmp'." }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"runs": [
|
||||
{
|
||||
"tool": { "driver": { "name": "Psalm", "version": "7.2.0" } },
|
||||
"results": [
|
||||
{
|
||||
"ruleId": "PossiblyUnusedMethod",
|
||||
"message": { "text": "Cannot find any calls to method App\\Mailer::sendLater" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "file:///ROOT/src/Mailer.php" }, "region": { "startLine": 18 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnusedClass",
|
||||
"message": { "text": "Class `App\\Legacy` is never used" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/Legacy.php" }, "region": { "startLine": 5 } } }]
|
||||
},
|
||||
{
|
||||
"ruleId": "UnreachableCode",
|
||||
"message": { "text": "Unreachable code" },
|
||||
"locations": [{ "physicalLocation": { "artifactLocation": { "uri": "src/Flow.php" }, "region": { "startLine": 30 } } }]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
app/models.py:3: unused import 'os' (90% confidence)
|
||||
app/models.py:14: unused function 'legacy_total' (60% confidence)
|
||||
app/views.py:22: unused variable 'retries' (60% confidence, 1 line)
|
||||
app/views.py:40: unreachable code after 'return' (100% confidence)
|
||||
this line is mangled
|
||||
@@ -111,11 +111,11 @@ test("loadAgentList: bad JSON and a wrong schema warn and give nothing", (t) =>
|
||||
assert.match(wrong.warnings[0], /schema/);
|
||||
});
|
||||
|
||||
test("loadAgentList: the shipped agents.json loads with 3 built-ins and 4 templates", () => {
|
||||
test("loadAgentList: the shipped agents.json loads with 3 built-ins and 5 templates", () => {
|
||||
const { builtins, templates, warnings } = loadAgentList({ dir: path.join(ROOT, "src", "launcher") });
|
||||
assert.deepEqual(warnings, []);
|
||||
assert.deepEqual(builtins.map((a) => a.id), ["claude", "devin", "codex"]);
|
||||
assert.deepEqual(templates.map((a) => a.id), ["copilot", "opencode", "gemini", "pi"]);
|
||||
assert.deepEqual(templates.map((a) => a.id), ["copilot", "opencode", "gemini", "pi", "cursor"]);
|
||||
});
|
||||
|
||||
test("every shipped template passes normalizeAgents() with no warnings", () => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS, NEW_RELEASE_COMMAND } from "../plan2code-app/ui/meter.js";
|
||||
import { helloRetryAction, retryLabel, RETRY_AFTER_SECONDS, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS, NEW_RELEASE_COMMAND } from "../plan2code-app/ui/meter.js";
|
||||
import { findBrowser, launchBrowser } from "./browser.mjs";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -423,6 +423,27 @@ test("a console dead between a loop's phases waits for the next phase; any other
|
||||
assert.equal(deadConsoleAction({ ...base, frameReady: false }), "no-hello");
|
||||
});
|
||||
|
||||
test("a page that said no hello is looked at again while a loop starts a phase, and the retry button counts down", () => {
|
||||
assert.equal(helloRetryAction({ loopRunning: true, loopStep: "Starting" }), "rearm", "the poll covers Starting, but nothing may drop the check for good");
|
||||
assert.equal(helloRetryAction({ loopRunning: true, loopStep: "Build" }), "check");
|
||||
assert.equal(helloRetryAction({ loopRunning: false, loopStep: "Starting" }), "check");
|
||||
assert.equal(retryLabel(10), "Try reconnecting in 10s");
|
||||
assert.equal(retryLabel(1), "Try reconnecting in 1s");
|
||||
assert.equal(retryLabel(0), "Try reconnecting");
|
||||
assert.equal(retryLabel(-3), "Try reconnecting");
|
||||
assert.equal(RETRY_AFTER_SECONDS, 10);
|
||||
});
|
||||
|
||||
test("app.js re-arms the hello check and offers Try reconnecting on the loop's waiting message", () => {
|
||||
const app = fs.readFileSync(path.join(HERE, "..", "plan2code-app", "ui", "app.js"), "utf8");
|
||||
const noHello = app.slice(app.indexOf("async function onNoHello"), app.indexOf("function showState"));
|
||||
assert.match(noHello, /helloRetryAction\(/);
|
||||
assert.match(noHello, /setTimeout\(onNoHello, HELLO_WAIT_MS\)/, "a swallowed hello check is armed again");
|
||||
assert.match(app, /showState\(loopDetailEl\.textContent[^)]*retryAfter/s, "the loop's wait for a phase's page offers the button");
|
||||
assert.doesNotMatch(app, /showState\('Opening the page'[^)]*retryAfter/s, "onNoHello swaps that message at 8s, so a 10s countdown there never finishes");
|
||||
assert.match(app, /loopStep === 'Starting' && stepBefore !== 'Starting' && consoleKnown\) void pollConsole\(\)/, "a phase starting looks at the console at once, so the countdown does not wait for the next poll");
|
||||
});
|
||||
|
||||
test("app.js refills the reconnect budget on a new page and brings the page back when a loop ends", () => {
|
||||
const app = fs.readFileSync(path.join(HERE, "..", "plan2code-app", "ui", "app.js"), "utf8");
|
||||
const announced = app.slice(app.indexOf("function showAnnounced"), app.indexOf("window.__TAURI__.event.listen('console-page'"));
|
||||
|
||||
@@ -58,7 +58,7 @@ test("a wrong workflow name or a missing notes file is reported", () => {
|
||||
test("a skill that loses its opening is caught by the count", () => {
|
||||
const dir = copySrc();
|
||||
fs.rmSync(path.join(dir, "plan2code-pr-prep.md"));
|
||||
assert.match(check(dir).join("\n"), /expected 18 skills with a console opening, found 17/);
|
||||
assert.match(check(dir).join("\n"), /expected 19 skills with a console opening, found 18/);
|
||||
});
|
||||
|
||||
test("helpers", () => {
|
||||
@@ -66,6 +66,7 @@ test("helpers", () => {
|
||||
assert.equal(workflowOf("plan2code-1b-revise-plan"), "revise-plan");
|
||||
assert.equal(workflowOf("plan2code-3-implement-review"), "implement-review");
|
||||
assert.equal(workflowOf("plan2code-pr-prep"), "pr-prep");
|
||||
assert.equal(workflowOf("plan2code-dead-code"), "dead-code");
|
||||
});
|
||||
|
||||
test("the CLI exits 1 on drift", () => {
|
||||
|
||||
@@ -166,7 +166,8 @@ test("no built skill holds the large console files; the shared copy keeps every
|
||||
assert.ok(fs.readFileSync(built).equals(fs.readFileSync(path.join(src, ...rel.split("/")))), `${rel} differs from src/`);
|
||||
}
|
||||
assert.ok(fs.existsSync(path.join(shared, "public", "vendor", "codemirror.esm.js")), "codemirror ships");
|
||||
assert.ok(fs.readdirSync(path.join(shared, "public")).filter((f) => f.endsWith(".mp3")).length >= 3, "every sound ships");
|
||||
assert.equal(fs.readdirSync(path.join(shared, "public", "sounds")).filter((f) => /^sound-\d\d\.mp3$/.test(f)).length, 19, "every pickable sound ships");
|
||||
assert.equal(fs.readdirSync(path.join(shared, "public")).filter((f) => f.endsWith(".mp3")).length, 2, "the boot and snore sounds ship");
|
||||
});
|
||||
|
||||
test("the shared copy ships a module for every game listed in public/activities.js", async () => {
|
||||
|
||||
@@ -29,6 +29,7 @@ export const BUDGETS = {
|
||||
// Each topic file under notes/, read when its workflow starts.
|
||||
notes: {
|
||||
"changelog.md": 1400,
|
||||
"dead-code.md": 4250,
|
||||
"diagnose.md": 2700,
|
||||
"document.md": 400,
|
||||
"finalize.md": 2000,
|
||||
@@ -38,9 +39,9 @@ export const BUDGETS = {
|
||||
"init.md": 300,
|
||||
"loop.md": 11600,
|
||||
"pathfinder.md": 2400,
|
||||
"plan.md": 700,
|
||||
"plan.md": 800,
|
||||
"pr-prep.md": 4500,
|
||||
"quick-task.md": 4000,
|
||||
"quick-task.md": 4100,
|
||||
"review.md": 1000,
|
||||
"revise-plan.md": 1200,
|
||||
"test.md": 5400,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"test-line-endings.mjs",
|
||||
"test-script-changelog.mjs",
|
||||
"test-script-coverage.mjs",
|
||||
"test-script-dead-code.mjs",
|
||||
"test-script-finalize.mjs",
|
||||
"test-script-git.mjs",
|
||||
"test-script-pathfinder.mjs",
|
||||
@@ -27,6 +28,8 @@
|
||||
"test-set-version.mjs",
|
||||
"test-skill-scripts.mjs",
|
||||
"test-skill-test-runs.mjs",
|
||||
"test-spec-carry-page.mjs",
|
||||
"test-spec-carry.mjs",
|
||||
"test-us-english.mjs",
|
||||
"test-web-console-agents-doc.mjs",
|
||||
"test-web-console-git-board.mjs",
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -70,11 +70,15 @@ test("every script a SKILL.md (or a reference it ships) runs exists beside it, a
|
||||
});
|
||||
|
||||
test("scripts are self-contained: built-ins and siblings only", () => {
|
||||
for (const dir of [path.join(ROOT, "src", "skill-scripts"), ...fs.readdirSync(path.join(ROOT, "src")).filter((n) => n.endsWith("-scripts")).map((n) => path.join(ROOT, "src", n))]) {
|
||||
const shared = path.join(ROOT, "src", "skill-scripts");
|
||||
for (const dir of [shared, ...fs.readdirSync(path.join(ROOT, "src")).filter((n) => n.endsWith("-scripts")).map((n) => path.join(ROOT, "src", n))]) {
|
||||
for (const f of fs.readdirSync(dir).filter((n) => n.endsWith(".mjs"))) {
|
||||
const t = fs.readFileSync(path.join(dir, f), "utf8");
|
||||
for (const m of t.matchAll(/^import .* from "([^"]+)";$/gm)) {
|
||||
const sibling = /^\.\/[\w-]+\.mjs$/.test(m[1]) && fs.existsSync(path.join(dir, m[1]));
|
||||
// A skill's own script may import a shared script too: the build lays
|
||||
// both in one scripts/ folder, and the check below holds the skill to
|
||||
// shipping it.
|
||||
const sibling = /^\.\/[\w-]+\.mjs$/.test(m[1]) && (fs.existsSync(path.join(dir, m[1])) || fs.existsSync(path.join(shared, m[1])));
|
||||
assert.ok(m[1].startsWith("node:") || m[1] === "./common.mjs" || sibling, `${f} imports ${m[1]}`);
|
||||
}
|
||||
assert.ok(!/[\u0000-\u0008]/.test(t), `${f} contains a control character (an escape lost in an edit?)`);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// The page side of the spec an app's New Session carries: loadSpecCarry() in selectors.js.
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { page } from "../src/web-console/public/state.js";
|
||||
import { loadSpecCarry } from "../src/web-console/public/selectors.js";
|
||||
|
||||
const specs = [
|
||||
{ dir: "specs/a", name: "a", state: "building" },
|
||||
{ dir: "specs/b", name: "b", state: "planned" },
|
||||
];
|
||||
|
||||
// loadSpecCarry asks once per page, so each case is a fresh module copy.
|
||||
async function fresh() {
|
||||
return (await import(`../src/web-console/public/selectors.js?${Math.random()}`)).loadSpecCarry;
|
||||
}
|
||||
|
||||
function setup({ spec, sel } = {}) {
|
||||
page.S = { workflow: "dashboard", scan: { specs } };
|
||||
page.local = sel === undefined ? {} : { specSel: sel };
|
||||
globalThis.localStorage = { setItem() {}, getItem: () => null, removeItem() {} };
|
||||
const calls = [];
|
||||
globalThis.fetch = async (url, init) => {
|
||||
calls.push([url, init && init.method]);
|
||||
return { status: 200, json: async () => ({ spec }) };
|
||||
};
|
||||
return calls;
|
||||
}
|
||||
|
||||
test("a carried spec the picker lists becomes the pick", async () => {
|
||||
setup({ spec: "specs/b" });
|
||||
await (await fresh())();
|
||||
assert.equal(page.local.specSel, "specs/b");
|
||||
});
|
||||
|
||||
test("a carried spec the picker does not list leaves the default", async () => {
|
||||
setup({ spec: "specs/gone" });
|
||||
await (await fresh())();
|
||||
assert.equal("specSel" in page.local, false);
|
||||
});
|
||||
|
||||
test("a pick the person already made is never replaced, or even asked about", async () => {
|
||||
const calls = setup({ spec: "specs/b", sel: null });
|
||||
await (await fresh())();
|
||||
assert.equal(page.local.specSel, null);
|
||||
assert.equal(calls.length, 0);
|
||||
});
|
||||
|
||||
test("it asks once per page", async () => {
|
||||
const calls = setup({ spec: undefined });
|
||||
const load = await fresh();
|
||||
await load();
|
||||
await load();
|
||||
assert.equal(calls.length, 1);
|
||||
assert.deepEqual(calls[0], ["/spec-carry", "POST"]);
|
||||
assert.equal(typeof loadSpecCarry, "function");
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
// The spec an app's New Session carries to the fresh dashboard (spec-carry.mjs).
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import { takeSpecCarry, SPEC_CARRY_MAX_AGE_MS } from "../src/web-console/spec-carry.mjs";
|
||||
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "spec-carry-"));
|
||||
const file = path.join(dir, "spec-carry.json");
|
||||
const put = (entry) => fs.writeFileSync(file, JSON.stringify(entry));
|
||||
const NOW = 1_000_000_000;
|
||||
|
||||
test("a fresh hint for this folder is taken once", () => {
|
||||
put({ project: dir, spec: "specs/feature", at: NOW });
|
||||
assert.equal(takeSpecCarry(dir, NOW + 1000, file), "specs/feature");
|
||||
assert.equal(fs.existsSync(file), false);
|
||||
assert.equal(takeSpecCarry(dir, NOW + 1000, file), null);
|
||||
});
|
||||
|
||||
test("a stale hint is dropped, not used", () => {
|
||||
put({ project: dir, spec: "specs/feature", at: NOW });
|
||||
assert.equal(takeSpecCarry(dir, NOW + SPEC_CARRY_MAX_AGE_MS + 1, file), null);
|
||||
assert.equal(fs.existsSync(file), false);
|
||||
});
|
||||
|
||||
test("another folder's fresh hint stays for its own dashboard", () => {
|
||||
put({ project: path.join(dir, "elsewhere"), spec: "specs/feature", at: NOW });
|
||||
assert.equal(takeSpecCarry(dir, NOW, file), null);
|
||||
assert.equal(fs.existsSync(file), true);
|
||||
});
|
||||
|
||||
test("a spec that is not directly under specs/ is refused", () => {
|
||||
for (const spec of ["../x", "specs/a/b", "specs/.hidden", "other", 5]) {
|
||||
put({ project: dir, spec, at: NOW });
|
||||
assert.equal(takeSpecCarry(dir, NOW, file), null, String(spec));
|
||||
}
|
||||
});
|
||||
|
||||
test("no file, or a broken one, is no hint", () => {
|
||||
fs.rmSync(file, { force: true });
|
||||
assert.equal(takeSpecCarry(dir, NOW, file), null);
|
||||
fs.writeFileSync(file, "{nope");
|
||||
assert.equal(takeSpecCarry(dir, NOW, file), null);
|
||||
});
|
||||
@@ -2085,8 +2085,8 @@ test("workspace cursor never moves backwards, and only changes past it are pendi
|
||||
}
|
||||
});
|
||||
|
||||
test("subagents: only the fifteen opted-in workflows offer the switch", () => {
|
||||
for (const w of ["init", "init-update", "pathfinder", "plan", "revise-plan", "document", "implement", "implement-review", "quick-task", "review", "finalize", "xray", "diagnose", "pr-prep", "test"]) {
|
||||
test("subagents: only the sixteen opted-in workflows offer the switch", () => {
|
||||
for (const w of ["init", "init-update", "pathfinder", "plan", "revise-plan", "document", "implement", "implement-review", "quick-task", "review", "finalize", "xray", "diagnose", "pr-prep", "test", "dead-code"]) {
|
||||
assert.equal(offered(w), true, w);
|
||||
assert.ok(defaultInstruction(w).length > 0, `${w} has a default instruction`);
|
||||
}
|
||||
@@ -2094,7 +2094,7 @@ test("subagents: only the fifteen opted-in workflows offer the switch", () => {
|
||||
assert.equal(offered(w), false, String(w));
|
||||
assert.equal(defaultInstruction(w), "");
|
||||
}
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 15);
|
||||
assert.equal(Object.keys(SUBAGENT_WORKFLOWS).length, 16);
|
||||
assert.deepEqual(defaultSetting("review"), { workflow: "review", on: true, instruction: null, max: 3, strength: "balanced" });
|
||||
assert.equal(defaultSetting("changelog").on, false, "a skill without the switch is never on");
|
||||
assert.equal(effectiveInstruction({ workflow: "review", instruction: " " }), defaultInstruction("review"));
|
||||
@@ -2384,14 +2384,14 @@ test("meter: the weights and labels built from the skill list are the ones writt
|
||||
"pathfinder-chart": 2, "pathfinder-question": 0, "pathfinder-research": 1,
|
||||
plan: 2, "revise-plan": 1, document: 2, "implement-phase": 2, "implement-review-phase": 3,
|
||||
review: 2, "quick-task": 1, init: 2, "init-update": 2, finalize: 1, handoff: 0, git: 1,
|
||||
"git-commits": 0, "git-conflict": 1, changelog: 1, xray: 1, diagnose: 1, "pr-prep": 1, test: 1,
|
||||
"git-commits": 0, "git-conflict": 1, changelog: 1, xray: 1, diagnose: 1, "pr-prep": 1, test: 1, "dead-code": 1,
|
||||
});
|
||||
assert.deepEqual({ ...LAUNCH_LABELS }, {
|
||||
plan: "Plan started", "revise-plan": "Revise plan started", document: "Document started",
|
||||
review: "Review started", "quick-task": "Quick task started", init: "Init started",
|
||||
"init-update": "Init update started", finalize: "Finalize started", git: "Git started",
|
||||
changelog: "Changelog started", xray: "X-ray started", diagnose: "Diagnose started",
|
||||
"pr-prep": "PR Prep started", test: "Test started",
|
||||
"pr-prep": "PR Prep started", test: "Test started", "dead-code": "Dead Code started",
|
||||
});
|
||||
assert.deepEqual({ ...RUN_LABELS }, {
|
||||
"pathfinder-chart": "Pathfinder map written", "pathfinder-question": "Pathfinder question settled",
|
||||
@@ -2401,7 +2401,7 @@ test("meter: the weights and labels built from the skill list are the ones writt
|
||||
"quick-task": "Quick task built", init: "Init run", "init-update": "Init update run",
|
||||
finalize: "Finalize run", handoff: "Handoff written", git: "Git run", "git-commits": "Commits in Git",
|
||||
"git-conflict": "Git conflict help", changelog: "Changelog run", xray: "X-ray run", diagnose: "Diagnose run",
|
||||
"pr-prep": "PR Prep run", test: "Test run",
|
||||
"pr-prep": "PR Prep run", test: "Test run", "dead-code": "Dead Code run",
|
||||
});
|
||||
for (const t of [WEIGHTS, LAUNCH_LABELS, RUN_LABELS]) assert.ok(Object.isFrozen(t));
|
||||
});
|
||||
@@ -2416,6 +2416,9 @@ test("noteSwitchShows: Pathfinder, Plan and Quick Task on Start fresh, Revise pl
|
||||
assert.equal(noteSwitchShows(entry(skill), scan, sel("exploring")), false, `${skill} on a picked spec`);
|
||||
assert.equal(noteSwitchShows(entry(skill), scan, sel("exploring", { planChange: true })), false, `${skill} on a picked spec with a brief`);
|
||||
}
|
||||
const diagnose = entry("plan2code-diagnose");
|
||||
assert.equal(noteSwitchShows(diagnose, scan, null), true, "Diagnose on Start fresh");
|
||||
assert.equal(noteSwitchShows(diagnose, scan, sel("documented")), true, "Diagnose launches untargeted, so a picked spec does not hide it");
|
||||
const revise = entry("plan2code-1b-revise-plan");
|
||||
assert.equal(noteSwitchShows(revise, scan, null), false, "Revise plan is grayed on Start fresh");
|
||||
for (const state of ["documented", "building", "built"]) {
|
||||
|
||||
@@ -478,6 +478,17 @@ test("loopEnd: ask is accepted in can, so a stopped loop can offer a question be
|
||||
assert.deepEqual(next.loopEnd.can, ["resume", "ask", "fix", "dashboard"]);
|
||||
});
|
||||
|
||||
test("loopEnd: a short reason and a recommended button are stored, and both stay optional", () => {
|
||||
const { problems, next } = tryPatch(loopState(), {
|
||||
loopEnd: goodEnd({ can: ["ask", "resume", "fix", "dashboard"], reason: "Phase 2 stopped because the quick check failed.", recommend: "fix", phase: 2 }),
|
||||
});
|
||||
assert.deepEqual(problems, []);
|
||||
assert.equal(next.loopEnd.phase, 2);
|
||||
assert.equal(next.loopEnd.reason, "Phase 2 stopped because the quick check failed.");
|
||||
assert.equal(next.loopEnd.recommend, "fix");
|
||||
assert.deepEqual(tryPatch(loopState(), { loopEnd: goodEnd() }).problems, [], "an older app sends neither");
|
||||
});
|
||||
|
||||
test("loopEnd: an unknown evidence id, a push in can, and the other bad fields are refused, each named", () => {
|
||||
const cases = [
|
||||
["an unknown evidence id", goodEnd({ evidence: "nope" }), /loopEnd\.evidence must be the id of a doc on the page/],
|
||||
@@ -489,6 +500,10 @@ test("loopEnd: an unknown evidence id, a push in can, and the other bad fields a
|
||||
["a bad decision count", goodEnd({ phases: [{ n: 1, name: "Setup", commit: "abc1234", unfixed: 0, retries: 0, assumed: -1 }] }), /loopEnd\.phases\[0\]\.assumed must be a non-negative integer/],
|
||||
["a bad commit hash", goodEnd({ phases: [{ n: 1, name: "Setup", commit: "zzz", unfixed: 0, retries: 0 }] }), /loopEnd\.phases\[0\]\.commit must be a short hex hash or null/],
|
||||
["a forbidden completion marker in line", goodEnd({ line: "TASK_COMPLETE" }), /loopEnd\.line: contains a loop completion marker/],
|
||||
["a two-line reason", goodEnd({ reason: "one\ntwo" }), /loopEnd\.reason must be one line/],
|
||||
["a recommend the screen does not offer", goodEnd({ can: ["resume", "dashboard"], recommend: "fix" }), /loopEnd\.recommend must be resume, fix or finalize, and one of can/],
|
||||
["a recommend that is not a choice", goodEnd({ can: ["ask", "resume"], recommend: "ask" }), /loopEnd\.recommend must be resume, fix or finalize/],
|
||||
["a phase that is not a positive integer", goodEnd({ phase: 0 }), /loopEnd\.phase must be a positive integer/],
|
||||
];
|
||||
for (const [what, end, expected] of cases) {
|
||||
const { problems } = tryPatch(loopState(), { loopEnd: end });
|
||||
|
||||
@@ -973,6 +973,8 @@ test("POST /notepad/tab/sent answers 200, 400 and 404, and GET /notepad carries
|
||||
assert.equal(ok.body.ok, true);
|
||||
assert.equal(ok.body.sent.workflow, "quick-task");
|
||||
assert.deepEqual((await getJson(s, "/notepad")).body.tabs, [{ id, name: "Idea", sent: ok.body.sent }]);
|
||||
assert.equal((await post({ id, workflow: "diagnose" })).status, 200, "Diagnose can be sent from a tab");
|
||||
assert.equal((await post({ id, workflow: "quick-task" })).status, 200);
|
||||
assert.deepEqual(await post({ id, workflow: "document" }), { status: 400, body: { error: "bad-sent" } });
|
||||
assert.deepEqual(await post({ id, workflow: "revise-plan", spec: "../x" }), { status: 400, body: { error: "bad-sent" } });
|
||||
assert.deepEqual(await post({ id: "ffffffffffff", workflow: "plan" }), { status: 404, body: { error: "no-such-tab" } });
|
||||
|
||||
@@ -827,3 +827,111 @@ test("a pathfinder session offers Write a brief, and the picked range reaches th
|
||||
assert.deepEqual(got.actions.map(({ i, type, range }) => ({ i, type, range })), [{ i: "__brief", type: "brief", range: "this week" }]);
|
||||
assert.equal(got.reply, "Write a brief for this week.");
|
||||
});
|
||||
|
||||
// What a person sees break: the agent answers a note in the thread and the
|
||||
// card says nothing, so the question looks as current as before the reply.
|
||||
test("a noted card with a trailing agent reply shows the check tag, and an un-noted one does not", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
payload: {
|
||||
items: [
|
||||
{ id: "q1", kind: "text", title: "What to call it", body: "A short name." },
|
||||
{ id: "q2", kind: "text", title: "Who uses it", body: "Who, and for what?" },
|
||||
],
|
||||
},
|
||||
});
|
||||
const aside = s.page.locator("#aside");
|
||||
const tag = aside.locator(".noted-tag");
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
assert.equal(await tag.count(), 0, "no tag before any note");
|
||||
|
||||
await fillBox(s.page.locator("#thread-q1"), "Maybe two names?");
|
||||
await sendAndCollect(s);
|
||||
s.post({ items: [{ id: "q1", thread: [{ who: "agent", text: "Two names fit, I will ask." }] }, { id: "q2", thread: [{ who: "agent", text: "A plain reply, no note from you." }] }] });
|
||||
await aside.getByText("Two names fit, I will ask.").waitFor();
|
||||
await tag.waitFor();
|
||||
assert.equal((await tag.innerText()).trim(), "Plan2Code replied, check this still fits");
|
||||
assert.equal(await tag.getAttribute("role"), "note", "the tag has an accessible role");
|
||||
assert.notEqual(await styleOf(tag, "backgroundColor"), "rgba(0, 0, 0, 0)", "the tag is drawn, not bare text");
|
||||
|
||||
await s.page.locator("#sidebar .rail-item", { hasText: "Who uses it" }).click();
|
||||
await aside.getByText("A plain reply, no note from you.").waitFor();
|
||||
assert.equal(await aside.locator(".noted-tag").count(), 0, "a reply on a question nobody noted gets no tag");
|
||||
});
|
||||
|
||||
// What a person sees break: a question arrives while they type, the notice
|
||||
// vanishes after 8 seconds, and the question stays buried in the list.
|
||||
test("a question arriving while a note is typed keeps its notice and a New mark until it is opened", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
clock: true,
|
||||
payload: { items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name." }] },
|
||||
});
|
||||
const note = s.page.locator("#thread-q1");
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
await fillBox(note, "my half-written thought");
|
||||
await note.click();
|
||||
await s.page.waitForFunction(() => Boolean(document.activeElement && document.activeElement.field));
|
||||
|
||||
s.post({ items: [{ id: "q2", kind: "text", title: "Who uses it", body: "Who, and for what?" }] });
|
||||
const banner = s.page.locator("#banner");
|
||||
await s.page.getByText("A new question from Plan2Code").waitFor();
|
||||
const entry = s.page.locator("#sidebar .rail-item", { hasText: "Who uses it" });
|
||||
await entry.locator(".rail-new").waitFor();
|
||||
|
||||
await s.page.clock.fastForward(20000);
|
||||
assert.equal(await banner.isVisible(), true, "the notice is still up after 20 seconds");
|
||||
assert.match(await banner.innerText(), /new question/);
|
||||
assert.equal(await boxValue(note), "my half-written thought", "the draft is untouched");
|
||||
assert.equal(await s.page.evaluate(() => Boolean(document.activeElement && document.activeElement.field)), true, "focus is still in the note box");
|
||||
assert.equal(await itemCard(s.page, "q1").isVisible(), true, "the selection did not move");
|
||||
|
||||
// By keyboard, so no pointer press clears the notice first: only the prune can.
|
||||
await entry.focus();
|
||||
await s.page.keyboard.press("Enter");
|
||||
await itemCard(s.page, "q2").waitFor();
|
||||
assert.equal(await s.page.locator("#sidebar .rail-new").count(), 0, "the mark is gone once the question is opened");
|
||||
assert.equal(await banner.isVisible(), false, "the notice goes with the last mark");
|
||||
});
|
||||
|
||||
test("opening the marked question from the pager clears its New mark", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
payload: { items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name." }] },
|
||||
});
|
||||
const note = s.page.locator("#thread-q1");
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
await fillBox(note, "half a thought");
|
||||
await note.click();
|
||||
await s.page.waitForFunction(() => Boolean(document.activeElement && document.activeElement.field));
|
||||
s.post({ items: [{ id: "q2", kind: "text", title: "Who uses it", body: "Who, and for what?" }] });
|
||||
const entry = s.page.locator("#sidebar .rail-item", { hasText: "Who uses it" });
|
||||
await entry.locator(".rail-new").waitFor();
|
||||
const pager = s.page.getByRole("navigation", { name: "Move between the questions waiting" });
|
||||
await pager.getByRole("button", { name: /Next.*Who uses it/ }).click();
|
||||
await itemCard(s.page, "q2").waitFor();
|
||||
assert.equal(await s.page.locator("#sidebar .rail-new").count(), 0, "the mark is gone once the pager opens the question");
|
||||
});
|
||||
|
||||
test("a staying arrival notice survives typing, goes on Escape, and the New mark outlasts it", async (t) => {
|
||||
const s = await openSession(await suite.browser(), {
|
||||
t,
|
||||
workflow: "plan",
|
||||
payload: { items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name." }] },
|
||||
});
|
||||
const note = s.page.locator("#thread-q1");
|
||||
await itemCard(s.page, "q1").waitFor();
|
||||
await note.click();
|
||||
await s.page.waitForFunction(() => Boolean(document.activeElement && document.activeElement.field));
|
||||
s.post({ items: [{ id: "q2", kind: "text", title: "Who uses it", body: "Who, and for what?" }] });
|
||||
const banner = s.page.locator("#banner");
|
||||
await s.page.getByText("A new question from Plan2Code").waitFor();
|
||||
await s.page.keyboard.press("a");
|
||||
assert.equal(await banner.isVisible(), true, "a letter typed in the note does not clear the notice");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await banner.waitFor({ state: "hidden" });
|
||||
assert.equal(await s.page.locator("#sidebar .rail-item", { hasText: "Who uses it" }).locator(".rail-new").count(), 1, "the New mark stays after the notice is dismissed");
|
||||
});
|
||||
@@ -212,11 +212,15 @@ test("picking Start from scratch instead of a spec grays Document, and a launch
|
||||
const document = lightOf(main, "/plan2code-2-document");
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
assert.equal(await document.isEnabled(), true, "Document is lit for the drafted spec");
|
||||
// The top bar names the picked spec beside the meter, and drops it from scratch.
|
||||
const specTag = main.page().locator("#spec-tag");
|
||||
assert.ok(await until(async () => (await specTag.isVisible()) && (await specTag.textContent()) === "demo"), "the top bar names the spec demo");
|
||||
|
||||
// From scratch there is no draft to document: the card grays.
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.equal(await document.isDisabled(), true, "Document is grayed with no spec picked");
|
||||
assert.ok(await until(() => specTag.isHidden()), "the top bar's spec name goes from scratch");
|
||||
assert.equal(await chipFor(main, "demo").getAttribute("aria-current"), "false");
|
||||
|
||||
// Back on the spec it is lit again; then from scratch once more to launch.
|
||||
@@ -232,6 +236,40 @@ test("picking Start from scratch instead of a spec grays Document, and a launch
|
||||
assert.ok(!launch.spec, `a launch from scratch names no spec: ${JSON.stringify(launch)}`);
|
||||
});
|
||||
|
||||
// What a person would see break: the Dead Code card missing from Useful any
|
||||
// time, drawn without its skull, grayed for want of a spec it never takes, or
|
||||
// launching with the picked spec riding along.
|
||||
test("the Dead Code card sits in Useful any time with its skull, is lit with or without a spec, and launches with no spec", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project: tempProject(DRAFT_PROJECT) });
|
||||
const main = await toTheMenu(s);
|
||||
await hideUnavailable(main, false);
|
||||
const card = lightOf(main, "/plan2code-dead-code");
|
||||
await card.waitFor();
|
||||
|
||||
const group = main.locator("section.dash-group").filter({ has: s.page.locator("h3", { hasText: /^Useful any time$/ }) });
|
||||
assert.equal(await group.locator("code", { hasText: /^\/plan2code-dead-code$/ }).count(), 1, "the card is in the Useful any time group");
|
||||
assert.match(await textOf(card), /Utility/i, "it wears the Utility chip (drawn in capitals)");
|
||||
assert.match(await textOf(card), /Clear out dead code/, "it has its title");
|
||||
assert.equal(await card.locator("use").getAttribute("href"), "#ci-dead-code", "its icon is the skull");
|
||||
assert.equal(await s.page.locator("symbol#ci-dead-code").count(), 1, "the skull symbol is drawn in the icon sheet");
|
||||
|
||||
// Lit with no spec picked, and with one.
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.equal(await card.isEnabled(), true, "lit with no spec picked");
|
||||
await chipFor(main, "demo").click();
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
assert.equal(await card.isEnabled(), true, "lit with a spec picked");
|
||||
|
||||
// A launch with the spec still picked names no spec: Dead Code takes none.
|
||||
await card.click();
|
||||
await main.getByRole("button", { name: "Start Clear out dead code" }).click();
|
||||
const launch = collect(s).actions.find((a) => a.i === "__launch");
|
||||
assert.ok(launch, "the send carries a launch");
|
||||
assert.deepEqual({ skill: launch.skill, workflow: launch.workflow }, { skill: "plan2code-dead-code", workflow: "dead-code" });
|
||||
assert.ok(!launch.spec, `a Dead Code launch names no spec: ${JSON.stringify(launch)}`);
|
||||
});
|
||||
|
||||
// What a person would see break: a spec not documented yet offers nothing to
|
||||
// read, or its Map and Plan draft tabs stay up for a spec that has an
|
||||
// overview (or for no spec at all).
|
||||
@@ -581,6 +619,8 @@ test("the Notebook switch shows on Start fresh for Pathfinder, Plan and Quick Ta
|
||||
assert.equal(await offersNote(main, "paused", "/plan2code-1b-revise-plan"), false, "Revise plan with a brief waiting");
|
||||
assert.equal(await offersNote(main, "ready", "/plan2code-3-implement"), false, "Implement never");
|
||||
assert.equal(await offersNote(main, "Start from scratch", "/plan2code-xray"), false, "a utility never");
|
||||
assert.equal(await offersNote(main, "Start from scratch", "/plan2code-diagnose"), true, "Diagnose on Start fresh");
|
||||
assert.equal(await offersNote(main, "ready", "/plan2code-diagnose"), true, "Diagnose on a picked spec");
|
||||
});
|
||||
|
||||
test("the switch lists the Notebook's tabs beside a preview: an empty tab grayed, five ticks at most, a Long tab note, and + note: on the command", async (t) => {
|
||||
|
||||
@@ -284,10 +284,140 @@ test("a stopped loop offers Ask a question, which tells the app and wakes no loo
|
||||
if (ask) ask.click();
|
||||
return { labels: buttons.map((b) => b.textContent), told: window.__told.map((x) => x.plan2code) };
|
||||
});
|
||||
assert.deepEqual(seen.labels, ["Ask a question", "Resume the loop", "Fix it by hand", "Back to the dashboard"]);
|
||||
assert.deepEqual(seen.labels, ["Ask a question", "Continue building", "Fix together with an agent", "Back to the dashboard"]);
|
||||
assert.deepEqual(seen.told, ["loop-ask"]);
|
||||
});
|
||||
|
||||
// Draws a stopped card in the page and reads what a person sees on it.
|
||||
async function drawStop(s, end) {
|
||||
return s.page.evaluate(async (end) => {
|
||||
const m = await import(new URL("screens/ending.js", document.baseURI).href);
|
||||
const card = m.renderLoopEnd(end);
|
||||
const choices = [...card.querySelectorAll(".loop-end-choice")];
|
||||
const details = card.querySelector("details.loop-end-details");
|
||||
return {
|
||||
heading: card.querySelector("h2").textContent,
|
||||
line: card.querySelector(".loop-line")?.textContent ?? null,
|
||||
safe: card.querySelector(".loop-end-safe")?.textContent ?? null,
|
||||
choices: choices.map((c) => ({ label: c.querySelector("button").textContent, primary: c.querySelector("button").classList.contains("primary"), hint: c.querySelector(".loop-end-hint").textContent })),
|
||||
details: details ? { open: details.open, summary: details.querySelector("summary").textContent, hasTable: Boolean(details.querySelector("table")), files: details.querySelectorAll("li").length } : null,
|
||||
tableOutside: Boolean(card.querySelector(":scope > table")),
|
||||
order: [...card.children].map((c) => c.className || c.tagName),
|
||||
};
|
||||
}, end);
|
||||
}
|
||||
|
||||
const HARD_STOP = {
|
||||
kind: "stopped",
|
||||
line: "Phase 3 stopped: 1 test outside this spec failed (test-web-console-shape.mjs: a raw locator.evaluate reads a style and the redraw replaced the card in between)",
|
||||
reason: "Phase 3 stopped on a problem the loop cannot fix by itself.",
|
||||
recommend: "fix",
|
||||
phase: 3,
|
||||
// Phase 4 is still to come: the button lines must name Phase 3, not the last row.
|
||||
phases: [{ n: 2, name: "API", commit: "abc1234", unfixed: 0, retries: 0 }, { n: 3, name: "Docs", commit: null, unfixed: 0, retries: 0 }, { n: 4, name: "Polish", commit: null, unfixed: 0, retries: 0 }],
|
||||
uncommitted: ["src/a.js", "src/b.js"],
|
||||
can: ["ask", "resume", "fix", "dashboard"],
|
||||
};
|
||||
|
||||
test("a stopped loop leads with its short reason and puts the long line under it", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
const seen = await drawStop(s, HARD_STOP);
|
||||
assert.equal(seen.heading, HARD_STOP.reason);
|
||||
assert.equal(seen.line, HARD_STOP.line, "the full line is still there, under the heading");
|
||||
const old = await drawStop(s, { ...HARD_STOP, reason: undefined, recommend: undefined });
|
||||
assert.equal(old.heading, HARD_STOP.line, "an older app without a reason keeps its line as the heading");
|
||||
});
|
||||
|
||||
test("every stop-screen button carries one plain line saying what it does", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
const seen = await drawStop(s, HARD_STOP);
|
||||
assert.deepEqual(
|
||||
seen.choices.map((c) => [c.label, c.hint]),
|
||||
[
|
||||
["Ask a question", "Wake an agent that answers your questions in the Ask tab. It changes nothing."],
|
||||
["Continue building", "Carry on unattended from Phase 3, the way the loop was running."],
|
||||
["Fix together with an agent", "Open a normal session on Phase 3 to fix this together with an agent."],
|
||||
["Back to the dashboard", "Leave this screen and pick another skill. Your work stays as it is."],
|
||||
],
|
||||
);
|
||||
const old = await drawStop(s, { ...HARD_STOP, phase: undefined });
|
||||
assert.equal(old.choices[1].hint, "Carry on unattended from where it stopped, the way the loop was running.", "an older app names no phase, and the line guesses none");
|
||||
const fin = await drawStop(s, { kind: "finished", line: "All 2 phases built", phases: [], uncommitted: [], can: ["finalize", "dashboard"] });
|
||||
assert.deepEqual(fin.choices.map((c) => c.hint), ["Write the feature's summary and move its spec to specs--completed/.", "Leave this screen and pick another skill. Your work stays as it is."]);
|
||||
assert.deepEqual(fin.choices.map((c) => c.primary), [true, false], "Finalize is the finish screen's one primary button");
|
||||
});
|
||||
|
||||
test("only the recommended button is primary: Fix together after a hard stop, Continue building after a soft one", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
const hard = await drawStop(s, HARD_STOP);
|
||||
assert.deepEqual(hard.choices.filter((c) => c.primary).map((c) => c.label), ["Fix together with an agent"]);
|
||||
const soft = await drawStop(s, { ...HARD_STOP, reason: "Phase 3 stopped because the agent crashed.", recommend: "resume" });
|
||||
assert.deepEqual(soft.choices.filter((c) => c.primary).map((c) => c.label), ["Continue building"]);
|
||||
const old = await drawStop(s, { ...HARD_STOP, recommend: undefined });
|
||||
assert.deepEqual(old.choices.filter((c) => c.primary).map((c) => c.label), ["Continue building"], "an older app's stop keeps Continue building as the one primary");
|
||||
});
|
||||
|
||||
test("a stop says nothing is lost and keeps the phases and files under a closed Details, below the buttons", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
const seen = await drawStop(s, HARD_STOP);
|
||||
assert.equal(seen.safe, "Nothing is lost. Your work stays on disk.");
|
||||
assert.deepEqual(seen.details, { open: false, summary: "Details: 3 phases, 2 uncommitted files", hasTable: true, files: 2 });
|
||||
assert.equal(seen.tableOutside, false, "no commit table between the reason and the buttons");
|
||||
const at = (cls) => seen.order.findIndex((c) => String(c).includes(cls));
|
||||
assert.ok(at("loop-end-safe") < at("loop-end-actions") && at("loop-end-actions") < at("loop-end-details"), seen.order.join(" > "));
|
||||
const fin = await drawStop(s, { kind: "finished", line: "All 1 phases built", phases: [{ n: 1, name: "API", commit: "abc1234", unfixed: 0, retries: 0 }], uncommitted: [], can: ["finalize", "dashboard"] });
|
||||
assert.equal(fin.safe, null, "the finish screen has nothing to reassure about");
|
||||
assert.equal(fin.details, null);
|
||||
assert.equal(fin.tableOutside, true, "the finish keeps its counts open");
|
||||
});
|
||||
|
||||
test("once the app starts the Ask agent, Ask a question opens the Ask tab and never asks the app twice", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
await frameInFakeApp(s);
|
||||
const seen = await s.page.evaluate(async (end) => {
|
||||
const m = await import(new URL("screens/ending.js", document.baseURI).href);
|
||||
const { page } = await import(new URL("state.js", document.baseURI).href);
|
||||
const askOf = (card) => [...card.querySelectorAll(".loop-end-choice")].find((c) => c.querySelector("button").textContent.includes("Ask"));
|
||||
const first = askOf(m.renderLoopEnd(end));
|
||||
first.querySelector("button").click();
|
||||
page.loopAction = { kind: "loop-ask-result", ok: true, error: null };
|
||||
const after = askOf(m.renderLoopEnd(end));
|
||||
const label = after.querySelector("button").textContent;
|
||||
const hint = after.querySelector(".loop-end-hint").textContent;
|
||||
after.querySelector("button").click();
|
||||
const view = page.view;
|
||||
page.view = "questions";
|
||||
page.loopAction = null;
|
||||
return { label, hint, view, told: window.__told.map((x) => x.plan2code) };
|
||||
}, HARD_STOP);
|
||||
assert.equal(seen.label, "Open the Ask tab");
|
||||
assert.equal(seen.hint, "The Ask agent is ready. Type your question in the Ask tab.");
|
||||
assert.equal(seen.view, "ask");
|
||||
assert.deepEqual(seen.told, ["loop-ask"], "the second press went to the Ask tab, not to the app");
|
||||
});
|
||||
|
||||
test("after Continue building replaces the Ask agent, the same stop again offers Ask a question afresh", async (t) => {
|
||||
const s = await openSetup(t);
|
||||
await frameInFakeApp(s);
|
||||
const seen = await s.page.evaluate(async (end) => {
|
||||
const m = await import(new URL("screens/ending.js", document.baseURI).href);
|
||||
const { page } = await import(new URL("state.js", document.baseURI).href);
|
||||
const button = (card, text) => [...card.querySelectorAll(".loop-end-choice button")].find((b) => b.textContent.includes(text));
|
||||
button(m.renderLoopEnd(end), "Ask").click();
|
||||
page.loopAction = { kind: "loop-ask-result", ok: true, error: null };
|
||||
const asked = button(m.renderLoopEnd(end), "Ask").textContent;
|
||||
button(m.renderLoopEnd(end), "Continue building").click();
|
||||
page.loopAction = { kind: "loop-resume-result", ok: true, error: null };
|
||||
// The loop ran and stopped again, the same way.
|
||||
const again = button(m.renderLoopEnd(end), "Ask").textContent;
|
||||
page.loopAction = null;
|
||||
return { asked, again, told: window.__told.map((x) => x.plan2code) };
|
||||
}, HARD_STOP);
|
||||
assert.equal(seen.asked, "Open the Ask tab");
|
||||
assert.equal(seen.again, "Ask a question", "no Ask agent is left to open");
|
||||
assert.deepEqual(seen.told, ["loop-ask", "loop-resume"]);
|
||||
});
|
||||
|
||||
// A real loop session: `open --loop` under the app's signal stamps the lock.
|
||||
async function openLoopPage(t) {
|
||||
return openSession(await suite.browser(), {
|
||||
@@ -353,7 +483,7 @@ test("a finished loop and a stop with no Ask keep the notes panel's old words",
|
||||
assert.ok(!aside.text.includes(ASK_HINT), "a finished loop does not offer Ask");
|
||||
assert.match(aside.text, /Nothing was said about this one/);
|
||||
s.post({ loopEnd: { ...STOPPED, can: ["resume", "fix", "dashboard"] } });
|
||||
await s.page.getByRole("button", { name: "Resume the loop" }).waitFor();
|
||||
await s.page.getByRole("button", { name: "Continue building" }).waitFor();
|
||||
aside = await asideOf(s);
|
||||
assert.ok(!aside.text.includes(ASK_HINT), "no Ask button, so no hint to press it");
|
||||
assert.match(aside.text, /Nothing was said about this one/);
|
||||
@@ -492,6 +622,75 @@ test("turning it on shows one row per phase left with the model each pick become
|
||||
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["", ""], "Match my session fills every row too");
|
||||
});
|
||||
|
||||
test("the arrow keys move the checked radio inside a row, and only that row", async (t) => {
|
||||
const s = await openStrengthSetup(t);
|
||||
await s.page.locator("#loop-phase-strength").check();
|
||||
await s.page.locator(".loop-strength-row").first().waitFor();
|
||||
// Focus once: every change redraws the section, and the page must put focus back on the new radio by itself.
|
||||
await s.page.locator("#loop-strength-1-match").focus();
|
||||
await s.page.keyboard.press("ArrowRight");
|
||||
await s.page.locator("#loop-strength-1-thrifty:checked").waitFor({ state: "attached" });
|
||||
await s.page.keyboard.press("ArrowRight");
|
||||
await s.page.locator("#loop-strength-1-balanced:checked").waitFor({ state: "attached" });
|
||||
await s.page.keyboard.press("ArrowLeft");
|
||||
await s.page.locator("#loop-strength-1-thrifty:checked").waitFor({ state: "attached" });
|
||||
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["thrifty", ""], "the other row did not move");
|
||||
});
|
||||
|
||||
// The step path starts on the first row's checked node and ends on the last one's, within a pixel;
|
||||
// a corner (Q) only when the two nodes sit in different columns. Waits, then asserts, so a redraw cannot race it.
|
||||
async function waitLineOnNodes(s, corner) {
|
||||
const read = () =>
|
||||
s.page.evaluate(() => {
|
||||
const grid = document.querySelector(".loop-strength-grid");
|
||||
const gr = grid.getBoundingClientRect();
|
||||
const nodes = [...grid.querySelectorAll(".loop-strength-row input:checked + .loop-strength-node")];
|
||||
const centers = nodes.map((n) => {
|
||||
const b = n.getBoundingClientRect();
|
||||
return { x: b.left - gr.left + b.width / 2, y: b.top - gr.top + b.height / 2 };
|
||||
});
|
||||
const d = grid.querySelector(".loop-strength-line path.step")?.getAttribute("d") || "";
|
||||
const nums = (d.match(/-?\d+(?:\.\d+)?/g) || []).map(Number);
|
||||
return { d, centers, nums };
|
||||
});
|
||||
const onNodes = ({ d, centers, nums }) =>
|
||||
centers.length === 2 &&
|
||||
nums.length >= 3 &&
|
||||
d.includes("Q") === corner &&
|
||||
Math.abs(nums[0] - centers[0].x) <= 1 &&
|
||||
Math.abs(nums[1] - centers[0].y) <= 1 &&
|
||||
Math.abs(nums[nums.length - 3] - centers[1].x) <= 1 &&
|
||||
Math.abs(nums[nums.length - 1] - centers[1].y) <= 1;
|
||||
const deadline = Date.now() + 5000;
|
||||
let got = await read();
|
||||
while (!onNodes(got) && Date.now() < deadline) {
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
got = await read();
|
||||
}
|
||||
assert.ok(onNodes(got), `the step path should run node to node (corner: ${corner}); got ${JSON.stringify(got)}`);
|
||||
}
|
||||
|
||||
test("the strength line has one path fewer than there are rows, and none with the toggle off", async (t) => {
|
||||
const s = await openStrengthSetup(t);
|
||||
const paths = s.page.locator(".loop-strength-line path.step");
|
||||
assert.equal(await paths.count(), 0, "no line while the toggle is off");
|
||||
await s.page.locator("#loop-phase-strength").check();
|
||||
await s.page.locator(".loop-strength-row").first().waitFor();
|
||||
// The line is drawn a frame after the rows exist: wait for it, never read straight after a click.
|
||||
await s.page.waitForFunction(() => document.querySelectorAll(".loop-strength-line path.step").length === 1);
|
||||
assert.equal(await s.page.locator(".loop-strength-row").count(), 2);
|
||||
assert.equal(await paths.count(), 1, "two rows, one path between them");
|
||||
assert.equal(await s.page.locator(".loop-strength-line line.col").count(), 4, "a dashed column line per strength, Match my session included");
|
||||
|
||||
// Both rows start on Match my session: one column, so a straight path with no corner.
|
||||
await waitLineOnNodes(s, false);
|
||||
await pickStrength(s, 2, "best");
|
||||
await waitLineOnNodes(s, true);
|
||||
await s.page.locator("#loop-phase-strength").uncheck();
|
||||
await s.page.locator(".loop-strength-row").first().waitFor({ state: "detached" });
|
||||
assert.equal(await paths.count(), 0, "the toggle off draws no line");
|
||||
});
|
||||
|
||||
test("an agent with nothing mapped grays the section and links to Agents & models", async (t) => {
|
||||
const s = await openStrengthSetup(t, { ...LAUNCH, agent: "codex", agentLabel: "Codex" });
|
||||
const note = s.page.locator(".loop-strength-none");
|
||||
|
||||
@@ -942,3 +942,163 @@ test("the Subagents dialog looks as it did before Preferences moved to tabs", as
|
||||
if (process.env.P2C_PRINT_SUBAGENTS) console.log("SUBAGENTS " + JSON.stringify(got));
|
||||
assert.deepEqual(got, SUBAGENTS_BEFORE);
|
||||
});
|
||||
|
||||
// The sound picker: a select of the 19 files and a play button for each of the
|
||||
// seven pickable cues, Planny's snoring and waking keeping plain boxes.
|
||||
const PICK_EVENTS = ["startSkill", "sessionStart", "skillReady", "sessionEnd", "question", "chatReply", "newTab"];
|
||||
const PICK_DEFAULTS = {
|
||||
startSkill: "sound-14",
|
||||
sessionStart: "sound-07",
|
||||
skillReady: "sound-16",
|
||||
sessionEnd: "sound-15",
|
||||
question: "sound-14",
|
||||
chatReply: "sound-06",
|
||||
newTab: "sound-05",
|
||||
};
|
||||
const pickSelect = (s, event) => s.page.locator(`select[data-sound-file="${event}"]`);
|
||||
|
||||
async function openSoundsTab(s) {
|
||||
await s.page.click("#btn-looks");
|
||||
await s.page.click("#prefs-tab-sounds");
|
||||
// Wait for the dialog to hold every row before acting on one.
|
||||
await s.page.waitForFunction((n) => document.querySelectorAll("select[data-sound-file]").length === n, PICK_EVENTS.length);
|
||||
}
|
||||
|
||||
// Counts the files the page asks to play, without making a sound. Installed
|
||||
// before the page loads (then reloaded), so a cue the session itself plays
|
||||
// never really plays: a preview is dropped while a higher-ranked cue is
|
||||
// audible, and an audible one would hide the click under test.
|
||||
async function stubPlay(s) {
|
||||
await s.page.addInitScript(() => {
|
||||
window.__played = [];
|
||||
HTMLMediaElement.prototype.play = function () {
|
||||
window.__played.push(this.src);
|
||||
return Promise.resolve();
|
||||
};
|
||||
});
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
}
|
||||
const played = (s) => s.page.evaluate(() => window.__played);
|
||||
|
||||
test("the sound picker: seven cues have a select of 19 sounds on their default, snoring and waking have none", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openSoundsTab(s);
|
||||
for (const event of PICK_EVENTS) {
|
||||
assert.equal(await pickSelect(s, event).locator("option").count(), 19, `${event} lists 19 sounds`);
|
||||
assert.equal(await pickSelect(s, event).inputValue(), PICK_DEFAULTS[event], `${event} starts on its default`);
|
||||
assert.equal(await s.page.locator(`[data-sound-play="${event}"]`).count(), 1, `${event} has a play button`);
|
||||
}
|
||||
for (const event of ["snore", "bootup"]) {
|
||||
assert.equal(await s.page.locator(`[data-sound="${event}"]`).count(), 1, `${event} keeps its box`);
|
||||
assert.equal(await s.page.locator(`[data-sound-file="${event}"], [data-sound-play="${event}"]`).count(), 0, `${event} has no picker`);
|
||||
}
|
||||
});
|
||||
|
||||
test("the sound picker: a pick plays once and persists across a reload, and Play replays it even with the cue unticked", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await stubPlay(s);
|
||||
await openSoundsTab(s);
|
||||
await s.page.evaluate(() => (window.__played.length = 0));
|
||||
await pickSelect(s, "question").selectOption("sound-07");
|
||||
await s.page.waitForFunction(() => window.__played.length === 1);
|
||||
assert.match((await played(s))[0], /\/sounds\/sound-07\.mp3$/, "the pick played");
|
||||
await s.page.waitForFunction(async () => ((await (await fetch("/looks")).json()).looks || {}).soundFileQuestion === "sound-07");
|
||||
|
||||
await s.page.locator('[data-sound="question"]').uncheck();
|
||||
await s.page.locator('[data-sound-play="question"]').click();
|
||||
await s.page.waitForFunction(() => window.__played.length === 2);
|
||||
assert.match((await played(s))[1], /\/sounds\/sound-07\.mp3$/, "Play replays the pick with the cue unticked");
|
||||
|
||||
await s.page.click("#looks-done");
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
await openSoundsTab(s);
|
||||
assert.equal(await pickSelect(s, "question").inputValue(), "sound-07", "the pick did not survive a reload");
|
||||
assert.equal(await pickSelect(s, "newTab").inputValue(), "sound-05", "an untouched cue kept its default");
|
||||
});
|
||||
|
||||
test("the sound picker: Play sounds off disables the selects and play buttons, and Back to default restores the defaults", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await openSoundsTab(s);
|
||||
await pickSelect(s, "newTab").selectOption("sound-15");
|
||||
await s.page.waitForFunction(async () => ((await (await fetch("/looks")).json()).looks || {}).soundFileNewTab === "sound-15");
|
||||
|
||||
await s.page.locator("#looks-sound").uncheck();
|
||||
for (const event of PICK_EVENTS) {
|
||||
assert.equal(await pickSelect(s, event).isDisabled(), true, `${event}'s select is disabled`);
|
||||
assert.equal(await s.page.locator(`[data-sound-play="${event}"]`).isDisabled(), true, `${event}'s play button is disabled`);
|
||||
}
|
||||
assert.equal(await pickSelect(s, "newTab").inputValue(), "sound-15", "the pick is kept while sounds are off");
|
||||
assert.equal(Number(await styleOf(s.page.locator("#looks-sound-events"), "opacity")) < 1, true, "the rows are dimmed");
|
||||
|
||||
await s.page.locator("#looks-sound").check();
|
||||
assert.equal(await pickSelect(s, "newTab").isDisabled(), false, "switching sounds on enables the select again");
|
||||
|
||||
await s.page.click("#looks-reset");
|
||||
await s.page.waitForFunction(() => document.querySelector('select[data-sound-file="newTab"]').value === "sound-05");
|
||||
for (const event of PICK_EVENTS) {
|
||||
assert.equal(await pickSelect(s, event).inputValue(), PICK_DEFAULTS[event], `${event} is back on its default`);
|
||||
}
|
||||
await s.page.waitForFunction(async () => ((await (await fetch("/looks")).json()).looks || {}).soundFileNewTab !== "sound-15");
|
||||
});
|
||||
|
||||
test("the sound picker: a preview is dropped behind a ranked cue that is still playing, and plays once it has stopped", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
// A stub whose Audio reports itself playing until the test says otherwise.
|
||||
await s.page.addInitScript(() => {
|
||||
window.__played = [];
|
||||
window.__audible = true;
|
||||
HTMLMediaElement.prototype.play = function () {
|
||||
window.__played.push(this.src);
|
||||
Object.defineProperty(this, "paused", { configurable: true, get: () => !window.__audible });
|
||||
return Promise.resolve();
|
||||
};
|
||||
});
|
||||
await s.page.reload({ waitUntil: "domcontentloaded" });
|
||||
await drawn(s.page);
|
||||
await openSoundsTab(s);
|
||||
// Let the cues the session itself played settle, then start a ranked one.
|
||||
await s.page.evaluate(async () => {
|
||||
window.__audible = false;
|
||||
const { sound } = await import("/sound.js");
|
||||
window.__played.length = 0;
|
||||
sound("question");
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
window.__audible = true;
|
||||
});
|
||||
await s.page.waitForFunction(() => window.__played.length === 1);
|
||||
await s.page.locator('[data-sound-play="newTab"]').click();
|
||||
assert.equal((await played(s)).length, 1, "the preview was dropped behind the audible cue");
|
||||
|
||||
await s.page.evaluate(() => (window.__audible = false));
|
||||
await s.page.locator('[data-sound-play="newTab"]').click();
|
||||
await s.page.waitForFunction(() => window.__played.length === 2);
|
||||
assert.match((await played(s))[1], /\/sounds\/sound-05\.mp3$/, "the preview played once the cue had stopped");
|
||||
});
|
||||
|
||||
test("the sound picker: Tab reaches Play from the select, and a row stacks inside the dialog at a narrow width", async (t) => {
|
||||
noSavedLooks(t);
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.setViewportSize({ width: 600, height: 900 });
|
||||
await openSoundsTab(s);
|
||||
await pickSelect(s, "question").focus();
|
||||
await s.page.keyboard.press("Tab");
|
||||
assert.equal(await s.page.evaluate(() => document.activeElement?.dataset.soundPlay), "question", "Tab from the select lands on its Play button");
|
||||
|
||||
const fits = await s.page.evaluate(() => {
|
||||
const box = document.getElementById("looks-modal").getBoundingClientRect();
|
||||
return [...document.querySelectorAll(".sound-row")].map((row) =>
|
||||
[...row.querySelectorAll("label, select, button")].every((n) => {
|
||||
const r = n.getBoundingClientRect();
|
||||
return r.left >= box.left - 1 && r.right <= box.right + 1;
|
||||
})
|
||||
);
|
||||
});
|
||||
assert.equal(fits.length, PICK_EVENTS.length, "every row is drawn");
|
||||
assert.equal(fits.every(Boolean), true, "no control spills out of the dialog at 600px");
|
||||
});
|
||||
@@ -1042,6 +1042,55 @@ test("Before you close this shows while a review is on offer, goes while it is a
|
||||
assert.equal(await closeGuide(s).count(), 0, "the guide came back on a reload");
|
||||
});
|
||||
|
||||
// What a person sees break: Commit, Changelog and Dashboard dead on the finish after a review, because the agent posted the new finish without clearing the old one.
|
||||
test("a different finish posted over a pressed Review starts with its own buttons live", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "quick-task", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
s.post({ finish: OFFERS });
|
||||
const main = s.page.locator("#main");
|
||||
await main.getByRole("button", { name: "Review it now" }).click();
|
||||
await main.getByRole("button", { name: "Review requested…" }).waitFor();
|
||||
collect(s);
|
||||
s.post({ finish: { ...OFFERS, headline: "The review is done", review: false } });
|
||||
await main.getByRole("heading", { name: "The review is done" }).waitFor();
|
||||
await s.page.waitForFunction(() => {
|
||||
const b = [...document.querySelectorAll("#main button")].find((x) => x.textContent.trim() === "Commit it now");
|
||||
return b && !b.disabled;
|
||||
});
|
||||
assert.equal(await main.getByRole("button", { name: "Commit it now" }).isEnabled(), true, "Commit stayed dead after the new finish");
|
||||
});
|
||||
|
||||
// What a person sees break: a finish screen whose every button is disabled while nothing answers them, with no way off the page but a toolbar button, and a footer pointing at buttons that do nothing.
|
||||
const STRANDED_FINISH = { ...OFFERS, command: 'git commit -m "Fix it"' };
|
||||
async function strandedFinish(t, opts) {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "quick-task", clock: true, ...opts, payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
|
||||
s.post({ finish: STRANDED_FINISH });
|
||||
const main = s.page.locator("#main");
|
||||
await main.getByRole("button", { name: "Review it now" }).click();
|
||||
await main.getByRole("button", { name: "Review requested…" }).waitFor();
|
||||
await s.page.clock.fastForward(200_000);
|
||||
await s.page.waitForFunction(() => document.body.innerText.includes("Plan2Code is not running"));
|
||||
return { s, main };
|
||||
}
|
||||
|
||||
test("a finish press nothing collects offers Start a New Session under the app, which asks the app for one", async (t) => {
|
||||
const { s, main } = await strandedFinish(t, { env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
|
||||
const press = main.getByRole("button", { name: "Start a New Session" });
|
||||
assert.equal(await press.isEnabled(), true, "the escape hatch must not be disabled");
|
||||
assert.equal(await closeGuide(s).count(), 1, "the guide stays while the press is stranded");
|
||||
const foot = await textOf(s.page.locator("#footer-summary"));
|
||||
assert.doesNotMatch(foot, /next step is above/i);
|
||||
assert.match(foot, /New Session/);
|
||||
await press.click();
|
||||
await until(async () => (await toApp(s, "new-session")).length === 1, 5000);
|
||||
});
|
||||
|
||||
test("a finish press nothing collects shows the dashboard command in a browser, with no button", async (t) => {
|
||||
const { s, main } = await strandedFinish(t, {});
|
||||
assert.equal(await main.getByRole("button", { name: "Start a New Session" }).count(), 0);
|
||||
assert.match(await textOf(main), /\/plan2code\b/);
|
||||
assert.doesNotMatch(await textOf(s.page.locator("#footer-summary")), /next step is above/i);
|
||||
});
|
||||
|
||||
// What a person sees break: the guide missing while a commit or the dashboard
|
||||
// is starting (it would say "start a new one" under "Opening Git"), or missing
|
||||
// once they said they are done or the server is gone.
|
||||
|
||||
@@ -156,6 +156,161 @@ test("a finish patch is exempt from the unanswered-note check", () => {
|
||||
assert.deepEqual(validate(next), []);
|
||||
});
|
||||
|
||||
/* ------------------------------------------------- a note on a question */
|
||||
|
||||
const guardNoted = () => ({
|
||||
...choice("guard"),
|
||||
thread: [{ who: "user", text: "Why this option?" }],
|
||||
noted: true,
|
||||
});
|
||||
const plan = (items) => ({ ...blankState({ sid: "x", project: "p", workflow: "plan" }), items });
|
||||
const notedAfter = (patch, item = guardNoted()) => applyPatch(plan([item]), patch).items.find((i) => i.id === "guard");
|
||||
|
||||
// The reported session: a note lands on an open question, the agent replies in
|
||||
// its thread and asks the next question in the same patch, and the page buries
|
||||
// the new one while the person is still typing. The console refuses the patch
|
||||
// and names the fix.
|
||||
const NOTED_REFUSAL =
|
||||
'item "guard" noted: has a note from the person that you answered in the thread: reword it, delete it ("_delete": true) or send "stands": true, in the same patch that adds a new question. Like this: {"id":"guard","stands":true}';
|
||||
const guardReply = { id: "guard", thread: [{ who: "agent", text: "Because it matches the brief." }] };
|
||||
const refusedPast = (state, patch) => assert.throws(() => applyPatch(state, patch), (e) => e.message === NOTED_REFUSAL);
|
||||
const passesPast = (state, patch) => {
|
||||
const next = applyPatch(state, patch);
|
||||
assert.deepEqual(validate(next), []);
|
||||
return next;
|
||||
};
|
||||
|
||||
test("a reply in the thread of a noted question, with a new question in the same patch, is refused", () => {
|
||||
const state = plan([choice("guard")]);
|
||||
state.items[0].noted = true; // the way the server sets it when the note lands
|
||||
refusedPast(state, { items: [guardReply, choice("build")] });
|
||||
});
|
||||
|
||||
test("the refusal names every noted question still standing, and only those", () => {
|
||||
const state = plan([guardNoted(), { ...guardNoted(), id: "other" }]);
|
||||
assert.throws(
|
||||
() => applyPatch(state, { items: [guardReply, { id: "other", stands: true, thread: [{ who: "agent", text: "Still right." }] }, choice("build")] }),
|
||||
(e) => e.message === NOTED_REFUSAL,
|
||||
);
|
||||
});
|
||||
|
||||
test("a reply alone on a noted question passes and keeps it noted: only a new question is refused", () => {
|
||||
const next = passesPast(plan([guardNoted()]), { items: [guardReply] });
|
||||
assert.equal(next.items[0].noted, true);
|
||||
});
|
||||
|
||||
test("a later patch that adds a new question past a still-noted card is refused", () => {
|
||||
const replied = applyPatch(plan([guardNoted()]), { items: [guardReply] });
|
||||
refusedPast(replied, { items: [choice("build")] });
|
||||
});
|
||||
|
||||
test('"stands": true on the noted question lets a new question through', () => {
|
||||
const next = passesPast(plan([guardNoted()]), { items: [{ ...guardReply, stands: true }, choice("build")] });
|
||||
assert.equal("noted" in next.items[0], false);
|
||||
});
|
||||
|
||||
test("rewording the noted question lets a new question through", () => {
|
||||
passesPast(plan([guardNoted()]), { items: [{ ...guardReply, body: "Which option fits the brief?" }, choice("build")] });
|
||||
});
|
||||
|
||||
test("deleting the noted question in the same patch lets a new question through", () => {
|
||||
const next = passesPast(plan([guardNoted()]), { items: [{ id: "guard", _delete: true }, choice("build")] });
|
||||
assert.deepEqual(next.items.map((i) => i.id), ["build"]);
|
||||
});
|
||||
|
||||
test("settling the noted question in the same patch lets a new question through", () => {
|
||||
passesPast(plan([guardNoted()]), { items: [{ ...guardReply, status: "answered", answer: { k: "A" } }, choice("build")] });
|
||||
});
|
||||
|
||||
test("an answered or skipped card that still carries noted holds nothing up", () => {
|
||||
for (const status of ["answered", "skipped"]) {
|
||||
passesPast(plan([{ ...guardNoted(), thread: [], status }]), { items: [choice("build")] });
|
||||
}
|
||||
});
|
||||
|
||||
test("an optional question or a notice may follow a noted card", () => {
|
||||
passesPast(plan([guardNoted()]), { items: [guardReply, choice("maybe", { required: false })] });
|
||||
passesPast(plan([guardNoted()]), { items: [guardReply, { id: "fyi", kind: "notice", title: "Heads up" }] });
|
||||
});
|
||||
|
||||
test("a patch that posts a finish is not held to the noted rule", () => {
|
||||
const finish = { headline: "Paused at the guard question", body: "Picked up later." };
|
||||
assert.doesNotThrow(() => applyPatch(plan([guardNoted()]), { items: [guardReply, choice("build")], finish }));
|
||||
});
|
||||
|
||||
test("the dashboard is not held to the noted rule (it draws no cards at all)", () => {
|
||||
const state = { ...blankState({ sid: "x", project: "p", workflow: "dashboard" }), items: [guardNoted()] };
|
||||
assert.doesNotThrow(() => applyPatch(state, { items: [guardReply, choice("build")] }));
|
||||
});
|
||||
|
||||
test("a noted card whose note is not yet replied to is refused for both, in one message", () => {
|
||||
assert.throws(
|
||||
() => applyPatch(plan([guardNoted()]), { items: [choice("build")] }),
|
||||
(e) =>
|
||||
e.message ===
|
||||
'item "guard" thread: has an unanswered note from the person; reply in its thread in this patch. Like this: {"id":"guard","thread":[{"who":"agent","text":"..."}]}\n' +
|
||||
NOTED_REFUSAL,
|
||||
);
|
||||
});
|
||||
|
||||
test("a top-level settle clears noted, so reopening the card later holds nothing up", () => {
|
||||
for (const settle of [true, ["guard"]]) {
|
||||
const sent = { ...guardNoted(), thread: [...guardNoted().thread, guardReply.thread[0]], submitted: { at: "2026-11-09T08:00:00.000Z", k: "A" } };
|
||||
const settled = applyPatch(plan([sent]), { settle });
|
||||
assert.equal(settled.items[0].status, "answered");
|
||||
assert.equal("noted" in settled.items[0], false);
|
||||
passesPast(settled, { items: [{ id: "guard", status: "reopened" }, choice("build")] });
|
||||
}
|
||||
});
|
||||
|
||||
test("one patch may settle an answered noted card and ask the next question", () => {
|
||||
const sent = { ...guardNoted(), thread: [...guardNoted().thread, guardReply.thread[0]], submitted: { at: "2026-11-09T08:00:00.000Z", k: "A" } };
|
||||
passesPast(plan([sent]), { settle: true, items: [choice("build")] });
|
||||
});
|
||||
|
||||
test("a reworded body clears noted", () => {
|
||||
assert.equal("noted" in notedAfter({ items: [{ id: "guard", body: "A different question." }] }), false);
|
||||
});
|
||||
|
||||
test("changed options clear noted", () => {
|
||||
const options = [{ k: "A", text: "Only this" }];
|
||||
assert.equal("noted" in notedAfter({ items: [{ id: "guard", options }] }), false);
|
||||
});
|
||||
|
||||
test("a reply that leaves the question alone keeps noted", () => {
|
||||
const item = notedAfter({ items: [{ id: "guard", thread: [{ who: "agent", text: "Seen." }] }] });
|
||||
assert.equal(item.noted, true);
|
||||
});
|
||||
|
||||
test("a patch that repeats the same body keeps noted", () => {
|
||||
assert.equal(notedAfter({ items: [{ id: "guard", body: guardNoted().body }] }).noted, true);
|
||||
});
|
||||
|
||||
test("deleting a noted question removes it with its flag", () => {
|
||||
assert.deepEqual(applyPatch(plan([guardNoted()]), { items: [{ id: "guard", _delete: true }] }).items, []);
|
||||
});
|
||||
|
||||
test("settling a noted question clears noted", () => {
|
||||
assert.equal("noted" in notedAfter({ items: [{ id: "guard", status: "answered" }] }), false);
|
||||
assert.equal("noted" in notedAfter({ items: [{ id: "guard", status: "skipped" }] }), false);
|
||||
assert.equal("noted" in notedAfter({ items: [{ id: "guard", answer: { k: "A" } }] }), false);
|
||||
});
|
||||
|
||||
test("stands: true clears noted and is never stored; a non-boolean stands is refused", () => {
|
||||
const item = notedAfter({ items: [{ id: "guard", stands: true }] });
|
||||
assert.equal("noted" in item, false);
|
||||
assert.equal("stands" in item, false);
|
||||
const kept = notedAfter({ items: [{ id: "guard", stands: false }] });
|
||||
assert.equal(kept.noted, true, "stands: false clears nothing");
|
||||
assert.equal("stands" in kept, false);
|
||||
assert.throws(() => applyPatch(plan([guardNoted()]), { items: [{ id: "guard", stands: "yes" }] }), /stands/);
|
||||
});
|
||||
|
||||
test("stands on a new question is dropped, not stored", () => {
|
||||
const next = applyPatch(plan([]), { items: [{ ...choice("fresh"), stands: true }] });
|
||||
assert.equal("stands" in next.items[0], false);
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------- the CLI */
|
||||
|
||||
test("post --file reads a patch PowerShell wrote: a UTF-8 BOM, or UTF-16", () => {
|
||||
|
||||
@@ -365,6 +365,7 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
file("looks.json"),
|
||||
file("workspaces.json"),
|
||||
file("loop-setup.json"),
|
||||
file("spec-carry.json"),
|
||||
file("loop-reports.json"),
|
||||
file("subagents.json"),
|
||||
file("pr-hosts.json"),
|
||||
@@ -381,7 +382,7 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
const stale = staleScratch(dir, Date.now(), SESSION_MAX_AGE_MS).sort();
|
||||
assert.deepEqual(stale, ["helper.mjs", "p2.json"]);
|
||||
assert.deepEqual(
|
||||
(await removeScratch(dir, [...stale, "looks.json", "workspaces.json", "loop-setup.json", "loop-reports.json", "subagents.json", "pr-hosts.json", "../p.json", "console-dir", "update-check.json"])).sort(),
|
||||
(await removeScratch(dir, [...stale, "looks.json", "workspaces.json", "loop-setup.json", "loop-reports.json", "subagents.json", "spec-carry.json", "pr-hosts.json", "../p.json", "console-dir", "update-check.json"])).sort(),
|
||||
["helper.mjs", "p2.json"]
|
||||
);
|
||||
for (const p of removable) assert.equal(fs.existsSync(p), false, p);
|
||||
@@ -392,6 +393,7 @@ test("the scratch sweep removes old patches and helpers, never looks, the pointe
|
||||
"loop-reports.json",
|
||||
"loop-setup.json",
|
||||
"pr-hosts.json",
|
||||
"spec-carry.json",
|
||||
"subagents.json",
|
||||
"update-check.json",
|
||||
"workspaces.json",
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
turnGate,
|
||||
} from "../src/web-console/public/answers.js";
|
||||
import { CHAT_LIMIT, CHAT_MAX_CHARS } from "../src/web-console/public/chat.js";
|
||||
import { ACCENTS, CARD_WIDTHS, SOUND_EVENTS, soundKey, soundPrefs } from "../src/web-console/public/palette.js";
|
||||
import { ACCENTS, CARD_WIDTHS, SOUND_EVENTS, soundKey, soundPrefs, SOUND_FILES, PICKABLE_SOUNDS, DEFAULT_SOUND_FILE, soundFileKey, soundFilePrefs } from "../src/web-console/public/palette.js";
|
||||
import { HELP_TABS, helpTabFor, helpKeyTarget } from "../src/web-console/public/help.js";
|
||||
import { tabKeyTarget } from "../src/web-console/public/tabs.js";
|
||||
import { PREFS_TABS, prefsOpenTab, prefsResetScope } from "../src/web-console/public/prefs.js";
|
||||
@@ -602,7 +602,8 @@ test("boot.js is served as JavaScript and imports without a DOM", async () => {
|
||||
// nobody adds serves 404 and the sound just never plays, so assert every file
|
||||
// the page asks for comes back as audio.
|
||||
test("the chime files are served as audio", async () => {
|
||||
for (const f of ["start-stop.mp3", "next.mp3", "insert.mp3", "sleeping.mp3", "bootup.mp3", "start-skill.mp3"]) {
|
||||
const sounds = Array.from({ length: 19 }, (_, i) => `sounds/sound-${String(i + 1).padStart(2, "0")}.mp3`);
|
||||
for (const f of [...sounds, "sleeping.mp3", "bootup.mp3"]) {
|
||||
const res = await fetch(`${baseUrl}/${f}`, { headers: { cookie: cookieFor(baseUrl, token) } });
|
||||
assert.equal(res.status, 200, `${f} is played but the server will not serve it`);
|
||||
assert.match(res.headers.get("content-type"), /^audio\//);
|
||||
@@ -613,7 +614,7 @@ test("the chime files are served as audio", async () => {
|
||||
// names a real event, and every event's file is served. A box with no event
|
||||
// saves a setting nothing reads; an event with no box can never be muted.
|
||||
test("every sound event has a preference box and a served file", async () => {
|
||||
assert.equal(SOUND_EVENTS.startSkill.file, "start-skill", "starting a skill has its own sound");
|
||||
assert.equal(SOUND_EVENTS.startSkill.file, "sounds/sound-14", "starting a skill has its own default sound");
|
||||
const html = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "index.html"), "utf8");
|
||||
const boxes = [...html.matchAll(/data-sound="(\w+)"/g)].map((m) => m[1]);
|
||||
assert.deepEqual([...boxes].sort(), Object.keys(SOUND_EVENTS).sort());
|
||||
@@ -642,6 +643,31 @@ test("soundPrefs: missing switches are on, saved booleans hold, anything else is
|
||||
assert.ok(!("extra" in prefs), "only the sound switches come back");
|
||||
});
|
||||
|
||||
// The picked file per cue: a looks.json from before the picker, an unknown
|
||||
// name or a non-string gets the cue's default; a valid name holds.
|
||||
test("soundFilePrefs: defaults for anything not a known file, a valid pick holds", () => {
|
||||
assert.equal(soundFileKey("startSkill"), "soundFileStartSkill");
|
||||
assert.equal(SOUND_FILES.length, 19);
|
||||
const keys = PICKABLE_SOUNDS.map(soundFileKey).sort();
|
||||
const defaults = Object.fromEntries(PICKABLE_SOUNDS.map((e) => [soundFileKey(e), DEFAULT_SOUND_FILE[e]]));
|
||||
for (const saved of [null, undefined, {}, { soundFileQuestion: "sound-99" }, { soundFileQuestion: 7 }, { soundFileQuestion: null }]) {
|
||||
const prefs = soundFilePrefs(saved);
|
||||
assert.deepEqual(Object.keys(prefs).sort(), keys);
|
||||
assert.deepEqual(prefs, defaults, `defaults for ${JSON.stringify(saved)}`);
|
||||
}
|
||||
const prefs = soundFilePrefs({ soundFileQuestion: "sound-07", soundFileNewTab: "bootup", extra: "sound-01" });
|
||||
assert.equal(prefs.soundFileQuestion, "sound-07");
|
||||
assert.equal(prefs.soundFileNewTab, DEFAULT_SOUND_FILE.newTab);
|
||||
assert.ok(!("extra" in prefs));
|
||||
});
|
||||
|
||||
test("every default sound file is a known file, and the pickable cues are the seven", () => {
|
||||
for (const file of Object.values(DEFAULT_SOUND_FILE)) assert.ok(SOUND_FILES.includes(file), file);
|
||||
assert.deepEqual(PICKABLE_SOUNDS, ["startSkill", "sessionStart", "skillReady", "sessionEnd", "question", "chatReply", "newTab"]);
|
||||
assert.ok(!PICKABLE_SOUNDS.includes("snore") && !PICKABLE_SOUNDS.includes("bootup"));
|
||||
for (const event of PICKABLE_SOUNDS) assert.equal(SOUND_EVENTS[event].file, `sounds/${DEFAULT_SOUND_FILE[event]}`);
|
||||
});
|
||||
|
||||
// The favicon rides the same allow-list, so a missing entry is a silent 404
|
||||
// and the tab falls back to a blank icon.
|
||||
test("the favicon is served as an SVG with a PNG fallback and the page points at both", async () => {
|
||||
@@ -827,7 +853,7 @@ test("prefs: four tabs in order, each section in exactly one", () => {
|
||||
for (const t of PREFS_TABS) assert.ok(t.hint, `${t.id} has a hint`);
|
||||
const sections = PREFS_TABS.flatMap((t) => t.sections);
|
||||
assert.equal(new Set(sections).size, sections.length, "no section sits in two tabs");
|
||||
assert.deepEqual(PREFS_TABS[0].sections, ["theme", "width", "accent", "role"], "Appearance in its order");
|
||||
assert.deepEqual(PREFS_TABS[0].sections, ["theme", "width", "accent", "role", "intro"], "Appearance in its order");
|
||||
});
|
||||
|
||||
test("prefs: the dialog opens on the tab asked for, else Appearance", () => {
|
||||
@@ -836,9 +862,9 @@ test("prefs: the dialog opens on the tab asked for, else Appearance", () => {
|
||||
});
|
||||
|
||||
test("prefs: Back to default resets Appearance or Sounds & activities only, and nothing on the other two", () => {
|
||||
assert.deepEqual(prefsResetScope("appearance"), ["theme", "width", "accent", "role"]);
|
||||
assert.deepEqual(prefsResetScope("appearance"), ["theme", "width", "accent", "role", "skipIntro"]);
|
||||
const sounds = prefsResetScope("sounds");
|
||||
assert.deepEqual(sounds, ["sound", ...Object.keys(SOUND_EVENTS).map(soundKey), "hideActivities", "activitySounds", "gameMusic"]);
|
||||
assert.deepEqual(sounds, ["sound", ...Object.keys(SOUND_EVENTS).map(soundKey), ...PICKABLE_SOUNDS.map(soundFileKey), "hideActivities", "activitySounds", "gameMusic"]);
|
||||
for (const key of [...prefsResetScope("appearance"), ...sounds]) {
|
||||
if (key !== "role") assert.ok(Object.hasOwn(DEFAULT_LOOKS, key), `${key} has a default`);
|
||||
}
|
||||
@@ -850,7 +876,7 @@ test("prefs: Back to default resets Appearance or Sounds & activities only, and
|
||||
test("looks: resetLooks(keys) changes only those keys, and the role is marked as asked", () => {
|
||||
const before = { ...looks };
|
||||
try {
|
||||
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: false, activityBestSnake: 7, lastActivity: "snake" });
|
||||
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: false, activityBestSnake: 7, lastActivity: "snake", skipIntro: true });
|
||||
resetLooks(prefsResetScope("appearance"));
|
||||
assert.equal(looks.theme, DEFAULT_LOOKS.theme);
|
||||
assert.equal(looks.width, DEFAULT_LOOKS.width);
|
||||
@@ -858,6 +884,7 @@ test("looks: resetLooks(keys) changes only those keys, and the role is marked as
|
||||
assert.equal(looks.role, ROLE_NOT_SET, "cleared but marked as asked");
|
||||
assert.equal(looks.sound, false, "sounds untouched by Appearance");
|
||||
assert.equal(looks.hideActivities, false);
|
||||
assert.equal(looks.skipIntro, DEFAULT_LOOKS.skipIntro, "Appearance resets Always SKIP Intro");
|
||||
resetLooks(prefsResetScope("sounds"));
|
||||
assert.equal(looks.sound, true);
|
||||
assert.equal(looks.soundQuestion, true);
|
||||
@@ -1285,6 +1312,7 @@ test("a send records its note and attachments on the item, so the page can show
|
||||
assert.equal(only.status, 200);
|
||||
const after = readState().items.find((i) => i.id === "q1");
|
||||
assert.equal(after.sentNote.text, "just a note");
|
||||
assert.equal(after.noted, true, "a note on an open question marks it noted");
|
||||
assert.deepEqual(after.sentNote.images ?? [], []);
|
||||
assert.deepEqual(
|
||||
after.thread.filter((m) => m.who === "user").map((m) => m.text).slice(-2),
|
||||
@@ -1298,11 +1326,18 @@ test("a request for suggestions is recorded with its flag and threaded even with
|
||||
const readState = () => JSON.parse(fs.readFileSync(path.join(HOME, "sessions", sid, "state.json"), "utf8"));
|
||||
const userCount = () => readState().items.find((i) => i.id === "q1").thread.filter((m) => m.who === "user").length;
|
||||
|
||||
// Earlier notes on q1 left it noted: the agent says the question stands.
|
||||
assert.equal(readState().items.find((i) => i.id === "q1").noted, true);
|
||||
assert.equal(cli(["post", "--session", sid, "--file", payload("stands-q1.json", { items: [{ id: "q1", stands: true }] })]).status, 0);
|
||||
assert.equal("noted" in readState().items.find((i) => i.id === "q1"), false, "stands: true clears noted");
|
||||
assert.equal("stands" in readState().items.find((i) => i.id === "q1"), false, "stands is never stored");
|
||||
|
||||
let before = userCount();
|
||||
const ok = await post("/submit", { actions: [{ i: "q1", type: "comment", text: "", suggest: true }], reply: "Suggestions wanted on q1: (no note)" });
|
||||
assert.equal(ok.status, 200);
|
||||
let q1 = readState().items.find((i) => i.id === "q1");
|
||||
assert.equal(q1.sentNote.suggest, true);
|
||||
assert.equal("noted" in q1, false, "a request for suggestions is not a note on the question");
|
||||
const mine = q1.thread.filter((m) => m.who === "user").at(-1);
|
||||
assert.equal(userCount(), before + 1, "an empty request still goes into the thread");
|
||||
assert.equal(mine.who, "user");
|
||||
@@ -1315,6 +1350,7 @@ test("a request for suggestions is recorded with its flag and threaded even with
|
||||
q1 = readState().items.find((i) => i.id === "q1");
|
||||
assert.equal("suggest" in q1.sentNote, false, "only true is kept");
|
||||
assert.equal(userCount(), before, "a plain empty comment still adds no thread entry");
|
||||
assert.equal("noted" in q1, false, "an empty comment leaves nothing to deal with, so it does not mark the question noted");
|
||||
assert.equal(cli(["wait", "--session", sid, "--seconds", "10"]).status, 0);
|
||||
});
|
||||
|
||||
@@ -1538,6 +1574,53 @@ test("the page reads older { from, md } thread entries", () => {
|
||||
assert.equal(threadText({ who: "agent" }), "");
|
||||
});
|
||||
|
||||
/* --------------------------------- the Dead Code findings page (notes/dead-code.md) */
|
||||
|
||||
test("Dead Code's findings page: one multi in three groups with All Safe and None presets is accepted, two recommended stay refused", () => {
|
||||
const opened = cli(["open", "--file", payload("dead-code-open.json", BASE), "--no-open"]);
|
||||
const s = opened.json;
|
||||
try {
|
||||
const findings = {
|
||||
id: "findings",
|
||||
kind: "multi",
|
||||
title: "What to remove",
|
||||
required: false,
|
||||
body: "- Safe to remove: 2\n- Check first: 1\n- Warning: 1\n\nNothing is removed until you send.",
|
||||
options: [
|
||||
{ k: "1", text: "formatDate in src/dates.js:14", detail: "Safe. Knip (exports): no caller found." },
|
||||
{ k: "2", text: "src/old/legacy.js", detail: "Safe. Knip (files): no caller found." },
|
||||
{ k: "3", text: "parseRow in src/csv.js:40", detail: "Check first. Own search only." },
|
||||
{ k: "4", text: "onLoad in src/plugin.js:8", detail: "Warning. A framework hook: the host calls it by name." },
|
||||
],
|
||||
presets: [{ label: "All Safe", ks: ["1", "2"] }, { label: "None", ks: [] }],
|
||||
};
|
||||
const ok = cli(["post", "--session", s.sid, "--file", payload("dead-code-findings.json", { items: [findings] })]);
|
||||
assert.equal(ok.status, 0, ok.stderr);
|
||||
const item = readState(s.session).items.find((i) => i.id === "findings");
|
||||
assert.ok(item, "the findings card is on the page");
|
||||
assert.deepEqual(item.options.map((o) => o.k), ["1", "2", "3", "4"], "Safe, Check first, Warning, in order");
|
||||
assert.deepEqual(item.presets, findings.presets, "both presets are kept for the page");
|
||||
assert.ok(!item.answer, "nothing starts ticked");
|
||||
|
||||
const twice = cli(
|
||||
["post", "--session", s.sid, "--file", payload("dead-code-twice.json", {
|
||||
items: [{ id: "method", kind: "choice", title: "How to look", body: "Which?", options: [{ text: "Knip", recommended: true }, { text: "Own search", recommended: true }] }],
|
||||
})],
|
||||
{ expectFail: true }
|
||||
);
|
||||
assert.equal(twice.status, 3, "a second recommended option is still refused");
|
||||
assert.match(twice.stderr, /recommended/);
|
||||
} finally {
|
||||
cli(["stop", "--session", s.sid, "--force"]);
|
||||
}
|
||||
// The budget is read as text: importing the budgets suite would run its tests here too.
|
||||
const budgets = fs.readFileSync(path.join(ROOT, "scripts", "test-console-wire-budgets.mjs"), "utf8");
|
||||
const budget = Number((budgets.match(/"dead-code\.md": (\d+)/) || [])[1]);
|
||||
assert.ok(budget > 0, "notes/dead-code.md has a byte budget");
|
||||
const bytes = fs.statSync(path.join(ROOT, "src", "web-console", "notes", "dead-code.md")).size;
|
||||
assert.ok(bytes <= budget, `notes/dead-code.md is ${bytes} bytes, over its ${budget} budget`);
|
||||
});
|
||||
|
||||
/* --------------------------------- output shape at each exit code (FR-1 to FR-3) */
|
||||
|
||||
test("the shape of every exit: 0 for an answer and a launch, 10, 30, 3 and 2", async (t) => {
|
||||
|
||||
@@ -193,7 +193,7 @@ const ROUTE_ORDER = [
|
||||
"/notepad", "/notepad/text", "/notepad/image", "/notepad/thumb", "/notepad/image/delete", "/notepad/tab",
|
||||
"/notepad/tab/rename", "/notepad/tab/delete", "/notepad/tab/order", "/notepad/tab/last", "/notepad/tab/sent", "/notepad/images/",
|
||||
"/attachments/", "/shots/", "/uploads/", "/submit", "/open-link", "/chat", "/chat/decision", "/workspace",
|
||||
"WORKSPACE_EDITS", "/workspace/scope", "/workspace/browse", "/loop-setup", "/loop-setup", "/cancel", "/ping", "/bye",
|
||||
"WORKSPACE_EDITS", "/workspace/scope", "/workspace/browse", "/loop-setup", "/loop-setup", "/spec-carry", "/cancel", "/ping", "/bye",
|
||||
];
|
||||
|
||||
test("shape: routes.mjs lists every URL the server answers, in order", () => {
|
||||
|
||||
@@ -399,7 +399,7 @@ test("Implement's card launches Implement + Review when Review is ticked", () =>
|
||||
assert.equal(launchVariant(quick, true), quick, "a card with no Review box is unchanged");
|
||||
});
|
||||
|
||||
test("helper-strength.md ships in the fifteen skills that start helpers, and in no other", () => {
|
||||
test("helper-strength.md ships in the sixteen skills that start helpers, and in no other", () => {
|
||||
// npm test has just built skills/; a direct run builds it so the check never reads a stale tree.
|
||||
if (process.env.npm_lifecycle_event !== "test") {
|
||||
execFileSync(process.execPath, [path.join(ROOT, "install.js"), "--build-skills"], { stdio: "ignore" });
|
||||
@@ -414,6 +414,7 @@ test("helper-strength.md ships in the fifteen skills that start helpers, and in
|
||||
"plan2code-3-implement",
|
||||
"plan2code-3-implement-review",
|
||||
"plan2code-4-finalize",
|
||||
"plan2code-dead-code",
|
||||
"plan2code-diagnose",
|
||||
"plan2code-init",
|
||||
"plan2code-init-update",
|
||||
|
||||
@@ -302,6 +302,18 @@ const CARDS = {
|
||||
built: { on: true },
|
||||
unrecognized: { on: true },
|
||||
},
|
||||
"plan2code-dead-code": {
|
||||
"none": { on: true },
|
||||
diagnosed: { on: true },
|
||||
fixed: { on: true },
|
||||
exploring: { on: true },
|
||||
mapped: { on: true },
|
||||
planned: { on: true },
|
||||
documented: { on: true },
|
||||
building: { on: true },
|
||||
built: { on: true },
|
||||
unrecognized: { on: true },
|
||||
},
|
||||
"plan2code-changelog": {
|
||||
"none": { on: true },
|
||||
diagnosed: { on: true },
|
||||
|
||||
@@ -498,7 +498,7 @@ test("every console workflow has its notes, and its skill's Interface reads them
|
||||
init: "init", "init-update": "init", pathfinder: "pathfinder", plan: "plan", "revise-plan": "revise-plan",
|
||||
document: "document", implement: "implement", "implement-review": "implement", "quick-task": "quick-task",
|
||||
review: "review", finalize: "finalize", handoff: "handoff", changelog: "changelog", git: "git", xray: "xray",
|
||||
diagnose: "diagnose", "pr-prep": "pr-prep", test: "test",
|
||||
diagnose: "diagnose", "pr-prep": "pr-prep", test: "test", "dead-code": "dead-code",
|
||||
};
|
||||
const skills = fs.readdirSync(path.join(ROOT, "src")).filter((f) => /^plan2code(-.*)?\.md$/.test(f));
|
||||
for (const f of skills) {
|
||||
|
||||
@@ -19,6 +19,7 @@ test("state: page starts as app.js always started it", () => {
|
||||
sent: {},
|
||||
stopping: null,
|
||||
afterBuild: null,
|
||||
afterBuildFinish: null,
|
||||
homeward: null,
|
||||
launching: null,
|
||||
deleting: null,
|
||||
@@ -60,6 +61,7 @@ test("state: the rest of the shared state starts as app.js always started it", (
|
||||
dashPick: null,
|
||||
mentionPop: null,
|
||||
heldPose: null,
|
||||
newQuestions: new Set(),
|
||||
scopeMine: null,
|
||||
launchScoping: false,
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
]
|
||||
},
|
||||
"installDirs": {
|
||||
"win": ["%USERPROFILE%\\.local\\bin"],
|
||||
"win": ["%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin", "%USERPROFILE%\\.local\\bin"],
|
||||
"mac": ["~/.local/bin"],
|
||||
"linux": ["~/.local/bin"]
|
||||
}
|
||||
@@ -117,7 +117,7 @@
|
||||
"args": ["{model}", "{prompt}"],
|
||||
"bypassArgs": ["--approval-mode=yolo"],
|
||||
"modelArgs": ["--model", "{model}"],
|
||||
"note": "For unpaid tier and Google One accounts Gemini CLI was replaced by Antigravity CLI on June 18, 2026; whether gemini still runs depends on the account."
|
||||
"note": "For Google AI Pro and Ultra accounts and free Gemini Code Assist for individuals, Gemini CLI was replaced by Antigravity CLI on June 18, 2026; Standard and Enterprise licenses and paid API keys are unaffected."
|
||||
},
|
||||
{
|
||||
"id": "pi",
|
||||
@@ -127,6 +127,16 @@
|
||||
"prompt": "/skill:plan2code",
|
||||
"args": ["{model}", "{prompt}"],
|
||||
"modelArgs": ["--model", "{model}"]
|
||||
},
|
||||
{
|
||||
"id": "cursor",
|
||||
"name": "Cursor CLI",
|
||||
"kind": "template",
|
||||
"command": "agent",
|
||||
"prompt": "/plan2code",
|
||||
"args": ["{model}", "{prompt}"],
|
||||
"bypassArgs": ["--force"],
|
||||
"modelArgs": ["--model", "{model}"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
{
|
||||
"id": "best",
|
||||
"label": "Best, Fable where available, otherwise Opus"
|
||||
"label": "Best, same model as Opus"
|
||||
}
|
||||
],
|
||||
"devin": [
|
||||
@@ -140,16 +140,12 @@
|
||||
"label": "GPT-6 Astra High Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5-6-sol-low",
|
||||
"label": "GPT-5.6 Sol Low Thinking"
|
||||
"id": "swe-2-flash-medium",
|
||||
"label": "SWE-2 Flash Medium"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5-6-sol-medium",
|
||||
"label": "GPT-5.6 Sol Medium Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gpt-5-6-sol-high",
|
||||
"label": "GPT-5.6 Sol High Thinking"
|
||||
"id": "swe-2-flash-high",
|
||||
"label": "SWE-2 Flash High"
|
||||
}
|
||||
],
|
||||
"codex": [
|
||||
@@ -187,7 +183,7 @@
|
||||
},
|
||||
"devin": {
|
||||
"thrifty": {
|
||||
"model": "swe-2-medium"
|
||||
"model": "swe-2-flash-high"
|
||||
},
|
||||
"balanced": {
|
||||
"model": "swe-2-high"
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Caller Search
|
||||
> Part of plan2code-dead-code: read in Step 4 before the caller search, and given to every helper that searches. Never invoked as a skill.
|
||||
|
||||
A candidate is dead only when nothing in the whole project reaches it. Search the whole project, never only the folder the run covers, and search for more than the plain name: the lists below are what else can reach an item in each language group. Include tests, scripts, config files, docs that act as config (an OpenAPI file, a route table, a cron file) and generated glue (bindings, stubs, registration files).
|
||||
|
||||
## Every language
|
||||
|
||||
- The plain name, as a whole word, in every text file, not only in source files of the same language.
|
||||
- The name inside strings and templates: config keys, JSON and YAML values, SQL, HTML attributes, environment files.
|
||||
- Build files, CI configs, `Dockerfile`, `Makefile`, package scripts and shell scripts that call a file or a function by name.
|
||||
- A file candidate: its path and its file name without the extension, anywhere.
|
||||
- Record what each search found in `callers`, even when it found nothing ("no match outside its own file").
|
||||
|
||||
## JavaScript and TypeScript
|
||||
|
||||
- Re-exports: `export * from`, `export { x } from`, and the barrel files (`index.js`, `index.ts`) that pass a name on.
|
||||
- Dynamic `import()` with a string or template path, and `require()` with a computed path.
|
||||
- `package.json` `exports`, `main`, `module`, `bin` and `types`; a workspace's other packages that import this one.
|
||||
- Framework conventions that load by file name: route folders (`pages/`, `app/`, `routes/`), `*.config.*` files, test setup files.
|
||||
- Names reached by string: `obj[name]`, event names, `customElements.define`, decorators.
|
||||
|
||||
## Python
|
||||
|
||||
- `__all__` lists, and `from module import *` that brings them in.
|
||||
- `getattr`, `importlib.import_module`, `__import__` and string paths such as `"package.module:func"`.
|
||||
- Decorators that register a function (routes, CLI commands, signal handlers, pytest fixtures used by name).
|
||||
- Entry points in `pyproject.toml`, `setup.cfg` and `setup.py` (`console_scripts`, plugin groups), and `manage.py` or framework settings that name a module.
|
||||
|
||||
## Rust
|
||||
|
||||
- `pub use` re-exports and the crate's public API in `lib.rs`.
|
||||
- Macros that expand to a call (`macro_rules!` bodies, derive and attribute macros).
|
||||
- `#[cfg(...)]` and feature flags: an item used only under a feature or a target is still used.
|
||||
- `mod` declarations, `#[path]` attributes, `build.rs`, and binaries under `src/bin/` or `[[bin]]` in `Cargo.toml`.
|
||||
|
||||
## Go
|
||||
|
||||
- Exported names (capitalized) used from another package or module in the workspace.
|
||||
- Interface satisfaction: a method with no direct caller may make a type meet an interface used elsewhere.
|
||||
- `init()` functions, blank imports (`import _ "pkg"`) that run them, and `//go:generate` lines.
|
||||
- Build tags and file-name suffixes (`_linux.go`, `_test.go`), and reflection (`reflect`, `MethodByName`, struct tags read at runtime).
|
||||
|
||||
## Java and Kotlin
|
||||
|
||||
- Reflection: `Class.forName`, `getMethod`, `getDeclaredField`, and names in strings.
|
||||
- Annotations that register or call: `@Bean`, `@Component`, `@Controller`, `@RequestMapping`, `@Test`, `@JsonCreator`, `@Subscribe`, `main` methods.
|
||||
- Spring and other dependency injection: XML configs, `application.properties` and `application.yml`, component scanning by package.
|
||||
- `META-INF/services` files, `AndroidManifest.xml`, Gradle and Maven files that name a class, and Kotlin `@JvmStatic` or `companion object` members called from Java.
|
||||
|
||||
## C#
|
||||
|
||||
- Reflection: `Type.GetType`, `GetMethod`, `Activator.CreateInstance`, `nameof` used as a key.
|
||||
- Attributes that register or call: `[HttpGet]`, `[Route]`, `[Fact]`, `[Test]`, `[JsonConstructor]`, `[DllImport]`.
|
||||
- Dependency injection registration (`AddScoped`, `AddTransient`, `AddSingleton`, assembly scanning) and `appsettings.json`.
|
||||
- Serialization: properties set only by a serializer, and `.csproj`, `.xaml` and `.razor` files that name a type or handler.
|
||||
|
||||
## Ruby
|
||||
|
||||
- `send`, `public_send`, `method`, `define_method` and `respond_to?` with a symbol or string.
|
||||
- `constantize`, `const_get` and class names built from strings.
|
||||
- Rails autoloading and conventions: controllers and actions reached through `config/routes.rb`, callbacks (`before_action`, `after_save`), helpers, jobs, mailers, views that call a helper, and concerns.
|
||||
- Rake tasks, `Gemfile` and gemspec `executables`, and initializers.
|
||||
|
||||
## PHP
|
||||
|
||||
- Composer autoload (`psr-4`, `classmap`, `files`) and `bin` entries in `composer.json`.
|
||||
- `class_exists`, `method_exists`, `call_user_func`, variable functions (`$fn()`) and `new $class`.
|
||||
- Routes and container config: framework route files, service container definitions (YAML, XML, PHP arrays), event listeners and middleware lists.
|
||||
- Templates (Blade, Twig) that call a function or helper by name, and attributes such as `#[Route]`.
|
||||
|
||||
## Any other language
|
||||
|
||||
Search the plain name, strings and config as in "Every language", say which of the language's dynamic features you could not cover, and leave the finding at Check first.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,157 @@
|
||||
# 💀 DEAD CODE MODE
|
||||
|
||||
Start all DEAD CODE MODE responses with '💀 [DEAD CODE]'
|
||||
|
||||
## Role
|
||||
|
||||
Finds unused code paths and dead code in the person's own project. Shows each finding with its evidence and a label that says how safe it is to remove, removes only the findings the person picks, then runs the project's tests and build. **Never commits, pushes or stages**, never installs an outside tool, and does no code review of its own (that is the Review skill's job).
|
||||
|
||||
## Interface
|
||||
|
||||
The FIRST thing you do, before anything else in this file, before running a script: ask **web console** (browser page, suggested) or **terminal**? Console → run `node "<D>/console.mjs" open --workflow dead-code` before reading (<D>: references/web-console/ beside this SKILL.md (~/.agents/skills/plan2code-dead-code/references/web-console/ globally) or the dir in ~/.plan2code/console/console-dir), then read <D>/console.md and <D>/notes/dead-code.md. The start questions, the findings list, the checks, the report and the save offers all go through it. 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? Its session is already open: resume it (console-launches.md), then Project Context.
|
||||
|
||||
## Project Context
|
||||
|
||||
Read `./AGENTS.md` when it exists: its commands, its `## Test map` and anything it says about slow suites or code reached by name. Dead Code still works without one, but the test map is what tells it which tests and build to run after a removal; without it the scripts read the project's config files, and the person confirms the commands.
|
||||
|
||||
## Scripts
|
||||
|
||||
`<S>` is `scripts/` beside this SKILL.md (`~/.agents/skills/plan2code-dead-code/scripts/` globally). Run from the project root. Each prints one JSON object; on a non-zero exit read `message` and do what `next` says.
|
||||
|
||||
- `node "<S>/dead-code.mjs" detect [--scope <dir>]`: the dead-code tools the project already has (`tools`: `id`, `language`, `marker`, `available`, `command`, `format`), `languages` with file counts, `sourceFiles`, and `overLimit` (a very big project).
|
||||
- `node "<S>/dead-code.mjs" run --tool <id> [--scope <dir>]`: runs that tool with a timeout and prints `candidates` (`file`, `line`, `name`, `kind`, `rule`, `message`), or `unparsed: true` with the output's `tail`.
|
||||
- `node "<S>/dead-code.mjs" narrow --candidates <file>`: `folders` ranked by candidate count.
|
||||
- `node "<S>/dead-code.mjs" keep list|filter|add|remove`: the shared keep list, `.plan2code-dead-code/keep.md`. `filter [--fresh]` reads candidates on stdin and prints `shown`, `hidden`, `kept` and `changed`; `add --file --reason` with `--name --line` for an item, and neither for a whole unused file; `remove --file --name`, plus `--hash` or `--line` when two rows share a name.
|
||||
- `node "<S>/dead-code.mjs" backup <files...> [--run <id>]` and `restore --run <id> [--files <f>...] [--verify]`: copies outside the project and a checked put-back.
|
||||
- `node "<S>/dead-code.mjs" report write --findings <file>`: saves `.plan2code-dead-code/reports/DEAD-CODE-<date>.md`, only on a yes.
|
||||
- `node "<S>/dead-code.mjs" gitignore-check` and `gitignore-add`: whether `reports/` is ignored, and adding the line, only on a yes.
|
||||
- `node "<S>/test-map.mjs" read`: the project test map (`found`, `rows` of `area`, `paths`, `run`, `shared`, and `problems`).
|
||||
- `node "<S>/test-commands.mjs" discover`: the project's commands from its config files: `suite`, `runners` (`cmd`, `cwd`, `covers`), `checks` (`kind` lint, types or build, with `cmd`), `builtin`.
|
||||
- `node "<S>/run-check.mjs" --cmd <c> --cwd <d> --timeout <s> --log <file>`: runs one check and prints `outcome` (`passed`, `failed`, `timeout`, `not-started` with a `reason`), `exit`, `seconds` and `tail`.
|
||||
|
||||
## References
|
||||
|
||||
- `references/caller-search.md`: what to search besides the plain name, per language group. Read it before Step 4.
|
||||
- `references/helper-strength.md`: helper strength and effort.
|
||||
|
||||
## Rules
|
||||
|
||||
- Follow `./AGENTS.md` when it exists.
|
||||
- **Never** run `git commit`, `git push`, `git add` or `git stash`. Read-only git is fine. The changes stay unstaged for the person to look at.
|
||||
- **Never install anything**: no `npm install`, `pip install`, `cargo install`, `go install` or download of a tool. A tool the project already has may be run.
|
||||
- **Write only** code removals, `.plan2code-dead-code/keep.md`, and, on a yes, the saved report and the `.gitignore` line.
|
||||
- **Nothing is removed before the person picks it.** Nothing is pre-ticked.
|
||||
- **Silence is not proof.** A finding reaches Safe only when a tool listed it and the caller search agrees.
|
||||
- **Never partial without saying so.** A narrowed or stopped run says what was and was not checked, and is never called complete.
|
||||
- **Record honestly.** A check that did not run is never reported as passed.
|
||||
- US English. No em dashes in any text you write (report, keep reasons, page text). Plain words: name the file, the item and the command.
|
||||
|
||||
## Helpers
|
||||
|
||||
When your tool can start helpers (subagents) and they are not switched off for this run (on the web console a `Subagents:` block says which, console-subagents.md): the caller search (Step 4), one helper per batch of candidates, each given `references/caller-search.md` and returning, per candidate, what it searched and what it found, never a label. Light strength, low effort, per references/helper-strength.md. Keep the labels, the Safe call, the removals, the checks and every question with you. No helpers? Do the same work yourself.
|
||||
|
||||
## Process
|
||||
|
||||
### Step 1: Start questions
|
||||
|
||||
Run `detect` and `keep list` first, then ask on one card, answered together:
|
||||
|
||||
1. **Method.** A tool counts only when its `language` has files in `detect`'s `languages`. Pick one available tool (`available: true`) per language group, preferring one the script reads (`format` other than `agent`) over one you read by hand. With a tool picked: use the project's tool or tools and verify their lists with a caller search (default), or also do a full search of our own. Say each tool used and its `marker`; with several groups each having a tool, one option names them all ("Knip and vulture, checked by a caller search"). A group with no available tool (say which and why) gets a search of our own (Step 3). When no group has one: skip this question and say the run is a search of our own, so every finding is Check first.
|
||||
2. **Scope.** The whole project (default) or a folder the person names. A folder: run `detect --scope <dir>` again and use its `overLimit` and `sourceFiles` from here on.
|
||||
3. **Keep list.** When `keep list` has entries: say how many, and offer to use it (default) or do a fresh scan that ignores it. Leave this out when it has none.
|
||||
4. **Size.** When `overLimit` is true: say the project has `sourceFiles` source files and that a narrow step may follow once the starting list is in (Step 2), and that picking a smaller folder skips it.
|
||||
|
||||
The answers are final for the run. A this-branch-only mode is not offered yet.
|
||||
|
||||
### Step 2: Scope and size
|
||||
|
||||
The scope picks which findings are reported, never where callers are searched: the caller search always covers the whole project, so a folder run never calls something dead that another folder uses.
|
||||
|
||||
When `overLimit` is true: run the tool (Step 3), write its `candidates` to a file in the session folder (`open` printed it; in the terminal, the OS temp folder) and run `narrow --candidates <file>`. Ask the person to narrow first, listing the five `folders` with the most candidates, and offer the whole project with a plain warning that it takes longer and costs more. With no tool, list the five biggest top-level source folders instead. Once the person picks, keep only the candidates whose `file` is under the pick (or rerun `run --scope <dir>`), set the report's `scope` to it and put the rest in `notChecked`. Helpers split the work inside what the person picks. Whatever is chosen, the report says so: a narrowed run is `ranFrom: "narrowed"` with what was left out in `notChecked`, never complete.
|
||||
|
||||
### Step 3: The starting list
|
||||
|
||||
**With a tool:** `run --tool <id>` (add `--scope <dir>` for a folder run), once per chosen tool. Merge their candidates into one list (the same `file`, `line` and `name` from two tools is one candidate); the merged list is what goes to `keep filter`.
|
||||
|
||||
- `unparsed: true`: read the `tail` yourself, write the candidates by hand in the same shape, and say the tool's output was read by the agent, not the script.
|
||||
- A tool that fails, times out or cannot start: report it as missing in one line and continue as a search of our own.
|
||||
- With the full-search choice, also make your own list (below) and merge it: an item both found is source `both`.
|
||||
|
||||
**With no tool, or none for a language in scope:** find candidates yourself: exports, functions, classes, methods and whole files that nothing references. Their source is `own`, every one stays Check first or Warning, and the report and the page say plainly that no tool confirmed them.
|
||||
|
||||
Never install, `npm install`, `pip install` or fetch a tool to get a list.
|
||||
|
||||
**The keep list, for every candidate.** Whatever the source (the script's `candidates`, ones you wrote from `tail`, the merged full search, or your own list), write the final list as one JSON array and pipe it to `keep filter` (`--fresh` when the person chose a fresh scan). Work on `shown`; the number of `hidden` entries is the hidden count. A shown candidate with `wasKept: true` was kept before but its code changed since: say so in its detail. A `kept` entry marked `gone` is offered for removal from the list in Step 8.
|
||||
|
||||
### Step 4: Verify with a caller search
|
||||
|
||||
Read `references/caller-search.md`. For each candidate, search the whole project for callers: the plain name, names inside strings, config files, tests, docs that act as config and generated glue, plus that language group's rules. Record what was found in `callers`.
|
||||
|
||||
- **A caller found:** the item is live. Drop it from the list and count it ("12 dropped: a caller was found").
|
||||
- **No caller, and a tool listed it:** the tool and the search agree; Safe unless Step 5 says otherwise.
|
||||
- **No caller, found only by our own search:** Check first.
|
||||
|
||||
A tool's silence about an item is never proof that it is live or dead. On a big list, helpers search in batches (Helpers).
|
||||
|
||||
### Step 5: Labels
|
||||
|
||||
Every finding gets one label, with its reason:
|
||||
|
||||
- **Safe to remove:** a tool listed it and the caller search found nothing.
|
||||
- **Check first:** found by our own search only; listed by a tool that sees private scope only while the item is public (such a tool never vouches for an unused public item); or anything you are unsure of.
|
||||
- **Warning:** always for these six kinds, with which one and why shown:
|
||||
1. called by name from a string or config
|
||||
2. a plugin or framework hook
|
||||
3. a public library export
|
||||
4. a CLI entry point or script
|
||||
5. a test helper
|
||||
6. code only tests call
|
||||
|
||||
A Warning is never in the quick-removal list (the All Safe preset). The person may still remove one by picking it by hand.
|
||||
|
||||
### Step 6: The findings page
|
||||
|
||||
Post one `multi` item (`notes/dead-code.md` gives its shape): options grouped Safe, then Check first, then Warning, each option's `text` the item and its location (`name` in `file:line`) and its `detail` the label, the source (tool, own search or both), the tool's rule id and the reason (the six-kind reason for a Warning). Preset: `All Safe` (ticks the Safe group). Nothing is ticked to begin with: the console's `multi` cannot open ticked, so the preset is the quick pick. Above it say the tool or tools used, how many items the keep list hid (on request, list each with its reason) and how many were dropped for having a caller. In the terminal, the same as a numbered list in three groups; the person names numbers or says "all safe".
|
||||
|
||||
Nothing picked → skip to Step 8.
|
||||
|
||||
### Step 7: Removal and checks
|
||||
|
||||
1. **Find the checks.** Run `test-map.mjs read`. With a map, every row's `run`, plus the `build` entries of `test-commands.mjs discover`'s `checks`. No map: `discover`; list its `suite`, `runners` and `checks` and confirm them on one card before anything runs; a correction replaces what was found. None at all: ask the person for the command. With nothing to run, say removal will be unchecked and continue only on the person's yes. The checks run project-wide, even on a folder run.
|
||||
2. **Back up.** `backup <every file the picks change>`; keep its `run` id.
|
||||
3. **Remove** the picked findings together: the item itself and anything that only existed for it in the same edit (its import line, a now-empty export list). A whole-file finding deletes the file.
|
||||
4. **Check once.** Run every check through `run-check.mjs` (`--timeout 600` by default, longer when `AGENTS.md` says a suite is slow; `--log` in the session folder, or the OS temp folder), posting one `activity` line per check with `quietMinutes` sized to its timeout.
|
||||
5. **All pass:** done; every pick's outcome is `removed`.
|
||||
6. **Any fail** (any `outcome` other than `passed`: `failed`, `timeout` or `not-started`, with its `reason` or `tail` as the failure text): `restore --run <id>`, then `restore --run <id> --verify`. Never go on while it reports a mismatch: stop, say which files did not match, and leave the rest to the person. Run the checks once on the restored tree: if they still fail, the project's checks fail without any removal, so stop, mark every pick `skipped` with that reason, say so, and do not retry. Otherwise retry the picks one at a time: for each, `backup` the files it touches as a new run, remove it, run the checks; a pass keeps it, a fail restores that run and records `failed: <the end of the failing check's tail>` as its outcome. A removal that depends on another (the second becomes unused only after the first goes) is retried with it as a pair.
|
||||
|
||||
Nothing is staged or committed at any point.
|
||||
|
||||
### Step 8: Report, keep list and finish
|
||||
|
||||
**Report.** Always show it on the page (in the terminal, as a table): the headline says complete or narrowed (or stopped), the scope, the method and tool or tools, how many the keep list hid, how many were dropped, then each finding with its label, source, rule id, the reason for any Warning and its outcome (`removed`, `kept`, `skipped`, `failed: ...`), and whether removal was unchecked.
|
||||
|
||||
Offer three things, each acted on only on a yes:
|
||||
|
||||
- **Save the report.** Write the findings JSON (`scope`, `mode` of `verify`, `full` (also when any language group had no tool) or `own`, `tool` (an id, a list of ids when several ran, or null), `ranFrom`, `findings`, `hidden` as a number, `notChecked`) to the session folder, each finding `{ file, line, name, kind, source (tool, own or both), rule, label (safe, check or warning), warningKind (which of the six kinds, and why), callers, outcome }`, and run `report write --findings <file>`. On first use, run `gitignore-check` and, when `ignored` is false, offer `gitignore-add`.
|
||||
- **Keep findings.** For any finding the person keeps, ask the reason and run `keep add --file --name --line --reason` (a whole unused file: `keep add --file --reason`). It is hidden next run, shown as a count.
|
||||
- **Take entries off.** List the keep list's entries with their reasons (the `gone` ones first) and run `keep remove --file --name` on the ones the person picks (a whole-file entry: `keep remove --file`). On exit 2 `ambiguous-entry`, show the rows it lists (each hash with its reason) and rerun with the `--hash` the person picks.
|
||||
|
||||
## Abort
|
||||
|
||||
On "stop", "cancel" or similar during a run: confirm. With removals on disk and the checks not yet passed, `restore --run <id>` and `--verify` first, and say so. Then show the report as far as it got with `ranFrom: "stopped"` and what was not checked, offer to save it, and stop. Never call a stopped run complete.
|
||||
|
||||
## Session End
|
||||
|
||||
Work summary: the scope and whether it was narrowed, the method and tool or tools, how many findings by label, how many were hidden by the keep list or dropped for a caller, what was removed, put back (with why) or left, whether removal was checked, and any file written (the report, `keep.md`, `.gitignore`).
|
||||
|
||||
**Next step**, as the closing line: "Review the unstaged changes and commit them, with `keep.md`, using `/plan2code-git`." Nothing removed and no keep-list change: "Nothing to commit."
|
||||
|
||||
On the console, post `finish` with the counts removed, kept and failed in `headline`, `"dashboard": true`, and `command` `/plan2code-git` for the unstaged changes and the keep list when something was removed or `keep.md` changed; otherwise leave `command` out, except a stop before anything was removed, where `command` is `/plan2code-dead-code`. Never a `commit` field: the Git skill commits.
|
||||
|
||||
```
|
||||
⋅
|
||||
╭───╮
|
||||
╲│ ★ │╱
|
||||
│ ◡ │ Swept clean!
|
||||
╰┬─┬╯
|
||||
```
|
||||
@@ -161,6 +161,6 @@ Ready to implement? (yes / modify / escalate / abort)
|
||||
|
||||
## Session End
|
||||
|
||||
Work summary — tell user: task name, plan delivered (or PLAN-DRAFT created if escalated). After a build, offer: "Reply `show me` to see it running." A review the person asks for after the build runs as `references/review-in-build.md` says. **Show me it working** (offered, never required): start the app as `AGENTS.md` Commands says (missing: work it out from `package.json` scripts, `Makefile` or `README` and, once it worked, offer the line for `AGENTS.md`; else ask), look at the change (a browser tool's screenshot, else the command's output), stop what you started, and add one line to the work summary: what was run and what was seen. Screenshots go on the web console page only.
|
||||
Work summary — tell user: task name, plan delivered (or PLAN-DRAFT created if escalated). After a build, offer: "Reply `show me` to see it running." A review the person asks for after the build runs as `references/review-in-build.md` says. **Show me it working** (offered, never required): start the app as `AGENTS.md` Commands says (missing: work it out from `package.json` scripts, `Makefile` or `README` and, once it worked, offer the line for `AGENTS.md`; else ask), look at the change (a browser tool's screenshot, else the command's output), stop what you started, and add one line to the work summary: what was run and what was seen. After the demo, ask "Looks right, or want changes?" and make any change before the summary. Screenshots go on the web console page only.
|
||||
|
||||
**On the web console:** after a build, keep waiting for the review button's answer before you stop.
|
||||
@@ -69,6 +69,7 @@ Ground truth for menu notes and Ask-tab answers. For anything beyond this table,
|
||||
| diagnose | the bug, the codebase, `references/building-habits.md` | `DIAGNOSIS-<date>.md`; no code changes |
|
||||
| pr-prep | git diff and status, the `AGENTS.md` test map, the project's config files, the PR template | the page report and description; `PR-READINESS-<date>.md` on a yes; the `AGENTS.md` test map on a yes; no commits, no push |
|
||||
| test | the codebase, the `AGENTS.md` test map, nearby tests, coverage output when offered | new test files; the `AGENTS.md` test map on a yes; `PLAN-DRAFT-<date>.md` when escalated; no source changes |
|
||||
| dead-code | the project's source, its own dead-code tool's output, the `AGENTS.md` test map, `.plan2code-dead-code/keep.md` | code removals the person picks; `.plan2code-dead-code/keep.md`; `.plan2code-dead-code/reports/DEAD-CODE-<date>.md` and the `.gitignore` line on a yes; no commits, no staging |
|
||||
|
||||
## A pick arrives
|
||||
|
||||
@@ -105,6 +106,7 @@ If `skill` is not in the table below, say so on the page and stay the dashboard.
|
||||
| plan2code-git | git | | plan2code-changelog | changelog |
|
||||
| plan2code-xray | xray | | plan2code-diagnose | diagnose |
|
||||
| plan2code-pr-prep | pr-prep | | plan2code-test | test |
|
||||
| plan2code-dead-code | dead-code | | | |
|
||||
|
||||
## A pick-up arrives
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Helper Strength
|
||||
> Shared by the skills that start helpers (subagents): Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray and Diagnose. Read it when you first start a helper in a session. Never invoked as a skill.
|
||||
> Shared by the skills that start helpers (subagents): Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray, Diagnose, PR Prep, Test and Dead Code. Read it when you first start a helper in a session. Never invoked as a skill.
|
||||
|
||||
## The words
|
||||
|
||||
|
||||
@@ -68,10 +68,16 @@ port, and the filesystem as transport; this CLI is the whole agent surface.
|
||||
then waits up to N seconds in the same command (two JSON lines;
|
||||
the exit code is the wait's). The patch may carry settle: true
|
||||
(or a list of item ids) to mark the latest send's cards answered
|
||||
with what was sent; doc blocks may carry file: "<path>" (and
|
||||
select: "tasks"), read from the project, and a doc refresh: true
|
||||
re-reads them. A doc's version moves up by itself. A patch may
|
||||
carry run: { event, id, tasks? } (session meter points) and folderIssue:
|
||||
with what was sent. An item may carry stands: true, saying it
|
||||
still applies after its note's thread reply: it clears the
|
||||
item's noted flag (set when the person's note lands on an open
|
||||
question) and is never stored. While any open item is noted, a
|
||||
patch adding a new open required question is refused unless it
|
||||
also rewords, deletes ("_delete": true) or stands each one. Doc
|
||||
blocks may carry file: "<path>" (and select: "tasks"), read from
|
||||
the project, and a doc refresh: true re-reads them. A doc's
|
||||
version moves up by itself. A patch may carry run: { event, id,
|
||||
tasks? } (session meter points) and folderIssue:
|
||||
{ name, reason, hint? } (a workspace folder you could not read);
|
||||
both go to the ledger, never into the state. A patch may also
|
||||
carry helpers: [{ id, title, ask, state, result?, strength?,
|
||||
|
||||
@@ -266,7 +266,7 @@ export async function cmdOpen() {
|
||||
s.setup = { forCli: args["for-cli"] || null, token: newToken(), created: nowIso() };
|
||||
}
|
||||
// The loop lock follows the flag: --loop locks the page, and a resume
|
||||
// without it (Fix it by hand, from a stop screen) is an ordinary,
|
||||
// without it (Fix together with an agent, from a stop screen) is an ordinary,
|
||||
// unlocked session. `loopExpect` goes with the lock: the app restamps it
|
||||
// on its next look, so a stale setup never judges a new run.
|
||||
if (loopMode) s.loop = loopLock();
|
||||
|
||||
@@ -6,7 +6,7 @@ The meter is advice and never blocks. The console scores these launches itself w
|
||||
|
||||
Per-unit work is yours: `{"run":{"event":"implement-phase","id":"phase-2","tasks":9}}`, one `run` per post, never reaching the page state.
|
||||
|
||||
- `event`: `pathfinder-chart`, `pathfinder-question` (scores nothing now), `pathfinder-research`, `plan`, `revise-plan`, `document`, `implement-phase`, `implement-review-phase`, `review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `git-commits`, `git-conflict`. An unknown event is exit 3. Post only the events your notes name: a launch the console scores already has its points.
|
||||
- `event`: `pathfinder-chart`, `pathfinder-question` (scores nothing now), `pathfinder-research`, `plan`, `revise-plan`, `document`, `implement-phase`, `implement-review-phase`, `review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`, `git-commits`, `git-conflict`. An unknown event is exit 3. Post only the events your notes name: a launch the console scores already has its points.
|
||||
- `id`: the unit (a question's slug, `phase-N`, `map`), non-empty. The same id in the same skill run is ignored.
|
||||
- `tasks`: only with `implement-phase` and `implement-review-phase`; the tasks completed (`[x]`, not blocked), a whole number 1 to 999. A phase scores one point per 3 tasks rounded up (Implement + Review one more for the review); without it, a flat 2 (or 3). It takes over the count from `headline.cleared`, never adding to it.
|
||||
- `commits`: only with `git-commits`; commits made, 1 to 999, one point per 2 rounded down.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Helpers (Subagents)
|
||||
|
||||
The console points here when a `Subagents:` block reaches you. On the skills that offer it (`init`, `init-update`, `pathfinder`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `quick-task`, `review`, `finalize`, `xray`, `diagnose`, `pr-prep`, `test`) the person turns helpers on or off from the top bar's Subagents button, per project and skill. It reaches you as a standing instruction, only when it changes.
|
||||
The console points here when a `Subagents:` block reaches you. On the skills that offer it (`init`, `init-update`, `pathfinder`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `quick-task`, `review`, `finalize`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`) the person turns helpers on or off from the top bar's Subagents button, per project and skill. It reaches you as a standing instruction, only when it changes.
|
||||
|
||||
## What arrives
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ A local page where the person answers your questions, reads your drafts and appr
|
||||
|
||||
## Start
|
||||
|
||||
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
|
||||
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
|
||||
|
||||
Keep `sid`: every later command takes `--session <sid>`. `open` failing: carry on in the terminal. When `open` adds `remote` and a `note`, give the link, ask whether it opened, and move to the terminal if not. Tell the person the link (with `"inApp":true`, never print it: only how many questions are waiting) and end every terminal message with the latest `terminalLine`, verbatim.
|
||||
|
||||
@@ -77,6 +77,8 @@ Items show in the order sent: send them in the order you want them answered.
|
||||
|
||||
Every note in an item's `thread` gets a reply: `{"id":"p4","thread":[{"who":"agent","text":"..."}]}`. Send only new entries.
|
||||
|
||||
After the person's note on an open question, reword it (same `id`), retire it with `"_delete":true`, or send `"stands":true` if it still applies, in the patch with your reply or your next question. Until you do, a new open required question is refused. Do the same when an Ask reply or your own finding changes what a question assumed.
|
||||
|
||||
## What the console refuses (exit 3)
|
||||
|
||||
- more than three open required questions at once (optional cards and notices do not count)
|
||||
|
||||
@@ -114,7 +114,7 @@ const isFile = (p) => {
|
||||
|
||||
// The workflows a tab can be sent to from the dashboard, and the spec a Revise
|
||||
// plan send names.
|
||||
export const SENT_WORKFLOWS = ["pathfinder", "plan", "quick-task", "revise-plan"];
|
||||
export const SENT_WORKFLOWS = ["pathfinder", "plan", "quick-task", "revise-plan", "diagnose"];
|
||||
const SENT_SPEC_RE = /^specs\/[A-Za-z0-9._-]+$/;
|
||||
|
||||
// A tab's `sent` record as stored, or null when it does not hold up.
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Dead Code
|
||||
|
||||
## Start questions
|
||||
|
||||
One `--wait` batch, after `detect` and `keep list`. Only the first card is required; leave out any the prompt says to skip (no method card with no tool, no keep card with an empty list):
|
||||
|
||||
```jsonc
|
||||
{"title":"Clear out dead code","headline":{"stage":"Start","cleared":0,"total":5},"items":[{"id":"method","kind":"choice","title":"How to look","allowOther":false,"body":"This project has Knip (`knip.json`).","options":[{"text":"Knip, checked by a caller search","recommended":true},{"text":"Knip plus a full search of my own","detail":"Slower; finds what Knip cannot see."}]},{"id":"scope","kind":"choice","title":"Where to look","required":false,"body":"Callers are always searched across the whole project.","options":[{"text":"The whole project","recommended":true},{"text":"One folder","detail":"Name it in the note."}]},{"id":"keep","kind":"choice","title":"The keep list","required":false,"allowOther":false,"body":"3 findings were kept on earlier runs.","options":[{"text":"Hide them again","recommended":true},{"text":"A fresh scan that ignores them"}]}]}
|
||||
```
|
||||
|
||||
## Narrow first
|
||||
|
||||
Only when `overLimit` is true. One `choice`, `--wait`: the five folders from `narrow` (or the biggest top-level folders with no tool), each with its count in `detail`, then the whole project with the time and cost warning in its `detail`.
|
||||
|
||||
## The findings
|
||||
|
||||
One `multi`, `--wait`, `required:false`. Options in three groups, in this order: Safe, Check first, Warning. Each option's `text` is `name` in `file:line`; its `detail` starts with the label, then the source (tool, own search or both), the rule id and the reason (the six-kind reason for a Warning). The `body` gives each group's count, how many the keep list hid and how many were dropped for a caller. Nothing starts ticked: the quick pick is the preset `All Safe` (the Safe group's keys). Leave out a preset with no keys (no Safe findings, or a `None`): the page drops it, and a pressed preset clears when pressed again.
|
||||
|
||||
```jsonc
|
||||
{"headline":{"stage":"Findings","cleared":2},"items":[{"id":"findings","kind":"multi","title":"What to remove","required":false,"body":"- Safe to remove: 2\n- Check first: 1\n- Warning: 1\n\n4 hidden by the keep list; 9 dropped: a caller was found. Nothing is removed until you send.","options":[{"k":"1","text":"formatDate in src/dates.js:14","detail":"Safe. Knip (exports): no caller found."},{"k":"2","text":"src/old/legacy.js","detail":"Safe. Knip (files): no caller found."},{"k":"3","text":"parseRow in src/csv.js:40","detail":"Check first. Own search only."},{"k":"4","text":"onLoad in src/plugin.js:8","detail":"Warning. A framework hook: the host calls it by name."}],"presets":[{"label":"All Safe","ks":["1","2"]}]}]}
|
||||
```
|
||||
|
||||
## Checks
|
||||
|
||||
With no test map: one `confirm` listing each command and the folder it runs in, `--wait`, `"yesLabel":"Use these","noLabel":"Not right"`, before anything runs. A "Not right" note replaces what was found; with none, ask for the commands as a `text` card.
|
||||
|
||||
One progress post per check, no `--wait`, its `activity` naming the check and `quietMinutes` sized to its timeout (600 s is 10 minutes, plus a margin). Run the `chat` check between checks, as a build does.
|
||||
|
||||
## The report and the offers
|
||||
|
||||
Doc `report`: one `md` block, the headline first (Complete, Narrowed or Stopped), then scope, method and tools, the hidden and dropped counts, and the findings table with each outcome. Then each offer as a `confirm`, `--wait`, `"doc":"report"`: "Save the report" (naming `.plan2code-dead-code/reports/DEAD-CODE-<date>.md`), "Keep these findings" (the reasons asked as a `text` card after a yes), and on first save ".gitignore line".
|
||||
|
||||
Helpers are reported as `helpers`, each `done` or `failed` before the findings page goes up. Labels, picks and questions stay with you.
|
||||
|
||||
## The finish
|
||||
|
||||
`headline` the counts removed, kept and failed; `body` the summary and any file written; `"dashboard":true`; `command` `/plan2code-git` when something was removed or `keep.md` changed, otherwise none; never `commit`. A stop before removal: `body` says nothing was removed, `"command":"/plan2code-dead-code"`.
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
## The bug
|
||||
|
||||
An argument that already describes the bug skips the cards it answers. Otherwise one `--wait` batch, no `templates`:
|
||||
An argument that already describes the bug skips the cards it answers. Otherwise one `--wait` batch, no `templates`; the first card carries `"fill":"note"` (a Notebook tab fills it):
|
||||
|
||||
```jsonc
|
||||
{"title":"Diagnose a bug","headline":{"stage":"The bug","cleared":0,"total":3},"items":[{"id":"bug","kind":"text","title":"What is wrong","body":"The bug, in a sentence or two."},{"id":"expected","kind":"text","title":"Expected and actual","required":false,"body":"What should happen, and what happens instead."},{"id":"see-it","kind":"text","title":"How to see it","required":false,"body":"The steps, command, page or input that shows it, and since when if known."}]}
|
||||
{"title":"Diagnose a bug","headline":{"stage":"The bug","cleared":0,"total":3},"items":[{"id":"bug","kind":"text","title":"What is wrong","fill":"note","body":"The bug, in a sentence or two."},{"id":"expected","kind":"text","title":"Expected and actual","required":false,"body":"What should happen, and what happens instead."},{"id":"see-it","kind":"text","title":"How to see it","required":false,"body":"The steps, command, page or input that shows it, and since when if known."}]}
|
||||
```
|
||||
|
||||
A follow-up the answers leave open is a new card with a new id. A skipped card is no answer: work from the rest, never guess the missing steps, and ask again when you cannot show someone else the bug without it.
|
||||
|
||||
@@ -34,7 +34,7 @@ A later phase in the same session asks with a new id (`signoff-phase-2`, title "
|
||||
|
||||
### Show me it working
|
||||
|
||||
On `show`, run the workflow's **Show me it working** paragraph. Save screenshots under the session's `shots/`, never `specs/`, and post them as image blocks in a `shown` doc with what was run in a `md` block above (no browser tool: that block alone says what the command printed). Then reopen the same card without the `show` verdict, with a `thread` reply naming what was seen. Same on Finalize's card and the one `building-review.md` reopens; Quick Task's card is settled instead.
|
||||
On `show`, run the workflow's **Show me it working** paragraph. Save screenshots under the session's `shots/`, never `specs/`, and post them as image blocks in a `shown` doc with what was run in a `md` block above (no browser tool: that block alone says what the command printed). Then reopen the same card without the `show` verdict, with a `thread` reply naming what was seen. Same on Finalize's card and the one `building-review.md` reopens; Quick Task's card is settled instead, and a "Does it look right?" card follows it (`notes/quick-task.md`).
|
||||
|
||||
## After approval: the finish
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
- Post `"stopWarning"` while no map exists (Steps 0 to 4), `""` once it does, and `"specDir":"specs/<idea>"` when the folder is created.
|
||||
- The menu after a decision is a `menu` card: `options` are `trail --form C`'s, the `Start fresh` one keeps `"fresh":true`. Set the card's `command` to the resume command printed under `OR START FRESH`. A declined confirm leaves you the pick: carry on as for `Start fresh`.
|
||||
- The fresh-idea card carries `"templates":"idea"`, `"fill":"note"`.
|
||||
- A note on an open question: reword it (same `id`), `"_delete":true` it or send `"stands":true` on it if it still fits, in the patch with your reply.
|
||||
- A doc that is a file as written (the map, a brief) is a `file` block (`{"id":"body","file":"specs/<idea>/pathfinder/map.md"}`). Keep `md` where `assumed` / `draft` state matters.
|
||||
- Step 8 research subagents all report before the finish; the finish `body` names what each found. Report every one as a helper, whatever the Subagents switch says.
|
||||
- Every session end `finish`es with Form A's command as `command`.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Planning
|
||||
|
||||
- Phase breakdowns are an editable `list`. The fresh-idea card carries `"templates":"idea"`, `"fill":"note"`.
|
||||
- A note on an open question: reword it, `"_delete":true` it or send `"stands":true` (still fits), with your reply.
|
||||
- Nothing is saved before the Large checkpoint or Phase 7: a stop before then has `finish.body` say nothing was kept, `"command":"/plan2code-1-plan"`. After the checkpoint post `"stopWarning":""`.
|
||||
- Completion finish `command`: `/plan2code-2-document`. The Large checkpoint finish is a pause: headline starts "Paused", `command` `/plan2code-1-plan`, no `dashboard`.
|
||||
- Helpers are reported as `helpers`, each `done` or `failed` before the sign-off it feeds. Questions, sign-offs and the PLAN-DRAFT stay with you.
|
||||
@@ -3,6 +3,7 @@
|
||||
Read `building.md` first.
|
||||
|
||||
- Clarifying questions are `text` or `choice`. The first (what to build) carries `"templates":"idea"`, `"fill":"note"`.
|
||||
- A note on an open question: reword it, `"_delete":true` it or send `"stands":true` (still fits), with your reply.
|
||||
- Post `"stopWarning":"A quick task saves nothing until it is built, so stopping now loses what we have worked out."` at the start and `""` once the build is under way.
|
||||
- **Scope check:** `choice` "Too big for a quick task?": `1` Continue (lightweight format), `2` Escalate to a full plan; measured counts against thresholds in `body`.
|
||||
- **Feature name** (escalating): `text`, `"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"`, kebab-case placeholder.
|
||||
@@ -26,7 +27,7 @@ Read `building.md` first.
|
||||
```
|
||||
|
||||
A step that cannot be done is `- [!]` with the reason, not counted in `cleared`. A step added mid-build raises `headline.total` in the same post. Tick Verify boxes in the post that reports the checks. Do not `wait` until the build is done.
|
||||
- **See it running, before the finish:** once built, post `review` "See it running" (`"doc":"plan"`, verdicts `show` ("Show me it working"), `fine` ("No need, finish up"), tokens `show me` / `no`) with `--wait`. On `show`, see `notes/implement.md` → Show me it working; its one line goes in the finish `body`. Settle the card in the finish post.
|
||||
- **See it running, before the finish:** once built, post `review` "See it running" (`"doc":"plan"`, verdicts `show` ("Show me it working"), `fine` ("No need, finish up"), tokens `show me` / `no`) with `--wait`. On `show`, see `notes/implement.md` → Show me it working; its one line goes in the finish `body`. `fine` settles the card in the finish post. After `show`, settle it in the post that shows it, then post `review` "Does it look right?" (`"doc":"shown"`, verdicts `fine` ("Looks right, finish up"), `changes` ("I want changes"), tokens `approved` / `needs changes`) with `--wait`. `changes`: make it, reshow if visible, reopen with a `thread` reply, wait again. Only `fine` leads to the finish.
|
||||
- **Archive a fixed bug:** launched on a diagnosed folder and now Fixed with nothing past the diagnosis, post `confirm` "Archive this bug?" in the same post as "See it running": dry run's `files` in `body`, `yesLabel` "Archive it", `noLabel` "Keep it in specs/", `consequences` naming `specs--completed/<bug>/`. Yes: `node "<S>/specs.mjs" archive <spec>`, and say where it went in the finish `body`.
|
||||
- **Finish after the build:** `command` is the filled-in commit command in the project's format (AGENTS.md), `"where":"When you are happy with it, commit it from your terminal:"`, with `review` (**Review it now**), `"commit":true`, `"changelog":true` and `"dashboard":true`. Review and dashboard are required. Whichever button is pressed, what follows is `building-review.md`.
|
||||
- **Escalated / aborted:** settle the verdict in the finish post: `"command":"/plan2code-1-plan"` with the PLAN-DRAFT's path in `body`, no review; or `"command":"/plan2code-quick-task"`. Both `"dashboard":true`.
|
||||
|
||||
+96
-14
@@ -123,10 +123,21 @@ const QUESTION_FIELDS = ["kind", "title", "body", "options", "steps", "rows", "s
|
||||
* settle it, that record (and any stale `answer`) is dropped, so the page shows
|
||||
* the new question as open instead of "Sent, waiting for Plan2Code" forever.
|
||||
*/
|
||||
function dropStaleSubmissions(currentItems, before, patchList) {
|
||||
function dropStaleSubmissions(currentItems, before, patchList, stands = new Set()) {
|
||||
const merged = mergeKeyed(currentItems, patchList, "id", ITEM_DEFAULTS, "items");
|
||||
for (const entry of patchList) {
|
||||
const prev = (before || []).find((x) => x.id === entry.id);
|
||||
// The person's note landed on this question (`noted`, set by the server).
|
||||
// It stays until the agent deals with the question: rewords it, settles it,
|
||||
// or says in the patch that the question stands as it is.
|
||||
if (prev && prev.noted) {
|
||||
const reworded = ["title", "body", "options"].some(
|
||||
(f) => f in entry && JSON.stringify(entry[f]) !== JSON.stringify(prev[f]),
|
||||
);
|
||||
const settled = entry.status === "answered" || entry.status === "skipped" || "answer" in entry;
|
||||
const item = merged.find((x) => x.id === entry.id);
|
||||
if (item && (reworded || settled || stands.has(entry.id))) delete item.noted;
|
||||
}
|
||||
// A whole new question under an answered card's id is not a typo fix: the
|
||||
// card would stay answered and nothing would be left for the person, who
|
||||
// sees a dead page. Refuse it so the agent picks a new id on the spot.
|
||||
@@ -296,8 +307,11 @@ function settleItems(items, settle, patchItems, collected) {
|
||||
// report) means it is not settled: no answer is recorded over the reopen.
|
||||
if (entry.status === "open" || entry.status === "reopened") return item;
|
||||
const { at, kind, ...answer } = item.submitted;
|
||||
// A settled card has been dealt with, so a note on it no longer holds
|
||||
// anything up, even when it is reopened later.
|
||||
const { noted: _noted, ...settled } = item;
|
||||
return {
|
||||
...item,
|
||||
...settled,
|
||||
// A "Skip this one" send settles as skipped, not as an answer.
|
||||
status: "status" in entry ? item.status : answer.skipped === true ? "skipped" : "answered",
|
||||
...("answer" in entry ? {} : { answer }),
|
||||
@@ -531,8 +545,22 @@ export function applyPatch(state, patch) {
|
||||
break;
|
||||
case "items":
|
||||
if (!Array.isArray(v)) throw new Error(rule("", "items", "must be an array", { items: [{ id: "q7", kind: "text", title: "Name" }] }));
|
||||
next.items = dropStaleSubmissions(next.items, state.items, normalizeThreads(letterOptions(v), state.items));
|
||||
break;
|
||||
{
|
||||
// `stands: true` says "the question is still right after the note". It
|
||||
// only clears `noted`, so it is never stored.
|
||||
const stands = new Set();
|
||||
const list = v.map((entry) => {
|
||||
if (!isPlainObject(entry) || !("stands" in entry)) return entry;
|
||||
if (typeof entry.stands !== "boolean") {
|
||||
throw new Error(rule(`item "${entry.id}"`, "stands", "must be true or false", { stands: true }));
|
||||
}
|
||||
if (entry.stands) stands.add(entry.id);
|
||||
const { stands: _stands, ...rest } = entry;
|
||||
return rest;
|
||||
});
|
||||
next.items = dropStaleSubmissions(next.items, state.items, normalizeThreads(letterOptions(list), state.items), stands);
|
||||
break;
|
||||
}
|
||||
case "topics":
|
||||
if (!Array.isArray(v)) throw new Error(rule("", "topics", "must be an array", { topics: [{ id: "t2", title: "How it behaves", status: "current" }] }));
|
||||
next.topics = mergeKeyed(next.topics, v, "id", {}, "topics");
|
||||
@@ -610,9 +638,59 @@ export function applyPatch(state, patch) {
|
||||
if (next.finish && !Object.hasOwn(patch, "finish") && asksSomething(patch.items, state.items)) {
|
||||
delete next.finish;
|
||||
}
|
||||
refuseQuestionPastNote(state, next);
|
||||
return stampTimes(state, settleAgent(next, patch, state));
|
||||
}
|
||||
|
||||
/**
|
||||
* A question the person put a note on (`noted`, set by the server) stays in
|
||||
* front of them until the agent deals with it. A new question asked past it
|
||||
* would be buried behind a card the reply may have made moot, so the patch
|
||||
* that adds one must also reword, delete or confirm (`stands`) every noted
|
||||
* card. Only a new open required question counts: a reply alone, an optional
|
||||
* card or a notice asks nothing new. A finish ends the session, and the
|
||||
* dashboard draws no cards, so neither is held to it.
|
||||
*/
|
||||
function refuseQuestionPastNote(before, next) {
|
||||
if (next.finish != null || next.workflow === "dashboard" || !Array.isArray(next.items)) return;
|
||||
const noted = next.items.filter((i) => isPlainObject(i) && i.noted === true && isOpen(i));
|
||||
if (!noted.length) return;
|
||||
const had = new Set((Array.isArray(before.items) ? before.items : []).map((i) => i && i.id));
|
||||
const asksNew = next.items.some(
|
||||
(i) => isPlainObject(i) && !had.has(i.id) && i.required !== false && i.kind !== "notice" && i.noted !== true && isOpen(i),
|
||||
);
|
||||
if (!asksNew) return;
|
||||
// A note not yet replied to is named too: validate() never runs after this
|
||||
// throw, and the agent would otherwise fix one and be refused for the other.
|
||||
throw new Error(
|
||||
noted
|
||||
.flatMap((i) => [
|
||||
...(lastWordIsTheirs(i) ? [unansweredNote(i)] : []),
|
||||
rule(
|
||||
`item "${i.id}"`,
|
||||
"noted",
|
||||
'has a note from the person that you answered in the thread: reword it, delete it ("_delete": true) or send "stands": true, in the same patch that adds a new question',
|
||||
{ id: i.id, stands: true },
|
||||
),
|
||||
])
|
||||
.join("\n"),
|
||||
);
|
||||
}
|
||||
|
||||
// The person had the last word in a card's thread: their note waits for a reply.
|
||||
function lastWordIsTheirs(item) {
|
||||
const thread = Array.isArray(item.thread) ? item.thread : [];
|
||||
const last = thread[thread.length - 1];
|
||||
return isPlainObject(last) && last.who === "user";
|
||||
}
|
||||
|
||||
function unansweredNote(item) {
|
||||
return rule(`item "${item.id}"`, "thread", "has an unanswered note from the person; reply in its thread in this patch", {
|
||||
id: item.id,
|
||||
thread: [{ who: "agent", text: "..." }],
|
||||
});
|
||||
}
|
||||
|
||||
// `activity` belongs under `agent`, which is the only place the page reads it.
|
||||
// Sent at the top level it would be stored where nothing looks, and the page
|
||||
// would sit on its starting screen while the skill works.
|
||||
@@ -862,16 +940,7 @@ export function validate(state) {
|
||||
// nothing further is coming to answer into.
|
||||
if (state.finish == null) {
|
||||
for (const item of state.items) {
|
||||
const thread = Array.isArray(item.thread) ? item.thread : [];
|
||||
const last = thread[thread.length - 1];
|
||||
if (isPlainObject(last) && last.who === "user") {
|
||||
problems.push(
|
||||
rule(`item "${item.id}"`, "thread", "has an unanswered note from the person; reply in its thread in this patch", {
|
||||
id: item.id,
|
||||
thread: [{ who: "agent", text: "..." }],
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (lastWordIsTheirs(item)) problems.push(unansweredNote(item));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1300,6 +1369,19 @@ export function loopEndProblems(e, state) {
|
||||
if (!Array.isArray(e.can) || !e.can.every((c) => LOOP_CAN.includes(c))) {
|
||||
bad("can", `must be an array with entries from ${LOOP_CAN.join(", ")}`);
|
||||
}
|
||||
// `reason` (the stop screen's short heading) and `recommend` (the one button
|
||||
// drawn as primary) are optional: an older app sends neither.
|
||||
if (e.reason !== undefined) {
|
||||
if (!oneLine(e.reason, 200)) bad("reason", "must be one line of 1 to 200 characters");
|
||||
else prose("reason", e.reason);
|
||||
}
|
||||
if (e.phase !== undefined && !isPosInt(e.phase)) bad("phase", "must be a positive integer");
|
||||
if (e.recommend !== undefined && e.recommend !== null) {
|
||||
const offered = Array.isArray(e.can) ? e.can : [];
|
||||
if (!["resume", "fix", "finalize"].includes(e.recommend) || !offered.includes(e.recommend)) {
|
||||
bad("recommend", "must be resume, fix or finalize, and one of can");
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -715,12 +715,14 @@ const NOTE_FRESH_CARDS = new Set(["plan2code-0-pathfinder", "plan2code-1-plan",
|
||||
|
||||
/**
|
||||
* Whether a lit card's confirm pane offers the Notebook switch: Pathfinder,
|
||||
* Plan and Quick Task on Start fresh (no spec picked), and Revise plan on a
|
||||
* picked spec with no plan change brief waiting (a waiting brief is what that
|
||||
* revision is about). Never on a grayed card, never on any other card.
|
||||
* Plan and Quick Task on Start fresh (no spec picked), Diagnose whenever it is
|
||||
* lit (it launches untargeted, so a picked spec does not matter), and Revise
|
||||
* plan on a picked spec with no plan change brief waiting (a waiting brief is
|
||||
* what that revision is about). Never on a grayed card, never on any other card.
|
||||
*/
|
||||
export function noteSwitchShows(entry, scan, sel) {
|
||||
if (!entry || !cardAvailability(entry, scan, sel).on) return false;
|
||||
if (entry.skill === "plan2code-diagnose") return true;
|
||||
if (NOTE_FRESH_CARDS.has(entry.skill)) return !sel;
|
||||
if (entry.skill === "plan2code-1b-revise-plan") return Boolean(sel) && sel.planChange !== true;
|
||||
return false;
|
||||
|
||||
@@ -145,6 +145,9 @@
|
||||
<button type="button" class="linky" id="meter-help">What is this?</button>
|
||||
</div>
|
||||
</span>
|
||||
<!-- The spec this session works on (the dashboard picker's pick on the
|
||||
dashboard), quiet beside the meter. Hidden when there is none. -->
|
||||
<span class="spec-tag" id="spec-tag" hidden></span>
|
||||
</div>
|
||||
<div class="progress-block">
|
||||
<div class="progress-label">
|
||||
@@ -436,6 +439,13 @@
|
||||
<path d="M10 3v14.5a2 2 0 0 0 4 0V3" />
|
||||
<path d="M10 12h4" />
|
||||
</symbol>
|
||||
<!-- Clear out dead code: a skull. -->
|
||||
<symbol id="ci-dead-code" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M12 3a7 7 0 0 0-7 7c0 2.4 1.2 4.1 3 5.2V18a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.8c1.8-1.1 3-2.8 3-5.2a7 7 0 0 0-7-7z" />
|
||||
<circle cx="9.5" cy="11" r="1.5" />
|
||||
<circle cx="14.5" cy="11" r="1.5" />
|
||||
<path d="M10 19v2M12 19v2M14 19v2" />
|
||||
</symbol>
|
||||
<!-- Changelog: a version tag. -->
|
||||
<symbol id="ci-changelog" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M3 4a1 1 0 0 1 1-1h7.6a2 2 0 0 1 1.4.6l7.4 7.4a2 2 0 0 1 0 2.8l-5.6 5.6a2 2 0 0 1-2.8 0L4.6 12a2 2 0 0 1-.6-1.4z" />
|
||||
@@ -901,6 +911,35 @@
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Dead code: clearing out code nothing uses. He holds up a small
|
||||
skull whose jaw chatters, his star glancing over at it, before it
|
||||
settles and the chatter starts again. -->
|
||||
<svg class="pose pose-dead-code" data-pose="dead-code" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
|
||||
<ellipse class="shadow" cx="126" cy="198" rx="44" ry="5" />
|
||||
<g class="bob">
|
||||
<g class="dd-skull">
|
||||
<g class="dd-jaw">
|
||||
<rect class="dd-bone" x="176" y="112" width="22" height="16" rx="5" />
|
||||
<line class="lt" x1="183" y1="120" x2="183" y2="127" />
|
||||
<line class="lt" x1="191" y1="120" x2="191" y2="127" />
|
||||
</g>
|
||||
<path class="dd-bone" d="M187 88 A17 17 0 0 0 170 105 C170 112 173 116 178 119 L196 119 C201 116 204 112 204 105 A17 17 0 0 0 187 88 Z" />
|
||||
<circle class="fl" cx="180" cy="105" r="4.5" />
|
||||
<circle class="fl" cx="194" cy="105" r="4.5" />
|
||||
<path class="fl" d="M187 110 L184.5 115 L189.5 115 Z" />
|
||||
</g>
|
||||
<g transform="translate(-14 0)">
|
||||
<rect class="fl foot f1" x="94" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="fl foot f2" x="126" y="179" width="20" height="10" rx="5" />
|
||||
<rect class="sh" x="80" y="72" width="80" height="108" rx="16" />
|
||||
<path class="ln" d="M80 126 L66 150" /><circle class="fl" cx="66" cy="150" r="5.5" />
|
||||
<g class="dd-look"><path class="ey blink" d="M126 86 L129.64 94.98 L139.31 95.67 L131.9 101.92 L134.23 111.33 L126 106.2 L117.77 111.33 L120.1 101.92 L112.69 95.67 L122.36 94.98 Z" /></g>
|
||||
<path class="es" d="M110 120 Q122 129 134 120" />
|
||||
<line class="ln" x1="160" y1="126" x2="196" y2="136" />
|
||||
<circle class="fl" cx="200" cy="136" r="5.5" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<!-- Agent setup: waving hello at a terminal window, its prompt waiting
|
||||
for the command line that brings an agent. -->
|
||||
<svg class="pose pose-setup" data-pose="setup" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
|
||||
@@ -2262,6 +2301,10 @@
|
||||
is on) goes one step up (Match my session stays on the launch model),
|
||||
and the phase's helpers follow.
|
||||
</p>
|
||||
<p>
|
||||
Click a dot in a phase's row to pick (the arrow keys move along a row);
|
||||
a line steps through each row's pick so the choices read at a glance.
|
||||
</p>
|
||||
<h4>What is locked while it runs</h4>
|
||||
<p>
|
||||
Answers, sign-offs, launches, Workspace, Helpers and
|
||||
@@ -2310,15 +2353,21 @@
|
||||
the loop stops.
|
||||
</li>
|
||||
<li>
|
||||
A stop screen says what failed and shows the evidence.
|
||||
<strong>Resume the loop</strong> carries on from that phase;
|
||||
<strong>Fix it by hand</strong> opens an ordinary Implement session
|
||||
on it.
|
||||
A stop screen leads with why it stopped, and the evidence is one
|
||||
button away. Every button has a line saying what it does, and the
|
||||
one that fits the stop is highlighted.
|
||||
<strong>Continue building</strong> carries on unattended from that
|
||||
phase (recommended when the agent crashed, went quiet or you
|
||||
stopped it); <strong>Fix together with an agent</strong> opens an
|
||||
ordinary Implement session on it (recommended when a check failed,
|
||||
a task is blocked or the commit was refused).
|
||||
<strong>Ask a question</strong> wakes an agent that only answers,
|
||||
in the Ask tab. Nothing is lost on a stop: your work stays on disk.
|
||||
</li>
|
||||
</ul>
|
||||
<h4>The report</h4>
|
||||
<p>
|
||||
One report follows the whole build, across stops and Resume: what each
|
||||
One report follows the whole build, across stops and Continue building: what each
|
||||
phase built and committed, the findings it fixed, the findings it chose
|
||||
not to fix and why, the findings left open, each assumption, any other
|
||||
decisions the agent reported, and every retry and stop. The agent writes
|
||||
@@ -3632,6 +3681,11 @@
|
||||
<select id="looks-role" aria-label="Role"></select>
|
||||
<p class="help">Only puts the starter templates most useful to you first.</p>
|
||||
</fieldset>
|
||||
<fieldset data-section="intro" class="modal-ranges">
|
||||
<legend>Intro</legend>
|
||||
<label><input type="checkbox" id="looks-skip-intro" /> <span>Always SKIP Intro</span></label>
|
||||
<p class="help">A newly opened dashboard starts with Planny asleep, waiting to be woken. Tick this to go straight to the dashboard every time.</p>
|
||||
</fieldset>
|
||||
</section>
|
||||
<section class="prefs-panel" data-tab="agents">
|
||||
<div class="prefs-agents" data-section="agents">
|
||||
@@ -3675,15 +3729,47 @@
|
||||
<legend>Sounds</legend>
|
||||
<label><input type="checkbox" id="looks-sound" checked /> <span>Play sounds</span></label>
|
||||
<div class="looks-row looks-sound-events" id="looks-sound-events">
|
||||
<label><input type="checkbox" data-sound="snore" checked /> <span>Planny snoring</span></label>
|
||||
<label><input type="checkbox" data-sound="bootup" checked /> <span>Planny waking up</span></label>
|
||||
<label><input type="checkbox" data-sound="startSkill" checked /> <span>Starting a skill</span></label>
|
||||
<label><input type="checkbox" data-sound="sessionStart" checked /> <span>Session opens</span></label>
|
||||
<label><input type="checkbox" data-sound="skillReady" checked /> <span>Skill is ready</span></label>
|
||||
<label><input type="checkbox" data-sound="sessionEnd" checked /> <span>Session ends</span></label>
|
||||
<label><input type="checkbox" data-sound="question" checked /> <span>New questions for you</span></label>
|
||||
<label><input type="checkbox" data-sound="chatReply" checked /> <span>Reply on the Ask tab</span></label>
|
||||
<label><input type="checkbox" data-sound="newTab" checked /> <span>New tab added</span></label>
|
||||
<div class="sound-plain">
|
||||
<label><input type="checkbox" data-sound="snore" checked /> <span>Planny snoring</span></label>
|
||||
<label><input type="checkbox" data-sound="bootup" checked /> <span>Planny waking up</span></label>
|
||||
</div>
|
||||
<div class="sound-rows">
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="startSkill" checked /> <span>Starting a skill</span></label>
|
||||
<select data-sound-file="startSkill" aria-label="Starting a skill sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="startSkill" aria-label="Play Starting a skill sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="sessionStart" checked /> <span>Session opens</span></label>
|
||||
<select data-sound-file="sessionStart" aria-label="Session opens sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="sessionStart" aria-label="Play Session opens sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="skillReady" checked /> <span>Skill is ready</span></label>
|
||||
<select data-sound-file="skillReady" aria-label="Skill is ready sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="skillReady" aria-label="Play Skill is ready sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="sessionEnd" checked /> <span>Session ends</span></label>
|
||||
<select data-sound-file="sessionEnd" aria-label="Session ends sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="sessionEnd" aria-label="Play Session ends sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="question" checked /> <span>New questions for you</span></label>
|
||||
<select data-sound-file="question" aria-label="New questions for you sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="question" aria-label="Play New questions for you sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="chatReply" checked /> <span>Reply on the Ask tab</span></label>
|
||||
<select data-sound-file="chatReply" aria-label="Reply on the Ask tab sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="chatReply" aria-label="Play Reply on the Ask tab sound">Play</button>
|
||||
</div>
|
||||
<div class="sound-row">
|
||||
<label><input type="checkbox" data-sound="newTab" checked /> <span>New tab added</span></label>
|
||||
<select data-sound-file="newTab" aria-label="New tab added sound"><option value="sound-01">sound-01</option><option value="sound-02">sound-02</option><option value="sound-03">sound-03</option><option value="sound-04">sound-04</option><option value="sound-05">sound-05</option><option value="sound-06">sound-06</option><option value="sound-07">sound-07</option><option value="sound-08">sound-08</option><option value="sound-09">sound-09</option><option value="sound-10">sound-10</option><option value="sound-11">sound-11</option><option value="sound-12">sound-12</option><option value="sound-13">sound-13</option><option value="sound-14">sound-14</option><option value="sound-15">sound-15</option><option value="sound-16">sound-16</option><option value="sound-17">sound-17</option><option value="sound-18">sound-18</option><option value="sound-19">sound-19</option></select>
|
||||
<button type="button" class="btn ghost" data-sound-play="newTab" aria-label="Play New tab added sound">Play</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help">Ticking one plays it. Play sounds switches them all off at once and keeps your picks for when you switch back on.</p>
|
||||
</fieldset>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// `looks` is a live binding: every file reads the current object, and only
|
||||
// this file replaces it.
|
||||
|
||||
import { DEFAULT_ACCENT, soundPrefs, DEFAULT_CARD_WIDTH, ACCENTS, accentId, cardWidth, soundKey } from "./palette.js";
|
||||
import { DEFAULT_ACCENT, soundPrefs, soundFilePrefs, DEFAULT_CARD_WIDTH, ACCENTS, accentId, cardWidth, soundKey, soundFileKey } from "./palette.js";
|
||||
import { normalizeRole, ROLE_NOT_SET } from "./starters.js";
|
||||
import { bootData, hooks } from "./state.js";
|
||||
import { el } from "./render.js";
|
||||
@@ -29,8 +29,12 @@ export const DEFAULT_LOOKS = {
|
||||
accent: DEFAULT_ACCENT,
|
||||
sound: true,
|
||||
...soundPrefs(null),
|
||||
// Which sound file each pickable cue plays (soundFileQuestion: "sound-03").
|
||||
...soundFilePrefs(null),
|
||||
width: DEFAULT_CARD_WIDTH,
|
||||
hideUnavailable: true,
|
||||
// Always SKIP Intro: never play the dashboard's first-open wake-up (Planny asleep), off by default.
|
||||
skipIntro: false,
|
||||
// Activities: the top bar's die (hidden until someone turns on Show Activities), whether its games play sounds (under Play
|
||||
// sounds, which silences them too), the game last picked, and one best score
|
||||
// per listed game (activityBestSnake) or, for a game with courses, per
|
||||
@@ -59,8 +63,10 @@ export function adoptLooks(saved) {
|
||||
if (!["system", "light", "dark"].includes(looks.theme)) looks.theme = DEFAULT_LOOKS.theme;
|
||||
if (typeof looks.sound !== "boolean") looks.sound = DEFAULT_LOOKS.sound;
|
||||
Object.assign(looks, soundPrefs(looks));
|
||||
Object.assign(looks, soundFilePrefs(looks));
|
||||
if (typeof looks.hideUnavailable !== "boolean") looks.hideUnavailable = DEFAULT_LOOKS.hideUnavailable;
|
||||
looks.width = cardWidth(looks.width);
|
||||
if (typeof looks.skipIntro !== "boolean") looks.skipIntro = DEFAULT_LOOKS.skipIntro;
|
||||
if (typeof looks.hideActivities !== "boolean") looks.hideActivities = DEFAULT_LOOKS.hideActivities;
|
||||
if (typeof looks.activitySounds !== "boolean") looks.activitySounds = DEFAULT_LOOKS.activitySounds;
|
||||
if (typeof looks.gameMusic !== "boolean") looks.gameMusic = DEFAULT_LOOKS.gameMusic;
|
||||
@@ -262,7 +268,14 @@ export function renderSwatches() {
|
||||
box.checked = looks[soundKey(box.dataset.sound)];
|
||||
box.disabled = !looks.sound;
|
||||
}
|
||||
// The pick per pickable cue; a select and a play button lock with the master switch.
|
||||
for (const select of document.querySelectorAll("select[data-sound-file]")) {
|
||||
select.value = looks[soundFileKey(select.dataset.soundFile)];
|
||||
select.disabled = !looks.sound;
|
||||
}
|
||||
for (const button of document.querySelectorAll("button[data-sound-play]")) button.disabled = !looks.sound;
|
||||
$("looks-role").value = looks.role ?? ROLE_NOT_SET;
|
||||
$("looks-skip-intro").checked = looks.skipIntro;
|
||||
$("looks-activities").checked = !looks.hideActivities;
|
||||
// Like a cue, the game sounds keep their tick while Play sounds is off.
|
||||
$("looks-activity-sounds").checked = looks.activitySounds;
|
||||
|
||||
@@ -249,20 +249,40 @@ export function cardWidth(value) {
|
||||
return typeof value === "string" && Object.hasOwn(CARD_WIDTHS, value) ? value : DEFAULT_CARD_WIDTH;
|
||||
}
|
||||
|
||||
// The sound files a person can give a cue, sound-01 to sound-19, served from
|
||||
// /sounds/<name>.mp3 (static.mjs).
|
||||
export const SOUND_FILES = Array.from({ length: 19 }, (_, i) => `sound-${String(i + 1).padStart(2, "0")}`);
|
||||
|
||||
// The cues that take a picked file, in the order the picker lists them.
|
||||
// Planny snoring and waking (snore, bootup) keep their own files.
|
||||
export const PICKABLE_SOUNDS = ["startSkill", "sessionStart", "skillReady", "sessionEnd", "question", "chatReply", "newTab"];
|
||||
|
||||
// The file each pickable cue plays until a person picks another.
|
||||
export const DEFAULT_SOUND_FILE = {
|
||||
startSkill: "sound-14",
|
||||
sessionStart: "sound-07",
|
||||
sessionEnd: "sound-15",
|
||||
question: "sound-14",
|
||||
skillReady: "sound-16",
|
||||
chatReply: "sound-06",
|
||||
newTab: "sound-05",
|
||||
};
|
||||
|
||||
// Every moment the page makes a noise, each switchable on its own in User
|
||||
// Preferences (the `data-sound` boxes in index.html). Several share a file;
|
||||
// the event, not the file, is what a person turns off. `rank` settles which
|
||||
// wins when two ask at once (see the sounds section in app.js). Stored flat as
|
||||
// `soundQuestion` and so on, because looks.json only holds flat values.
|
||||
// `soundQuestion` and so on, because looks.json only holds flat values. For a
|
||||
// pickable cue `file` is its default; the pick is `soundFile<Event>` in looks.
|
||||
export const SOUND_EVENTS = {
|
||||
startSkill: { file: "start-skill", rank: 5 },
|
||||
startSkill: { file: `sounds/${DEFAULT_SOUND_FILE.startSkill}`, rank: 5 },
|
||||
bootup: { file: "bootup", rank: 4 },
|
||||
sessionStart: { file: "start-stop", rank: 3 },
|
||||
sessionEnd: { file: "start-stop", rank: 3 },
|
||||
question: { file: "next", rank: 2 },
|
||||
skillReady: { file: "next", rank: 2 },
|
||||
chatReply: { file: "next", rank: 2 },
|
||||
newTab: { file: "insert", rank: 1 },
|
||||
sessionStart: { file: `sounds/${DEFAULT_SOUND_FILE.sessionStart}`, rank: 3 },
|
||||
sessionEnd: { file: `sounds/${DEFAULT_SOUND_FILE.sessionEnd}`, rank: 3 },
|
||||
question: { file: `sounds/${DEFAULT_SOUND_FILE.question}`, rank: 2 },
|
||||
skillReady: { file: `sounds/${DEFAULT_SOUND_FILE.skillReady}`, rank: 2 },
|
||||
chatReply: { file: `sounds/${DEFAULT_SOUND_FILE.chatReply}`, rank: 2 },
|
||||
newTab: { file: `sounds/${DEFAULT_SOUND_FILE.newTab}`, rank: 1 },
|
||||
snore: { file: "sleeping", rank: 0 },
|
||||
};
|
||||
|
||||
@@ -280,3 +300,18 @@ export function soundPrefs(saved) {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export const soundFileKey = (event) => "soundFile" + event[0].toUpperCase() + event.slice(1);
|
||||
|
||||
// The picked file per pickable cue out of a saved looks object: each one as
|
||||
// saved when it names one of SOUND_FILES, the cue's default otherwise (a
|
||||
// looks.json from before the picker, a removed file, a non-string).
|
||||
export function soundFilePrefs(saved) {
|
||||
const source = saved && typeof saved === "object" ? saved : {};
|
||||
return Object.fromEntries(
|
||||
PICKABLE_SOUNDS.map((event) => {
|
||||
const value = source[soundFileKey(event)];
|
||||
return [soundFileKey(event), typeof value === "string" && SOUND_FILES.includes(value) ? value : DEFAULT_SOUND_FILE[event]];
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -4,13 +4,13 @@
|
||||
// each. No DOM access at module scope, and its one import is the data-only
|
||||
// palette.js: the page and `node --test` both import this file.
|
||||
|
||||
import { SOUND_EVENTS, soundKey } from "./palette.js";
|
||||
import { SOUND_EVENTS, soundKey, PICKABLE_SOUNDS, soundFileKey } from "./palette.js";
|
||||
|
||||
const tab = (id, label, hint, sections) => Object.freeze({ id, label, hint, sections: Object.freeze(sections) });
|
||||
|
||||
// Each section id names one fieldset in the dialog (its data-section).
|
||||
export const PREFS_TABS = Object.freeze([
|
||||
tab("appearance", "Appearance", "Theme, width, color, role", ["theme", "width", "accent", "role"]),
|
||||
tab("appearance", "Appearance", "Theme, width, color, role, intro", ["theme", "width", "accent", "role", "intro"]),
|
||||
tab("agents", "Agents & models", "Your CLIs and models", ["agents"]),
|
||||
tab("system", "System", "Cleanup, desktop app", ["cleanup", "desktop"]),
|
||||
tab("sounds", "Sounds & activities", "What plays", ["sounds", "activities"]),
|
||||
@@ -25,7 +25,7 @@ export function prefsOpenTab(asked) {
|
||||
// The looks keys Back to default resets on a tab, or null where it has
|
||||
// nothing to reset (and is hidden).
|
||||
export function prefsResetScope(tab) {
|
||||
if (tab === "appearance") return ["theme", "width", "accent", "role"];
|
||||
if (tab === "sounds") return ["sound", ...Object.keys(SOUND_EVENTS).map(soundKey), "hideActivities", "activitySounds", "gameMusic"];
|
||||
if (tab === "appearance") return ["theme", "width", "accent", "role", "skipIntro"];
|
||||
if (tab === "sounds") return ["sound", ...Object.keys(SOUND_EVENTS).map(soundKey), ...PICKABLE_SOUNDS.map(soundFileKey), "hideActivities", "activitySounds", "gameMusic"];
|
||||
return null;
|
||||
}
|
||||
@@ -760,6 +760,15 @@ export function renderAside() {
|
||||
aside.appendChild(box);
|
||||
}
|
||||
|
||||
// The agent answered a note and has not yet dealt with the question itself:
|
||||
// say so, because the reply may have changed what the question asks.
|
||||
const last = thread[thread.length - 1];
|
||||
if (item.noted === true && isOpen(item) && !finish() && last && threadWho(last) === "agent") {
|
||||
const tag = el("p", "pill noted-tag", "Plan2Code replied, check this still fits");
|
||||
tag.setAttribute("role", "note");
|
||||
aside.appendChild(tag);
|
||||
}
|
||||
|
||||
if (waiting && !waitingShown) {
|
||||
const box = el("div", "msg you pending");
|
||||
const who = el("div", "msg-who");
|
||||
|
||||
@@ -54,8 +54,8 @@ import { helperRows, showTab } from "../subagents.js";
|
||||
import { FOOTER_TIERS, footerLabel } from "../workspace.js";
|
||||
import {
|
||||
activity, agentAdrift, agentWorking, askBusy, loopDriving, loopWaiting, loopWaitingKey, asked, awaitingReply, byId, dashboardLive, docs, doingNow,
|
||||
AGENTS_VIEW, agentsTabShown, finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadAgentsDoc, loadOverview, myTurn, openItems,
|
||||
patience, pressStranded, reviewPending, scan, selSpec, sendCollected, specFileTabs, stagedCount, stranded,
|
||||
AGENTS_VIEW, agentsTabShown, finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadAgentsDoc, loadOverview, loadSpecCarry, myTurn, openItems,
|
||||
finishKey, overviewSpec, patience, pressStranded, reviewPending, scan, selSpec, sendCollected, specFileTabs, stagedCount, stranded,
|
||||
topics, workingMs, WORKING_GRACE_MS,
|
||||
workspaceFolders,
|
||||
} from "../selectors.js";
|
||||
@@ -394,6 +394,15 @@ export function adopt(body) {
|
||||
// with its own offer unanswered.
|
||||
if (!finish() && page.local.afterBuild) {
|
||||
page.local.afterBuild = null;
|
||||
page.local.afterBuildFinish = null;
|
||||
save();
|
||||
}
|
||||
// Same when the agent took the review up and posted a different finish
|
||||
// without clearing the old one: the press was on the old finish, so the new
|
||||
// finish's Commit, Changelog and Dashboard start live.
|
||||
if (page.local.afterBuild === "review" && finish() && page.local.afterBuildFinish && page.local.afterBuildFinish !== finishKey(finish())) {
|
||||
page.local.afterBuild = null;
|
||||
page.local.afterBuildFinish = null;
|
||||
save();
|
||||
}
|
||||
// A way home that ended in a finish instead (the agent paused rather than
|
||||
@@ -514,9 +523,13 @@ export function adopt(body) {
|
||||
arrived.length === 1
|
||||
? "A new question from Plan2Code. It is in the list on the left."
|
||||
: `${arrived.length} new questions from Plan2Code. They are in the list on the left.`;
|
||||
banner(staleLine ? `${staleLine} ${arrivedLine}` : arrivedLine, "info");
|
||||
// The notice stays until a click, Escape or opening the question: a
|
||||
// question that arrives mid-sentence is easy to miss in eight seconds.
|
||||
// The question already on screen needs no mark: it is where they are looking.
|
||||
for (const q of arrived) if (!(page.view === "questions" && page.selected === q.id)) page.newQuestions.add(q.id);
|
||||
arrivalNotice = staleLine ? `${staleLine} ${arrivedLine}` : arrivedLine;
|
||||
banner(arrivalNotice, "info");
|
||||
clearTimeout(arrivalBannerTimer);
|
||||
arrivalBannerTimer = setTimeout(() => !page.gone && banner(null), 8000);
|
||||
} else {
|
||||
page.selected = arrived[0].id;
|
||||
page.view = "questions";
|
||||
@@ -525,6 +538,7 @@ export function adopt(body) {
|
||||
}
|
||||
|
||||
if (!page.selected || !byId(page.selected)) page.selected = pickDefault();
|
||||
pruneNewQuestions();
|
||||
// A reply that lands while another tab is open: a dot on Ask, and one chime.
|
||||
// Not on the first load, which has nothing new to announce.
|
||||
const dot = unreadDot({ lastSeenReplyId: page.local.chat.lastSeenReplyId, frameChat: page.chatFrame, viewIsAsk: page.view === "ask" });
|
||||
@@ -536,6 +550,8 @@ export function adopt(body) {
|
||||
// A spec file tab's file changes under a build, so a tab you are watching
|
||||
// refetches on every new frame too, not only on the click that opened it.
|
||||
if (firstLoad || page.S.specDir !== prevSpecDir || page.S.workflow !== prevWorkflow || isSpecFileView(page.view)) loadOverview();
|
||||
// A New Session in the app leaves the spec it was in; the fresh dashboard picks it up once its scan is here.
|
||||
loadSpecCarry();
|
||||
// The Dashboard's AGENTS.md tab: found on arrival, re-read while it is open.
|
||||
if (firstLoad || page.S.workflow !== prevWorkflow || page.view === AGENTS_VIEW) loadAgentsDoc();
|
||||
if (announce) showArrival(announce);
|
||||
@@ -591,6 +607,24 @@ function scrollRail(where) {
|
||||
}
|
||||
|
||||
let arrivalBannerTimer = null;
|
||||
// The text of a notice that stays up (see adopt), so only that banner is cleared.
|
||||
let arrivalNotice = "";
|
||||
|
||||
function dropArrivalNotice() {
|
||||
if (arrivalNotice && $("banner").textContent === arrivalNotice) banner(null);
|
||||
arrivalNotice = "";
|
||||
}
|
||||
|
||||
// Marks that no longer apply: a question that is answered or gone, or the one
|
||||
// now on screen. The notice goes with the last mark.
|
||||
function pruneNewQuestions() {
|
||||
const had = page.newQuestions.size;
|
||||
for (const id of [...page.newQuestions]) {
|
||||
const item = byId(id);
|
||||
if (!item || !isOpen(item) || (page.view === "questions" && page.selected === id)) page.newQuestions.delete(id);
|
||||
}
|
||||
if (had && !page.newQuestions.size) dropArrivalNotice();
|
||||
}
|
||||
|
||||
// Typing in any text field, the question's own or the notes beside it. A
|
||||
// focused Markdown field surfaces as its .md-host (the editor inside its
|
||||
@@ -810,6 +844,8 @@ export function render() {
|
||||
if (rendering) return;
|
||||
rendering = true;
|
||||
try {
|
||||
// A question opened by any route (the pager, a tab switch) loses its New mark.
|
||||
pruneNewQuestions();
|
||||
trackAbout();
|
||||
const enteringAsk = page.view === "ask" && drawnView !== "ask";
|
||||
const switchingTab = drawnView !== null && page.view !== drawnView;
|
||||
@@ -1097,8 +1133,20 @@ function renderMeter() {
|
||||
);
|
||||
}
|
||||
|
||||
// The spec in hand, quiet beside the meter: the picker's pick on the
|
||||
// dashboard, the session's own spec everywhere else (overviewSpec()).
|
||||
function renderSpecTag() {
|
||||
const tag = $("spec-tag");
|
||||
const dir = isAgentless(page.S.workflow) ? "" : overviewSpec();
|
||||
const name = dir ? (isDashboard() && selSpec()?.name) || dir.replace(/^specs\//, "") : "";
|
||||
tag.hidden = !name;
|
||||
tag.textContent = name;
|
||||
tag.title = name ? "Spec: " + dir : "";
|
||||
}
|
||||
|
||||
function renderChrome() {
|
||||
renderMeter();
|
||||
renderSpecTag();
|
||||
$("title").textContent = page.S.title || "Session";
|
||||
$("badge").textContent = workflowLabel(page.S.workflow);
|
||||
renderTabTitle();
|
||||
@@ -1597,9 +1645,15 @@ export function renderSidebar() {
|
||||
mark.title = m.label;
|
||||
b.appendChild(mark);
|
||||
b.appendChild(el("span", null, item.title));
|
||||
if (page.newQuestions.has(item.id)) {
|
||||
const fresh = el("span", "rail-new", "New");
|
||||
fresh.title = "arrived while you were typing";
|
||||
b.appendChild(fresh);
|
||||
}
|
||||
b.addEventListener("click", () => {
|
||||
page.selected = item.id;
|
||||
page.view = "questions";
|
||||
pruneNewQuestions();
|
||||
render();
|
||||
$("main").focus();
|
||||
});
|
||||
@@ -1803,6 +1857,17 @@ export function renderFooter() {
|
||||
// already gone. Say what is actually outstanding instead: their own send.
|
||||
next.appendChild(el("strong", null, stranded() ? `${sent.length} saved, not picked up yet` : `${sent.length} with Plan2Code`));
|
||||
next.appendChild(document.createTextNode(" · " + sent.map((i) => i.title).join(" · ")));
|
||||
} else if (finish() && pressStranded()) {
|
||||
// Every button on the screen waits on an agent that is gone; say so, and
|
||||
// name the one way off.
|
||||
next.appendChild(el("strong", null, "Plan2Code is not running."));
|
||||
next.appendChild(
|
||||
document.createTextNode(
|
||||
page.inApp
|
||||
? " Press New Session at the top of the window, or the button above."
|
||||
: " Start a new conversation with the command above."
|
||||
)
|
||||
);
|
||||
} else if (finish()) {
|
||||
// Not "nothing to send yet". There is no yet.
|
||||
const fin = finish();
|
||||
@@ -1814,7 +1879,9 @@ export function renderFooter() {
|
||||
: finishPaused(fin)
|
||||
? " Run the command above to pick this up."
|
||||
: fin.command
|
||||
? " The next step is above."
|
||||
? String(fin.command).trim().startsWith("/")
|
||||
? " The next step is above."
|
||||
: " Run the command above in your terminal."
|
||||
: " Nothing left to run."
|
||||
)
|
||||
);
|
||||
@@ -2291,6 +2358,10 @@ export function wireChrome() {
|
||||
true
|
||||
);
|
||||
|
||||
// A click or Escape puts a staying arrival notice away; the list keeps the "New" mark.
|
||||
document.addEventListener("pointerdown", () => arrivalNotice && dropArrivalNotice(), true);
|
||||
document.addEventListener("keydown", (e) => e.key === "Escape" && arrivalNotice && dropArrivalNotice(), true);
|
||||
|
||||
$("meter-pill").addEventListener("click", () => toggleMeterPop());
|
||||
$("meter-help").addEventListener("click", () => {
|
||||
toggleMeterPop(false);
|
||||
|
||||
@@ -298,6 +298,7 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
function maybeWake() {
|
||||
if (wakeTried || page.S.wake !== true || finish()) return;
|
||||
wakeTried = true;
|
||||
if (looks.skipIntro === true) return;
|
||||
const key = "p2c-console:woke:" + page.S.sid;
|
||||
try {
|
||||
if (sessionStorage.getItem(key)) return;
|
||||
|
||||
@@ -38,6 +38,8 @@ import {
|
||||
reviewPending,
|
||||
docs,
|
||||
finish,
|
||||
finishKey,
|
||||
pressStranded,
|
||||
agentAdrift,
|
||||
agentWorking,
|
||||
awaitingReply,
|
||||
@@ -153,7 +155,7 @@ function renderCloseGuide(shape, fin = {}) {
|
||||
// A review, a commit in Git, the dashboard or the next step the person just asked for is starting
|
||||
// here, so the page is about to carry on rather than end.
|
||||
function closeGuideHeld() {
|
||||
if (page.gone) return false;
|
||||
if (page.gone || pressStranded()) return false;
|
||||
return ["review", "commit", "changelog", "dashboard", "launch"].includes(page.local.afterBuild) || reviewPending() === "asked";
|
||||
}
|
||||
|
||||
@@ -161,18 +163,55 @@ function closeGuideHeld() {
|
||||
// second press cannot send the same request twice.
|
||||
let loopPressed = null;
|
||||
|
||||
// The stop screen's Ask agent is up once the app answered a press of Ask a
|
||||
// question: from then on the button opens the Ask tab, so it can never ask the
|
||||
// app for a second agent. Keyed by the ending it was pressed on.
|
||||
let askUpFor = null;
|
||||
|
||||
// Whether the stop screen's Details is open, kept across redraws (keyed like askUpFor).
|
||||
let loopDetailsOpen = null;
|
||||
|
||||
const LOOP_BUTTONS = [
|
||||
["ask", "loop-ask", "Ask a question", ""],
|
||||
["resume", "loop-resume", "Resume the loop", "primary"],
|
||||
["fix", "loop-fix", "Fix it by hand", ""],
|
||||
["finalize", "loop-finalize", "Finalize", "primary"],
|
||||
["dashboard", "loop-dashboard", "Back to the dashboard", ""],
|
||||
["ask", "loop-ask", "Ask a question"],
|
||||
["resume", "loop-resume", "Continue building"],
|
||||
["fix", "loop-fix", "Fix together with an agent"],
|
||||
["finalize", "loop-finalize", "Finalize"],
|
||||
["dashboard", "loop-dashboard", "Back to the dashboard"],
|
||||
];
|
||||
|
||||
/** One plain sentence under each stop-screen button: what pressing it does. */
|
||||
function loopButtonLine(key, phase, askUp) {
|
||||
const at = phase ? `Phase ${phase}` : "the stopped phase";
|
||||
switch (key) {
|
||||
case "ask":
|
||||
return askUp ? "The Ask agent is ready. Type your question in the Ask tab." : "Wake an agent that answers your questions in the Ask tab. It changes nothing.";
|
||||
case "resume":
|
||||
return phase ? `Carry on unattended from Phase ${phase}, the way the loop was running.` : "Carry on unattended from where it stopped, the way the loop was running.";
|
||||
case "fix":
|
||||
return `Open a normal session on ${at} to fix this together with an agent.`;
|
||||
case "finalize":
|
||||
return "Write the feature's summary and move its spec to specs--completed/.";
|
||||
case "dashboard":
|
||||
return "Leave this screen and pick another skill. Your work stays as it is.";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** The one button drawn as primary: the app's pick when it offers it, else Continue building or Finalize. */
|
||||
function loopRecommended(end, can) {
|
||||
if (typeof end.recommend === "string" && can.includes(end.recommend)) return end.recommend;
|
||||
return ["resume", "finalize"].find((k) => can.includes(k)) || null;
|
||||
}
|
||||
|
||||
function shortHash(h) {
|
||||
return typeof h === "string" ? h.slice(0, 7) : "";
|
||||
}
|
||||
|
||||
function loopEndKey(end) {
|
||||
return `${end.kind}|${end.line}|${end.reason || ""}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* How the Implementation Loop ended, drawn from the app's `loopEnd`: a stop
|
||||
* (why, what was committed, what is left uncommitted, what can be done next) or
|
||||
@@ -183,8 +222,11 @@ export function renderLoopEnd(end) {
|
||||
const card = el("article", "card handoff loop-end");
|
||||
const finished = end.kind === "finished";
|
||||
card.appendChild(el("p", "card-kicker", finished ? "Loop finished" : "Loop stopped"));
|
||||
card.appendChild(el("h2", null, finished ? "Every phase is built" : end.line));
|
||||
if (finished && end.line) card.appendChild(el("p", "loop-line", end.line));
|
||||
// A stop leads with the app's short reason; the full line, which can run
|
||||
// long, goes under it rather than in the heading.
|
||||
const reason = !finished && typeof end.reason === "string" && end.reason ? end.reason : "";
|
||||
card.appendChild(el("h2", "loop-end-heading", finished ? "Every phase is built" : reason || end.line));
|
||||
if ((finished || reason) && end.line) card.appendChild(el("p", "loop-line", end.line));
|
||||
|
||||
const evidence = end.evidence && docs().find((d) => d.id === end.evidence);
|
||||
if (evidence) {
|
||||
@@ -197,7 +239,12 @@ export function renderLoopEnd(end) {
|
||||
card.appendChild(read);
|
||||
}
|
||||
|
||||
// The record (phases with their commits, files left uncommitted). On a stop
|
||||
// it sits under Details, below the choice, so the reason and the buttons come
|
||||
// first; the finish screen keeps its table open, since the counts are its point.
|
||||
const phases = Array.isArray(end.phases) ? end.phases : [];
|
||||
const files = Array.isArray(end.uncommitted) ? end.uncommitted : [];
|
||||
const record = [];
|
||||
if (phases.length) {
|
||||
const table = el("table", "loop-end-phases");
|
||||
const head = el("tr");
|
||||
@@ -218,46 +265,83 @@ export function renderLoopEnd(end) {
|
||||
}
|
||||
table.appendChild(row);
|
||||
}
|
||||
card.appendChild(table);
|
||||
record.push(table);
|
||||
}
|
||||
|
||||
const files = Array.isArray(end.uncommitted) ? end.uncommitted : [];
|
||||
if (files.length) {
|
||||
card.appendChild(el("h3", null, "Uncommitted in this phase"));
|
||||
record.push(el("h3", null, "Uncommitted in this phase"));
|
||||
const list = el("ul", "loop-end-files");
|
||||
const fill = (items, into) => items.forEach((f) => into.appendChild(el("li", null, f)));
|
||||
fill(files.slice(0, 10), list);
|
||||
record.push(list);
|
||||
if (files.length > 10) {
|
||||
const more = el("details");
|
||||
more.appendChild(el("summary", null, `${files.length - 10} more files`));
|
||||
const rest = el("ul", "loop-end-files");
|
||||
fill(files.slice(10), rest);
|
||||
more.appendChild(rest);
|
||||
card.append(list, more);
|
||||
} else {
|
||||
card.appendChild(list);
|
||||
record.push(more);
|
||||
}
|
||||
}
|
||||
if (finished) record.forEach((node) => card.appendChild(node));
|
||||
|
||||
const can = Array.isArray(end.can) ? end.can : [];
|
||||
const key = loopEndKey(end);
|
||||
if (page.loopAction && page.loopAction.kind === "loop-ask-result" && page.loopAction.ok) askUpFor = key;
|
||||
const askUp = askUpFor === key;
|
||||
const recommended = loopRecommended(end, can);
|
||||
// The phase Continue building starts on, as the app names it: the last row of
|
||||
// `phases` can be a phase the run never reached.
|
||||
const stoppedPhase = Number.isInteger(end.phase) && end.phase > 0 ? end.phase : null;
|
||||
|
||||
// A stop never throws work away: the app only ends the agent and, at most,
|
||||
// takes files back out of the index.
|
||||
if (!finished && can.length) card.appendChild(el("p", "loop-end-safe", "Nothing is lost. Your work stays on disk."));
|
||||
|
||||
const actions = el("div", "loop-end-actions");
|
||||
for (const [key, message, label, kind] of LOOP_BUTTONS) {
|
||||
if (!can.includes(key)) continue;
|
||||
const b = el("button", "btn" + (kind ? " " + kind : ""), label);
|
||||
for (const [k, message, label] of LOOP_BUTTONS) {
|
||||
if (!can.includes(k)) continue;
|
||||
const choice = el("div", "loop-end-choice" + (k === recommended ? " is-recommended" : ""));
|
||||
const asked = k === "ask" && askUp;
|
||||
const b = el("button", "btn" + (k === recommended ? " primary" : ""), asked ? "Open the Ask tab" : label);
|
||||
b.type = "button";
|
||||
b.disabled = page.gone || (loopPressed === message && !page.loopAction);
|
||||
b.disabled = page.gone || (!asked && loopPressed === message && !page.loopAction);
|
||||
b.addEventListener("click", () => {
|
||||
if (asked) {
|
||||
page.view = "ask";
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
// Any other press replaces the Ask agent, so its button must ask again on
|
||||
// the next stop, even one that reads the same.
|
||||
askUpFor = null;
|
||||
loopDetailsOpen = null;
|
||||
loopPressed = message;
|
||||
page.loopAction = null;
|
||||
tellApp(message);
|
||||
redraw();
|
||||
});
|
||||
actions.appendChild(b);
|
||||
choice.appendChild(b);
|
||||
choice.appendChild(el("p", "loop-end-hint", loopButtonLine(k, stoppedPhase, asked)));
|
||||
actions.appendChild(choice);
|
||||
}
|
||||
if (actions.childElementCount) card.appendChild(actions);
|
||||
if (page.loopAction && !page.loopAction.ok) {
|
||||
card.appendChild(el("p", "loop-error", page.loopAction.error));
|
||||
}
|
||||
|
||||
if (!finished && record.length) {
|
||||
const details = el("details", "loop-end-details");
|
||||
details.open = loopDetailsOpen === key;
|
||||
details.addEventListener("toggle", () => {
|
||||
loopDetailsOpen = details.open ? key : null;
|
||||
});
|
||||
const parts = [];
|
||||
if (phases.length) parts.push(phases.length === 1 ? "1 phase" : `${phases.length} phases`);
|
||||
if (files.length) parts.push(files.length === 1 ? "1 uncommitted file" : `${files.length} uncommitted files`);
|
||||
details.appendChild(el("summary", null, `Details: ${parts.join(", ")}`));
|
||||
record.forEach((node) => details.appendChild(node));
|
||||
card.appendChild(details);
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
@@ -268,6 +352,10 @@ export function renderHandoff(fin) {
|
||||
card.appendChild(el("h2", null, fin.headline));
|
||||
if (fin.body) card.appendChild(md(fin.body, "md prompt"));
|
||||
|
||||
// Every press below is waiting on an agent that is gone: the way off this
|
||||
// page must not be one of them.
|
||||
if (pressStranded()) card.appendChild(renderStrandedEscape());
|
||||
|
||||
// A finished build offers its review first, above the next step, because it
|
||||
// is the one thing on this screen that has to happen before they leave.
|
||||
const offer = reviewOffer(fin);
|
||||
@@ -333,7 +421,7 @@ export function renderHandoff(fin) {
|
||||
step.appendChild(row);
|
||||
// Under the app a clean start is the bar's New Session: one press, with
|
||||
// the command already on the clipboard to paste into the new terminal.
|
||||
if (page.inApp && command.startsWith("/") && !page.gone) {
|
||||
if (page.inApp && command.startsWith("/") && !page.gone && !pressStranded()) {
|
||||
const fresh = el("div", "handoff-newsession");
|
||||
const press = el("button", "btn small", "Start a New Session");
|
||||
press.type = "button";
|
||||
@@ -435,6 +523,45 @@ export function renderHandoff(fin) {
|
||||
return card;
|
||||
}
|
||||
|
||||
// The escape hatch of a finished screen whose press nothing collects (the
|
||||
// agent's turn ended while the page waited). Always enabled: under the app a
|
||||
// New Session, with the dashboard command copied first; in a browser the
|
||||
// command itself to run in a new conversation.
|
||||
function renderStrandedEscape() {
|
||||
const box = el("section", "review-offer stranded-escape");
|
||||
box.appendChild(el("p", "handoff-label", "Nothing is answering"));
|
||||
const text = handoffText({ command: DASHBOARD_COMMAND });
|
||||
if (page.inApp) {
|
||||
box.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"review-offer-text",
|
||||
"The buttons here cannot reach Plan2Code any more. Start a new session to carry on; the dashboard command is copied first, so paste it into the terminal panel once the new session opens."
|
||||
)
|
||||
);
|
||||
const row = el("div", "btn-row");
|
||||
const go = el("button", "btn primary", "Start a New Session");
|
||||
go.type = "button";
|
||||
go.addEventListener("click", () => startNewSession(text));
|
||||
row.appendChild(go);
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
box.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"review-offer-text",
|
||||
"The buttons here cannot reach Plan2Code any more. To carry on, run this in a new conversation:"
|
||||
)
|
||||
);
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
|
||||
// The review button, on the hand-off of a finished build (a finished quick
|
||||
// task; an implementation phase gets its review offer earlier, as a verdict
|
||||
// on the sign-off card).
|
||||
@@ -645,6 +772,7 @@ async function sendAfterBuild(kind, launch = null) {
|
||||
}
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
page.local.afterBuild = kind;
|
||||
page.local.afterBuildFinish = finishKey(finish());
|
||||
page.pendingResult = true;
|
||||
saveNow();
|
||||
const started = {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Agents & models tab is agents-view.js's.
|
||||
|
||||
import { adoptLooks, applyLooks, loadLooks, looks, renderSwatches, saveLooks, syncLooks } from "../looks.js";
|
||||
import { dropHeldSound, releaseHeldSound, sound, soundOn } from "../sound.js";
|
||||
import { dropHeldSound, previewSound, releaseHeldSound, sound, soundOn } from "../sound.js";
|
||||
import { hushTones, tone, unlockTones } from "../tones.js";
|
||||
import { hushMusic } from "../music.js";
|
||||
import { SOUND_EVENTS, soundKey } from "../palette.js";
|
||||
import { SOUND_EVENTS, soundFileKey, soundKey } from "../palette.js";
|
||||
import { ROLES, ROLE_NOT_SET, ROLE_NOT_SET_LABEL, needsRoleNudge, normalizeRole } from "../starters.js";
|
||||
import { isDashboard } from "../selectors.js";
|
||||
import { el } from "../render.js";
|
||||
@@ -96,6 +96,10 @@ export function wireLooks() {
|
||||
if (!looks.gameMusic) hushMusic();
|
||||
hooks.markSaved(fieldsetOf(e.target), saveLooks());
|
||||
});
|
||||
$("looks-skip-intro").addEventListener("change", (e) => {
|
||||
looks.skipIntro = e.target.checked;
|
||||
hooks.markSaved(fieldsetOf(e.target), saveLooks());
|
||||
});
|
||||
$("looks-activities").addEventListener("change", (e) => {
|
||||
looks.hideActivities = !e.target.checked;
|
||||
hooks.markSaved(fieldsetOf(e.target), saveLooks());
|
||||
@@ -114,6 +118,21 @@ export function wireLooks() {
|
||||
});
|
||||
}
|
||||
|
||||
// The sound picked for a cue: a change saves it and plays it once, and the
|
||||
// play button replays the current pick. Neither depends on the cue's own tick.
|
||||
for (const select of document.querySelectorAll("select[data-sound-file]")) {
|
||||
select.addEventListener("change", () => {
|
||||
looks[soundFileKey(select.dataset.soundFile)] = select.value;
|
||||
hooks.markSaved(fieldsetOf(select), saveLooks());
|
||||
previewSound(select.value);
|
||||
});
|
||||
}
|
||||
for (const button of document.querySelectorAll("button[data-sound-play]")) {
|
||||
button.addEventListener("click", () => {
|
||||
previewSound(looks[soundFileKey(button.dataset.soundPlay)]);
|
||||
});
|
||||
}
|
||||
|
||||
// Desktop app: the taskbar switch, kept by the app in its own app.json. The
|
||||
// app says what it holds once the page is up; checked until it does.
|
||||
if (framed()) {
|
||||
|
||||
@@ -378,6 +378,8 @@ function strengthBars(level) {
|
||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||
let lineGrid = null;
|
||||
let lineWatching = false;
|
||||
// The grid can change width with no window resize (Preferences' page width): watch the grid itself too.
|
||||
const lineObserver = typeof ResizeObserver === "function" ? new ResizeObserver(() => redrawLine()) : null;
|
||||
|
||||
function svgPart(name, attrs) {
|
||||
const part = document.createElementNS(SVG_NS, name);
|
||||
@@ -432,14 +434,16 @@ function redrawLine() {
|
||||
function stopWatchingLine() {
|
||||
lineGrid = null;
|
||||
if (lineWatching) window.removeEventListener("resize", redrawLine);
|
||||
if (lineObserver) lineObserver.disconnect();
|
||||
lineWatching = false;
|
||||
}
|
||||
|
||||
/** Draw once layout exists, and again on resize and when fonts load; stop once the grid is gone. */
|
||||
/** Draw once layout exists, and again on resize (the window's or the grid's) and when fonts load; stop once the grid is gone. */
|
||||
function watchStrengthLine(grid) {
|
||||
lineGrid = grid;
|
||||
if (!lineWatching) window.addEventListener("resize", redrawLine);
|
||||
lineWatching = true;
|
||||
if (lineObserver) lineObserver.observe(grid);
|
||||
requestAnimationFrame(redrawLine);
|
||||
if (document.fonts && document.fonts.ready) document.fonts.ready.then(redrawLine);
|
||||
}
|
||||
|
||||
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user