mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Add the Changes tab at sign-off: snapshot at start, diff at the end, drawn in the console
AI Assisted
This commit is contained in:
1 parent
72ae44745f
commit
f61ef6e0a7
25 files changed
+1324
-21
No files matched your search
@@ -10,6 +10,8 @@ One row per file under `src/web-console/public/` (the games and their sound are
|
|||||||
| `public/md-field.css` | The frame a Markdown field wears inside its shadow root, linked beside `notepad-editor.css`. |
|
| `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 |
|
| `public/app.js` | the page's entry and the only page file that starts anything: the start-up block. `index.html` loads it; it imports `screens/core.js` and the screens beside it |
|
||||||
| `public/doc-files.js` | a document as the page shows it, and as a file: blocks, Markdown and HTML download |
|
| `public/doc-files.js` | a document as the page shows it, and as a file: blocks, Markdown and HTML download |
|
||||||
|
| `public/diff-parse.js` | the Changes tab's parser: the unified diff `changes.mjs diff` writes, read into files, hunks and numbered lines; never throws |
|
||||||
|
| `public/diff-view.js` | the Changes tab: a `diff` doc block drawn as a file list and one unified diff, with its empty, loading and error states (Check again and Reload send `__changes`) |
|
||||||
| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, into Git, or from one skill into another off a finished screen, but never out of Git or into Review); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` |
|
| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, into Git, or from one skill into another off a finished screen, but never out of Git or into Review); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` |
|
||||||
| `public/looks.js` | how the page looks and sounds: the saved looks, their sync, and the preferences dialog's swatches |
|
| `public/looks.js` | how the page looks and sounds: the saved looks, their sync, and the preferences dialog's swatches |
|
||||||
| `public/mention-box.js` | the @name suggestions popover under a text box |
|
| `public/mention-box.js` | the @name suggestions popover under a text box |
|
||||||
@@ -51,6 +53,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
|
|||||||
| `public/styles/dashboard.css` | The dashboard: the menu, the spec picker, its confirm and the launching pane |
|
| `public/styles/dashboard.css` | The dashboard: the menu, the spec picker, its confirm and the launching pane |
|
||||||
| `public/styles/learning.css` | Learning's row (the paused amber tint, the sliding switch, the upward More menu) and the waiting banner, from the saved prototype on the page's tokens |
|
| `public/styles/learning.css` | Learning's row (the paused amber tint, the sliding switch, the upward More menu) and the waiting banner, from the saved prototype on the page's tokens |
|
||||||
| `public/styles/docs.css` | Documents and the doc tools |
|
| `public/styles/docs.css` | Documents and the doc tools |
|
||||||
|
| `public/styles/diff.css` | The Changes tab: file list, unified diff and its states, on the page's tokens (added rows `--ok`, removed rows `--warn`) |
|
||||||
| `public/styles/ending.css` | The end of a session: the hand-off and the stopping screen |
|
| `public/styles/ending.css` | The end of a session: the hand-off and the stopping screen |
|
||||||
| `public/styles/git.css` | The git board |
|
| `public/styles/git.css` | The git board |
|
||||||
| `public/styles/help.css` | The help dialog, its diagrams and its tabs |
|
| `public/styles/help.css` | The help dialog, its diagrams and its tabs |
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ Anything a workflow step decides with one correct answer (parsing a spec's check
|
|||||||
| `git.mjs` (own) | git | `state`, `plan`, `branch-check`, `init-check`, `delete-check`, `cleanup-list`, `conflicts`, `pr-url`, `classify-error`: the repo snapshot, each action's exact command and confirm text (shared by the terminal and the board), branch-name, delete, cleanup and git init checks, a stopped rebase's conflicts, the pull-request link and git's errors sorted into kinds with a next step. Read-only: the agent runs every command it prints, and `guard()` refuses force push, hook skipping, amend, remote delete and blanket add |
|
| `git.mjs` (own) | git | `state`, `plan`, `branch-check`, `init-check`, `delete-check`, `cleanup-list`, `conflicts`, `pr-url`, `classify-error`: the repo snapshot, each action's exact command and confirm text (shared by the terminal and the board), branch-name, delete, cleanup and git init checks, a stopped rebase's conflicts, the pull-request link and git's errors sorted into kinds with a next step. Read-only: the agent runs every command it prints, and `guard()` refuses force push, hook skipping, amend, remote delete and blanket add |
|
||||||
| `ui-prototype.mjs` (shared, with `ui-prototype-round.mjs`, `ui-prototype-page.mjs`, `ui-prototype-drafts.mjs`, `ui-prototype-block.mjs`) | ui-prototype, pathfinder, plan, revise-plan, quick-task (ride-along) | `sweep` (drafts older than 30 days), `new-round`, `assemble` (the page from `round.json`, the variant files and the shell in `references/ui-prototype-shell/`, images and fonts embedded; exit 4 `round-mismatch` when a drafts round's `round.json` names another `name` or `round` than its folder), `check` (the contract's rules, the three image rules `image-type`, `image-size` and `image-missing`, and the size ceiling), `open` (the default browser), `read-block` (a pasted choice block from stdin into fields) and `save` (the pair `specs/<spec>/prototypes/<name>.html` and `.md`, then that prototype's drafts removed). Writes only under `~/.plan2code/prototypes/<project key>/` and, on `save`, the spec's `prototypes/`; never writes project code, never opens a page outside the drafts or `specs/`, never fetches anything over the network. The helper modules are imported only by `ui-prototype.mjs` |
|
| `ui-prototype.mjs` (shared, with `ui-prototype-round.mjs`, `ui-prototype-page.mjs`, `ui-prototype-drafts.mjs`, `ui-prototype-block.mjs`) | ui-prototype, pathfinder, plan, revise-plan, quick-task (ride-along) | `sweep` (drafts older than 30 days), `new-round`, `assemble` (the page from `round.json`, the variant files and the shell in `references/ui-prototype-shell/`, images and fonts embedded; exit 4 `round-mismatch` when a drafts round's `round.json` names another `name` or `round` than its folder), `check` (the contract's rules, the three image rules `image-type`, `image-size` and `image-missing`, and the size ceiling), `open` (the default browser), `read-block` (a pasted choice block from stdin into fields) and `save` (the pair `specs/<spec>/prototypes/<name>.html` and `.md`, then that prototype's drafts removed). Writes only under `~/.plan2code/prototypes/<project key>/` and, on `save`, the spec's `prototypes/`; never writes project code, never opens a page outside the drafts or `specs/`, never fetches anything over the network. The helper modules are imported only by `ui-prototype.mjs` |
|
||||||
| `lessons.mjs` | dashboard, pathfinder, plan, revise-plan, document, implement(-review), review, finalize, quick-task, xray, diagnose, pr-prep, test, dead-code, ui-prototype | Learning's one script. Every answer carries `state` (`not-set-up`, `off`, `on`, `paused`, `unknown`) and `active`, decided only by `learningState()` in the bundled `web-console/learning.mjs`, which it loads at run time through `consoleModule("learning.mjs")` (exit 3 `no-console` without it), so the dashboard and the skills never disagree. `state` (the state, since when Paused for you, the waiting count, whether AGENTS.md exists, whether on the default branch) / `switch on\|off` (the team switch) / `pause on\|off` (Paused for you, refused unless On) / `read` (the lessons for the named paths and the branch's changed files, `marked` when their About files changed since, with a `run` handle so a later read hands over only new areas) / `note` (a lesson, an area, a doubt or an AGENTS.md fix, checked, then held as waiting; nothing while Off or Paused for you; a secret exits 5) / `check` (the secret refusal and the email, handle and person-name flags; reads only) / `list` (the approval list of everything waiting, new failure log lines, the first-ask card) / `decide` (applies the person's choices, or `--first-ask yes\|no`; a test map row fix carries `row` on its list item and is reworded with `row` or with `after` as its one table line, read back by `rowFromLine()` in `test-map.mjs`, and every row is validated and secret-checked again at Apply) / `log-lines` (failure log lines added since Learning was first switched on) / `areas --suggest` (first areas from the test map) / `report` (lessons per area, the oldest, marked and gone ones) / `remove --confirm` (deletes every saved lesson). Writes only the project's `.plan2code/settings.json` and `.plan2code/lessons/<area>.md`, the pointer line and upkeep sentence in the project's `AGENTS.md`, its failure log lines (moved into lessons, marked `(kept in the log)`, or added on a first-ask no), accepted fixes to `AGENTS.md` or an `.agents-docs/` file, and, through the core, the pause and the waiting lessons on this machine only, in `~/.plan2code/learning/<repository key>/`. Never stages or commits |
|
| `lessons.mjs` | dashboard, pathfinder, plan, revise-plan, document, implement(-review), review, finalize, quick-task, xray, diagnose, pr-prep, test, dead-code, ui-prototype | Learning's one script. Every answer carries `state` (`not-set-up`, `off`, `on`, `paused`, `unknown`) and `active`, decided only by `learningState()` in the bundled `web-console/learning.mjs`, which it loads at run time through `consoleModule("learning.mjs")` (exit 3 `no-console` without it), so the dashboard and the skills never disagree. `state` (the state, since when Paused for you, the waiting count, whether AGENTS.md exists, whether on the default branch) / `switch on\|off` (the team switch) / `pause on\|off` (Paused for you, refused unless On) / `read` (the lessons for the named paths and the branch's changed files, `marked` when their About files changed since, with a `run` handle so a later read hands over only new areas) / `note` (a lesson, an area, a doubt or an AGENTS.md fix, checked, then held as waiting; nothing while Off or Paused for you; a secret exits 5) / `check` (the secret refusal and the email, handle and person-name flags; reads only) / `list` (the approval list of everything waiting, new failure log lines, the first-ask card) / `decide` (applies the person's choices, or `--first-ask yes\|no`; a test map row fix carries `row` on its list item and is reworded with `row` or with `after` as its one table line, read back by `rowFromLine()` in `test-map.mjs`, and every row is validated and secret-checked again at Apply) / `log-lines` (failure log lines added since Learning was first switched on) / `areas --suggest` (first areas from the test map) / `report` (lessons per area, the oldest, marked and gone ones) / `remove --confirm` (deletes every saved lesson). Writes only the project's `.plan2code/settings.json` and `.plan2code/lessons/<area>.md`, the pointer line and upkeep sentence in the project's `AGENTS.md`, its failure log lines (moved into lessons, marked `(kept in the log)`, or added on a first-ask no), accepted fixes to `AGENTS.md` or an `.agents-docs/` file, and, through the core, the pause and the waiting lessons on this machine only, in `~/.plan2code/learning/<repository key>/`. Never stages or commits |
|
||||||
|
| `changes.mjs` | implement, implement-review, quick-task | The sign-off page's Changes tab. `start --session <folder>` snapshots the working tree (tracked, modified and new files, never ignored ones) into a git tree object through a temporary index and `git write-tree`, so the real index, HEAD, branches and working tree stay as they were, and writes the tree id to `<session>/changes-start.json`; a rerun replaces it. `diff --session <folder> [--cap 524288]` snapshots the tree now, compares it with the start tree and writes `<session>/changes.diff` (unified, `git diff --no-color -M` headers; over the cap it is cut at a file boundary with a notice, every file still named; a file that may hold a secret keeps its name and counts, its lines hidden; the counts of hidden and cut files travel as `# counts: <added> <removed> <path>` trailer lines (tab separated fields) that the page applies to files with no lines of their own), printing `{ ok, files, added, removed, truncated, hidden, file }`. Exit 3 for no repository, no snapshot or a snapshot git no longer has, 4 when git cannot snapshot. Work done before `start` never shows, and nothing has to be committed. The notes for Implement and Quick Task (`notes/implement.md`, `notes/quick-task.md`) say when to run each; the page draws the result as a `diff` doc block |
|
||||||
|
|
||||||
**Shared reference for `lessons.mjs`:** `src/shared-references/lessons.md` ships as `references/lessons.md` (through `additionalReferences`) to the same fifteen skills and the dashboard. It is the prose half of Learning: the fixed words (Learning, lesson, waiting; Not set up, Off, On, Paused for you), when a skill runs each command (Start, While working, End, unattended runs, Learning off), and that a failed call means one "Lessons could not be read this run." and carrying on without lessons.
|
**Shared reference for `lessons.mjs`:** `src/shared-references/lessons.md` ships as `references/lessons.md` (through `additionalReferences`) to the same fifteen skills and the dashboard. It is the prose half of Learning: the fixed words (Learning, lesson, waiting; Not set up, Off, On, Paused for you), when a skill runs each command (Start, While working, End, unattended runs, Learning off), and that a failed call means one "Lessons could not be read this run." and carrying on without lessons.
|
||||||
|
|
||||||
**Conventions** (`common.mjs`): Node 18+ built-ins only; one JSON object on stdout (`ok: false` plus `error`, `message`, `next` on a handled failure, the same line on stderr); exit 0 ok, 1 crash, 2 bad arguments, 3 not found, 4 invalid or check failed, 5 refused; `--help` documents commands and exit codes; writes take `--dry-run`; `PLAN2CODE_NOW` pins the clock for tests. A SKILL.md names a script as `node "<S>/<name>.mjs"`, where `<S>` is `scripts/` beside it.
|
**Conventions** (`common.mjs`): Node 18+ built-ins only; one JSON object on stdout (`ok: false` plus `error`, `message`, `next` on a handled failure, the same line on stderr); exit 0 ok, 1 crash, 2 bad arguments, 3 not found, 4 invalid or check failed, 5 refused; `--help` documents commands and exit codes; writes take `--dry-run`; `PLAN2CODE_NOW` pins the clock for tests. A SKILL.md names a script as `node "<S>/<name>.mjs"`, where `<S>` is `scripts/` beside it.
|
||||||
|
|
||||||
**Tests:** `scripts/test-skill-scripts.mjs` (installer plumbing and the shared scripts), `scripts/test-script-<skill>.mjs` (a skill's own, and the newer shared scripts: `test-script-test-map.mjs`, `test-script-test-match.mjs`, `test-script-test-commands.mjs`, `test-script-run-check.mjs`, `test-script-pr-prep.mjs`, `test-script-coverage.mjs`, `test-script-lessons.mjs`, `test-script-deps.mjs`), with fixtures from `scripts/skill-script-helpers.mjs`. Importing that module rebuilds `skills/` unless `npm_lifecycle_event` is `test` (`npm test` has just built it). Git fixtures go through `copyFixture()` (`scripts/fixture-helpers.mjs`): built once per test file, copied per test, since every `git` process costs a few hundred milliseconds on Windows; a remote inside the fixture is added with `slashed()` so the copy's `.git/config` can be pointed at its own origin. They run the built `skills/` tree, and one test fails if any SKILL.md or shipped reference names a `<S>/<name>.mjs` that skill does not ship. The per-skill scripts import `./common.mjs`, which only sits beside them in the built tree, so run them from `skills/`, not `src/`.
|
**Tests:** `scripts/test-skill-scripts.mjs` (installer plumbing and the shared scripts), `scripts/test-script-<skill>.mjs` (a skill's own, and the newer shared scripts: `test-script-test-map.mjs`, `test-script-test-match.mjs`, `test-script-test-commands.mjs`, `test-script-run-check.mjs`, `test-script-pr-prep.mjs`, `test-script-coverage.mjs`, `test-script-lessons.mjs`, `test-script-deps.mjs`, `test-script-changes.mjs`), with fixtures from `scripts/skill-script-helpers.mjs`. Importing that module rebuilds `skills/` unless `npm_lifecycle_event` is `test` (`npm test` has just built it). Git fixtures go through `copyFixture()` (`scripts/fixture-helpers.mjs`): built once per test file, copied per test, since every `git` process costs a few hundred milliseconds on Windows; a remote inside the fixture is added with `slashed()` so the copy's `.git/config` can be pointed at its own origin. They run the built `skills/` tree, and one test fails if any SKILL.md or shipped reference names a `<S>/<name>.mjs` that skill does not ship. The per-skill scripts import `./common.mjs`, which only sits beside them in the built tree, so run them from `skills/`, not `src/`.
|
||||||
@@ -11,6 +11,7 @@ Which checks cover which files, read by PR Prep and Test (`test-map.mjs read` ch
|
|||||||
| Update Dependencies script | `src/plan2code-deps-scripts/**`, `scripts/fixtures/deps/**` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-deps.mjs` | no |
|
| Update Dependencies script | `src/plan2code-deps-scripts/**`, `scripts/fixtures/deps/**` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-deps.mjs` | no |
|
||||||
| UI Prototype script and shell | `src/skill-scripts/ui-prototype*.mjs`, `src/plan2code-ui-prototype-references/**`, `scripts/fixtures/ui-prototype/**` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-ui-prototype.mjs scripts/test-ui-prototype-page.mjs` | no |
|
| UI Prototype script and shell | `src/skill-scripts/ui-prototype*.mjs`, `src/plan2code-ui-prototype-references/**`, `scripts/fixtures/ui-prototype/**` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-ui-prototype.mjs scripts/test-ui-prototype-page.mjs` | no |
|
||||||
| Lessons script | `src/skill-scripts/lessons.mjs`, `src/web-console/learning.mjs` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-lessons.mjs` | no |
|
| Lessons script | `src/skill-scripts/lessons.mjs`, `src/web-console/learning.mjs` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-lessons.mjs` | no |
|
||||||
|
| Changes tab and script | `src/skill-scripts/changes.mjs`, `src/web-console/public/diff-parse.js`, `src/web-console/public/diff-view.js`, `src/web-console/public/styles/diff.css` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-changes.mjs scripts/test-web-console-diff-parse.mjs scripts/test-web-console-page-changes.mjs` | no |
|
||||||
| Learning on the console | `src/web-console/learning.mjs`, `src/web-console/public/screens/learning-row.js`, `src/web-console/public/styles/learning.css` | `node scripts/node-test.mjs scripts/test-web-console-learning.mjs scripts/test-web-console-page-learning.mjs` | no |
|
| Learning on the console | `src/web-console/learning.mjs`, `src/web-console/public/screens/learning-row.js`, `src/web-console/public/styles/learning.css` | `node scripts/node-test.mjs scripts/test-web-console-learning.mjs scripts/test-web-console-page-learning.mjs` | no |
|
||||||
| Workflow prompts | `src/plan2code-*.md` | `node scripts/validate-char-count.js && node scripts/check-skill-table.mjs` | no |
|
| Workflow prompts | `src/plan2code-*.md` | `node scripts/validate-char-count.js && node scripts/check-skill-table.mjs` | no |
|
||||||
| Desktop app | `plan2code-app/**` | `cd plan2code-app && cargo test` | no |
|
| Desktop app | `plan2code-app/**` | `cd plan2code-app && cargo test` | no |
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# General
|
# General
|
||||||
|
|
||||||
|
### A new file under src/web-console/ needs a row in the AGENTS-architecture console files tables; run scripts/test-web-console-shape.mjs after adding one, since it fails until the row exists.
|
||||||
|
- Kind: convention
|
||||||
|
- About: scripts/test-web-console-shape.mjs, .agents-docs/AGENTS-architecture-console-page.md
|
||||||
|
- Noted: 2026-11-14, implement-review
|
||||||
|
|
||||||
### When a card in src/plan2code-deps.md changes (what it lists or asks), change the same card in src/web-console/notes/deps.md in the same edit: the console builds the card from the notes.
|
### When a card in src/plan2code-deps.md changes (what it lists or asks), change the same card in src/web-console/notes/deps.md in the same edit: the console builds the card from the notes.
|
||||||
- Kind: correction
|
- Kind: correction
|
||||||
- About: src/plan2code-deps.md, src/web-console/notes/deps.md
|
- About: src/plan2code-deps.md, src/web-console/notes/deps.md
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Details: [Status line](./.agents-docs/AGENTS-architecture-statusline.md)
|
|||||||
|
|
||||||
## Web Console
|
## 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, a spec's saved prototypes (a **Prototypes** tab: an `.md` read in place, an `.html` opened in the default browser), 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, Diagnose, UI Prototype 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 of game rows in two columns, ordered Recently played or A to Z (saved in `activityOrder`), with never-picked games under Not played yet, 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` (and the time each game was last picked in `activityPlayed<Id>`) (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 23-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, setup, Changelog, Git, Handoff and UI Prototype) 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 strenLine 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, and in Implement, Implement + Review and Quick Task a **Changes** tab: a `diff` doc block fed by the `changes.mjs` skill script, parsed by `public/diff-parse.js` and drawn by `public/diff-view.js`), build progress, the living document, a spec's saved prototypes (a **Prototypes** tab: an `.md` read in place, an `.html` opened in the default browser), 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, Diagnose, UI Prototype 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 of game rows in two columns, ordered Recently played or A to Z (saved in `activityOrder`), with never-picked games under Not played yet, 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` (and the time each game was last picked in `activityPlayed<Id>`) (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 23-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, setup, Changelog, Git, Handoff and UI Prototype) a **SLine 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`.
|
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`.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
"play": "node scripts/play.mjs",
|
"play": "node scripts/play.mjs",
|
||||||
"pretest": "node scripts/fix-line-endings.mjs",
|
"pretest": "node scripts/fix-line-endings.mjs",
|
||||||
"test:fast": "node scripts/test-fast.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-lessons.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-deps.mjs scripts/test-script-ui-prototype.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-script-changes.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-web-console-learning.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-prototypes.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-activities-bounce-arcade.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-card-rows.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-learning.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/testLine 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-lessons.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-deps.mjs scripts/test-script-ui-prototype.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-script-changes.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-web-console-learning.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-diff-parse.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-prototypes.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-activities-bounce-arcade.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-card-rows.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-changes.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-learning.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-Line truncated
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gpt-tokenizer": "2.9.0",
|
"gpt-tokenizer": "2.9.0",
|
||||||
|
|||||||
@@ -30,19 +30,19 @@ export const BUDGETS = {
|
|||||||
notes: {
|
notes: {
|
||||||
"changelog.md": 1400,
|
"changelog.md": 1400,
|
||||||
"dead-code.md": 4900,
|
"dead-code.md": 4900,
|
||||||
"deps.md": 9000, // raised by the pin, newer-Node, baseline and full-suite lines, then the fix card and the install card (8765 bytes)
|
"deps.md": 9000, // raised by the pin, newer-Node, baseline and full-suite lines, then the fix card and the install card (8823 bytes)
|
||||||
"diagnose.md": 2840, // raised by the lessons card line's bytes only
|
"diagnose.md": 2840, // raised by the lessons card line's bytes only
|
||||||
"document.md": 400,
|
"document.md": 400,
|
||||||
"finalize.md": 2000,
|
"finalize.md": 2000,
|
||||||
"git.md": 6500,
|
"git.md": 6500,
|
||||||
"handoff.md": 300,
|
"handoff.md": 300,
|
||||||
"implement.md": 5700,
|
"implement.md": 6416, // raised by the Changes tab's lines only
|
||||||
"init.md": 300,
|
"init.md": 300,
|
||||||
"loop.md": 11712, // raised by the failed report's nextStep line's bytes only
|
"loop.md": 11857, // raised by the failed report's nextStep line's and the Changes tab line's bytes only
|
||||||
"pathfinder.md": 2622, // raised by the UI prototype line's bytes only
|
"pathfinder.md": 2622, // raised by the UI prototype line's bytes only
|
||||||
"plan.md": 1023, // raised by the UI prototype line's bytes only
|
"plan.md": 1023, // raised by the UI prototype line's bytes only
|
||||||
"pr-prep.md": 4500,
|
"pr-prep.md": 4500,
|
||||||
"quick-task.md": 4869, // raised by the UI prototype line's, the prototype recap line's, the prototype archive wording's and the lessons card line's bytes only
|
"quick-task.md": 5194, // raised by the UI prototype line's, the prototype recap line's, the prototype archive wording's, the lessons card line's and the Changes tab lines' bytes only
|
||||||
"review.md": 1140, // raised by the lessons card line's bytes only
|
"review.md": 1140, // raised by the lessons card line's bytes only
|
||||||
"revise-plan.md": 1422, // raised by the UI prototype line's bytes only
|
"revise-plan.md": 1422, // raised by the UI prototype line's bytes only
|
||||||
"test.md": 5540, // raised by the lessons card line's bytes only
|
"test.md": 5540, // raised by the lessons card line's bytes only
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"test-us-english.mjs",
|
"test-us-english.mjs",
|
||||||
"test-web-console-agents-doc.mjs",
|
"test-web-console-agents-doc.mjs",
|
||||||
"test-web-console-card-rows.mjs",
|
"test-web-console-card-rows.mjs",
|
||||||
|
"test-web-console-diff-parse.mjs",
|
||||||
"test-web-console-git-board.mjs",
|
"test-web-console-git-board.mjs",
|
||||||
"test-web-console-prototypes.mjs",
|
"test-web-console-prototypes.mjs",
|
||||||
"test-web-console-send-state.mjs",
|
"test-web-console-send-state.mjs",
|
||||||
@@ -112,6 +113,7 @@
|
|||||||
"test-web-console-page-activities.mjs",
|
"test-web-console-page-activities.mjs",
|
||||||
"test-web-console-page-ask.mjs",
|
"test-web-console-page-ask.mjs",
|
||||||
"test-web-console-page-cards.mjs",
|
"test-web-console-page-cards.mjs",
|
||||||
|
"test-web-console-page-changes.mjs",
|
||||||
"test-web-console-page-dashboard.mjs",
|
"test-web-console-page-dashboard.mjs",
|
||||||
"test-web-console-page-git.mjs",
|
"test-web-console-page-git.mjs",
|
||||||
"test-web-console-page-help.mjs",
|
"test-web-console-page-help.mjs",
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ test("changes: a sensitive file shows its name and counts but no lines", () => {
|
|||||||
assert.match(diff, /^diff --git a\/\.env b\/\.env$/m);
|
assert.match(diff, /^diff --git a\/\.env b\/\.env$/m);
|
||||||
assert.match(diff, /^Lines hidden: this file may hold a secret\.$/m);
|
assert.match(diff, /^Lines hidden: this file may hold a secret\.$/m);
|
||||||
assert.match(diff, /^# hidden: \.env$/m);
|
assert.match(diff, /^# hidden: \.env$/m);
|
||||||
|
assert.match(diff, /^# counts: 2\t0\t\.env$/m, "a hidden file's counts travel in the trailer");
|
||||||
assert.match(diff, /^\+fine$/m, "other files keep their lines");
|
assert.match(diff, /^\+fine$/m, "other files keep their lines");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,301 @@
|
|||||||
|
// Web console tests, the Changes tab's parser: public/diff-parse.js reads the
|
||||||
|
// unified diff changes.mjs writes into files, hunks and numbered lines, and
|
||||||
|
// never throws on text it cannot read. Run with:
|
||||||
|
// node --test scripts/test-web-console-diff-parse.mjs
|
||||||
|
|
||||||
|
import test from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { parseDiff, HIDDEN_LINE, TOO_LARGE_LINE } from "../src/web-console/public/diff-parse.js";
|
||||||
|
|
||||||
|
const one = (text) => {
|
||||||
|
const r = parseDiff(text);
|
||||||
|
assert.equal(r.bad, undefined, "read as a diff");
|
||||||
|
assert.equal(r.files.length, 1);
|
||||||
|
return r.files[0];
|
||||||
|
};
|
||||||
|
const shape = (lines) => lines.map((l) => [l.kind, l.oldNo, l.newNo, l.text]);
|
||||||
|
|
||||||
|
test("a modified file with two hunks numbers every line from its hunk header", () => {
|
||||||
|
const f = one(
|
||||||
|
[
|
||||||
|
"diff --git a/src/app.js b/src/app.js",
|
||||||
|
"index 1111111..2222222 100644",
|
||||||
|
"--- a/src/app.js",
|
||||||
|
"+++ b/src/app.js",
|
||||||
|
"@@ -3,3 +3,4 @@ function start() {",
|
||||||
|
" one",
|
||||||
|
"-two",
|
||||||
|
"+TWO",
|
||||||
|
"+two and a half",
|
||||||
|
" three",
|
||||||
|
"@@ -20,2 +21,1 @@",
|
||||||
|
"-gone",
|
||||||
|
" kept",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(f.path, "src/app.js");
|
||||||
|
assert.equal(f.oldPath, null, "only a rename names an old path");
|
||||||
|
assert.equal(f.status, "modified");
|
||||||
|
assert.equal(f.added, 2);
|
||||||
|
assert.equal(f.removed, 2);
|
||||||
|
assert.equal(f.hunks.length, 2);
|
||||||
|
assert.equal(f.hunks[0].header, "@@ -3,3 +3,4 @@ function start() {");
|
||||||
|
assert.deepEqual(shape(f.hunks[0].lines), [
|
||||||
|
["ctx", 3, 3, "one"],
|
||||||
|
["del", 4, null, "two"],
|
||||||
|
["add", null, 4, "TWO"],
|
||||||
|
["add", null, 5, "two and a half"],
|
||||||
|
["ctx", 5, 6, "three"],
|
||||||
|
]);
|
||||||
|
assert.deepEqual(shape(f.hunks[1].lines), [
|
||||||
|
["del", 20, null, "gone"],
|
||||||
|
["ctx", 21, 21, "kept"],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an added file and a deleted file", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/new.txt b/new.txt",
|
||||||
|
"new file mode 100644",
|
||||||
|
"index 0000000..3333333",
|
||||||
|
"--- /dev/null",
|
||||||
|
"+++ b/new.txt",
|
||||||
|
"@@ -0,0 +1,2 @@",
|
||||||
|
"+hello",
|
||||||
|
"+world",
|
||||||
|
"diff --git a/old.txt b/old.txt",
|
||||||
|
"deleted file mode 100644",
|
||||||
|
"index 4444444..0000000",
|
||||||
|
"--- a/old.txt",
|
||||||
|
"+++ /dev/null",
|
||||||
|
"@@ -1 +0,0 @@",
|
||||||
|
"-bye",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.files.length, 2);
|
||||||
|
const [added, deleted] = r.files;
|
||||||
|
assert.equal(added.status, "added");
|
||||||
|
assert.equal(added.path, "new.txt");
|
||||||
|
assert.deepEqual([added.added, added.removed], [2, 0]);
|
||||||
|
assert.deepEqual(shape(added.hunks[0].lines), [
|
||||||
|
["add", null, 1, "hello"],
|
||||||
|
["add", null, 2, "world"],
|
||||||
|
]);
|
||||||
|
assert.equal(deleted.status, "deleted");
|
||||||
|
assert.equal(deleted.path, "old.txt", "a deleted file keeps its own name");
|
||||||
|
assert.deepEqual([deleted.added, deleted.removed], [0, 1]);
|
||||||
|
assert.deepEqual(shape(deleted.hunks[0].lines), [["del", 1, null, "bye"]]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a pure rename and a rename with edits", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/a/old name.md b/b/new name.md",
|
||||||
|
"similarity index 100%",
|
||||||
|
"rename from a/old name.md",
|
||||||
|
"rename to b/new name.md",
|
||||||
|
"diff --git a/lib/x.js b/lib/y.js",
|
||||||
|
"similarity index 80%",
|
||||||
|
"rename from lib/x.js",
|
||||||
|
"rename to lib/y.js",
|
||||||
|
"index 5555555..6666666 100644",
|
||||||
|
"--- a/lib/x.js",
|
||||||
|
"+++ b/lib/y.js",
|
||||||
|
"@@ -1,2 +1,2 @@",
|
||||||
|
"-const x = 1;",
|
||||||
|
"+const y = 1;",
|
||||||
|
" export {};",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.files.length, 2);
|
||||||
|
const [pure, edited] = r.files;
|
||||||
|
assert.equal(pure.status, "renamed");
|
||||||
|
assert.equal(pure.oldPath, "a/old name.md");
|
||||||
|
assert.equal(pure.path, "b/new name.md");
|
||||||
|
assert.equal(pure.hunks.length, 0);
|
||||||
|
assert.deepEqual([pure.added, pure.removed], [0, 0]);
|
||||||
|
assert.equal(edited.status, "renamed");
|
||||||
|
assert.equal(edited.oldPath, "lib/x.js");
|
||||||
|
assert.equal(edited.path, "lib/y.js");
|
||||||
|
assert.deepEqual([edited.added, edited.removed], [1, 1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a binary file and a hidden file show no lines", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/logo.png b/logo.png",
|
||||||
|
"index 7777777..8888888 100644",
|
||||||
|
"Binary files a/logo.png and b/logo.png differ",
|
||||||
|
"diff --git a/.env b/.env",
|
||||||
|
"index 9999999..aaaaaaa 100644",
|
||||||
|
HIDDEN_LINE,
|
||||||
|
"# hidden: .env",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.files.length, 2);
|
||||||
|
const [bin, secret] = r.files;
|
||||||
|
assert.equal(bin.binary, true);
|
||||||
|
assert.equal(bin.hunks.length, 0);
|
||||||
|
assert.equal(secret.path, ".env");
|
||||||
|
assert.equal(secret.hidden, true);
|
||||||
|
assert.equal(secret.hunks.length, 0);
|
||||||
|
assert.equal(secret.truncated, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a hidden file takes its counts from the trailer", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
["diff --git a/.env b/.env", "new file mode 100644", HIDDEN_LINE, "# hidden: .env", "# counts: 40\t3\t.env", ""].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.files.length, 1);
|
||||||
|
assert.equal(r.files[0].added, 40);
|
||||||
|
assert.equal(r.files[0].removed, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a truncated set: the files after the too-large line hold only a header", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/kept.txt b/kept.txt",
|
||||||
|
"--- a/kept.txt",
|
||||||
|
"+++ b/kept.txt",
|
||||||
|
"@@ -1 +1 @@",
|
||||||
|
"-a",
|
||||||
|
"+b",
|
||||||
|
TOO_LARGE_LINE,
|
||||||
|
"diff --git a/big.txt b/big.txt",
|
||||||
|
"diff --git a/moved.txt b/there.txt",
|
||||||
|
"rename from moved.txt",
|
||||||
|
"rename to there.txt",
|
||||||
|
"# truncated: true",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.tooLarge, true);
|
||||||
|
assert.equal(r.files.length, 3);
|
||||||
|
assert.equal(r.files[0].truncated, false);
|
||||||
|
assert.deepEqual(shape(r.files[0].hunks[0].lines), [
|
||||||
|
["del", 1, null, "a"],
|
||||||
|
["add", null, 1, "b"],
|
||||||
|
]);
|
||||||
|
assert.equal(r.files[1].truncated, true);
|
||||||
|
assert.equal(r.files[1].path, "big.txt");
|
||||||
|
assert.equal(r.files[2].truncated, true);
|
||||||
|
assert.equal(r.files[2].status, "renamed");
|
||||||
|
assert.equal(r.files[2].path, "there.txt");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a change set too big to print: every name first, the too-large line last, each file listed only", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/a.txt b/a.txt",
|
||||||
|
"diff --git a/old.txt b/new.txt",
|
||||||
|
"rename from old.txt",
|
||||||
|
"rename to new.txt",
|
||||||
|
"diff --git a/.env b/.env",
|
||||||
|
HIDDEN_LINE,
|
||||||
|
TOO_LARGE_LINE,
|
||||||
|
"# truncated: true",
|
||||||
|
"# hidden: .env",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(r.tooLarge, true);
|
||||||
|
assert.deepEqual(
|
||||||
|
r.files.map((f) => [f.path, f.truncated, f.hidden]),
|
||||||
|
[
|
||||||
|
["a.txt", true, false],
|
||||||
|
["new.txt", true, false],
|
||||||
|
[".env", false, true],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
assert.equal("afterCut" in r.files[0], false, "no working field leaks out");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a line starting +++ or --- inside a hunk stays a changed line", () => {
|
||||||
|
const f = one(
|
||||||
|
[
|
||||||
|
"diff --git a/notes.md b/notes.md",
|
||||||
|
"--- a/notes.md",
|
||||||
|
"+++ b/notes.md",
|
||||||
|
"@@ -1,2 +1,2 @@",
|
||||||
|
"--- a rule",
|
||||||
|
"+++ a plus rule",
|
||||||
|
" same",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.equal(f.path, "notes.md");
|
||||||
|
assert.deepEqual(shape(f.hunks[0].lines), [
|
||||||
|
["del", 1, null, "-- a rule"],
|
||||||
|
["add", null, 1, "++ a plus rule"],
|
||||||
|
["ctx", 2, 2, "same"],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a file with no newline at its end keeps the marker as a meta line", () => {
|
||||||
|
const f = one(
|
||||||
|
[
|
||||||
|
"diff --git a/end.txt b/end.txt",
|
||||||
|
"--- a/end.txt",
|
||||||
|
"+++ b/end.txt",
|
||||||
|
"@@ -1 +1 @@",
|
||||||
|
"-old",
|
||||||
|
"\\ No newline at end of file",
|
||||||
|
"+new",
|
||||||
|
"\\ No newline at end of file",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.deepEqual(shape(f.hunks[0].lines), [
|
||||||
|
["del", 1, null, "old"],
|
||||||
|
["meta", null, null, "\\ No newline at end of file"],
|
||||||
|
["add", null, 1, "new"],
|
||||||
|
["meta", null, null, "\\ No newline at end of file"],
|
||||||
|
]);
|
||||||
|
assert.deepEqual([f.added, f.removed], [1, 1], "the marker is not counted");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("paths with spaces and quoted paths", () => {
|
||||||
|
const r = parseDiff(
|
||||||
|
[
|
||||||
|
"diff --git a/with space.txt b/with space.txt",
|
||||||
|
"--- a/with space.txt\t",
|
||||||
|
"+++ b/with space.txt\t",
|
||||||
|
"@@ -1 +1,2 @@",
|
||||||
|
" a",
|
||||||
|
"+b",
|
||||||
|
'diff --git "a/say \\"hi\\".txt" "b/say \\"hi\\".txt"',
|
||||||
|
'--- "a/say \\"hi\\".txt"',
|
||||||
|
'+++ "b/say \\"hi\\".txt"',
|
||||||
|
"@@ -1 +1 @@",
|
||||||
|
"-x",
|
||||||
|
"+y",
|
||||||
|
'diff --git "a/caf\\303\\251 tab\\t.txt" "b/caf\\303\\251 tab\\t.txt"',
|
||||||
|
"new file mode 100644",
|
||||||
|
"",
|
||||||
|
].join("\n")
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
r.files.map((f) => f.path),
|
||||||
|
["with space.txt", 'say "hi".txt', "café tab\t.txt"]
|
||||||
|
);
|
||||||
|
assert.equal(r.files[0].added, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an empty string is no files, and garbage never throws", () => {
|
||||||
|
assert.deepEqual(parseDiff(""), { files: [], tooLarge: false });
|
||||||
|
for (const junk of ["hello there\nthis is not a diff\n", "@@ -1 +1 @@\n+x\n", "diff --git nonsense", "\u0000\u0001", " \n"]) {
|
||||||
|
const r = parseDiff(junk);
|
||||||
|
assert.deepEqual(r.files, [], junk);
|
||||||
|
assert.equal(r.tooLarge, false);
|
||||||
|
}
|
||||||
|
assert.equal(parseDiff("hello there\nthis is not a diff\n").bad, true);
|
||||||
|
assert.equal(parseDiff("diff --git nonsense").bad, true);
|
||||||
|
assert.equal(parseDiff(" \n").bad, undefined, "blank text is an empty diff");
|
||||||
|
assert.equal(parseDiff(undefined).bad, true);
|
||||||
|
assert.equal(parseDiff(null).bad, true);
|
||||||
|
});
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
// Page tests for the Changes tab: a `diff` doc block (a .diff file saved in the
|
||||||
|
// session folder, changes.mjs diff) drawn as a file list and one unified diff,
|
||||||
|
// with its empty, error and loading states. Run with:
|
||||||
|
// node --test scripts/test-web-console-page-changes.mjs
|
||||||
|
//
|
||||||
|
// Each test drives the real console in a real Chrome or Edge through
|
||||||
|
// scripts/page-test-helpers.mjs: one browser for the file, a fresh console
|
||||||
|
// session per test.
|
||||||
|
|
||||||
|
import test from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import { pageSuite, openSession, itemCard, textOf, styleOf, scrollCard } from "./page-test-helpers.mjs";
|
||||||
|
|
||||||
|
const suite = pageSuite(test);
|
||||||
|
|
||||||
|
// Five files: a modified one with two hunks, an added one, a binary one, a
|
||||||
|
// hidden one, then a file cut by the size cap.
|
||||||
|
const DIFF = [
|
||||||
|
"diff --git a/src/app.js b/src/app.js",
|
||||||
|
"index 1111111..2222222 100644",
|
||||||
|
"--- a/src/app.js",
|
||||||
|
"+++ b/src/app.js",
|
||||||
|
"@@ -3,3 +3,4 @@ function start() {",
|
||||||
|
" one",
|
||||||
|
"-two",
|
||||||
|
"+TWO",
|
||||||
|
"+two and a half",
|
||||||
|
" three",
|
||||||
|
"@@ -20,2 +21,2 @@",
|
||||||
|
"-gone",
|
||||||
|
"+<b>not html</b>",
|
||||||
|
" kept",
|
||||||
|
"diff --git a/docs/new.md b/docs/new.md",
|
||||||
|
"new file mode 100644",
|
||||||
|
"--- /dev/null",
|
||||||
|
"+++ b/docs/new.md",
|
||||||
|
"@@ -0,0 +1,2 @@",
|
||||||
|
"+# New",
|
||||||
|
"+Hello.",
|
||||||
|
"diff --git a/logo.png b/logo.png",
|
||||||
|
"index 7777777..8888888 100644",
|
||||||
|
"Binary files a/logo.png and b/logo.png differ",
|
||||||
|
"diff --git a/.env b/.env",
|
||||||
|
"index 9999999..aaaaaaa 100644",
|
||||||
|
"Lines hidden: this file may hold a secret.",
|
||||||
|
"\\ No more lines shown: this change is too large to show in full.",
|
||||||
|
"diff --git a/big.txt b/big.txt",
|
||||||
|
"# truncated: true",
|
||||||
|
"# hidden: .env",
|
||||||
|
"",
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
|
// A sign-off card about the report, as Implement posts it.
|
||||||
|
const SIGNOFF = {
|
||||||
|
id: "signoff",
|
||||||
|
kind: "review",
|
||||||
|
title: "Approve this phase",
|
||||||
|
doc: "report",
|
||||||
|
body: "Read the report, then approve it or say what to change.",
|
||||||
|
verdicts: [
|
||||||
|
{ id: "approve", label: "Approve this phase" },
|
||||||
|
{ id: "changes", label: "I want changes" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const REPORT = { id: "report", title: "Completion report", blocks: [{ id: "summary", md: "## Summary\n\nPhase 3 draws the Changes tab." }] };
|
||||||
|
|
||||||
|
// Opens an implement session whose Changes doc reads `text` from changes.diff.
|
||||||
|
async function withChanges(t, text, extra = {}) {
|
||||||
|
const s = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "waiting" } } });
|
||||||
|
fs.writeFileSync(path.join(s.session, "changes.diff"), text);
|
||||||
|
s.post({
|
||||||
|
docs: [REPORT, { id: "changes", title: "Changes", blocks: [{ id: "c1", diff: "changes.diff" }] }],
|
||||||
|
agent: { status: "waiting" },
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tab = (s, name) => s.page.locator("#views .view-tab", { hasText: new RegExp(`^${name}`) });
|
||||||
|
|
||||||
|
async function openChanges(s) {
|
||||||
|
await tab(s, "Changes").click();
|
||||||
|
await s.page.locator("#main .diff-view").waitFor();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The rows of the diff pane as [old number, new number, mark, text].
|
||||||
|
async function paneRows(s) {
|
||||||
|
return s.page.locator("#main .diff-pane .diff-line").evaluateAll((rows) =>
|
||||||
|
rows.map((r) => [...r.children].map((c) => c.textContent))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whether the element is fully inside the window.
|
||||||
|
async function inViewport(s, locator) {
|
||||||
|
const box = await locator.boundingBox();
|
||||||
|
const size = s.page.viewportSize();
|
||||||
|
return Boolean(box) && box.y >= 0 && box.x >= 0 && box.y + box.height <= size.height && box.x + box.width <= size.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// What the person sees break: a tab that never shows, a list without its
|
||||||
|
// counts, or the wrong line numbers on the lines.
|
||||||
|
test("the Changes tab lists each file with its counts and draws the first file's lines numbered and marked", async (t) => {
|
||||||
|
const s = await withChanges(t, DIFF);
|
||||||
|
await tab(s, "Changes").waitFor();
|
||||||
|
const tabs = await s.page.locator("#views .view-tab").allTextContents();
|
||||||
|
const report = tabs.findIndex((x) => x.startsWith("Completion report"));
|
||||||
|
assert.ok(report >= 0, `the report tab: ${tabs}`);
|
||||||
|
assert.ok(tabs[report + 1].startsWith("Changes"), `the Changes tab sits beside the report tab: ${tabs}`);
|
||||||
|
await openChanges(s);
|
||||||
|
|
||||||
|
assert.equal(await textOf(s.page.locator("#main .diff-totals")), "5 files changed, +5 -2");
|
||||||
|
assert.match(await textOf(s.page.locator("#main .diff-notice")), /too large to show in full/);
|
||||||
|
const files = s.page.locator("#main .diff-file");
|
||||||
|
assert.equal(await files.count(), 5);
|
||||||
|
const first = files.nth(0);
|
||||||
|
assert.equal(await textOf(first.locator(".diff-file-name strong")), "app.js");
|
||||||
|
assert.equal(await textOf(first.locator(".diff-file-dir")), "src");
|
||||||
|
assert.equal(await textOf(first.locator(".diff-plus")), "+3");
|
||||||
|
assert.equal(await textOf(first.locator(".diff-minus")), "-2");
|
||||||
|
assert.equal(await files.nth(1).locator(".diff-status").textContent(), "Added");
|
||||||
|
assert.equal(await first.getAttribute("aria-selected"), "true", "the first file is picked");
|
||||||
|
assert.equal(await s.page.locator("#main .diff-list").getAttribute("role"), "listbox");
|
||||||
|
|
||||||
|
assert.deepEqual(await s.page.locator("#main .diff-hunk").allTextContents(), ["@@ -3,3 +3,4 @@ function start() {", "@@ -20,2 +21,2 @@"]);
|
||||||
|
assert.deepEqual(await paneRows(s), [
|
||||||
|
["3", "3", "", "one"],
|
||||||
|
["4", "", "-", "two"],
|
||||||
|
["", "4", "+", "TWO"],
|
||||||
|
["", "5", "+", "two and a half"],
|
||||||
|
["5", "6", "", "three"],
|
||||||
|
["20", "", "-", "gone"],
|
||||||
|
["", "21", "+", "<b>not html</b>"],
|
||||||
|
["21", "22", "", "kept"],
|
||||||
|
]);
|
||||||
|
// Diff text is never HTML: the tag stays text.
|
||||||
|
assert.equal(await s.page.locator("#main .diff-pane b").count(), 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("clicking a file or pressing the arrows swaps the diff, and binary, hidden and cut files show one plain line", async (t) => {
|
||||||
|
const s = await withChanges(t, DIFF);
|
||||||
|
await openChanges(s);
|
||||||
|
const files = s.page.locator("#main .diff-file");
|
||||||
|
const pane = s.page.locator("#main .diff-pane");
|
||||||
|
|
||||||
|
await files.nth(1).click();
|
||||||
|
await pane.locator(".diff-pane-path", { hasText: "docs/new.md" }).waitFor();
|
||||||
|
assert.deepEqual(await paneRows(s), [
|
||||||
|
["", "1", "+", "# New"],
|
||||||
|
["", "2", "+", "Hello."],
|
||||||
|
]);
|
||||||
|
assert.equal(await files.nth(1).getAttribute("aria-selected"), "true");
|
||||||
|
assert.equal(await files.nth(0).getAttribute("aria-selected"), "false");
|
||||||
|
|
||||||
|
const plain = [
|
||||||
|
[2, "logo.png", "Binary file: no lines to show"],
|
||||||
|
[3, ".env", "Lines hidden: this file may hold a secret"],
|
||||||
|
[4, "big.txt", "Too large to show in full: this file is listed only"],
|
||||||
|
];
|
||||||
|
for (const [i, name, line] of plain) {
|
||||||
|
await files.nth(i).click();
|
||||||
|
await pane.locator(".diff-pane-path", { hasText: name }).waitFor();
|
||||||
|
assert.equal(await textOf(pane.locator(".diff-plain")), line, name);
|
||||||
|
assert.equal(await pane.locator(".diff-line").count(), 0, `${name} shows no lines`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arrow keys on the list move the pick.
|
||||||
|
await s.page.locator("#main .diff-list").focus();
|
||||||
|
await s.page.keyboard.press("ArrowUp");
|
||||||
|
await pane.locator(".diff-pane-path", { hasText: ".env" }).waitFor();
|
||||||
|
await s.page.keyboard.press("Home");
|
||||||
|
await pane.locator(".diff-pane-path", { hasText: "src/app.js" }).waitFor();
|
||||||
|
assert.equal(await files.nth(0).getAttribute("aria-selected"), "true");
|
||||||
|
|
||||||
|
// The pick survives a redraw of the same block.
|
||||||
|
await files.nth(1).click();
|
||||||
|
s.post({ title: "Phase 3, again" });
|
||||||
|
await s.page.waitForFunction(() => document.getElementById("title").textContent.includes("Phase 3, again"));
|
||||||
|
await pane.locator(".diff-pane-path", { hasText: "docs/new.md" }).waitFor();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the empty state offers Check again, which sends the __changes action", async (t) => {
|
||||||
|
const s = await withChanges(t, "");
|
||||||
|
await openChanges(s);
|
||||||
|
const empty = s.page.locator("#main .diff-empty");
|
||||||
|
assert.equal(await textOf(empty.locator(".diff-state-msg")), "Nothing has changed since this run started.");
|
||||||
|
await empty.getByRole("button", { name: "Check again" }).click();
|
||||||
|
const got = s.wait(10);
|
||||||
|
assert.equal(got.code, 0, `nothing was sent (wait exit ${got.code})`);
|
||||||
|
assert.ok(got.actions.some((a) => a.i === "__changes" && a.type === "changes"), JSON.stringify(got.actions));
|
||||||
|
assert.match(got.reply, /Changes tab/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// What the person sees break: a click on a finished session that leaves the
|
||||||
|
// page waiting for an agent who has gone.
|
||||||
|
test("on a finished session Check again sends nothing and says why", async (t) => {
|
||||||
|
const s = await withChanges(t, "");
|
||||||
|
s.post({ finish: { headline: "Phase 3 is done", body: "7 of 7 tasks." } });
|
||||||
|
await s.page.waitForFunction(() => document.body.textContent.includes("Phase 3 is done"));
|
||||||
|
await openChanges(s);
|
||||||
|
const empty = s.page.locator("#main .diff-empty");
|
||||||
|
await empty.getByRole("button", { name: "Check again" }).click();
|
||||||
|
await empty.locator(".diff-state-why", { hasText: "This session is finished." }).waitFor();
|
||||||
|
assert.equal(s.wait(2).code, 10, "nothing reached the agent");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a block with an error shows the reason and a Reload button that sends the __changes action", async (t) => {
|
||||||
|
const s = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "waiting" } } });
|
||||||
|
s.post({ docs: [{ id: "changes", title: "Changes", blocks: [{ id: "c1", error: "No snapshot was taken at the start of this run." }] }] });
|
||||||
|
await tab(s, "Changes").click();
|
||||||
|
const box = s.page.locator("#main .diff-error");
|
||||||
|
await box.waitFor();
|
||||||
|
assert.equal(await textOf(box.locator(".diff-state-msg")), "The changes could not be read: No snapshot was taken at the start of this run.");
|
||||||
|
await box.getByRole("button", { name: "Reload the changes" }).click();
|
||||||
|
const got = s.wait(10);
|
||||||
|
assert.equal(got.code, 0, `nothing was sent (wait exit ${got.code})`);
|
||||||
|
assert.ok(got.actions.some((a) => a.i === "__changes" && a.type === "changes"), JSON.stringify(got.actions));
|
||||||
|
|
||||||
|
// A stale doc is still being read again: the loading rows show.
|
||||||
|
fs.writeFileSync(path.join(s.session, "changes.diff"), DIFF);
|
||||||
|
s.post({ docs: [{ id: "changes", stale: true, blocks: [{ id: "c1", diff: "changes.diff" }] }] });
|
||||||
|
await s.page.locator("#main .diff-view.is-loading .diff-skel-row").first().waitFor();
|
||||||
|
});
|
||||||
|
|
||||||
|
// What the person sees break: a long diff pushing the way to the sign-off off
|
||||||
|
// the screen, or a long line widening the page.
|
||||||
|
test("a long diff scrolls inside its own pane, the way back to the sign-off stays in view, and the added rows differ by theme", async (t) => {
|
||||||
|
const long = Array.from({ length: 640 }, (_, i) => `+line ${i + 1} ${i === 3 ? "x".repeat(600) : ""}`);
|
||||||
|
const text = ["diff --git a/long.txt b/long.txt", "new file mode 100644", "--- /dev/null", "+++ b/long.txt", "@@ -0,0 +1,640 @@", ...long, ""].join("\n");
|
||||||
|
const s = await withChanges(t, text, { items: [SIGNOFF] });
|
||||||
|
await itemCard(s.page, "signoff").waitFor();
|
||||||
|
await openChanges(s);
|
||||||
|
const pane = s.page.locator("#main .diff-pane");
|
||||||
|
assert.equal(await pane.locator(".diff-line").count(), 640);
|
||||||
|
|
||||||
|
// The pane scrolls itself; the column and the page do not grow past the window.
|
||||||
|
const sizes = await pane.evaluate((p) => ({ inner: p.scrollHeight > p.clientHeight, page: document.documentElement.scrollWidth <= window.innerWidth }));
|
||||||
|
assert.ok(sizes.inner, "the diff pane scrolls inside itself");
|
||||||
|
assert.ok(sizes.page, "a long line never gives the page a sideways scroll");
|
||||||
|
// The pane itself scrolls sideways, so its scrollbar sits at the window's
|
||||||
|
// edge of the pane, not under the file's last line.
|
||||||
|
assert.ok(await pane.evaluate((p) => p.scrollWidth > p.clientWidth), "the long line scrolls inside the diff pane");
|
||||||
|
await scrollCard(pane, "end");
|
||||||
|
const back = s.page.locator("#main .doc-head .back-home");
|
||||||
|
assert.ok(await inViewport(s, back), "Back to Questions stays in view with the diff scrolled to its end");
|
||||||
|
assert.ok(await inViewport(s, pane), "the whole diff pane fits in the window");
|
||||||
|
|
||||||
|
// One click from the Changes tab, the sign-off's verdicts are on screen.
|
||||||
|
await back.click();
|
||||||
|
const card = itemCard(s.page, "signoff");
|
||||||
|
await card.waitFor();
|
||||||
|
for (const name of ["Approve this phase", "I want changes"]) {
|
||||||
|
assert.ok(await inViewport(s, card.getByRole("button", { name })), `${name} is inside the window`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await openChanges(s);
|
||||||
|
const added = s.page.locator("#main .diff-line.add").first();
|
||||||
|
await s.page.evaluate(() => document.documentElement.setAttribute("data-theme", "light"));
|
||||||
|
const light = await styleOf(added, "backgroundColor");
|
||||||
|
await s.page.evaluate(() => document.documentElement.setAttribute("data-theme", "dark"));
|
||||||
|
const dark = await styleOf(added, "backgroundColor");
|
||||||
|
assert.notEqual(light, dark, "the added rows take the theme's own soft color");
|
||||||
|
assert.notEqual(light, "rgba(0, 0, 0, 0)");
|
||||||
|
});
|
||||||
@@ -1048,6 +1048,49 @@ test("a diff block reads a .diff file in the session folder, refreshes and turns
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// When the changes could not be read, the agent sends the plain reason as the
|
||||||
|
// block's `error` instead of a diff; a diff sent later replaces it.
|
||||||
|
test("a diff block may carry one line of error instead of a diff, never both", () => {
|
||||||
|
const res = cli(["open", "--workflow", "implement", "--no-open"]);
|
||||||
|
const sid = res.json.sid;
|
||||||
|
const dir = res.json.session;
|
||||||
|
const post = (name, patch, opts) => cli(["post", "--session", sid, "--file", payload(name, patch)], opts);
|
||||||
|
const block = () => readState(dir).docs.find((d) => d.id === "changes").blocks[0];
|
||||||
|
try {
|
||||||
|
post("err-ok.json", { docs: [{ id: "changes", title: "Changes", blocks: [{ id: "c1", error: " No snapshot was taken at the start of this run. " }] }] });
|
||||||
|
assert.equal(block().error, "No snapshot was taken at the start of this run.");
|
||||||
|
assert.equal(block().diff, undefined);
|
||||||
|
assert.equal(block().text, undefined);
|
||||||
|
assert.equal(block().state, "settled");
|
||||||
|
|
||||||
|
for (const [name, b, why] of [
|
||||||
|
["err-both.json", { id: "c1", diff: "changes.diff", error: "x" }, /carries "diff" or "error", never both/],
|
||||||
|
["err-md.json", { id: "c1", error: "x", md: "text" }, /an error block cannot also carry "md", "file" or "image"/],
|
||||||
|
["err-lines.json", { id: "c1", error: "one\ntwo" }, /must be one line of prose/],
|
||||||
|
["err-blank.json", { id: "c1", error: " " }, /must be one line of prose/],
|
||||||
|
["err-type.json", { id: "c1", error: 3 }, /must be one line of prose/],
|
||||||
|
]) {
|
||||||
|
fs.writeFileSync(path.join(dir, "changes.diff"), "diff --git a/a b/a\n");
|
||||||
|
const r = post(name, { docs: [{ id: "changes", blocks: [b] }] }, { expectFail: true });
|
||||||
|
assert.equal(r.status, 3, name);
|
||||||
|
assert.match(r.stderr, why, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A diff over it clears the error, and an error over a diff clears the text.
|
||||||
|
const text = "diff --git a/a.txt b/a.txt\n--- a/a.txt\n+++ b/a.txt\n@@ -1 +1 @@\n-old\n+new\n";
|
||||||
|
fs.writeFileSync(path.join(dir, "changes.diff"), text);
|
||||||
|
post("err-to-diff.json", { docs: [{ id: "changes", blocks: [{ id: "c1", diff: "changes.diff" }] }] });
|
||||||
|
assert.equal(block().text, text);
|
||||||
|
assert.equal(block().error, undefined);
|
||||||
|
post("diff-to-err.json", { docs: [{ id: "changes", blocks: [{ id: "c1", error: "The snapshot is gone." }] }] });
|
||||||
|
assert.equal(block().error, "The snapshot is gone.");
|
||||||
|
assert.equal(block().diff, undefined);
|
||||||
|
assert.equal(block().text, undefined);
|
||||||
|
} finally {
|
||||||
|
cli(["stop", "--session", sid, "--force"]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test("a diff block refuses a path, a wrong extension, a missing file and a link out of the session folder", () => {
|
test("a diff block refuses a path, a wrong extension, a missing file and a link out of the session folder", () => {
|
||||||
const res = cli(["open", "--workflow", "implement", "--no-open"]);
|
const res = cli(["open", "--workflow", "implement", "--no-open"]);
|
||||||
const sid = res.json.sid;
|
const sid = res.json.sid;
|
||||||
|
|||||||
@@ -245,6 +245,21 @@ function sumNumstat(text) {
|
|||||||
return { added, removed };
|
return { added, removed };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Per-file counts from `numstat -z`, keyed by the new path; a binary file counts 0. */
|
||||||
|
function fileCounts(text) {
|
||||||
|
const tok = (text || "").split("\0");
|
||||||
|
const counts = new Map();
|
||||||
|
for (let i = 0; i < tok.length && tok[i]; ) {
|
||||||
|
const m = /^(\d+|-)\t(\d+|-)\t([\s\S]*)$/.exec(tok[i]);
|
||||||
|
if (!m) break;
|
||||||
|
const renamed = m[3] === "";
|
||||||
|
const key = renamed ? tok[i + 2] : m[3];
|
||||||
|
counts.set(key, [/^\d+$/.test(m[1]) ? Number(m[1]) : 0, /^\d+$/.test(m[2]) ? Number(m[2]) : 0]);
|
||||||
|
i += renamed ? 3 : 1;
|
||||||
|
}
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- commands */
|
/* ------------------------------------------------------------- commands */
|
||||||
|
|
||||||
function sessionFolder(args) {
|
function sessionFolder(args) {
|
||||||
@@ -300,6 +315,13 @@ async function diffCommand(args) {
|
|||||||
const trailer = [];
|
const trailer = [];
|
||||||
if (capped.truncated) trailer.push("# truncated: true");
|
if (capped.truncated) trailer.push("# truncated: true");
|
||||||
for (const p of shown.hidden) trailer.push(`# hidden: ${p}`);
|
for (const p of shown.hidden) trailer.push(`# hidden: ${p}`);
|
||||||
|
// Hidden and cut files carry no lines for the page to count: give it their counts.
|
||||||
|
if (shown.hidden.length || capped.truncated) {
|
||||||
|
const counts = fileCounts(git(top, ["diff", "--numstat", "-z", "-M", "--no-ext-diff", start.tree, now]));
|
||||||
|
for (const [p, [a, d]] of counts) {
|
||||||
|
if ((capped.truncated || shown.hidden.includes(p)) && !/[\t\n]/.test(p)) trailer.push(`# counts: ${a}\t${d}\t${p}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (trailer.length) text += (text && !text.endsWith("\n") ? "\n" : "") + trailer.join("\n") + "\n";
|
if (trailer.length) text += (text && !text.endsWith("\n") ? "\n" : "") + trailer.join("\n") + "\n";
|
||||||
|
|
||||||
fs.mkdirSync(session, { recursive: true });
|
fs.mkdirSync(session, { recursive: true });
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Docs and their blocks merge by `id`; a new id is added at the end. Patch blocks
|
|||||||
- `md`: markdown you write.
|
- `md`: markdown you write.
|
||||||
- `file`: the console reads the text from that project file (inside the project, 512 KB at most). Re-send the block, or the doc with `"refresh":true`, after the file changes. `"select":"tasks"` keeps only its `- [ ] **Task N.M:**` lines. Never paste a file you can name.
|
- `file`: the console reads the text from that project file (inside the project, 512 KB at most). Re-send the block, or the doc with `"refresh":true`, after the file changes. `"select":"tasks"` keeps only its `- [ ] **Task N.M:**` lines. Never paste a file you can name.
|
||||||
- `image`: `{"id":"s1","image":"shots/run.png","alt":"..."}`: a PNG, JPEG or WebP (5 MB at most) saved directly in the session's `shots/` folder (the `session` path `open` printed), named with letters, digits, `.`, `_` or `-`. Anything else is exit 3.
|
- `image`: `{"id":"s1","image":"shots/run.png","alt":"..."}`: a PNG, JPEG or WebP (5 MB at most) saved directly in the session's `shots/` folder (the `session` path `open` printed), named with letters, digits, `.`, `_` or `-`. Anything else is exit 3.
|
||||||
- `diff`: `{"id":"changes","diff":"changes.diff"}`: a unified diff `changes.mjs diff` wrote, saved directly in the session folder (a name ending `.diff`, 512 KB at most, longer text is cut). The page draws it as the Changes tab. Never paste a diff you can name; re-send the block after running `changes.mjs diff` again.
|
- `diff`: `{"id":"changes","diff":"changes.diff"}`: a unified diff `changes.mjs diff` wrote, saved directly in the session folder (a name ending `.diff`, 512 KB at most, longer text is cut). The page draws it as the Changes tab. Never paste a diff you can name; re-send the block after running `changes.mjs diff` again. When the changes could not be read, send `{"id":"changes","error":"<one line: why>"}` instead (never both): the tab shows the reason and a Reload button.
|
||||||
|
|
||||||
## State
|
## State
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
## First post of a phase
|
## First post of a phase
|
||||||
|
|
||||||
|
Before the first task, snapshot the tree for the Changes tab: `node "<S>/changes.mjs" start --session <session folder>` (the `session` path `open` printed, not the sid; once per phase, a rerun replaces the snapshot). A non-zero exit: say so in one line and carry on; the sign-off's `diff` then posts the error.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{"headline":{"stage":"Phase 3: API layer","cleared":0,"total":9},"docs":[{"id":"phasefile","title":"phase-3.md","blocks":[{"id":"body","file":"specs/<feature>/phase-3.md"}]}],"agent":{"status":"working","activity":"Checking the prerequisites","quietMinutes":15}}
|
{"headline":{"stage":"Phase 3: API layer","cleared":0,"total":9},"docs":[{"id":"phasefile","title":"phase-3.md","blocks":[{"id":"body","file":"specs/<feature>/phase-3.md"}]}],"agent":{"status":"working","activity":"Checking the prerequisites","quietMinutes":15}}
|
||||||
```
|
```
|
||||||
@@ -28,6 +30,8 @@ Loop mode (`notes/loop.md`) posts `loopOutcome` instead. Otherwise the Completio
|
|||||||
{"docs":[{"id":"report","title":"Completion report","blocks":[{"id":"summary","state":"settled","md":"## Summary\n\n..."},{"id":"files","state":"settled","md":"## Files\n\n..."},{"id":"verify","state":"settled","md":"## How to check it\n\n..."}]}],"items":[{"id":"signoff","kind":"review","title":"Approve this phase","doc":"report","body":"Phase 3 is built. Read the report, try the checks, then approve it, review the code first, see it running, or say what to change.","verdicts":[{"id":"review","label":"Review the code first"},{"id":"approve","label":"Approve this phase"},{"id":"show","label":"Show me it working"},{"id":"changes","label":"I want changes"}],"token":{"approve":"approved","changes":"needs changes","show":"show me"},"nothingYet":"Nothing is marked complete until you approve.","gate":{"id":"signoff","authoritative":true}}]}
|
{"docs":[{"id":"report","title":"Completion report","blocks":[{"id":"summary","state":"settled","md":"## Summary\n\n..."},{"id":"files","state":"settled","md":"## Files\n\n..."},{"id":"verify","state":"settled","md":"## How to check it\n\n..."}]}],"items":[{"id":"signoff","kind":"review","title":"Approve this phase","doc":"report","body":"Phase 3 is built. Read the report, try the checks, then approve it, review the code first, see it running, or say what to change.","verdicts":[{"id":"review","label":"Review the code first"},{"id":"approve","label":"Approve this phase"},{"id":"show","label":"Show me it working"},{"id":"changes","label":"I want changes"}],"token":{"approve":"approved","changes":"needs changes","show":"show me"},"nothingYet":"Nothing is marked complete until you approve.","gate":{"id":"signoff","authoritative":true}}]}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Changes tab:** first run `node "<S>/changes.mjs" diff --session <session folder>`, then add a second doc after `report` in the same post: `{"id":"changes","title":"Changes","blocks":[{"id":"diff","diff":"changes.diff"}]}` (the card keeps `"doc":"report"`). `files: 0` posts it as is. A non-zero exit sends `{"id":"diff","error":"<its message, one line>"}` instead; the sign-off goes on. On an `__changes` send (the tab's Check again or Reload button), run `diff` again, re-send the block (`"refresh":true` on the doc while it stays a diff), then wait as usual. Code changed before the card reopens (a `changes` verdict, a note's change, review fixes): run `diff` again and re-send the block in that post. A later phase re-sends the doc after its new `start`.
|
||||||
|
|
||||||
Posted with `--wait`. An approval whose note asks for a change: do the change first and ask again. `changes`: address it, update the report, reopen the item with a `thread` reply. `review`: read `building-review.md`. `show`: below.
|
Posted with `--wait`. An approval whose note asks for a change: do the change first and ask again. `changes`: address it, update the report, reopen the item with a `thread` reply. `review`: read `building-review.md`. `show`: below.
|
||||||
|
|
||||||
A later phase in the same session asks with a new id (`signoff-phase-2`, title "Approve Phase 2"); the old card is a record.
|
A later phase in the same session asks with a new id (`signoff-phase-2`, title "Approve Phase 2"); the old card is a record.
|
||||||
@@ -62,4 +66,4 @@ Yes: `specs.mjs tick`, `{"headline":{"cleared":N}}` with the next item. After th
|
|||||||
|
|
||||||
## Implement + Review (`implement-review`)
|
## Implement + Review (`implement-review`)
|
||||||
|
|
||||||
Stage 2 publishes findings as in `building-review.md` (The findings). Stage 3 has no "Check the fixes" item. The post starting Stage 2 carries `"run":{"event":"review","id":"review"}` (scores 1 point; the final `run` leaves it out). Stage 4 is the sign-off above, `show` included, without the `review` verdict, with review results and unresolved findings in the report and "Reviewed and ready for sign-off" in `body`. Its finish `run` is `implement-review-phase`.
|
Stage 2 publishes findings as in `building-review.md` (The findings). Stage 3 has no "Check the fixes" item. The post starting Stage 2 carries `"run":{"event":"review","id":"review"}` (scores 1 point; the final `run` leaves it out). Stage 4 is the sign-off above, `show` and the Changes tab included (run `changes.mjs diff` after the review's fixes, so the tab shows the fixed code), without the `review` verdict, with review results and unresolved findings in the report and "Reviewed and ready for sign-off" in `body`. Its finish `run` is `implement-review-phase`.
|
||||||
@@ -36,6 +36,8 @@ approve.
|
|||||||
- Build the phase `--phase` names, without asking (Choosing the phase).
|
- Build the phase `--phase` names, without asking (Choosing the phase).
|
||||||
- No sign-off card, no "Approve this phase", no Show me it working, no Continue
|
- No sign-off card, no "Approve this phase", no Show me it working, no Continue
|
||||||
offer. A loop run notes lessons and never lists them: no `lessons` card.
|
offer. A loop run notes lessons and never lists them: no `lessons` card.
|
||||||
|
- Take the `changes.mjs start` snapshot as `notes/implement.md` says, but run
|
||||||
|
no `diff` and post no Changes tab: a loop phase has no sign-off.
|
||||||
- Never run `specs.mjs mark --to done`, and never set `[x]` on the phase in
|
- Never run `specs.mjs mark --to done`, and never set `[x]` on the phase in
|
||||||
`overview.md`. Tasks inside the phase file are still checked off as they
|
`overview.md`. Tasks inside the phase file are still checked off as they
|
||||||
finish: `[x]`, `[!]` when blocked, `[?]` when assumed.
|
finish: `[x]`, `[!]` when blocked, `[?]` when assumed.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Read `building.md` first.
|
|||||||
```
|
```
|
||||||
|
|
||||||
A `modify` reposts the changed blocks.
|
A `modify` reposts the changed blocks.
|
||||||
- **Building** after `yes`: the Plan tab is the live task list; steps are the tasks. Settle the verdict in the post that starts it:
|
- **Building** after `yes`: before the first edit (a resumed run: when editing starts), run `changes.mjs start` as `notes/implement.md` (First post of a phase) says. The Plan tab is the live task list; steps are the tasks. Settle the verdict in the post that starts it:
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{"stopWarning":"","settle":true,"headline":{"stage":"Building","cleared":0,"total":4},"agent":{"status":"working","activity":"Task 1 of 4: step one","quietMinutes":10}}
|
{"stopWarning":"","settle":true,"headline":{"stage":"Building","cleared":0,"total":4},"agent":{"status":"working","activity":"Task 1 of 4: step one","quietMinutes":10}}
|
||||||
@@ -28,7 +28,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.
|
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`. `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.
|
- **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`, the `changes` doc in the same post (`notes/implement.md` → Sign-off, Changes tab); before "Does it look right?", run `diff` again and re-send its block. 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, re-run `diff` and re-send its block, reshow if visible, reopen with a `thread` reply, wait again. Only `fine` leads to the finish.
|
||||||
- **Archive a finished folder:** launched on a diagnosed folder now Fixed or an upgrade folder now Done, with nothing past the diagnosis or brief, or on a folder of only prototypes now built, post `confirm` "Archive this bug?" ("Archive this upgrade?", "Archive this prototype?") in the same post as "See it running": dry run's `files` in `body`, with any prototype not built named there, `yesLabel` "Archive it", `noLabel` "Keep it in specs/", `consequences` naming `specs--completed/<name>/`. Yes: `node "<S>/specs.mjs" archive <spec>`, and say where it went in the finish `body`.
|
- **Archive a finished folder:** launched on a diagnosed folder now Fixed or an upgrade folder now Done, with nothing past the diagnosis or brief, or on a folder of only prototypes now built, post `confirm` "Archive this bug?" ("Archive this upgrade?", "Archive this prototype?") in the same post as "See it running": dry run's `files` in `body`, with any prototype not built named there, `yesLabel` "Archive it", `noLabel` "Keep it in specs/", `consequences` naming `specs--completed/<name>/`. 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`.
|
- **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`.
|
||||||
- **Lessons first:** with lessons to offer (`references/lessons.md`, End), post its `card` as one `lessons` item with `--wait` before the finish.
|
- **Lessons first:** with lessons to offer (`references/lessons.md`, End), post its `card` as one `lessons` item with `--wait` before the finish.
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ function mergeDocs(current, patchList) {
|
|||||||
// version: the agent no longer has to track what the page holds, and a
|
// version: the agent no longer has to track what the page holds, and a
|
||||||
// repost of unchanged content is not a new version.
|
// repost of unchanged content is not a new version.
|
||||||
if (prev && typeof entry.version !== "number" && typeof prev.version === "number") {
|
if (prev && typeof entry.version !== "number" && typeof prev.version === "number") {
|
||||||
const text = (blocks) => JSON.stringify((blocks || []).map((b) => [b.id, b.md, b.state, b.image, b.alt, b.diff, b.text]));
|
const text = (blocks) => JSON.stringify((blocks || []).map((b) => [b.id, b.md, b.state, b.image, b.alt, b.diff, b.text, b.error]));
|
||||||
if (text(prev.blocks) !== text(doc.blocks)) doc.version = prev.version + 1;
|
if (text(prev.blocks) !== text(doc.blocks)) doc.version = prev.version + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,8 +492,11 @@ export function resolveDocImages(patch, state, dir) {
|
|||||||
// Diff blocks: `{ "id": "changes", "diff": "changes.diff" }` names a unified
|
// Diff blocks: `{ "id": "changes", "diff": "changes.diff" }` names a unified
|
||||||
// diff the agent saved directly in the session folder (changes.mjs diff). The
|
// diff the agent saved directly in the session folder (changes.mjs diff). The
|
||||||
// server reads it like a file block, with the same 512 KB cap, and stores the
|
// server reads it like a file block, with the same 512 KB cap, and stores the
|
||||||
// name beside the text so the page can tell a diff from markdown.
|
// name beside the text so the page can tell a diff from markdown. When the
|
||||||
|
// changes could not be read, `{ "id": "changes", "error": "<one line>" }`
|
||||||
|
// carries the plain reason instead, and the page shows it with a Reload button.
|
||||||
const DIFF_RIGHT = { id: "d1", diff: "changes.diff" };
|
const DIFF_RIGHT = { id: "d1", diff: "changes.diff" };
|
||||||
|
const ERROR_RIGHT = { id: "d1", error: "No snapshot was taken at the start of this run." };
|
||||||
const readDiff = (name, docId, blockId) => {
|
const readDiff = (name, docId, blockId) => {
|
||||||
const at = `doc "${docId}" block "${blockId}"`;
|
const at = `doc "${docId}" block "${blockId}"`;
|
||||||
if (typeof name !== "string" || !name.trim()) throw new Error(rule(at, "diff", "must be a file name", DIFF_RIGHT));
|
if (typeof name !== "string" || !name.trim()) throw new Error(rule(at, "diff", "must be a file name", DIFF_RIGHT));
|
||||||
@@ -542,11 +545,19 @@ export function resolveDocImages(patch, state, dir) {
|
|||||||
if (["md", "file", "image"].some((k) => k in b && b[k] != null)) {
|
if (["md", "file", "image"].some((k) => k in b && b[k] != null)) {
|
||||||
throw new Error(rule(`doc "${entry.id}" block "${b.id}"`, "diff", 'a diff block cannot also carry "md", "file" or "image"', DIFF_RIGHT));
|
throw new Error(rule(`doc "${entry.id}" block "${b.id}"`, "diff", 'a diff block cannot also carry "md", "file" or "image"', DIFF_RIGHT));
|
||||||
}
|
}
|
||||||
return { state: prevBlock?.state || "settled", ...b, diff: b.diff, text: readDiff(b.diff, entry.id, b.id), md: null, file: null, image: null };
|
if (b.error != null) throw new Error(rule(`doc "${entry.id}" block "${b.id}"`, "error", 'a diff block carries "diff" or "error", never both', DIFF_RIGHT));
|
||||||
|
return { state: prevBlock?.state || "settled", ...b, diff: b.diff, text: readDiff(b.diff, entry.id, b.id), error: null, md: null, file: null, image: null };
|
||||||
|
}
|
||||||
|
if (b.error !== undefined && b.error !== null) {
|
||||||
|
const at = `doc "${entry.id}" block "${b.id}"`;
|
||||||
|
if (["md", "file", "image"].some((k) => k in b && b[k] != null)) throw new Error(rule(at, "error", 'an error block cannot also carry "md", "file" or "image"', ERROR_RIGHT));
|
||||||
|
if (typeof b.error !== "string" || !b.error.trim() || /[\r\n]/.test(b.error.trim())) throw new Error(rule(at, "error", "must be one line of prose: why the changes could not be read", ERROR_RIGHT));
|
||||||
|
return { state: prevBlock?.state || "settled", ...b, error: b.error.trim(), diff: null, text: null, md: null, file: null, image: null };
|
||||||
}
|
}
|
||||||
// Text, a file or an image over what was a diff: it stops being one.
|
// Text, a file or an image over what was a diff: it stops being one.
|
||||||
const wasDiff = prevBlock && typeof prevBlock.diff === "string";
|
const wasDiff = prevBlock && typeof prevBlock.diff === "string";
|
||||||
const notDiff = wasDiff && ("md" in b || "file" in b || "image" in b) ? { diff: null, text: null } : {};
|
const wasError = prevBlock && typeof prevBlock.error === "string";
|
||||||
|
const notDiff = (wasDiff || wasError) && ("md" in b || "file" in b || "image" in b) ? { diff: null, text: null, error: null } : {};
|
||||||
if (b.image === undefined || b.image === null) {
|
if (b.image === undefined || b.image === null) {
|
||||||
// Text or a file over what was an image: it stops being one.
|
// Text or a file over what was an image: it stops being one.
|
||||||
return ("md" in b || "file" in b) && prevBlock && typeof prevBlock.image === "string" ? { ...b, ...notDiff, image: null, alt: null } : { ...b, ...notDiff };
|
return ("md" in b || "file" in b) && prevBlock && typeof prevBlock.image === "string" ? { ...b, ...notDiff, image: null, alt: null } : { ...b, ...notDiff };
|
||||||
|
|||||||
@@ -0,0 +1,242 @@
|
|||||||
|
// Plan2Code Web Console - a unified diff (changes.mjs diff) read into files, hunks and numbered lines; defines only.
|
||||||
|
//
|
||||||
|
// The Changes tab draws what this returns. It never throws: text it cannot
|
||||||
|
// read comes back as `{ files: [], tooLarge: false, bad: true }`, which the tab
|
||||||
|
// shows as its error state.
|
||||||
|
|
||||||
|
// The lines changes.mjs writes in place of a file's lines, and after the last
|
||||||
|
// file it kept whole when the change set was over its cap.
|
||||||
|
export const HIDDEN_LINE = "Lines hidden: this file may hold a secret.";
|
||||||
|
export const TOO_LARGE_LINE = "\\ No more lines shown: this change is too large to show in full.";
|
||||||
|
|
||||||
|
const HUNK = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/;
|
||||||
|
|
||||||
|
// A path git quoted ("a/with \"quote\".txt"): C escapes, octal bytes as UTF-8.
|
||||||
|
// Returns [path, rest of the line] or null.
|
||||||
|
function unquote(s) {
|
||||||
|
if (s[0] !== '"') return null;
|
||||||
|
const bytes = [];
|
||||||
|
const enc = new TextEncoder();
|
||||||
|
const named = { n: 10, t: 9, r: 13, a: 7, b: 8, f: 12, v: 11, '"': 34, "\\": 92 };
|
||||||
|
let i = 1;
|
||||||
|
while (i < s.length) {
|
||||||
|
const c = s[i];
|
||||||
|
if (c === '"') return [new TextDecoder().decode(new Uint8Array(bytes)), s.slice(i + 1)];
|
||||||
|
if (c === "\\") {
|
||||||
|
const n = s[i + 1];
|
||||||
|
if (/[0-7]/.test(n || "")) {
|
||||||
|
const oct = /^[0-7]{1,3}/.exec(s.slice(i + 1))[0];
|
||||||
|
bytes.push(parseInt(oct, 8) & 0xff);
|
||||||
|
i += 1 + oct.length;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (n in named) {
|
||||||
|
bytes.push(named[n]);
|
||||||
|
i += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// One whole character, so a surrogate pair stays one.
|
||||||
|
const ch = String.fromCodePoint(s.codePointAt(i));
|
||||||
|
bytes.push(...enc.encode(ch));
|
||||||
|
i += ch.length;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const strip = (p, prefix) => (p.startsWith(prefix) ? p.slice(prefix.length) : p);
|
||||||
|
|
||||||
|
// The two paths of a `diff --git a/x b/y` line. Unquoted paths with spaces are
|
||||||
|
// ambiguous, so the halves are taken equal when they can be (the usual case:
|
||||||
|
// the same file on both sides); the ---, +++ and rename lines correct it later.
|
||||||
|
function gitLinePaths(rest) {
|
||||||
|
if (rest[0] === '"') {
|
||||||
|
const a = unquote(rest);
|
||||||
|
if (!a) return null;
|
||||||
|
const after = a[1].replace(/^ /, "");
|
||||||
|
const b = after[0] === '"' ? unquote(after) : [after, ""];
|
||||||
|
if (!b) return null;
|
||||||
|
return [strip(a[0], "a/"), strip(b[0], "b/")];
|
||||||
|
}
|
||||||
|
const half = (rest.length - 1) / 2;
|
||||||
|
if (Number.isInteger(half) && rest[half] === " " && rest.slice(0, half).slice(2) === rest.slice(half + 1).slice(2)) {
|
||||||
|
return [strip(rest.slice(0, half), "a/"), strip(rest.slice(half + 1), "b/")];
|
||||||
|
}
|
||||||
|
const quotedB = rest.indexOf(' "b/');
|
||||||
|
if (quotedB > 0) {
|
||||||
|
const b = unquote(rest.slice(quotedB + 1));
|
||||||
|
if (b) return [strip(rest.slice(0, quotedB), "a/"), strip(b[0], "b/")];
|
||||||
|
}
|
||||||
|
const at = rest.indexOf(" b/");
|
||||||
|
if (at < 0) return null;
|
||||||
|
return [strip(rest.slice(0, at), "a/"), strip(rest.slice(at + 1), "b/")];
|
||||||
|
}
|
||||||
|
|
||||||
|
// The path on a ---, +++, rename from or rename to line: quoted or plain, with
|
||||||
|
// the trailing tab git adds after a name holding a space dropped.
|
||||||
|
function linePath(raw) {
|
||||||
|
const q = unquote(raw);
|
||||||
|
if (q) return q[0];
|
||||||
|
return raw.replace(/\t$/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function newFile(paths) {
|
||||||
|
return {
|
||||||
|
path: paths[1],
|
||||||
|
oldPath: paths[0],
|
||||||
|
status: "modified",
|
||||||
|
added: 0,
|
||||||
|
removed: 0,
|
||||||
|
binary: false,
|
||||||
|
hidden: false,
|
||||||
|
truncated: false,
|
||||||
|
hunks: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish(file, afterCut) {
|
||||||
|
if (file.status !== "renamed") file.oldPath = null;
|
||||||
|
if (afterCut && !file.hunks.length && !file.binary && !file.hidden) file.truncated = true;
|
||||||
|
file.afterCut = afterCut;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseDiff(text) {
|
||||||
|
const bad = { files: [], tooLarge: false, bad: true };
|
||||||
|
if (typeof text !== "string") return bad;
|
||||||
|
try {
|
||||||
|
return readDiff(text);
|
||||||
|
} catch {
|
||||||
|
return bad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function readDiff(text) {
|
||||||
|
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
||||||
|
const files = [];
|
||||||
|
let tooLarge = false;
|
||||||
|
let file = null;
|
||||||
|
let fileAfterCut = false;
|
||||||
|
let hunk = null;
|
||||||
|
let oldNo = 0;
|
||||||
|
let newNo = 0;
|
||||||
|
let oldLeft = 0;
|
||||||
|
let newLeft = 0;
|
||||||
|
let lastWasLine = false;
|
||||||
|
const close = () => {
|
||||||
|
if (file) files.push(finish(file, fileAfterCut));
|
||||||
|
file = null;
|
||||||
|
hunk = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
// Inside a hunk, its counts decide: a line starting "+++" or "---" there
|
||||||
|
// is a changed line, never a header.
|
||||||
|
if (hunk && (oldLeft > 0 || newLeft > 0)) {
|
||||||
|
const c = line[0];
|
||||||
|
if (c === "+" && newLeft > 0) {
|
||||||
|
hunk.lines.push({ kind: "add", oldNo: null, newNo: newNo++, text: line.slice(1) });
|
||||||
|
newLeft--;
|
||||||
|
file.added++;
|
||||||
|
lastWasLine = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c === "-" && oldLeft > 0) {
|
||||||
|
hunk.lines.push({ kind: "del", oldNo: oldNo++, newNo: null, text: line.slice(1) });
|
||||||
|
oldLeft--;
|
||||||
|
file.removed++;
|
||||||
|
lastWasLine = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// An empty line stands for an empty context line some tools trim.
|
||||||
|
if ((c === " " || line === "") && oldLeft > 0 && newLeft > 0) {
|
||||||
|
hunk.lines.push({ kind: "ctx", oldNo: oldNo++, newNo: newNo++, text: line.slice(1) });
|
||||||
|
oldLeft--;
|
||||||
|
newLeft--;
|
||||||
|
lastWasLine = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c === "\\" && line !== TOO_LARGE_LINE && lastWasLine) {
|
||||||
|
hunk.lines.push({ kind: "meta", oldNo: null, newNo: null, text: line });
|
||||||
|
lastWasLine = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Anything else ends the hunk early and is read below.
|
||||||
|
hunk = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line === TOO_LARGE_LINE) {
|
||||||
|
close();
|
||||||
|
tooLarge = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (line.startsWith("diff --git ")) {
|
||||||
|
close();
|
||||||
|
const paths = gitLinePaths(line.slice("diff --git ".length));
|
||||||
|
if (!paths) throw new Error("unreadable diff header");
|
||||||
|
file = newFile(paths);
|
||||||
|
fileAfterCut = tooLarge;
|
||||||
|
lastWasLine = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!file) continue;
|
||||||
|
// The marker after the last line of a file with no newline at its end.
|
||||||
|
if (hunk && line[0] === "\\" && lastWasLine) {
|
||||||
|
hunk.lines.push({ kind: "meta", oldNo: null, newNo: null, text: line });
|
||||||
|
lastWasLine = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const h = HUNK.exec(line);
|
||||||
|
if (h) {
|
||||||
|
oldNo = Number(h[1]);
|
||||||
|
oldLeft = h[2] === undefined ? 1 : Number(h[2]);
|
||||||
|
newNo = Number(h[3]);
|
||||||
|
newLeft = h[4] === undefined ? 1 : Number(h[4]);
|
||||||
|
hunk = { header: line, lines: [] };
|
||||||
|
file.hunks.push(hunk);
|
||||||
|
lastWasLine = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (file.hunks.length) continue;
|
||||||
|
// The extended header lines, before any hunk.
|
||||||
|
if (line.startsWith("new file mode")) file.status = "added";
|
||||||
|
else if (line.startsWith("deleted file mode")) file.status = "deleted";
|
||||||
|
else if (line.startsWith("rename from ")) {
|
||||||
|
file.status = "renamed";
|
||||||
|
file.oldPath = linePath(line.slice("rename from ".length));
|
||||||
|
} else if (line.startsWith("rename to ")) {
|
||||||
|
file.status = "renamed";
|
||||||
|
file.path = linePath(line.slice("rename to ".length));
|
||||||
|
} else if (line.startsWith("--- ")) {
|
||||||
|
const p = linePath(line.slice(4));
|
||||||
|
if (p !== "/dev/null") file.oldPath = strip(p, "a/");
|
||||||
|
} else if (line.startsWith("+++ ")) {
|
||||||
|
const p = linePath(line.slice(4));
|
||||||
|
if (p !== "/dev/null") file.path = strip(p, "b/");
|
||||||
|
} else if (/^Binary files .* differ$/.test(line) || line === "GIT binary patch") file.binary = true;
|
||||||
|
else if (line === HIDDEN_LINE) file.hidden = true;
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
// A change set too big for git to print at all comes as every file's name
|
||||||
|
// first and the too-large line last (changes.mjs): no file follows the
|
||||||
|
// line, and each file it names is listed only.
|
||||||
|
if (tooLarge && !files.some((f) => f.afterCut)) {
|
||||||
|
for (const f of files) if (!f.hunks.length && !f.binary && !f.hidden) f.truncated = true;
|
||||||
|
}
|
||||||
|
// A hidden or cut file has no lines to count: changes.mjs sends its counts as trailer lines.
|
||||||
|
for (const line of lines) {
|
||||||
|
const m = /^# counts: (\d+)\t(\d+)\t(.+)$/.exec(line);
|
||||||
|
if (!m) continue;
|
||||||
|
for (const f of files) {
|
||||||
|
if (f.path === m[3] && !f.hunks.length) {
|
||||||
|
f.added = Number(m[1]);
|
||||||
|
f.removed = Number(m[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const f of files) delete f.afterCut;
|
||||||
|
// Text with no file section at all is not a diff.
|
||||||
|
if (!files.length && text.trim()) return { files: [], tooLarge: false, bad: true };
|
||||||
|
return { files, tooLarge };
|
||||||
|
}
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
// Plan2Code Web Console - the Changes tab: a diff block drawn as a file list and one unified diff; defines only.
|
||||||
|
//
|
||||||
|
// The block is `{ id, diff: "changes.diff", text }` (or `{ id, error }` when
|
||||||
|
// the agent could not read the changes). Diff text is file content from the
|
||||||
|
// repository, so every node is built with el() and filled with textContent:
|
||||||
|
// nothing from it ever goes through innerHTML or md().
|
||||||
|
|
||||||
|
import { el } from "./render.js";
|
||||||
|
import { parseDiff } from "./diff-parse.js";
|
||||||
|
import { agentWorking, workingMs, patience, WORKING_GRACE_MS } from "./selectors.js";
|
||||||
|
import { hooks, page, redraw } from "./state.js";
|
||||||
|
import { sendState } from "./send-state.js";
|
||||||
|
|
||||||
|
// The picked file and the scroll of each pane, per diff block, so a redraw
|
||||||
|
// of the same block keeps the person where they were.
|
||||||
|
const picks = new Map();
|
||||||
|
// The last parse of each block's text: a redraw does not parse again.
|
||||||
|
const parsed = new Map();
|
||||||
|
|
||||||
|
const blockKey = (b) => String(b.id || "") + "|" + String(b.diff || "");
|
||||||
|
|
||||||
|
function parseOnce(b) {
|
||||||
|
const key = blockKey(b);
|
||||||
|
const hit = parsed.get(key);
|
||||||
|
if (hit && hit.text === b.text) return hit.result;
|
||||||
|
const result = parseDiff(b.text);
|
||||||
|
parsed.set(key, { text: b.text, result });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseName = (p) => String(p || "").split("/").pop();
|
||||||
|
const folderOf = (p) => {
|
||||||
|
const parts = String(p || "").split("/");
|
||||||
|
parts.pop();
|
||||||
|
return parts.join("/");
|
||||||
|
};
|
||||||
|
|
||||||
|
// What a rename row reads: old -> new, by name when the folder stayed.
|
||||||
|
function renameLabel(f) {
|
||||||
|
return folderOf(f.oldPath) === folderOf(f.path) ? `${baseName(f.oldPath)} → ${baseName(f.path)}` : `${f.oldPath} → ${f.path}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_WORD = { added: "Added", deleted: "Deleted", renamed: "Renamed" };
|
||||||
|
|
||||||
|
function counts(f) {
|
||||||
|
const box = el("span", "diff-counts");
|
||||||
|
box.appendChild(el("span", "diff-plus", `+${f.added}`));
|
||||||
|
box.appendChild(el("span", "diff-minus", `-${f.removed}`));
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------- states */
|
||||||
|
|
||||||
|
// Asks the agent to read the changes again. Refused whenever Send itself
|
||||||
|
// would be (a finished or paused session, the loop building, no connection),
|
||||||
|
// and, as the brief button is, while a turn is in flight.
|
||||||
|
async function askAgain(button, status, reply) {
|
||||||
|
const state = sendState(true);
|
||||||
|
if (state.disabled || page.gone || page.pendingResult || (agentWorking() && workingMs() <= patience(WORKING_GRACE_MS))) {
|
||||||
|
status.textContent = state.why || "Wait for Plan2Code to finish, then ask again.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const label = button.textContent;
|
||||||
|
button.disabled = true;
|
||||||
|
button.textContent = "Asking…";
|
||||||
|
try {
|
||||||
|
const res = await fetch("/submit", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "content-type": "application/json" },
|
||||||
|
body: JSON.stringify({ actions: [{ i: "__changes", type: "changes" }], reply }),
|
||||||
|
});
|
||||||
|
if (res.status === 409) throw Object.assign(new Error("pending"), { pending: true });
|
||||||
|
if (!res.ok) throw new Error(String(res.status));
|
||||||
|
hooks.banner("Asked for the changes again. The tab updates when they are read.", "good");
|
||||||
|
setTimeout(() => hooks.banner(null), 5000);
|
||||||
|
page.pendingResult = true;
|
||||||
|
redraw();
|
||||||
|
} catch (err) {
|
||||||
|
if (err && err.pending) page.pendingResult = true;
|
||||||
|
status.textContent =
|
||||||
|
err && err.pending ? "Your last answers are still being picked up. Try again in a moment." : "That did not go through. Try again in a moment.";
|
||||||
|
} finally {
|
||||||
|
button.disabled = false;
|
||||||
|
button.textContent = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stateBox(kind, message, buttonLabel, reply) {
|
||||||
|
const box = el("div", "diff-state diff-" + kind);
|
||||||
|
box.appendChild(el("p", "diff-state-msg", message));
|
||||||
|
if (buttonLabel) {
|
||||||
|
const btn = el("button", "btn small diff-again", buttonLabel);
|
||||||
|
btn.type = "button";
|
||||||
|
const status = el("p", "diff-state-why");
|
||||||
|
status.setAttribute("role", "status");
|
||||||
|
btn.addEventListener("click", () => askAgain(btn, status, reply));
|
||||||
|
box.appendChild(btn);
|
||||||
|
box.appendChild(status);
|
||||||
|
}
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLoading() {
|
||||||
|
const view = el("div", "diff-view is-loading");
|
||||||
|
view.setAttribute("aria-busy", "true");
|
||||||
|
view.appendChild(el("p", "diff-totals", "Reading the changes…"));
|
||||||
|
const cols = el("div", "diff-cols");
|
||||||
|
const list = el("div", "diff-list diff-skeleton");
|
||||||
|
for (let i = 0; i < 4; i++) list.appendChild(el("span", "diff-skel-row"));
|
||||||
|
const pane = el("div", "diff-pane diff-skeleton");
|
||||||
|
for (let i = 0; i < 8; i++) pane.appendChild(el("span", "diff-skel-row"));
|
||||||
|
cols.appendChild(list);
|
||||||
|
cols.appendChild(pane);
|
||||||
|
view.appendChild(cols);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- ready */
|
||||||
|
|
||||||
|
function drawHunks(f) {
|
||||||
|
if (f.binary) return el("p", "diff-plain", "Binary file: no lines to show");
|
||||||
|
if (f.hidden) return el("p", "diff-plain", "Lines hidden: this file may hold a secret");
|
||||||
|
if (f.truncated) return el("p", "diff-plain", "Too large to show in full: this file is listed only");
|
||||||
|
if (!f.hunks.length) return el("p", "diff-plain", f.status === "renamed" ? "Renamed only: no lines changed" : "No lines changed");
|
||||||
|
const code = el("div", "diff-code");
|
||||||
|
const rows = el("div", "diff-rows");
|
||||||
|
for (const h of f.hunks) {
|
||||||
|
rows.appendChild(el("div", "diff-hunk", h.header));
|
||||||
|
for (const l of h.lines) {
|
||||||
|
const row = el("div", "diff-line " + l.kind);
|
||||||
|
row.appendChild(el("span", "diff-no", l.oldNo == null ? "" : String(l.oldNo)));
|
||||||
|
row.appendChild(el("span", "diff-no", l.newNo == null ? "" : String(l.newNo)));
|
||||||
|
row.appendChild(el("span", "diff-sign", l.kind === "add" ? "+" : l.kind === "del" ? "-" : ""));
|
||||||
|
row.appendChild(el("code", "diff-text", l.text));
|
||||||
|
rows.appendChild(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
code.appendChild(rows);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPane(f) {
|
||||||
|
const pane = el("section", "diff-pane");
|
||||||
|
pane.setAttribute("aria-label", "Lines of " + f.path);
|
||||||
|
const head = el("header", "diff-pane-head");
|
||||||
|
head.appendChild(el("strong", "diff-pane-path", f.status === "renamed" ? `${f.oldPath} → ${f.path}` : f.path));
|
||||||
|
head.appendChild(counts(f));
|
||||||
|
pane.appendChild(head);
|
||||||
|
pane.appendChild(drawHunks(f));
|
||||||
|
return pane;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawReady(b, result) {
|
||||||
|
const key = blockKey(b);
|
||||||
|
const files = result.files;
|
||||||
|
const memory = picks.get(key) || {};
|
||||||
|
let picked = files.findIndex((f) => f.path === memory.path);
|
||||||
|
if (picked < 0) picked = 0;
|
||||||
|
|
||||||
|
const view = el("div", "diff-view");
|
||||||
|
const added = files.reduce((n, f) => n + f.added, 0);
|
||||||
|
const removed = files.reduce((n, f) => n + f.removed, 0);
|
||||||
|
const totals = el("p", "diff-totals");
|
||||||
|
totals.appendChild(el("span", null, `${files.length} ${files.length === 1 ? "file" : "files"} changed, `));
|
||||||
|
totals.appendChild(el("span", "diff-plus", `+${added}`));
|
||||||
|
totals.appendChild(document.createTextNode(" "));
|
||||||
|
totals.appendChild(el("span", "diff-minus", `-${removed}`));
|
||||||
|
view.appendChild(totals);
|
||||||
|
if (result.tooLarge) {
|
||||||
|
view.appendChild(el("p", "diff-notice", "This change is too large to show in full: every file is listed, but some show no lines."));
|
||||||
|
}
|
||||||
|
|
||||||
|
const cols = el("div", "diff-cols");
|
||||||
|
const list = el("ul", "diff-list");
|
||||||
|
list.setAttribute("role", "listbox");
|
||||||
|
list.setAttribute("aria-label", "Changed files");
|
||||||
|
list.tabIndex = 0;
|
||||||
|
const idBase = "diff-" + String(b.id || "block").replace(/[^A-Za-z0-9_-]/g, "") + "-";
|
||||||
|
const rows = files.map((f, i) => {
|
||||||
|
const row = el("li", "diff-file");
|
||||||
|
row.id = idBase + i;
|
||||||
|
row.setAttribute("role", "option");
|
||||||
|
const name = el("span", "diff-file-name");
|
||||||
|
name.appendChild(el("strong", null, f.status === "renamed" ? renameLabel(f) : baseName(f.path)));
|
||||||
|
if (STATUS_WORD[f.status]) name.appendChild(el("span", "diff-status diff-status-" + f.status, STATUS_WORD[f.status]));
|
||||||
|
row.appendChild(name);
|
||||||
|
const folder = folderOf(f.path);
|
||||||
|
if (folder) row.appendChild(el("span", "diff-file-dir", folder));
|
||||||
|
row.appendChild(counts(f));
|
||||||
|
row.addEventListener("click", () => pick(i, false));
|
||||||
|
list.appendChild(row);
|
||||||
|
return row;
|
||||||
|
});
|
||||||
|
cols.appendChild(list);
|
||||||
|
let pane = drawPane(files[picked]);
|
||||||
|
cols.appendChild(pane);
|
||||||
|
view.appendChild(cols);
|
||||||
|
|
||||||
|
const remember = () => {
|
||||||
|
picks.set(key, {
|
||||||
|
path: files[picked].path,
|
||||||
|
listTop: list.scrollTop,
|
||||||
|
paneTop: pane.scrollTop,
|
||||||
|
paneLeft: pane.scrollLeft,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const watch = () => pane.addEventListener("scroll", remember, { passive: true });
|
||||||
|
function mark() {
|
||||||
|
rows.forEach((r, i) => {
|
||||||
|
r.setAttribute("aria-selected", i === picked ? "true" : "false");
|
||||||
|
r.classList.toggle("is-picked", i === picked);
|
||||||
|
});
|
||||||
|
list.setAttribute("aria-activedescendant", rows[picked].id);
|
||||||
|
}
|
||||||
|
function pick(i, fromKeys) {
|
||||||
|
if (i < 0 || i >= files.length) return;
|
||||||
|
const changed = i !== picked;
|
||||||
|
picked = i;
|
||||||
|
mark();
|
||||||
|
if (changed) {
|
||||||
|
const next = drawPane(files[picked]);
|
||||||
|
pane.replaceWith(next);
|
||||||
|
pane = next;
|
||||||
|
watch();
|
||||||
|
}
|
||||||
|
if (fromKeys) rows[picked].scrollIntoView({ block: "nearest" });
|
||||||
|
remember();
|
||||||
|
}
|
||||||
|
list.addEventListener("keydown", (e) => {
|
||||||
|
const step = { ArrowDown: 1, ArrowUp: -1 }[e.key];
|
||||||
|
const jump = { Home: 0, End: files.length - 1 }[e.key];
|
||||||
|
if (step === undefined && jump === undefined) return;
|
||||||
|
e.preventDefault();
|
||||||
|
pick(step !== undefined ? picked + step : jump, true);
|
||||||
|
});
|
||||||
|
list.addEventListener("scroll", remember, { passive: true });
|
||||||
|
watch();
|
||||||
|
mark();
|
||||||
|
|
||||||
|
// Back to where the person was once the view is on the page (a fresh
|
||||||
|
// element has no layout to scroll yet).
|
||||||
|
if (memory.path === files[picked].path) {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
list.scrollTop = memory.listTop || 0;
|
||||||
|
pane.scrollTop = memory.paneTop || 0;
|
||||||
|
pane.scrollLeft = memory.paneLeft || 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
picks.set(key, { ...memory, path: files[picked].path });
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- entry */
|
||||||
|
|
||||||
|
// One diff block as the Changes tab. `doc` is the block's document, when
|
||||||
|
// known: a doc marked stale is still being read again.
|
||||||
|
export function drawDiff(b, doc) {
|
||||||
|
if (typeof b.error === "string" && b.error.trim()) {
|
||||||
|
return wrap(stateBox("error", `The changes could not be read: ${b.error.trim()}`, "Reload the changes", "Please refresh the Changes tab."));
|
||||||
|
}
|
||||||
|
if (typeof b.text !== "string" || (doc && doc.stale)) return drawLoading();
|
||||||
|
const result = parseOnce(b);
|
||||||
|
if (result.bad) {
|
||||||
|
return wrap(stateBox("error", "The changes could not be read: the diff is not in a shape this page can draw.", "Reload the changes", "Please refresh the Changes tab."));
|
||||||
|
}
|
||||||
|
if (!result.files.length) {
|
||||||
|
return wrap(stateBox("empty", "Nothing has changed since this run started.", "Check again", "Please refresh the Changes tab."));
|
||||||
|
}
|
||||||
|
return drawReady(b, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function wrap(box) {
|
||||||
|
const view = el("div", "diff-view");
|
||||||
|
view.appendChild(box);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
@@ -3,10 +3,14 @@
|
|||||||
// Shared by the documents tab and the finished screen, so neither imports the other.
|
// Shared by the documents tab and the finished screen, so neither imports the other.
|
||||||
|
|
||||||
import { el, md } from "./render.js";
|
import { el, md } from "./render.js";
|
||||||
|
import { drawDiff } from "./diff-view.js";
|
||||||
|
|
||||||
// A block's content: its markdown, or for an image block (a screenshot the
|
// A block's content: its markdown, for an image block (a screenshot the
|
||||||
// agent saved under the session's shots/ folder) a captioned picture.
|
// agent saved under the session's shots/ folder) a captioned picture, and for
|
||||||
export function blockBody(b) {
|
// a diff block (changes.mjs diff) the Changes tab. `doc` is the block's
|
||||||
|
// document, when known.
|
||||||
|
export function blockBody(b, doc) {
|
||||||
|
if (isDiffBlock(b)) return drawDiff(b, doc);
|
||||||
if (typeof b.image !== "string") return md(b.md, "md");
|
if (typeof b.image !== "string") return md(b.md, "md");
|
||||||
const fig = el("figure", "doc-figure");
|
const fig = el("figure", "doc-figure");
|
||||||
const img = el("img", "doc-img");
|
const img = el("img", "doc-img");
|
||||||
@@ -27,13 +31,31 @@ export function downloadDoc(doc) {
|
|||||||
// assumptions or drafts. Without the marks a half-finished document reads,
|
// assumptions or drafts. Without the marks a half-finished document reads,
|
||||||
// once it leaves the page, as a set of decisions.
|
// once it leaves the page, as a set of decisions.
|
||||||
const mark = { assumed: "> **Assumed for now, still open.**\n\n", draft: "> **Draft.**\n\n" };
|
const mark = { assumed: "> **Assumed for now, still open.**\n\n", draft: "> **Draft.**\n\n" };
|
||||||
const blocks = (doc.blocks || []).map((b) => (mark[b.state] || "") + (typeof b.image === "string" ? b.alt || "" : b.md || ""));
|
const blocks = (doc.blocks || []).map((b) => (mark[b.state] || "") + blockText(b));
|
||||||
const first = (doc.blocks || [])[0];
|
const first = (doc.blocks || [])[0];
|
||||||
const titled = first && /^\s*#\s/.test(first.md || "");
|
const titled = first && /^\s*#\s/.test(first.md || "");
|
||||||
const body = [titled || !doc.title ? null : `# ${doc.title}`, ...blocks].filter((x) => x != null).join("\n\n");
|
const body = [titled || !doc.title ? null : `# ${doc.title}`, ...blocks].filter((x) => x != null).join("\n\n");
|
||||||
saveFile(`${docFileName(doc)}.md`, body, "text/markdown");
|
saveFile(`${docFileName(doc)}.md`, body, "text/markdown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A diff block names its .diff file, or carries only the agent's reason it
|
||||||
|
// could not read one.
|
||||||
|
function isDiffBlock(b) {
|
||||||
|
return typeof b.diff === "string" || (typeof b.error === "string" && b.md == null && b.image == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// What one block contributes to a saved file: a diff block's text as a fenced
|
||||||
|
// diff (its error line when it has none), an image's caption, else markdown.
|
||||||
|
function blockText(b) {
|
||||||
|
if (isDiffBlock(b)) {
|
||||||
|
if (typeof b.error === "string" && b.error.trim()) return `The changes could not be read: ${b.error.trim()}`;
|
||||||
|
if (typeof b.text !== "string") return "";
|
||||||
|
const fence = b.text.includes("```") ? "~~~~" : "```";
|
||||||
|
return `${fence}diff\n${b.text.replace(/\n$/, "")}\n${fence}`;
|
||||||
|
}
|
||||||
|
return typeof b.image === "string" ? b.alt || "" : b.md || "";
|
||||||
|
}
|
||||||
|
|
||||||
function docFileName(doc) {
|
function docFileName(doc) {
|
||||||
const name = (doc.title || "document").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
const name = (doc.title || "document").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
||||||
return name || "document";
|
return name || "document";
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
<link rel="modulepreload" href="/spec-states.js" />
|
<link rel="modulepreload" href="/spec-states.js" />
|
||||||
<link rel="modulepreload" href="/state.js" />
|
<link rel="modulepreload" href="/state.js" />
|
||||||
<link rel="modulepreload" href="/doc-files.js" />
|
<link rel="modulepreload" href="/doc-files.js" />
|
||||||
|
<link rel="modulepreload" href="/diff-view.js" />
|
||||||
|
<link rel="modulepreload" href="/diff-parse.js" />
|
||||||
<link rel="modulepreload" href="/send-state.js" />
|
<link rel="modulepreload" href="/send-state.js" />
|
||||||
<link rel="modulepreload" href="/mention-box.js" />
|
<link rel="modulepreload" href="/mention-box.js" />
|
||||||
<link rel="modulepreload" href="/uploads.js" />
|
<link rel="modulepreload" href="/uploads.js" />
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export function renderDoc(main, id) {
|
|||||||
box.appendChild(el("span", "block-tag", "Assumed for now, still open"));
|
box.appendChild(el("span", "block-tag", "Assumed for now, still open"));
|
||||||
}
|
}
|
||||||
if (b.state === "draft") box.appendChild(el("span", "block-tag", "Draft"));
|
if (b.state === "draft") box.appendChild(el("span", "block-tag", "Draft"));
|
||||||
box.appendChild(blockBody(b));
|
box.appendChild(blockBody(b, doc));
|
||||||
main.appendChild(box);
|
main.appendChild(box);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/* diff.css: The Changes tab, a diff block drawn as a file list and one unified diff. */
|
||||||
|
|
||||||
|
/* Every color is a token, so light and dark both come from tokens.css. Added
|
||||||
|
lines take the success pair (--ok, --ok-soft), removed lines the danger
|
||||||
|
pair (--warn, --warn-soft). */
|
||||||
|
|
||||||
|
.diff-view { --diff-gutter: 3.4em; --diff-sign: 1.6em; min-width: 0; }
|
||||||
|
|
||||||
|
.diff-totals { margin: 0 0 10px; color: var(--ink-2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
|
||||||
|
.diff-notice {
|
||||||
|
margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--stage); border-radius: 8px;
|
||||||
|
background: var(--stage-soft); color: var(--ink); font-size: 13px;
|
||||||
|
}
|
||||||
|
.diff-plus { color: var(--ok); font-weight: 600; }
|
||||||
|
.diff-minus { color: var(--warn); font-weight: 600; }
|
||||||
|
.diff-counts { display: inline-flex; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
|
/* Two columns, each scrolling inside itself: the tab never grows past the
|
||||||
|
window, so the doc's head (with its way back to the sign-off card) stays in
|
||||||
|
view however long the diff is. */
|
||||||
|
.diff-cols {
|
||||||
|
display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 12px; align-items: start;
|
||||||
|
--diff-max: max(260px, calc(100vh - 280px));
|
||||||
|
}
|
||||||
|
|
||||||
|
.diff-list {
|
||||||
|
list-style: none; margin: 0; padding: 6px; max-height: var(--diff-max); overflow-y: auto; overscroll-behavior: contain;
|
||||||
|
background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
|
||||||
|
}
|
||||||
|
.diff-list:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
||||||
|
.diff-file {
|
||||||
|
display: grid; gap: 2px; padding: 7px 10px; border-radius: calc(var(--radius) / 2); cursor: pointer;
|
||||||
|
}
|
||||||
|
.diff-file:hover { background: var(--panel-2); }
|
||||||
|
.diff-file.is-picked { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
|
||||||
|
.diff-file-name { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; min-width: 0; }
|
||||||
|
.diff-file-name strong { font-weight: 600; overflow-wrap: anywhere; }
|
||||||
|
.diff-file-dir { color: var(--ink-3); font-size: 12px; overflow-wrap: anywhere; }
|
||||||
|
.diff-status {
|
||||||
|
font: 700 10px/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
|
||||||
|
padding: 0 5px; border-radius: 4px; border: 1px solid var(--rule-2); color: var(--ink-2);
|
||||||
|
}
|
||||||
|
.diff-status-added { border-color: var(--ok); color: var(--ok); }
|
||||||
|
.diff-status-deleted { border-color: var(--warn); color: var(--warn); }
|
||||||
|
.diff-status-renamed { border-color: var(--accent); color: var(--accent); }
|
||||||
|
|
||||||
|
/* The pane scrolls both ways, so the sideways scrollbar for a long line sits
|
||||||
|
at the bottom of the pane, never under the file's last row. */
|
||||||
|
.diff-pane {
|
||||||
|
min-width: 0; max-height: var(--diff-max); overflow: auto; overscroll-behavior: contain;
|
||||||
|
background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
|
||||||
|
}
|
||||||
|
.diff-pane-head {
|
||||||
|
display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
|
||||||
|
padding: 9px 14px; border-bottom: 1px solid var(--rule);
|
||||||
|
position: sticky; top: 0; left: 0; z-index: 1; background: var(--panel);
|
||||||
|
}
|
||||||
|
.diff-pane-path { font-weight: 600; overflow-wrap: anywhere; }
|
||||||
|
|
||||||
|
/* Long lines scroll sideways with the pane, all rows together, never the page. */
|
||||||
|
.diff-rows { display: grid; min-width: 100%; width: max-content; font: 12px/1.55 var(--mono); }
|
||||||
|
.diff-hunk { padding: 3px 14px; color: var(--ink-3); background: var(--panel-2); white-space: pre; }
|
||||||
|
.diff-line { display: grid; grid-template-columns: var(--diff-gutter) var(--diff-gutter) var(--diff-sign) auto; }
|
||||||
|
.diff-no { text-align: right; padding-right: 8px; color: var(--ink-3); font-variant-numeric: tabular-nums; user-select: none; }
|
||||||
|
.diff-sign { text-align: center; color: var(--ink-3); user-select: none; }
|
||||||
|
.diff-text { font: inherit; white-space: pre; padding-right: 14px; color: var(--ink); background: none; border: 0; }
|
||||||
|
.diff-line.add { background: var(--ok-soft); }
|
||||||
|
.diff-line.add .diff-sign { color: var(--ok); font-weight: 700; }
|
||||||
|
.diff-line.del { background: var(--warn-soft); }
|
||||||
|
.diff-line.del .diff-sign { color: var(--warn); font-weight: 700; }
|
||||||
|
.diff-line.meta .diff-text { color: var(--ink-3); font-style: italic; }
|
||||||
|
|
||||||
|
.diff-plain { margin: 0; padding: 16px 14px; color: var(--ink-2); }
|
||||||
|
|
||||||
|
/* Empty and error: a plain line and a button to ask again. */
|
||||||
|
.diff-state { padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); }
|
||||||
|
.diff-state.diff-error { border-color: var(--warn); background: var(--warn-soft); }
|
||||||
|
.diff-state-msg { margin: 0 0 12px; }
|
||||||
|
.diff-state-why { margin: 8px 0 0; color: var(--ink-2); font-size: 13px; }
|
||||||
|
.diff-state-why:empty { display: none; }
|
||||||
|
|
||||||
|
/* Loading: muted rows where the list and the lines will be. */
|
||||||
|
.diff-skeleton { display: grid; gap: 10px; padding: 14px; }
|
||||||
|
.diff-skel-row { display: block; height: 14px; border-radius: 4px; background: var(--rule); }
|
||||||
|
.diff-pane.diff-skeleton .diff-skel-row:nth-child(3n) { width: 70%; }
|
||||||
|
.diff-pane.diff-skeleton .diff-skel-row:nth-child(4n + 1) { width: 85%; }
|
||||||
|
|
||||||
|
/* Narrow window: the file list stacks above the diff as a short list. */
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.diff-cols { grid-template-columns: minmax(0, 1fr); --diff-max: max(240px, calc(100vh - 340px)); }
|
||||||
|
.diff-list { max-height: 152px; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.diff-list, .diff-pane { max-height: none; overflow: visible; }
|
||||||
|
.diff-text { white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||||
|
.diff-rows { width: auto; }
|
||||||
|
}
|
||||||
@@ -28,6 +28,8 @@ export const SERVABLE = new Set([
|
|||||||
"card-rows.js",
|
"card-rows.js",
|
||||||
"state.js",
|
"state.js",
|
||||||
"doc-files.js",
|
"doc-files.js",
|
||||||
|
"diff-parse.js",
|
||||||
|
"diff-view.js",
|
||||||
"send-state.js",
|
"send-state.js",
|
||||||
"mention-box.js",
|
"mention-box.js",
|
||||||
"md-field.js",
|
"md-field.js",
|
||||||
@@ -320,7 +322,7 @@ export const SERVABLE = new Set([
|
|||||||
// Layers first, then one file per screen, then responsive and print last so
|
// Layers first, then one file per screen, then responsive and print last so
|
||||||
// its overrides still come after everything they override. The files are not
|
// its overrides still come after everything they override. The files are not
|
||||||
// on SERVABLE: they reach the page only through /app.css.
|
// on SERVABLE: they reach the page only through /app.css.
|
||||||
export const CSS_ORDER = ["tokens.css", "shell.css", "planny.css", "pieces.css", "dashboard.css", "learning.css", "poses.css", "docs.css", "ask.css", "ending.css", "help.css", "looks.css", "prefs.css", "agents.css", "notepad.css", "activities.css", "git.css", "responsive.css"];
|
export const CSS_ORDER = ["tokens.css", "shell.css", "planny.css", "pieces.css", "dashboard.css", "learning.css", "poses.css", "docs.css", "diff.css", "ask.css", "ending.css", "help.css", "looks.css", "prefs.css", "agents.css", "notepad.css", "activities.css", "git.css", "responsive.css"];
|
||||||
|
|
||||||
// The files joined with one newline between them (each file's own last newline
|
// The files joined with one newline between them (each file's own last newline
|
||||||
// is that one), as the server serves them before the accent rules. The test
|
// is that one), as the server serves them before the accent rules. The test
|
||||||
|
|||||||
Reference in new issue
Block a user