From bb5bd5986dfee3b457472e37b30dabf6f107689c Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Fri, 13 Nov 2026 23:29:12 -0800 Subject: [PATCH] Add Learning, move tool folders under .plan2code, and the Loop, Snake and console changes AI Assisted --- .../AGENTS-architecture-console-design.md | 5 +- .../AGENTS-architecture-console-page.md | 12 +- .agents-docs/AGENTS-architecture-console.md | 11 +- .agents-docs/AGENTS-architecture-install.md | 10 +- .../AGENTS-architecture-skill-scripts.md | 16 +- .agents-docs/AGENTS-architecture.md | 1 + .agents-docs/AGENTS-plan2code-metrics.md | 2 +- .agents-docs/AGENTS-test-map.md | 3 + .gitignore | 4 +- .readme/web-console.md | 150 +- AGENTS.md | 6 +- install.js | 101 +- package.json | 2 +- plan2code-app/src-tauri/src/loop_driver.rs | 212 +- plan2code-metrics/README.md | 14 +- plan2code-metrics/src/cli.ts | 6 +- scripts/capture-screenshots.mjs | 13 +- scripts/skill-script-helpers.mjs | 12 +- scripts/test-console-wire-budgets.mjs | 11 +- scripts/test-lanes.json | 5 + scripts/test-script-dead-code.mjs | 46 +- scripts/test-script-lessons.mjs | 2177 +++++++++++++++ scripts/test-skill-scripts.mjs | 24 +- scripts/test-web-console-activities.mjs | 183 +- scripts/test-web-console-learning.mjs | 277 ++ scripts/test-web-console-logic.mjs | 206 +- scripts/test-web-console-loop.mjs | 35 + scripts/test-web-console-page-learning.mjs | 485 ++++ scripts/test-web-console-page-loop.mjs | 41 + scripts/test-web-console-pointers.mjs | 12 + scripts/test-web-console-server.mjs | 6 +- scripts/test-web-console-session.mjs | 9 +- scripts/test-web-console-shape.mjs | 2 +- scripts/test-web-console-speed.mjs | 2 +- scripts/web-console-test-helpers.mjs | 6 +- src/plan2code-0-pathfinder.md | 2 + src/plan2code-1-plan.md | 3 + src/plan2code-1b-revise-plan.md | 1 + src/plan2code-2-document.md | 1 + src/plan2code-3-implement-review.md | 3 +- src/plan2code-3-implement.md | 5 +- src/plan2code-4-finalize.md | 1 + src/plan2code-dead-code-scripts/dead-code.mjs | 22 +- src/plan2code-dead-code.md | 8 +- src/plan2code-diagnose.md | 4 + src/plan2code-pr-prep.md | 2 + src/plan2code-quick-task.md | 5 + src/plan2code-review.md | 5 + src/plan2code-test.md | 4 + src/plan2code-ui-prototype.md | 2 + src/plan2code-xray.md | 4 + src/plan2code.md | 34 +- src/shared-references/lessons.md | 81 + src/skill-scripts/lessons.mjs | 2412 +++++++++++++++++ src/skill-scripts/test-map.mjs | 58 +- src/web-console/cmd-open.mjs | 8 + src/web-console/cmd-post-wait.mjs | 3 +- src/web-console/console-launches.md | 6 +- src/web-console/console.md | 7 +- src/web-console/learning.mjs | 258 ++ src/web-console/notes/dead-code.md | 2 +- src/web-console/notes/diagnose.md | 2 + src/web-console/notes/implement.md | 2 + src/web-console/notes/loop.md | 10 +- src/web-console/notes/review.md | 2 + src/web-console/notes/test.md | 2 + src/web-console/notes/xray.md | 2 + src/web-console/patches.mjs | 164 +- src/web-console/pointers.mjs | 2 + src/web-console/public/activities/snake.js | 472 +++- src/web-console/public/answers.js | 203 +- src/web-console/public/app.js | 6 +- src/web-console/public/help.js | 3 + src/web-console/public/index.html | 221 +- src/web-console/public/render.js | 23 +- src/web-console/public/screens/cards.js | 443 ++- src/web-console/public/screens/core.js | 15 +- src/web-console/public/screens/dashboard.js | 72 +- src/web-console/public/screens/ending.js | 32 +- .../public/screens/learning-row.js | 374 +++ src/web-console/public/styles/activities.css | 4 + src/web-console/public/styles/dashboard.css | 6 + src/web-console/public/styles/help.css | 4 + src/web-console/public/styles/learning.css | 198 ++ src/web-console/routes.mjs | 102 + src/web-console/sessions.mjs | 2 +- src/web-console/static.mjs | 5 +- 87 files changed, 9163 insertions(+), 256 deletions(-) create mode 100644 scripts/test-script-lessons.mjs create mode 100644 scripts/test-web-console-learning.mjs create mode 100644 scripts/test-web-console-page-learning.mjs create mode 100644 src/shared-references/lessons.md create mode 100644 src/skill-scripts/lessons.mjs create mode 100644 src/web-console/learning.mjs create mode 100644 src/web-console/public/screens/learning-row.js create mode 100644 src/web-console/public/styles/learning.css diff --git a/.agents-docs/AGENTS-architecture-console-design.md b/.agents-docs/AGENTS-architecture-console-design.md index 1ee4359..3071d7e 100644 --- a/.agents-docs/AGENTS-architecture-console-design.md +++ b/.agents-docs/AGENTS-architecture-console-design.md @@ -17,7 +17,7 @@ Key design points: - **`GET /overview` reads a project file too.** It serves `/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=`. - **The Prototypes tab reads a spec's `prototypes/` folder.** `GET /prototypes` lists its `.md` and `.html` files (204 when none), `GET /prototype?name=` serves one `.md`, and `POST /open-prototype` (origin-checked) hands one `.html` to the system's default opener through `openFile()` in `open-link.mjs` (one argument, no shell). The spec is chosen as `/overview` chooses it (`specInView()`); `listPrototypes()`, `readPrototype()` and `prototypeHtmlPath()` in `sessions.mjs` take a bare file name only and refuse any file whose realpath is not directly in the folder. The page shows the tab after the spec file tabs, on the dashboard and in a session alike (`loadPrototypes()`, called from `loadOverview()`). - **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:` (the `staleSessions()` rule, and every file in the folder that old too, never the serving sid), `console:` (anything at the top of the console home but `PROTECTED_CONSOLE_FILES`, `sessions` and `runtime`, directories too) and `root:` (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:` (a month-old notepad, whole; see Notebook below) and `completed:` (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 `..tmp`, which live for milliseconds. `root:` is only scanned when the console home is `/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, refused, refusal }`. So Cleanup is the one place the server deletes in a project, and it keeps a completed spec git could not give back: `completedSpecs()` marks each `completed:` item `tracked` only when `git ls-files` lists it and `git ls-files --others` lists nothing inside (outside a repository, or gitignored as `specs--completed/` is by default, it is untracked), and `removeCleanup()` refuses an untracked one into `refused`, with `refusal` the line the page's status shows. Nothing records a backup copy, so tracked by git is the only way through. The page always shows the list before **Delete these**. +- **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:` (the `staleSessions()` rule, and every file in the folder that old too, never the serving sid), `console:` (anything at the top of the console home but `PROTECTED_CONSOLE_FILES`, `sessions` and `runtime`, directories too) and `root:` (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`, `prototypes`, `learning`), `notepad:` (a month-old notepad, whole; see Notebook below) and `completed:` (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 `..tmp`, which live for milliseconds. `root:` is only scanned when the console home is `/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, refused, refusal }`. So Cleanup is the one place the server deletes in a project, and it keeps a completed spec git could not give back: `completedSpecs()` marks each `completed:` item `tracked` only when `git ls-files` lists it and `git ls-files --others` lists nothing inside (outside a repository, or gitignored as `specs--completed/` is by default, it is untracked), and `removeCleanup()` refuses an untracked one into `refused`, with `refusal` the line the page's status shows. Nothing records a backup copy, so tracked by git is the only way through. 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//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. - **`open` needs no payload, and runs first.** `--file` and `--title` are optional (the title defaults to the folder name). Every skill's Interface line puts `node "/console.mjs" open --workflow ` BEFORE reading console.md or the project, and a test (`every skill opens the console before it reads anything`) keeps it that way; a blank session renders a starting screen ("Starting Pathfinder", Planny in flight) until the first post. Every skill replaces the flight with its own animated pose (init — init-update borrows it — pathfinder, plan — revise-plan borrows it — document, implement — implement-review borrows it — finalize, quick-task, review, handoff; only the dashboard keeps the flight), cloned by `startStage()` in `screens/starting.js` from `