Add Suggest for me to the loop setup's strength per phase and release 3.1.2

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-18 06:35:28 -08:00
1 parent 9cbb970552
commit e6d5075101
21 files changed
+357 -24

No files matched your search

@@ -32,10 +32,10 @@ One row per file under `src/web-console/public/` (the games and their sound are
| `public/screens/core.js` | the core every screen sits inside: connection, the render loop, the page chrome and Send; the only file that imports the screens, and only `app.js` imports it | | `public/screens/core.js` | the core every screen sits inside: connection, the render loop, the page chrome and Send; the only file that imports the screens, and only `app.js` imports it |
| `public/screens/dashboard.js` | the dashboard: cards, the spec picker, handoff chips, delete, the first-open wake-up, and Learning's waiting banner (`learningBanner()`: the line from `learningBannerText()` and a **Review** button sending `__learning` `review`, last of the banners), which places Learning's row through `hooks.renderLearningRow` | | `public/screens/dashboard.js` | the dashboard: cards, the spec picker, handoff chips, delete, the first-open wake-up, and Learning's waiting banner (`learningBanner()`: the line from `learningBannerText()` and a **Review** button sending `__learning` `review`, last of the banners), which places Learning's row through `hooks.renderLearningRow` |
| `public/screens/learning-row.js` | Learning's row on the dashboard (`renderLearningRow(scan, position)`): four states in two places (under the picker while not set up, off or paused; after the last card group while on), Pause for me posting `/learning/pause` with no agent, More, Open the lessons and the Remove confirm, plus `renderLessonsDialog()`, the Lessons to review dialog that draws an open `lessons` card over the menu; the agent-run controls send `__learning` through `hooks.sendLearning` and gray out under `learningBlocked()` | | `public/screens/learning-row.js` | Learning's row on the dashboard (`renderLearningRow(scan, position)`): four states in two places (under the picker while not set up, off or paused; after the last card group while on), Pause for me posting `/learning/pause` with no agent, More, Open the lessons and the Remove confirm, plus `renderLessonsDialog()`, the Lessons to review dialog that draws an open `lessons` card over the menu; the agent-run controls send `__learning` through `hooks.sendLearning` and gray out under `learningBlocked()` |
| `public/screens/loop-setup.js` | the Implementation Loop's setup screen on the dashboard (app only): the fields, their defaults and read-only facts, the Start checks, and the request to the app. The **Strength per phase** field (`strengthField`) is a grid: four headed columns (Match my session, Thrifty, Balanced, Best; level 0 to 3) and one `radiogroup` row per phase left, one radio per column (`#loop-strength-<n>-<word>`, `match` for Match my session; an unmapped word's radio is disabled and its header says "(not mapped)"), the cell's dot (`strengthBars`) over the hidden radio, and the model the pick becomes at the row's end. **Set all to** stays a select (`#loop-strength-all`, blank again after use). `drawStrengthLine(grid)` draws the grid's SVG from the checked nodes' measured positions, never from state: a very light dashed `line.col` per column and a thick square-step `path.step` from each row's node to the next (one path fewer than rows, none under two rows or with the toggle off). It redraws on the window's resize, a `ResizeObserver` on the grid (Preferences' page width), fonts loading and every redraw of the section, and stops once the grid is gone. The colors are the `--lvl-0` to `--lvl-3` tokens (`--lvl-0` is the neutral gray of Match my session); tests wait for the drawn state before reading the line. The page locks while `state.loop.driving` is set (`loopDriving()` in `selectors.js`) until the app posts `loopEnd`; Activities, Notebook, Help and Preferences stay usable. `loopEnd.can` accepts `ask` (`LOOP_CAN` in `patches.mjs`); the app adds it first to every stop that offers `resume`, and the stopped screen's **Ask a question** wakes an ordinary agent on the same session | | `public/screens/loop-setup.js` | the Implementation Loop's setup screen on the dashboard (app only): the fields, their defaults and read-only facts, the Start checks, and the request to the app. The **Strength per phase** field (`strengthField`) is a grid: four headed columns (Match my session, Thrifty, Balanced, Best; level 0 to 3) and one `radiogroup` row per phase left, one radio per column (`#loop-strength-<n>-<word>`, `match` for Match my session; an unmapped word's radio is disabled and its header says "(not mapped)"), the cell's dot (`strengthBars`) over the hidden radio, and the model the pick becomes at the row's end. **Set all to** stays a select (`#loop-strength-all`, blank again after use). **Suggest for me** (`#loop-strength-suggest`, right of it) sends a no-hop `__loopSuggest` (`id`, `spec`, `phases`, the mapped `strengths`) to the dashboard agent and grays the field under `.loop-suggest-overlay` (`.is-suggesting`, `aria-busy`); the agent posts `loopSuggest` (`{ id, spec, picks: [{ n, strength, why }] }`, checked by `loopSuggestProblems` in `patches.mjs`), and the page applies only the answer whose `id` and `spec` match its own request, mapped words only, with each `why` as a `.loop-strength-why` line that a hand change or Set all to clears; `SUGGEST_WAIT_MS` (two minutes) gives the field back with a note when nobody answers. The dashboard skill answers it under "A strength suggestion arrives". `drawStrengthLine(grid)` draws the grid's SVG from the checked nodes' measured positions, never from state: a very light dashed `line.col` per column and a thick square-step `path.step` from each row's node to the next (one path fewer than rows, none under two rows or with the toggle off). It redraws on the window's resize, a `ResizeObserver` on the grid (Preferences' page width), fonts loading and every redraw of the section, and stops once the grid is gone. The colors are the `--lvl-0` to `--lvl-3` tokens (`--lvl-0` is the neutral gray of Match my session); tests wait for the drawn state before reading the line. The page locks while `state.loop.driving` is set (`loopDriving()` in `selectors.js`) until the app posts `loopEnd`; Activities, Notebook, Help and Preferences stay usable. `loopEnd.can` accepts `ask` (`LOOP_CAN` in `patches.mjs`); the app adds it first to every stop that offers `resume`, and the stopped screen's **Ask a question** wakes an ordinary agent on the same session |
| `public/screens/docs.js` | documents: tabs, blocks, print and download, and the brief button | | `public/screens/docs.js` | documents: tabs, blocks, print and download, and the brief button |
| `public/screens/ending.js` | how a session ends: the finished screen, its offers, Stop and the way home; a Diagnose finish whose `doc` is saved shows that file whole as a Bug report box with Copy report (the raw Markdown), above Next step | | `public/screens/ending.js` | how a session ends: the finished screen, its offers, Stop and the way home; a Diagnose finish whose `doc` is saved shows that file whole as a Bug report box with Copy report (the raw Markdown), above Next step |
| `public/screens/git-host.js` | hosts the git board: tabs, panels and what each click sends | | `public/screens/git-host.js` | hosts the git board: the tools fold-out (`board.tools`, saved with the board), tabs, panels and what each click sends |
| `public/screens/help-dialog.js` | the Help dialog and the first-run Welcome (named so it is never confused with the pure help.js). Help reads right in both modes: a phrase that differs under the desktop app carries its app wording in `data-app` (swapped in by `renderAppWording()`), and a paragraph that differs is a `.for-browser` / `.for-app` sibling pair, switched by `:root.in-app` (set in `core.js` from `page.inApp`, rule in `help.css`). The older `render*Help()` functions patch a few ids the same way. `scripts/test-web-console-page-help.mjs` sweeps every topic's visible text in each mode for the other mode's wording | | `public/screens/help-dialog.js` | the Help dialog and the first-run Welcome (named so it is never confused with the pure help.js). Help reads right in both modes: a phrase that differs under the desktop app carries its app wording in `data-app` (swapped in by `renderAppWording()`), and a paragraph that differs is a `.for-browser` / `.for-app` sibling pair, switched by `:root.in-app` (set in `core.js` from `page.inApp`, rule in `help.css`). The older `render*Help()` functions patch a few ids the same way. `scripts/test-web-console-page-help.mjs` sweeps every topic's visible text in each mode for the other mode's wording |
| `public/screens/looks.js` | User Preferences: the look and sound controls, which save as they change | | `public/screens/looks.js` | User Preferences: the look and sound controls, which save as they change |
| `public/screens/agents-view.js` | the agents view's mount, state and server calls, serving both User Preferences' Agents & models tab and the setup page. Preferences draws a roster of agent cards with the picked agent's form in a side drawer (`data-av="drawer"`, hidden while no form is open, the roster `inert` behind it) and the Add agent chooser (`data-av="chooser"`); the setup page keeps a master-detail split, the pickable list on the left and the picked entry's state (or the same form) in the right pane. Picking a card or row is the navigation; a dirty form asks the dialog's unsaved prompt first. Each form edits a draft; Save sends the saved list with only that draft swapped in (`POST /models` or `POST /agents`), Discard drops it. `hasUnsaved`, `saveOpen` and `discardOpen` feed the dialog's unsaved prompt. `mountAgentsView(container, {mode, forCli, onStart})` hands its renderers one `ctx` (state plus callbacks); `mode: "prefs"` draws the agent cards with Found / Not found on PATH badges and the model each strength uses, `openChooser` / `startNew(template)` (the starter templates are an opt-in there, not a list section) and `closeDrawer` (Esc, the scrim and Close go through it, so a dirty draft asks first), `mode: "setup"` draws the pick list (found / outside-PATH / missing states, install lines, Use it from here, templates, Start) inside a caller-supplied container | | `public/screens/agents-view.js` | the agents view's mount, state and server calls, serving both User Preferences' Agents & models tab and the setup page. Preferences draws a roster of agent cards with the picked agent's form in a side drawer (`data-av="drawer"`, hidden while no form is open, the roster `inert` behind it) and the Add agent chooser (`data-av="chooser"`); the setup page keeps a master-detail split, the pickable list on the left and the picked entry's state (or the same form) in the right pane. Picking a card or row is the navigation; a dirty form asks the dialog's unsaved prompt first. Each form edits a draft; Save sends the saved list with only that draft swapped in (`POST /models` or `POST /agents`), Discard drops it. `hasUnsaved`, `saveOpen` and `discardOpen` feed the dialog's unsaved prompt. `mountAgentsView(container, {mode, forCli, onStart})` hands its renderers one `ctx` (state plus callbacks); `mode: "prefs"` draws the agent cards with Found / Not found on PATH badges and the model each strength uses, `openChooser` / `startNew(template)` (the starter templates are an opt-in there, not a list section) and `closeDrawer` (Esc, the scrim and Close go through it, so a dirty draft asks first), `mode: "setup"` draws the pick list (found / outside-PATH / missing states, install lines, Use it from here, templates, Start) inside a caller-supplied container |
@@ -69,8 +69,8 @@ One row per file under `src/web-console/public/` (the games and their sound are
| `public/help.js` | the Help dialog's PURE rules: `HELP_TABS` (23 tabs: ids, order, labels, diagram flags; `HELP_GROUPS` and `helpGroupStart()` name the four group headings, Start here, Working in a session, Tools and Reference, each a run of neighbors so grouping never moves a tab; every tab uses the chosen highlight color; Implementation Loop sits right after Watching a build, The git board right after it, and Activities right after Ask a quick question), `helpTabFor()` (which tab opens, FR-8 order, first match wins: finished → Stopping and finishing, server gone or agent adrift → When something looks stuck, opened from the Workspace dialog → Your workspace, then Ask, the Subagents tab → Subagents, a red-meter dashboard → Session meter, dashboard, a doc or the Overview, a git session → The git board, a build, else What this page is) and `helpKeyTarget()` (roving arrow keys, Home, End, wrapping; a re-export of `tabs.js`'s `tabKeyTarget`). No module-scope DOM, so `node --test` covers it | | `public/help.js` | the Help dialog's PURE rules: `HELP_TABS` (23 tabs: ids, order, labels, diagram flags; `HELP_GROUPS` and `helpGroupStart()` name the four group headings, Start here, Working in a session, Tools and Reference, each a run of neighbors so grouping never moves a tab; every tab uses the chosen highlight color; Implementation Loop sits right after Watching a build, The git board right after it, and Activities right after Ask a quick question), `helpTabFor()` (which tab opens, FR-8 order, first match wins: finished → Stopping and finishing, server gone or agent adrift → When something looks stuck, opened from the Workspace dialog → Your workspace, then Ask, the Subagents tab → Subagents, a red-meter dashboard → Session meter, dashboard, a doc or the Overview, a git session → The git board, a build, else What this page is) and `helpKeyTarget()` (roving arrow keys, Home, End, wrapping; a re-export of `tabs.js`'s `tabKeyTarget`). No module-scope DOM, so `node --test` covers it |
| `public/tabs.js` | the WAI-ARIA tabs shared by Help and User Preferences: `wireTabs()` (buttons and panel links, roving tabindex, automatic activation, `aria-orientation` switching at 720 px, an optional `beforeSelect` guard) and the pure `tabKeyTarget()` | | `public/tabs.js` | the WAI-ARIA tabs shared by Help and User Preferences: `wireTabs()` (buttons and panel links, roving tabindex, automatic activation, `aria-orientation` switching at 720 px, an optional `beforeSelect` guard) and the pure `tabKeyTarget()` |
| `public/prefs.js` | User Preferences' PURE rules: `PREFS_TABS` (Appearance, Agents & models, System, Sounds & activities, with hints and the sections each holds), `prefsOpenTab()` and `prefsResetScope()` (the looks keys Reset this tab resets per tab, or null) | | `public/prefs.js` | User Preferences' PURE rules: `PREFS_TABS` (Appearance, Agents & models, System, Sounds & activities, with hints and the sections each holds), `prefsOpenTab()` and `prefsResetScope()` (the looks keys Reset this tab resets per tab, or null) |
| `public/git-board.js` | PURE, one import (`pr-url.js`): the git board's rules from a `state.git` snapshot: branch order and the Remote only fold at `REMOTE_FOLD` 50, whether a new branch name is free, which buttons show and are enabled, whether the board still waits on the agent (`boardAwaiting()`: from a click until the agent's next post, not just until `wait` collects it), the plain sentence each click sends as `reply`, the "Last refreshed" line, which files start ticked in the commit dialog, the pull-request link, and the current branch's page on its host (`boardBranchLink()`, null until the branch is pushed under its own name); the next step (ten rules, `nextStep()`), the tab that owns it, per-tab badges (`tabBadges()`), the busy mode and per-control gate (`busyMode()`, `controlAllowed()`), the tab to show (`pickTab()`), and the create-panel sources and clean-up groups. `app.js` only renders what it says | | `public/git-board.js` | PURE, one import (`pr-url.js`): the git board's rules from a `state.git` snapshot: branch order and the Remote only fold at `REMOTE_FOLD` 50, whether a new branch name is free, which buttons show and are enabled, whether the board still waits on the agent (`boardAwaiting()`: from a click until the agent's next post, not just until `wait` collects it), the plain sentence each click sends as `reply`, the "Last refreshed" line, which files start ticked in the commit dialog, the pull-request link, and the current branch's page on its host (`boardBranchLink()`, null until the branch is pushed under its own name); the next step (ten rules, `nextStep()`), the tab that owns it, where it sits on the Save, Share, Review, Tidy path (`PATH_STOPS`, `boardPath()`), whether the task card carries the commit table (`cardShowsFiles()`), per-tab badges (`tabBadges()`), the busy mode and per-control gate (`busyMode()`, `controlAllowed()`), the tab to show (`pickTab()`), and the create-panel sources and clean-up groups. `app.js` only renders what it says |
| `public/git-board-view.js` | No DOM access of its own: `drawGitBoard(ctx)` draws the tabbed board (header, whose branch name is a link to the branch on its host once pushed, tab strip with Done with git, the card slot, step strip, Changes / Branches / Sync) from the helpers it is handed (`el`, `md`, `copyButton`), every control through one gate; `screens/git-host.js` hosts it, and `scripts/test-web-console-git-board.mjs` drives it with a recording fake `el` | | `public/git-board-view.js` | No DOM access of its own: `drawGitBoard(ctx)` draws the guided board (header with Done with git, whose branch name is a link to the branch on its host once pushed; the path; the card slot; the task card, which holds the commit table on a Save stop and the operation mid-rebase; the **All branches and tools** fold-out with the Changes / Branches / Sync tabs) from the helpers it is handed (`el`, `md`, `copyButton`), every control through one gate; `screens/git-host.js` hosts it, and `scripts/test-web-console-git-board.mjs` drives it with a recording fake `el` |
| `public/pr-url.js` | PURE, no imports: `prUrl()`, the "open a pull request" link for the GitHub, GitLab, Azure DevOps and Bitbucket shapes (`null` for an unknown kind, no web address, or a non-https result), and `branchUrl()`, the branch's own page on the same four hosts under the same rules. `git-repo.mjs` re-exports `prUrl()`, and the board's base picker rebuilds the link in the browser with the same code | | `public/pr-url.js` | PURE, no imports: `prUrl()`, the "open a pull request" link for the GitHub, GitLab, Azure DevOps and Bitbucket shapes (`null` for an unknown kind, no web address, or a non-https result), and `branchUrl()`, the branch's own page on the same four hosts under the same rules. `git-repo.mjs` re-exports `prUrl()`, and the board's base picker rebuilds the link in the browser with the same code |
| `public/workspace.js` | PURE, no imports: the Workspace's name rules (`nameProblem()`, `NAME_MAX`, `defaultName()`, `freeName()` for the `-2` suggestion), the footer label and its width tiers (`footerLabel()`, `FOOTER_TIERS`) and `changeLine()`, the `Workspace: …` reply line an agent is handed per change. Imported by the server, `cmd-chat.mjs`, `cmd-post-wait.mjs`, `workspace.mjs` and the page | | `public/workspace.js` | PURE, no imports: the Workspace's name rules (`nameProblem()`, `NAME_MAX`, `defaultName()`, `freeName()` for the `-2` suggestion), the footer label and its width tiers (`footerLabel()`, `FOOTER_TIERS`) and `changeLine()`, the `Workspace: …` reply line an agent is handed per change. Imported by the server, `cmd-chat.mjs`, `cmd-post-wait.mjs`, `workspace.mjs` and the page |
| `public/meter.js` | PURE, imports only `skills.js`: the session meter. `WEIGHTS` (the events that are not a skill's own launch, merged with each skill's `weight` from `skills.js`; its keys are also `RUN_EVENTS`, the `run` events `post` accepts), `LAUNCH_COUNTED` (workflows whose launch itself scores), the built-phase sizing (`TASK_EVENTS`, the keys of `TASK_BONUS`: `implement-phase` +0 and `implement-review-phase` +1; `isTaskCount()` accepts a whole `tasks` from 1 to `MAX_TASKS` 999; `runPoints()` scores such a run `ceil(tasks / TASKS_PER_POINT)` (3) plus its bonus, and any other run its `WEIGHTS` value), `ANSWERS_PER_POINT` 2 (`answer` entries score per skill run, `floor(count / 2)`), `breakdownFrom()` (the click-the-ring list: one row per scoring entry plus one answers row per skill run), `pointsFrom()` (the count, its sum, folded from `ledger.ndjson` and deduplicated by id, never stored), `levelFor()` with `YELLOW_AT` 5 / `RED_AT` 10, `ringFraction()` (full at `RING_FULL` 15), `WORDS`, `tooltipFor()`, `RED_BANNER` and `meterView()` | | `public/meter.js` | PURE, imports only `skills.js`: the session meter. `WEIGHTS` (the events that are not a skill's own launch, merged with each skill's `weight` from `skills.js`; its keys are also `RUN_EVENTS`, the `run` events `post` accepts), `LAUNCH_COUNTED` (workflows whose launch itself scores), the built-phase sizing (`TASK_EVENTS`, the keys of `TASK_BONUS`: `implement-phase` +0 and `implement-review-phase` +1; `isTaskCount()` accepts a whole `tasks` from 1 to `MAX_TASKS` 999; `runPoints()` scores such a run `ceil(tasks / TASKS_PER_POINT)` (3) plus its bonus, and any other run its `WEIGHTS` value), `ANSWERS_PER_POINT` 2 (`answer` entries score per skill run, `floor(count / 2)`), `breakdownFrom()` (the click-the-ring list: one row per scoring entry plus one answers row per skill run), `pointsFrom()` (the count, its sum, folded from `ledger.ndjson` and deduplicated by id, never stored), `levelFor()` with `YELLOW_AT` 5 / `RED_AT` 10, `ringFraction()` (full at `RING_FULL` 15), `WORDS`, `tooltipFor()`, `RED_BANNER` and `meterView()` |
+10
View File
@@ -4,6 +4,16 @@ All notable changes to Plan2Code will be documented in this file.
<!-- Format from 3.1.0 on: `## vX.Y.Z (YYYY-MM-DD)` with the date from version.json; a minor release opens with a three-bullet `### Highlights`; sections run Added, Changed, Fixed; game changes sit under one Activities line; tooling and test lines go under "For contributors". Older headings have no date and are not backfilled. --> <!-- Format from 3.1.0 on: `## vX.Y.Z (YYYY-MM-DD)` with the date from version.json; a minor release opens with a three-bullet `### Highlights`; sections run Added, Changed, Fixed; game changes sit under one Activities line; tooling and test lines go under "For contributors". Older headings have no date and are not backfilled. -->
## v3.1.2 (2026-11-17)
### ✨ Added
- **desktop app**: Suggest for me, beside Set all to in the Implementation Loop's Strength per phase, asks the dashboard's agent to read each phase and pick a strength for it, with a one-line reason under each row; every pick stays yours to change.
### 🐛 Fixed
- **web console**: a click anywhere inside a Markdown box's border now puts the cursor in it, not only a click on the text.
## v3.1.1 (2026-11-17) ## v3.1.1 (2026-11-17)
### ✨ Added ### ✨ Added
+1 -1
View File
@@ -13,7 +13,7 @@
Plan2Code is a spec-driven workflow for AI coding agents. You work through it on a page in your browser: the dashboard lists every step as a card, and each step's questions, progress and sign-offs arrive on that same page while your agent does the work. An approved plan becomes phase documents, and the agent builds to them one phase at a time. Plan2Code is a spec-driven workflow for AI coding agents. You work through it on a page in your browser: the dashboard lists every step as a card, and each step's questions, progress and sign-offs arrive on that same page while your agent does the work. An approved plan becomes phase documents, and the agent builds to them one phase at a time.
Version 3.1.1 · Apache 2.0 · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com) Version 3.1.2 · Apache 2.0 · 📖 [plan2code.jparkerweb.com](https://plan2code.jparkerweb.com)
--- ---
+1 -1
View File
@@ -168,7 +168,7 @@ not), so your own edits never end up inside a phase's commit.
- **Fix findings**: **Smart pick** (the default) has a fresh agent read the findings and fix only the - **Fix findings**: **Smart pick** (the default) has a fresh agent read the findings and fix only the
ones worth fixing, recording every skip. A skipped Critical stops the phase. **By level** fixes the ones worth fixing, recording every skip. A skipped Critical stops the phase. **By level** fixes the
Critical, Warning and Suggestion findings you tick (all three start ticked). Critical, Warning and Suggestion findings you tick (all three start ticked).
- **Strength per phase** (off): turn on **Set strength per phase** to see one row per phase still to build under four headed columns, **Match my session**, **Thrifty**, **Balanced** and **Best**, and click a dot in a row to pick (the arrow keys move along a row), or use **Set all to** for one pick. A thick line steps through each row's picked dot, so the choices read at a glance, and the model each pick becomes shows at the end of its row. A phase you leave untouched runs on the model the app was launched with, as before. A phase whose agent crashes or goes quiet gets its one retry (when the retry tick is on) one step up (Thrifty to Balanced, Balanced to Best; Best stays Best; **Match my session** runs on the launch model and its retry stays there), and the phase's subagents follow the same strength. Which model each word means for your agent is set in User Preferences, **Agents & models**, under **Strengths in the loop**; an agent with nothing mapped shows the toggle off with a link there. The picks are remembered per project and spec, and a pick for a phase that is done or gone is dropped. - **Strength per phase** (off): turn on **Set strength per phase** to see one row per phase still to build under four headed columns, **Match my session**, **Thrifty**, **Balanced** and **Best**, and click a dot in a row to pick (the arrow keys move along a row), or use **Set all to** for one pick. **Suggest for me**, beside it, asks the agent on the dashboard to read each phase and pick for you: the field grays under a spinner while it thinks, then the rows fill with a one-line reason under each, and you can still change any of them (a row changed by hand drops its reason). If the agent does not answer within two minutes, your picks stay as they were. A thick line steps through each row's picked dot, so the choices read at a glance, and the model each pick becomes shows at the end of its row. A phase you leave untouched runs on the model the app was launched with, as before. A phase whose agent crashes or goes quiet gets its one retry (when the retry tick is on) one step up (Thrifty to Balanced, Balanced to Best; Best stays Best; **Match my session** runs on the launch model and its retry stays there), and the phase's subagents follow the same strength. Which model each word means for your agent is set in User Preferences, **Agents & models**, under **Strengths in the loop**; an agent with nothing mapped shows the toggle off with a link there. The picks are remembered per project and spec, and a pick for a phase that is done or gone is dropped.
- **When a phase asks something**: **Take the agent's best guess** (the default), which records the - **When a phase asks something**: **Take the agent's best guess** (the default), which records the
assumption as a `[?]` task, **Pause and wait for me**, or **Stop the loop**. assumption as a `[?]` task, **Pause and wait for me**, or **Stop the loop**.
- **After the last phase**: **Stop and offer Finalize** (the default) or **Run Finalize automatically**. - **After the last phase**: **Stop and offer Finalize** (the default) or **Run Finalize automatically**.
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "plan2code", "name": "plan2code",
"version": "3.1.1", "version": "3.1.2",
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"engines": { "engines": {
+2 -2
View File
@@ -957,7 +957,7 @@ dependencies = [
[[package]] [[package]]
name = "fake-agent" name = "fake-agent"
version = "3.1.1" version = "3.1.2"
dependencies = [ dependencies = [
"serde_json", "serde_json",
"terminal_size", "terminal_size",
@@ -2647,7 +2647,7 @@ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
[[package]] [[package]]
name = "plan2code-app" name = "plan2code-app"
version = "3.1.1" version = "3.1.2"
dependencies = [ dependencies = [
"chrono", "chrono",
"libc", "libc",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "fake-agent" name = "fake-agent"
version = "3.1.1" version = "3.1.2"
description = "A stand-in agent program for the Plan2Code app's tests" description = "A stand-in agent program for the Plan2Code app's tests"
edition = "2021" edition = "2021"
publish = false publish = false
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "plan2code-app", "name": "plan2code-app",
"version": "3.1.1", "version": "3.1.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "plan2code-app", "name": "plan2code-app",
"version": "3.1.1", "version": "3.1.2",
"dependencies": { "dependencies": {
"@tauri-apps/api": "2.12.4", "@tauri-apps/api": "2.12.4",
"@xterm/addon-fit": "0.11.0", "@xterm/addon-fit": "0.11.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "plan2code-app", "name": "plan2code-app",
"version": "3.1.1", "version": "3.1.2",
"private": true, "private": true,
"description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.", "description": "Plan2Code desktop app (Tauri). Separate from the repo root so the root and the web console stay dependency-free.",
"scripts": { "scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "plan2code-app" name = "plan2code-app"
version = "3.1.1" version = "3.1.2"
description = "Plan2Code desktop app" description = "Plan2Code desktop app"
edition = "2021" edition = "2021"
publish = false publish = false
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Plan2Code", "productName": "Plan2Code",
"version": "3.1.1", "version": "3.1.2",
"identifier": "com.plan2code.desktop", "identifier": "com.plan2code.desktop",
"build": { "build": {
"frontendDist": "../ui", "frontendDist": "../ui",
+40
View File
@@ -1038,3 +1038,43 @@ test("GET /loop-setup?agent= answers the loop agent's resolved strengths and thi
cli(["stop", "--session", opened.json.sid, "--force"], { cwd, expectFail: true }); cli(["stop", "--session", opened.json.sid, "--force"], { cwd, expectFail: true });
} }
}); });
/* ------------------------------------------- loopSuggest (Suggest for me) */
const dashState = () => blankState({ sid: "s", workflow: "dashboard", project: "p" });
const goodSuggest = () => ({
id: "ls-1",
spec: "specs/ready",
picks: [
{ n: 1, strength: "thrifty", why: "A small copy change." },
{ n: 2, strength: "", why: "Matches the session: nothing unusual here." },
],
});
test("loopSuggest: a well formed answer is stored, Match my session as an empty strength", () => {
const got = tryPatch(dashState(), { loopSuggest: goodSuggest() });
assert.deepEqual(got.problems, []);
assert.deepEqual(got.next.loopSuggest, goodSuggest());
});
test("loopSuggest: each bad field is refused with a message naming it", () => {
const cases = [
["not an object", () => ({ replace: "best" }), /loopSuggest must be an object/],
["no id", (o) => delete o.id, /loopSuggest\.id must be/],
["a spec outside specs/", (o) => (o.spec = "../x"), /loopSuggest\.spec must be/],
["no picks", (o) => (o.picks = []), /loopSuggest\.picks must be/],
["a bad phase number", (o) => (o.picks[0].n = 0), /loopSuggest\.picks\[0\]\.n must be/],
["an unknown strength", (o) => (o.picks[0].strength = "turbo"), /loopSuggest\.picks\[0\]\.strength must be one of/],
["a reason over one line", (o) => (o.picks[1].why = "One.\nTwo."), /loopSuggest\.picks\[1\]\.why must be one line/],
["a phase named twice", (o) => (o.picks[1].n = 1), /loopSuggest\.picks\[1\]\.n names phase 1 twice/],
["no strength", (o) => delete o.picks[0].strength, /loopSuggest\.picks\[0\]\.strength must be one of/],
["a reason the prose check refuses", (o) => (o.picks[0].why = "Easy, then TASK_COMPLETE."), /loopSuggest\.picks\[0\]\.why: contains a loop completion marker/],
];
for (const [label, change, pattern] of cases) {
let v = goodSuggest();
const out = change(v);
if (out && typeof out === "object" && "replace" in out) v = out.replace;
const got = tryPatch(dashState(), { loopSuggest: v });
assert.ok(got.problems.some((p) => pattern.test(p)), `${label}: ${got.problems.join(" | ") || "accepted"}`);
}
});
+123 -4
View File
@@ -22,9 +22,9 @@ const PROJECT = {
const MENU = { menu: { note: "Ready when you are." }, agent: { status: "waiting" } }; const MENU = { menu: { note: "Ready when you are." }, agent: { status: "waiting" } };
async function openSetup(t) { async function openSetup(t, { clock = false } = {}) {
const browser = await suite.browser(); const browser = await suite.browser();
const s = await openSession(browser, { t, workflow: "dashboard", payload: MENU, project: tempProject(PROJECT) }); const s = await openSession(browser, { t, workflow: "dashboard", payload: MENU, project: tempProject(PROJECT), clock });
// Past Planny's wake-up and, on a first run, the Welcome. // Past Planny's wake-up and, on a first run, the Welcome.
const skip = s.page.getByRole("button", { name: "Skip the intro" }); const skip = s.page.getByRole("button", { name: "Skip the intro" });
await skip.click(); await skip.click();
@@ -605,9 +605,9 @@ function installShippedModels() {
} }
// The setup screen with the app's answer in: this launch choice, then the strengths read for it. // The setup screen with the app's answer in: this launch choice, then the strengths read for it.
async function openStrengthSetup(t, launch = LAUNCH) { async function openStrengthSetup(t, launch = LAUNCH, opts = {}) {
installShippedModels(); installShippedModels();
const s = await openSetup(t); const s = await openSetup(t, opts);
await s.page.evaluate(async (facts) => { await s.page.evaluate(async (facts) => {
const { page, redraw } = await import(new URL("state.js", document.baseURI).href); const { page, redraw } = await import(new URL("state.js", document.baseURI).href);
page.loopFacts = facts; page.loopFacts = facts;
@@ -837,3 +837,122 @@ test("the toggle and the picks survive reopening the screen, and the toggle off
const cleared = await save(); const cleared = await save();
assert.deepEqual(cleared.body.setup.strengths, {}); assert.deepEqual(cleared.body.setup.strengths, {});
}); });
/* ------------------------------------------- Suggest for me (the agent's picks) */
// The strength field with the toggle on and its rows drawn.
async function openSuggestSetup(t, opts) {
const s = await openStrengthSetup(t, LAUNCH, opts);
await s.page.locator("#loop-phase-strength").check();
await s.page.locator(".loop-strength-row").first().waitFor();
return s;
}
const suggestButton = (s) => s.page.locator("#loop-strength-suggest");
const busyField = (s) => s.page.locator(".loop-field.is-suggesting");
test("Suggest for me sits right of Set all to, asks the dashboard agent with the phases and mapped words, and grays the field", async (t) => {
const s = await openSuggestSetup(t);
const button = suggestButton(s);
assert.equal(await textOf(button), "Suggest for me");
assert.equal(await button.evaluate((b) => b.previousElementSibling && b.previousElementSibling.id), "loop-strength-all", "right after the Set all to list");
await button.click();
await busyField(s).waitFor();
assert.equal(await busyField(s).getAttribute("aria-busy"), "true");
assert.match(await textOf(busyField(s).locator(".loop-suggest-overlay")), /reading each phase/i);
assert.equal(await s.page.locator("#loop-strength-all").isDisabled(), true, "Set all to waits too");
assert.equal(await button.isDisabled(), true);
assert.equal(await s.page.locator("#loop-phase-strength").isDisabled(), true, "the toggle waits too");
for (const radio of await s.page.locator(".loop-strength-row input").all()) assert.equal(await radio.isDisabled(), true);
const got = s.wait(10);
assert.equal(got.code, 0, "the request reached the agent");
assert.equal(got.actions.length, 1);
const [action] = got.actions;
assert.equal(action.i, "__loopSuggest");
assert.equal(action.spec, "specs/ready");
assert.deepEqual(action.phases, [{ n: 1, name: "One" }, { n: 2, name: "Two" }]);
assert.deepEqual(action.strengths, ["thrifty", "balanced", "best"], "only the words mapped for this agent, in rank order");
assert.match(action.id, /^[a-z0-9-]+$/);
assert.match(got.reply, /Suggest a strength for each phase left in specs\/ready/);
});
test("a posted suggestion fills the rows with a reason each, frees the field, and a hand change drops only that row's reason", async (t) => {
const s = await openSuggestSetup(t);
await suggestButton(s).click();
const got = s.wait(10);
assert.equal(got.code, 0);
const id = got.actions[0].id;
s.post({
loopSuggest: {
id,
spec: "specs/ready",
picks: [
{ n: 1, strength: "thrifty", why: "A small copy change." },
{ n: 2, strength: "best", why: "A new parser with many edge cases." },
],
},
agent: { status: "waiting" },
});
await busyField(s).waitFor({ state: "detached" });
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["thrifty", "best"]);
assert.deepEqual(await s.page.locator(".loop-strength-why").allInnerTexts(), ["A small copy change.", "A new parser with many edge cases."]);
assert.equal(await suggestButton(s).isDisabled(), false, "free to ask again");
await s.page.waitForFunction(() => document.activeElement && document.activeElement.id === "loop-strength-suggest");
await pickStrength(s, 1, "balanced");
assert.deepEqual(await s.page.locator(".loop-strength-why").allInnerTexts(), ["A new parser with many edge cases."], "row 1 was changed by hand");
await s.page.locator("#loop-strength-all").selectOption("match");
assert.equal(await s.page.locator(".loop-strength-why").count(), 0, "Set all to replaces every pick, and every reason with it");
});
test("an answer for an older request, or for another spec, is never applied", async (t) => {
const s = await openSuggestSetup(t);
await suggestButton(s).click();
const got = s.wait(10);
s.post({ loopSuggest: { id: "old-request", spec: "specs/ready", picks: [{ n: 1, strength: "best", why: "Old." }] }, agent: { status: "waiting" } });
s.post({ loopSuggest: { id: got.actions[0].id, spec: "specs/other", picks: [{ n: 1, strength: "best", why: "Other." }] } });
await s.page.waitForTimeout(500);
assert.equal(await busyField(s).count(), 1, "still waiting for its own answer");
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["", ""]);
});
test("no answer in time frees the field, says the agent did not answer, and leaves the picks as they were", async (t) => {
const s = await openSuggestSetup(t, { clock: true });
await pickStrength(s, 2, "thrifty");
await suggestButton(s).click();
await busyField(s).waitFor();
await s.page.clock.fastForward(121000);
await busyField(s).waitFor({ state: "detached" });
assert.match(await textOf(s.page.locator(".loop-suggest-note")), /did not answer/);
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["", "thrifty"]);
});
test("a send that fails frees the field at once with a note, and focus goes back to the button", async (t) => {
const s = await openSuggestSetup(t);
await s.page.route("**/submit", (route) => route.fulfill({ status: 500, body: "{}" }));
await suggestButton(s).click();
await s.page.locator(".loop-suggest-note").waitFor();
assert.match(await textOf(s.page.locator(".loop-suggest-note")), /could not be asked/);
assert.equal(await busyField(s).count(), 0);
assert.equal(await suggestButton(s).isDisabled(), false);
await s.page.waitForFunction(() => document.activeElement && document.activeElement.id === "loop-strength-suggest");
});
test("a pick for an unmapped word, or a phase left out, keeps that row as it was", async (t) => {
const s = await openSuggestSetup(t);
await s.page.evaluate(async () => {
const { page, redraw } = await import(new URL("state.js", document.baseURI).href);
page.loopSetup.facts.resolved = { thrifty: { model: "sonnet", effort: "low" }, balanced: { model: "sonnet", effort: "medium" } };
redraw();
});
await pickStrength(s, 2, "thrifty");
await suggestButton(s).click();
const got = s.wait(10);
assert.deepEqual(got.actions[0].strengths, ["thrifty", "balanced"], "Best is not mapped, so it is not offered");
s.post({ loopSuggest: { id: got.actions[0].id, spec: "specs/ready", picks: [{ n: 1, strength: "best", why: "Needs the strongest." }] }, agent: { status: "waiting" } });
await busyField(s).waitFor({ state: "detached" });
assert.deepEqual((await strengthRows(s)).map((r) => r.pick), ["", "thrifty"]);
assert.equal(await s.page.locator(".loop-strength-why").count(), 0, "no reason shows for a pick that was not applied");
});
+1
View File
@@ -264,6 +264,7 @@ test("pointersForSend: the whole table", () => {
assert.deepEqual(pointersForSend(act({ i: "__stop", handoff: true }), empty, noFlags), ["stop"]); assert.deepEqual(pointersForSend(act({ i: "__stop", handoff: true }), empty, noFlags), ["stop"]);
assert.deepEqual(pointersForSend(act({ i: "__review" }), empty, noFlags), ["review"]); assert.deepEqual(pointersForSend(act({ i: "__review" }), empty, noFlags), ["review"]);
assert.deepEqual(pointersForSend(act({ i: "__learning", type: "learning", do: "remove" }), empty, noFlags), ["learning"]); assert.deepEqual(pointersForSend(act({ i: "__learning", type: "learning", do: "remove" }), empty, noFlags), ["learning"]);
assert.deepEqual(pointersForSend(act({ i: "__loopSuggest", type: "loopSuggest", id: "ls-1", spec: "specs/x" }), empty, noFlags), ["learning"], "Suggest for me is explained in the same file");
const reviewCard = { items: [{ id: "signoff", kind: "review" }] }; const reviewCard = { items: [{ id: "signoff", kind: "review" }] };
assert.deepEqual(pointersForSend(act({ i: "signoff", type: "answer", verdict: "review" }), reviewCard, noFlags), ["review"]); assert.deepEqual(pointersForSend(act({ i: "signoff", type: "answer", verdict: "review" }), reviewCard, noFlags), ["review"]);
assert.deepEqual(pointersForSend(act({ i: "signoff", type: "answer", answer: { verdict: "approve" } }), reviewCard, noFlags), ["review"]); assert.deepEqual(pointersForSend(act({ i: "signoff", type: "answer", answer: { verdict: "approve" } }), reviewCard, noFlags), ["review"]);
+8
View File
@@ -145,6 +145,14 @@ The card: post `list`'s `card` as one `lessons` item with `--wait` (the page sho
Then `node "<D>/console.mjs" open --resume <sid> --no-open --workflow dashboard` to rescan, and post the menu again with `"settle":true` and `--wait`, its note saying what changed (after the card, `decide`'s `closing` line). Never stage or commit. Then `node "<D>/console.mjs" open --resume <sid> --no-open --workflow dashboard` to rescan, and post the menu again with `"settle":true` and `--wait`, its note saying what changed (after the card, `decide`'s `closing` line). Never stage or commit.
## A strength suggestion arrives
The loop setup's **Suggest for me** sends `__loopSuggest` with `id`, `spec`, `phases` (`[{ n, name }]`, the phases left) and `strengths` (the words mapped for the loop's agent). No hop: you stay the dashboard and the setup screen stays up. The page gives up after two minutes, so answer before anything else:
1. Read `<spec>/overview.md` and each phase file in `phases`: its tasks, the files it touches, what later phases build on it.
2. Pick one word per phase, from `strengths` only: `thrifty` for small, mechanical or copy-only work; `balanced` for an ordinary feature; `best` for tricky logic, a wide refactor, security, concurrency or data migrations. `""` (Match my session) when none fits.
3. Post with `--wait`: `{"loopSuggest":{"id":"<the send's id>","spec":"<spec>","picks":[{"n":1,"strength":"thrifty","why":"Label and copy changes only."}]},"agent":{"status":"waiting"}}`, one pick per phase, `why` one plain line the person reads under the row. The page fills the rows; the person can still change any of them.
## Coming back from another skill ## Coming back from another skill
You arrive here mid-conversation after a `__dashboard` press — from a finished screen, or mid-workflow from the top bar's triangle once that skill saved its place — having already run `open --resume <sid> --no-open --workflow dashboard` (the send's `resume`; it cleared the last skill's page, its finish included — console-finish.md, console-stop.md). Skip Interface steps 1–2; your first job is the menu judgment, then post the menu with `--wait`: re-read `state.scan`, which the resume refreshed — the spec you just worked on is usually the most recently touched. Then the usual wait loop and launches. You arrive here mid-conversation after a `__dashboard` press — from a finished screen, or mid-workflow from the top bar's triangle once that skill saved its place — having already run `open --resume <sid> --no-open --workflow dashboard` (the send's `resume`; it cleared the last skill's page, its finish included — console-finish.md, console-stop.md). Skip Interface steps 1–2; your first job is the menu judgment, then post the menu with `--wait`: re-read `state.scan`, which the resume refreshed — the spec you just worked on is usually the most recently touched. Then the usual wait loop and launches.
+4
View File
@@ -27,3 +27,7 @@ The ✕ on a chip (after the page's two-step confirm) sends `session:[{"i":"__de
## A Learning action ## A Learning action
The Learning row and banner send `session:[{"i":"__learning","do":"switch-on"}]` (`do` is `review`, `switch-on`, `switch-off`, `move-log` or `remove`; Remove was confirmed on the page). No hop: you stay the dashboard. Run `lessons.mjs` as the dashboard skill's "A Learning action arrives" says (a `review` while Learning is not set up is `list --first-ask` and the first ask, before anything is kept; the lessons card is the only question this page shows), then `open --resume <sid> --no-open --workflow dashboard` and post the menu again with `--wait`. Pause for me never reaches you: the page saves it itself. A `__launch` with `fromBanner: true` came from a dashboard showing lessons waiting. The Learning row and banner send `session:[{"i":"__learning","do":"switch-on"}]` (`do` is `review`, `switch-on`, `switch-off`, `move-log` or `remove`; Remove was confirmed on the page). No hop: you stay the dashboard. Run `lessons.mjs` as the dashboard skill's "A Learning action arrives" says (a `review` while Learning is not set up is `list --first-ask` and the first ask, before anything is kept; the lessons card is the only question this page shows), then `open --resume <sid> --no-open --workflow dashboard` and post the menu again with `--wait`. Pause for me never reaches you: the page saves it itself. A `__launch` with `fromBanner: true` came from a dashboard showing lessons waiting.
## A strength suggestion
The loop setup's **Suggest for me** sends `session:[{"i":"__loopSuggest","id":"ls-m3x1","spec":"specs/<name>","phases":[{"n":1,"name":"..."}],"strengths":["thrifty","best"]}]`. No hop: you stay the dashboard. Read the phase files, then post `loopSuggest` (`{ id, spec, picks: [{ n, strength, why }] }`, `id` echoed, `strength` from `strengths` or `""`) with `--wait`, as the dashboard skill's "A strength suggestion arrives" says. Within two minutes, or the page gives up.
+35
View File
@@ -1197,6 +1197,8 @@ export function validate(state) {
if (state.loopExpect !== undefined) problems.push(...loopExpectProblems(state.loopExpect)); if (state.loopExpect !== undefined) problems.push(...loopExpectProblems(state.loopExpect));
if (state.loopOutcome !== undefined) problems.push(...loopOutcomeProblems(state.loopOutcome, state.loopExpect)); if (state.loopOutcome !== undefined) problems.push(...loopOutcomeProblems(state.loopOutcome, state.loopExpect));
if (state.loopEnd !== undefined) problems.push(...loopEndProblems(state.loopEnd, state)); if (state.loopEnd !== undefined) problems.push(...loopEndProblems(state.loopEnd, state));
// The dashboard agent's answer to Suggest for me on the loop setup screen.
if (state.loopSuggest !== undefined) problems.push(...loopSuggestProblems(state.loopSuggest));
// A note on a card is unanswered the moment no agent words follow it in its // A note on a card is unanswered the moment no agent words follow it in its
// thread. Once that is true, no patch may move past it except one that // thread. Once that is true, no patch may move past it except one that
@@ -1621,6 +1623,39 @@ export function loopOutcomeProblems(o, expect) {
return p; return p;
} }
/**
* Problems with a `loopSuggest`: the dashboard agent's strength per phase for
* the loop setup's Suggest for me, answering the page's `__loopSuggest` send.
* `{ id, spec, picks: [{ n, strength, why }] }`; `id` echoes the send's, and
* an empty `strength` is Match my session.
*/
export const SUGGEST_STRENGTHS = ["", "thrifty", "balanced", "best"];
export function loopSuggestProblems(v) {
const p = [];
const bad = (field, rule) => p.push(`loopSuggest.${field} ${rule}`);
const right = ' Like this: {"loopSuggest":{"id":"<the send id>","spec":"specs/<name>","picks":[{"n":1,"strength":"thrifty","why":"A small copy change."}]}}';
if (!isPlainObject(v)) return ["loopSuggest must be an object." + right];
if (typeof v.id !== "string" || !/^[a-z0-9-]{1,40}$/.test(v.id)) bad("id", "must be the id the __loopSuggest send carried");
if (typeof v.spec !== "string" || !/^specs\/[^/\\\r\n]+$/.test(v.spec)) bad("spec", "must be the send's spec, specs/<name>");
if (!Array.isArray(v.picks) || v.picks.length === 0) {
bad("picks", "must be a non-empty array, one { n, strength, why } per phase left");
return p;
}
const seen = new Set();
v.picks.forEach((pick, i) => {
if (!isPlainObject(pick)) return bad(`picks[${i}]`, "must be an object { n, strength, why }");
if (!isPosInt(pick.n)) bad(`picks[${i}].n`, "must be a positive integer, the phase number");
else if (seen.has(pick.n)) bad(`picks[${i}].n`, `names phase ${pick.n} twice`);
else seen.add(pick.n);
if (!SUGGEST_STRENGTHS.includes(pick.strength)) bad(`picks[${i}].strength`, 'must be one of "thrifty", "balanced", "best", or "" for Match my session');
if (pick.why !== undefined) {
if (!oneLine(pick.why, 160)) bad(`picks[${i}].why`, "must be one line of 1 to 160 characters");
else p.push(...proseProblems(pick.why, `loopSuggest.picks[${i}].why`));
}
});
return p;
}
/** /**
* Problems with a `loopEnd` (the app's word on how the loop ended), given the * Problems with a `loopEnd` (the app's word on how the loop ended), given the
* merged state so `evidence` can be checked against the docs on the page. * merged state so `evidence` can be checked against the docs on the page.
+2 -1
View File
@@ -90,7 +90,8 @@ export function pointersForSend(result, state, changes, chat = []) {
else if (a.i === "__dashboard") topics.push(state && state.finish ? "finish" : "stop"); else if (a.i === "__dashboard") topics.push(state && state.finish ? "finish" : "stop");
else if (a.i === "__stop") topics.push("stop"); else if (a.i === "__stop") topics.push("stop");
else if (a.i === "__review") topics.push("review"); else if (a.i === "__review") topics.push("review");
else if (a.i === "__learning") topics.push("learning"); // Both no-hop dashboard actions are explained in console-launches.md.
else if (a.i === "__learning" || a.i === "__loopSuggest") topics.push("learning");
else if (a.type === "answer" && typeof a.i === "string" && !a.i.startsWith("__")) { else if (a.type === "answer" && typeof a.i === "string" && !a.i.startsWith("__")) {
const item = items.find((x) => x && x.id === a.i); const item = items.find((x) => x && x.id === a.i);
if (item && item.kind === "review" && verdictOf(a)) topics.push("review"); if (item && item.kind === "review" && verdictOf(a)) topics.push("review");
+109 -3
View File
@@ -7,12 +7,15 @@
// runs or sends to the app. // runs or sends to the app.
import { el } from "../render.js"; import { el } from "../render.js";
import { hooks, page, redraw } from "../state.js"; import { hooks, page, redraw, saveNow } from "../state.js";
import { SKILL_CATALOG } from "../answers.js"; import { SKILL_CATALOG } from "../answers.js";
import { postJson } from "../net.js"; import { postJson } from "../net.js";
import { tellApp, wireLoopMessages } from "../app-bridge.js"; import { tellApp, wireLoopMessages } from "../app-bridge.js";
let justPicked = ""; // the strength node picked a moment ago, which alone plays its grow let justPicked = ""; // the strength node picked a moment ago, which alone plays its grow
// Suggest for me was pressed and has just come back (answer, time-out or failed
// send): the next draw puts focus back on the button the busy redraw replaced.
let refocusSuggest = false;
const LEVELS = [ const LEVELS = [
["critical", "Critical"], ["critical", "Critical"],
@@ -37,6 +40,8 @@ const STRENGTH_WORDS = [
["best", "Best"], ["best", "Best"],
]; ];
const MATCH_SESSION = "Match my session"; const MATCH_SESSION = "Match my session";
// How long Suggest for me waits on the dashboard agent before it gives the field back.
export const SUGGEST_WAIT_MS = 120000;
const DEFAULT_NOTIFY_PARAM = "message"; const DEFAULT_NOTIFY_PARAM = "message";
// What the setup can send a notification to. `name` is the label for the field // What the setup can send a notification to. `name` is the label for the field
@@ -66,7 +71,7 @@ export async function openLoopSetup(spec) {
const dir = spec.dir; const dir = spec.dir;
page.loopStart = null; page.loopStart = null;
page.loopNotifyTest = null; page.loopNotifyTest = null;
page.loopSetup = { spec: dir, loaded: false, failed: false, form: null, facts: null, problems: [], starting: false, resolvedFor: undefined }; page.loopSetup = { spec: dir, loaded: false, failed: false, form: null, facts: null, problems: [], starting: false, resolvedFor: undefined, suggest: null, why: {}, suggestNote: "" };
tellApp("loop-facts"); tellApp("loop-facts");
redraw(); redraw();
const mine = page.loopSetup; const mine = page.loopSetup;
@@ -186,6 +191,7 @@ export function pickModelText(resolved, word, appFacts) {
function close() { function close() {
stopWatchingLine(); stopWatchingLine();
if (page.loopSetup && page.loopSetup.suggest) clearTimeout(page.loopSetup.suggest.timer);
page.loopSetup = null; page.loopSetup = null;
page.loopStart = null; page.loopStart = null;
redraw(); redraw();
@@ -450,6 +456,70 @@ function watchStrengthLine(grid) {
if (document.fonts && document.fonts.ready) document.fonts.ready.then(redrawLine); if (document.fonts && document.fonts.ready) document.fonts.ready.then(redrawLine);
} }
/**
* Suggest for me: ask the dashboard's agent to pick a strength per phase left.
* It goes as a `__loopSuggest` send (no hop: the agent stays the dashboard),
* carrying the phases and the words this agent has mapped; the agent reads the
* phase files and posts `loopSuggest` back, which applySuggestion() fills in.
*/
async function askForSuggestion(s, words) {
if (s.suggest || page.pendingResult || page.gone) return;
const id = "ls-" + Date.now().toString(36);
const mine = { id, timer: 0 };
s.suggest = mine;
s.suggestNote = "";
mine.timer = setTimeout(() => {
if (s.suggest !== mine) return;
s.suggest = null;
refocusSuggest = true;
s.suggestNote = "The agent did not answer in time. Your picks are as they were.";
redraw();
}, SUGGEST_WAIT_MS);
redraw();
const action = {
i: "__loopSuggest",
type: "loopSuggest",
id,
spec: s.spec,
phases: s.facts.phasesLeft.map((p) => ({ n: p.n, name: p.name })),
strengths: words,
};
try {
const res = await fetch("/submit", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ actions: [action], reply: `Suggest a strength for each phase left in ${s.spec}.` }),
});
if (!res.ok) throw new Error(String(res.status));
page.pendingResult = true;
saveNow();
} catch {
if (s.suggest !== mine) return;
clearTimeout(mine.timer);
s.suggest = null;
refocusSuggest = true;
s.suggestNote = "The agent could not be asked just now. Try again in a moment.";
redraw();
}
}
/** Fill in the agent's answer to this screen's own request: mapped words only, a reason per row. */
function applySuggestion(s, answer, resolved) {
clearTimeout(s.suggest.timer);
s.suggest = null;
refocusSuggest = true;
s.why = {};
const picks = Array.isArray(answer.picks) ? answer.picks : [];
for (const p of s.facts.phasesLeft) {
const hit = picks.find((x) => x && x.n === p.n);
if (!hit || typeof hit.strength !== "string") continue;
if (hit.strength && !(resolved && resolved[hit.strength])) continue;
setPick(s.form, s.spec, p, hit.strength);
if (typeof hit.why === "string" && hit.why.trim()) s.why[p.n] = hit.why.trim();
}
s.problems = [];
}
/** The "Strength per phase" field: the toggle, Set all to, and one row per phase left. */ /** The "Strength per phase" field: the toggle, Set all to, and one row per phase left. */
function strengthField(s, redo) { function strengthField(s, redo) {
stopWatchingLine(); stopWatchingLine();
@@ -481,6 +551,15 @@ function strengthField(s, redo) {
} }
if (!f.phaseStrength) return box; if (!f.phaseStrength) return box;
const answer = page.S && page.S.loopSuggest;
if (s.suggest && answer && answer.id === s.suggest.id && answer.spec === s.spec) applySuggestion(s, answer, resolved);
const busy = Boolean(s.suggest);
if (busy) {
box.classList.add("is-suggesting");
box.setAttribute("aria-busy", "true");
sw.querySelector("input").disabled = true;
}
// An unmapped word stays in the list, grayed, so a saved one is seen and changed. // An unmapped word stays in the list, grayed, so a saved one is seen and changed.
const options = [ const options = [
["", MATCH_SESSION], ["", MATCH_SESSION],
@@ -492,10 +571,29 @@ function strengthField(s, redo) {
const everyone = select("loop-strength-all", "Set all phases to", [["-", "Choose..."], ...options.map(([v, t, d]) => [v === "" ? "match" : v, t, d])], "-", (v) => { const everyone = select("loop-strength-all", "Set all phases to", [["-", "Choose..."], ...options.map(([v, t, d]) => [v === "" ? "match" : v, t, d])], "-", (v) => {
if (v === "-") return; if (v === "-") return;
for (const p of s.facts.phasesLeft) setPick(f, s.spec, p, v === "match" ? "" : v); for (const p of s.facts.phasesLeft) setPick(f, s.spec, p, v === "match" ? "" : v);
s.why = {};
redraw(); redraw();
}); });
everyone.disabled = busy;
all.appendChild(everyone); all.appendChild(everyone);
const words = STRENGTH_WORDS.map(([word]) => word).filter((word) => resolved[word]);
const suggest = el("button", "btn loop-strength-suggest", "Suggest for me");
suggest.type = "button";
suggest.id = "loop-strength-suggest";
suggest.title = "The agent reads each phase and picks a strength for it";
suggest.disabled = busy || page.pendingResult || page.gone || !s.facts.phasesLeft.length;
suggest.addEventListener("click", () => askForSuggestion(s, words));
all.appendChild(suggest);
if (refocusSuggest && !busy) {
refocusSuggest = false;
// Only when nothing else took focus meanwhile: the busy redraw dropped it on the body.
requestAnimationFrame(() => {
const a = document.activeElement;
if (suggest.isConnected && (!a || a === document.body)) suggest.focus();
});
}
box.appendChild(all); box.appendChild(all);
if (s.suggestNote && !busy) box.appendChild(el("p", "loop-hint loop-suggest-note", s.suggestNote));
// One column per option, in rank order: level 0 is Match my session. // One column per option, in rank order: level 0 is Match my session.
const columns = [["", MATCH_SESSION], ...STRENGTH_WORDS].map(([value, label], level) => ({ value, label, level, mapped: value === "" || Boolean(resolved[value]) })); const columns = [["", MATCH_SESSION], ...STRENGTH_WORDS].map(([value, label], level) => ({ value, label, level, mapped: value === "" || Boolean(resolved[value]) }));
@@ -528,11 +626,12 @@ function strengthField(s, redo) {
input.id = `loop-strength-${p.n}-${c.value || "match"}`; input.id = `loop-strength-${p.n}-${c.value || "match"}`;
input.value = c.value; input.value = c.value;
input.checked = word === c.value; input.checked = word === c.value;
input.disabled = !c.mapped; input.disabled = !c.mapped || busy;
input.setAttribute("aria-label", `Phase ${p.n} ${c.label}`); input.setAttribute("aria-label", `Phase ${p.n} ${c.label}`);
input.addEventListener("change", () => { input.addEventListener("change", () => {
if (!input.checked) return; if (!input.checked) return;
setPick(f, s.spec, p, c.value); setPick(f, s.spec, p, c.value);
delete s.why[p.n];
s.problems = []; s.problems = [];
justPicked = input.id; // only this redraw plays the grow justPicked = input.id; // only this redraw plays the grow
redraw(); redraw();
@@ -544,6 +643,7 @@ function strengthField(s, redo) {
row.appendChild(cell); row.appendChild(cell);
} }
row.appendChild(el("span", "loop-strength-model", pickModelText(resolved, word, page.loopFacts))); row.appendChild(el("span", "loop-strength-model", pickModelText(resolved, word, page.loopFacts)));
if (s.why[p.n]) row.appendChild(el("span", "loop-strength-why", s.why[p.n]));
rows.appendChild(row); rows.appendChild(row);
} }
grid.appendChild(rows); grid.appendChild(rows);
@@ -552,6 +652,12 @@ function strengthField(s, redo) {
watchStrengthLine(grid); watchStrengthLine(grid);
} }
box.appendChild(grid); box.appendChild(grid);
if (busy) {
const veil = el("div", "loop-suggest-overlay");
veil.setAttribute("role", "status");
veil.append(el("span", "spinner"), el("span", null, "The agent is reading each phase and picking a strength..."));
box.appendChild(veil);
}
return box; return box;
} }
@@ -579,6 +579,13 @@
.loop-switch[hidden] { display: none; } .loop-switch[hidden] { display: none; }
.loop-strength-none .linky { font-size: inherit; } .loop-strength-none .linky { font-size: inherit; }
.loop-strength-all { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); } .loop-strength-all { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.loop-strength-suggest { padding: 6px 12px; font-size: var(--fs-sm); }
/* Suggest for me, waiting on the agent: the field stays visible under a veil with a spinner. */
.loop-field.is-suggesting { position: relative; }
.loop-field.is-suggesting > :not(.loop-suggest-overlay) { opacity: 0.45; pointer-events: none; }
.loop-suggest-overlay { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; font-size: var(--fs-sm); color: var(--ink); background: color-mix(in srgb, var(--bg) 55%, transparent); border-radius: 8px; cursor: progress; }
.loop-suggest-overlay .spinner { margin: 0; flex: none; }
.loop-strength-why { grid-column: 1 / -2; padding: 0 8px 8px 0; font-size: var(--fs-sm); color: var(--ink-3); overflow-wrap: anywhere; }
.loop-strength-grid { position: relative; display: grid; gap: 6px; margin-top: 6px; } .loop-strength-grid { position: relative; display: grid; gap: 6px; margin-top: 6px; }
.loop-strength-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; } .loop-strength-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }
.loop-strength-line .step { fill: none; stroke: var(--ink-3); stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; } .loop-strength-line .step { fill: none; stroke: var(--ink-3); stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; }
@@ -620,6 +627,8 @@
.loop-strength-head, .loop-strength-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } .loop-strength-head, .loop-strength-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.loop-strength-spacer, .loop-strength-model { display: none; } .loop-strength-spacer, .loop-strength-model { display: none; }
.loop-strength-phase { grid-column: 1 / -1; padding-top: 8px; } .loop-strength-phase { grid-column: 1 / -1; padding-top: 8px; }
.loop-strength-why { grid-column: 1 / -1; }
.loop-strength-all { flex-wrap: wrap; }
.loop-strength-chip { font-size: var(--fs-2xs); padding: 4px 6px; gap: 4px; flex-wrap: wrap; justify-content: center; } .loop-strength-chip { font-size: var(--fs-2xs); padding: 4px 6px; gap: 4px; flex-wrap: wrap; justify-content: center; }
} }
.loop-ticks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-left: 4px; } .loop-ticks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-left: 4px; }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "Plan2Code", "name": "Plan2Code",
"version": "3.1.1", "version": "3.1.2",
"description": "A structured workflow of six steps (Pathfinder, Plan, Document, Implement, Review, Finalize) for AI-assisted software development", "description": "A structured workflow of six steps (Pathfinder, Plan, Document, Implement, Review, Finalize) for AI-assisted software development",
"keywords": [ "keywords": [
"ai", "ai",