mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-04 00:15:41 -08:00
Sync upstream v3.2.4: slim install refs, a crash-safe installer, Change project restarts the agent (v3.2.4)
AI Assisted
This commit is contained in:
1 parent
50319aa332
commit
f997a82c4d
45 files changed
+7851
-306
No files matched your search
@@ -57,3 +57,4 @@ One row per file of every game but Ghoul Rush (which has its own files: [core](.
|
||||
- **The window owns pausing.** A game never resumes itself; `screens/activities.js` decides when a key or click plays on, including the hold on a question or finish (see the row above), so a game needs nothing of its own for it. Full screen is the window's too (`setFull()`: the button, `F`, and a turn or finish putting it back; `fitFull()` sizes the game to the whole screen (black bars where its shape leaves room) and docks the overlaid panel in a bar that holds it, `data-dock="side"` or `"below"`, or floats it, `"float"`, shrunk to the score while a round plays and the pointer is still; and tells the desktop app `activities-full`); a game only sees a bigger `resize()`, so a new game needs nothing for it, as long as its `resize()` sets the canvas's CSS size.
|
||||
- **Every moment has a sound, and moving things hum.** A game plays a one-shot through the `tone` it is handed for each event worth hearing (a hit, a pickup, a level, a new best, game over) and keeps continuous things (an engine, a motor, wind, water, a fuse, a monster close by) going with `hum(id, name, level, pitch)` from its `tick`, pitch following speed. Never a one-shot every frame: a repeating cue is throttled by a timer in the round. Its own sounds live in `activities/<id>-sfx.js`, named with the game id; the shared kit is in `tones.js`. `create()` defaults `tone` and `hum` to no-ops, since the suites make games with neither, and a sound never changes the game's state.
|
||||
- **Its logic tests pin the dice.** A game rolls `Math.random` for roads, spawns and layouts, and an unlucky roll once failed a test on CI at random (Ghoul Rush's Eye, Bounce Road twice). Import `./seed-random.mjs` FIRST in every `scripts/test-web-console-activities*.mjs` file: it seeds `Math.random` (set `PLAN2CODE_TEST_SEED` to try another roll), so a test sees the same world on every run.
|
||||
- **Its tests run only on request.** Game test files (`scripts/test-web-console-activities*.mjs`, and `test-web-console-page-activities.mjs` for the Activities window) are listed in `npm run test:games`, never in `npm test`: the games are an add-on and the owner runs them by hand when a game changes. A new game test file goes in `test:games` (and in `test-lanes.json`'s `skipFast`); `test-skill-scripts.mjs` fails if it lands in `npm test`.
|
||||
@@ -44,7 +44,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web
|
||||
| `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/`) |
|
||||
| `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 `^{}`, `install-v*` and pre-release tags skipped), `parseLsRemoteSnapshot()`, `installRefForRelease()` and `chooseReleaseRef()` (the launcher's and the installer's logical release ref and the `install-vX.Y.Z` fetch ref npx gets, from one snapshot), `checkForUpdate({ installed, cacheFile, now, run })` (never throws) and `runLsRemote()` (`git ls-remote --tags --heads` on the repo: no shell, `GIT_TERMINAL_PROMPT=0`, `GCM_INTERACTIVE=never`, SSH `BatchMode` when `GIT_SSH_COMMAND` is unset, `windowsHide`, killed at 10 s; git authenticates itself, the console never touches a credential). The answer, failures included, is cached for an hour in `~/.plan2code/console/update-check.json` (`UPDATE_CHECK_FILE`, in `PROTECTED_CONSOLE_FILES` so no sweep removes it). `server.mjs` starts it after the ready line and never awaits it; `stateFrame()` carries `update: { installed, latest }` only when a newer release exists (its `latest` is part of `haveKey()`, so a page that connected first still gets it), and `GET /version` returns `{ version, latest }`. Tests seed a fresh cached failure in every console home, so no test server reaches the network. The `plan2code` launcher reads the same cache for its terminal release notice (a copy of this module sits in `~/.plan2code/bin/`) |
|
||||
| `console.md` | the core of the agent-facing contract, read once per conversation (every skill ships the same copy, so a dashboard hop never re-reads it): starting, the turn (`post --wait`, the exit codes, handling a send, `settle`), posting, the payload and its kinds, documents (including `file` blocks), the house rules, and an index of the topic files below with the moment each is read. A test caps it at 24,000 characters |
|
||||
| `console-finish.md` · `console-stop.md` · `console-chat.md` · `console-workspace.md` · `console-subagents.md` · `console-launches.md` · `console-meter.md` · `console-attachments.md` · `console-trouble.md` · `console-interface.md` | topic files, each read only when its moment first comes: finishing (the finish and its buttons), stop requests (the way home mid-workflow, `stopWarning`, resuming a pause), Quick questions, the Workspace, standing instructions and helper reports, dashboard launches and the menu payload, the session meter's `run` events (read only when a `run` is refused: the notes inline every `run`), keeping a cited note attachment, recovery, and the interface pick (when to ask, switching mid-session) |
|
||||
| `notes/<workflow>.md` | per-workflow notes (`init` for both inits, `pathfinder` with Briefs, `plan`, `revise-plan`, `document`, `implement` for both builds, `loop` for a build the desktop app's Implementation Loop runs with `--loop` (where it reports a `loopOutcome` instead of asking for sign-off), `quick-task`, `review`, `finalize`, `handoff`, `changelog`, `git`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`, `ui-prototype`). Each skill's Interface line reads `<D>/console.md` and its own notes file right after `open`; a test checks every skill names one that exists |
|
||||
|
||||
@@ -62,6 +62,8 @@ plan2code/
|
||||
│ └── public/ # Page assets served to the browser
|
||||
├── scripts/ # Development scripts
|
||||
│ ├── bench-web-console.mjs # Start-path timing
|
||||
│ ├── bench-install-update.mjs # Isolated install/update benchmark, with optional local `--repo-url`
|
||||
│ ├── publish-install-refs.mjs, install-ref-fixtures.mjs, install-e2e-fixture.mjs # Slim install-ref publisher and its local release fixture builders
|
||||
│ ├── capture-screenshots.mjs # Stages web console screens and saves the docs screenshots (needs a local Chrome or Edge, through `playwright-core`)
|
||||
│ ├── browser.mjs # The one place a browser is launched (Chrome, then Edge, through `playwright-core`; `PLAN2CODE_TEST_BROWSER` forces one); page tests, the screenshots and the bench use it
|
||||
│ ├── css-snapshot.mjs # Dev-only: every element's computed style on every screen, both themes; take one before a stylesheet move and `--compare` after
|
||||
@@ -90,7 +92,8 @@ plan2code/
|
||||
├── docs/ # Landing page `index.html` served at plan2code.jparkerweb.com (GitHub Pages, `CNAME`) and assets
|
||||
│ └── screenshots/ # Web console screenshots, <shot>-light.webp and <shot>-dark.webp (generated)
|
||||
├── specs/ # Feature specs (if any in-progress)
|
||||
├── install.js # Interactive installer (Node.js)
|
||||
├── install.js # Interactive installer entry point (Node.js)
|
||||
├── src/installer/ # Shared install/update modules: timing, canonical skills, console staging, skills CLI resolution
|
||||
├── package.json # Root package (husky only, private: true)
|
||||
├── version.json # Version metadata
|
||||
├── CHANGELOG.md, QUICK-REFERENCE.md, LICENSE
|
||||
@@ -103,7 +106,8 @@ plan2code/
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `install.js` | Interactive installer — builds `skills/` from `src/`, then delegates installation to the skills CLI |
|
||||
| `install.js` | Interactive installer/update entry point — builds `skills/` from `src/`, coordinates the shared modules below and delegates link refresh to the pinned `skills` CLI |
|
||||
| `src/installer/` | Shared zero-dependency installer seams: timing JSONL, canonical skill staging/manifests/rollback, shared console staging/commit, exact `skills` CLI resolution and npx-cache reuse |
|
||||
| `src/plan2code-*.md` | Source workflow prompts (the "source of truth") |
|
||||
| `skills/` | Generated Agent Skills, gitignored build output regenerated by the installer (and `npm run build:skills`) before every `skills add` |
|
||||
| `scripts/validate-char-count.js` | Pre-commit validator ensuring all source prompts ≤ 20,000 chars |
|
||||
@@ -130,11 +134,13 @@ plan2code/
|
||||
|
||||
### Release channel
|
||||
|
||||
Install and update follow release tags, never `main`. `release-app.yml`'s `publish` job ends by fast-forwarding the `release` branch to the tag it just published (no force: a tag not ahead of the branch fails the job), and the README's first install is `npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git#release`. `plan2code update` installs the newest `vX.Y.Z` tag (`newestReleaseTag()` in `src/launcher/plan2code.js`, using `latestTag()` and `runLsRemote()` from the copy of `update-check.mjs` beside it); `--main` installs the tip of `main`, `--tag <ref>` any ref (how to go back to a release); `--main` and a `--tag` naming a branch always pass `--force`, since unreleased work keeps the last release's version and the installer's `Already on` check would install nothing. `plan2code uninstall` runs the newest release's installer the same way, falling back to `main` only when no release tag can be found. Launchers older than the channel (and install commands copied without `#release`) still fetch `main`, so `install.js` redirects itself (`redirectToRelease()`): when npx fetched it from a commit no `vX.Y.Z` tag points at (`fetchedCommit()` reads npm's hidden `node_modules/.package-lock.json`; `releaseRedirectRef()` decides), it reruns the same options from `#v<newest>`. The launcher sets `PLAN2CODE_INSTALL_REF` on every installer run (`main` for `--main`) so a deliberate ref is never redirected, a checkout is not under `node_modules` so it never is either, and anything unknown (no lock file, no network) runs in place. The redirect lives on `main` for old launchers to find, so it must stay there. The console's release check (`update-check.mjs`) and the app's notice (`versions.rs` `latest_tag()`) use the same rule: the highest plain `vX.Y.Z` in `git ls-remote --tags`, peeled and pre-release tags skipped. The app's Update skills still pins to the app's own tag.
|
||||
Install and update follow release refs, never unreleased `main` by accident. `release-app.yml`'s `publish` job ends with `scripts/publish-install-refs.mjs`: one synthetic slim runtime commit is pushed as immutable `refs/tags/install-vX.Y.Z` and as the fast-forward tip of `refs/heads/release` (no force). It refuses to move `release` to a version that is not newer than the one it installs (`--allow-older` for a deliberate rollback), exits 0 with nothing pushed when the release is already fully published (a second trigger), and refuses a `package.json` with a script npm runs when preparing a git package (`prepare`, `build`, `install`, `preinstall`, `postinstall`, `prepack`), which would make every user's npx do a full dev install. The README's first install is `npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git#release`, so it fetches the slim payload rather than the full source tree; a payload carries `.plan2code-install-ref.json` beside `install.js`, so `redirectToRelease()` skips its `git ls-remote` for it.
|
||||
|
||||
### Agents file
|
||||
Canonical skills (`src/installer/canonical-skills.js`, called by `installCanonicalSkills()`): the store is staged, checked and swapped in with a journal; retired skills go only after the swap worked; a skill folder Windows will not let go of is written over in place (its old files copied aside for a rollback); a failed roll back names the skills left missing; stages and backups another live install owns are left alone; `.DS_Store`, `Thumbs.db` and `desktop.ini` never count as a change. Links come from one `skills add`: the current `skills` pin takes the store itself as the source, but the legacy `1.5.x` pin (Node below 22.20.0) is given the built `skills/` folder (`agentLinkSource()`), because 1.5.x skips every agent when the source is the canonical store. With no cached pin, `skillsCliReachable()` checks the CLI runs before anything is replaced; a cached copy missing a dependency is retried once through npx. After a successful install from an npx copy, `removeNpxLeftovers()` drops the built `skills/` and day-old Plan2Code `_npx/<hash>` folders. Uninstall also removes the store's manifest, journal and stage or backup folders, and the console's `<version>.install-*` / `.backup-*` leftovers.
|
||||
|
||||
`~/.plan2code/agents.json` holds the person's custom agent CLIs. The web console is its only writer (User Preferences → Agents & models, through `POST /agents`); the `plan2code` launcher and the desktop app only read it. Each reader carries its own copy of the rules (`src/web-console/agents.mjs` for the console, a copy in `src/launcher/plan2code.js`, `agents.rs` in the app), and `scripts/fixtures/agents-cases.json` is the contract all three readers' tests load: file normalization with its warnings, `buildArgs` command lines and `makeId` ids. Change a rule in the fixture first.
|
||||
`plan2code update` resolves one promptless `git ls-remote --tags --heads` snapshot through `src/web-console/update-check.mjs`: a default update always takes the newest plain `vX.Y.Z` (the release the banner and the app report), fetched as its `install-vX.Y.Z` when that tag exists, exact `--tag vX.Y.Z` uses the matching install tag when present, and a release without one falls back to the plain heavyweight tag. `--main` installs the tip of `main`, a branch `--tag` stays on that branch, and both force-reinstall because unreleased work can carry the last release's version. `PLAN2CODE_INSTALL_REF` is the intentional fetch ref; `PLAN2CODE_RELEASE_REF` is the logical release when they differ. `plan2code uninstall` runs the newest release's installer the same way, falling back to `main` only when no release can be found.
|
||||
|
||||
Launchers older than the release channel can still fetch `main`, so `install.js` keeps `redirectToRelease()`: `fetchedCommit()` reads npm's hidden lock file, `releaseRedirectRef()` leaves release tags, install tags, peeled commits, `release`, intentional launcher refs and non-main branches where they are, and only unreleased/unknown main-tip work is rerun at the newest release (its install tag when advertised). The redirect lives on `main` for old launchers to find, so it must stay there. The console's release check and the app's notice still mean the highest plain logical `vX.Y.Z`, never an `install-v*` ref. The app's Update skills still pins to the app's own tag.
|
||||
|
||||
`src/launcher/agents.json` is the shipped list: `kind: "builtin"` entries (Claude Code, Devin, Codex) with `installUrl`, per-OS `install` lines and `installDirs`, and `kind: "template"` entries other CLIs can be saved from. Each entry may carry `helpers` beside `bypassArgs`: the agent can start a subagent from inside a session (`true` for Claude Code, `false` for every other built-in and template); missing means it cannot. `loadAgentList()` and the app's `AgentEntry` both read it as a boolean, so a custom agent without it reads `false`. `install.js` copies it to `~/.plan2code/bin/agents.json` beside `agent-lookup.mjs`, which all JS readers share: `loadAgentList()` reads it, `findAgent()` gives a command its `found` / `outside` / `missing` state (PATH, the saved Windows PATH, npm's global bin, the entry's `installDirs`). The app reads the same JSON with `serde_json` at run time (`include_str!` of the repo file baked in as fallback) and `find_on_path` in `agents.rs` is its Rust twin: `scripts/fixtures/agent-lookup-cases.json`, loaded by `scripts/test-agent-lookup.mjs` and by `cargo test` through `include_str!`, is the contract both lookups are held to.
|
||||
|
||||
@@ -195,7 +201,7 @@ Reference files are NOT subject to the 20,000 character limit. The review workfl
|
||||
|
||||
## Shared Console
|
||||
|
||||
The web console is built once into `skills/_console/<version>/` and installed by `installSharedConsole()` in `install.js` to `<console home>/<version>/` (`~/.plan2code/console`, or `PLAN2CODE_CONSOLE_HOME`, which tests set). Each skill carries only `src/web-console-stub/console.mjs`, with the version baked in at build. The stub tries `<home>/<version>/` first, then the `console-dir` pointer, and needs a matching `version.txt`; with neither it prints one line and exits 5. Only an installed console's `open` writes `console-dir` (a source checkout's does not, or every stub would point at the checkout). `install()` and `installProjectSkills()` call `installSharedConsole({ sweep: false })` before `skills add` and `sweepOldConsoles()` only after it succeeds, so a failed update leaves the old stubs able to find their old console. A test that runs a built skill's `console.mjs` must point `PLAN2CODE_CONSOLE_HOME` at a folder whose `console-dir` names `skills/_console/<version>/`, and a shared console finds skill files in `~/.agents/skills/`.
|
||||
The web console is built once into `skills/_console/<version>/` and installed by `installSharedConsole()` in `install.js` to `<console home>/<version>/` (`~/.plan2code/console`, or `PLAN2CODE_CONSOLE_HOME`, which tests set). Each skill carries only `src/web-console-stub/console.mjs`, with the version baked in at build. The stub tries `<home>/<version>/` first, then the `console-dir` pointer, and needs a matching `version.txt`; with neither it prints one line and exits 5. Only an installed console's `open` writes `console-dir` (a source checkout's does not, or every stub would point at the checkout). `installSharedConsole()` stages and commits through `src/installer/console-stage.js` (a validated `<version>.install-*` copy with a manifest and a `.complete` marker written last, renamed in with a `<version>.backup-*`, copied in place when a lock refuses the rename). `install()` stages and commits the console itself before canonical skill replacement, and `installProjectSkills()` calls `installSharedConsole({ sweep: false })` before `skills add`; both run `sweepOldConsoles()` (old version folders and other versions' leftover stages and backups) only after it succeeds, so a failed update leaves the old stubs able to find their old console. A test that runs a built skill's `console.mjs` must point `PLAN2CODE_CONSOLE_HOME` at a folder whose `console-dir` names `skills/_console/<version>/`, and a shared console finds skill files in `~/.agents/skills/`.
|
||||
|
||||
## Repo-Local Skills (`.claude/skills/`)
|
||||
|
||||
|
||||
@@ -29,9 +29,14 @@ npm run test:fast
|
||||
|
||||
# Full check (takes minutes; every page suite drives a browser): list check, char limits,
|
||||
# skills/ build, browser-module parse check, dashboard skill-table check, web console +
|
||||
# launcher + getting-started node:test suites
|
||||
# launcher + getting-started node:test suites. Never the Activities game tests: they are an
|
||||
# add-on, run only on request with npm run test:games
|
||||
npm test
|
||||
|
||||
# The Activities game tests (every scripts/test-web-console-activities*.mjs and
|
||||
# test-web-console-page-activities.mjs), on request only: npm test never runs them
|
||||
npm run test:games
|
||||
|
||||
# Put every text file git sees back to LF (also runs by itself as pretest and in
|
||||
# the pre-commit hook); --check only lists
|
||||
npm run fix:eol
|
||||
@@ -43,6 +48,10 @@ node --test --test-name-pattern "<regex>" scripts/test-web-console-<area>.mjs
|
||||
# playwright-core, which `npm install` already provides)
|
||||
node scripts/bench-web-console.mjs [--runs 7] [--workflow dashboard]
|
||||
|
||||
# Install/update benchmark (isolated HOME/npm cache; GitHub by default, or a local
|
||||
# bare repo with --repo-url for offline evidence)
|
||||
node scripts/bench-install-update.mjs --baseline <ref> --candidate <ref> --mode cold-npx --runs 3 --json <report>
|
||||
|
||||
# Refresh the web console screenshots in docs/screenshots/ (needs a local Chrome or Edge).
|
||||
# Rerun after any change a person would see on the console page, and open every image
|
||||
# before committing: right screen, both themes, no username or home path in frame.
|
||||
@@ -94,7 +103,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 |
|
||||
| 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. `npm run test:games` runs every game test; `npm test` runs none |
|
||||
| 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`, the Review Loop's `test-web-console-review-loop.mjs` with `test-web-console-page-review-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/` |
|
||||
@@ -107,6 +116,8 @@ The same areas as one-command rows live in the [Test map](./AGENTS-test-map.md),
|
||||
| A new skill or console workflow | First update the hand-written tables that list every workflow: the `SUBAGENT_WORKFLOWS` count and the meter's `WEIGHTS`, `LAUNCH_LABELS` and `RUN_LABELS` in `test-web-console-logic.mjs`, `notesFor` in `test-web-console-speed.mjs`, the event list in `src/web-console/console-meter.md` (checked by `test-web-console-chat-stress.mjs`) and a `BUDGETS.notes` entry in `test-console-wire-budgets.mjs`. Then run those four suites plus `test-web-console-skills.mjs` and `test-web-console-spec-states.mjs`; the PR Prep and Test build missed all five tables and only the full suite caught them |
|
||||
| Docs or comments only | `node --test scripts/test-us-english.mjs scripts/test-line-endings.mjs` |
|
||||
|
||||
**Games are never part of the full run.** The Activities games are an add-on, so `npm test` leaves out every game test file (`test-web-console-activities*.mjs` and `test-web-console-page-activities.mjs`, about a third of all tests and most of them browser page tests); they live in `npm run test:games`, run by hand when a game changes. `test-skill-scripts.mjs` checks that every `scripts/test-*.mjs` is named once across the two scripts and that no game test is in `npm test`, so a new game test file goes in `test:games` and a new other test file in `test`.
|
||||
|
||||
Run the full `npm test` when the change touches something many suites lean on: `web-console-test-helpers.mjs` or `page-test-helpers.mjs`, `looks.js` / `prefs.js` / `static.mjs` (the `SERVABLE` list), `skills.js`, `install.js`, the server's shared modules (`console.mjs`, `routes.mjs`); after a sync merge or a version bump; before opening a PR or cutting a release; and whenever you cannot say which suites a change reaches.
|
||||
|
||||
The root `npm test` does not run the metrics or bot vitest suites; run them in their package. `npm run dev` in metrics and bot is `tsup --watch`. The web console and launcher suites isolate themselves with `PLAN2CODE_CONSOLE_HOME`, `PLAN2CODE_MODELS_DIR` and `PLAN2CODE_NO_BROWSER=1` (`scripts/web-console-test-helpers.mjs`), so they never open a browser or touch your real console home. The web console suites are split by area so `node --test` runs them in parallel. `npm test` runs them through `scripts/node-test.mjs`, which caps the files run at once at one per spare core (8 at most): each page test file drives a browser, and more at once than the cores can carry fails page tests at random (a flat 8 did on 3 and 4 core CI runners). Page tests (`test-web-console-page-*.mjs`) read styles and set scrolls only through `styleOf()`, `stylesOf()` and `scrollCard()` from `page-test-helpers.mjs`, which retry until the element is still on the page; `test-web-console-shape.mjs` fails a raw `locator.evaluate` that does either.
|
||||
@@ -154,18 +165,18 @@ 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`, 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) |
|
||||
| `--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 release the launcher resolves from one `git ls-remote` snapshot: immutable slim `install-vX.Y.Z` when advertised, plain `vX.Y.Z` as the compatibility fallback (`--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
|
||||
|
||||
1. **Builds `skills/` from `src/`** — one Agent Skill per source prompt, including uncommitted source edits.
|
||||
2. **Checks the skills CLI is reachable** with `npx --yes skills@1.7.6 --version` (the version is pinned: `SKILLS_CLI_VERSION` in `install.js`).
|
||||
3. **Sweeps pre-2.2 install paths** and removes installed `plan2code-*` skills so renamed or retired prompts cannot survive as orphans.
|
||||
4. **Delegates installation** to `npx --yes skills@1.7.6 add "<repo>/skills" -g -s <skill names> -y`.
|
||||
5. **Installs the global `plan2code` command** (only when step 4 succeeded). Advanced → `L` runs the same flow without `-g` and without the launcher.
|
||||
1. **Builds `skills/` from `src/`** — one Agent Skill per source prompt (`buildSkills()`), so uncommitted `src/` edits are picked up; verbatim files are copied from their source with `copyFileSync` (much faster than writing bytes on Windows), generated ones written
|
||||
2. **Resolves the pinned `skills` CLI** (`src/installer/skills-cli.js`): exact `skills@1.5.18` below Node 22.20.0, exact `skills@1.7.6` at or above it; an exact cached npx copy is run directly, otherwise npx fetches that pin
|
||||
3. **Stages and commits the shared console** (`src/installer/console-stage.js`) as one checksummed versioned folder under the console home, with `.complete` written last
|
||||
4. **Sweeps pre-2.2 install paths** (`cleanLegacyPaths()`), files the `skills` CLI knows nothing about
|
||||
5. **Stages every skill once into the canonical store** (`src/installer/canonical-skills.js`) with a manifest, journal and rollback, commits the store, removes retired skills, then runs one canonical-source `skills add` to refresh agent links
|
||||
|
||||
The skills CLI owns distribution from step 4 onward. It stores canonical skills under `~/.agents/skills/` and links them into agents that maintain their own skill directory. Plan2Code no longer maintains platform-specific output formats.
|
||||
The canonical store is `~/.agents/skills/<skill-name>/` for a global install. Copying there happens once per skill; the `skills` CLI is used for link/unlink semantics, not as a repeated copy mechanism. There are no longer any platform-specific file formats in this repo.
|
||||
|
||||
**Invocation choices:**
|
||||
|
||||
@@ -175,6 +186,17 @@ The skills CLI owns distribution from step 4 onward. It stores canonical skills
|
||||
| No `-a` / `--agent '*'` | Uses the CLI's supported default agent set instead of requesting incompatible scope/agent combinations. |
|
||||
| Captured output | Suppresses the CLI's duplicated banners while preserving real failures; unsupported-scope noise is filtered. |
|
||||
|
||||
## Installer/benchmark environment variables
|
||||
|
||||
| Variable | Use |
|
||||
|---|---|
|
||||
| `PLAN2CODE_BENCH_JSON` | JSONL timing-event output for installer benchmarks |
|
||||
| `PLAN2CODE_LS_REMOTE_FILE` | test hook replacing the launcher/update-check `git ls-remote` call |
|
||||
| `PLAN2CODE_INSTALL_REF` | the intentional fetch ref stamped by the launcher/redirect and benchmark |
|
||||
| `PLAN2CODE_RELEASE_REF` | the logical `vX.Y.Z` release when the fetch ref is `install-vX.Y.Z` |
|
||||
| `PLAN2CODE_RELEASE_BASE` | test-only release-asset download base |
|
||||
| `HOME`, `USERPROFILE`, `npm_config_prefix`, `npm_config_cache`, `PLAN2CODE_CONSOLE_HOME` | benchmark/test isolation boundaries; never point them at real user state |
|
||||
|
||||
## Skill Format
|
||||
|
||||
| Item | Value |
|
||||
|
||||
@@ -5,9 +5,12 @@ Which checks cover which files, read by PR Prep and Test (`test-map.mjs read` ch
|
||||
|
||||
| Area | Paths | Run | Shared |
|
||||
|---|---|---|---|
|
||||
| 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 |
|
||||
| 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` (every game test: `npm run test:games`, never part of `npm test`) | 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 |
|
||||
| Installer update | `install.js`, `src/installer/**`, `scripts/test-install-update.mjs` | `node --test scripts/test-install-update.mjs` | yes |
|
||||
| Installer refs and end-to-end install | `src/web-console/update-check.mjs`, `src/launcher/plan2code.js`, `scripts/install-ref-fixtures.mjs`, `scripts/install-e2e-fixture.mjs`, `scripts/test-install-refs.mjs`, `scripts/test-install-e2e.mjs` | `node --test scripts/test-install-refs.mjs scripts/test-install-e2e.mjs scripts/test-launcher.mjs` | yes |
|
||||
| Installer benchmark | `scripts/bench-install-update.mjs`, `src/installer/timing.js` | `node --test scripts/test-install-bench.mjs` | yes |
|
||||
| Install-ref publisher | `scripts/publish-install-refs.mjs`, `.github/workflows/release-app.yml` | `node --test scripts/test-publish-install-refs.mjs` | yes |
|
||||
| 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 |
|
||||
|
||||
Reference in new issue
Block a user