mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-28 05:11:18 -08:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1345aa0a95 | ||
|
|
b06a4cb4ab | ||
|
|
cfc58f5a06 | ||
|
|
630a1169c3 | ||
|
|
ab4e3322d6 | ||
|
|
1616019705 | ||
|
|
f2e9b8bde8 | ||
|
|
fb81f80ce5 |
No files matched your search
@@ -18,7 +18,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `open-link.mjs` | the desktop app's webview opens no new windows, so the page there sends links off the console (`linkLeavesPage()` in `public/app-bridge.js`: http or https on another origin, caught in `wireChrome()`) to `POST /open-link`. `linkToOpen()` takes http and https only (400 otherwise); `openLink()` starts the default browser with the link as one argument, never through a shell (`rundll32 url.dll,FileProtocolHandler` on Windows, `open` on macOS, `$BROWSER` or `xdg-open` elsewhere) and skips it under `PLAN2CODE_NO_BROWSER`. When that fails the page shows the link with a Copy button to paste into a browser |
|
||||
| `loop-setup.mjs` | the Implementation Loop's setup, remembered per project in `~/.plan2code/console/loop-setup.json` (one entry per folded project folder, schema 1): defaults, validation and the read and write the `/loop-setup` route uses. The app reads the same file itself for the quick check, so the page never carries that command |
|
||||
| `spec-carry.mjs` | the spec a desktop app's New Session carries to the fresh dashboard: one short-lived `~/.plan2code/console/spec-carry.json` (`{project, spec, at}`), written by `restart_brief::leave_spec` in the app from the old session's `specDir` (or, from a dashboard, its picker's `specSel` in the draft), taken once by `POST /spec-carry` (`takeSpecCarry`: same folded project, under ten minutes old, one folder under `specs/`) and used by `loadSpecCarry()` in `selectors.js` only when the new picker lists that spec |
|
||||
| `cmd-post-wait.mjs` | `post` and `wait`: publish a patch, then collect what the person sent. `sessionActions()` hands the send's `__` actions to the agent whole: `__delete`, a `__launch` with its `fromBanner` (sent from a dashboard showing lessons waiting), and `__learning` with every field (`{ "i": "__learning", "do": ... }`, `do` one of `LEARNING_ACTIONS` in `public/answers.js`: `review`, `switch-on`, `switch-off`, `move-log` or `remove`). `__learning` is not a hop: the dashboard agent runs `lessons.mjs`, resumes as the dashboard and posts the menu again, and `pointers.mjs` names `console-launches.md` for it. Pause for me never reaches the agent (`POST /learning/pause`) |
|
||||
| `cmd-post-wait.mjs` | `post` and `wait`: publish a patch, then collect what the person sent. `sessionActions()` hands the send's `__` actions to the agent whole: `__delete`, a `__launch` with its `fromBanner` (sent from a dashboard showing lessons waiting), and `__learning` with every field (`{ "i": "__learning", "do": ... }`, `do` one of `LEARNING_ACTIONS` in `public/answers.js`: `review`, `switch-on`, `switch-off`, `move-log`, `remove` or `tidy`). `__learning` is not a hop: the dashboard agent runs `lessons.mjs`, resumes as the dashboard and posts the menu again, and `pointers.mjs` names `console-launches.md` for it. Pause for me never reaches the agent (`POST /learning/pause`) |
|
||||
| `cmd-small.mjs` | the small commands: keep, forget, delete-spec, handoff, delete-handoff, status and stop; `handoff new` refuses an unknown `--workflow` the same way `open` does |
|
||||
| `files.mjs` | where the console's files live, how they are written safely, and the argument parser both command lines share |
|
||||
| `agents.mjs` | the rules of `~/.plan2code/agents.json` (see "Agents file" in [the install file](./AGENTS-architecture-install.md)), console side: `normalizeAgents()` reads the file into clean entries and warnings, never throwing; `validateForSave()` checks what User Preferences sends and names the first bad entry and field; `makeId()`, `buildArgs()` (the command line from an entry) and `resolveCommand()` (where a command runs from, never running it). Served by `GET` / `POST /agents` and `POST /agents/test` in `routes.mjs` |
|
||||
@@ -40,7 +40,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| loop setup `phaseStrength` / `strengths` | `loop-setup.mjs` keeps the per-project toggle and, per spec folder, a list of `{n, name, strength}` picks, pruned as specs finish and phases move (twin: `LoopSetup` in `loop_driver.rs`). `loop_driver.rs` starts a phase with `AgentManager::start_phase_on(prompt, model, effort, env)` and sets `PLAN2CODE_LOOP_STRENGTH` (thrifty, balanced or best) in its environment, which `cmd-open.mjs` reads to give the phase's helpers the same Helper strength line; a retry goes one step up with `models::next_strength` (Rust twin of `nextStrength`; a Match my session phase stays) |
|
||||
| `git-repo.mjs` | the one read-only reader of a git repository: the worktree status (`countPending()`, behind `pendingFiles()`), the branch table, the default branch, a merge or rebase in progress, the remotes and their web addresses, the last fetch and the pull-request link; `snapshot()` is what `open` and every `reread` store as `state.git`. Every git call carries `GIT_OPTIONAL_LOCKS=0`, so a background look never takes the index lock. Imported by `cmd-open.mjs`, `cmd-post-wait.mjs` and `sessions.mjs`; the git skill's `git.mjs` reaches it through `common.mjs` |
|
||||
| `handoffs.mjs` | the handoff store, the only code that names, lists, marks, deletes and sweeps handoffs, all in `~/.plan2code/handoffs/` (`PLAN2CODE_HANDOFFS_DIR` for tests; `PLAN2CODE_NOW` pins its clock): `newHandoff()` claims `YYYY-MM-DD-HHmm-handoff` (`-2`, `-3` on a clash, the `.json` created exclusively) and writes only `<id>.json` (`{ v: 1, id, title, worktree, project, spec, workflow, skill, written, fromStop, usedAt }`), the agent writing `<id>.md`; `listHandoffs(worktree)` (unused, same worktree, `.md` present, newest first, title and Next task read off the document); `readHandoffMeta()`, `markHandoffUsed()`; `removeHandoff()` (`HANDOFF_ID` only, regular files, never a link, realpath inside the folder, throws on any refusal); `staleHandoffs()` / `removeHandoffs()` for the sweep |
|
||||
| `learning.mjs` | Learning's core, shared with the `lessons.mjs` skill script: the one `learningState()` (not set up, off, on, paused, unknown), the repository key, the tracked `.plan2code/settings.json` read, and the two stores on this machine under `~/.plan2code/learning/<key>/` (`pause.json`, `waiting/<id>.json`; `PLAN2CODE_LEARNING_DIR` moves them for tests); `learningScan()` is the dashboard's `scan.learning`, read without pruning. Never writes into a project |
|
||||
| `learning.mjs` | Learning's core, shared with the `lessons.mjs` skill script: the one `learningState()` (not set up, off, on, paused, unknown), the repository key, the tracked `.plan2code/settings.json` read, and the stores on this machine under `~/.plan2code/learning/<key>/` (`pause.json`, `waiting/<id>.json`, `checks/`, and the append-only `follows.ndjson` that `followCounts()` sums on read; `PLAN2CODE_LEARNING_DIR` moves them for tests); `learningScan()` is the dashboard's `scan.learning`, read without pruning, with `nearCap` while Learning is On and general lessons reach 22 of 25 or an area file 30. Never writes into a project |
|
||||
| `notepads.mjs` | the notebook store (the feature is named Notebook; its code, routes and storage folder keep the name `notepad`), the only code that names, reads, writes and removes notebooks, one per folder Plan2Code runs in, in `~/.plan2code/notepads/<folder-name>-<12 hex>/` (`PLAN2CODE_NOTEPADS_DIR` for tests), split into named tabs: `meta.json` (`{ v: 2, folder, created }`), `tabs.json` (`{ v: 1, order, last, tabs: { id: { name, created, sent? } } }`) and `tabs/<id>/note.md` with `tabs/<id>/images/`. `notepadKey()` (the folder's basename slug and the first 12 hex of `sha256(foldKey(folder))`), `listTabs()` / `defaultTabId()`, `readNotepad(folder, tab)` (never creates or writes anything; `{ tabs, last, tab }` with the tab's `text`, `savedAt` and `images` repeated at the top), the tab changes `createTab()` / `renameTab()` / `reorderTabs()` / `setLastTab()` / `deleteTab()` (index first, then the folder; names pass `normalizeTabName()`, `TAB_NAME_MAX` 40, any case compared by `nameKey()`, `NOTEPAD_MAX_TABS` 20), `saveNote(folder, tab, text)` (1 MB cap, atomic), `addImage()` / `addThumb()` / `removeImage()` (JPEG bytes only, 200 pictures per tab, UUID names), `imagePath()` (regular files whose realpath stays inside the folder), `staleNotepads(now, maxAgeMs)` (the real folders directly under it named like a key, never a link or a file, whose newest file is at least `maxAgeMs` old, as `{ key, folder, path }` with `folder` from `meta.json` or null), `removeNotepad(key)` (the key checked against `NOTEPAD_KEY_RE`, the path kept inside the notepads folder by `path.relative`, a link refused, then the whole folder removed; User Preferences, Cleanup is its only caller) and `NotepadError` (`code` and `status`, turned into `{ error }` by the `/notepad` routes). **Migration:** a notepad in the first shape (`note.md` and `images/` at the top) reads as one virtual tab, Notes (`LEGACY_TAB_ID`), and writes nothing; its first write moves the files into `tabs/<LEGACY_TAB_ID>/` and writes `tabs.json` last, every step safe to run again after a crash. A `tabs.json` that does not hold up is set aside as `tabs.json.corrupt` and rebuilt from the tab folders on the next write. Every write runs under a `notepad.lock` in the notepad's folder. The agent CLI never imports it: nothing in a notepad reaches the agent |
|
||||
| `picker.mjs` | the per-OS native folder picker behind **Browse…** (`pickerCommand()` → `{ command, args, env }` or `null`; `pickFolder()` runs it with async `spawn`, so the server keeps serving while the dialog is open). Copied from `src/launcher/plan2code.js` (self-contained CommonJS, so it cannot be shared) with the prompt as a parameter; a drift test keeps the two in step |
|
||||
| `update-check.mjs` | the dashboard's release check, server-only (never in `SERVABLE`): `compareVersions()` (numeric X.Y.Z, `null` otherwise), `latestTag()` (the highest `refs/tags/vX.Y.Z`, peeled `^{}` and pre-release tags skipped), `checkForUpdate({ installed, cacheFile, now, run })` (never throws) and `runLsRemote()` (`git ls-remote --tags` on the repo: no shell, `GIT_TERMINAL_PROMPT=0`, `GCM_INTERACTIVE=never`, SSH `BatchMode` when `GIT_SSH_COMMAND` is unset, `windowsHide`, killed at 10 s; git authenticates itself, the console never touches a credential). The answer, failures included, is cached for an hour in `~/.plan2code/console/update-check.json` (`UPDATE_CHECK_FILE`, in `PROTECTED_CONSOLE_FILES` so no sweep removes it). `server.mjs` starts it after the ready line and never awaits it; `stateFrame()` carries `update: { installed, latest }` only when a newer release exists (its `latest` is part of `haveKey()`, so a page that connected first still gets it), and `GET /version` returns `{ version, latest }`. Tests seed a fresh cached failure in every console home, so no test server reaches the network. The `plan2code` launcher reads the same cache for its terminal release notice (a copy of this module sits in `~/.plan2code/bin/`) |
|
||||
|
||||
@@ -17,7 +17,8 @@ plan2code/
|
||||
│ │ └── trail.md # Every-response map visual + pathed resume command
|
||||
│ ├── shared-references/ # Reference files shared across skills
|
||||
│ │ ├── building-habits.md # Find the cause, test first, pin behavior (quick-task, implement, implement-review, test)
|
||||
│ │ ├── helper-strength.md # How strong a model and how much effort each helper gets (init, init-update, pathfinder, plan, revise-plan, document, quick-task, implement, implement-review, review, finalize, xray, diagnose, pr-prep, test)
|
||||
│ │ ├── helper-strength.md # How strong a model and how much effort each helper gets (dashboard, for the lesson check only, init, init-update, pathfinder, plan, revise-plan, document, quick-task, implement, implement-review, review, finalize, xray, diagnose, pr-prep, test)
|
||||
│ │ ├── lesson-check.md # Learning: the lesson checker's brief, four tests, verdicts and reasons, never edits (dashboard, implement, implement-review, review, quick-task, xray, diagnose, test)
|
||||
│ │ ├── lessons.md # Learning: the fixed words and when a skill runs each `lessons.mjs` command (dashboard, pathfinder, plan, revise-plan, document, implement, implement-review, review, finalize, quick-task, xray, diagnose, pr-prep, test, dead-code, ui-prototype)
|
||||
│ │ ├── review-in-build.md # The review a building skill runs on its own work (quick-task, implement, implement-review, review, finalize, dead-code)
|
||||
│ │ └── test-runs.md # Choosing what tests to run: targeted per task and phase, full suite only where the plan puts it (document, implement, implement-review, quick-task, review, finalize, pr-prep, test, dead-code)
|
||||
|
||||
@@ -34,7 +34,7 @@ Anything a workflow step decides with one correct answer (parsing a spec's check
|
||||
| `changelog-state.mjs` (own) | changelog | `state`, `bump`, `set-package-version`: the default branch's version, whether the branch's entry can be extended (not released, not on another branch), the file's heading style, the gap since the entry was last touched; only `set-package-version` writes, and only the version field |
|
||||
| `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` |
|
||||
| `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, an AGENTS.md fix or a `tidy` proposal (`--change merge|reword|retire|move --targets <ids>`), checked, then held as waiting; nothing while Off or Paused for you; a secret exits 5; a lesson may carry a literal search, `--shows-in <glob> --match should|never --text-match <text>`, its glob at most 120 characters and three `**`; a correction or convention needs `--why`; an inferred lesson from a read-only skill is refused) / `check-input [--tidy]` (the waiting lessons for the lesson check, oldest first and at most 10, each with its search already run and its named files hashed; a search looks only at the files git tracks or leaves unignored, listed once per command, so ignored build output is never searched; check files over a day old are pruned first) / `check-record --file` (validates the checker's verdicts, four tests of Pass, Doubt or Fail each with a reason, and stores them on the waiting items; exit 4 names the fault) / `follow --lesson <id> --skill <name>` (one line in `follows.ndjson` per "Following a lesson") / `tidy-input` (every saved lesson with its follow count and mark, for the tidy-up coach) / `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; with `--check <checkId>` the rows carry the verdicts, the outline and the how-checked line, `--check-failed` says why the check did not run) / `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, the waiting lessons (with their verdicts), `checks/` and `follows.ndjson` on this machine only, in `~/.plan2code/learning/<repository key>/`. `read` also writes there: a marked lesson whose search no longer matches becomes a waiting doubt. 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.
|
||||
|
||||
@@ -90,6 +90,7 @@ The same areas as one-command rows live in the [Test map](./AGENTS-test-map.md),
|
||||
| What changed | Run |
|
||||
|---|---|
|
||||
| An Activities game (`public/activities/*`), `public/tones.js` or `public/music.js` | `node --test scripts/test-web-console-tones.mjs scripts/test-web-console-activities.mjs`, plus the game's own `scripts/test-web-console-activities-<game>*.mjs` when it has one; add `test-web-console-page-activities.mjs` when the Activities window or its switches changed |
|
||||
| Page styles (`public/styles/*.css`) or `public/index.html` | `npm run test:page -- scripts/test-web-console-page-layout.mjs`, plus the page file of a screen whose own look changed (`test:page` unsets the app variables, takes `--test-name-pattern`, and is the way to run any page file) |
|
||||
| A music prototype (`prototypes/music/<game>/`) | `node prototypes/music/check.cjs <game>` (nothing in `npm test` reads `prototypes/`) |
|
||||
| One web console area (server routes, chat, git board, workspace, notepad, Implementation Loop...) | that area's `scripts/test-web-console-<area>.mjs` (the loop's is `test-web-console-loop.mjs`), and its `test-web-console-page-<area>.mjs` when the page changed; `node scripts/parse-check.mjs` after editing any browser module under `public/` |
|
||||
| The launcher (`src/launcher/`) | `node --test scripts/test-launcher.mjs` |
|
||||
@@ -148,7 +149,7 @@ The root `npm test` does not run the metrics or bot vitest suites; run them in t
|
||||
|------|--------|
|
||||
| `--build-skills` | Regenerate `skills/` from `src/`, pruning stale skills and reference files |
|
||||
| `--verify-skills` | Diff local `skills/` against `src/`; exits 1 on drift. Diagnostic only, the installer rebuilds anyway |
|
||||
| `--update [--force]` | No menu: reinstall what `~/.plan2code/install.json` lists (skills, launcher, app, statusline; metrics and bot only when run from a git checkout, since they run from the install folder, which npx's cache is not), never uninstalling; with no record, the skills and the `plan2code` command. Compact output: `Updating <old> -> <new>` from the record's version (or `Already on <new>`, which stops unless `--force`), each piece's own output held back (`captureOutput()`) and shown only for a warning or a failure, one summary with human piece names (`PIECE_LABELS`), the release notes link and the restart hint; a failed update also prints `plan2code update --tag v<old>`. A failed update, or one whose desktop app was kept because the release has no app file yet, puts the old version back on `install.json`, so the next update (the app's Update and restart included) runs instead of stopping at Already on. `plan2code update` runs it through npx, pinned to the newest `vX.Y.Z` tag the launcher finds with update-check.mjs's `git ls-remote` pick (`--main` takes the tip of `main`, `--tag <ref>` any ref, `--force` is passed on; `PLAN2CODE_LS_REMOTE_FILE` replaces the git call in tests) |
|
||||
| `--update [--force]` | No menu: reinstall what `~/.plan2code/install.json` lists (skills, launcher, app, statusline; metrics and bot only when run from a git checkout, since they run from the install folder, which npx's cache is not), never uninstalling; with no record, the skills and the `plan2code` command. Compact output: `Updating <old> -> <new>` from the record's version (or `Already on <new>`, which stops unless `--force`, and only when the installed command's `bin/version.json` agrees with the record, so an update stopped after its skills step installs again), each piece's own output held back (`captureOutput()`) and shown only for a warning or a failure, one summary with human piece names (`PIECE_LABELS`), the release notes link and the restart hint; a failed update also prints `plan2code update --tag v<old>`. While an update runs, record writes keep the old version (`recordVersionHold`) and the new one is stamped only when every piece is in; a failed update, or one whose desktop app was kept because the release has no app file yet, leaves the old version on `install.json`, so the next update (the app's Update and restart included) runs instead of stopping at Already on. `plan2code update` runs it through npx, pinned to the newest `vX.Y.Z` tag the launcher finds with update-check.mjs's `git ls-remote` pick (`--main` takes the tip of `main`, `--tag <ref>` any ref, `--force` is passed on; `PLAN2CODE_LS_REMOTE_FILE` replaces the git call in tests) |
|
||||
| `--uninstall [--yes] [--purge]` | No menu: confirm y/N (`--yes` skips it), run `uninstallAll()`, then ask whether to also delete `~/.plan2code` (`purgeData()`; `--purge` says yes without asking, `--yes` alone keeps the data). `uninstallAll()` is driven by the pieces `install.json` records plus a quiet probe for strays (`UNINSTALL_STEPS`, `UNINSTALL_PROBES`), prints one line per piece actually removed, falls back to deleting the `plan2code*` folders under `~/.agents/skills` when the skills CLI is unreachable, and removes the versioned console folders and `console-dir` (`removeConsoleFolders()`, stopping a running console first). What stays in `~/.plan2code` is listed by name with its size (`listKeptData()`), and the run always ends with the Removed / Could not remove / To finish block (`printUninstallReport()`). Deleting the data also removes the app's webview data outside `~/.plan2code` (`appWebviewDirs()`, `purgeAppWebview()`), and a running app is named before anything is removed (`appRunning()`). `plan2code uninstall [--yes] [--purge]` runs it through npx |
|
||||
|
||||
## How the Installer Works
|
||||
|
||||
@@ -7,6 +7,7 @@ Which checks cover which files, read by PR Prep and Test (`test-map.mjs read` ch
|
||||
|---|---|---|---|
|
||||
| Activities games | `src/web-console/public/activities/**`, `src/web-console/public/tones.js`, `src/web-console/public/music.js` | `node --test scripts/test-web-console-tones.mjs scripts/test-web-console-activities.mjs` | no |
|
||||
| Launcher | `src/launcher/**` | `node --test scripts/test-launcher.mjs` | no |
|
||||
| Installer update | `scripts/test-install-update.mjs` | `node --test scripts/test-install-update.mjs` | no |
|
||||
| Dead Code script | `src/plan2code-dead-code-scripts/**`, `scripts/fixtures/dead-code/**` | `npm run build:skills && node scripts/node-test.mjs scripts/test-script-dead-code.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 |
|
||||
@@ -17,5 +18,6 @@ Which checks cover which files, read by PR Prep and Test (`test-map.mjs read` ch
|
||||
| Desktop app | `plan2code-app/**` | `cd plan2code-app && cargo test` | no |
|
||||
| Metrics | `plan2code-metrics/**` | `cd plan2code-metrics && npm test` | no |
|
||||
| Bot | `plan2code-bot/**` | `cd plan2code-bot && npm test` | no |
|
||||
| Web console page shell and styles | `src/web-console/public/styles/**`, `src/web-console/public/index.html` | `npm run test:page -- scripts/test-web-console-page-layout.mjs` | no |
|
||||
| Shared code | `install.js`, `src/web-console/public/skills.js`, `src/web-console/console.mjs`, `src/web-console/routes.mjs`, `src/web-console/static.mjs`, `scripts/*-helpers.mjs` | `npm test` | yes |
|
||||
| Docs only | `**/*.md` | `node --test scripts/test-us-english.mjs scripts/test-line-endings.mjs` | no |
|
||||
@@ -1 +1 @@
|
||||
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 truncated
|
||||
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 truncated
|
||||
@@ -81,7 +81,18 @@ jobs:
|
||||
defaults:
|
||||
run:
|
||||
working-directory: plan2code-app
|
||||
env:
|
||||
# Debug info and incremental state are most of target/'s size; the ubuntu
|
||||
# runner ran out of disk building both the debug and the release app.
|
||||
CARGO_INCREMENTAL: 0
|
||||
CARGO_PROFILE_DEV_DEBUG: 0
|
||||
steps:
|
||||
- name: Free disk space on the Linux runner
|
||||
if: runner.os == 'Linux'
|
||||
working-directory: .
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
|
||||
df -h /
|
||||
- uses: actions/checkout@v7.0.1
|
||||
- uses: actions/setup-node@v7.1.0
|
||||
with:
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
- About: install.js
|
||||
- Noted: 2026-11-17, implement-review
|
||||
|
||||
### Every heading and .md-h gets text-wrap: balance from tokens.css, so a long heading such as a lesson title splits into two even halves; set text-wrap: wrap where a heading runs longer than a line.
|
||||
- Kind: how-it-works
|
||||
- About: src/web-console/public/styles/tokens.css, src/web-console/public/styles/learning.css
|
||||
- Noted: 2026-11-19, quick-task
|
||||
|
||||
### In a Markdown field (md-field.js), CodeMirror's scroller and content are only as tall as the text, not the bordered host: code that hit-tests the scroller must not assume it fills the box.
|
||||
- Kind: how-it-works
|
||||
- About: src/web-console/public/md-field.js
|
||||
|
||||
@@ -169,8 +169,8 @@ origin.
|
||||
| `POST /open-prototype` | `{ spec, name }`: opens one `.html` from `<spec>/prototypes/` in the person's default browser. 404 for any other name, 500 when no browser could start. |
|
||||
| `GET /handoff?id=<id>` | *Read it all*: the handoff's `.md` from `~/.plan2code/handoffs/`, as `text/markdown` with `cache-control: no-store`. A dashboard only, and only an id its own scan listed: a used, unknown or malformed id is 404. |
|
||||
| `POST /learning/pause` | Pause for me: `{ paused: boolean }` (origin-checked; anything else is 400 `bad-request`, and 409 `not-on` unless Learning is On or Paused for you). Writes the personal pause on this machine only (`pause.json` under `~/.plan2code/learning/<key>/`), the server's only write for Learning, and repaints the row with no agent. |
|
||||
| `GET /learning/state` | The Learning row's state worked out now, `{ state, pausedSince, waiting, oldestDays }` (`{}` when the project's settings file is from a format it cannot read), with `cache-control: no-store`. |
|
||||
| `GET /learning/lessons` | Open the lessons, read only: `{ files: [{ name, title, text }] }` from the project's lessons (`.plan2code/lessons/`, saved with the repository), `general.md` first, then the other `.md` files in name order (plain files only, at most 100 of 512 KB each), with `cache-control: no-store`. |
|
||||
| `GET /learning/state` | The Learning row's state worked out now, `{ state, pausedSince, waiting, oldestDays, nearCap }` (`{}` when the project's settings file is from a format it cannot read), with `cache-control: no-store`. |
|
||||
| `GET /learning/lessons` | Open the lessons, read only: `{ files: [{ name, title, text }], follows: { <lesson id>: { count, last } } }` (follows from this machine's `follows.ndjson`, for the reader's "Followed N times" line) from the project's lessons (`.plan2code/lessons/`, saved with the repository), `general.md` first, then the other `.md` files in name order (plain files only, at most 100 of 512 KB each), with `cache-control: no-store`. |
|
||||
| `GET /workspace` | The Workspace dialog's list: folders, `missing`, `remote` and the agent's folder `issues`. `?check=1` re-checks every folder on disk first. |
|
||||
| `POST /workspace/add` | `{ path, name?, description? }`. The path is resolved against the folder the session started in (`~` expanded) and must be a folder: 400 `not-a-folder`, `duplicate` (with its `name`; compared case-insensitively on Windows and macOS), `bad-name`, or `name-taken` with a `suggest`. Answers the new entry, `nested: true` when it sits inside another folder in the list. |
|
||||
| `POST /workspace/edit` | `{ id, name?, description? }`. Renames or re-describes one folder: 400 `bad-name` / `name-taken`, 404 `unknown`. |
|
||||
|
||||
@@ -113,7 +113,7 @@ The easy way in is the dashboard: type `/plan2code` in your agent, or run `plan2
|
||||
- **Specs and their states.** The picker at the top chooses the spec. A diagnosed bug reads *Bug diagnosed* (Quick task suggested, Plan lit), then *Bug fixed* once Quick task has fixed it; a held-back upgrade from Update dependencies reads *Upgrade ready*, then *Upgrade done*. A finished one can be archived, or deleted from its chip.
|
||||
- **Handoffs.** Handoffs this folder has not picked up follow the specs as dashed chips. Select one to preview it, then **Pick it up here**, **Read it all**, **Copy for a new conversation** or **Delete**. They live in `~/.plan2code/handoffs/`, written by *Stop with a handoff* (below) and by the Handoff skill.
|
||||
- **Git and the utilities.** **Git** opens a board with three tabs (Changes, Branches, Sync) and asks before every push, publish and delete; outside a repository it offers to start one. **Codebase X-ray**, **Diagnose a bug** and **Update dependencies** are always available too.
|
||||
- **Learning.** A row shows *Not set up*, *Off*, *On* or *Paused for you*; **Pause for me** pauses it for you alone. A banner offers **Review** while lessons are waiting. Kept lessons go to `.plan2code/lessons/` in the project; waiting lessons and your pause stay on this machine, and nothing is committed for you.
|
||||
- **Learning.** A row shows *Not set up*, *Off*, *On* or *Paused for you*; **Pause for me** pauses it for you alone. A banner offers **Review** while lessons are waiting. Before you see them, each waiting lesson is checked against the code by a separate reader, and the card shows any Doubt or Fail with its reason (and, where it helps, a better wording to use); you still decide. The lessons reader shows how often each lesson was followed. **More, Tidy up lessons** (and a banner nudge once general lessons reach 22 of 25, or an area file 30) has the agent propose merges, rewords, retires and moves, one change each, checked like any lesson and applied only on your **Apply**. Kept lessons go to `.plan2code/lessons/` in the project; waiting lessons and your pause stay on this machine, and nothing is committed for you.
|
||||
- **Planny wakes up.** A fresh dashboard starts with him asleep; click to wake him (**Skip** or Escape skips it, and reduced motion shows the awake dashboard at once).
|
||||
|
||||
Or start any step by its command (the full list is in the README's [Prefer the terminal?](../README.md#prefer-the-terminal) section), and add `--web` to open the console without being asked: `/plan2code-1-plan --web plan a lunch voting app`. Without it, the first question is "In your browser (suggested)" or "Here in the terminal". The page opens straight away at a `127.0.0.1` address, with a starting screen while the skill reads your project. You can switch to the terminal at any point: the files under `specs/` are the same either way.
|
||||
|
||||
@@ -36,11 +36,11 @@ Details: [Status line](./.agents-docs/AGENTS-architecture-statusline.md)
|
||||
|
||||
## Web Console
|
||||
|
||||
Optional local browser UI (`src/web-console/`, zero dependencies, detached `node` server on `127.0.0.1`) installed once under `~/.plan2code/console/<version>/` (`installSharedConsole` in `install.js`) and reached from every skill through a forwarding stub, `src/web-console-stub/console.mjs`. The bare `plan2code` skill opens its dashboard, a card menu that launches any skill in the same session. Pages cover questions, sign-off gates (with an in-page code review, 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 (a Save, Share, Review, Tidy path, one task card for the step you are on, and the Changes, Branches and Sync tabs folded into **All branches and tools**; 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 woLine 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 (a Save, Share, Review, Tidy path, one task card for the step you are on, and the Changes, Branches and Sync tabs folded into **All branches and tools**; 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 woLine 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`.
|
||||
|
||||
**Learning** (lessons about a codebase, kept with it): the dashboard draws a Learning row (Not set up, Off, On or Paused for you, with a Pause for me switch and a More menu) and, while lessons are waiting, a banner with Review, both from the scan's `learning` field (`public/screens/learning-row.js`, `public/styles/learning.css`); skills ask for approval through the `lessons` card kind. The server's only write for it is the personal pause, on this machine only (`POST /learning/pause`, under `~/.plan2code/learning/`); every change to the project's Learning files (`.plan2code/settings.json` and `.plan2code/lessons/`) goes through the `lessons.mjs` skill script, which shares one core with the scan, `src/web-console/learning.mjs`.
|
||||
**Learning** (lessons about a codebase, kept with it): the dashboard draws a Learning row (Not set up, Off, On or Paused for you, with a Pause for me switch and a More menu) and, while lessons are waiting, a banner with Review (plus a Tidy up nudge from the scan's `nearCap`; More, Tidy up lessons sends the `tidy` action, which writes `tidy` waiting items the same card applies), both from the scan's `learning` field (`public/screens/learning-row.js`, `public/styles/learning.css`); skills ask for approval through the `lessons` card kind. Before that card, every waiting lesson is graded by a separate check, a fresh read-only helper where the agent has one, else a labeled second pass by the same agent (`src/shared-references/lesson-check.md`; `lessons.mjs check-input` prepares, the checker judges, `check-record` stores), and the card shows each Doubt or Fail with its reason; follows ("Following a lesson") are counted on this machine only, in `follows.ndjson`, for the lessons reader. The server's only write for it is the personal pause, on this machine only (`POST /learning/pause`, under `~/.plan2code/learning/`); every change to the project's Learning files (`.plan2code/settings.json` and `.plan2code/lessons/`) goes through the `lessons.mjs` skill script, which shares one core with the scan, `src/web-console/learning.mjs`.
|
||||
Building or changing an Activities game: follow the game rules in [Activities](./.agents-docs/AGENTS-architecture-activities.md) ("Building an Activities game": lives in the solid lives pill, the endless-lives code (`cheat(on)`) in every game with lives, banners placed away from the player and see-through over what matters, pausing left to the window).
|
||||
Details: [Web console server and contract](./.agents-docs/AGENTS-architecture-console.md), [page](./.agents-docs/AGENTS-architecture-console-page.md), [design points](./.agents-docs/AGENTS-architecture-console-design.md), [Activities](./.agents-docs/AGENTS-architecture-activities.md) (and the Ghoul Rush and Bounce Road files it links) [.readme/web-console.md](./.readme/web-console.md) (the user guide), [.readme/activities.md](./.readme/activities.md) and [.readme/web-console-internals.md](./.readme/web-console-internals.md) (routes, security, driving it by hand, refreshing screenshots)
|
||||
Why the agent-facing console docs are shaped as they are (the card, pointers, refusals): [Web Console Contract](./.agents-docs/AGENTS-web-console-contract.md); it never ships.
|
||||
|
||||
@@ -4,6 +4,25 @@ All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
<!-- Format from 3.1.0 on: `## vX.Y.Z (YYYY-MM-DD)` with the date from version.json; a minor release opens with a three-bullet `### Highlights`; sections run Added, Changed, Fixed; game changes sit under one Activities line; tooling and test lines go under "For contributors". Older headings have no date and are not backfilled. -->
|
||||
|
||||
## v3.1.5 (2026-11-23)
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
- **desktop app**: Change project, and picking a recent folder, now starts the new project's agent and dashboard; before, the agent opened inside the old project's stopped session and never showed its page.
|
||||
- **web console**: the page itself no longer scrolls (its panels do), so the blank space that could show below the footer is gone; the narrow-window layout and printing follow the same rule.
|
||||
- **For contributors**: `npm run test:page -- <file>` runs page test files with the desktop app's variables unset, and a new layout page test checks that the page shell never scrolls.
|
||||
|
||||
## v3.1.4 (2026-11-20)
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **launcher**: the model menu offers Claude Fable 5.2 in place of 5.1, Gemini 4 Hydrogen and Gemini 4 Neon for Devin, and GPT-6.2 Astra and GPT-6.2 Sol for Codex; Gemini 3.8 Flash, GLM-5.3 Low and SWE-2 Flash Medium leave Devin's list, and Claude's `haiku` and `fable` labels follow the Claude Code docs.
|
||||
- **launcher**: Claude Code's install options add the Windows CMD installer and install `@latest` through npm, the OpenCode starter template opens with `@plan2code`, and the Gemini CLI note also names Gemini Code Assist for GitHub.
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
- **launcher**: `plan2code update` no longer stops at "Already on" after an earlier update stopped partway and left the `plan2code` command on the old version; the install record keeps the old version until every piece is in.
|
||||
|
||||
## v3.1.3 (2026-11-18)
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
Plan2Code is a spec-driven workflow for AI coding agents. You work through it on a page in your browser: the dashboard lists every step as a card, and each step's questions, progress and sign-offs arrive on that same page while your agent does the work. An approved plan becomes phase documents, and the agent builds to them one phase at a time.
|
||||
|
||||
Version 3.1.3 · Apache 2.0 · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
Version 3.1.5 · Apache 2.0 · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+62
-17
@@ -170,7 +170,9 @@ const SOURCE_PROMPTS = [
|
||||
scripts: ['lessons.mjs', 'glob.mjs', 'test-map.mjs'],
|
||||
additionalReferences: [
|
||||
{ source: 'web-console', target: 'web-console' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -240,7 +242,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'plan2code-review-references' },
|
||||
{ source: 'plan2code-ui-prototype.md', target: 'ui-prototype.md' },
|
||||
{ source: 'plan2code-ui-prototype-references' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -310,7 +313,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'shared-references/test-runs.md', target: 'test-runs.md' },
|
||||
{ source: 'plan2code-review.md', target: 'review.md' },
|
||||
{ source: 'plan2code-review-references' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -329,7 +333,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'shared-references/test-runs.md', target: 'test-runs.md' },
|
||||
{ source: 'plan2code-review.md', target: 'review.md' },
|
||||
{ source: 'plan2code-review-references' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -347,7 +352,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'shared-references/review-in-build.md', target: 'review-in-build.md' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' },
|
||||
{ source: 'shared-references/test-runs.md', target: 'test-runs.md' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -392,7 +398,8 @@ const SOURCE_PROMPTS = [
|
||||
additionalReferences: [
|
||||
{ source: 'web-console', target: 'web-console' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -409,7 +416,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'web-console', target: 'web-console' },
|
||||
{ source: 'shared-references/building-habits.md', target: 'building-habits.md' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -444,7 +452,8 @@ const SOURCE_PROMPTS = [
|
||||
{ source: 'shared-references/test-runs.md', target: 'test-runs.md' },
|
||||
{ source: 'shared-references/building-habits.md', target: 'building-habits.md' },
|
||||
{ source: 'shared-references/helper-strength.md', target: 'helper-strength.md' },
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' }
|
||||
{ source: 'shared-references/lessons.md', target: 'lessons.md' },
|
||||
{ source: 'shared-references/lesson-check.md', target: 'lesson-check.md' }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2569,8 +2578,13 @@ function readInstallRecord() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// While update() runs, every record write keeps the version the update started from (`{ version }`),
|
||||
// so an update stopped partway (Ctrl+C, a closed window, a killed child) never leaves the record
|
||||
// claiming the new version over pieces that are still old. update() stamps the new one at the end.
|
||||
let recordVersionHold = null;
|
||||
|
||||
/** Temp file, then rename, so a crash never leaves a half-written record. A failure only skips the record. */
|
||||
function writeInstallRecord(pieces, skipped = (readInstallRecord() || {}).skipped || [], version = projectVersion.version) {
|
||||
function writeInstallRecord(pieces, skipped = (readInstallRecord() || {}).skipped || [], version = recordVersionHold ? recordVersionHold.version : projectVersion.version) {
|
||||
const record = {
|
||||
version,
|
||||
scope: 'global',
|
||||
@@ -2591,15 +2605,25 @@ function writeInstallRecord(pieces, skipped = (readInstallRecord() || {}).skippe
|
||||
}
|
||||
|
||||
/**
|
||||
* Put `version` back in the record (null when none was known) without touching its pieces: every
|
||||
* recordInstalled() stamps the version being installed, so an update that failed uses this to
|
||||
* stay behind, and the next `plan2code update` does not answer "Already on".
|
||||
* Write `version` on the record without touching its pieces: update() uses it to stamp the new
|
||||
* version once every piece is in, and to keep the old one (null when none was known) after a
|
||||
* failure or a kept app, so the next `plan2code update` does not answer "Already on".
|
||||
*/
|
||||
function setRecordVersion(version) {
|
||||
const record = readInstallRecord();
|
||||
if (record) writeInstallRecord(record.pieces, record.skipped || [], version);
|
||||
}
|
||||
|
||||
/** The version in the installed plan2code command's version.json, or null when it is missing or unreadable. */
|
||||
function installedLauncherVersion() {
|
||||
try {
|
||||
const { version } = JSON.parse(fs.readFileSync(LAUNCHER_VERSION_DEST, 'utf8'));
|
||||
return typeof version === 'string' ? version : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a piece after a successful global install. */
|
||||
function recordInstalled(piece) {
|
||||
const record = readInstallRecord();
|
||||
@@ -3725,7 +3749,8 @@ function releaseNotesUrl(version) {
|
||||
/**
|
||||
* Reinstall whatever ~/.plan2code/install.json lists, without the menu or any prompt, and print
|
||||
* one compact summary: `Updating <old> -> <new>` (or `Already on <new>`, which stops early unless
|
||||
* `force`), one line per piece by its human name, then the release notes link and the restart
|
||||
* `force`, and only when the installed command's bin/version.json agrees with the record whenever
|
||||
* the record lists `launcher`), one line per piece by its human name, then the release notes link and the restart
|
||||
* hint. Each piece's own output is held back and shown only when that piece warns or fails.
|
||||
* Returns the exit code: 0 when every piece updated, 1 naming the pieces that failed.
|
||||
*/
|
||||
@@ -3733,15 +3758,33 @@ async function update({ steps = UPDATE_STEPS, cleanShims = removeLegacyLoopShims
|
||||
const record = readInstallRecord();
|
||||
const version = projectVersion.version;
|
||||
const before = record && typeof record.version === 'string' ? record.version : null;
|
||||
if (before === version && !force) {
|
||||
const pieces = record ? record.pieces : ['skills', 'launcher'];
|
||||
// The record alone is not proof: an update stopped before its launcher step (or one run by a
|
||||
// launcher too old to pass --force on) left the record new and the command old, and every later
|
||||
// update stopped here. The command's own version.json says what is really in place.
|
||||
const launcherVersion = pieces.includes('launcher') ? installedLauncherVersion() : version;
|
||||
if (before === version && launcherVersion === version && !force) {
|
||||
console.log(`${COLORS.GREEN}${MARKS.DONE}${COLORS.RESET} Already on ${version}`);
|
||||
console.log(`${COLORS.DIM}Run plan2code update --force to install it again.${COLORS.RESET}`);
|
||||
return 0;
|
||||
}
|
||||
console.log(`${COLORS.BRIGHT}${before ? `Updating ${before} -> ${version}` : `Updating to ${version}`}${COLORS.RESET}`);
|
||||
const pieces = record ? record.pieces : ['skills', 'launcher'];
|
||||
if (before === version && launcherVersion !== version && !force) {
|
||||
console.log(`${COLORS.DIM}The plan2code command is still on ${launcherVersion || 'an unknown version'}, so everything is installed again.${COLORS.RESET}`);
|
||||
}
|
||||
if (!record) console.log(`${COLORS.DIM}No install record found; updating the skills and the plan2code command.${COLORS.RESET}`);
|
||||
|
||||
recordVersionHold = { version: before };
|
||||
try {
|
||||
return await updatePieces({ steps, cleanShims, pieces, before, version });
|
||||
} finally {
|
||||
recordVersionHold = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** update()'s body once it has decided to install: the pieces, the summary, and the version stamp. */
|
||||
async function updatePieces({ steps, cleanShims, pieces, before, version }) {
|
||||
|
||||
await captureOutput(async () => cleanShims());
|
||||
|
||||
const results = {};
|
||||
@@ -3798,7 +3841,7 @@ async function update({ steps = UPDATE_STEPS, cleanShims = removeLegacyLoopShims
|
||||
console.log('');
|
||||
if (failed.length > 0) {
|
||||
console.log(`${COLORS.RED}${MARKS.FAIL} Update failed for: ${failed.join(', ')}${COLORS.RESET}`);
|
||||
// The pieces that did install stamped the new version on the record: take it back, so running
|
||||
// Keep the old version on the record (writes during the update already held it), so running
|
||||
// plan2code update again retries instead of stopping at "Already on".
|
||||
setRecordVersion(before);
|
||||
console.log(`To try again, run: ${COLORS.CYAN}plan2code update${COLORS.RESET}`);
|
||||
@@ -3809,7 +3852,9 @@ async function update({ steps = UPDATE_STEPS, cleanShims = removeLegacyLoopShims
|
||||
// The release had no desktop app file yet, so the installed app is still the old one: keep the
|
||||
// old version on the record, or the next update (the app's Update and restart among them) stops
|
||||
// at "Already on" and never fetches the app once the file is attached.
|
||||
if (before && typeof results.app === 'string' && results.app.startsWith('kept')) setRecordVersion(before);
|
||||
// Otherwise every piece is in: only now does the record name the new version.
|
||||
const appKept = typeof results.app === 'string' && results.app.startsWith('kept');
|
||||
setRecordVersion(before && appKept ? before : version);
|
||||
console.log(`${COLORS.GREEN}${MARKS.DONE} Plan2Code is up to date (v${version})${COLORS.RESET}`);
|
||||
console.log(`What's new: ${releaseNotesUrl(version)}`);
|
||||
console.log('Close any open Plan2Code console or app and start `plan2code` again.');
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
@@ -17,7 +17,8 @@
|
||||
"play": "node scripts/play.mjs",
|
||||
"pretest": "node scripts/fix-line-endings.mjs",
|
||||
"test:fast": "node scripts/test-fast.mjs",
|
||||
"test": "node scripts/check-test-lanes.mjs && node scripts/validate-char-count.js && node install.js --build-skills && node scripts/check-versions.mjs && node scripts/check-doc-size.mjs && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/check-prompt-wording.mjs && node scripts/check-console-openings.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-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
|
||||
"test:page": "node scripts/run-page-tests.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-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-layout.mjs scripts/test-web-console-page-learning.mjs scripts/test-web-console-page-session.mjs scripts/teLine truncated
|
||||
},
|
||||
"devDependencies": {
|
||||
"gpt-tokenizer": "2.9.0",
|
||||
|
||||
Generated
+2
-2
@@ -957,7 +957,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fake-agent"
|
||||
version = "3.1.3"
|
||||
version = "3.1.5"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"terminal_size",
|
||||
@@ -2647,7 +2647,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "plan2code-app"
|
||||
version = "3.1.3"
|
||||
version = "3.1.5"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fake-agent"
|
||||
version = "3.1.3"
|
||||
version = "3.1.5"
|
||||
description = "A stand-in agent program for the Plan2Code app's tests"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "plan2code-app",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.12.4",
|
||||
"@xterm/addon-fit": "0.11.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"private": true,
|
||||
"description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "plan2code-app"
|
||||
version = "3.1.3"
|
||||
version = "3.1.5"
|
||||
description = "Plan2Code desktop app"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
@@ -1139,6 +1139,14 @@ fn teardown_project(state: &AppState) -> Result<(), String> {
|
||||
let _ = sup.stop();
|
||||
}
|
||||
}
|
||||
// The new project's agent asks the window which session is current and
|
||||
// joins it; left at the old project's (its console just stopped), its
|
||||
// `open` joined a dead page and the dashboard never showed.
|
||||
if let Ok(guard) = state.announce.lock() {
|
||||
if let Some(server) = guard.as_ref() {
|
||||
server.forget_current();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2011,8 +2019,22 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_session_forgets_the_windows_session_so_the_fresh_agent_starts_its_own() {
|
||||
fn changing_project_forgets_the_old_projects_session_so_the_new_agent_starts_its_own() {
|
||||
// The new agent's `open` asks the window which session is current; left
|
||||
// at the old project's (its console torn down) it joined a dead page
|
||||
// and never showed its dashboard.
|
||||
let state = state_for("project-a");
|
||||
announce_page(&state, "s1");
|
||||
teardown_project(&state).unwrap();
|
||||
assert_eq!(
|
||||
state.announce.lock().unwrap().as_ref().unwrap().current(),
|
||||
None,
|
||||
"the new project's agent must not join the old project's s1"
|
||||
);
|
||||
}
|
||||
|
||||
/// Starts the announce server on `state` and announces page `sid` to it.
|
||||
fn announce_page(state: &AppState, sid: &str) {
|
||||
let server = AnnounceServer::start(Arc::new(|_| true)).unwrap();
|
||||
let port: u16 = server
|
||||
.url()
|
||||
@@ -2023,7 +2045,8 @@ mod tests {
|
||||
.parse()
|
||||
.unwrap();
|
||||
*state.announce.lock().unwrap() = Some(server);
|
||||
let body = r#"{"url":"http://127.0.0.1:5000/s/abc/","sid":"s1","workflow":"plan"}"#;
|
||||
let body =
|
||||
format!(r#"{{"url":"http://127.0.0.1:5000/s/abc/","sid":"{sid}","workflow":"plan"}}"#);
|
||||
let mut stream = std::net::TcpStream::connect(("127.0.0.1", port)).unwrap();
|
||||
let token = state
|
||||
.announce
|
||||
@@ -2055,8 +2078,14 @@ mod tests {
|
||||
.unwrap()
|
||||
.current()
|
||||
.map(|n| n.sid),
|
||||
Some("s1".to_string())
|
||||
Some(sid.to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_session_forgets_the_windows_session_so_the_fresh_agent_starts_its_own() {
|
||||
let state = state_for("project-a");
|
||||
announce_page(&state, "s1");
|
||||
|
||||
// No console supervised here, so no brief to write: only the forgetting.
|
||||
assert_eq!(before_fresh_hook(&state)(), None);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Plan2Code",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"identifier": "com.plan2code.desktop",
|
||||
"build": {
|
||||
"frontendDist": "../ui",
|
||||
|
||||
@@ -351,7 +351,7 @@ function makeLearningProject() {
|
||||
const note = (text, kind, about) =>
|
||||
spawnSync(
|
||||
process.execPath,
|
||||
[path.join(ROOT, "src", "skill-scripts", "lessons.mjs"), "note", "--type", "lesson", "--text", text, "--kind", kind, "--about", about, "--source", "said", "--skill", "implement"],
|
||||
[path.join(ROOT, "src", "skill-scripts", "lessons.mjs"), "note", "--type", "lesson", "--text", text, "--kind", kind, "--about", about, "--source", "said", "--skill", "implement", ...(kind === "convention" ? ["--why", "An offset skips rows when the list changes between pages."] : [])],
|
||||
{ cwd: project, env: ENV, encoding: "utf8" }
|
||||
);
|
||||
note("Every list endpoint pages with a cursor, never an offset.", "convention", "src/tasks");
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,22 @@
|
||||
// Runs page test files the way CI does: the PLAN2CODE_* app variables are
|
||||
// unset first, because inherited from the desktop app (or an agent running
|
||||
// inside it) they fail about a dozen unrelated tests. Files run through
|
||||
// node-test.mjs, so its cap of one file per spare core applies. Extra
|
||||
// arguments (such as --test-name-pattern "<name>") pass straight through.
|
||||
// Usage: npm run test:page -- scripts/test-web-console-page-layout.mjs
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const env = { ...process.env };
|
||||
for (const name of Object.keys(env)) if (name.startsWith("PLAN2CODE_") && /^PLAN2CODE_(IN_APP|APP_|EMBED_ORIGIN|CONSOLE_SID|LOOP_STRENGTH)/.test(name)) delete env[name];
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (!args.length) {
|
||||
console.error("Usage: npm run test:page -- <scripts/test-web-console-page-*.mjs ...> [--test-name-pattern <name>]");
|
||||
process.exit(2);
|
||||
}
|
||||
const runner = path.join(path.dirname(fileURLToPath(import.meta.url)), "node-test.mjs");
|
||||
const r = spawnSync(process.execPath, [runner, ...args], { env, stdio: "inherit" });
|
||||
process.exit(r.status ?? 1);
|
||||
@@ -175,9 +175,18 @@ test("update: prints the version change, one line per piece by name, the release
|
||||
assert.doesNotMatch(out, /Happy coding|PARAMETERS|To go back to a release/);
|
||||
});
|
||||
|
||||
const LAUNCHER_VERSION = path.join(HOME, ".plan2code", "bin", "version.json");
|
||||
|
||||
/** The installed plan2code command's version.json, as installLauncher() writes it. */
|
||||
function writeLauncherVersion(version) {
|
||||
fs.mkdirSync(path.dirname(LAUNCHER_VERSION), { recursive: true });
|
||||
fs.writeFileSync(LAUNCHER_VERSION, JSON.stringify({ name: "Plan2Code", version }));
|
||||
}
|
||||
|
||||
test("update: already on the new version it says so and stops, until --force", async () => {
|
||||
fs.mkdirSync(path.dirname(RECORD), { recursive: true });
|
||||
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["skills", "launcher"] }));
|
||||
writeLauncherVersion(VERSION);
|
||||
const idle = fakeSteps();
|
||||
const stopped = await runUpdate(idle.steps);
|
||||
assert.equal(stopped.code, 0, stopped.out);
|
||||
@@ -202,6 +211,52 @@ test("update: already on the new version it says so and stops, until --force", a
|
||||
assert.match(out, new RegExp(`Updating ${VERSION.replace(/\./g, "\\.")} -> ${VERSION.replace(/\./g, "\\.")}`));
|
||||
});
|
||||
|
||||
test("update: a record on the new version over an older plan2code command installs again, without --force", async () => {
|
||||
// An update stopped after the skills step: the record says new, the command is still old.
|
||||
fs.mkdirSync(path.dirname(RECORD), { recursive: true });
|
||||
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["skills", "launcher"] }));
|
||||
for (const launcher of ["1.0.0", null]) {
|
||||
if (launcher) writeLauncherVersion(launcher);
|
||||
else fs.rmSync(LAUNCHER_VERSION, { force: true });
|
||||
const fake = fakeSteps();
|
||||
const { code, out } = await runUpdate(fake.steps);
|
||||
assert.equal(code, 0, out);
|
||||
assert.doesNotMatch(out, /Already on/);
|
||||
assert.match(out, new RegExp(`The plan2code command is still on ${launcher ? "1\\.0\\.0" : "an unknown version"}`));
|
||||
assert.deepEqual(fake.ran(), ["skills"]);
|
||||
assert.match(out, /plan2code command: updated/);
|
||||
}
|
||||
// A record without the command does not look at its version.json.
|
||||
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["statusline"] }));
|
||||
const idle = fakeSteps();
|
||||
assert.match((await runUpdate(idle.steps)).out, /Already on/);
|
||||
assert.deepEqual(idle.ran(), []);
|
||||
});
|
||||
|
||||
test("update: the record keeps the old version until every piece is in, so a stopped update retries", async () => {
|
||||
writeRecord(["skills", "launcher", "app"]);
|
||||
const seen = [];
|
||||
const fake = fakeSteps();
|
||||
// As the real steps: each records its piece as it finishes.
|
||||
for (const piece of ["skills", "app"]) {
|
||||
const step = fake.steps[piece];
|
||||
fake.steps[piece] = async (options) => {
|
||||
const code = await step(options);
|
||||
installer.recordInstalled(piece);
|
||||
seen.push(installer.readInstallRecord().version);
|
||||
return code;
|
||||
};
|
||||
}
|
||||
const { code, out } = await runUpdate(fake.steps);
|
||||
assert.equal(code, 0, out);
|
||||
assert.deepEqual(seen, ["1.0.0", "1.0.0"], "mid-update writes keep the old version");
|
||||
assert.equal(installer.readInstallRecord().version, VERSION, "stamped once the update finished");
|
||||
assert.deepEqual(installer.readInstallRecord().pieces, ["app", "launcher", "skills"]);
|
||||
// Outside an update, a record write stamps the version being installed again.
|
||||
installer.recordInstalled("statusline");
|
||||
assert.equal(installer.readInstallRecord().version, VERSION);
|
||||
});
|
||||
|
||||
test("update: a step's own output stays out of the summary, except its warnings and its failures", async () => {
|
||||
writeRecord(["skills", "statusline", "bot"]);
|
||||
const fake = fakeSteps();
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
"test-web-console-page-cards.mjs",
|
||||
"test-web-console-page-changes.mjs",
|
||||
"test-web-console-page-dashboard.mjs",
|
||||
"test-web-console-page-layout.mjs",
|
||||
"test-web-console-page-git.mjs",
|
||||
"test-web-console-page-help.mjs",
|
||||
"test-web-console-page-learning.mjs",
|
||||
|
||||
@@ -27,6 +27,17 @@ const FIXTURES = path.join(ROOT, "scripts", "fixtures", "deps");
|
||||
const MANIFESTS = path.join(FIXTURES, "manifests");
|
||||
const readJson = (...p) => JSON.parse(fs.readFileSync(path.join(FIXTURES, ...p), "utf8"));
|
||||
|
||||
// Recorded npm projects keep their lockfile as package-lock.fixture.json, so
|
||||
// dependency scanners never read the old versions the recordings pin as the
|
||||
// repository's own. A copy gets the real name back.
|
||||
const FIXTURE_LOCK = "package-lock.fixture.json";
|
||||
function copyFixture(src, dir) {
|
||||
fs.cpSync(src, dir, { recursive: true });
|
||||
for (const rel of fs.readdirSync(dir, { recursive: true })) {
|
||||
if (path.basename(rel) === FIXTURE_LOCK) fs.renameSync(path.join(dir, rel), path.join(dir, path.dirname(rel), "package-lock.json"));
|
||||
}
|
||||
}
|
||||
|
||||
const runDeps = (args, opts) => runScript("plan2code-deps", "deps.mjs", args, opts);
|
||||
|
||||
const made = [];
|
||||
@@ -849,7 +860,7 @@ function runStubbed(args, pathDir) {
|
||||
/** The recorded project copied into a temp folder (extra files on top), so a run never touches the fixture. */
|
||||
function project(extra = {}) {
|
||||
const dir = tmp("deps-project");
|
||||
fs.cpSync(path.join(NPM, "project"), dir, { recursive: true });
|
||||
copyFixture(path.join(NPM, "project"), dir);
|
||||
for (const [rel, content] of Object.entries(extra)) write(dir, rel, typeof content === "string" ? content : JSON.stringify(content, null, 2) + "\n");
|
||||
return dir;
|
||||
}
|
||||
@@ -1206,7 +1217,7 @@ test("apply refuses a batch with no backup (exit 5) and reports a pick that neve
|
||||
test("backup then restore --verify puts an untracked CRLF lockfile and a tracked one back byte for byte", () => {
|
||||
const root = project({
|
||||
"web/package.json": fs.readFileSync(path.join(NPM, "project", "package.json"), "utf8"),
|
||||
"web/package-lock.json": fs.readFileSync(path.join(NPM, "project", "package-lock.json"), "utf8"),
|
||||
"web/package-lock.json": fs.readFileSync(path.join(NPM, "project", FIXTURE_LOCK), "utf8"),
|
||||
});
|
||||
// The root lockfile is untracked and written with CRLF, as some Windows tools leave one: put back exactly as found.
|
||||
const lockPath = path.join(root, "package-lock.json");
|
||||
@@ -1534,7 +1545,7 @@ const UV = fx("uv-0.13.7");
|
||||
/** A recorded project folder copied into a temp folder, extra files on top. */
|
||||
function copyFrom(src, extra = {}) {
|
||||
const dir = tmp("deps-eco");
|
||||
fs.cpSync(src, dir, { recursive: true });
|
||||
copyFixture(src, dir);
|
||||
for (const [rel, content] of Object.entries(extra)) write(dir, rel, content);
|
||||
return dir;
|
||||
}
|
||||
@@ -2564,7 +2575,7 @@ const PINS = fx("pins", "project");
|
||||
/** The pins fixture project copied into a temp folder, with extra files on top. */
|
||||
function pinsProject(extra = {}) {
|
||||
const dir = tmp("deps-pins");
|
||||
fs.cpSync(PINS, dir, { recursive: true });
|
||||
copyFixture(PINS, dir);
|
||||
for (const [rel, content] of Object.entries(extra)) write(dir, rel, content);
|
||||
return dir;
|
||||
}
|
||||
|
||||
+1141
-16
File diff suppressed because it is too large.
Load diff
@@ -14,9 +14,9 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { ENV, HOME, LEARNING_DIR, ROOT, cli, postPatch, readState, sessionUrl } from "./web-console-test-helpers.mjs";
|
||||
import { learningScan, storeDir, writePause, writeWaiting } from "../src/web-console/learning.mjs";
|
||||
import { followCounts, learningScan, lessonsNearCap, recordFollow, storeDir, writePause, writeWaiting } from "../src/web-console/learning.mjs";
|
||||
import { sessionActions } from "../src/web-console/cmd-post-wait.mjs";
|
||||
import { indentReply, learningAction, learningBannerText, learningReply, lessonsReply } from "../src/web-console/public/answers.js";
|
||||
import { indentReply, learningAction, learningBannerText, learningNearCapText, learningReply, lessonDecisionLine, lessonsReply } from "../src/web-console/public/answers.js";
|
||||
|
||||
const LESSONS = path.join(ROOT, "src", "skill-scripts", "lessons.mjs");
|
||||
|
||||
@@ -67,7 +67,7 @@ function dashboard(t, dir) {
|
||||
test("scan.learning: not set up, off, on and paused, with the waiting count", (t) => {
|
||||
const none = project();
|
||||
const s1 = dashboard(t, none);
|
||||
assert.deepEqual(readState(s1.session).scan.learning, { state: "not-set-up", pausedSince: null, waiting: 0, oldestDays: 0 });
|
||||
assert.deepEqual(readState(s1.session).scan.learning, { state: "not-set-up", pausedSince: null, waiting: 0, oldestDays: 0, nearCap: false });
|
||||
|
||||
const off = project(SETTINGS("off"));
|
||||
assert.equal(readState(dashboard(t, off).session).scan.learning.state, "off");
|
||||
@@ -76,7 +76,7 @@ test("scan.learning: not set up, off, on and paused, with the waiting count", (t
|
||||
const noted = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 - 60000).toISOString();
|
||||
writeWaiting(on, { id: "20261111-120000-abcdef", type: "lesson", text: "A lesson.", noted });
|
||||
writeWaiting(on, { id: "20261112-120000-abcdef", type: "lesson", text: "Another.", noted: new Date().toISOString() });
|
||||
assert.deepEqual(readState(dashboard(t, on).session).scan.learning, { state: "on", pausedSince: null, waiting: 2, oldestDays: 2 });
|
||||
assert.deepEqual(readState(dashboard(t, on).session).scan.learning, { state: "on", pausedSince: null, waiting: 2, oldestDays: 2, nearCap: false });
|
||||
|
||||
const paused = project(SETTINGS("on"));
|
||||
const pause = writePause(paused, true, "2026-11-13T09:00:00.000Z");
|
||||
@@ -92,6 +92,33 @@ test("scan.learning is absent for a settings format this console does not know",
|
||||
assert.equal("learning" in scan, false, "no learning field, so the page draws no row");
|
||||
});
|
||||
|
||||
// An area file holding `n` lessons.
|
||||
const lessonFile = (title, n) =>
|
||||
`# ${title}\n\n` + Array.from({ length: n }, (_, i) => `### Lesson number ${i}\n- Kind: how-it-works\n- About: src/a.js\n- Noted: 2026-11-01, Implement\n`).join("\n");
|
||||
|
||||
test("scan.learning.nearCap: true at 22 general lessons or 30 in an area, false below, and only while Learning is on", (t) => {
|
||||
const near = (files) => learningScan(project(files)).nearCap;
|
||||
assert.equal(near({ ...SETTINGS("on") }), false, "no lessons folder");
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 21) }), false);
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 22) }), true);
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 25) }), true);
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/web.md": lessonFile("Web", 29) }), false);
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/web.md": lessonFile("Web", 30) }), true);
|
||||
// 22 is the general file's line only: an area at 22 is not crowded.
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/web.md": lessonFile("Web", 22) }), false);
|
||||
// Either file is enough, and CRLF files count the same.
|
||||
assert.equal(near({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 3), ".plan2code/lessons/web.md": lessonFile("Web", 30).replace(/\n/g, "\r\n") }), true);
|
||||
// Not on: no nudge, however full.
|
||||
assert.equal(near({ ...SETTINGS("off"), ".plan2code/lessons/general.md": lessonFile("General", 25) }), false);
|
||||
assert.equal(lessonsNearCap(project({ ".plan2code/lessons/general.md": lessonFile("General", 25) })), true, "the count itself ignores the state");
|
||||
// It reaches the page through the dashboard's scan.
|
||||
const full = project({ ...SETTINGS("on"), ".plan2code/lessons/general.md": lessonFile("General", 23) });
|
||||
assert.equal(readState(dashboard(t, full).session).scan.learning.nearCap, true);
|
||||
const before = listing(full);
|
||||
learningScan(full);
|
||||
assert.deepEqual(listing(full), before, "the scan writes nothing");
|
||||
});
|
||||
|
||||
test("a failure in Learning's core never fails the scan", () => {
|
||||
const boom = () => {
|
||||
throw new Error("the core broke");
|
||||
@@ -109,7 +136,7 @@ test("an unreadable learning store reads as empty: on, not paused, nothing waiti
|
||||
fs.writeFileSync(store, "not a folder");
|
||||
t.after(() => fs.rmSync(store, { force: true }));
|
||||
const s = dashboard(t, dir);
|
||||
assert.deepEqual(readState(s.session).scan.learning, { state: "on", pausedSince: null, waiting: 0, oldestDays: 0 });
|
||||
assert.deepEqual(readState(s.session).scan.learning, { state: "on", pausedSince: null, waiting: 0, oldestDays: 0, nearCap: false });
|
||||
});
|
||||
|
||||
test("the scan reads without pruning: an old waiting item stays on disk", (t) => {
|
||||
@@ -170,7 +197,7 @@ test("GET /learning/state answers the scan's object, worked out now", async (t)
|
||||
writeWaiting(dir, { id: "20261113-120000-bbbbbb", type: "lesson", text: "New.", noted: new Date().toISOString() });
|
||||
const res = await s.get("/learning/state");
|
||||
assert.equal(res.status, 200);
|
||||
assert.deepEqual(await res.json(), { state: "on", pausedSince: null, waiting: 1, oldestDays: 0 });
|
||||
assert.deepEqual(await res.json(), { state: "on", pausedSince: null, waiting: 1, oldestDays: 0, nearCap: false });
|
||||
|
||||
const unknown = dashboard(t, project({ ".plan2code/settings.json": "{}" }));
|
||||
assert.deepEqual(await (await unknown.get("/learning/state")).json(), {});
|
||||
@@ -208,13 +235,37 @@ test("GET /learning/lessons: general first, then the rest by name; no sub-folder
|
||||
if (linked) assert.equal(files.some((f) => f.name === "linked.md"), false, "the link out was not followed");
|
||||
|
||||
const empty = dashboard(t, project(SETTINGS("on")));
|
||||
assert.deepEqual(await (await empty.get("/learning/lessons")).json(), { files: [] });
|
||||
assert.deepEqual(await (await empty.get("/learning/lessons")).json(), { files: [], follows: {} });
|
||||
});
|
||||
|
||||
test("followCounts: sums lines per lesson, keeps the latest time and skips an unreadable line", () => {
|
||||
const dir = project(SETTINGS("on"));
|
||||
assert.deepEqual(followCounts(dir), {}, "no file yet");
|
||||
recordFollow(dir, { lesson: "web/a", skill: "implement" }, new Date("2026-11-10T09:00:00Z"));
|
||||
recordFollow(dir, { lesson: "web/a", skill: "quick-task" }, new Date("2026-11-20T09:00:00Z"));
|
||||
recordFollow(dir, { lesson: "web/b", skill: "implement" }, new Date("2026-11-12T09:00:00Z"));
|
||||
fs.appendFileSync(path.join(storeDir(dir), "follows.ndjson"), "{ not json\n\n{\"lesson\":3}\n");
|
||||
recordFollow(dir, { lesson: "web/a", skill: "implement" }, new Date("2026-11-15T09:00:00Z"));
|
||||
assert.deepEqual(followCounts(dir), {
|
||||
"web/a": { count: 3, last: "2026-11-20T09:00:00.000Z" },
|
||||
"web/b": { count: 1, last: "2026-11-12T09:00:00.000Z" },
|
||||
});
|
||||
assert.equal(listing(dir).some((f) => f.includes("follows")), false, "nothing written into the project");
|
||||
});
|
||||
|
||||
test("GET /learning/lessons carries follows from this machine's store", async (t) => {
|
||||
const dir = project({ ...SETTINGS("on"), ".plan2code/lessons/general.md": "# General\n\n### A lesson\n- Kind: how-it-works\n- About: src/x.js\n- Noted: 2026-11-01, Implement\n" });
|
||||
recordFollow(dir, { lesson: "general/a-lesson", skill: "implement" }, new Date("2026-11-10T09:00:00Z"));
|
||||
recordFollow(dir, { lesson: "general/a-lesson", skill: "implement" }, new Date("2026-11-11T09:00:00Z"));
|
||||
const s = dashboard(t, dir);
|
||||
const body = await (await s.get("/learning/lessons")).json();
|
||||
assert.deepEqual(body.follows, { "general/a-lesson": { count: 2, last: "2026-11-11T09:00:00.000Z" } });
|
||||
});
|
||||
|
||||
/* ------------------------------------------------- the action and reply */
|
||||
|
||||
test("a Learning action reaches the agent whole, and a launch keeps fromBanner", () => {
|
||||
for (const what of ["review", "switch-on", "switch-off", "move-log", "remove"]) {
|
||||
for (const what of ["review", "switch-on", "switch-off", "move-log", "remove", "tidy"]) {
|
||||
const action = learningAction(what);
|
||||
assert.deepEqual(action, { i: "__learning", type: "learning", do: what });
|
||||
assert.deepEqual(sessionActions({ actions: [action] }), [{ i: "__learning", do: what }]);
|
||||
@@ -235,6 +286,25 @@ test("the waiting banner's line shows only while lessons wait and Learning is on
|
||||
assert.equal(learningBannerText(undefined), "");
|
||||
});
|
||||
|
||||
test("the tidy-up nudge's line shows only while Learning is on and the lessons are near their limit", () => {
|
||||
assert.equal(learningNearCapText({ state: "on", waiting: 0, nearCap: true }), "Lessons are nearing their limit. Tidy up?");
|
||||
assert.equal(learningNearCapText({ state: "on", waiting: 3, nearCap: true }), "Lessons are nearing their limit. Tidy up?", "beside the waiting line");
|
||||
assert.equal(learningNearCapText({ state: "on", waiting: 0, nearCap: false }), "");
|
||||
assert.equal(learningNearCapText({ state: "on", waiting: 0 }), "");
|
||||
assert.equal(learningNearCapText({ state: "paused", nearCap: true }), "");
|
||||
assert.equal(learningNearCapText({ state: "off", nearCap: true }), "");
|
||||
assert.equal(learningNearCapText({ state: "not-set-up", nearCap: true }), "");
|
||||
assert.equal(learningNearCapText(undefined), "");
|
||||
});
|
||||
|
||||
test("a tidy row's decisions read as the change, never as an AGENTS.md file", () => {
|
||||
const retire = { id: "t1", type: "tidy", change: "retire", text: "Retire: Draw the page from state Reason: Git marks it.", choices: ["Apply", "Leave"] };
|
||||
const fix = { id: "f1", type: "agents-fix", file: ".agents-docs/AGENTS-code-style.md", text: "x", choices: ["Apply", "Reword", "Drop"] };
|
||||
assert.equal(lessonDecisionLine(retire, { id: "t1", choice: "Apply" }), "Apply: Retire: Draw the page from state Reason: Git marks it.");
|
||||
assert.equal(lessonDecisionLine(retire, { id: "t1", choice: "Leave" }), "Leave: Retire: Draw the page from state Reason: Git marks it.");
|
||||
assert.equal(lessonDecisionLine(fix, { id: "f1", choice: "Apply" }), "Apply: .agents-docs/AGENTS-code-style.md", "a fix still shows its file");
|
||||
});
|
||||
|
||||
/* ---------------------------------------------- the lessons card, end to end */
|
||||
|
||||
test("the lessons card from lessons.mjs list goes up on the dashboard, and a Keep comes back as a Keep line and a decisions file decide takes", async (t) => {
|
||||
|
||||
@@ -104,6 +104,8 @@ import {
|
||||
loopLessonsLine,
|
||||
} from "../src/web-console/public/answers.js";
|
||||
import { chatView } from "../src/web-console/public/chat.js";
|
||||
import { LEARNING_BUSY_MS, LEARNING_CHECK_MS, learningBusyLimit, learningBusyNow } from "../src/web-console/public/selectors.js";
|
||||
import { page } from "../src/web-console/public/state.js";
|
||||
import { agoWords, whenTitle, whenWords } from "../src/web-console/public/labels.js";
|
||||
import { ACCENTS, DEFAULT_ACCENT, RETIRED_ACCENTS, accentId } from "../src/web-console/public/palette.js";
|
||||
import {
|
||||
@@ -1672,7 +1674,7 @@ test("validate: a lessons item takes rows each with a type and its own choices,
|
||||
const one = (extra) => validate({ items: [item(extra)] });
|
||||
assert.deepEqual(one({ opening: "You are on main: kept lessons will be uncommitted changes here.", rows: [row({ why: "A full run hides it.", origin: "You said this.", note: "", flags: [], refused: null, area: "General", areas: ["General"] })] }), []);
|
||||
assert.deepEqual(
|
||||
one({ rows: ["lesson", "doubt", "gone", "agents-fix", "log-line", "area"].map((type, i) => row({ id: `w${i}`, type })) }),
|
||||
one({ rows: ["lesson", "doubt", "gone", "agents-fix", "tidy", "log-line", "area"].map((type, i) => row({ id: `w${i}`, type })) }),
|
||||
[],
|
||||
"every row type the list gives"
|
||||
);
|
||||
@@ -1705,6 +1707,53 @@ test("validate: a lessons item takes rows each with a type and its own choices,
|
||||
assert.deepEqual(answered, [], "an answered card does not count");
|
||||
});
|
||||
|
||||
test("validate: a lessons row takes the check's verdicts and a tag, and the card how it was checked", () => {
|
||||
const check = { fails: [{ test: "Search", reason: "It matches 3 files." }], doubts: [{ test: "Why", reason: "No reason given." }], passed: 2, suggestion: "A shorter wording." };
|
||||
const row = (extra = {}) => ({ id: "w1", type: "lesson", text: "A lesson.", choices: ["Keep", "Reword", "Drop"], ...extra });
|
||||
const item = (extra) => ({ id: "lessons", kind: "lessons", title: "Lessons to keep", status: "open", rows: [row()], ...extra });
|
||||
const one = (extra) => validate({ items: [item(extra)] });
|
||||
const refused = (extra, field) => {
|
||||
const problems = one(extra);
|
||||
assert.ok(problems.some((p) => p.includes(field)), `${field}: ${problems.join(" | ")}`);
|
||||
};
|
||||
assert.deepEqual(one({ rows: [row({ check, tag: "Checked in an earlier run" })], checked: { how: "helper", count: 6, seconds: 40 } }), [], "a good check, tag and how");
|
||||
assert.deepEqual(one({ rows: [row({ check: { fails: [], doubts: [], passed: 4 }, tag: "Not checked yet" })], checked: { how: "same-agent", count: 1, seconds: 0 } }), []);
|
||||
assert.deepEqual(one({ checked: { failed: "The checker answered with nothing usable." } }), [], "a check that could not run");
|
||||
refused({ rows: [row({ check: { ...check, extra: 1 } })] }, 'row "w1" check "extra"');
|
||||
refused({ rows: [row({ check: { ...check, passed: 5 } })] }, 'row "w1" check passed');
|
||||
refused({ rows: [row({ check: { ...check, fails: [{ test: "Search", reason: 7 }] } })] }, 'row "w1" check fails[0]');
|
||||
refused({ rows: [row({ check: { ...check, doubts: Array.from({ length: 5 }, () => ({ test: "a", reason: "b" })) } })] }, 'row "w1" check doubts');
|
||||
refused({ rows: [row({ check: { ...check, suggestion: "x".repeat(201) } })] }, 'row "w1" check suggestion');
|
||||
refused({ rows: [row({ tag: "Old" })] }, 'row "w1" tag');
|
||||
refused({ checked: { how: "robot", count: 1, seconds: 1 } }, "checked");
|
||||
refused({ checked: { how: "helper", count: -1, seconds: 1 } }, "checked");
|
||||
refused({ checked: { failed: "x".repeat(201) } }, "checked");
|
||||
});
|
||||
|
||||
test("learning busy: a Review or Tidy up the agent is still working on outlasts LEARNING_BUSY_MS, a switch never does", () => {
|
||||
const saved = { S: page.S, learningBusy: page.learningBusy, pendingResult: page.pendingResult };
|
||||
try {
|
||||
page.pendingResult = null;
|
||||
const at = (what, agoMs, status) => {
|
||||
page.S = { agent: { status }, items: [] };
|
||||
page.learningBusy = { what, from: "on", at: Date.now() - agoMs, seen: true };
|
||||
return learningBusyNow("on");
|
||||
};
|
||||
page.S = { agent: { status: "working" }, items: [] };
|
||||
assert.equal(learningBusyLimit({ what: "review" }), LEARNING_CHECK_MS);
|
||||
assert.equal(learningBusyLimit({ what: "tidy" }), LEARNING_CHECK_MS);
|
||||
assert.equal(learningBusyLimit({ what: "switch-on" }), LEARNING_BUSY_MS, "a switch keeps the short limit");
|
||||
assert.ok(at("review", LEARNING_BUSY_MS + 10000, "working"), "a Review still being checked stays busy past 30 seconds");
|
||||
assert.ok(at("tidy", LEARNING_BUSY_MS + 10000, "working"), "so does a Tidy up");
|
||||
assert.equal(at("review", LEARNING_CHECK_MS + 1000, "working"), null, "but not past the check limit");
|
||||
assert.equal(at("review", LEARNING_BUSY_MS + 10000, "waiting"), null, "an agent back to waiting ends it at the short limit");
|
||||
page.pendingResult = { id: "x" };
|
||||
assert.equal(learningBusyLimit({ what: "review" }), LEARNING_CHECK_MS, "a send not yet picked up counts as working");
|
||||
} finally {
|
||||
Object.assign(page, saved);
|
||||
}
|
||||
});
|
||||
|
||||
test("validate: a lesson's own words never get the lessons card refused, but the card's own text still can", () => {
|
||||
const marker = "TASK_" + "COMPLETE";
|
||||
const words = ["Requirements 12 and 13 are checked by check-versions.mjs.", "Risk 3 is the slow blame on Windows.", `Never print ${marker} in a spec file.`, "The grill step reads the map first."];
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Page tests for the page shell: what keeps the console page itself from
|
||||
// scrolling (only its panels scroll), checked at wide and narrow window sizes.
|
||||
// A change to src/web-console/public/styles/ or index.html needs only this
|
||||
// file, not the whole page suites. Run with:
|
||||
// npm run test:page -- scripts/test-web-console-page-layout.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 { pageSuite, openSession } from "./page-test-helpers.mjs";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
|
||||
// A plan session on the person's turn: one text question and the agent listening.
|
||||
const PLAN_QUESTION = {
|
||||
items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name for the export." }],
|
||||
agent: { status: "waiting" },
|
||||
};
|
||||
|
||||
test("the page itself never scrolls: oversized content stays inside its own panel", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.locator("#main [data-item=\"q1\"]").first().waitFor();
|
||||
const page = await s.page.evaluate(() => {
|
||||
const big = document.createElement("div");
|
||||
big.style.cssText = "height: 5000px";
|
||||
document.querySelector(".main").append(big);
|
||||
const root = document.documentElement;
|
||||
const before = { scrollHeight: root.scrollHeight, innerHeight: innerHeight };
|
||||
scrollTo(0, 400);
|
||||
return {
|
||||
...before,
|
||||
scrolled: scrollY,
|
||||
rootOverflow: getComputedStyle(root).overflowY,
|
||||
bodyOverflow: getComputedStyle(document.body).overflowY,
|
||||
bodyHeight: Math.round(document.body.getBoundingClientRect().height),
|
||||
};
|
||||
});
|
||||
assert.equal(page.rootOverflow, "hidden", "the page root never scrolls");
|
||||
assert.equal(page.bodyOverflow, "hidden", "the body never scrolls");
|
||||
assert.equal(page.bodyHeight, page.innerHeight, "the body is exactly the window tall");
|
||||
assert.ok(page.scrollHeight <= page.innerHeight, "the page is never taller than the window (an absolutely placed bit in a panel stretched it)");
|
||||
assert.equal(page.scrolled, 0, "the page does not move when asked to scroll");
|
||||
});
|
||||
|
||||
test("the one-column layout (900px and narrower) keeps its page scroll", async (t) => {
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
|
||||
await s.page.setViewportSize({ width: 600, height: 700 });
|
||||
const narrow = await s.page.evaluate(() => getComputedStyle(document.documentElement).overflowY);
|
||||
assert.equal(narrow, "visible", "its content sits under the first screen, so the lock must not apply");
|
||||
});
|
||||
@@ -13,7 +13,7 @@ import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, tempProject, textOf, styleOf, stylesOf, itemCard, sendAndCollect, settled, scrollCard } from "./page-test-helpers.mjs";
|
||||
import { cli, until } from "./web-console-test-helpers.mjs";
|
||||
import { writePause, writeWaiting } from "../src/web-console/learning.mjs";
|
||||
import { recordFollow, writePause, writeWaiting } from "../src/web-console/learning.mjs";
|
||||
|
||||
const suite = pageSuite(test);
|
||||
|
||||
@@ -126,6 +126,32 @@ test("on: the row is after the last card group, before the tip, with no count of
|
||||
assert.match(await textOf(dlg), /The project's lessons \(\.plan2code\/lessons\/, saved with the repository\)/);
|
||||
});
|
||||
|
||||
test("the lessons reader draws a quiet follow line under each lesson's heading", async (t) => {
|
||||
const lesson = (title) => `### ${title}\n- Kind: how-it-works\n- About: src/x.js\n- Noted: 2026-11-01, Implement\n\n`;
|
||||
const { main } = await dashboard(
|
||||
t,
|
||||
{ ...PROJECT("on"), ".plan2code/lessons/general.md": `# General\n\n${lesson("Followed lesson")}${lesson("Untouched lesson")}${lesson("Once lesson")}` },
|
||||
(project) => {
|
||||
recordFollow(project, { lesson: "general/followed-lesson", skill: "implement" }, new Date("2026-11-10T12:00:00Z"));
|
||||
recordFollow(project, { lesson: "general/followed-lesson", skill: "quick-task" }, new Date("2026-11-20T12:00:00Z"));
|
||||
recordFollow(project, { lesson: "general/once-lesson", skill: "implement" }, new Date("2026-11-12T12:00:00Z"));
|
||||
}
|
||||
);
|
||||
const row = main.locator("section.learn-row");
|
||||
await row.waitFor();
|
||||
await row.getByRole("button", { name: "Open the lessons" }).click();
|
||||
const dlg = main.page().locator("#learn-lessons-modal");
|
||||
await dlg.locator(".learn-follow").first().waitFor();
|
||||
const lines = await dlg.locator(".learn-follow").allInnerTexts();
|
||||
assert.equal(lines.length, 3, "one line per lesson");
|
||||
assert.match(lines[0], /^Followed 2 times, last on Nov 2[01]$/);
|
||||
assert.equal(lines[1], "Not followed yet");
|
||||
assert.match(lines[2], /^Followed once, last on Nov 1[123]$/);
|
||||
// The line sits right under its heading.
|
||||
const order = await dlg.locator(".learn-lessons-file").evaluate((n) => [...n.children].map((c) => (c.classList.contains("learn-follow") ? "follow" : c.textContent.includes("Followed lesson") ? "heading" : "other")));
|
||||
assert.equal(order.indexOf("follow"), order.indexOf("heading") + 1);
|
||||
});
|
||||
|
||||
test("Pause for me repaints the row with no agent listening, both ways", async (t) => {
|
||||
const { s, main } = await dashboard(t, PROJECT("on"));
|
||||
const bottom = main.locator("section.learn-row.is-bottom");
|
||||
@@ -153,6 +179,7 @@ test("More opens upward and closes on Escape and on a click outside", async (t)
|
||||
assert.ok(m.y + m.height <= b.y + 1, `the menu opens above its button: ${JSON.stringify({ m, b })}`);
|
||||
assert.deepEqual(await menu.getByRole("menuitem").allInnerTexts(), [
|
||||
"Switch off for this project",
|
||||
"Tidy up lessons",
|
||||
"Move the failure log into lessons",
|
||||
"Remove all lessons…",
|
||||
]);
|
||||
@@ -211,6 +238,50 @@ test("the banner shows only with lessons waiting, directly above the title", asy
|
||||
assert.equal(await paused.main.locator(".learn-banner").count(), 0, "hidden while paused");
|
||||
});
|
||||
|
||||
test("More has Tidy up lessons, which sends the tidy Learning action and shows working at once", async (t) => {
|
||||
const { s, main } = await dashboard(t, PROJECT("on"));
|
||||
const row = main.locator("section.learn-row.is-bottom");
|
||||
await row.getByRole("button", { name: /More/ }).click();
|
||||
await row.getByRole("menuitem", { name: "Tidy up lessons" }).click();
|
||||
const got = s.wait(10);
|
||||
assert.equal(got.code, 0, "the send reached the agent");
|
||||
assert.deepEqual(got.actions, [{ i: "__learning", type: "learning", do: "tidy" }]);
|
||||
await main.locator(".learn-banner").getByText("Looking over your lessons…").waitFor();
|
||||
});
|
||||
|
||||
// An area file holding `n` lessons.
|
||||
const lessonFile = (title, n) =>
|
||||
`# ${title}\n\n` + Array.from({ length: n }, (_, i) => `### Lesson number ${i}\n- Kind: how-it-works\n- About: src/a.js\n- Noted: 2026-11-01, Implement\n`).join("\n");
|
||||
|
||||
test("the banner nudges a tidy-up when lessons are near their limit, and only then", async (t) => {
|
||||
const full = await dashboard(t, { ...PROJECT("on"), ".plan2code/lessons/general.md": lessonFile("General", 22) });
|
||||
const banner = full.main.locator(".learn-banner");
|
||||
await banner.waitFor();
|
||||
assert.match(await textOf(banner), /Lessons are nearing their limit\. Tidy up\?/);
|
||||
assert.equal(await banner.getByRole("button", { name: "Review" }).count(), 0, "nothing waits, so no Review");
|
||||
await banner.getByRole("button", { name: "Tidy up" }).click();
|
||||
const got = full.s.wait(10);
|
||||
assert.equal(got.code, 0);
|
||||
assert.deepEqual(got.actions, [{ i: "__learning", type: "learning", do: "tidy" }]);
|
||||
|
||||
// Beside the waiting line when lessons wait too.
|
||||
const both = await dashboard(t, { ...PROJECT("on"), ".plan2code/lessons/web.md": lessonFile("Web", 30) }, (p) =>
|
||||
writeWaiting(p, { id: "20261113-120000-ffffff", type: "lesson", text: "Waits.", noted: new Date().toISOString() })
|
||||
);
|
||||
const two = both.main.locator(".learn-banner");
|
||||
await two.waitFor();
|
||||
const text = await textOf(two);
|
||||
assert.match(text, /1 lesson is waiting for your review/);
|
||||
assert.match(text, /Lessons are nearing their limit\. Tidy up\?/);
|
||||
assert.equal(await two.getByRole("button", { name: "Review" }).count(), 1);
|
||||
assert.equal(await two.getByRole("button", { name: "Tidy up" }).count(), 1);
|
||||
|
||||
// One short of the line, in general.md and in an area: no nudge.
|
||||
const below = await dashboard(t, { ...PROJECT("on"), ".plan2code/lessons/general.md": lessonFile("General", 21), ".plan2code/lessons/web.md": lessonFile("Web", 29) });
|
||||
await below.main.locator("section.learn-row").waitFor();
|
||||
assert.equal(await below.main.locator(".learn-banner").count(), 0, "no banner below the line");
|
||||
});
|
||||
|
||||
test("a launch from a dashboard showing lessons waiting carries fromBanner", async (t) => {
|
||||
const { s, main } = await dashboard(t, PROJECT("on"), (p) =>
|
||||
writeWaiting(p, { id: "20261113-120000-eeeeee", type: "lesson", text: "Waits.", noted: new Date().toISOString() })
|
||||
@@ -293,6 +364,29 @@ test("lessons card: each row shows its own choice words, and nothing is chosen",
|
||||
assert.match(await textOf(rowOf(card, "w-area")), /Noted on feature\/x\./);
|
||||
});
|
||||
|
||||
test("lessons card: a tidy row shows the change, the lessons it replaces and its reason, and Reword edits the new wording", async (t) => {
|
||||
const merge = { id: "w-merge", type: "tidy", change: "merge", text: "Merge 2 lessons into: Keep modules small and kebab-case their files.", why: "They say the same thing twice.", origin: "", note: "", flags: [], refused: null, area: "Source", areas: ["General", "Source"], targets: [{ id: "source/keep-modules-small", text: "Keep modules small", area: "Source" }, { id: "source/name-files-in-kebab-case", text: "Name files in kebab case", area: "Source" }], wording: "Keep modules small and kebab-case their files.", wordingWhy: "Both keep the tree easy to scan.", choices: ["Apply", "Reword", "Leave"] };
|
||||
const retire = { id: "w-retire", type: "tidy", change: "retire", text: "Retire: Draw the page from state Reason: Git marks it.", why: "", origin: "", note: "", flags: [], refused: null, area: "", areas: ["General", "Source"], targets: [{ id: "web/draw-the-page-from-state", text: "Draw the page from state", area: "Web" }], choices: ["Apply", "Leave"] };
|
||||
const { s, card } = await lessonsCard(t, CARD([merge, retire]));
|
||||
assert.deepEqual(await choicesOf(rowOf(card, "w-merge")).allInnerTexts(), ["Apply", "Reword", "Leave"]);
|
||||
assert.deepEqual(await choicesOf(rowOf(card, "w-retire")).allInnerTexts(), ["Apply", "Leave"], "no Reword where there is no wording");
|
||||
const text = await textOf(rowOf(card, "w-merge"));
|
||||
assert.match(text, /Merge 2 lessons into: Keep modules small and kebab-case their files\./);
|
||||
assert.match(text, /It replaces these lessons:\s+Keep modules small\s+Name files in kebab case/);
|
||||
assert.match(text, /Why: They say the same thing twice\./);
|
||||
assert.match(await textOf(rowOf(card, "w-retire")), /Retire: Draw the page from state Reason: Git marks it\./);
|
||||
// Reword opens on the new wording and its own Why, not on the sentence describing the change.
|
||||
await rowOf(card, "w-merge").getByRole("button", { name: "Reword" }).click();
|
||||
const words = rowOf(card, "w-merge").getByLabel("The lesson");
|
||||
assert.equal(await words.inputValue(), "Keep modules small and kebab-case their files.");
|
||||
assert.equal(await rowOf(card, "w-merge").getByLabel("Why").inputValue(), "Both keep the tree easy to scan.");
|
||||
await words.fill("Keep modules small and name their files in kebab case.");
|
||||
await rowOf(card, "w-retire").getByRole("button", { name: "Apply" }).click();
|
||||
const got = await sendAndCollect(s);
|
||||
const decisions = got.actions.find((a) => a.i === "lessons").decisions;
|
||||
assert.deepEqual(decisions, [{ id: "w-merge", choice: "Reword", text: "Keep modules small and name their files in kebab case.", why: "Both keep the tree easy to scan." }, { id: "w-retire", choice: "Apply" }]);
|
||||
});
|
||||
|
||||
test("lessons card: Keep on one row sends only that row, and the rest are left waiting", async (t) => {
|
||||
const { s, card } = await lessonsCard(t);
|
||||
await rowOf(card, "w-lesson").getByRole("button", { name: "Keep" }).click();
|
||||
@@ -409,6 +503,71 @@ test("lessons card: a refused row's Keep still chooses after its words go back a
|
||||
]);
|
||||
});
|
||||
|
||||
const CHECKED_ROWS = [
|
||||
{ ...ROWS[0], id: "c-fail", text: "Never run the full suite.", check: { fails: [{ test: "Search", reason: "It matches 3 files." }], doubts: [], passed: 3 } },
|
||||
{ ...ROWS[0], id: "c-doubt", text: "The handler is small.", tag: "Checked in an earlier run", check: { fails: [], doubts: [{ test: "Why", reason: "The reason repeats the lesson." }], passed: 3 } },
|
||||
{ ...ROWS[0], id: "c-pass", text: "Use the helper.", check: { fails: [], doubts: [], passed: 4 } },
|
||||
{ ...ROWS[0], id: "c-none", text: "Not looked at.", tag: "Not checked yet" },
|
||||
{ ...ROWS[0], id: "c-all", text: "Every test flagged.", check: { fails: [{ test: "Search", reason: "No match." }, { test: "Worth", reason: "Already in AGENTS.md." }], doubts: [{ test: "Why", reason: "Thin." }, { test: "Clear", reason: "Vague." }], passed: 0 } },
|
||||
];
|
||||
|
||||
test("lessons card: a Fail, a Doubt and a pass show their lines, and the outline follows suggested without choosing", async (t) => {
|
||||
const { card } = await lessonsCard(t, CARD(CHECKED_ROWS, { suggested: { "c-fail": "Drop", "c-pass": "Keep" }, checked: { how: "helper", count: 4, seconds: 40 } }));
|
||||
const fail = rowOf(card, "c-fail");
|
||||
assert.match(await textOf(fail.locator(".lesson-check.fail")), /^Fail Search: It matches 3 files\.$/);
|
||||
assert.equal(await fail.locator(".lesson-check.doubt").count(), 0);
|
||||
assert.match(await textOf(fail.locator(".lesson-check-pass")), /^Passed the other 3$/);
|
||||
const doubt = rowOf(card, "c-doubt");
|
||||
assert.match(await textOf(doubt.locator(".lesson-check.doubt")), /^Doubt Why: The reason repeats the lesson\.$/);
|
||||
assert.equal(await doubt.locator(".lesson-check.fail").count(), 0);
|
||||
assert.match(await textOf(doubt.locator(".lessons-tag")), /^Checked in an earlier run$/);
|
||||
const pass = rowOf(card, "c-pass");
|
||||
assert.equal(await pass.locator(".lesson-check.fail, .lesson-check.doubt").count(), 0, "a pass lists no verdicts");
|
||||
assert.match(await textOf(pass.locator(".lesson-check-pass")), /^Passed the check$/);
|
||||
const none = rowOf(card, "c-none");
|
||||
assert.equal(await none.locator(".lesson-checks").count(), 0, "a row never checked draws nothing");
|
||||
assert.match(await textOf(none.locator(".lessons-tag")), /^Not checked yet$/);
|
||||
const all = rowOf(card, "c-all");
|
||||
assert.equal(await all.locator(".lesson-check.fail, .lesson-check.doubt").count(), 4);
|
||||
assert.equal(await all.locator(".lesson-check-pass").count(), 0, "no pass line when nothing passed");
|
||||
const outlined = async (row) => row.locator(".lessons-choices button.is-suggested").allInnerTexts();
|
||||
assert.deepEqual(await outlined(fail), ["Drop"]);
|
||||
assert.deepEqual(await outlined(doubt), [], "a Doubt outlines nothing");
|
||||
assert.deepEqual(await outlined(pass), ["Keep"]);
|
||||
assert.equal(await card.locator('.lessons-choices [aria-pressed="true"]').count(), 0, "nothing is chosen for the person");
|
||||
assert.notEqual(await styleOf(fail.locator(".lesson-check.fail"), "color"), await styleOf(pass.locator(".lesson-check-pass"), "color"), "a Fail is not drawn like the quiet pass line");
|
||||
const px = async (loc) => parseFloat(await styleOf(loc, "fontSize"));
|
||||
assert.ok((await px(pass.locator(".lesson-check-pass"))) < (await px(fail.locator(".lesson-check.fail"))), "the pass line is smaller than a verdict line");
|
||||
assert.match(await textOf(card.locator(".lessons-checked")), /^Checked 4 lessons in 40 seconds by a fresh helper that could only read$/);
|
||||
});
|
||||
|
||||
test("lessons card: the how-checked line names the same agent, or why the check could not run", async (t) => {
|
||||
const same = await lessonsCard(t, CARD(CHECKED_ROWS.slice(2, 3), { checked: { how: "same-agent", count: 1, seconds: 1 } }));
|
||||
assert.match(await textOf(same.card.locator(".lessons-checked")), /^Checked 1 lesson in 1 second by the same agent that noted them$/);
|
||||
const failed = await lessonsCard(t, CARD(CHECKED_ROWS.slice(3, 4), { checked: { failed: "the checker answered with nothing usable." } }));
|
||||
assert.match(await textOf(failed.card.locator(".lessons-checked")), /^The check could not run: the checker answered with nothing usable\.$/);
|
||||
const bare = await lessonsCard(t, CARD(CHECKED_ROWS.slice(3, 4)));
|
||||
assert.equal(await bare.card.locator(".lessons-checked").count(), 0, "no line without a check");
|
||||
});
|
||||
|
||||
test("lessons card: Use this wording opens Reword filled with the suggestion, and what is sent is a normal Reword", async (t) => {
|
||||
const row = { ...ROWS[0], id: "c-sug", check: { fails: [], doubts: [{ test: "Search", reason: "Two files match." }], passed: 3, suggestion: "Run one page test file alone first." } };
|
||||
const { s, card } = await lessonsCard(t, CARD([row]));
|
||||
const li = rowOf(card, "c-sug");
|
||||
assert.match(await textOf(li.locator(".lesson-suggestion")), /^Suggested wording: Run one page test file alone first\./);
|
||||
await li.getByRole("button", { name: "Use this wording" }).click();
|
||||
const edit = li.locator(".lessons-edit");
|
||||
await edit.waitFor();
|
||||
assert.equal(await li.getByRole("button", { name: "Reword" }).getAttribute("aria-pressed"), "true");
|
||||
const text = edit.getByLabel("The lesson");
|
||||
assert.equal(await text.inputValue(), "Run one page test file alone first.", "it opens on the suggestion, not the row's own words");
|
||||
await text.fill("Run one page test file alone first, then the rest.");
|
||||
const got = await sendAndCollect(s);
|
||||
assert.deepEqual(got.actions.find((a) => a.i === "lessons").decisions, [
|
||||
{ id: "c-sug", choice: "Reword", text: "Run one page test file alone first, then the rest.", why: "A full run hides the race." },
|
||||
]);
|
||||
});
|
||||
|
||||
test("lessons card: a flagged row says what was flagged", async (t) => {
|
||||
const flagged = { ...ROWS[0], id: "w-flag", flags: [{ pattern: "email", part: "a@b.c" }] };
|
||||
const { card } = await lessonsCard(t, CARD([flagged]));
|
||||
|
||||
@@ -973,6 +973,9 @@ test("the Subagents dialog looks as it did before Preferences moved to tabs", as
|
||||
second: await stylesOf(modal.locator("fieldset.modal-ranges").nth(1), ["margin-top"]),
|
||||
actions: await stylesOf(modal.locator(".modal-actions"), ["display", "justify-content"]),
|
||||
};
|
||||
// Chrome 158 reads `justify-content: flex-end` back as "flow-end"; older Chrome and Edge
|
||||
// say "flex-end". The stylesheet is the same either way, so count them as one.
|
||||
if (got.actions["justify-content"] === "flow-end") got.actions["justify-content"] = "flex-end";
|
||||
if (process.env.P2C_PRINT_SUBAGENTS) console.log("SUBAGENTS " + JSON.stringify(got));
|
||||
assert.deepEqual(got, SUBAGENTS_BEFORE);
|
||||
});
|
||||
|
||||
@@ -399,7 +399,7 @@ test("Implement's card launches Implement + Review when Review is ticked", () =>
|
||||
assert.equal(launchVariant(quick, true), quick, "a card with no Review box is unchanged");
|
||||
});
|
||||
|
||||
test("helper-strength.md ships in the seventeen skills that start helpers, and in no other", () => {
|
||||
test("helper-strength.md ships in the eighteen skills that start helpers (the dashboard for its lesson check only), and in no other", () => {
|
||||
// npm test has just built skills/; a direct run builds it so the check never reads a stale tree.
|
||||
if (process.env.npm_lifecycle_event !== "test") {
|
||||
execFileSync(process.execPath, [path.join(ROOT, "install.js"), "--build-skills"], { stdio: "ignore" });
|
||||
@@ -407,6 +407,7 @@ test("helper-strength.md ships in the seventeen skills that start helpers, and i
|
||||
const built = path.join(ROOT, "skills");
|
||||
const having = fs.readdirSync(built).filter((dir) => fs.existsSync(path.join(built, dir, "references", "helper-strength.md")));
|
||||
assert.deepEqual(having.sort(), [
|
||||
"plan2code",
|
||||
"plan2code-0-pathfinder",
|
||||
"plan2code-1-plan",
|
||||
"plan2code-1b-revise-plan",
|
||||
|
||||
@@ -14,15 +14,16 @@
|
||||
"install": {
|
||||
"win": [
|
||||
{ "label": "PowerShell", "run": "irm https://claude.ai/install.ps1 | iex" },
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code", "note": "Needs Node.js 22 or later" }
|
||||
{ "label": "CMD", "run": "curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd" },
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code@latest", "note": "Needs Node.js 22 or later" }
|
||||
],
|
||||
"mac": [
|
||||
{ "label": "Terminal", "run": "curl -fsSL https://claude.ai/install.sh | bash" },
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code", "note": "Needs Node.js 22 or later" }
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code@latest", "note": "Needs Node.js 22 or later" }
|
||||
],
|
||||
"linux": [
|
||||
{ "label": "Terminal", "run": "curl -fsSL https://claude.ai/install.sh | bash" },
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code", "note": "Needs Node.js 22 or later" }
|
||||
{ "label": "npm", "run": "npm install -g @anthropic-ai/claude-code@latest", "note": "Needs Node.js 22 or later" }
|
||||
]
|
||||
},
|
||||
"installDirs": {
|
||||
@@ -103,7 +104,7 @@
|
||||
"name": "OpenCode",
|
||||
"kind": "template",
|
||||
"command": "opencode",
|
||||
"prompt": "Use the plan2code skill",
|
||||
"prompt": "@plan2code",
|
||||
"args": ["{model}", "--prompt", "{prompt}"],
|
||||
"bypassArgs": ["--auto"],
|
||||
"modelArgs": ["--model", "{model}"]
|
||||
@@ -117,7 +118,7 @@
|
||||
"args": ["{model}", "{prompt}"],
|
||||
"bypassArgs": ["--approval-mode=yolo"],
|
||||
"modelArgs": ["--model", "{model}"],
|
||||
"note": "For Google AI Pro and Ultra accounts and free Gemini Code Assist for individuals, Gemini CLI was replaced by Antigravity CLI on June 18, 2026; Standard and Enterprise licenses and paid API keys are unaffected."
|
||||
"note": "For Google AI Pro and Ultra accounts, free Gemini Code Assist for individuals and Gemini Code Assist for GitHub, Gemini CLI was replaced by Antigravity CLI on June 18, 2026; Standard and Enterprise licenses and paid API keys are unaffected."
|
||||
},
|
||||
{
|
||||
"id": "pi",
|
||||
|
||||
+46
-34
@@ -15,7 +15,7 @@
|
||||
},
|
||||
{
|
||||
"id": "haiku",
|
||||
"label": "latest Haiku"
|
||||
"label": "fast and efficient Haiku"
|
||||
},
|
||||
{
|
||||
"id": "opusplan",
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
{
|
||||
"id": "fable",
|
||||
"label": "latest Fable"
|
||||
"label": "Fable for your hardest tasks"
|
||||
},
|
||||
{
|
||||
"id": "best",
|
||||
@@ -79,22 +79,6 @@
|
||||
"id": "gpt-6-luna-high",
|
||||
"label": "GPT-6 Luna High Thinking"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3-8-flash-low",
|
||||
"label": "Gemini 3.8 Flash Low"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3-8-flash-medium",
|
||||
"label": "Gemini 3.8 Flash Medium"
|
||||
},
|
||||
{
|
||||
"id": "gemini-3-8-flash-high",
|
||||
"label": "Gemini 3.8 Flash High"
|
||||
},
|
||||
{
|
||||
"id": "glm-5-3-low",
|
||||
"label": "GLM-5.3 Low"
|
||||
},
|
||||
{
|
||||
"id": "glm-5-3-high",
|
||||
"label": "GLM-5.3 High"
|
||||
@@ -115,18 +99,6 @@
|
||||
"id": "claude-haiku-5-5-high",
|
||||
"label": "Claude Haiku 5.5 High"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-1-low",
|
||||
"label": "Claude Fable 5.1 Low"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-1-medium",
|
||||
"label": "Claude Fable 5.1 Medium"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-1-high",
|
||||
"label": "Claude Fable 5.1 High"
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-astra-low",
|
||||
"label": "GPT-6 Astra Low Thinking"
|
||||
@@ -139,13 +111,45 @@
|
||||
"id": "gpt-6-astra-high",
|
||||
"label": "GPT-6 Astra High Thinking"
|
||||
},
|
||||
{
|
||||
"id": "swe-2-flash-medium",
|
||||
"label": "SWE-2 Flash Medium"
|
||||
},
|
||||
{
|
||||
"id": "swe-2-flash-high",
|
||||
"label": "SWE-2 Flash High"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-2-low",
|
||||
"label": "Claude Fable 5.2 Low"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-2-medium",
|
||||
"label": "Claude Fable 5.2 Medium"
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-2-high",
|
||||
"label": "Claude Fable 5.2 High"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-hydrogen-low",
|
||||
"label": "Gemini 4 Hydrogen Low"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-hydrogen-medium",
|
||||
"label": "Gemini 4 Hydrogen Medium"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-hydrogen-high",
|
||||
"label": "Gemini 4 Hydrogen High"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-neon-low",
|
||||
"label": "Gemini 4 Neon Low"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-neon-medium",
|
||||
"label": "Gemini 4 Neon Medium"
|
||||
},
|
||||
{
|
||||
"id": "gemini-4-neon-high",
|
||||
"label": "Gemini 4 Neon High"
|
||||
}
|
||||
],
|
||||
"codex": [
|
||||
@@ -164,6 +168,14 @@
|
||||
{
|
||||
"id": "gpt-6-luna",
|
||||
"label": "GPT-6 Luna"
|
||||
},
|
||||
{
|
||||
"id": "gpt-6.2-astra",
|
||||
"label": "GPT-6.2 Astra"
|
||||
},
|
||||
{
|
||||
"id": "gpt-6.2-sol",
|
||||
"label": "GPT-6.2 Sol"
|
||||
}
|
||||
],
|
||||
"strengths": {
|
||||
|
||||
@@ -35,7 +35,7 @@ On `local`, the map's bookkeeping is a script; the decisions are yours. `node "<
|
||||
|
||||
Load `./AGENTS.md` if it exists — its conventions govern; never re-ask what it answers. If missing, fold it into the Step 0 gate batch: *"No `AGENTS.md`. Pathfinder can chart without it. Continue, or run `plan2code-init` first?"* Record the outcome as the first line of `## Ground rules`: ``- `AGENTS.md` exists and governs.`` or, when missing, exactly ``- `AGENTS.md` is absent.`` (the handoff reads it).
|
||||
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Check if `./AGENTS.md` exists:
|
||||
|
||||
Do not proceed until user confirms continuing without `AGENTS.md`.
|
||||
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); `<S>` is `scripts/` beside this SKILL.md, `~/.agents/skills/plan2code-1-plan/scripts/` globally.
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working); `<S>` is `scripts/` beside this SKILL.md, `~/.agents/skills/plan2code-1-plan/scripts/` globally.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ The FIRST thing you do, before anything else in this file — before Step 1, bef
|
||||
## Rules
|
||||
|
||||
- Follow `./AGENTS.md` if it exists
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
- Never remove completed `[x]` tasks without explicit approval
|
||||
- Warn if changes invalidate completed work
|
||||
- Keep task numbers sequential
|
||||
|
||||
@@ -22,7 +22,7 @@ The FIRST thing you do, before anything else in this file — before Auto-Discov
|
||||
## Rules
|
||||
|
||||
- Follow `./AGENTS.md` if it exists
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
- Require planning document before proceeding
|
||||
- Tasks must be specific enough for a developer with NO context
|
||||
- Use checkbox format `- [ ]` for Task items ONLY (not prerequisites, acceptance criteria, or success criteria)
|
||||
|
||||
@@ -24,7 +24,7 @@ The FIRST thing you do, before anything else in this file — before the Require
|
||||
## Rules
|
||||
|
||||
- Follow `./AGENTS.md` if it exists
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
- **Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
- Complete steps IN ORDER
|
||||
- STOP and ask user before proceeding when:
|
||||
- Incomplete tasks found (Step 1)
|
||||
|
||||
@@ -14,7 +14,7 @@ The FIRST thing you do, before anything else in this file, before running a scri
|
||||
|
||||
Read `./AGENTS.md` when it exists: its commands, its `## Test map` and anything it says about slow suites or code reached by name. Dead Code still works without one, but the test map is what tells it which tests and build to run after a removal; without it the scripts read the project's config files, and the person confirms the commands.
|
||||
|
||||
**Lessons:** follow `references/lessons.md` → Start and While working.
|
||||
**Lessons:** follow `references/lessons.md` → Start and While working; note only what the person asks you to remember (references/lessons.md, While working).
|
||||
|
||||
## Scripts
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ The FIRST thing you do, before anything else in this file, before reading the br
|
||||
|
||||
Read `./AGENTS.md` when it exists: its commands, its `## Test map` and anything it says about slow suites. PR Prep still works without one: the scripts find the project's commands from its config files, and nothing here needs Plan2Code's specs.
|
||||
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
|
||||
## Scripts
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ When this file is `references/ui-prototype.md` inside Pathfinder, Plan, Revise p
|
||||
|
||||
Read `./AGENTS.md` when it exists: its stack, its style files and its conventions help Step 1 find the look. Its absence does not block this skill.
|
||||
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`).
|
||||
**Lessons:** then read `references/lessons.md` and follow its Start and While working sections (`node "<S>/lessons.mjs"`); note only what the person asks you to remember (references/lessons.md, While working).
|
||||
|
||||
## Scripts
|
||||
|
||||
|
||||
+2
-1
@@ -139,7 +139,8 @@ The Learning row and banner send a `__learning` action with `do`. It is no hop:
|
||||
- `switch-off`: `switch off`.
|
||||
- `move-log`: `list --log-all`, then the card below.
|
||||
- `remove`: `remove --confirm` (the page already asked).
|
||||
- `review`: `list`, then the card below. While the state is `not-set-up`, `list --first-ask` instead: a `firstAsk` goes up as the reference's The first ask card (never `decide --file` before it), then `decide --first-ask yes` or `decide --first-ask no --skill dashboard`; on Yes, the card below from the list it returns.
|
||||
- `tidy`: while Learning is On, `tidy-input`, then up to 10 proposals, each `note --type tidy --change merge|reword|retire|move --targets <ids> --reason "<one sentence>" --skill dashboard` (`--text` for a merge or reword, `--area` for a move; one change each, nothing for lessons that are fine). A retire's reason is what you saw: git marks it and the code no longer does this, or `followed` 0 and none in 90 days (a hint only, never alone for a lesson that is not marked). Then the `review` check step with `check-input --tidy`, `list --check <checkId>` and the card below. No proposals: say so in the menu's `note`. In `decide`'s results a tidy-up's `outOfDate` is gone (its lesson changed since), and `applied` and `left` need no follow-up.
|
||||
- `review`: the check step from `references/lessons.md` End (check-input, the checker, check-record), with an `activity` line ("Checking 4 lessons") posted while it runs, then `list --check <checkId>` (`list` when there was nothing to check), then the card below. While the state is `not-set-up`, `list --first-ask` instead: a `firstAsk` goes up as the reference's The first ask card (never `decide --file` before it), then `decide --first-ask yes` or `decide --first-ask no --skill dashboard`; on Yes, the card below from the list it returns.
|
||||
|
||||
The card: post `list`'s `card` as one `lessons` item with `--wait` (the page shows it over the menu; give it a new `id` when an earlier lessons card is in the session). Write the reply's `Decisions:` JSON to a file in the session folder, adding what End step 6 says a choice still needs, run `decide --file <that file>`, and handle its results as End step 7 does. An empty `card` needs no post. The lessons card is the only question the dashboard shows: where End says to ask (a Move's `why` and `about`, or once more for an item), take `about` from the files the line names and post that row again as a new lessons card with the choices `Reword and move` and `Leave` (other rows: their own choices), its `note` saying what is needed.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Helper Strength
|
||||
> Shared by the skills that start helpers (subagents): Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray, Diagnose, PR Prep, Test, Dead Code and Update Dependencies. Read it when you first start a helper in a session. Never invoked as a skill.
|
||||
> Shared by the skills that start helpers (subagents): the dashboard (lesson check only), Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray, Diagnose, PR Prep, Test, Dead Code and Update Dependencies. Read it when you first start a helper in a session. Never invoked as a skill.
|
||||
|
||||
## The words
|
||||
|
||||
@@ -24,6 +24,7 @@ Never write a model or vendor name in a brief, a report or a file, and never inv
|
||||
| Build task needing a design decision the spec leaves open | strongest (or keep it yourself) | high |
|
||||
| Pathfinder research question, sketch | standard | medium |
|
||||
| Plan's PLAN-DRAFT cross-check against the conversation | standard | medium |
|
||||
| Lesson check (`lesson-check.md`) | standard | medium |
|
||||
| Review analysis, focused scope | standard | high |
|
||||
| Review analysis, branch or full scope, or touching security, auth or data | strongest | high |
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# Lesson check: the checker's brief
|
||||
> Read by the noting skills (Implement, Implement + Review, Quick Task, Diagnose, X-ray, Review, Test) and the dashboard when they start the checker, and by the checker itself. Never invoked as a skill.
|
||||
|
||||
You are the checker. You grade waiting lessons before a person decides on them. You judge only: the person still decides every lesson.
|
||||
|
||||
## Hard rules
|
||||
|
||||
- Never edit, create or delete any file.
|
||||
- Never run a command. The search results you need are already in the input.
|
||||
- Read only the files the input names (each lesson's `files`, plus `AGENTS.md` when `context.agentsMd` is set). Read nothing else.
|
||||
- Judge only: no fixes, no advice outside a verdict's reason or suggestion.
|
||||
- Return the JSON below as the whole reply: no prose before or after it, no code fence.
|
||||
|
||||
## The input
|
||||
|
||||
The JSON that `lessons.mjs check-input` printed:
|
||||
|
||||
- `checkId`: copy it into your reply unchanged.
|
||||
- `lessons`: each with `id`, `text`, `why`, `kind`, `about`, `files` (`path`, `hash`, `read`: `whole` or `sampled`), `budgetHit` (true when files were left unread) and, when the lesson carries a search, `search` and `searchResult` (`matched`, `hits`, `filesSearched`).
|
||||
- `context`: `agentsMd` (`AGENTS.md` or null), `saved` (the project's saved lessons: `id`, `text`) and `waiting` (the other waiting lessons: `id`, `text`).
|
||||
|
||||
## The four tests
|
||||
|
||||
Give every lesson all four, each a verdict and one sentence of reason.
|
||||
|
||||
- **true**: True against the code. Read the listed files and the search result: does the code still do what the lesson says? A `searchResult` that did not match, or matched where the lesson says it should not, counts against it.
|
||||
- **worth**: Worth keeping. Not obvious from reading the code, not a one-off, and the `why` earns its place. A teammate's run would act differently because of it.
|
||||
- **overlap**: Overlap or conflict. Compare with `context.saved`, `context.waiting` and `AGENTS.md`: a near-duplicate, or a statement that contradicts one. Name what it overlaps in the reason.
|
||||
- **clear**: Clear enough. One sentence a teammate can act on without this conversation: it names the thing and says what to do.
|
||||
|
||||
## Tidy-ups
|
||||
|
||||
With `check-input --tidy`, a lesson may carry `type: "tidy"`, `change` (merge, reword, retire or move), `reason` and `targets` (the saved lessons it touches: `id`, `text`, `why`, `kind`, `about`, `area`). Give it the same four tests and the same reply shape, judging the change:
|
||||
|
||||
- merge, reword: the lesson under test is `text`, the new wording, with the targets' `about`. **true**: it is still true against the files. **worth**: it is worth more than the targets said apart. **overlap**: it overlaps `context.saved` (the targets are left out of it). **clear**: one sentence a teammate can act on. A merge that drops a fact its targets held is a Doubt on **true**.
|
||||
- retire: grade the proposal, so Pass means the lesson should go. **true**: the reason holds against the files (the lesson no longer matches the code). **worth**: retiring loses nothing a teammate needs. **overlap**: no other saved lesson depends on it. **clear**: the reason is one plain sentence. `reason` is the proposer's view, never proof.
|
||||
- Suggest a wording only for a merge or reword; a retire or move has none to change, and a suggestion there is dropped.
|
||||
- move: `area` is where it lands (`targets[0].area` is where it is). **clear**: does the new area's name fit what the lesson is about? The other tests grade the lesson as it stands.
|
||||
|
||||
## The three verdicts
|
||||
|
||||
- **Pass**: it holds.
|
||||
- **Doubt**: you cannot tell, or it is weak. Give a Doubt when you could not read enough to decide, when `budgetHit` is true and the unread files could change the answer, or when the search does not test what the lesson says.
|
||||
- **Fail**: it is plainly wrong, a duplicate, a conflict, or unclear. Say what is wrong.
|
||||
|
||||
## A suggested wording
|
||||
|
||||
Optional, on a lesson with a Doubt or Fail where a better sentence would fix it. One sentence, at most 200 characters, in the same voice as the lesson, never a secret, a person's name or a customer detail. Leave `suggestion` out when you have none. A bad one is dropped.
|
||||
|
||||
## The reply
|
||||
|
||||
```json
|
||||
{
|
||||
"checkId": "<the input's checkId>",
|
||||
"how": "helper",
|
||||
"verdicts": [
|
||||
{
|
||||
"id": "<lesson id>",
|
||||
"tests": {
|
||||
"true": { "verdict": "Pass", "reason": "One sentence." },
|
||||
"worth": { "verdict": "Pass", "reason": "One sentence." },
|
||||
"overlap": { "verdict": "Doubt", "reason": "One sentence." },
|
||||
"clear": { "verdict": "Pass", "reason": "One sentence." }
|
||||
},
|
||||
"suggestion": "Optional one-sentence wording."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
One verdict per lesson in `lessons`, none for a lesson not listed. `how` is `helper` when you are a fresh helper, `same-agent` when the noting agent grades in a separate step. Every `reason` is one sentence of at most 200 characters, on one line, with no secret in it.
|
||||
@@ -27,9 +27,12 @@ Once per run: when a reference sends you here inside a run that already did Star
|
||||
|
||||
- Before the first edit in a folder outside the areas already read, run `read --paths <that folder> --run <handle>`, keep the new `run`, and print its `line` when not empty, such as "Read 3 more for Web console server."
|
||||
- When a lesson changes what you do, and you would have done otherwise, print at that moment: "Following a lesson: <the lesson>".
|
||||
Then run `node "<S>/lessons.mjs" follow --lesson <its id> --skill <this skill>` (the ids come from `read`) so the reader can show how often lessons are followed. It is recorded on this machine only and does nothing while Learning is off; skip it quietly when it fails.
|
||||
- When your own memory disagrees with a lesson, follow the lesson and say "My own memory says otherwise; following the project's lesson: <the lesson>". If the person says the memory is right, note a doubt about that lesson.
|
||||
|
||||
The rest of this section is for the seven skills that note lessons: Implement, Implement + Review, Quick Task, Diagnose, X-ray, Review and Test.
|
||||
**Remember this (every skill that reads lessons).** When the person asks for something to be remembered ("remember this", "so this doesn't happen again" or the like), note it in that turn with `--source said` (the note commands below) and print the returned "Noted for the end of the run: <the lesson>" line. The script refuses a correction or convention without a `--why`: when the person gave no reason for one, ask one short question first ("Why does this matter?") and note it once with their answer as the Why; with no answer, note it with `--why "You asked for this to be remembered."`: the card's row then asks for the reason, and only a Reword with one saves it. Noting the same words again with a different `--why` replaces the waiting item. A said lesson in a skill with no End waits, and shows in the dashboard banner's Review.
|
||||
|
||||
Inferred lessons and fixes to `AGENTS.md` (below) are for the seven skills that note lessons only: Implement, Implement + Review, Quick Task, Diagnose, X-ray, Review and Test. The script refuses `--source inferred` from the other eight, which note only what the person said and the doubts Start step 5 and the memory bullet above ask for.
|
||||
|
||||
**What to offer.** Offer only what a teammate's run should follow: a fact about the code, never secrets, customer or personal details, or remarks about people. Facts about this codebase that a teammate would need are offered as lessons; a person's own preferences stay in whatever memory their agent keeps. Never offer what is already in `AGENTS.md` or in a lesson just read.
|
||||
|
||||
@@ -44,7 +47,8 @@ The rest of this section is for the seven skills that note lessons: Implement, I
|
||||
|
||||
**The note commands** (`--skill` is this skill's name, such as `implement`):
|
||||
|
||||
- A lesson: `node "<S>/lessons.mjs" note --type lesson --text "<one sentence>" --kind <kind> --about <one to three files, or one folder> --source said|inferred [--seen <files>] [--why "<one sentence>"] --skill <name>`
|
||||
- A lesson: `node "<S>/lessons.mjs" note --type lesson --text "<one sentence>" --kind <kind> --about <one to three files, or one folder> --source said|inferred [--seen <files>] [--why "<one sentence>"] [--shows-in <glob> --match should|never --text-match "<literal>"] --skill <name>`
|
||||
Give it a search (all three flags or none) when the lesson names text that should always, or never, appear in some files, such as "never `localStorage` in `src/web-console/public/**/*.js`": the check and later reads test it against the code, and a search that stops agreeing raises a doubt. The literal is one line, at most 120 characters.
|
||||
- A doubt about a saved lesson: `note --type doubt --target <lesson id> --found "<one sentence>" --skill <name>`
|
||||
- A fix to `AGENTS.md`: whatever corrects something `AGENTS.md` states is a fix, not a lesson: `note --type agents-fix --before "<exact text>" --after "<new text>" [--file .agents-docs/<name>.md] --skill <name>`. A test map row is `note --type agents-fix --test-map-row '<{"area","paths":[..],"run","shared"}>' --skill <name>`. Note a lesson only when `AGENTS.md` has no place for it.
|
||||
- A new area: when a lesson fits no existing area and is not general, run `areas --suggest` and note the fitting suggestion, or, when the test map offers none, a name and paths of your own: `note --type area --name "<Area name>" --paths <glob,glob> --skill <name>`. It shows in the same list as Create, Rename or Drop.
|
||||
@@ -53,13 +57,19 @@ Print the returned `line`, such as "Noted for the end of the run: <the lesson>".
|
||||
|
||||
## End
|
||||
|
||||
The seven noting skills only (and any skill sent here by Start's Review now), before the commit instructions and before the console's finish.
|
||||
The seven noting skills (and any skill sent here by Start's Review now) run it before the commit instructions and before the console's finish. The eight read-only skills have no End: their said lessons wait for the next noting run or the dashboard banner's Review.
|
||||
|
||||
1. Run `node "<S>/lessons.mjs" list` (`list --first-ask` when the state is `not-set-up`).
|
||||
**The check** (before step 1, unless the state is `not-set-up`). Skip it when `references/lesson-check.md` is not beside this file (a read-only skill sent here by Review now ships no checker brief): run plain `list`, and the rows show Not checked yet. Otherwise run `node "<S>/lessons.mjs" check-input`. `lessons` empty: skip the check and run step 1 as written. Otherwise:
|
||||
|
||||
- **Start the checker** with `references/lesson-check.md` and the JSON. With helpers on and available, it is a fresh helper given reading tools only, never relying on a permission mode (Claude Code: a custom helper already installed whose tool list holds only reading tools, such as `tools: Read, Grep, Glob`, never the built-in `Explore` or a general-purpose one, since both keep the shell; Devin: `run_subagent` with the read-only explore profile; Codex: a fresh helper told it may only read), `how: "helper"`, at `helper-strength.md`'s lesson check row (standard strength, medium effort). With Subagents off for the skill, no helper support, or (Claude Code) no reading-only helper installed, you grade in a separate step after re-reading the brief, `how: "same-agent"`; the card says so.
|
||||
- Write its reply to a file in the console session folder, or the OS temp folder in a terminal, never in the project. Run `check-record --file <path>`. Exit 4: give the checker its `problems` once and record again; still failing, step 1 runs `list --check-failed "<one line>"` and every lesson still shows.
|
||||
- Step 1 then runs `list --check <checkId>`. On the web console, post an `activity` line while it runs ("Checking 4 lessons").
|
||||
|
||||
1. Run `node "<S>/lessons.mjs" list` (`list --first-ask` when the state is `not-set-up`; `list --check <checkId>` after a check, or `list --check-failed "<one line>"` when it failed).
|
||||
2. `items` empty and no `firstAsk`: say nothing and skip this step.
|
||||
3. `firstAsk` present: see The first ask below, instead of 4 to 7.
|
||||
4. Show `opening` first when present.
|
||||
5. **On the web console:** post the returned `card` as one `lessons` item with `--wait` (a new `id` when an earlier lessons card is in the session). Its reply has one line per decision ("Keep: ...", "Reword: ...") and a `Decisions:` line holding them as JSON: that JSON is step 6's file, plus what a choice still needs. A `Suggestions wanted on` line for it: reply in its `thread` and, in the same patch, send `suggested` (row id to one of that row's `choices`, such as `{"w1":"Keep"}`), which outlines those buttons without choosing them. **In a terminal:** ask each group in `rounds` with your question tool, one question per item with exactly its `choices` and nothing pre-selected (`heading`, `text`, `why`, `origin` and `note` are what the person reads; an area shows its `name` and `paths`); with no question tool, a numbered list. A choice that needs more (step 6) asks the person for it.
|
||||
5. **On the web console:** post the returned `card` as one `lessons` item with `--wait` (a new `id` when an earlier lessons card is in the session). Its reply has one line per decision ("Keep: ...", "Reword: ...") and a `Decisions:` line holding them as JSON: that JSON is step 6's file, plus what a choice still needs. A `Suggestions wanted on` line for it: reply in its `thread` and, in the same patch, send `suggested` (row id to one of that row's `choices`, such as `{"w1":"Keep"}`), which outlines those buttons without choosing them. **In a terminal:** ask each group in `rounds` with your question tool, one question per item with exactly its `choices` and nothing pre-selected (`heading`, `text`, `why`, `origin` and `note` are what the person reads; an area shows its `name` and `paths`); with no question tool, a numbered list. Show the card's `checked` line first ("Checked 6 lessons in 40 seconds by a fresh helper that could only read", "... by the same agent that noted them", or "The check could not run: <reason>"). Read each item's `check` and `tag` into its text in this order: every Fail, then every Doubt (each as "Fail <test>: <reason>"), then the pass line ("Passed the other N", "Passed the check" with none, and no pass line when all four found something), then its `tag` when present. A `suggestion` is offered as a Reword carrying exactly those words, which the person may adjust. A choice that needs more (step 6) asks the person for it.
|
||||
6. Write the decisions, one `{ "id", "choice" }` per answered item plus what its choice needs, to a JSON file in the console session folder, or the OS temp folder in a terminal, never in the project. Run `decide --file <path>` and print its `closing` line, such as "Kept 2 (1 reworded), retired 1. 1 still waiting." What a choice needs:
|
||||
- Reword of a lesson, a doubt or a lesson whose files are gone: the new `text`, plus `why`, `kind`, `about` or `area` when they change.
|
||||
- Rename of an area: the new `name`, plus `paths` when they change.
|
||||
@@ -74,7 +84,7 @@ Never stage or commit: what End writes is part of the run's change.
|
||||
|
||||
## Unattended runs
|
||||
|
||||
A run with nobody there (an Implementation Loop phase started with `--loop`, or a helper) follows Start without asking the heads-up, follows While working and notes lessons, but never runs End, never approves and never shows the first ask. A helper reports a lesson to the main agent in its result, and the main agent notes it as its own. When `note` exits 5 in an unattended run, the lesson is not written, and the run's report says "1 lesson was not noted: it held secret-shaped text" without the text.
|
||||
A run with nobody there (an Implementation Loop phase started with `--loop`, or a helper) follows Start without asking the heads-up, follows While working, notes lessons, records each "Following a lesson" moment with `follow` (as above; a helper reports its follows to the main agent, which records them), but never runs End, never approves and never shows the first ask. A helper reports a lesson to the main agent in its result, and the main agent notes it as its own. When `note` exits 5 in an unattended run, the lesson is not written, and the run's report says "1 lesson was not noted: it held secret-shaped text" without the text. A loop phase never runs the check: its lessons are graded at the next lessons card.
|
||||
|
||||
## With Learning off
|
||||
|
||||
|
||||
+923
-38
File diff suppressed because it is too large.
Load diff
@@ -26,7 +26,7 @@ The ✕ on a chip (after the page's two-step confirm) sends `session:[{"i":"__de
|
||||
|
||||
## A Learning action
|
||||
|
||||
The Learning row and banner send `session:[{"i":"__learning","do":"switch-on"}]` (`do` is `review`, `switch-on`, `switch-off`, `move-log` or `remove`; Remove was confirmed on the page). No hop: you stay the dashboard. Run `lessons.mjs` as the dashboard skill's "A Learning action arrives" says (a `review` while Learning is not set up is `list --first-ask` and the first ask, before anything is kept; the lessons card is the only question this page shows), then `open --resume <sid> --no-open --workflow dashboard` and post the menu again with `--wait`. Pause for me never reaches you: the page saves it itself. A `__launch` with `fromBanner: true` came from a dashboard showing lessons waiting.
|
||||
The Learning row and banner send `session:[{"i":"__learning","do":"switch-on"}]` (`do` is `review`, `switch-on`, `switch-off`, `move-log`, `remove` or `tidy`; Remove was confirmed on the page). No hop: you stay the dashboard. Run `lessons.mjs` as the dashboard skill's "A Learning action arrives" says (a `review` while Learning is not set up is `list --first-ask` and the first ask, before anything is kept; the lessons card is the only question this page shows), then `open --resume <sid> --no-open --workflow dashboard` and post the menu again with `--wait`. Pause for me never reaches you: the page saves it itself. A `__launch` with `fromBanner: true` came from a dashboard showing lessons waiting.
|
||||
|
||||
## A strength suggestion
|
||||
|
||||
|
||||
@@ -126,6 +126,49 @@ export function writePause(cwd, paused, now) {
|
||||
return { paused: true, since };
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ follow counts */
|
||||
|
||||
/** One line per "Following a lesson" moment, on this machine only. */
|
||||
function followsFile(cwd) {
|
||||
return path.join(storeDir(cwd), "follows.ndjson");
|
||||
}
|
||||
|
||||
/**
|
||||
* Append one follow: `{"lesson":"<area>/<slug>","at":"<ISO>","skill":"<name>"}`.
|
||||
* The file is only ever appended to, so two runs at once cannot lose a count.
|
||||
*/
|
||||
export function recordFollow(cwd, { lesson, skill }, now) {
|
||||
const file = followsFile(cwd);
|
||||
ensureDir(path.dirname(file));
|
||||
const line = JSON.stringify({ lesson: String(lesson), at: toDate(now).toISOString(), skill: String(skill) });
|
||||
fs.appendFileSync(file, line + "\n");
|
||||
}
|
||||
|
||||
/** `{ <lesson id>: { count, last } }`, summed on read; an unreadable line is skipped. */
|
||||
export function followCounts(cwd) {
|
||||
let text;
|
||||
try {
|
||||
text = fs.readFileSync(followsFile(cwd), "utf8");
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
const counts = {};
|
||||
for (const raw of text.split("\n")) {
|
||||
if (!raw.trim()) continue;
|
||||
let row;
|
||||
try {
|
||||
row = JSON.parse(raw);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
if (!row || typeof row.lesson !== "string" || typeof row.at !== "string" || Number.isNaN(Date.parse(row.at))) continue;
|
||||
const c = counts[row.lesson] || (counts[row.lesson] = { count: 0, last: row.at });
|
||||
c.count += 1;
|
||||
if (Date.parse(row.at) > Date.parse(c.last)) c.last = row.at;
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ the waiting store */
|
||||
|
||||
const pad = (n) => String(n).padStart(2, "0");
|
||||
@@ -232,9 +275,42 @@ export function learningState(cwd = process.cwd(), now, { prune = true } = {}) {
|
||||
|
||||
/* ------------------------------------------------------- the console's view */
|
||||
|
||||
// Where the dashboard starts to nudge a tidy-up: general.md holds at most 25
|
||||
// lessons (GENERAL_MAX in lessons.mjs, which the installed console does not
|
||||
// carry), so 22 is close; an area file has no cap, so 30 is a long file.
|
||||
export const NEAR_CAP_GENERAL = 22;
|
||||
export const NEAR_CAP_AREA = 30;
|
||||
|
||||
/**
|
||||
* Whether the project's saved lessons are crowded: general.md at 22 or more,
|
||||
* or any other area file at 30 or more (counted as `### ` headings). Reads
|
||||
* only; a missing folder or an unreadable file counts as not crowded.
|
||||
*/
|
||||
export function lessonsNearCap(cwd = process.cwd()) {
|
||||
const dir = path.join(worktreeOf(cwd), ".plan2code", "lessons");
|
||||
let names;
|
||||
try {
|
||||
names = fs.readdirSync(dir);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
for (const name of names) {
|
||||
if (!name.endsWith(".md")) continue;
|
||||
let text;
|
||||
try {
|
||||
text = fs.readFileSync(path.join(dir, name), "utf8");
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
const count = text.split(/\r?\n/).filter((l) => l.startsWith("### ")).length;
|
||||
if (count >= (name === "general.md" ? NEAR_CAP_GENERAL : NEAR_CAP_AREA)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* What the dashboard's scan carries as `scan.learning`:
|
||||
* `{ state, pausedSince, waiting, oldestDays }`, or null when the state is
|
||||
* `{ state, pausedSince, waiting, oldestDays, nearCap }`, or null when the state is
|
||||
* `unknown` (a settings format this console does not know: the page then
|
||||
* draws no row) or when the core fails, so a broken store never fails `open`.
|
||||
* Reads without pruning: the console server writes nothing here but the pause.
|
||||
@@ -254,5 +330,6 @@ export function learningScan(cwd = process.cwd(), { now, read = learningState }
|
||||
pausedSince: s.pausedSince || null,
|
||||
waiting: Number.isInteger(waiting.count) ? waiting.count : 0,
|
||||
oldestDays: Number.isInteger(waiting.oldestDays) ? waiting.oldestDays : 0,
|
||||
nearCap: s.state === "on" && lessonsNearCap(cwd),
|
||||
};
|
||||
}
|
||||
@@ -856,9 +856,12 @@ export const ITEM_KINDS = new Set([
|
||||
// type and its choices, and nothing arrives already chosen (FR-14, FR-15).
|
||||
// `gone` is a saved lesson whose files no longer exist: the list offers it
|
||||
// with a doubt's words.
|
||||
export const LESSON_ROW_TYPES = ["lesson", "doubt", "gone", "agents-fix", "log-line", "area"];
|
||||
const LESSON_ROW_TEXT = ["why", "kind", "area", "origin", "note", "before", "after", "found", "heading", "file", "name"];
|
||||
const LESSON_ROW_LISTS = ["about", "areas", "flags", "lessons", "paths"];
|
||||
// `tidy` is a proposed change to saved lessons (merge, reword, retire or
|
||||
// move): `change` names it, `targets` the lessons it touches, and a merge or
|
||||
// reword carries its new `wording` and that wording's `wordingWhy`.
|
||||
export const LESSON_ROW_TYPES = ["lesson", "doubt", "gone", "agents-fix", "tidy", "log-line", "area"];
|
||||
const LESSON_ROW_TEXT = ["why", "kind", "area", "origin", "note", "before", "after", "found", "heading", "file", "name", "change", "wording", "wordingWhy"];
|
||||
const LESSON_ROW_LISTS = ["about", "areas", "flags", "lessons", "paths", "targets"];
|
||||
const LESSONS_RIGHT = {
|
||||
kind: "lessons",
|
||||
rows: [{ id: "w1", type: "lesson", text: "Run a page test with node scripts/node-test.mjs <file>.", choices: ["Keep", "Reword", "Drop"] }],
|
||||
@@ -868,6 +871,49 @@ const FIRST_ASK_RIGHT = {
|
||||
firstAsk: { lesson: { id: "w1", text: "..." }, sentences: ["...", "...", "..."], yes: "Switch Learning on", no: "Not for this project", later: "..." },
|
||||
};
|
||||
|
||||
// What the check found, as lessons.mjs list puts it on a row (`check`) and on
|
||||
// the card (`checked`), and the two words a row's `tag` may carry.
|
||||
export const LESSON_ROW_TAGS = ["Checked in an earlier run", "Not checked yet"];
|
||||
const LESSON_CHECK_KEYS = ["fails", "doubts", "passed", "suggestion"];
|
||||
const CHECK_RIGHT = { check: { fails: [{ test: "Search", reason: "It matches 3 files." }], doubts: [], passed: 3, suggestion: "A shorter wording." } };
|
||||
const CHECKED_RIGHT = { checked: { how: "helper", count: 6, seconds: 40 } };
|
||||
const isCount = (n) => Number.isInteger(n) && n >= 0;
|
||||
|
||||
function lessonCheckProblems(check, name, at) {
|
||||
if (!isPlainObject(check)) return [rule(at, name, "must be the { fails, doubts, passed, suggestion? } lessons.mjs gave", CHECK_RIGHT)];
|
||||
const problems = [];
|
||||
for (const key of Object.keys(check)) {
|
||||
if (!LESSON_CHECK_KEYS.includes(key)) problems.push(rule(at, `${name} "${key}"`, `is not a field of a check. Use ${LESSON_CHECK_KEYS.join(", ")}`, CHECK_RIGHT));
|
||||
}
|
||||
for (const key of ["fails", "doubts"]) {
|
||||
const list = check[key];
|
||||
if (list == null) continue;
|
||||
if (!Array.isArray(list) || list.length > 4) {
|
||||
problems.push(rule(at, `${name} ${key}`, "must be an array of at most 4 { test, reason } entries", CHECK_RIGHT));
|
||||
continue;
|
||||
}
|
||||
list.forEach((e, i) => {
|
||||
const ok = isPlainObject(e) && typeof e.test === "string" && typeof e.reason === "string" && e.reason.length <= 240;
|
||||
if (!ok) problems.push(rule(at, `${name} ${key}[${i}]`, "must be { test, reason }, two strings, the reason at most 240 characters", CHECK_RIGHT));
|
||||
});
|
||||
}
|
||||
if (check.passed != null && !(Number.isInteger(check.passed) && check.passed >= 0 && check.passed <= 4)) {
|
||||
problems.push(rule(at, `${name} passed`, "must be a whole number from 0 to 4", CHECK_RIGHT));
|
||||
}
|
||||
if (check.suggestion != null && (typeof check.suggestion !== "string" || check.suggestion.length > 200)) {
|
||||
problems.push(rule(at, `${name} suggestion`, "must be a string of at most 200 characters, or left out", CHECK_RIGHT));
|
||||
}
|
||||
return problems;
|
||||
}
|
||||
|
||||
function lessonsCheckedProblems(checked, at) {
|
||||
const how = isPlainObject(checked) && ["helper", "same-agent"].includes(checked.how);
|
||||
const ran = how && isCount(checked.count) && isCount(checked.seconds) && Object.keys(checked).every((k) => ["how", "count", "seconds"].includes(k));
|
||||
const failed = isPlainObject(checked) && typeof checked.failed === "string" && checked.failed.length <= 200 && Object.keys(checked).length === 1;
|
||||
if (ran || failed) return [];
|
||||
return [rule(at, "checked", 'must be { how: "helper" or "same-agent", count, seconds } (whole numbers), or { failed } with a reason of at most 200 characters', CHECKED_RIGHT)];
|
||||
}
|
||||
|
||||
// What is wrong with a lessons item, as rule() sentences.
|
||||
function lessonsProblems(item, at) {
|
||||
const problems = [];
|
||||
@@ -923,7 +969,12 @@ function lessonsProblems(item, at) {
|
||||
if (row.refused != null && !isPlainObject(row.refused)) {
|
||||
problems.push(rule(at, `${name} refused`, "must be the { pattern, part } lessons.mjs gave, or null", { refused: { pattern: "aws-access-key", part: "AKIA" } }));
|
||||
}
|
||||
if (row.check != null) problems.push(...lessonCheckProblems(row.check, `${name} check`, at));
|
||||
if (row.tag != null && !LESSON_ROW_TAGS.includes(row.tag)) {
|
||||
problems.push(rule(at, `${name} tag`, `must be one of ${LESSON_ROW_TAGS.map((t) => `"${t}"`).join(", ")}, or left out`, { tag: LESSON_ROW_TAGS[0] }));
|
||||
}
|
||||
});
|
||||
if (item.checked != null) problems.push(...lessonsCheckedProblems(item.checked, at));
|
||||
// The agent's answer to Ask for suggestions, readable by the page: row id to
|
||||
// one of that row's own choice words. It outlines a button; it never picks.
|
||||
const sug = item.suggested;
|
||||
|
||||
@@ -191,11 +191,11 @@ export function answerLines(item, v) {
|
||||
|
||||
// The choice that keeps a row as it stands, per row type (FR-15). A refused
|
||||
// row cannot take it until it is reworded.
|
||||
export const LESSON_KEEP_WORD = { lesson: "Keep", doubt: "Keep", gone: "Keep", "agents-fix": "Apply", "log-line": "Move", area: "Create" };
|
||||
export const LESSON_KEEP_WORD = { lesson: "Keep", doubt: "Keep", gone: "Keep", "agents-fix": "Apply", tidy: "Apply", "log-line": "Move", area: "Create" };
|
||||
// The choices that open the row for editing.
|
||||
export const LESSON_EDIT_WORDS = new Set(["Reword", "Reword and move", "Rename"]);
|
||||
// The edit word per row type: what a refused row's keep word goes back to.
|
||||
export const LESSON_EDIT_WORD = { lesson: "Reword", doubt: "Reword", gone: "Reword", "agents-fix": "Reword", "log-line": "Reword and move", area: "Rename" };
|
||||
export const LESSON_EDIT_WORD = { lesson: "Reword", doubt: "Reword", gone: "Reword", "agents-fix": "Reword", tidy: "Reword", "log-line": "Reword and move", area: "Rename" };
|
||||
// The first ask's answers, as the agent reads them.
|
||||
export const FIRST_ASK_WORDS = { yes: "Switch Learning on", no: "Not for this project" };
|
||||
|
||||
@@ -211,12 +211,17 @@ export function lessonEditField(row) {
|
||||
// list gave none (a refused line comes masked and with none).
|
||||
const logLessons = (row) => (Array.isArray(row.lessons) && row.lessons.length ? row.lessons.map(String) : [row.text || ""]);
|
||||
|
||||
/** The edit fields' first values: the row as it stands. */
|
||||
export function lessonEditStart(row) {
|
||||
if (row.type === "agents-fix") return { after: lessonOriginal(row) };
|
||||
if (row.type === "area") return { name: lessonOriginal(row), paths: [...(row.paths || [])] };
|
||||
if (row.type === "log-line") return { lessons: logLessons(row), why: row.why || "", area: row.area || "" };
|
||||
return { text: lessonOriginal(row), why: row.why || "", area: row.area || "" };
|
||||
/**
|
||||
* The edit fields' first values: the row as it stands, or its text replaced by
|
||||
* `prefill` (a suggested wording) when one is given.
|
||||
*/
|
||||
export function lessonEditStart(row, prefill) {
|
||||
const given = typeof prefill === "string" && prefill.trim() ? prefill : null;
|
||||
if (row.type === "agents-fix") return { after: given ?? lessonOriginal(row) };
|
||||
if (row.type === "area") return { name: given ?? lessonOriginal(row), paths: [...(row.paths || [])] };
|
||||
if (row.type === "log-line") return { lessons: given ? [given] : logLessons(row), why: row.why || "", area: row.area || "" };
|
||||
if (row.type === "tidy") return { text: given ?? lessonOriginal(row), why: row.wordingWhy || "", area: row.area || "" };
|
||||
return { text: given ?? lessonOriginal(row), why: row.why || "", area: row.area || "" };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,6 +232,8 @@ export function lessonOriginal(row) {
|
||||
if (row.type === "agents-fix") return row.after || row.text || "";
|
||||
if (row.type === "area") return row.name || row.text || "";
|
||||
if (row.type === "log-line") return logLessons(row).join("\n");
|
||||
// A tidy row's words are the new wording, not the sentence describing the change.
|
||||
if (row.type === "tidy") return row.wording || "";
|
||||
return row.text || "";
|
||||
}
|
||||
|
||||
@@ -267,7 +274,8 @@ export function lessonDecision(row, choice, edit = {}) {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
const why = typeof edit.why === "string" ? edit.why.trim() : row.why || "";
|
||||
const baseWhy = row.type === "tidy" ? row.wordingWhy || "" : row.why || "";
|
||||
const why = typeof edit.why === "string" ? edit.why.trim() : baseWhy;
|
||||
const area = typeof edit.area === "string" && edit.area && edit.area !== (row.area || "") ? edit.area : "";
|
||||
if (row.type === "log-line") {
|
||||
const texts = typed.split("\n");
|
||||
@@ -275,7 +283,7 @@ export function lessonDecision(row, choice, edit = {}) {
|
||||
}
|
||||
const out = { ...d, text: typed };
|
||||
// An emptied Why is sent as "", so decide does not keep the old one.
|
||||
if (why || (typeof edit.why === "string" && row.why)) out.why = why;
|
||||
if (why || (typeof edit.why === "string" && baseWhy)) out.why = why;
|
||||
if (area) out.area = area;
|
||||
return out;
|
||||
}
|
||||
@@ -294,7 +302,7 @@ export function lessonMissing(row, decision) {
|
||||
/** The words one decision reads as: "Keep: <text>", "Reword: <new text>", "Apply: <file>". */
|
||||
export function lessonDecisionLine(row, d) {
|
||||
const shown =
|
||||
d.choice === "Apply"
|
||||
d.choice === "Apply" && !(row && row.type === "tidy")
|
||||
? (row && row.file) || "AGENTS.md"
|
||||
: Array.isArray(d.lessons)
|
||||
? d.lessons.map((l) => (l && l.text) || "").join(" / ")
|
||||
@@ -982,13 +990,14 @@ export function deleteReply(spec) {
|
||||
// A Learning control on the dashboard (screens/learning-row.js and the
|
||||
// waiting banner). No hop: the dashboard agent runs lessons.mjs for it. Plain
|
||||
// wording, no em dashes: these lines are read by the agent.
|
||||
export const LEARNING_ACTIONS = ["review", "switch-on", "switch-off", "move-log", "remove"];
|
||||
export const LEARNING_ACTIONS = ["review", "switch-on", "switch-off", "move-log", "remove", "tidy"];
|
||||
const LEARNING_REPLIES = {
|
||||
review: "Review the waiting lessons.",
|
||||
"switch-on": "Switch Learning on for this project.",
|
||||
"switch-off": "Switch Learning off for this project.",
|
||||
"move-log": "Move the failure log into lessons.",
|
||||
remove: "Remove all saved lessons from this project. Learning stays on.",
|
||||
tidy: "Tidy up the saved lessons: propose merges, rewords, retires and moves.",
|
||||
};
|
||||
export function learningAction(what) {
|
||||
if (!LEARNING_ACTIONS.includes(what)) throw new Error("unknown Learning action: " + what);
|
||||
@@ -1016,6 +1025,13 @@ export function learningBannerText(learning) {
|
||||
return `${n} ${n === 1 ? "lesson is" : "lessons are"} waiting for your review (oldest ${d} ${d === 1 ? "day" : "days"}).`;
|
||||
}
|
||||
|
||||
// The tidy-up nudge's line, or "" when it shows nothing: the saved lessons are
|
||||
// near their limit (the scan's nearCap) and Learning is on.
|
||||
export function learningNearCapText(learning) {
|
||||
if (!learning || learning.state !== "on" || learning.nearCap !== true) return "";
|
||||
return "Lessons are nearing their limit. Tidy up?";
|
||||
}
|
||||
|
||||
// What the delete dialog says about the spec, from the scan alone. `touched`
|
||||
// stays a number: the page formats it in the person's own locale.
|
||||
// A handoff on the dashboard (scan.handoffs). The page sends only the id; the
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
lessonDecision,
|
||||
lessonMissing,
|
||||
lessonEditStart,
|
||||
lessonEditField,
|
||||
lessonReworded,
|
||||
startsTicked,
|
||||
} from "../answers.js";
|
||||
@@ -1825,6 +1826,8 @@ function buildLessons(card, item, staged) {
|
||||
};
|
||||
|
||||
if (item.opening) card.appendChild(el("p", "lessons-opening", item.opening));
|
||||
const how = lessonsCheckedLine(item.checked);
|
||||
if (how) card.appendChild(el("p", "lessons-checked", how));
|
||||
const list = el("ul", "lessons-rows");
|
||||
for (const row of item.rows || []) list.appendChild(lessonRow(item, row, draft, commit));
|
||||
card.appendChild(list);
|
||||
@@ -1850,6 +1853,61 @@ function buildLessons(card, item, staged) {
|
||||
commentField(card, item, "Anything to add?");
|
||||
}
|
||||
|
||||
const plural = (n, one) => `${n} ${one}${n === 1 ? "" : "s"}`;
|
||||
|
||||
// The card's one how-checked line, or "" when the card carries none.
|
||||
function lessonsCheckedLine(checked) {
|
||||
if (!checked || typeof checked !== "object") return "";
|
||||
if (typeof checked.failed === "string") return `The check could not run: ${checked.failed}`;
|
||||
const by = checked.how === "helper" ? "a fresh helper that could only read" : checked.how === "same-agent" ? "the same agent that noted them" : "";
|
||||
if (!by) return "";
|
||||
return `Checked ${plural(checked.count, "lesson")} in ${plural(checked.seconds, "second")} by ${by}`;
|
||||
}
|
||||
|
||||
// What the check found on one row: each Fail then each Doubt on a line of its
|
||||
// own, then a quiet pass line. Nothing at all for a row the check never saw.
|
||||
function lessonCheckLines(li, item, row, draft, commit) {
|
||||
const check = row.check;
|
||||
if (!check || typeof check !== "object") return;
|
||||
const fails = Array.isArray(check.fails) ? check.fails : [];
|
||||
const doubts = Array.isArray(check.doubts) ? check.doubts : [];
|
||||
const box = el("div", "lesson-checks");
|
||||
for (const [word, list] of [["Fail", fails], ["Doubt", doubts]]) {
|
||||
for (const e of list) {
|
||||
const line = el("p", "lesson-check " + word.toLowerCase());
|
||||
line.appendChild(el("span", "lesson-check-word", word));
|
||||
line.appendChild(document.createTextNode(` ${e.test}: ${e.reason}`));
|
||||
box.appendChild(line);
|
||||
}
|
||||
}
|
||||
const found = fails.length + doubts.length;
|
||||
// With all four tests flagged there is nothing left that passed.
|
||||
if (!found || check.passed !== 0) box.appendChild(el("p", "lesson-check-pass", found && Number.isInteger(check.passed) ? `Passed the other ${check.passed}` : "Passed the check"));
|
||||
if (check.suggestion) {
|
||||
const sug = el("p", "lesson-suggestion");
|
||||
sug.appendChild(el("span", null, `Suggested wording: ${check.suggestion}`));
|
||||
const use = el("button", "btn sm", "Use this wording");
|
||||
use.type = "button";
|
||||
use.id = `lesson-use-${item.id}-${row.id}`;
|
||||
use.addEventListener("click", () => {
|
||||
// Picks Reword and opens it on the suggestion; what is sent is a
|
||||
// normal Reword of whatever the person leaves in the box.
|
||||
const word = LESSON_EDIT_WORD[row.type];
|
||||
draft.picks[row.id] = (row.choices || []).includes(word) ? word : "Reword";
|
||||
draft.leaveAll = false;
|
||||
// Only the words change: a Why or Area already typed stays.
|
||||
const start = lessonEditStart(row, check.suggestion);
|
||||
const key = lessonEditField(row).key;
|
||||
draft.edits[row.id] = { ...(draft.edits[row.id] || start), [key]: start[key] };
|
||||
commit(true);
|
||||
document.getElementById(use.id)?.focus();
|
||||
});
|
||||
sug.appendChild(use);
|
||||
box.appendChild(sug);
|
||||
}
|
||||
li.appendChild(box);
|
||||
}
|
||||
|
||||
// One waiting item: what it is, why, where it came from, and its own choices.
|
||||
function lessonRow(item, row, draft, commit) {
|
||||
const pick = draft.picks[row.id] || "";
|
||||
@@ -1868,6 +1926,16 @@ function lessonRow(item, row, draft, commit) {
|
||||
pair.appendChild(el("p", "lessons-fix-label", "After"));
|
||||
pair.appendChild(el("blockquote", "lessons-after", row.after || row.text || ""));
|
||||
li.appendChild(pair);
|
||||
} else if (row.type === "tidy") {
|
||||
li.appendChild(el("p", "lessons-text", row.text));
|
||||
// A merge or reword replaces lessons already saved: show them, so the change reads whole.
|
||||
const was = (row.targets || []).filter((t) => t && t.text);
|
||||
if ((row.change === "merge" || row.change === "reword") && was.length) {
|
||||
li.appendChild(el("p", "lessons-heading", row.change === "merge" ? "It replaces these lessons:" : "It replaces this wording:"));
|
||||
const ul = el("ul", "lessons-become");
|
||||
for (const t of was) ul.appendChild(el("li", null, t.text));
|
||||
li.appendChild(ul);
|
||||
}
|
||||
} else if (row.type === "log-line") {
|
||||
li.appendChild(el("p", "lessons-text", row.text));
|
||||
const become = (row.lessons || []).filter(Boolean);
|
||||
@@ -1885,6 +1953,8 @@ function lessonRow(item, row, draft, commit) {
|
||||
// The doubt's and the fix's origin repeat what is drawn above them.
|
||||
if (row.origin && !["doubt", "gone", "agents-fix"].includes(row.type)) li.appendChild(el("p", "lessons-origin", row.origin));
|
||||
if (row.note) li.appendChild(el("p", "lessons-note", row.note));
|
||||
if (row.tag) li.appendChild(el("p", "lessons-tag", row.tag));
|
||||
lessonCheckLines(li, item, row, draft, commit);
|
||||
|
||||
for (const f of Array.isArray(row.flags) ? row.flags : []) {
|
||||
const what = FLAG_WORDS[f && f.pattern] || "something personal";
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
loopDriving,
|
||||
learningBusyNow,
|
||||
LEARNING_BUSY_MS,
|
||||
learningBusyLimit,
|
||||
} from "../selectors.js";
|
||||
import { whenTitle, whenWords } from "../labels.js";
|
||||
import { hooks, page, redraw, saveNow } from "../state.js";
|
||||
@@ -49,6 +50,7 @@ import {
|
||||
learningAction,
|
||||
learningReply,
|
||||
learningBannerText,
|
||||
learningNearCapText,
|
||||
noteSwitchShows,
|
||||
noteTabEmpty,
|
||||
defaultNoteTicks,
|
||||
@@ -1440,16 +1442,17 @@ function learningBanner(sc) {
|
||||
const busy = learningBusyNow(state);
|
||||
// Review pressed, or the choices just saved: the banner says what the agent
|
||||
// is doing, in the same place, so the wait is never silent.
|
||||
const working = busy && (busy.what === "review" || busy.what === "decide") ? busy : null;
|
||||
const working = busy && (busy.what === "review" || busy.what === "decide" || busy.what === "tidy") ? busy : null;
|
||||
const text = learningBannerText(sc && sc.learning);
|
||||
if (!text && !working) return null;
|
||||
const nudge = learningNearCapText(sc && sc.learning);
|
||||
if (!text && !nudge && !working) return null;
|
||||
const banner = el("div", "callout is-info dash-nudge learn-banner");
|
||||
banner.setAttribute("role", "status");
|
||||
if (working) {
|
||||
banner.classList.add("is-busy");
|
||||
banner.setAttribute("aria-busy", "true");
|
||||
const line = el("span", "dash-nudge-text learn-busy");
|
||||
line.append(el("span", "spinner tiny"), document.createTextNode(working.what === "review" ? "Opening lessons…" : "Saving your lessons…"));
|
||||
line.append(el("span", "spinner tiny"), document.createTextNode(working.what === "review" ? "Opening lessons…" : working.what === "tidy" ? "Looking over your lessons…" : "Saving your lessons…"));
|
||||
banner.appendChild(line);
|
||||
if (working.what === "review") {
|
||||
const review = el("button", "btn sm primary", "Review");
|
||||
@@ -1459,14 +1462,21 @@ function learningBanner(sc) {
|
||||
}
|
||||
return banner;
|
||||
}
|
||||
banner.appendChild(el("span", "dash-nudge-text", text));
|
||||
const review = el("button", "btn sm primary", "Review");
|
||||
review.type = "button";
|
||||
const why = hooks.learningBlocked();
|
||||
review.disabled = Boolean(why);
|
||||
if (why) review.title = why;
|
||||
review.addEventListener("click", () => sendLearning("review"));
|
||||
banner.appendChild(review);
|
||||
// Each line is its own row with its own button: lessons waiting, and lessons near their limit.
|
||||
const row = (words, label, what, primary) => {
|
||||
const r = el("div", "learn-banner-row");
|
||||
r.appendChild(el("span", "dash-nudge-text", words));
|
||||
const b = el("button", "btn sm" + (primary ? " primary" : ""), label);
|
||||
b.type = "button";
|
||||
b.disabled = Boolean(why);
|
||||
if (why) b.title = why;
|
||||
b.addEventListener("click", () => sendLearning(what));
|
||||
r.appendChild(b);
|
||||
banner.appendChild(r);
|
||||
};
|
||||
if (text) row(text, "Review", "review", true);
|
||||
if (nudge) row(nudge, "Tidy up", "tidy", !text);
|
||||
return banner;
|
||||
}
|
||||
|
||||
@@ -1478,7 +1488,7 @@ function learningBanner(sc) {
|
||||
function watchLearningBusy(busy) {
|
||||
const timer = setInterval(() => {
|
||||
if (page.learningBusy !== busy) return clearInterval(timer);
|
||||
if (Date.now() - busy.at > LEARNING_BUSY_MS) {
|
||||
if (Date.now() - busy.at > learningBusyLimit(busy)) {
|
||||
clearInterval(timer);
|
||||
page.learningBusy = null;
|
||||
redraw();
|
||||
@@ -1493,8 +1503,8 @@ function watchLearningBusy(busy) {
|
||||
if (!busy.seen && Date.now() - busy.at < 3000) return;
|
||||
clearInterval(timer);
|
||||
page.learningBusy = null;
|
||||
if (busy.what === "review") {
|
||||
const none = hooks.banner("No lessons are waiting any more.", "info");
|
||||
if (busy.what === "review" || busy.what === "tidy") {
|
||||
const none = hooks.banner(busy.what === "tidy" ? "Nothing to tidy up right now." : "No lessons are waiting any more.", "info");
|
||||
setTimeout(() => hooks.clearBanner(none), 4000);
|
||||
}
|
||||
redraw();
|
||||
@@ -1523,13 +1533,13 @@ export async function sendLearning(what) {
|
||||
// the agent answers.
|
||||
const sc = scan();
|
||||
const from = sc && sc.learning && sc.learning.state;
|
||||
if ((what === "switch-on" || what === "switch-off" || what === "review") && from) {
|
||||
if ((what === "switch-on" || what === "switch-off" || what === "review" || what === "tidy") && from) {
|
||||
const busy = { what, from, at: Date.now(), seen: false };
|
||||
page.learningBusy = busy;
|
||||
redraw();
|
||||
// One redraw at the limit, so an action the agent never answers stops spinning.
|
||||
setTimeout(redraw, LEARNING_BUSY_MS + 500);
|
||||
if (what === "review") watchLearningBusy(busy);
|
||||
if (what === "review" || what === "tidy") watchLearningBusy(busy);
|
||||
}
|
||||
try {
|
||||
const res = await fetch("/submit", {
|
||||
|
||||
@@ -155,6 +155,7 @@ function moreMenu() {
|
||||
};
|
||||
list.append(
|
||||
item("Switch off for this project", () => hooks.sendLearning("switch-off")),
|
||||
item("Tidy up lessons", () => hooks.sendLearning("tidy")),
|
||||
item("Move the failure log into lessons", () => hooks.sendLearning("move-log")),
|
||||
item("Remove all lessons…", () => openRemoveConfirm(), " is-danger")
|
||||
);
|
||||
@@ -504,6 +505,49 @@ function openRemoveConfirm() {
|
||||
dlg.showModal();
|
||||
}
|
||||
|
||||
// The same slug lessons.mjs gives a lesson's heading (slugOf), so a lesson's id
|
||||
// is `<file name without .md>/<slug>` here as there.
|
||||
function slugOf(text) {
|
||||
return String(text || "")
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-+|-+$/g, "")
|
||||
.slice(0, 60)
|
||||
.replace(/-+$/, "");
|
||||
}
|
||||
|
||||
/** "Followed 12 times, last on Nov 20", "Followed once, last on Nov 20" or "Not followed yet". */
|
||||
function followLine(entry) {
|
||||
if (!entry || !(entry.count > 0)) return "Not followed yet";
|
||||
const last = shortDate(entry.last);
|
||||
const times = entry.count === 1 ? "once" : `${entry.count} times`;
|
||||
return `Followed ${times}${last ? ", last on " + last : ""}`;
|
||||
}
|
||||
|
||||
// One file's text through the page's Markdown, a quiet follow line under each
|
||||
// lesson's heading (a "### " line).
|
||||
function appendLessonText(part, file, follows) {
|
||||
const area = String(file.name || "").replace(/\.md$/i, "");
|
||||
const chunks = String(file.text || "").split(/\r?\n(?=### )/);
|
||||
const add = (text) => {
|
||||
if (!text.trim()) return;
|
||||
const div = el("div", "md");
|
||||
mdInto(div, text);
|
||||
part.appendChild(div);
|
||||
};
|
||||
for (const chunk of chunks) {
|
||||
const m = /^### (.+?)\s*(?:\r?\n|$)/.exec(chunk);
|
||||
if (!m) {
|
||||
add(chunk);
|
||||
continue;
|
||||
}
|
||||
add(m[0]);
|
||||
const line = el("p", "learn-follow", followLine(follows[`${area}/${slugOf(m[1])}`]));
|
||||
part.appendChild(line);
|
||||
add(chunk.slice(m[0].length));
|
||||
}
|
||||
}
|
||||
|
||||
// Open the lessons: every lesson file, read-only, through the page's Markdown.
|
||||
async function openLessons() {
|
||||
let dlg = document.getElementById("learn-lessons-modal");
|
||||
@@ -525,7 +569,7 @@ async function openLessons() {
|
||||
try {
|
||||
const res = await fetch("/learning/lessons", { cache: "no-store" });
|
||||
if (res.status !== 200) throw new Error(String(res.status));
|
||||
const { files } = await res.json();
|
||||
const { files, follows } = await res.json();
|
||||
body.replaceChildren();
|
||||
if (!files || !files.length) {
|
||||
body.appendChild(el("p", "md-p", "No lessons are saved in this project yet."));
|
||||
@@ -534,9 +578,7 @@ async function openLessons() {
|
||||
for (const f of files) {
|
||||
const part = el("section", "learn-lessons-file");
|
||||
part.appendChild(el("p", "learn-lessons-name", f.name));
|
||||
const text = el("div", "md");
|
||||
mdInto(text, f.text || "");
|
||||
part.appendChild(text);
|
||||
appendLessonText(part, f, follows || {});
|
||||
body.appendChild(part);
|
||||
}
|
||||
} catch {
|
||||
|
||||
@@ -15,6 +15,16 @@ export const WORKING_GRACE_MS = 5 * 60 * 1000;
|
||||
// How long a Learning action may show as working before the page gives up
|
||||
// waiting for the agent (it normally answers in a second or two).
|
||||
export const LEARNING_BUSY_MS = 30000;
|
||||
// Review and Tidy up first grade every waiting lesson (check-input, a checker,
|
||||
// check-record), which often takes longer than LEARNING_BUSY_MS: while the
|
||||
// agent is still working on one, the page waits up to this long instead.
|
||||
export const LEARNING_CHECK_MS = 5 * 60 * 1000;
|
||||
|
||||
/** How long a Learning action may stay busy: LEARNING_CHECK_MS for a Review or Tidy up the agent is still working on, else LEARNING_BUSY_MS. */
|
||||
export function learningBusyLimit(busy) {
|
||||
const checking = (busy.what === "review" || busy.what === "tidy") && (page.pendingResult || agentWorking());
|
||||
return checking ? LEARNING_CHECK_MS : LEARNING_BUSY_MS;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Learning action the person just pressed while the agent works on it, or
|
||||
@@ -31,9 +41,9 @@ export function learningBusyNow(state) {
|
||||
page.learningBusy = null;
|
||||
return null;
|
||||
};
|
||||
if (Date.now() - busy.at > LEARNING_BUSY_MS) return end();
|
||||
if (Date.now() - busy.at > learningBusyLimit(busy)) return end();
|
||||
if ((busy.what === "switch-on" || busy.what === "switch-off") && busy.from !== state) return end();
|
||||
if (busy.what === "review" && ((page.S && page.S.items) || []).some((i) => i && i.kind === "lessons" && isOpen(i))) return end();
|
||||
if ((busy.what === "review" || busy.what === "tidy") && ((page.S && page.S.items) || []).some((i) => i && i.kind === "lessons" && isOpen(i))) return end();
|
||||
return busy;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,10 +112,18 @@
|
||||
/* Lessons waiting: the banner nearest the title, in the accent tint. */
|
||||
.dash-nudge.learn-banner { border-left-width: 4px; }
|
||||
.learn-banner .btn { margin-left: auto; }
|
||||
/* Two lines in one banner (lessons waiting, lessons near their limit): each its own row. */
|
||||
.learn-banner-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; flex: 1 1 100%; }
|
||||
|
||||
/* Open the lessons: each file under its own name. */
|
||||
.learn-lessons-file + .learn-lessons-file { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }
|
||||
.learn-lessons-name { margin: 0 0 6px; font-family: var(--mono); font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
/* Each file's own .md block would keep the page-wide 68ch cap; let it fill the dialog.
|
||||
A lesson's title is a long heading: balanced wrapping (tokens.css) halves it, so fill each line. */
|
||||
.learn-lessons-file .md { max-width: none; }
|
||||
.learn-lessons-file .md-h { text-wrap: wrap; }
|
||||
/* One quiet line under a lesson's heading: how often it was followed. */
|
||||
.learn-follow { margin: 2px 0 6px; font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
|
||||
/* The lessons card (cards.js buildLessons): one block per item, none chosen at first. */
|
||||
.lessons-opening { margin: 14px 0 0; font-size: var(--fs-md); color: var(--ink-3); }
|
||||
@@ -134,6 +142,15 @@
|
||||
.lessons-found { font-size: var(--fs-md); color: var(--ink-2); }
|
||||
.lessons-origin,
|
||||
.lessons-note { font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
.lessons-tag { font-size: var(--fs-sm); color: var(--ink-3); font-style: italic; }
|
||||
.lessons-checked { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink-3); }
|
||||
.lesson-checks { margin: 0 0 6px; }
|
||||
.lesson-checks p { margin: 0 0 4px; font-size: var(--fs-md); }
|
||||
.lesson-check-word { font-weight: 700; margin-right: 2px; }
|
||||
.lesson-check.fail { color: var(--warn); }
|
||||
.lesson-check.doubt { color: var(--stage); }
|
||||
.lesson-checks .lesson-check-pass { color: var(--ink-3); font-size: var(--fs-sm); }
|
||||
.lesson-suggestion { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--ink-2); }
|
||||
.lessons-fix blockquote {
|
||||
margin: 0 0 8px;
|
||||
padding: 6px 10px;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* Print only the document; session furniture stays off paper. */
|
||||
@media print {
|
||||
.topbar, .rail, .aside, .footer, .banner, .skip, .doc-tools, .pager, .modal, .arrival, .review-offer { display: none !important; }
|
||||
html, body { height: auto; background: #fff; color: #000; }
|
||||
html, body { height: auto; overflow: visible; background: #fff; color: #000; }
|
||||
body { display: block; }
|
||||
.layout { display: block; overflow: visible; }
|
||||
.main { overflow: visible; padding: 0; max-width: none; }
|
||||
@@ -32,7 +32,9 @@
|
||||
rail becomes a strip above the page (Planny beside the list) and the notes
|
||||
follow the card, as on a phone. */
|
||||
@media (max-width: 900px) {
|
||||
body { display: block; }
|
||||
/* One column: here the page scrolls as a whole (the sticky footer rides it). */
|
||||
html, body { overflow: visible; }
|
||||
body { display: block; min-height: 100vh; }
|
||||
.layout, .layout:has(> .aside:empty), .layout:has(.git-board) { display: block; }
|
||||
.rail { border-right: 0; border-bottom: 1px solid var(--rule); }
|
||||
.sidebar, .aside { border: 0; border-bottom: 1px solid var(--rule); max-height: 30vh; }
|
||||
|
||||
@@ -217,6 +217,10 @@ h1 {
|
||||
grid-template-columns: 250px minmax(0, 1fr) 320px;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
/* The containing block for the absolutely placed bits inside (the rail items'
|
||||
screen-reader text): without one they sit against the page, and the ones
|
||||
below a scrolled panel stretched the page itself past the footer. */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* A side column with nothing to show is not drawn: an empty aside gives its
|
||||
|
||||
@@ -194,7 +194,9 @@ h1, h2, h3, .md-h, .dash-title, .git-branch, .git-step-title { font-variant-nume
|
||||
.md-p, .card .prompt { text-wrap: pretty; }
|
||||
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
|
||||
|
||||
html, body { height: 100%; }
|
||||
/* The page itself never scrolls (the desktop app frames it, and a scrolling
|
||||
page showed blank space under the footer): panels scroll, the shell does not. */
|
||||
html, body { height: 100%; overflow: hidden; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
@@ -203,7 +205,7 @@ body {
|
||||
font: var(--fs-base)/var(--lh-body) var(--sans);
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
min-height: 100vh;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
|
||||
@@ -52,7 +52,7 @@ import { cleanSetting, offered } from "./public/subagents.js";
|
||||
import { DEFAULT_ACCENT, DEFAULT_CARD_WIDTH, accentId, cardWidth } from "./public/palette.js";
|
||||
import { SERVABLE, TYPES, asset } from "./static.mjs";
|
||||
import { handoffsDir, isHandoffId } from "./handoffs.mjs";
|
||||
import { learningScan, learningState, writePause } from "./learning.mjs";
|
||||
import { followCounts, learningScan, learningState, writePause } from "./learning.mjs";
|
||||
import { linkToOpen, openFile, openLink } from "./open-link.mjs";
|
||||
import {
|
||||
NotepadError,
|
||||
@@ -743,7 +743,9 @@ function readLessonFiles(worktree) {
|
||||
}
|
||||
|
||||
function learningLessons(req, res, ctx) {
|
||||
return json(res, 200, { files: readLessonFiles(ctx.worktree() || ctx.project) }, { "cache-control": "no-store" });
|
||||
const project = ctx.worktree() || ctx.project;
|
||||
// follows: how often each saved lesson was followed, read from this machine's store.
|
||||
return json(res, 200, { files: readLessonFiles(project), follows: followCounts(project) }, { "cache-control": "no-store" });
|
||||
}
|
||||
|
||||
// What an unknown git host is, for the git board's pull-request link. Saved
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Plan2Code",
|
||||
"version": "3.1.3",
|
||||
"version": "3.1.5",
|
||||
"description": "A structured workflow of six steps (Pathfinder, Plan, Document, Implement, Review, Finalize) for AI-assisted software development",
|
||||
"keywords": [
|
||||
"ai",
|
||||
@@ -17,6 +17,6 @@
|
||||
"url": "https://github.com/jparkerweb/plan2code"
|
||||
},
|
||||
"homepage": "https://github.com/jparkerweb/plan2code",
|
||||
"releaseDate": "2026-11-18",
|
||||
"releaseDate": "2026-11-23",
|
||||
"mode": "utility"
|
||||
}
|
||||
Reference in new issue
Block a user