mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Compare commits
13
Commits
23ac3a9c19
...
v3.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
184876b437 | ||
|
|
20a349a3f8 | ||
|
|
d84d6a4690 | ||
|
|
9226b82c37 | ||
|
|
76e0c44e0b | ||
|
|
f28d4d592a | ||
|
|
272e514372 | ||
|
|
cedc3300ed | ||
|
|
8bace16e06 | ||
|
|
e87148ad10 | ||
|
|
be31f6af89 | ||
|
|
50acdc8216 | ||
|
|
a19dc6c5df |
No files matched your search
@@ -63,7 +63,7 @@ plan2code/
|
||||
│ ├── node-test.mjs, page-test-helpers.mjs # `npm test`'s `node --test`, files at once capped at one per spare core; the page tests' browser sessions and their redraw-safe `styleOf()`, `stylesOf()`, `scrollCard()`
|
||||
│ ├── test-launcher.mjs, test-getting-started.mjs # Launcher suite; newcomer docs kept in step
|
||||
│ ├── test-skill-scripts.mjs, test-script-<skill>.mjs, test-git-repo.mjs, skill-script-helpers.mjs, fixture-helpers.mjs # Skill script suites and fixtures
|
||||
│ ├── check-versions.mjs, fix-line-endings.mjs, play.mjs # Six-file version sync; restores LF everywhere (also pretest + pre-commit); tries the games from src/
|
||||
│ ├── check-versions.mjs, fix-line-endings.mjs, play.mjs # Version sync across every file that carries it (twelve places, also run by npm test); restores LF everywhere (also pretest + pre-commit); tries the games from src/
|
||||
│ ├── measure-console-wire.mjs, css-helpers.mjs, ghoul-test-helpers.mjs, fixtures/, console-wire-runs/ # Wire-size probe and its captured runs; shared CSS and Ghoul Rush test helpers; skill-script fixtures
|
||||
│ └── validate-char-count.js # Pre-commit character count validator
|
||||
├── skills/ # Generated, gitignored build output — one Agent Skill per src/ prompt
|
||||
@@ -546,7 +546,8 @@ Key design points:
|
||||
- **The CLI hands the agent its terminal line.** `open`, `post` and `wait` (exits `0` and `10`) print `terminalLine: "→ Look at the web console: <url>"` (`terminalLine()` in `sessions.mjs`), and `console.md` asks the agent to end every terminal message with the latest one verbatim, so the tool builds the line rather than the model. In `wait` it is added to the printed result only; the collected `result.json` on disk never carries it. `open` also prints `swept: { sessions, scratch, handoffs }` when it found anything to clean.
|
||||
- **State fields written by `open`, not the agent.** Every `open` (fresh or resume) records `state.worktree` and `state.branch` from `repoRoots()` — the branch is read off `<gitdir>/HEAD` on the walk that already finds the gitdir (`""` on a detached HEAD or outside git; env-relocated repos ask git, as before) — and the page shows them in the footer as the workspace label (`footerLabel()`: `folder · branch`, or `folder + N folders · branch` once folders are added, stepping down through narrower tiers); a click opens the Workspace dialog. `state.wake = true` is set only by a fresh `open --workflow dashboard` and deleted by every resume (server restart, launch, Back to the dashboard); the page also keeps a per-sid `sessionStorage` guard so a reload never replays it.
|
||||
- **`looks.width` is a person-level preference** alongside theme, accent and sounds in `looks.json`. `CARD_WIDTHS` in `public/palette.js` (`narrow` 720, `comfortable` 880 — default — `wide` 1080) is read by the page (`cardWidth()` validates a saved value) and by `routes.mjs`, which paints `data-width` on first load; `styles/tokens.css` maps `data-width` onto the single `--card-width` variable that every column rule uses.
|
||||
- **`GET /overview` is the one route that reads a project file.** It serves `<spec>/overview.md` as `text/markdown` with `cache-control: no-store` (so the Overview tab is always fresh), or with `?file=map` / `?file=draft` the spec's `pathfinder/map.md` / live `PLAN-DRAFT-*.md` (the dashboard's Map and Plan draft tabs, shown only while the spec has no overview; `readSpecFile()` picks the file and names it in `x-spec-file`), or an empty `204` when there is no such file (normal for most specs, and no failed request in the browser console). A dashboard session honors `?spec=` only when it equals a `dir` in `state.scan.specs`; every other workflow uses `state.specDir` and ignores the query. The root is `state.worktree` (fallback `state.project`), and `readSpecFile()` (which `readOverview()` wraps) resolves and `realpath`s the file and refuses anything outside the root's realpath, so `../`, absolute paths and outward symlinks all get the same 204, as do an unscanned `?spec=` and an unknown `?file=`.
|
||||
- **`GET /agents-doc` is the other route that reads a project file** (the dashboard's AGENTS.md tab, right after Dashboard, shown while the project has an `AGENTS.md`). A dashboard session only; it serves `AGENTS.md` or one markdown file directly under `.agents-docs/` (`?file=`, default `AGENTS.md`; `readAgentsDoc()` in `sessions.mjs` allows exactly those two shapes and `realpath`s the file inside the root), as `text/markdown` with `no-store`, or a `204` for anything else. The page links `.agents-docs/` files in place through `md()`'s `link` option (`renderAgentsDoc()` in `screens/docs.js`).
|
||||
- **`GET /overview` reads a project file too.** It serves `<spec>/overview.md` as `text/markdown` with `cache-control: no-store` (so the Overview tab is always fresh), or with `?file=map` / `?file=draft` the spec's `pathfinder/map.md` / live `PLAN-DRAFT-*.md` (the dashboard's Map and Plan draft tabs, shown only while the spec has no overview; `readSpecFile()` picks the file and names it in `x-spec-file`), or an empty `204` when there is no such file (normal for most specs, and no failed request in the browser console). A dashboard session honors `?spec=` only when it equals a `dir` in `state.scan.specs`; every other workflow uses `state.specDir` and ignores the query. The root is `state.worktree` (fallback `state.project`), and `readSpecFile()` (which `readOverview()` wraps) resolves and `realpath`s the file and refuses anything outside the root's realpath, so `../`, absolute paths and outward symlinks all get the same 204, as do an unscanned `?spec=` and an unknown `?file=`.
|
||||
- **Month-old sessions are deleted whole.** `open` lists `staleSessions()` (directories matching the session-id pattern whose `state.json` mtime is older than 30 days, never the sid being opened — no exceptions for paused sessions or unread sends) and `staleScratch()` (top-level regular `.json` / `.mjs` files in the console folder older than 30 days, never `looks.json` or `console-dir` — `PROTECTED_CONSOLE_FILES` — never a directory or symlink) before it prints, and removes them after; `removeSessions()` / `removeScratch()` re-check every name against the session-id pattern / the scratch-name rule before deleting — not the age, the skipped sid or the file type, which the `stale*` listing already decided, so never hand them names that did not come from it. `console.md` tells agents to write temporary payload files into the session's own folder so they go with it.
|
||||
- **User Preferences → System → Cleanup deletes on demand, from a list the server makes.** `POST /cleanup` (origin-checked) with `{ scan: true }` returns `cleanupFindings()`: `{ items: [{ id, where, name, kind, bytes, folder? }], bytes }` (`folder` on `notepad:` items only), ids `session:<sid>` (the `staleSessions()` rule, and every file in the folder that old too, never the serving sid), `console:<name>` (anything at the top of the console home but `PROTECTED_CONSOLE_FILES`, `sessions` and `runtime`, directories too) and `root:<name>` (anything at the top of `~/.plan2code` but `KEPT_PLAN2CODE_ENTRIES`: `console`, `bin`, `launcher.json`, `install.json`, `models.json`, `handoffs`, `notepads`, `app`, `app.json`, `agents.json`), `notepad:<key>` (a month-old notepad, whole; see Notebook below) and `completed:<name>` (each folder or link directly under the session worktree's `specs--completed/` whose newest mtime is older than the session age, 30 days; loose files there stay; the server passes `project: sessionWorktree() || PROJECT`, and without a `project` the archive is never scanned). Both stray kinds must be untouched for `STRAY_GRACE_MS` (an hour, by the newest `lstat` mtime anywhere inside, since rewriting a file never moves its folder's mtime; unreadable reads as fresh): the same folders hold `workspaces.json.lock` and `writeJsonAtomic()`'s `<file>.<pid>.tmp`, which live for milliseconds. `root:` is only scanned when the console home is `<PLAN2CODE_MODELS_DIR or ~/.plan2code>/console`, so a test or dev home never reaches the real folder. Paths never go to the page. `{ delete: [id] }` runs `removeCleanup()`, which re-scans and removes only ids still on the fresh list (symlinks unlinked, never followed), returning `{ removed, bytes, failed }`. The page always shows the list before **Delete these**.
|
||||
- **The console's path is stated, not searched for.** Each Interface line names `references/web-console/` beside the SKILL.md and the `~/.plan2code/console/console-dir` fallback; the prompts with room (all but pathfinder, plan, document and finalize, which sit near the char limit) also name the canonical global install path `~/.agents/skills/<skill>/references/web-console/` (the skills CLI's real store; every agent dir links into it), and every `console.mjs open` writes `HERE` to `~/.plan2code/console/console-dir` (only `open`, so a `help` or dev run from `src/` never repoints it) so a later session can read the path from a fixed place. Without these the agent hunts the skill install dirs on every session.
|
||||
@@ -605,6 +606,7 @@ Tests: `npm test` runs, in order, `validate-char-count.js`, `install.js --build-
|
||||
- **Banners never get in the way.** A banner over the board (`"Hit!"`, a new level, a power-up) is placed on the frame it first shows, on the part of the board away from the player, and fades to `BANNER_SEE_THROUGH` (0.12) over `BANNER_FADE_MS` while the player, or anything the player must react to (a diving bug, a bomb, a rival, a hazard, the road over a hill), is in its strip; Snake's `bannerRow()` and `underBanner()` are the model. Give the banner object a `see` field, multiply the draw's alpha by it, and export the strip check (`underBanner`) for the unit suite.
|
||||
- **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.
|
||||
|
||||
## Status Line
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
## Gotchas / Pitfalls
|
||||
|
||||
- **Version sync:** When adding a new version to `CHANGELOG.md`, also update `version.json` and `package.json` (root) to match. `README.md` (the `Version X.Y.Z` line near the top) also carries the version, and `version.json`'s `releaseDate` moves with it. `version.json` is copied into every skill's `references/web-console/` (the console's Help shows it), so after a bump run `npm run build:skills` or `npm test` (`--verify-skills`) fails. The installer displays the version from `version.json` in its header. All three files (`CHANGELOG.md`, `version.json`, `package.json`) must always show the same version number. The desktop app carries it too (`plan2code-app/src-tauri/tauri.conf.json`, `plan2code-app/package.json`, `plan2code-app/src-tauri/Cargo.toml`, and `Cargo.lock`'s `plan2code-app` entry follows the build): `node scripts/check-versions.mjs [--tag vX.Y.Z]` compares all six, and the release workflow runs it before building. It reports a mismatch today because the app is at 3.0.0 while the rest is still 2.x; it is deliberately not part of `npm test`, so bump the app's files with the release that ships v3.0.0.
|
||||
- **Version sync:** When adding a new version to `CHANGELOG.md`, also update `version.json` and `package.json` (root) to match. `README.md` (the `Version X.Y.Z` line near the top) also carries the version, and `version.json`'s `releaseDate` moves with it. `version.json` is copied into every skill's `references/web-console/` (the console's Help shows it), so after a bump run `npm run build:skills` or `npm test` (`--verify-skills`) fails. The installer displays the version from `version.json` in its header. All three files (`CHANGELOG.md`, `version.json`, `package.json`) must always show the same version number. The desktop app carries it too (under `plan2code-app/`: `package.json`, `package-lock.json` with two lines, `src-tauri/tauri.conf.json`, `src-tauri/Cargo.toml`, `fake-agent/Cargo.toml`, and `Cargo.lock`'s `plan2code-app` and `fake-agent` entries): `node scripts/check-versions.mjs [--tag vX.Y.Z]` compares those, `version.json`, `package.json`, `CHANGELOG.md` and README's line (twelve places in all), `npm test` runs it first on this tree, and the release workflow runs it before building.
|
||||
- **CHANGELOG ordering:** Entries in `CHANGELOG.md` must be in reverse-chronological order — newest version at the top, oldest at the bottom. New entries are always inserted immediately after the file header.
|
||||
- **CHANGELOG house format is not Keep a Changelog:** version headings are `## vX.Y.Z` — with a `v` prefix and **no date**. The release date is recorded only in `version.json`'s `releaseDate`. Category headings carry emoji: `### ✨ Added`, `### 🔧 Changed`, `### 🐛 Fixed`, `### 💥 Breaking`, `### 🗑️ Removed`, `### 📚 Documentation`. Older entries contain one-off variants (`🎁 Added`, `📦 Updated`, `📝 Documentation`, `🏎️ Improved`, `🧪 Testing`) — do not introduce new ones. The `.claude/skills/plan2code-changelog/` skill automates version selection and formatting; use it rather than hand-rolling an entry.
|
||||
- **PowerShell mangles the CHANGELOG emoji:** `Get-Content` / `Select-String` render the `###` heading emoji as `?` under the default Windows console encoding, so a heading audit done that way reports garbage. Read `CHANGELOG.md` with a file-read or grep tool instead.
|
||||
|
||||
@@ -5,7 +5,7 @@ description: "Publish a GitHub Release for jparkerweb/plan2code whenever CHANGEL
|
||||
|
||||
# Plan2Code Release Publisher
|
||||
|
||||
Publish a GitHub Release for `jparkerweb/plan2code` whenever `CHANGELOG.md`'s top version is ahead of the latest published release on GitHub. This turns the merged CHANGELOG entry on `main` into an actual GitHub Release (which also creates the `vX.Y.Z` git tag).
|
||||
Publish a GitHub Release for `jparkerweb/plan2code` whenever `CHANGELOG.md`'s top version is ahead of the latest published release on GitHub. This turns the merged CHANGELOG entry on `main` into an actual GitHub Release (the `release-app` workflow builds the app first and creates the release, with its `vX.Y.Z` git tag, last).
|
||||
|
||||
**Repo-local by design.** This skill lives in the repo's `.claude/skills/` and is intentionally NOT wired into `install.js` — it is a maintainer dev tool, not part of the shipped product, so it is never installed to `~/.claude/skills/`. Do **not** copy it there: the uninstaller (`uninstallFiles()` in `install.js`) and every re-install's pre-copy cleanup in `install()` both delete every entry matching `/^plan2code-/` under `~/.claude/skills/`, so a copy placed there would be silently removed.
|
||||
|
||||
@@ -103,57 +103,59 @@ Present all three to the user and wait for an explicit answer before any write.
|
||||
|
||||
If the user supplies a suffix, set `title = "v$CHANGELOG_VERSION " + <suffix>` (single space join) and proceed to publish. The tag and notes are unaffected by the suffix.
|
||||
|
||||
### Step 9 — Publish (on approval)
|
||||
### Step 9 - Publish (on approval)
|
||||
|
||||
On approval, write `$notes` to a temp file — never pass multiline text inline via `--notes`, that regresses into a quoting bug — then create the release targeting `main`. Two requirements for the temp file: `$notes` must already hold **real newlines** (per Step 8) because `printf '%s'` / `WriteAllText` write it byte-for-byte — a literal `\n` in the string lands literally in the release body; and it MUST be **UTF-8** because the notes contain emoji (`🎉`, `🐛`, `✨`, `🔧`).
|
||||
The release is created by the `release-app` workflow, **last**, not by this skill. The workflow builds the app on four systems, attaches every file to a draft release, and only then publishes it, so the `vX.Y.Z` tag (which the app's update check watches) never exists before its binaries do. Creating the release here with `gh release create` would put the tag up first and leave users offered an upgrade with nothing to download. Do not do that.
|
||||
|
||||
On approval, write `$notes` to a temp file, never inline (multiline text on the command line is a quoting bug). `$notes` must already hold **real newlines** (per Step 8) because `printf '%s'` / `WriteAllText` write it byte-for-byte, and the file MUST be **UTF-8** because the notes contain emoji. Then start the workflow on `main`, passing the file as the `notes` input (`-F key=@file` reads the file's contents):
|
||||
|
||||
**bash (preferred in this environment):**
|
||||
|
||||
```bash
|
||||
NOTES_FILE=$(mktemp)
|
||||
printf '%s' "$notes" > "$NOTES_FILE"
|
||||
gh release create "$tag" --repo jparkerweb/plan2code --title "$title" --notes-file "$NOTES_FILE" --target main
|
||||
gh workflow run release-app.yml --repo jparkerweb/plan2code --ref main -f version="$CHANGELOG_VERSION" -f title="$title" -F notes=@"$NOTES_FILE"
|
||||
rm -f "$NOTES_FILE"
|
||||
```
|
||||
|
||||
**PowerShell:** do NOT use `Set-Content` — under Windows PowerShell 5.1 it writes ANSI/UTF-16 by default and mangles the emoji into `??`. Write UTF-8 **without BOM** (a BOM would leak into the release body):
|
||||
**PowerShell:** do NOT use `Set-Content` (under Windows PowerShell 5.1 it writes ANSI/UTF-16 and mangles the emoji into `??`). Write UTF-8 **without BOM**:
|
||||
|
||||
```powershell
|
||||
$NotesFile = [System.IO.Path]::GetTempFileName()
|
||||
[System.IO.File]::WriteAllText($NotesFile, $notes, [System.Text.UTF8Encoding]::new($false))
|
||||
gh release create "$tag" --repo jparkerweb/plan2code --title "$title" --notes-file "$NotesFile" --target main
|
||||
gh workflow run release-app.yml --repo jparkerweb/plan2code --ref main -f version="$CHANGELOG_VERSION" -f title="$title" -F notes=@"$NotesFile"
|
||||
Remove-Item -Path $NotesFile
|
||||
```
|
||||
|
||||
Always delete the temp file afterward, regardless of whether `gh release create` succeeded or failed.
|
||||
Always delete the temp file afterward, whether or not the dispatch succeeded. If `gh workflow run` exits non-zero, show its error verbatim.
|
||||
|
||||
**Failure handling — already-exists classification:** if `gh release create` exits non-zero, inspect the error text.
|
||||
|
||||
- If and only if it contains the substring `already exists` (real output: `HTTP 422: Validation Failed` / `Release.tag_name already exists`), report this to the user as already published, not as a raw CLI error:
|
||||
|
||||
> This version ($CHANGELOG_VERSION) was already published as a release — nothing more to do.
|
||||
|
||||
- Every other failure (auth, network, permissions, etc.) must be surfaced to the user verbatim. Never silently reclassify a genuine failure as "already published."
|
||||
|
||||
### Step 10 — Verify
|
||||
|
||||
Confirm the release now exists and report its URL:
|
||||
Then find the run it started and watch it to the end (the builds take a while; tell the user so):
|
||||
|
||||
```bash
|
||||
gh release view "$tag" --repo jparkerweb/plan2code
|
||||
gh run list --repo jparkerweb/plan2code --workflow release-app.yml --event workflow_dispatch --limit 1 --json databaseId,status,createdAt
|
||||
gh run watch <databaseId> --repo jparkerweb/plan2code --exit-status
|
||||
```
|
||||
|
||||
Report the release URL to the user.
|
||||
If the run list shows a run that started before the dispatch, wait a few seconds and list again. If the run fails, show which job failed and stop: no release or tag exists yet (a failed run leaves at most an unpublished draft, which a re-run reuses). Never publish a release by hand to get around a failed build.
|
||||
|
||||
### Step 10 - Verify
|
||||
|
||||
Confirm the release now exists, is published (not a draft) and carries the files, and report its URL:
|
||||
|
||||
```bash
|
||||
gh release view "$tag" --repo jparkerweb/plan2code --json url,isDraft,assets -q '.url, .isDraft, (.assets | length)'
|
||||
```
|
||||
|
||||
Expect `false` for the draft flag and five assets (four binaries and the SHA256SUMS file). Report the release URL to the user.
|
||||
|
||||
## Rules
|
||||
|
||||
- **Repo-local only** — this skill is not part of the installed product; never add it to `install.js`, and never copy it to `~/.claude/skills/` (the uninstaller deletes `plan2code-*` entries there).
|
||||
- **Read-only on version files** — never modify `CHANGELOG.md`, `version.json`, or `package.json`; this skill only reads and compares them.
|
||||
- **Version-sync gate is hard** (Step 4) — if the three version sources disagree, stop and report; do not publish a release from an inconsistent repo.
|
||||
- **Never run a local `git tag` or `git push`** — tag creation is delegated entirely to `gh release create --target main`.
|
||||
- **Always use `--notes-file`**, never inline multiline `--notes`, and always write the notes file as UTF-8 (no BOM) so emoji survive.
|
||||
- **Repo-local only**: this skill is not part of the installed product; never add it to `install.js`, and never copy it to `~/.claude/skills/` (the uninstaller deletes `plan2code-*` entries there).
|
||||
- **Read-only on version files**: never modify `CHANGELOG.md`, `version.json`, or `package.json`; this skill only reads and compares them.
|
||||
- **Version-sync gate is hard** (Step 4): if the three version sources disagree, stop and report; do not publish a release from an inconsistent repo.
|
||||
- **Never run a local `git tag` or `git push`, and never run `gh release create` yourself**: the `release-app` workflow creates the release and its tag after the builds, so the tag never gets ahead of its binaries.
|
||||
- **Always pass the notes through a UTF-8 (no BOM) temp file**, never inline, so emoji survive.
|
||||
- **Always clean up the temp notes file**, even on a mid-run error.
|
||||
- **Always get explicit approval before any write** (Step 8) — no release is created without a yes (or a yes-with-suffix).
|
||||
- **Derive the current version from the highest published semver tag** (Step 5), never from GitHub's manually-pinnable "Latest" flag. On an empty or failed release list, treat it as "no prior release" (baseline `0.0.0`) — no error-text matching needed.
|
||||
- **On a `gh release create` failure** (Step 9), only reclassify as already-published when the error contains `already exists` — every other failure must be shown verbatim, never swallowed.
|
||||
- **Idempotent and safe to re-run** at any time — re-running after a successful publish hits the Step 7 no-op; re-running after a race-lost publish hits the Step 9 already-exists handling.
|
||||
- **Always get explicit approval before any write** (Step 8): no workflow run is started without a yes (or a yes-with-suffix).
|
||||
- **Derive the current version from the highest published semver tag** (Step 5), never from GitHub's manually-pinnable "Latest" flag. On an empty or failed release list, treat it as "no prior release" (baseline `0.0.0`); no error-text matching needed.
|
||||
- **Idempotent and safe to re-run** at any time: re-running after a successful publish hits the Step 7 no-op; re-running after a failed build starts a fresh run, which reuses any leftover draft.
|
||||
+11
-10
@@ -17,10 +17,12 @@ concurrency:
|
||||
group: app-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Speed: a pull request runs on Ubuntu only (the cheapest runner) unless it carries the
|
||||
# `full-matrix` label; pushes to main and manual runs use all three systems. A change that
|
||||
# touches only the website, the README, the changelog or similar skips the heavy jobs and runs
|
||||
# the fast `prose` job instead, which keeps the checks that read those files.
|
||||
# Speed: pushes and pull requests run on Ubuntu only (the cheapest runner) unless a pull request
|
||||
# carries the `full-matrix` label; manual runs use all three systems. The release build
|
||||
# (release-app.yml) compiles on Windows and macOS too. A change that
|
||||
# touches only the website, the README, the changelog or similar skips the heavy `app` job. The
|
||||
# fast `prose` job runs on every push and pull request. The root `npm test` suite does not run on
|
||||
# pushes or pull requests at all: run it locally, or start `node-tests` by hand.
|
||||
jobs:
|
||||
changes:
|
||||
name: changes
|
||||
@@ -56,8 +58,6 @@ jobs:
|
||||
|
||||
prose:
|
||||
name: prose checks
|
||||
needs: changes
|
||||
if: needs.changes.outputs.code == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: ${{ fromJSON(github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') && '["ubuntu-latest"]' || '["windows-latest","macos-latest","ubuntu-latest"]') }}
|
||||
os: ${{ fromJSON((github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'full-matrix')) && '["windows-latest","macos-latest","ubuntu-latest"]' || '["ubuntu-latest"]') }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: plan2code-app
|
||||
@@ -170,13 +170,14 @@ jobs:
|
||||
|
||||
node-tests:
|
||||
name: npm test (${{ matrix.os }})
|
||||
needs: changes
|
||||
if: needs.changes.outputs.code == 'true'
|
||||
# Manual runs only: run `npm test` on the dev machine before pushing. Start this from the
|
||||
# Actions tab to check all three systems.
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: ${{ fromJSON(github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'full-matrix') && '["ubuntu-latest"]' || '["windows-latest","macos-latest","ubuntu-latest"]') }}
|
||||
os: [windows-latest, macos-latest, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/setup-node@v4.4.0
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
name: release-app
|
||||
|
||||
# Builds the desktop app on four systems when a GitHub release is published, or a v* tag is
|
||||
# pushed ahead of one, and attaches one file per system, named
|
||||
# The normal way to release is to start this workflow by hand (`plan2code-publish` does it) with
|
||||
# the version and the release notes. It builds first and creates the release LAST, so the vX.Y.Z
|
||||
# tag, which is what the app's update check looks for, only appears once every file is attached
|
||||
# and nobody is offered an upgrade that has no binary yet. A release published by hand, or a v*
|
||||
# tag pushed ahead of one, still starts it as a fallback; the tag then exists before the files.
|
||||
#
|
||||
# Builds the desktop app on four systems and attaches one file per system, named
|
||||
# plan2code-app-<version>-<os>-<arch>[.exe], plus one checksum file
|
||||
# (plan2code-app-<version>-SHA256SUMS.txt). install.js fetches the matching file and checks it
|
||||
# against that list. Linux ships the plain binary, not an AppImage: docs/desktop-app.md documents
|
||||
@@ -9,6 +14,20 @@ name: release-app
|
||||
# how to allow it.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to release, without the v (it must match CHANGELOG.md, version.json and package.json)'
|
||||
required: true
|
||||
type: string
|
||||
title:
|
||||
description: 'Release title (defaults to the tag)'
|
||||
required: false
|
||||
type: string
|
||||
notes:
|
||||
description: 'Release notes (Markdown)'
|
||||
required: false
|
||||
type: string
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
@@ -22,9 +41,13 @@ permissions:
|
||||
# A release published after its tag push starts a second run for the same tag: queue it behind
|
||||
# the first so two builds never upload over each other.
|
||||
concurrency:
|
||||
group: release-app-${{ github.event.release.tag_name || github.ref_name }}
|
||||
group: release-app-${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
# The release tag: the published release's, the version a manual run was given, or the pushed tag.
|
||||
TAG: ${{ github.event.release.tag_name || (inputs.version && format('v{0}', inputs.version)) || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build (${{ matrix.label }})
|
||||
@@ -50,8 +73,6 @@ jobs:
|
||||
cache: npm
|
||||
cache-dependency-path: plan2code-app/package-lock.json
|
||||
- name: Check the versions agree with the release tag
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name || github.ref_name }}
|
||||
run: node scripts/check-versions.mjs --tag "$TAG"
|
||||
- name: Install the pinned Rust toolchain
|
||||
working-directory: plan2code-app
|
||||
@@ -97,7 +118,6 @@ jobs:
|
||||
contents: write
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.event.release.tag_name || github.ref_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/download-artifact@v4.3.0
|
||||
@@ -123,9 +143,30 @@ jobs:
|
||||
cd dist
|
||||
sha256sum plan2code-app-* > "plan2code-app-${VERSION}-SHA256SUMS.txt"
|
||||
cat "plan2code-app-${VERSION}-SHA256SUMS.txt"
|
||||
- name: Make sure the release exists
|
||||
# A tag push alone names no release; create one (same tag, generated notes) so the
|
||||
# upload below always has somewhere to go, whichever trigger ran it.
|
||||
run: gh release view "$TAG" || gh release create "$TAG" --title "$TAG" --generate-notes
|
||||
- name: Attach to the release
|
||||
run: gh release upload "$TAG" dist/* --clobber
|
||||
- name: Attach to the release, creating it last
|
||||
env:
|
||||
RELEASE_TITLE: ${{ inputs.title }}
|
||||
RELEASE_NOTES: ${{ inputs.notes }}
|
||||
# No release yet (a manual run, or a bare tag push): create it as a DRAFT with every file
|
||||
# attached, then publish it, so the tag appears only when the files are already there.
|
||||
# A release that already exists (published by hand) just gets the files. A draft left
|
||||
# by an earlier failed run is reused. Releases made with the workflow's own token do not
|
||||
# start another run.
|
||||
run: |
|
||||
state="$(gh release list --limit 100 --json tagName,isDraft -q ".[] | select(.tagName==\"$TAG\") | .isDraft")"
|
||||
if [ -z "$state" ]; then
|
||||
notes_file="$(mktemp)"
|
||||
if [ -n "$RELEASE_NOTES" ]; then
|
||||
printf '%s' "$RELEASE_NOTES" > "$notes_file"
|
||||
notes_args=(--notes-file "$notes_file")
|
||||
else
|
||||
notes_args=(--generate-notes)
|
||||
fi
|
||||
gh release create "$TAG" dist/* --draft --target "$GITHUB_SHA" --title "${RELEASE_TITLE:-$TAG}" "${notes_args[@]}"
|
||||
state=true
|
||||
else
|
||||
gh release upload "$TAG" dist/* --clobber
|
||||
fi
|
||||
if [ "$state" = "true" ]; then
|
||||
gh release edit "$TAG" --draft=false
|
||||
fi
|
||||
@@ -1955,6 +1955,7 @@ origin.
|
||||
| `POST /chat` | A Quick question `{ text, about?, images?, files?, conversation }`, or `{ reset: true, conversation }` for New conversation. Appended to the session's `chat.ndjson`. 400 `too-long` (over 4,000 characters), `image`, `file` or `bad`; 409 `offline`, `stale` or `limit` (10 per conversation). Never refused because a card send is still uncollected. |
|
||||
| `POST /chat/decision` | Approve or Decline on an edit the agent proposed: `{ re, decision, text?, conversation }`. Once per proposal; does not count toward the 10. |
|
||||
| `GET /overview?spec=specs/<name>[&file=map\|draft]` | The Overview tab's read of `<spec>/overview.md` (or, with `file=`, the Map tab's `pathfinder/map.md` or the Plan draft tab's live `PLAN-DRAFT-*.md`), as `text/markdown` with `cache-control: no-store` and the file's spec-relative name, URL-encoded, in `x-spec-file`. A missing file is a 204. On the dashboard `spec` must be one of the scanned specs; elsewhere the session's own spec is used. The file's real path must stay inside the project, so `../`, absolute paths and symlinks pointing out all get the same 204 as a missing file, as does an unscanned `spec` or an unknown `file`. |
|
||||
| `GET /agents-doc[?file=<name>]` | The Dashboard's AGENTS.md tab: `AGENTS.md` (the default) or one `.agents-docs/<name>.md`, as `text/markdown` with `cache-control: no-store`. A dashboard only; any other file name, a missing file or a path that leaves the project is a 204. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
|
||||
@@ -93,19 +93,19 @@ When you make a mistake, get corrected, or discover something about this codebas
|
||||
## Failure log
|
||||
|
||||
- Do not audit `CHANGELOG.md` headings through PowerShell — the emoji come back as `?`. See the gotcha for the correct approach.
|
||||
- Sync upstream only through `/sync-repo`, and verify its baseline against the real tree before porting: an earlier sync silently skipped a whole upstream release (the `3-implement-review` skill) while the recorded version froze. Update the baseline with `.claude/skills/sync-repo/set-synced.mjs`, never with a shell pipe over the decrypted body.
|
||||
- Sync upstream only through `/sync-repo`, and verify its baseline against the real tree before porting: an earlier sync silently skipped a whole upstream release (the `3-implement-review` skill) while the recorded version froze. Update the baseline with `.claude/skills/sync-repo/set-synced.mjs`, never with a shell pipe over the decrypted body. Keep plan2code's ticket-free `commit-msg.mjs` (`<subject>`, `AI Assisted`) through every sync: upstream's ticket-from-branch rule was ported by mistake once and removed in v2.6.0.
|
||||
- After a sync merge, run `npm test` before trusting a "clean" file: when upstream and plan2code fixed the same bug, `git merge-file` keeps both copies without a conflict (a sync once left `let pattern` declared twice in `app.js`, caught only by `parse-check`).
|
||||
- When extracting upstream files in Git Bash, run `git show <ref>:<path>` with `MSYS_NO_PATHCONV=1` and `C:/` style paths (never `/c/`): path conversion rewrites `origin/main:.readme/x.md` into `origin\main;.readme\x.md`, the show fails, and the merge silently runs against an empty "theirs". Check every extracted file is non-empty before merging.
|
||||
- After a sync, grep the result for every upstream name the rebrand map can miss (the `/sync-repo` body lists them): the owner slug and company name in any case, the bare brand word inside identifiers and fixtures, and the ticket key followed by anything, not only digits. Each slipped through once: an owner slug in `feedback-payload.mjs` and its test (fixed by hand to `jparkerweb/plan2code`); in v2.7.0 a `KEPT_<BRAND>_ENTRIES` constant, a `<brand>Dir` option, a `"<brand>"` test folder and an owner slug in a git remote URL; in v2.8.0 git board fixtures built as `` `feature/<KEY>-${11000 + i}-…` `` template literals, which a digits-only rewrite to `ABC-<n>` misses. No upstream name may appear in plain text anywhere in this repo.
|
||||
- Keep plan2code's ticket-free `commit-msg.mjs` (`<subject>`, `AI Assisted`) in every `/sync-repo`: upstream's ticket-from-branch rule was ported by mistake once and removed in v2.6.0.
|
||||
- When a new first-run dialog is added to the web console, set its seen flag in `scripts/capture-screenshots.mjs`'s `looks.json` too: the Welcome dialog once covered the regenerated dashboard screenshots until `welcomeSeen: true` was added.
|
||||
- Import `scripts/skill-script-helpers.mjs` in any test that builds git fixtures for a skill script or `git-repo.mjs`: it scrubs the whole test process's git config, so fixtures, imported modules and spawned scripts agree. Mixed configs broke `git plan switch` once (a global `core.autocrlf=true` checked fixtures out with CRLF the scrubbed script read as changed). It also rebuilds `skills/` and prunes any skill folder `install.js` does not list, so register a new skill in `SOURCE_PROMPTS` before running its `scripts/test-script-<name>.mjs` or the script under test vanishes.
|
||||
- Before deleting a test file that upstream split or removed, diff plan2code's copy against the rebranded upstream base and port the plan2code-only tests: v2.7.0's split of the web console suite would otherwise have dropped seven hardening tests (now in `scripts/test-web-console-hardening.mjs`).
|
||||
- When a `CHANGELOG.md` heading gets a version number, set the same number in `version.json` (with its `releaseDate`), the root `package.json` and README's `Version X.Y.Z` line in the same change, then run `npm run build:skills`. The changelog skill only touches `package.json`: v2.9.0 nearly shipped with `version.json` at 2.8.1, and README's line sat at 2.6.0 for three releases.
|
||||
- When a `CHANGELOG.md` heading gets a version number, set the same number in every file that carries it in the same change, then run `npm run build:skills`: `version.json` (with its `releaseDate`), the root `package.json`, README's `Version X.Y.Z` line, and under `plan2code-app/`: `package.json`, `package-lock.json` (two lines), `src-tauri/tauri.conf.json`, `src-tauri/Cargo.toml`, `fake-agent/Cargo.toml` and `Cargo.lock` (the `plan2code-app` and `fake-agent` entries). `node scripts/check-versions.mjs` compares all of them and runs in `npm test`; widen its `SOURCES` when a new file carries the version. The changelog skill only touches `package.json`: v2.9.0 nearly shipped with `version.json` at 2.8.1, and README's line sat at 2.6.0 for three releases.
|
||||
- When a page test (`scripts/test-web-console-page-*.mjs`) fails only on CI or only in a full run, look for a race with a redraw before suspecting the change, and fix the test, not the timeout: read styles and set scrolls through `styleOf()`, `stylesOf()` and `scrollCard()` in `page-test-helpers.mjs` (a card a redraw replaced reads "" for every style and scrolls nothing; `test-web-console-shape.mjs` now fails a raw `locator.evaluate` that does either), and wait for the page to hold what the next step needs before acting (the workspace frame before typing `@`, the notepad's drawn marks, a newly selected tab). Keep `npm test`'s file concurrency under `scripts/node-test.mjs`'s cap of one file per spare core: a flat `--test-concurrency=8` ran 8 browsers on 3 and 4 core runners and failed a different page test on every CI run. On a busy local machine, rerun the failing files alone first; the chat stress test and the session suite's "no submitted frame within 5s" cascade still fail that way under load.
|
||||
- Run `npm test` and `cargo test` from a terminal outside the desktop app, or with `PLAN2CODE_IN_APP`, `PLAN2CODE_APP_TOKEN`, `PLAN2CODE_APP_VERSION`, `PLAN2CODE_APP_ANNOUNCE`, `PLAN2CODE_EMBED_ORIGIN` and `PLAN2CODE_CONSOLE_SID` unset (`env -u ... npm test`): inherited from the app they fail about 34 tests that check behavior outside the app (the update banner, the terminal line, cookies, open's browser launch), and a test console announces itself to the live window. A `cargo test` run mid-build once took the window over that way, then left an agent-less dashboard in it, and the build's question was never seen. The app now ignores sessions outside its console store (`take_announced` in `main.rs`), and the Rust console tests scrub the variables, but the JS suites do not. Before pushing a change under `plan2code-app/`, also run `cargo fmt --check` and `cargo clippy --workspace --all-targets -- -D warnings` there, not only `cargo test`: CI's `app` workflow fails on either, and the Rust code once reached a PR never formatted (20 files) with three clippy errors, one only macOS and Linux could see (see plan2code-app/README.md "Tests"). `loop_driver` tests failing with `never saw ... agent generations` and no `ARGS` line in the output mean `target/debug/fake-agent` is older than its source (a file restored with an old time, so Cargo never rebuilds it): `touch plan2code-app/fake-agent/src/main.rs` and rerun. A stale binary once read as 2 real failures in PR Prep.
|
||||
- Never fix CRLF by hand, one file at a time: run `npm run fix:eol` (`scripts/fix-line-endings.mjs`). Windows Python in text mode, among other tools, writes CRLF into files git keeps as LF; a whole session's edits once came out CRLF and 14 other files were found the same way. It now also runs as `pretest`, in the pre-commit hook and after every agent Write or Edit (see the LF gotcha in Code Style).
|
||||
- Bring the Windows folder picker (`picker.mjs`, copied into `src/launcher/plan2code.js`) to the front with an Alt tap before `SetForegroundWindow`, never with `windowsHide`, the owner form's `TopMost`, `HWND_TOPMOST` or `AttachThreadInput`: measured on Windows 11, `SetWindowPos(HWND_TOPMOST)` returns true while the dialog stays non-topmost behind the browser, and only the Alt tap made it the foreground window. Check with `GetForegroundWindow` from a second process, since no test can see it.
|
||||
- Add any new file or folder Plan2Code writes at the top of `~/.plan2code/` to `KEPT_PLAN2CODE_ENTRIES` in `src/web-console/sessions.mjs` and to the Cleanup test in `scripts/test-web-console-server.mjs`: User Preferences → System → Cleanup offers every other entry there for deletion once it is an hour old, and the desktop app's `app/` and `app.json` were about to be listed.
|
||||
- When a test checks how `cmd.exe` finds a `.cmd`/`.bat` (current folder before PATH), clear `NoDefaultCurrentDirectoryInExePath` for the run under test (`env_remove` in Rust, `undefined` in a `test-launcher.mjs` `box.run` env): some shells (Claude Code's among them) already set it, and the decoy `.cmd` test for custom agents passed without its fix until it did.
|
||||
- Never set a `Secure` cookie for the app's `tauri://localhost` frame (Linux and macOS): WebKit drops a Secure cookie sent over plain `http://127.0.0.1`, so every request after the sign-in got a 403 and the Linux app showed "its page did not show in this window" while working on Windows, where WebView2 counts loopback as secure. `cookieSameSite()` in `src/web-console/routes.mjs` sends Lax there and None; Secure only to `tauri.localhost`; check an embed change in a WebKit view, not only Chrome.
|
||||
- On Windows, treat a console the agent opened as dying with the agent: the app ends the agent's whole Job Object, so a `detached` server goes too, with no `exit` event. A `console.mjs post` still succeeds because it writes the session's files, so it proves nothing about the server; only the window's reconnect brings the page back. Every loop phase ends this way, and a reconnect budget that never refilled once lost the loop's stop card after Phase 3.
|
||||
@@ -2,6 +2,36 @@
|
||||
|
||||
All notable changes to Plan2Code will be documented in this file.
|
||||
|
||||
## v3.0.3
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
- **desktop app**: the terminal now starts docked on the right on a fresh install, as intended, instead of at the bottom. The app always reported a saved `bottom` dock, so the page's right-dock default never ran; it now reports nothing until a dock is saved. A dock you already chose is kept.
|
||||
|
||||
### ✨ Added
|
||||
|
||||
- **web console**: the dashboard has an **AGENTS.md** tab right after Dashboard, shown while the project has an `AGENTS.md`. It reads the file fresh from disk, read-only, and links into `.agents-docs/` open in place with a way back.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **releases**: `npm test` now runs `scripts/check-versions.mjs` first, and that check reads every place that carries the version (README's `Version` line, both `package-lock.json` lines, `fake-agent/Cargo.toml` and both `Cargo.lock` entries as well as the six it read before), so a release that leaves any of them behind fails the tests instead of shipping.
|
||||
|
||||
## v3.0.2
|
||||
|
||||
### ✨ Added
|
||||
|
||||
- **desktop app**: the app now checks GitHub for a newer release when it starts, and its top bar says `Update available: vX.Y.Z` with a button that copies `plan2code update`, the command that brings the app, skills and launcher up together. The web console already showed this in the browser; the app only compared its own version with the installed skills, so it never knew a release was out.
|
||||
|
||||
### 🔧 Changed
|
||||
|
||||
- **releases**: the release workflow now builds all four systems first and creates the release, with its `vX.Y.Z` tag, last, so nobody is offered an upgrade before its downloads exist. CI runs the root `npm test` suite only by hand, and the app job on Ubuntu only for pushes.
|
||||
|
||||
## v3.0.1
|
||||
|
||||
### 🐛 Fixed
|
||||
|
||||
- **desktop app**: on Linux (and macOS) the dashboard now shows in the app's window instead of "The console is running but its page did not show in this window." The console's sign-in cookie was marked `Secure`, which WebKit drops on a plain `http://127.0.0.1` page, so every request after sign-in was refused. Inside the app on those systems the cookie is now `SameSite=Lax`; Windows and the standalone browser are unchanged.
|
||||
|
||||
## v3.0.0
|
||||
|
||||
### ✨ Added
|
||||
|
||||
@@ -13,7 +13,7 @@ the next engineer all start from the same specs.
|
||||
|
||||
One command opens it, every step is a card, and the terminal is always there if you prefer it.
|
||||
|
||||
Version 3.0.0 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
Version 3.0.3 · MIT · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"plan2code-install": "./install.js"
|
||||
@@ -11,7 +11,7 @@
|
||||
"fix:eol": "node scripts/fix-line-endings.mjs",
|
||||
"play": "node scripts/play.mjs",
|
||||
"pretest": "node scripts/fix-line-endings.mjs",
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-flock.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-send-state.mjs scripts/test-web-console-strengths.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
"test": "node scripts/validate-char-count.js && node install.js --build-skills && node scripts/check-versions.mjs && node scripts/parse-check.mjs && node scripts/check-skill-table.mjs && node scripts/node-test.mjs scripts/test-line-endings.mjs scripts/test-us-english.mjs scripts/test-script-git.mjs scripts/test-git-repo.mjs scripts/test-skill-scripts.mjs scripts/test-script-test-map.mjs scripts/test-script-test-match.mjs scripts/test-script-test-commands.mjs scripts/test-script-run-check.mjs scripts/test-script-pr-prep.mjs scripts/test-script-coverage.mjs scripts/test-script-changelog.mjs scripts/test-web-console-git.mjs scripts/test-web-console-git-board.mjs scripts/test-web-console-chat.mjs scripts/test-web-console-subagents.mjs scripts/test-web-console-pointers.mjs scripts/test-console-wire-budgets.mjs scripts/test-web-console-speed.mjs scripts/test-web-console-qa.mjs scripts/test-web-console-concurrency.mjs scripts/test-web-console-workspace.mjs scripts/test-web-console-lifecycle.mjs scripts/test-web-console-chat-stress.mjs scripts/test-web-console-server.mjs scripts/test-web-console-session.mjs scripts/test-web-console-logic.mjs scripts/test-web-console-activities.mjs scripts/test-web-console-activities-rapids.mjs scripts/test-web-console-activities-flock.mjs scripts/test-web-console-activities-bounce.mjs scripts/test-web-console-activities-bounce-game.mjs scripts/test-web-console-activities-ghoul.mjs scripts/test-web-console-activities-ghoul-graveyard.mjs scripts/test-web-console-activities-ghoul-grounds.mjs scripts/test-web-console-activities-ghoul-chapel.mjs scripts/test-web-console-activities-ghoul-sanatorium.mjs scripts/test-web-console-activities-ghoul-village.mjs scripts/test-web-console-activities-ghoul-mine.mjs scripts/test-web-console-activities-ghoul-carnival.mjs scripts/test-web-console-activities-ghoul-frozen.mjs scripts/test-web-console-activities-ghoul-bog.mjs scripts/test-web-console-activities-ghoul-lantern.mjs scripts/test-web-console-activities-ghoul-marrow.mjs scripts/test-web-console-activities-ghoul-mat.mjs scripts/test-web-console-activities-ghoul-eye.mjs scripts/test-web-console-activities-ghoul-bonestair.mjs scripts/test-web-console-activities-ghoul-heart.mjs scripts/test-web-console-activities-ghoul-ending.mjs scripts/test-web-console-activities-ghoul-ride.mjs scripts/test-web-console-activities-ghoul-cart.mjs scripts/test-web-console-activities-ghoul-sled.mjs scripts/test-web-console-activities-ghoul-banister.mjs scripts/test-web-console-activities-ghoul-gurney.mjs scripts/test-web-console-activities-ghoul-hearse.mjs scripts/test-web-console-activities-ghoul-wagon.mjs scripts/test-web-console-activities-ghoul-pew.mjs scripts/test-web-console-activities-ghoul-mower.mjs scripts/test-web-console-activities-ghoul-tray.mjs scripts/test-web-console-activities-ghoul-arms.mjs scripts/test-web-console-activities-ghoul-dice.mjs scripts/test-web-console-activities-ghoul-gameover.mjs scripts/test-web-console-activities-ghoul-intro.mjs scripts/test-web-console-activities-ghoul-bossintro.mjs scripts/test-web-console-activities-ghoul-story.mjs scripts/test-web-console-activities-ghoul-bones.mjs scripts/test-web-console-activities-ghoul-retry.mjs scripts/test-web-console-activities-bounce-cars.mjs scripts/test-web-console-tones.mjs scripts/test-web-console-skills.mjs scripts/test-web-console-spec-states.mjs scripts/test-web-console-state.mjs scripts/test-web-console-send-state.mjs scripts/test-web-console-strengths.mjs scripts/test-web-console-shape.mjs scripts/test-script-pathfinder.mjs scripts/test-skill-test-runs.mjs scripts/test-launcher.mjs scripts/test-agents-file.mjs scripts/test-agent-lookup.mjs scripts/test-web-console-source.mjs scripts/test-web-console-hardening.mjs scripts/test-web-console-embed.mjs scripts/test-web-console-in-app.mjs scripts/test-web-console-loop.mjs scripts/test-web-console-handoffs.mjs scripts/test-web-console-notepad.mjs scripts/test-script-xray.mjs scripts/test-script-finalize.mjs scripts/test-getting-started.mjs scripts/test-install-update.mjs scripts/test-browser-helper.mjs scripts/test-web-console-page-cards.mjs scripts/test-web-console-page-dashboard.mjs scripts/test-web-console-page-session.mjs scripts/test-web-console-page-ask.mjs scripts/test-web-console-page-workspace.mjs scripts/test-web-console-page-help.mjs scripts/test-web-console-page-prefs.mjs scripts/test-web-console-page-git.mjs scripts/test-web-console-page-notepad.mjs scripts/test-web-console-page-send.mjs scripts/test-web-console-page-loop.mjs scripts/test-web-console-page-activities.mjs scripts/test-web-console-page-setup.mjs scripts/test-standalone-check.mjs scripts/test-check-versions.mjs scripts/test-app-meter.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gpt-tokenizer": "2.9.0",
|
||||
|
||||
Generated
+2
-2
@@ -757,7 +757,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fake-agent"
|
||||
version = "3.0.0"
|
||||
version = "3.0.3"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"terminal_size",
|
||||
@@ -2371,7 +2371,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.0"
|
||||
version = "3.0.3"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fake-agent"
|
||||
version = "3.0.0"
|
||||
version = "3.0.3"
|
||||
description = "A stand-in agent program for the Plan2Code app's tests"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "2.12.4",
|
||||
"@xterm/addon-fit": "0.11.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plan2code-app",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"private": true,
|
||||
"description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "plan2code-app"
|
||||
version = "3.0.0"
|
||||
version = "3.0.3"
|
||||
description = "Plan2Code desktop app"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
@@ -706,14 +706,11 @@ fn app_state(state: State<'_, AppState>) -> serde_json::Value {
|
||||
.filter(known)
|
||||
})
|
||||
.or_else(|| project::remembered_agent().filter(known));
|
||||
let term_panel = settings_file.as_ref().map_or(
|
||||
settings::TermPanelSettings {
|
||||
dock: settings::DEFAULT_TERM_DOCK.to_string(),
|
||||
fraction: settings::DEFAULT_TERM_FRACTION,
|
||||
collapsed: false,
|
||||
},
|
||||
|file| settings::load_term_panel(file),
|
||||
);
|
||||
// Null until the person has docked, dragged or collapsed the pane: the
|
||||
// page then starts it docked right.
|
||||
let term_panel = settings_file
|
||||
.as_ref()
|
||||
.and_then(|file| settings::load_term_panel(file));
|
||||
let first_run_done = settings_file
|
||||
.as_ref()
|
||||
.is_some_and(|file| settings::load_first_run_done(file));
|
||||
@@ -765,6 +762,17 @@ fn version_status(app: tauri::AppHandle) -> versions::VersionStatus {
|
||||
)
|
||||
}
|
||||
|
||||
/// The newest GitHub release's version when it is newer than this app, else none (also none on
|
||||
/// any failure to ask). The page asks once at start and never waits on it.
|
||||
#[tauri::command]
|
||||
async fn check_new_release(app: tauri::AppHandle) -> Option<String> {
|
||||
let version = app.package_info().version.to_string();
|
||||
tauri::async_runtime::spawn_blocking(move || versions::check_new_release(&version))
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// What `update_skills` resolves with: the installer's last line, and the version status
|
||||
/// re-read afterwards, so the bar can say plainly whether the mismatch is actually gone.
|
||||
#[derive(serde::Serialize)]
|
||||
@@ -1319,6 +1327,7 @@ fn main() {
|
||||
save_term_panel,
|
||||
save_first_run_done,
|
||||
version_status,
|
||||
check_new_release,
|
||||
update_skills,
|
||||
pick_project_folder,
|
||||
change_project,
|
||||
|
||||
@@ -21,7 +21,6 @@ pub struct TermPanelSettings {
|
||||
pub collapsed: bool,
|
||||
}
|
||||
|
||||
pub const DEFAULT_TERM_DOCK: &str = "bottom";
|
||||
pub const DEFAULT_TERM_FRACTION: f64 = 0.25;
|
||||
const TERM_FRACTION_MIN: f64 = 0.05;
|
||||
const TERM_FRACTION_MAX: f64 = 0.9;
|
||||
@@ -53,15 +52,16 @@ pub fn save_last_agent(file: &Path, id: &str) -> Result<(), String> {
|
||||
write(file, settings)
|
||||
}
|
||||
|
||||
/// The terminal pane's shape, from the file or the defaults. A dock other
|
||||
/// than `bottom` or `right`, or a fraction outside its range, is the default.
|
||||
pub fn load_term_panel(file: &Path) -> TermPanelSettings {
|
||||
/// The terminal pane's saved shape, or `None` when no valid dock is saved (a
|
||||
/// fresh install, or a dock other than `bottom` or `right`): the page then
|
||||
/// picks its own default, docked right. A fraction outside its range falls
|
||||
/// back to the default fraction.
|
||||
pub fn load_term_panel(file: &Path) -> Option<TermPanelSettings> {
|
||||
let settings = read(file);
|
||||
let dock = settings
|
||||
.get(TERM_DOCK_KEY)
|
||||
.and_then(|v| v.as_str())
|
||||
.filter(|d| *d == "bottom" || *d == "right")
|
||||
.unwrap_or(DEFAULT_TERM_DOCK)
|
||||
.filter(|d| *d == "bottom" || *d == "right")?
|
||||
.to_string();
|
||||
let fraction = settings
|
||||
.get(TERM_FRACTION_KEY)
|
||||
@@ -72,11 +72,11 @@ pub fn load_term_panel(file: &Path) -> TermPanelSettings {
|
||||
.get(TERM_COLLAPSED_KEY)
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false);
|
||||
TermPanelSettings {
|
||||
Some(TermPanelSettings {
|
||||
dock,
|
||||
fraction,
|
||||
collapsed,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Save the terminal pane's shape, keeping any other key the file holds. An
|
||||
@@ -202,13 +202,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_term_panel_defaults_to_bottom_at_a_quarter() {
|
||||
let want = TermPanelSettings {
|
||||
dock: "bottom".into(),
|
||||
fraction: 0.25,
|
||||
collapsed: false,
|
||||
};
|
||||
assert_eq!(load_term_panel(&temp_file("term-missing")), want);
|
||||
fn nothing_saved_reports_no_term_panel_so_the_page_docks_right() {
|
||||
assert_eq!(load_term_panel(&temp_file("term-missing")), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -219,11 +214,11 @@ mod tests {
|
||||
save_term_panel(&file, "right", 0.4, true).unwrap();
|
||||
assert_eq!(
|
||||
load_term_panel(&file),
|
||||
TermPanelSettings {
|
||||
Some(TermPanelSettings {
|
||||
dock: "right".into(),
|
||||
fraction: 0.4,
|
||||
collapsed: true
|
||||
}
|
||||
})
|
||||
);
|
||||
assert!(std::fs::read_to_string(&file)
|
||||
.unwrap()
|
||||
@@ -272,11 +267,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_dock_or_out_of_range_fraction_on_disk_reads_as_the_default() {
|
||||
fn a_bad_dock_on_disk_reads_as_nothing_saved_and_a_bad_fraction_as_the_default() {
|
||||
let file = temp_file("term-bad-load");
|
||||
std::fs::create_dir_all(file.parent().unwrap()).unwrap();
|
||||
std::fs::write(&file, r#"{"termDock": "top", "termFraction": 5}"#).unwrap();
|
||||
let loaded = load_term_panel(&file);
|
||||
assert_eq!(load_term_panel(&file), None);
|
||||
std::fs::write(&file, r#"{"termDock": "bottom", "termFraction": 5}"#).unwrap();
|
||||
let loaded = load_term_panel(&file).unwrap();
|
||||
assert_eq!(loaded.dock, "bottom");
|
||||
assert_eq!(loaded.fraction, 0.25);
|
||||
let _ = std::fs::remove_dir_all(file.parent().unwrap());
|
||||
|
||||
@@ -73,6 +73,84 @@ pub fn status(app: &str, skills: Option<String>) -> VersionStatus {
|
||||
}
|
||||
}
|
||||
|
||||
/// The repo's tags, asked of GitHub the way the web console's own check does it
|
||||
/// (src/web-console/update-check.mjs): `git ls-remote --tags` needs no token and rides on the
|
||||
/// person's own git and proxy setup.
|
||||
const REPO_URL: &str = "https://github.com/jparkerweb/plan2code.git";
|
||||
/// How long the tag lookup may take before it is given up on (nothing waits on it).
|
||||
const RELEASE_CHECK_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
/// The highest plain `vX.Y.Z` tag in `git ls-remote --tags` output, without the `v`. Peeled
|
||||
/// lines (`^{}`) and pre-release or other tag names never match.
|
||||
pub fn latest_tag(text: &str) -> Option<String> {
|
||||
let mut best: Option<((u64, u64, u64), String)> = None;
|
||||
for line in text.lines() {
|
||||
let Some(version) = line.trim().rsplit_once("refs/tags/v").map(|(_, v)| v) else {
|
||||
continue;
|
||||
};
|
||||
let Some(triple) = parse(version) else {
|
||||
continue;
|
||||
};
|
||||
if best.as_ref().is_none_or(|(top, _)| triple > *top) {
|
||||
best = Some((triple, version.to_string()));
|
||||
}
|
||||
}
|
||||
best.map(|(_, version)| version)
|
||||
}
|
||||
|
||||
/// The newest release's version when it is newer than `app`; none when the app is current,
|
||||
/// ahead, or either version is not a plain `X.Y.Z`.
|
||||
pub fn newer_release(app: &str, ls_remote: &str) -> Option<String> {
|
||||
let latest = latest_tag(ls_remote)?;
|
||||
(parse(&latest)? > parse(app)?).then_some(latest)
|
||||
}
|
||||
|
||||
/// Ask GitHub for the newest release and return its version when it is newer than `app`.
|
||||
/// None on any failure (no git, no network, a login prompt, the timeout): a missing answer
|
||||
/// is never a reason to nag. No prompt and no console window.
|
||||
pub fn check_new_release(app: &str) -> Option<String> {
|
||||
let mut command = Command::new("git");
|
||||
command
|
||||
.env("PATH", crate::node_check::resolved_path())
|
||||
.env("GIT_TERMINAL_PROMPT", "0")
|
||||
.env("GCM_INTERACTIVE", "never")
|
||||
.args(["ls-remote", "--tags", REPO_URL])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::null());
|
||||
if std::env::var_os("GIT_SSH_COMMAND").is_none() {
|
||||
command.env("GIT_SSH_COMMAND", "ssh -o BatchMode=yes");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
command.creation_flags(0x08000000); // CREATE_NO_WINDOW, as the console calls are
|
||||
}
|
||||
let mut child = command.spawn().ok()?;
|
||||
let mut stdout = child.stdout.take()?;
|
||||
let (tx, rx) = mpsc::channel::<String>();
|
||||
std::thread::spawn(move || {
|
||||
let mut text = String::new();
|
||||
let _ = std::io::Read::read_to_string(&mut stdout, &mut text);
|
||||
let _ = tx.send(text);
|
||||
});
|
||||
match rx.recv_timeout(RELEASE_CHECK_TIMEOUT) {
|
||||
Ok(text) => {
|
||||
let ok = child.wait().is_ok_and(|status| status.success());
|
||||
if ok {
|
||||
newer_release(app, &text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the existing installer's update (`plan2code update`, through the launcher's own copy),
|
||||
/// which brings the skills, the launcher and the app level. Pinned to the release tag `app_version`
|
||||
/// names, not `main`, so Update skills never pulls in work the app does not know about yet. Blocks
|
||||
@@ -215,6 +293,34 @@ mod tests {
|
||||
assert!(!status("3.0.0", Some("".into())).mismatch);
|
||||
}
|
||||
|
||||
const TAGS: &str = "aaa\trefs/tags/v2.11.0\n\
|
||||
bbb\trefs/tags/v3.0.0\n\
|
||||
ccc\trefs/tags/v3.0.0^{}\n\
|
||||
ddd\trefs/tags/v3.0.1\n\
|
||||
eee\trefs/tags/v3.10.0\n\
|
||||
fff\trefs/tags/v3.11.0-beta\n\
|
||||
ggg\trefs/tags/not-a-version\n";
|
||||
|
||||
#[test]
|
||||
fn the_latest_tag_is_the_highest_plain_version_compared_by_number() {
|
||||
assert_eq!(latest_tag(TAGS).as_deref(), Some("3.10.0"));
|
||||
assert_eq!(
|
||||
latest_tag("aaa\trefs/tags/v3.0.1\r\nbbb\trefs/tags/v3.0.9\r\n").as_deref(),
|
||||
Some("3.0.9")
|
||||
);
|
||||
assert_eq!(latest_tag(""), None);
|
||||
assert_eq!(latest_tag("aaa\trefs/tags/v3.0.0-beta\n"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_newer_release_is_reported_only_when_it_is_ahead_of_the_app() {
|
||||
assert_eq!(newer_release("3.0.0", TAGS).as_deref(), Some("3.10.0"));
|
||||
assert_eq!(newer_release("3.10.0", TAGS), None);
|
||||
assert_eq!(newer_release("3.11.0", TAGS), None);
|
||||
assert_eq!(newer_release("3.0.0-beta", TAGS), None);
|
||||
assert_eq!(newer_release("3.0.0", ""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_the_version_field_of_a_version_file() {
|
||||
let file = temp_file("ok", r#"{ "name": "Plan2Code", "version": "2.11.0" }"#);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Plan2Code",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"identifier": "com.plan2code.desktop",
|
||||
"build": {
|
||||
"frontendDist": "../ui",
|
||||
|
||||
+35
-4
@@ -1,8 +1,9 @@
|
||||
// The app page: the top bar, the console dashboard in an iframe, and the
|
||||
// agent's terminal panel docked at the bottom with a drag handle.
|
||||
// agent's terminal panel, docked right by default (or at the bottom on
|
||||
// request) with a drag handle.
|
||||
|
||||
import { mountTerminal } from './terminal.js';
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js';
|
||||
import { NEW_RELEASE_COMMAND, attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, lastAgentNotice, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopLocks, loopStopLabels, loopWindowTitle } from './meter.js';
|
||||
|
||||
const { invoke, Channel } = window.__TAURI__.core;
|
||||
|
||||
@@ -1012,6 +1013,29 @@ async function checkVersions() {
|
||||
}
|
||||
}
|
||||
|
||||
// Once, at start, and never waited on: is a newer Plan2Code release out on GitHub? The Rust
|
||||
// side asks (the same tag lookup the web console uses) and answers with the newer version, or
|
||||
// nothing when the app is current or the lookup failed.
|
||||
async function checkNewRelease() {
|
||||
try {
|
||||
const latest = await invoke('check_new_release');
|
||||
if (latest) setNewRelease({ latest, copied: false });
|
||||
} catch {
|
||||
// No answer is no reason to nag.
|
||||
}
|
||||
}
|
||||
|
||||
async function copyUpdateCommand() {
|
||||
if (!newRelease) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(NEW_RELEASE_COMMAND);
|
||||
setNewRelease({ ...newRelease, copied: true });
|
||||
} catch {
|
||||
// The webview refused the clipboard: the bar spells the command out instead.
|
||||
setNewRelease({ ...newRelease, manual: true });
|
||||
}
|
||||
}
|
||||
|
||||
async function updateSkills() {
|
||||
setVersionState({ kind: 'updating', line: 'Updating Plan2Code...' });
|
||||
const progress = new Channel();
|
||||
@@ -1225,11 +1249,12 @@ loopStopNowBtn.onclick = () =>
|
||||
// barNextSteps decides which, and its button), with the rest as "+N more".
|
||||
let consoleDead = false;
|
||||
let versionState = null;
|
||||
const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills };
|
||||
let newRelease = null;
|
||||
const NEXT_STEP_ACTIONS = { reconnect: reconnectConsole, 'restart-console': restartConsole, update: updateSkills, 'copy-update': copyUpdateCommand };
|
||||
let nextStepAction = null;
|
||||
|
||||
function renderNextStep() {
|
||||
const steps = barNextSteps({ consoleDead, version: versionState });
|
||||
const steps = barNextSteps({ consoleDead, version: versionState, newRelease });
|
||||
nextStepEl.hidden = steps.length === 0;
|
||||
const [first, ...rest] = steps;
|
||||
nextStepTextEl.textContent = first ? first.text : '';
|
||||
@@ -1249,6 +1274,11 @@ function setVersionState(next) {
|
||||
renderNextStep();
|
||||
}
|
||||
|
||||
function setNewRelease(next) {
|
||||
newRelease = next;
|
||||
renderNextStep();
|
||||
}
|
||||
|
||||
function markConsoleAlive() {
|
||||
consoleDead = false;
|
||||
renderNextStep();
|
||||
@@ -1425,6 +1455,7 @@ async function main() {
|
||||
applyDefaultAgent(state.lastAgent);
|
||||
setInterval(updateBadge, BADGE_POLL_MS);
|
||||
checkVersions();
|
||||
checkNewRelease();
|
||||
|
||||
let reattach = null;
|
||||
try {
|
||||
|
||||
@@ -9,8 +9,14 @@ export const NEXT_STEP_LABELS = {
|
||||
reconnect: 'Reconnect the console',
|
||||
'restart-console': 'Reconnect the console',
|
||||
update: 'Update skills',
|
||||
'copy-update': 'Copy update command',
|
||||
};
|
||||
|
||||
// What a person runs in a terminal to move to the newest release: the same line the web
|
||||
// console's banner gives. The app cannot replace itself, and Update skills is pinned to the
|
||||
// app's own version, so only this brings the app, the skills and the launcher up together.
|
||||
export const NEW_RELEASE_COMMAND = 'plan2code update';
|
||||
|
||||
/**
|
||||
* What the console page's **continue** button types into the agent's
|
||||
* terminal, one write each: the word, then Enter. Claude Code holds typed
|
||||
@@ -76,7 +82,7 @@ export function lastAgentNotice(list, remembered) {
|
||||
* update, its Reconnect (which stops the old console first, so the new skills
|
||||
* are really picked up) covers a console that has also stopped.
|
||||
*/
|
||||
export function barNextSteps({ consoleDead = false, version = null } = {}) {
|
||||
export function barNextSteps({ consoleDead = false, version = null, newRelease = null } = {}) {
|
||||
const v = version || {};
|
||||
const steps = [];
|
||||
if (v.kind === 'updated') {
|
||||
@@ -108,6 +114,17 @@ export function barNextSteps({ consoleDead = false, version = null } = {}) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Last: the pending fix for a mismatch or a stopped console comes before a release that is
|
||||
// merely out. `newRelease` is `{ latest, copied, manual }`.
|
||||
if (newRelease && newRelease.latest) {
|
||||
steps.push(
|
||||
newRelease.manual
|
||||
? { id: 'new-release', text: `Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'warn', action: null }
|
||||
: newRelease.copied
|
||||
? { id: 'new-release', text: `Copied: run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app`, title: `Plan2Code v${newRelease.latest} is out. Run \`${NEW_RELEASE_COMMAND}\` in a terminal, then reopen the app.`, tone: 'ok', action: null }
|
||||
: { id: 'new-release', text: `Update available: v${newRelease.latest}`, title: `Plan2Code v${newRelease.latest} is out. Copy the command, run it in a terminal, then reopen the app.`, tone: 'warn', action: 'copy-update' }
|
||||
);
|
||||
}
|
||||
return steps.map((step) => ({ ...step, label: step.action ? NEXT_STEP_LABELS[step.action] : null }));
|
||||
}
|
||||
|
||||
|
||||
+29
-11
@@ -1,7 +1,9 @@
|
||||
// Checks that every file carrying the product's version agrees, the desktop app's included:
|
||||
// version.json, package.json, CHANGELOG.md's top heading, and the app's tauri.conf.json,
|
||||
// package.json and Cargo.toml. The release-app workflow runs it before building, with
|
||||
// --tag <the release tag>, so a release cannot ship an app that names another version.
|
||||
// version.json, package.json, CHANGELOG.md's top heading, README's "Version X.Y.Z" line, and the
|
||||
// app's tauri.conf.json, package.json, package-lock.json (two lines), src-tauri/Cargo.toml,
|
||||
// fake-agent/Cargo.toml and Cargo.lock (the plan2code-app and fake-agent entries). `npm test` runs
|
||||
// it on this tree, and the release-app workflow runs it before building, with --tag <the release
|
||||
// tag>, so a release cannot ship a file that names another version.
|
||||
//
|
||||
// node scripts/check-versions.mjs [--tag v3.0.0]
|
||||
//
|
||||
@@ -16,19 +18,35 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8")).version;
|
||||
const CARGO_VERSION = /^\s*version\s*=\s*"([^"]+)"/m;
|
||||
const CHANGELOG_HEADING = /^##\s+v?(\d+\.\d+\.\d+)\b/m;
|
||||
const README_LINE = /^Version (\d+\.\d+\.\d+)\b/m;
|
||||
|
||||
/** Each file that carries the version, with how to read it. Paths are relative to the repo root. */
|
||||
// The first `version =` line is the [package] one; dependencies come after it.
|
||||
const readCargoToml = (file) => fs.readFileSync(file, "utf8").match(CARGO_VERSION)?.[1];
|
||||
/** The version of the `[[package]]` called `name` in a Cargo.lock. */
|
||||
const lockEntry = (name) => (file) =>
|
||||
fs.readFileSync(file, "utf8").match(new RegExp(`^name = "${name}"\\r?\\nversion = "([^"]+)"`, "m"))?.[1];
|
||||
|
||||
/**
|
||||
* Each place that carries the version, with how to read it. Paths are relative to the repo root;
|
||||
* a file with two places gets a `label` so a mismatch says which one.
|
||||
*/
|
||||
const SOURCES = [
|
||||
{ file: "version.json", read: readJson },
|
||||
{ file: "package.json", read: readJson },
|
||||
{ file: "CHANGELOG.md", read: (file) => fs.readFileSync(file, "utf8").match(CHANGELOG_HEADING)?.[1] },
|
||||
{ file: "README.md", read: (file) => fs.readFileSync(file, "utf8").match(README_LINE)?.[1] },
|
||||
{ file: "plan2code-app/src-tauri/tauri.conf.json", read: readJson },
|
||||
{ file: "plan2code-app/package.json", read: readJson },
|
||||
{ file: "plan2code-app/package-lock.json", label: "plan2code-app/package-lock.json (top)", read: readJson },
|
||||
{
|
||||
file: "plan2code-app/src-tauri/Cargo.toml",
|
||||
// The first `version =` line is the [package] one; dependencies come after it.
|
||||
read: (file) => fs.readFileSync(file, "utf8").match(CARGO_VERSION)?.[1],
|
||||
file: "plan2code-app/package-lock.json",
|
||||
label: "plan2code-app/package-lock.json (packages[\"\"])",
|
||||
read: (file) => JSON.parse(fs.readFileSync(file, "utf8")).packages?.[""]?.version,
|
||||
},
|
||||
{ file: "plan2code-app/src-tauri/Cargo.toml", read: readCargoToml },
|
||||
{ file: "plan2code-app/fake-agent/Cargo.toml", read: readCargoToml },
|
||||
{ file: "plan2code-app/Cargo.lock", label: "plan2code-app/Cargo.lock (plan2code-app)", read: lockEntry("plan2code-app") },
|
||||
{ file: "plan2code-app/Cargo.lock", label: "plan2code-app/Cargo.lock (fake-agent)", read: lockEntry("fake-agent") },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -39,19 +57,19 @@ const SOURCES = [
|
||||
export function checkVersions(root = ROOT, { tag } = {}) {
|
||||
const versions = [];
|
||||
const problems = [];
|
||||
for (const { file, read } of SOURCES) {
|
||||
for (const { file, label = file, read } of SOURCES) {
|
||||
let version;
|
||||
try {
|
||||
version = read(path.join(root, file));
|
||||
} catch (error) {
|
||||
problems.push(`${file}: cannot be read (${error.code || error.message})`);
|
||||
problems.push(`${label}: cannot be read (${error.code || error.message})`);
|
||||
continue;
|
||||
}
|
||||
if (!version) {
|
||||
problems.push(`${file}: no version found`);
|
||||
problems.push(`${label}: no version found`);
|
||||
continue;
|
||||
}
|
||||
versions.push({ file, version });
|
||||
versions.push({ file: label, version });
|
||||
}
|
||||
const expected = versions.find((v) => v.file === "version.json")?.version;
|
||||
for (const { file, version } of versions) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Pins Math.random to a seeded generator for a test file that drives an Activities game, so the
|
||||
// game's own dice (a road with a crack where a test wanted plain road, a spawn that lands out of
|
||||
// reach) give the same layout on every run and a rare roll can never fail a test at random.
|
||||
// Import it FIRST in the file: a game module may roll at load time.
|
||||
//
|
||||
// A seed that fails a test is a real finding, not a flake: set PLAN2CODE_TEST_SEED to reproduce
|
||||
// another roll, for example to hunt a bug the fixed seed hides.
|
||||
|
||||
let state = Number(process.env.PLAN2CODE_TEST_SEED || 20261105) >>> 0;
|
||||
|
||||
// mulberry32: small, fast and good enough for game dice.
|
||||
Math.random = () => {
|
||||
state = (state + 0x6d2b79f5) | 0;
|
||||
let t = Math.imul(state ^ (state >>> 15), 1 | state);
|
||||
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
@@ -11,7 +11,7 @@ import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS } from "../plan2code-app/ui/meter.js";
|
||||
import { attentionSignal, barNextSteps, continueKeys, defaultRightFraction, folderName, pickDefaultAgent, taskbarSwitch, windowTitleFor, deadConsoleAction, loopBanner, loopRunText, loopLocks, loopStopLabels, loopWindowTitle, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS, NEW_RELEASE_COMMAND } from "../plan2code-app/ui/meter.js";
|
||||
import { findBrowser, launchBrowser } from "./browser.mjs";
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -38,6 +38,34 @@ test("only one control for reconnecting the console is ever offered: after an up
|
||||
assert.deepEqual(steps.map((step) => step.action), ["restart-console"], "the plain reconnect steps aside for the one that stops the old console first");
|
||||
});
|
||||
|
||||
test("a newer GitHub release is offered last, with the command to copy; a mismatch or a stopped console comes first", () => {
|
||||
const newRelease = { latest: "3.0.1" };
|
||||
const ids = (input) => barNextSteps(input).map((step) => step.id);
|
||||
assert.deepEqual(ids({ newRelease }), ["new-release"]);
|
||||
assert.deepEqual(ids({ consoleDead: true, version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" }, newRelease }), ["console-dead", "mismatch", "new-release"]);
|
||||
const [step] = barNextSteps({ newRelease });
|
||||
assert.equal(step.text, "Update available: v3.0.1");
|
||||
assert.equal(step.label, "Copy update command");
|
||||
assert.equal(step.action, "copy-update");
|
||||
assert.equal(NEW_RELEASE_COMMAND, "plan2code update");
|
||||
assert.deepEqual(barNextSteps({ newRelease: null }), [], "nothing newer, nothing shown");
|
||||
});
|
||||
|
||||
test("after the copy the bar says what to do next; if the clipboard was refused it spells the command out", () => {
|
||||
const [copied] = barNextSteps({ newRelease: { latest: "3.0.1", copied: true } });
|
||||
assert.match(copied.text, /^Copied: run `plan2code update` in a terminal/);
|
||||
assert.equal(copied.action, null);
|
||||
const [manual] = barNextSteps({ newRelease: { latest: "3.0.1", manual: true } });
|
||||
assert.match(manual.text, /^Run `plan2code update` in a terminal/);
|
||||
assert.equal(manual.action, null);
|
||||
});
|
||||
|
||||
test("the app asks once at start for a newer release, and the bar is wired to the copy action", () => {
|
||||
assert.match(APP_JS, /invoke\('check_new_release'\)/);
|
||||
assert.match(APP_JS, /'copy-update': copyUpdateCommand/);
|
||||
assert.match(APP_JS, /barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\)/);
|
||||
});
|
||||
|
||||
test("each version state reads and acts as the old version bar did", () => {
|
||||
const [mismatch] = barNextSteps({ version: { kind: "mismatch", skills: "3.0.0", app: "3.1.0" } });
|
||||
assert.equal(mismatch.text, "Skills v3.0.0, app v3.1.0");
|
||||
@@ -63,7 +91,7 @@ test("every control that reconnects the console carries the same label, never 'R
|
||||
});
|
||||
|
||||
test("app.js draws the bar's right end through barNextSteps, not a hand-rolled copy of its order", () => {
|
||||
assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState \}\);/);
|
||||
assert.match(APP_JS, /const steps = barNextSteps\(\{ consoleDead, version: versionState, newRelease \}\);/);
|
||||
for (const gone of ["console-again", "version-update", "permissions-note", "console-status", "project-dir"]) {
|
||||
assert.ok(!INDEX_HTML.includes(`id="${gone}"`), `index.html still has #${gone}`);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Tests for scripts/check-versions.mjs. Run with: node --test scripts/test-check-versions.mjs
|
||||
//
|
||||
// Each test builds a small tree in a temp folder holding the six files that carry the version,
|
||||
// Each test builds a small tree in a temp folder holding every file that carries the version,
|
||||
// so the check is exercised without depending on what the real repo says today.
|
||||
|
||||
import test from "node:test";
|
||||
@@ -14,6 +14,11 @@ import { checkVersions } from "./check-versions.mjs";
|
||||
|
||||
const SCRIPT = path.join(path.dirname(fileURLToPath(import.meta.url)), "check-versions.mjs");
|
||||
|
||||
/** A Cargo.lock whose two workspace entries sit among others that carry their own versions. */
|
||||
function cargoLock(app, fake) {
|
||||
return `[[package]]\nname = "chrono"\nversion = "0.4.0"\n\n[[package]]\nname = "fake-agent"\nversion = "${fake}"\n\n[[package]]\nname = "plan2code-app"\nversion = "${app}"\n`;
|
||||
}
|
||||
|
||||
/** A tree with every version file at `version`, each overridable by its path in `over`. */
|
||||
function tree(t, version = "3.0.0", over = {}) {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-versions-"));
|
||||
@@ -23,8 +28,16 @@ function tree(t, version = "3.0.0", over = {}) {
|
||||
"package.json": JSON.stringify({ name: "plan2code", version }),
|
||||
"CHANGELOG.md": `# Changelog\n\n## v${version}\n\n### Added\n\n- something\n\n## v0.0.1\n`,
|
||||
"plan2code-app/src-tauri/tauri.conf.json": JSON.stringify({ productName: "Plan2Code", version }),
|
||||
"README.md": `# Plan2Code\n\nVersion ${version} · MIT\n`,
|
||||
"plan2code-app/package.json": JSON.stringify({ name: "plan2code-app", version }),
|
||||
"plan2code-app/package-lock.json": JSON.stringify({
|
||||
name: "plan2code-app",
|
||||
version,
|
||||
packages: { "": { name: "plan2code-app", version } },
|
||||
}),
|
||||
"plan2code-app/src-tauri/Cargo.toml": `[package]\nname = "plan2code-app"\nversion = "${version}"\n\n[dependencies]\nserde = { version = "1" }\n`,
|
||||
"plan2code-app/fake-agent/Cargo.toml": `[package]\nname = "fake-agent"\nversion = "${version}"\n`,
|
||||
"plan2code-app/Cargo.lock": cargoLock(version, version),
|
||||
...over,
|
||||
};
|
||||
for (const [file, content] of Object.entries(files)) {
|
||||
@@ -35,10 +48,10 @@ function tree(t, version = "3.0.0", over = {}) {
|
||||
return root;
|
||||
}
|
||||
|
||||
test("versions: six files at one version pass, and each is listed", (t) => {
|
||||
test("versions: every file at one version passes, and each place is listed", (t) => {
|
||||
const result = checkVersions(tree(t));
|
||||
assert.equal(result.ok, true, result.problems.join("; "));
|
||||
assert.equal(result.versions.length, 6);
|
||||
assert.equal(result.versions.length, 12);
|
||||
assert.ok(result.versions.every((v) => v.version === "3.0.0"));
|
||||
});
|
||||
|
||||
@@ -58,6 +71,35 @@ test("versions: Cargo.toml's package version counts, a dependency's does not", (
|
||||
assert.match(checkVersions(root).problems[0], /Cargo\.toml says 3\.1\.0/);
|
||||
});
|
||||
|
||||
test("versions: README's line, a lockfile line and a fake-agent entry each disagree by name", (t) => {
|
||||
const readme = checkVersions(tree(t, "3.0.0", { "README.md": "# Plan2Code\n\nVersion 2.6.0 · MIT\n" }));
|
||||
assert.deepEqual(readme.problems, ["README.md says 2.6.0, version.json says 3.0.0"]);
|
||||
|
||||
const lock = checkVersions(
|
||||
tree(t, "3.0.0", {
|
||||
"plan2code-app/package-lock.json": JSON.stringify({ version: "3.0.0", packages: { "": { version: "2.9.0" } } }),
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(lock.problems, ['plan2code-app/package-lock.json (packages[""]) says 2.9.0, version.json says 3.0.0']);
|
||||
|
||||
const fake = checkVersions(
|
||||
tree(t, "3.0.0", { "plan2code-app/fake-agent/Cargo.toml": '[package]\nname = "fake-agent"\nversion = "2.9.0"\n' }),
|
||||
);
|
||||
assert.deepEqual(fake.problems, ["plan2code-app/fake-agent/Cargo.toml says 2.9.0, version.json says 3.0.0"]);
|
||||
});
|
||||
|
||||
test("versions: each Cargo.lock entry is read by its own name", (t) => {
|
||||
const stale = checkVersions(tree(t, "3.0.0", { "plan2code-app/Cargo.lock": cargoLock("3.0.0", "2.9.0") }));
|
||||
assert.deepEqual(stale.problems, ["plan2code-app/Cargo.lock (fake-agent) says 2.9.0, version.json says 3.0.0"]);
|
||||
const other = checkVersions(tree(t, "3.0.0", { "plan2code-app/Cargo.lock": cargoLock("2.9.0", "3.0.0") }));
|
||||
assert.deepEqual(other.problems, ["plan2code-app/Cargo.lock (plan2code-app) says 2.9.0, version.json says 3.0.0"]);
|
||||
const gone = checkVersions(
|
||||
tree(t, "3.0.0", { "plan2code-app/Cargo.lock": '[[package]]\nname = "chrono"\nversion = "0.4.0"\n' }),
|
||||
);
|
||||
assert.equal(gone.problems.length, 2);
|
||||
assert.match(gone.problems[0], /Cargo\.lock \(plan2code-app\): no version found/);
|
||||
});
|
||||
|
||||
test("versions: the changelog's top heading is the one read", (t) => {
|
||||
const root = tree(t, "3.0.0", { "CHANGELOG.md": "# Changelog\n\n## v3.1.0\n\n## v3.0.0\n" });
|
||||
assert.match(checkVersions(root).problems[0], /CHANGELOG\.md says 3\.1\.0/);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// and records every point it draws through, as in
|
||||
// scripts/test-web-console-activities-rapids.mjs.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { CAR_STYLES, MARGINS, STYLE_NAMES, carLength, carReach, drawCarBody, drawCarShadow, rgbOf, shade, styleOf } from "../src/web-console/public/activities/bounce-cars.js";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// handed, so a stub canvas stands in for the page, as in
|
||||
// scripts/test-web-console-activities.mjs, whose helpers this file copies.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as bounce from "../src/web-console/public/activities/bounce.js";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// handed, so a stub canvas stands in for the page, as in
|
||||
// scripts/test-web-console-activities.mjs, whose helpers this file copies.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as bounce from "../src/web-console/public/activities/bounce.js";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// handed, so a stub canvas stands in for the page, as in
|
||||
// scripts/test-web-console-activities-rapids.mjs, whose helpers this file copies.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as flock from "../src/web-console/public/activities/flock.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's secondary weapons: the double tap that uses one (hammering spends one at most, a hold carries on as bolts), the bag and its HUD pill, what each weapon does, what they may do to a boss, where they are placed and how they drop, and that all of it draws and sounds.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Grand Banister (the Manor's bonus round, between the Library and the Ballroom): its shape (every break clears with a jump and swallows a rider that does not jump, the brass under-rails, every low can be ducked, spacing, checkpoints, the clock), the ride's speed on slopes and its lean and brake, its jump, ducking and diving, a vase, a candlestick, a hanging frame, a chandelier on its pendulum, a ghostly butler, the cobwebs, a fall off the rail, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole stair (one that rides well, one that never dodges).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-banister.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// mud spans that slow and sink you, the Bog Runner's stub and the Drowning
|
||||
// Pool's boss spec. The monsters' rules, the fight and the ride land in
|
||||
// later phases.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Old Rattlebones: his volley and slam, the skull he throws like a boomerang (and is headless without), the bone rain and the skeletons he raises once his rage begins, the double slam, and what each move looks and sounds like.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Bone Stair (the finale's second ride, between Kill II and the Pit): its shape (the spiral's flights and seams, every gap of missing treads clears with a jump and swallows YOU without one, every ribcage can be ducked, spacing, checkpoints, the last step over the Pit's floor), the run's speed (DOWN and LEFT slow YOU), every obstacle's cost and cause (missing treads, treads giving way, ribcages, skeletons, hands, masonry, the rubble), the telegraphs (shadows, creaks and cracks, fingers over the edge, skeletons rising), shooting skeletons down, the pursuit meter (the gap that clean running opens and hits, ducks and holds close), the catch, three hearts of its own, the grade and the dice, endless lives, the finish, no random numbers, its sounds and its drawing on a fake canvas, and bots that play it well and badly.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-bonestair.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's boss intro cards: every boss room has an entry (the boss's exact name, an epithet, no em dash, never the hero's name), the card shows when a boss room is entered (after the bonus ride too) and in no other room, not again on a retry, any fresh move key, fire or click moves it on after the lockout (repeats and early presses never do), it never moves on by itself, a pause holds it, and it draws for every boss on a fake canvas (through the boss's own art, with a fallback when the art throws or is missing).
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Midnight Carnival stage: its four rooms (the Midway, the Hall of Mirrors, the Funhouse with its conveyor floors, the Big Top), grinners that honk out acid balloons, marionettes that drop on their strings, Mirror You that copies your moves and shots half a second late, strongmen that lob barbells, circus hounds that leap through hoops of fire, Cotton Candy and the Custard Pie (found only here), and the Ringmaster, whose puppet hangs on three strings: cut them all and he is open for four seconds.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Runaway Cart (the Deep Seam Mine's ride room): its shape (between the Collapse and the Seam, every gap clears at the cart's speed with a jump, every beam can be ducked, checkpoints spaced, the clock covers the ride), the cart's speed on slopes, leaning and braking, its jump and its steering in the air, a ramp's launch, landing on the upper or the lower line of a split, a fall into the chasm and the respawn at the last checkpoint, ducking under a beam, rubble, crates (two shots break one), the boulder behind, the buffer stop and the door, the ledge imp, a canary's slide of rubble, endless lives for every new cause, a voice for every event, the drawing, and a bot that rides the whole room.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-cart.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Chapel stage: its four rooms, gargoyles that are stone on their perch and dive when you pass under, choir ghosts whose song quickens the monsters near them, censer monks and their smoke, bats in the bells, the bell toll that freezes everything for a second, Holy Water (found only here), and the Choirmaster, whose organ pipes guard him and whose columns of notes have one gap each.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Lucky die: it comes only from a kill, stacks to nine and lasts the run; when a life would be lost one rolls: a 4 to 6 brings Planny back (the monsters in view blown apart in an ordinary room, a boss's room untouched; a 5 adds a heart, a 6 a heart and a Garlic shield), a 3 or 2 costs the life and leaves a gift for the respawn, a 1 only laughs.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's ending: four pages that obey the story's rules (2 to 4 short lines, no digits, no em dash, YOU on each, the gag's FINAL NOTICE); the House's last room opens it instead of the win; a press turns pages only after the lockout and finishes the typing first; holding fire skips it, a tap never does; the last page wins the run once, with n = round.winN; the window's keys, a click, a pause, its track and its sounds; every scene draws on a fake canvas at many moments; every event it raises has a react; every tone it names exists.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-ending.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// shoot apart), the kill and its retreat in order with the door kept until it has gone, a bot's
|
||||
// fight length, the voices, words and drawing.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-eye.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Frozen Lake stage: its rooms (Ice Fishing Huts, Snowbound Lodge, The Black Ice, the Widow's Web), slippery ice and thin ice that cracks and breaks, under-ice hands, snow shades you only see by their footprints, frozen ghouls that slide and shatter, ice wraiths whose dive leaves you frozen, Hot Cocoa and the Road Flare (found only here), and the Frost Widow, whose veil melts only to a burning barrel or a flare.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's game over: a lost end plays the mechanical laugh track (and a win does not), and the "G A M E - O V E R" banner drops in letter by letter and draws on a fake canvas.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Graveyard stage: its four rooms, grasping hands, mourners and their wail, grave robbers, rotters and the legs they leave, carrion crows, the graves rotters climb out of, and Mother Mourning, who can only be hurt while she watches and drops a stone fist on whatever moves.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Grounds stage: its four rooms, topiary beasts that creep only when your back is turned, rootlings under the lawn, lantern moths, mulch crawlers, the Hedge shears (found only here), and the Groundskeeper, whose lantern takes triple damage, whose scythe is jumped, whose fire burns the floor and who mounts a mower at half his hp.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Code Blue (Blackmoor Sanatorium's bonus round, between the Surgical Theater and the Night Ward): its shape (every elevator shaft clears with a jump and swallows a gurney that does not jump, every low can be ducked, spacing, the surge lamps and the blackout waves, checkpoints, the clock), the gurney's speed on slopes, its jump, ducking, a wheelchair that rolls, an IV stand, a lamp or a door overhead, an orderly in a doorway, the surge lamp shot from the air, the lights-out rhythm (the countdown, the dark, the lights back), the heartbeat monitor, a fall down a shaft, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9) and the clean-dark-stretches die, endless lives for every cause, a voice for every event, the drawing, and bots that ride the whole way (one that dodges well, one that never does).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-gurney.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Midnight Hearse (the Graveyard's bonus round, between the Mausoleum Row and Angel's Rest): its shape (two lanes, the gates, every thing spaced for a player, the closed stretches with a gate before each), the hearse's motion (a steady speed, a jump, a duck, a hop between lanes only at a gate), each obstacle and its cost (grave, headstone, cross, branch, hand, crow, wreck), the lamp and its lanterns, the coffins thrown out and the ghouls that sit up in them, the hearts and the grade and the dice, endless lives, the drawing and the sounds, and bots that play it.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-hearse.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// the weak beats that only knock it back, the white, the last thump, the fall, the daylight and its
|
||||
// door), a life lost keeping it all, a bot's fight length at full depth, the voices, words and drawing.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-heart.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's stage intro cards: every stage has one (3 or 4 lines, short, no em dash, never the hero's name), the card shows when a stage is entered and not before the pick, any move key or fire moves it on after the minimum (repeats and early presses never do) and it never moves on by itself, and it draws on a fake canvas.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Drowned Lantern (Gallows Bog's bonus round, between the Stilt House and the Drowning Pool, a top-down game on one screen and not a ride): the island, the walk and the slide, the flare and the oil, the shrines and the run to the boat, each hunter's one rule (the Lurker hears steps on wood and dashes down a lane through where it heard you, the wisps guard the shrines and burst in a flare, the leeches never enter the light, the bog bodies take only someone standing still, Old Mother Bog's hand), the hearts and the grade, the clock, determinism, the balance (a bot that ignores the hunters loses, one that plays them wins), the voices, the hums and the drawing.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-lantern.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// weighted pick, the wall in front of the house, the retreat in order and its standing door, a
|
||||
// bot's fight length, the voices, words and drawing.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-marrow.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Down the Hatch (the finale's first ride, after the Front Lawn): its shape (eleven swallows, every fork's hole swallows a rider who does not jump and its gristle ledge catches one who does, every uvula can be ducked, spacing, checkpoints every 8 to 10 seconds, the lip), the ride's speed on slopes and bile, its jump and duck, a rib, a uvula-lamp, a squeeze's throb, close and ease (peristalsis), the swallowed furniture, a plunge, the checkpoints, the lip and the door, the bonus round's three hearts and dice (3 to 8), endless lives for every cause, a voice for every event, the drawing, the telegraphs, and bots that ride the whole throat (one that rides well finishes, one that never dodges loses all three hearts without a game over).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-mat.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Deep Seam Mine stage: its four rooms (always dark, the cage lifts, the water, the rockfall), rocks that fall after a dust warning and crush monsters and cost a life, the knocker imp that steals your light but never a life, the canary ghost whose scream brings three rocks down, the dead miner that digs out of the wall, the blind crawler that hunts by sound, the cage you can ride, the Hard Hat and Dynamite (found only here), and the Tommyknocker, who knocks, sweeps his hammer, puts the lights out, sinks into the seam and bursts out dazed, and rages at half his hp.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Gardener's Revenge (the Grounds' bonus round, between the Gazebo and the Groundskeeper's Yard): its shape (every pond and ditch clears with a jump and swallows a mower that does not jump, every low can be ducked), the mower's motion, each obstacle's cost and cause, the blades (cutting, the heat, the jam, the lawn cut), the topiary beasts, the hearts, the checkpoints, the finish and the dice, endless lives, the art on a fake canvas, and the two bots (one that plays well finishes in time, one that never dodges loses).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-mower.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Holy Roller (the Chapel's bonus round, between the Organ Loft and the Choir): an endless-runner seen from behind, in three lanes. Its room and its seeded course (every thing in the way has a safe answer, a safe path exists at every moment), the speed ramp, the lanes and the wall bump, the jump and the slide, each kind of obstacle's cost and cause, the gargoyles and the bell ropes, the wax souls, the combo and the halo's magnet, the grade, the last heart ending the round with the run going on, endless lives, the Garlic shield, the sounds and words, the drawing on a fake canvas, and bots that play it well and badly.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-pew.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Web console tests, Ghoul Rush's retry mercy: after a loss in a room, each restart of it sets one power-up a few steps ahead of Planny (never the first attempt, never in a ride or bonus room), the kind from its own hash so no shared roll shifts, on a firm surface, replacing the last one uncollected, reset when the room is cleared.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-retry.mjs
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's dark ride (the Midnight Carnival's bonus round): its place (between the funhouse and the Big Top), the bonus round's five hearts and the flow on to the boss, the dice rule, the controls (arrows, Space, the mouse, the duck zone), aim assist, the mini-bosses, the Exit's twist, a bot that rides it all and one that does nothing, the endless-lives code, and every event voiced.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-ride.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Blackmoor Sanatorium stage: its four rooms, orderlies that grab and throw you (and cost no life), gurneys that park, rattle and roll, flickers you can only hit and be hurt by when the lamps go out, specimen bloaters and their formaldehyde, the lamps' flicker, Smelling Salts and the Bone Saw (found only here), and the Night Matron, whose lantern cone builds heat, is stopped by the medicine cabinets and cannot reach the boards, with her syringes, arms and rage.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Coffin Sled (the Frozen Lake's bonus round, between the Black Ice and the Widow's Web): its shape (every crack clears with a jump and swallows a sled that does not jump, every low can be ducked, spacing, checkpoints, the clock), the sled's speed on slopes, its jump, ducking, a headstone, a drift, a branch, a hand in the snow, the ghoul that pops up and the icicles (bolts that follow the hill), a fall into a crack, the checkpoint, the jump off the end and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole hill (one that dodges well, one that never does).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-sled.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's intro story: 6 to 8 pages that fit the field, never name the hero, stay generic about stages (no names, no counts) and speak to YOU; a run opens on it and ends in The Long Hall; the lockout, the typing that finishes first, every key and a click, the skip by holding fire, a pause that holds it; never in the practice stage select, on a respawn or in a new room; every page draws on a fake canvas at many moments; every sound it asks for exists.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Servants' Back Stairs (the East Wing's bonus round, between the Attic and the Crypt): its shape (every gap between flights clears with a jump and swallows a tray that does not jump, every low can be ducked, spacing, checkpoints, greased stretches, the clock), the tray's speed on slopes and grease, its jump and duck, a pot, cutlery, a ham, pans, the cook's dish, the domes and plates (the courses), the cherries, a fall down the stairs, the checkpoint, the jump off the last shelf and the door, the bonus round's hearts and dice (3 to 9), endless lives for every new cause, a voice for every event, the drawing, and bots that ride the whole route (one that dodges well, one that never does).
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-tray.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Web console tests, Ghoul Rush's Hollow End Village stage: its four rooms, the moonrise (a moon that climbs over each room and, at full, turns the villagers into wolf-men and makes the moonhounds grow), torch mob villagers that lob fire, hanged men that drop on their ropes, shutter ghouls that can be hit only while out, moonhounds, Wolfsbane (found only here), and the Beast of Hollow End, which clings to the wall for double damage, pounces under a shadow, swipes, howls for hounds and rages at half its hp.
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Web console tests, Ghoul Rush's Torch Mob (Hollow End Village's bonus round, between the Square and the Green): its shape (every ditch and the bridge clear with a jump and swallow a wagon that does not jump, every low can be ducked, spacing, checkpoints), the wagon's speed (the brake that is also a duck), every obstacle's cost and cause (barrels, crates, washing lines, inn signs, pitchforks, torches, horses, ditches, the river, the mob), the throwers' wind-up and aim, shooting torches and forks out of the air, the horses, the pursuit meter (the gap that clean riding opens and braking, hits and fire close), the hay fire, the catch, hearts of its own, the grade and the dice, endless lives, the checkpoints, the finish, no random numbers, its sounds and its drawing on a fake canvas, and bots that play it well and badly.
|
||||
// Run with: node --test scripts/test-web-console-activities-ghoul-wagon.mjs
|
||||
import "./seed-random.mjs";
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as ghoul from "../src/web-console/public/activities/ghoul-rush/ghoul.js";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// handed, so stub canvases that count or record calls stand in for the page.
|
||||
// The rules are plain functions over a round, driven here slice by slice.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// handed, so a stub canvas stands in for the page, as in
|
||||
// scripts/test-web-console-activities.mjs, whose helpers this file copies.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import * as rapids from "../src/web-console/public/activities/rapids.js";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// walks every entry in ACTIVITIES plus a stub second game defined here, which
|
||||
// is what proves a new game needs no change to the window.
|
||||
|
||||
import "./seed-random.mjs";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// The Dashboard's AGENTS.md tab: which files the server will read for it.
|
||||
// Run with: node --test scripts/test-web-console-agents-doc.mjs
|
||||
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { readAgentsDoc } from "../src/web-console/sessions.mjs";
|
||||
|
||||
function project(files) {
|
||||
const base = fs.mkdtempSync(path.join(os.tmpdir(), "p2c-agents-doc-"));
|
||||
const root = path.join(base, "project");
|
||||
for (const [rel, text] of Object.entries(files)) {
|
||||
fs.mkdirSync(path.dirname(path.join(root, rel)), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, rel), text);
|
||||
}
|
||||
fs.mkdirSync(root, { recursive: true });
|
||||
fs.writeFileSync(path.join(base, "secret.md"), "outside\n");
|
||||
return { base, root };
|
||||
}
|
||||
|
||||
test("readAgentsDoc reads AGENTS.md and one markdown file under .agents-docs", async () => {
|
||||
const { base, root } = project({ "AGENTS.md": "# Guide\n", ".agents-docs/AGENTS-x.md": "# X\n" });
|
||||
try {
|
||||
assert.deepEqual(await readAgentsDoc(root, "AGENTS.md"), { file: "AGENTS.md", text: "# Guide\n" });
|
||||
assert.deepEqual(await readAgentsDoc(root, ".agents-docs/AGENTS-x.md"), { file: ".agents-docs/AGENTS-x.md", text: "# X\n" });
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("readAgentsDoc is null for a missing file and for any other path", async () => {
|
||||
const { base, root } = project({ "AGENTS.md": "# Guide\n", "README.md": "readme\n", ".agents-docs/sub/deep.md": "deep\n", ".agents-docs/notes.txt": "t\n" });
|
||||
try {
|
||||
const refused = [
|
||||
"README.md",
|
||||
"agents.md",
|
||||
"../secret.md",
|
||||
".agents-docs/../secret.md",
|
||||
".agents-docs/sub/deep.md",
|
||||
".agents-docs/notes.txt",
|
||||
".agents-docs/missing.md",
|
||||
".agents-docs\AGENTS-x.md",
|
||||
path.join(base, "secret.md"),
|
||||
"",
|
||||
null,
|
||||
];
|
||||
for (const rel of refused) assert.equal(await readAgentsDoc(root, rel), null, String(rel));
|
||||
assert.equal(await readAgentsDoc("", "AGENTS.md"), null);
|
||||
fs.rmSync(path.join(root, "AGENTS.md"));
|
||||
assert.equal(await readAgentsDoc(root, "AGENTS.md"), null);
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("readAgentsDoc does not follow a link out of the project root", async (t) => {
|
||||
const { base, root } = project({ "AGENTS.md": "# Guide\n" });
|
||||
try {
|
||||
fs.mkdirSync(path.join(root, ".agents-docs"), { recursive: true });
|
||||
try {
|
||||
fs.symlinkSync(path.join(base, "secret.md"), path.join(root, ".agents-docs", "leak.md"));
|
||||
} catch {
|
||||
return t.skip("symlinks are not allowed here");
|
||||
}
|
||||
assert.equal(await readAgentsDoc(root, ".agents-docs/leak.md"), null);
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
@@ -86,6 +86,15 @@ test("the session cookie is Strict standalone and None; Secure under embed", asy
|
||||
assert.match(embedded, /SameSite=None; Secure/);
|
||||
});
|
||||
|
||||
// WebKit (the app on Linux and macOS) drops a Secure cookie sent over plain
|
||||
// http, so the page in the app's frame got a 403 after the sign-in.
|
||||
test("the session cookie is Lax and never Secure under the tauri://localhost embed", async () => {
|
||||
const embedded = await cookieWith("tauri://localhost");
|
||||
assert.match(embedded, /SameSite=Lax/);
|
||||
assert.doesNotMatch(embedded, /Secure/);
|
||||
assert.match(embedded, /HttpOnly/);
|
||||
});
|
||||
|
||||
test("anything but exactly one allowed origin keeps frame-ancestors 'none'", async () => {
|
||||
const rejected = [
|
||||
"https://example.com",
|
||||
|
||||
@@ -364,18 +364,23 @@ test("framed, an Activities game in full screen asks the app for the whole scree
|
||||
await s.page.locator('.activities-card[data-activity="snake"]').click();
|
||||
await s.page.locator("#activities-board").waitFor();
|
||||
const told = async () => (await toApp(s, "activities-full")).map((m) => m.on);
|
||||
await s.page.keyboard.press("f");
|
||||
// Each key asks the browser for its own full screen too, and the browser answers a moment
|
||||
// later: keys fired faster than a person could press them let a late answer to one undo the
|
||||
// next (seen on slow runners). Pace them: wait for the message to the app, then let the
|
||||
// browser settle.
|
||||
const pace = async (key, count) => {
|
||||
await s.page.keyboard.press(key);
|
||||
await until(async () => (await told()).length >= count, 5000);
|
||||
await s.page.waitForTimeout(250);
|
||||
};
|
||||
await pace("f", 1);
|
||||
assert.deepEqual(await told(), [true], "a named request with one boolean");
|
||||
await s.page.keyboard.press("f");
|
||||
await s.page.keyboard.press("f");
|
||||
await s.page.keyboard.press("Escape");
|
||||
await pace("f", 2);
|
||||
await pace("f", 3);
|
||||
await pace("Escape", 4);
|
||||
assert.deepEqual(await told(), [true, false, true, false], "F and Esc each give it back");
|
||||
// The focus comes back to the board a moment after leaving full screen: an F pressed before
|
||||
// that goes nowhere (seen on slow runners).
|
||||
await s.page.waitForFunction(() => document.activeElement && document.activeElement.id === "activities-board");
|
||||
await s.page.keyboard.press("f");
|
||||
await pace("f", 5);
|
||||
s.post({ items: [{ id: "q2", kind: "text", title: "Who uses it", body: "Who opens the export?" }], agent: { status: "waiting" } });
|
||||
// Wait for both new messages: the list already ends in false, so checking only its last item passed at once.
|
||||
await until(async () => (await told()).length >= 6, 5000);
|
||||
assert.deepEqual(await told(), [true, false, true, false, true, false], "and so does a new question");
|
||||
});
|
||||
|
||||
@@ -187,7 +187,7 @@ test("shape: no page module sets a style attribute from script", () => {
|
||||
// and WORKSPACE_EDITS for /workspace/add, /edit and /remove. The git board has
|
||||
// no routes of its own: its buttons are sends (`__git`), through /submit.
|
||||
const ROUTE_ORDER = [
|
||||
"/health", "/s/", "/handover", "/", "SERVABLE", "/overview", "/handoff", "/version", "/state", "/events", "/draft",
|
||||
"/health", "/s/", "/handover", "/", "SERVABLE", "/overview", "/agents-doc", "/handoff", "/version", "/state", "/events", "/draft",
|
||||
"/looks", "/looks", "/subagents", "/pr-host", "/models", "/models", "/agents", "/agents", "/agents/test", "/agents/use-path", "/cleanup", "/upload",
|
||||
"/notepad", "/notepad/text", "/notepad/image", "/notepad/thumb", "/notepad/image/delete", "/notepad/tab",
|
||||
"/notepad/tab/rename", "/notepad/tab/delete", "/notepad/tab/order", "/notepad/tab/last", "/notepad/tab/sent", "/notepad/images/",
|
||||
|
||||
@@ -64,6 +64,11 @@ function takeMarker(item) {
|
||||
return TASK_MARKERS[m[1]];
|
||||
}
|
||||
|
||||
// While md() runs with a `link` option: a function that takes a link's href and
|
||||
// returns a click handler to make it an in-page link, or null to leave it to the
|
||||
// usual rules. Set only for the duration of one md() call.
|
||||
let linkHook = null;
|
||||
|
||||
function safeHref(href) {
|
||||
if (!href) return null;
|
||||
const trimmed = String(href).trim();
|
||||
@@ -117,6 +122,19 @@ function inlineInto(parent, tokens) {
|
||||
parent.appendChild(document.createElement("br"));
|
||||
break;
|
||||
case "link": {
|
||||
const onOpen = linkHook && linkHook(String(t.href || "").trim());
|
||||
if (onOpen) {
|
||||
const a = el("a");
|
||||
a.href = "#";
|
||||
a.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
onOpen();
|
||||
});
|
||||
if (t.title) a.title = t.title;
|
||||
inlineInto(a, t.tokens);
|
||||
parent.appendChild(a);
|
||||
break;
|
||||
}
|
||||
const href = safeHref(t.href);
|
||||
if (!href) {
|
||||
inlineInto(parent, t.tokens);
|
||||
@@ -288,7 +306,7 @@ function blockInto(parent, tokens) {
|
||||
}
|
||||
|
||||
/** Render markdown into a fresh element. Returns the element. */
|
||||
export function md(source, className = "md") {
|
||||
export function md(source, className = "md", options = {}) {
|
||||
const host = el("div", className);
|
||||
if (!source) return host;
|
||||
let tokens;
|
||||
@@ -298,7 +316,13 @@ export function md(source, className = "md") {
|
||||
host.appendChild(el("p", "md-p", String(source)));
|
||||
return host;
|
||||
}
|
||||
blockInto(host, tokens);
|
||||
// `options.link`: see linkHook above.
|
||||
linkHook = typeof options.link === "function" ? options.link : null;
|
||||
try {
|
||||
blockInto(host, tokens);
|
||||
} finally {
|
||||
linkHook = null;
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import { helperRows, showTab } from "../subagents.js";
|
||||
import { FOOTER_TIERS, footerLabel } from "../workspace.js";
|
||||
import {
|
||||
activity, agentAdrift, agentWorking, askBusy, loopDriving, loopWaiting, loopWaitingKey, asked, awaitingReply, byId, dashboardLive, docs, doingNow,
|
||||
finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadOverview, myTurn, openItems,
|
||||
AGENTS_VIEW, agentsTabShown, finish, gitAwaiting, isDashboard, isGitBoard, isOpen, isSpecFileView, items, loadAgentsDoc, loadOverview, myTurn, openItems,
|
||||
patience, pressStranded, reviewPending, scan, selSpec, sendCollected, specFileTabs, stagedCount, stranded,
|
||||
topics, workingMs, WORKING_GRACE_MS,
|
||||
workspaceFolders,
|
||||
@@ -67,7 +67,7 @@ import { attachFiles, heldNotes, noteImages, pendingNotes, removeImage } from ".
|
||||
import { closeMentions } from "../mention-box.js";
|
||||
import { buildPager, fitGrowBox, markFor, markMore, renderCard, renderEndItem, renderNotice } from "./cards.js";
|
||||
import { sendState, suggestState } from "../send-state.js";
|
||||
import { renderBriefButton, renderDoc, renderOverview } from "./docs.js";
|
||||
import { renderAgentsDoc, renderBriefButton, renderDoc, renderOverview } from "./docs.js";
|
||||
import { board, renderGitBoard, resetBoard } from "./git-host.js";
|
||||
import { renderWorkspace, tellFolderIssues } from "./workspace.js";
|
||||
import { openHelpOn } from "./help-dialog.js";
|
||||
@@ -535,6 +535,8 @@ export function adopt(body) {
|
||||
// A spec file tab's file changes under a build, so a tab you are watching
|
||||
// refetches on every new frame too, not only on the click that opened it.
|
||||
if (firstLoad || page.S.specDir !== prevSpecDir || page.S.workflow !== prevWorkflow || isSpecFileView(page.view)) loadOverview();
|
||||
// The Dashboard's AGENTS.md tab: found on arrival, re-read while it is open.
|
||||
if (firstLoad || page.S.workflow !== prevWorkflow || page.view === AGENTS_VIEW) loadAgentsDoc();
|
||||
if (announce) showArrival(announce);
|
||||
// New entries land at the bottom of the rail. Gliding down to them beats
|
||||
// leaving the list parked where it was while it grew underneath.
|
||||
@@ -991,7 +993,7 @@ function withFocus(fn) {
|
||||
// (the dashboard menu, the end page).
|
||||
function currentScroller() {
|
||||
if (!drawnView) return null;
|
||||
if (drawnView.startsWith("doc:") || isSpecFileView(drawnView)) return $("main");
|
||||
if (drawnView.startsWith("doc:") || isSpecFileView(drawnView) || drawnView === AGENTS_VIEW) return $("main");
|
||||
if (drawnView === "questions") return $("main").querySelector(":scope > .card.question");
|
||||
if (drawnView === "ask") return $("main").querySelector(".ask-list");
|
||||
return null;
|
||||
@@ -1430,6 +1432,10 @@ function renderViews() {
|
||||
const fileTabs = specFileTabs();
|
||||
for (const f of fileTabs) tabs.push({ id: f.id, label: f.label, count: 0 });
|
||||
if (isSpecFileView(page.view) && !fileTabs.some((f) => f.id === page.view)) page.view = "questions";
|
||||
// Right after Dashboard: the project's AGENTS.md, present while the file is.
|
||||
// Like a spec file tab, it sends the person home if the file goes away.
|
||||
if (agentsTabShown()) tabs.splice(1, 0, { id: AGENTS_VIEW, label: "AGENTS.md", count: 0 });
|
||||
else if (page.view === AGENTS_VIEW) page.view = "questions";
|
||||
for (const d of docs()) tabs.push({ id: "doc:" + d.id, label: d.title || "Document", count: 0 });
|
||||
// The helpers the agent reported, from the first one on; cleared by a
|
||||
// dashboard hop, which sends the person home like the Overview tab does.
|
||||
@@ -1482,6 +1488,10 @@ function renderViews() {
|
||||
// changed on disk since.
|
||||
render();
|
||||
if (isSpecFileView(t.id)) loadOverview();
|
||||
if (t.id === AGENTS_VIEW) {
|
||||
page.agentsDoc.open = "AGENTS.md";
|
||||
loadAgentsDoc();
|
||||
}
|
||||
});
|
||||
nav.appendChild(b);
|
||||
}
|
||||
@@ -1616,7 +1626,7 @@ function renderMain() {
|
||||
}
|
||||
|
||||
function paintMain(main) {
|
||||
main.classList.toggle("is-doc", page.view.startsWith("doc:") || isSpecFileView(page.view));
|
||||
main.classList.toggle("is-doc", page.view.startsWith("doc:") || isSpecFileView(page.view) || page.view === AGENTS_VIEW);
|
||||
main.classList.toggle("is-ask", page.view === "ask");
|
||||
|
||||
// An agent-less session has no questions, docs or board to draw: its whole
|
||||
@@ -1625,6 +1635,7 @@ function paintMain(main) {
|
||||
|
||||
if (page.view.startsWith("doc:")) return renderDoc(main, page.view.slice(4));
|
||||
if (isSpecFileView(page.view)) return renderOverview(main, page.view);
|
||||
if (page.view === AGENTS_VIEW) return renderAgentsDoc(main);
|
||||
if (page.view === "ask") return renderAsk(main);
|
||||
if (page.view === "subagents") return renderSubagents(main);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Plan2Code Web Console - documents: tabs, blocks, print and download, and the brief button; defines only.
|
||||
|
||||
import { docs, agentWorking, workingMs, patience, WORKING_GRACE_MS, finish, SPEC_FILES } from "../selectors.js";
|
||||
import { docs, agentWorking, workingMs, patience, WORKING_GRACE_MS, finish, SPEC_FILES, loadAgentsDoc } from "../selectors.js";
|
||||
import { el, md } from "../render.js";
|
||||
import { downloadDocHtml, docSavedNote, downloadDoc, blockBody } from "../doc-files.js";
|
||||
import { hooks, page, redraw } from "../state.js";
|
||||
@@ -239,6 +239,64 @@ export function renderOverview(main, kind = "overview") {
|
||||
main.appendChild(box);
|
||||
}
|
||||
|
||||
// The files the AGENTS.md tab may show: the same two shapes the server serves.
|
||||
const AGENTS_FILE = /^(?:AGENTS\.md|\.agents-docs\/[A-Za-z0-9._-]+\.md)$/;
|
||||
|
||||
// A link in an agent-guide file, resolved against the file it sits in: the
|
||||
// guide's own name when it points at another agent-guide file, else null (an
|
||||
// outside link keeps the usual rules).
|
||||
export function agentsLinkTarget(from, href) {
|
||||
if (!href || /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("#") || href.startsWith("/")) return null;
|
||||
try {
|
||||
const u = new URL(href, "http://guide.invalid/" + from);
|
||||
const rel = decodeURIComponent(u.pathname.slice(1));
|
||||
return AGENTS_FILE.test(rel) ? rel : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// The Dashboard's AGENTS.md tab: the project's agent guide, read-only, straight
|
||||
// from disk. A link to another guide file (.agents-docs/...) opens in place,
|
||||
// with a way back to AGENTS.md.
|
||||
export function renderAgentsDoc(main) {
|
||||
const { open, texts } = page.agentsDoc;
|
||||
const head = el("div", "doc-head");
|
||||
head.appendChild(el("h2", null, open === "AGENTS.md" ? "AGENTS.md" : open));
|
||||
const tools = el("div", "doc-tools");
|
||||
if (open !== "AGENTS.md") {
|
||||
const guide = el("button", "btn small", "Back to AGENTS.md");
|
||||
guide.type = "button";
|
||||
guide.addEventListener("click", () => {
|
||||
page.agentsDoc.open = "AGENTS.md";
|
||||
redraw();
|
||||
main.scrollTop = 0;
|
||||
});
|
||||
tools.appendChild(guide);
|
||||
}
|
||||
tools.appendChild(backButton());
|
||||
tools.appendChild(printButton());
|
||||
head.appendChild(tools);
|
||||
main.appendChild(head);
|
||||
main.appendChild(el("p", "help", open + " · read-only, straight from disk"));
|
||||
const box = el("div", "block settled");
|
||||
box.appendChild(
|
||||
md(texts[open] || "", "md", {
|
||||
link: (href) => {
|
||||
const rel = agentsLinkTarget(open, href);
|
||||
if (!rel) return null;
|
||||
return () => {
|
||||
page.agentsDoc.open = rel;
|
||||
redraw();
|
||||
main.scrollTop = 0;
|
||||
loadAgentsDoc();
|
||||
};
|
||||
},
|
||||
})
|
||||
);
|
||||
main.appendChild(box);
|
||||
}
|
||||
|
||||
// The brief dialog's buttons, wired once at start-up.
|
||||
export function wireDocs() {
|
||||
$("btn-brief").addEventListener("click", openBrief);
|
||||
|
||||
@@ -333,5 +333,46 @@ export async function loadOverview() {
|
||||
if (changed) redraw();
|
||||
}
|
||||
|
||||
// The Dashboard's AGENTS.md tab: its view id, and whether it is on now (the
|
||||
// dashboard, with an AGENTS.md the last read found).
|
||||
export const AGENTS_VIEW = "agents-md";
|
||||
export const agentsTabShown = () => isDashboard() && typeof page.agentsDoc.texts["AGENTS.md"] === "string";
|
||||
|
||||
// Read one agent-guide file fresh from disk (`rel` as the server names it) and
|
||||
// keep its text; null when it is not there. Off the dashboard nothing is read.
|
||||
async function fetchAgentsDoc(rel) {
|
||||
try {
|
||||
const res = await fetch("/agents-doc?file=" + encodeURIComponent(rel), { cache: "no-store" });
|
||||
return res.status === 200 ? await res.text() : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Fresh from disk every time, like the spec file tabs: AGENTS.md changes under
|
||||
// init-update, and the tab is only worth having if it shows what is there now.
|
||||
// Reads AGENTS.md (does the tab exist?) and, when a linked file is open, that
|
||||
// file too. Repaints only when a tab would appear or vanish or a text changed.
|
||||
export async function loadAgentsDoc() {
|
||||
if (!isDashboard()) {
|
||||
if (Object.keys(page.agentsDoc.texts).length) page.agentsDoc = { open: "AGENTS.md", texts: {} };
|
||||
return;
|
||||
}
|
||||
const open = page.agentsDoc.open;
|
||||
const rels = open === "AGENTS.md" ? ["AGENTS.md"] : ["AGENTS.md", open];
|
||||
const found = await Promise.all(rels.map(fetchAgentsDoc));
|
||||
// The person moved on (Back to AGENTS.md) while this was in flight.
|
||||
if (!isDashboard() || page.agentsDoc.open !== open) return;
|
||||
const texts = {};
|
||||
rels.forEach((rel, i) => {
|
||||
if (typeof found[i] === "string") texts[rel] = found[i];
|
||||
});
|
||||
// A linked file that went missing: back to AGENTS.md itself.
|
||||
const next = { open: texts[open] === undefined ? "AGENTS.md" : open, texts };
|
||||
const changed = JSON.stringify(next) !== JSON.stringify(page.agentsDoc);
|
||||
page.agentsDoc = next;
|
||||
if (changed) redraw();
|
||||
}
|
||||
|
||||
// The workspace's folders, original first, or none before a frame has them.
|
||||
export const workspaceFolders = () => (page.wsFrame && Array.isArray(page.wsFrame.folders) ? page.wsFrame.folders : []);
|
||||
@@ -136,6 +136,10 @@ export const page = {
|
||||
// for, `files` maps each SPEC_FILES kind (overview, map, draft) that exists
|
||||
// to `{ file, text }`. See loadOverview().
|
||||
overview: { key: null, files: {} },
|
||||
// The Dashboard's AGENTS.md tab: `texts` maps each agent-guide file read so
|
||||
// far (AGENTS.md, .agents-docs/<name>.md) to its text, `open` is the one in
|
||||
// view. The tab exists while texts["AGENTS.md"] does. See loadAgentsDoc().
|
||||
agentsDoc: { open: "AGENTS.md", texts: {} },
|
||||
// The dashboard's first-open wake-up (boot.js), while it runs. `cards` turns
|
||||
// true at the glide, which lets the menu in; `entered` once its entrance has
|
||||
// played; `typed` is how many characters of the note show, or null once all
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
} from "./files.mjs";
|
||||
import { AGENTS_SCHEMA, makeId, normalizeAgents, resolveCommand, validateForSave } from "./agents.mjs";
|
||||
import { findAgent, loadAgentList } from "./agent-lookup.mjs";
|
||||
import { checkDocument, cleanupFindings, readSpecFile, removeCleanup } from "./sessions.mjs";
|
||||
import { checkDocument, cleanupFindings, readAgentsDoc, readSpecFile, removeCleanup } from "./sessions.mjs";
|
||||
import { SHOTS_DIR_NAME, SHOT_NAME, shotType } from "./patches.mjs";
|
||||
import { appendChat, currentConversation, pendingChatCount, typedCount } from "./inbox.mjs";
|
||||
import { specKey } from "./workspace.mjs";
|
||||
@@ -85,6 +85,7 @@ const ROUTES = [
|
||||
{ path: "/", method: "GET", run: page },
|
||||
{ match: (p, req) => req.method === "GET" && SERVABLE.has(p.slice(1)), run: publicFile },
|
||||
{ path: "/overview", method: "GET", run: overview },
|
||||
{ path: "/agents-doc", method: "GET", run: agentsDoc },
|
||||
{ path: "/handoff", method: "GET", run: handoffDoc },
|
||||
{ path: "/version", method: "GET", run: version },
|
||||
{ path: "/state", method: "GET", run: stateGet },
|
||||
@@ -189,19 +190,33 @@ function signIn(req, res, ctx, url) {
|
||||
const given = url.pathname.slice(3).replace(/\/$/, "");
|
||||
if (!ctx.token || !timingSafeEq(given, ctx.token)) return send(res, 403, "Not found", "text/plain");
|
||||
ctx.touch();
|
||||
// Inside the app's frame the page is cross-site, and SameSite=Strict would
|
||||
// never be sent back, so embed mode loosens the cookie to None; Secure, which
|
||||
// loopback counts as a trustworthy origin for. Anywhere else it stays Strict.
|
||||
res.writeHead(
|
||||
302,
|
||||
baseHeaders({
|
||||
location: "/",
|
||||
"set-cookie": `${cookieName(ctx)}=${ctx.token}; HttpOnly; ${embedAncestor() === "'none'" ? "SameSite=Strict" : "SameSite=None; Secure"}; Path=/`,
|
||||
"set-cookie": `${cookieName(ctx)}=${ctx.token}; HttpOnly; ${cookieSameSite(embedAncestor())}; Path=/`,
|
||||
})
|
||||
);
|
||||
return res.end();
|
||||
}
|
||||
|
||||
// The cookie's SameSite (and Secure) for the frame the page is drawn in.
|
||||
// Standalone it stays Strict. Inside the app's frame the page is cross-site,
|
||||
// where Strict would never be sent back:
|
||||
// - WebView2 (Windows, http(s)://tauri.localhost) sends only a None cookie
|
||||
// into a cross-site frame, and None needs Secure, which Chromium accepts
|
||||
// over http because it counts loopback as a trustworthy origin.
|
||||
// - WebKit (Linux and macOS, tauri://localhost) drops a Secure cookie that
|
||||
// arrives over plain http, so None; Secure never comes back and every
|
||||
// request after the sign-in is a 403: the app shows "its page did not show
|
||||
// in this window". Lax, without Secure, is kept and sent there (measured in
|
||||
// WebKitGTK 2.52 under both its cookie policies).
|
||||
function cookieSameSite(ancestor) {
|
||||
if (ancestor === "'none'") return "SameSite=Strict";
|
||||
if (ancestor === "tauri://localhost") return "SameSite=Lax";
|
||||
return "SameSite=None; Secure";
|
||||
}
|
||||
|
||||
// The setup session's hand-over: a launcher process opened this session's
|
||||
// /s/ link in its own web view, then POSTs here so the launcher's setup page
|
||||
// (the caller's own console) can move that tab to the new session. Only a
|
||||
@@ -405,6 +420,29 @@ function overview(req, res, ctx, url) {
|
||||
.catch(noOverview);
|
||||
}
|
||||
|
||||
// The project's AGENTS.md (or one file under .agents-docs/), read-only, for the
|
||||
// dashboard's AGENTS.md tab. Only a dashboard serves it, and only the two
|
||||
// shapes readAgentsDoc() allows; anything else, or a missing file, is a 204
|
||||
// (no tab) so the browser console stays free of a failed request.
|
||||
function agentsDoc(req, res, ctx, url) {
|
||||
const state = ctx.readState() || {};
|
||||
const none = () => {
|
||||
res.writeHead(204, baseHeaders({ "cache-control": "no-store" }));
|
||||
res.end();
|
||||
};
|
||||
if (state.workflow !== "dashboard") return none();
|
||||
readAgentsDoc(state.worktree || state.project, url.searchParams.get("file") || "AGENTS.md")
|
||||
.then((found) =>
|
||||
found
|
||||
? send(res, 200, found.text, "text/markdown; charset=utf-8", {
|
||||
"cache-control": "no-store",
|
||||
"x-spec-file": encodeURIComponent(found.file),
|
||||
})
|
||||
: none()
|
||||
)
|
||||
.catch(none);
|
||||
}
|
||||
|
||||
// A handoff's document, read-only, for the dashboard's "Read it all". Only a
|
||||
// dashboard serves it, and only an id its own scan listed: a used or unknown
|
||||
// id, or anything that is not a bare handoff id, is a 404.
|
||||
|
||||
@@ -540,6 +540,28 @@ export async function readSpecFile(root, specDir, kind) {
|
||||
}
|
||||
}
|
||||
|
||||
// The project's agent guide as the Dashboard's AGENTS.md tab shows it: only
|
||||
// AGENTS.md itself or one markdown file directly under .agents-docs/, never any
|
||||
// other path. Kept inside the root by realpath, like readSpecFile().
|
||||
const AGENTS_DOC_RE = /^(?:AGENTS\.md|\.agents-docs\/[A-Za-z0-9._-]+\.md)$/;
|
||||
|
||||
/**
|
||||
* `{ file, text }` for an allowed agent-guide file (`rel` as written, with `/`
|
||||
* separators), or null when it is not allowed, missing or outside the root.
|
||||
*/
|
||||
export async function readAgentsDoc(root, rel) {
|
||||
if (!root || typeof rel !== "string" || !AGENTS_DOC_RE.test(rel)) return null;
|
||||
try {
|
||||
const file = path.resolve(root, ...rel.split("/"));
|
||||
const [realFile, realRoot] = await Promise.all([fs.promises.realpath(file), fs.promises.realpath(root)]);
|
||||
const inside = path.relative(realRoot, realFile);
|
||||
if (!inside || inside === ".." || inside.startsWith(".." + path.sep) || path.isAbsolute(inside)) return null;
|
||||
return { file: rel, text: await fs.promises.readFile(realFile, "utf8") };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// The line every CLI command hands the agent to end its terminal messages with.
|
||||
// Under the desktop app the page is already in the window beside the terminal,
|
||||
// so the address would only be noise there: the line points at the window.
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Plan2Code",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.3",
|
||||
"description": "A structured 4-step workflow methodology for AI-assisted software development",
|
||||
"keywords": [
|
||||
"ai",
|
||||
@@ -17,6 +17,6 @@
|
||||
"url": "https://github.com/jparkerweb/plan2code"
|
||||
},
|
||||
"homepage": "https://github.com/jparkerweb/plan2code",
|
||||
"releaseDate": "2026-11-05",
|
||||
"releaseDate": "2026-11-06",
|
||||
"mode": "utility"
|
||||
}
|
||||
Reference in new issue
Block a user