@buffcore/cli 0.8.45 → 0.8.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/commands/change-merge-remove.d.ts +9 -2
  3. package/dist/commands/change-merge-remove.js +27 -15
  4. package/dist/commands/design/check.d.ts +1 -1
  5. package/dist/commands/design/check.js +2 -1
  6. package/dist/commands/design/contract-size.d.ts +7 -0
  7. package/dist/commands/design/contract-size.js +47 -0
  8. package/dist/commands/design/tells.en.d.ts +2 -0
  9. package/dist/commands/design/tells.en.js +2 -0
  10. package/dist/commands/design/tells.es.js +2 -0
  11. package/dist/commands/extension/places-approval.d.ts +4 -0
  12. package/dist/commands/process-paths.d.ts +14 -0
  13. package/dist/commands/process-paths.js +90 -0
  14. package/dist/commands/prototype/ai-approval.d.ts +27 -0
  15. package/dist/commands/prototype/ai-approval.js +60 -0
  16. package/dist/commands/prototype/approver.d.ts +71 -0
  17. package/dist/commands/prototype/approver.js +168 -0
  18. package/dist/commands/prototype/browser.d.ts +4 -24
  19. package/dist/commands/prototype/browser.js +13 -76
  20. package/dist/commands/prototype/critique-gate.d.ts +14 -0
  21. package/dist/commands/prototype/critique-gate.js +48 -0
  22. package/dist/commands/prototype/fence.d.ts +1 -0
  23. package/dist/commands/prototype/fence.js +12 -0
  24. package/dist/commands/prototype/final-approval-grant.js +18 -0
  25. package/dist/commands/prototype/final-approval.js +4 -1
  26. package/dist/commands/prototype/index.js +3 -0
  27. package/dist/commands/prototype/layout-hints.d.ts +34 -0
  28. package/dist/commands/prototype/layout-hints.js +194 -0
  29. package/dist/commands/prototype/layout-measure.d.ts +39 -0
  30. package/dist/commands/prototype/layout-measure.js +97 -0
  31. package/dist/commands/prototype/layout-words.d.ts +2 -0
  32. package/dist/commands/prototype/layout-words.js +11 -0
  33. package/dist/commands/prototype/layout.en.d.ts +6 -0
  34. package/dist/commands/prototype/layout.en.js +7 -0
  35. package/dist/commands/prototype/load-location.js +2 -3
  36. package/dist/commands/prototype/loaded-garbage.d.ts +10 -0
  37. package/dist/commands/prototype/loaded-garbage.js +20 -0
  38. package/dist/commands/prototype/media-ready.d.ts +9 -3
  39. package/dist/commands/prototype/media-ready.js +9 -4
  40. package/dist/commands/prototype/messages.en.d.ts +15 -0
  41. package/dist/commands/prototype/messages.en.js +15 -0
  42. package/dist/commands/prototype/messages.js +15 -0
  43. package/dist/commands/prototype/milestone-versions.d.ts +4 -0
  44. package/dist/commands/prototype/prune-command.d.ts +5 -0
  45. package/dist/commands/prototype/prune-command.js +25 -0
  46. package/dist/commands/prototype/prune-words.d.ts +1 -0
  47. package/dist/commands/prototype/prune-words.js +7 -0
  48. package/dist/commands/prototype/prune.d.ts +16 -0
  49. package/dist/commands/prototype/prune.en.d.ts +9 -0
  50. package/dist/commands/prototype/prune.en.js +9 -0
  51. package/dist/commands/prototype/prune.es.d.ts +2 -0
  52. package/dist/commands/prototype/prune.es.js +9 -0
  53. package/dist/commands/prototype/prune.js +140 -0
  54. package/dist/commands/prototype/reopen-messages.d.ts +9 -0
  55. package/dist/commands/prototype/reopen-messages.js +19 -0
  56. package/dist/commands/prototype/report.d.ts +14 -0
  57. package/dist/commands/prototype/report.js +5 -1
  58. package/dist/commands/prototype/scene-check.d.ts +37 -0
  59. package/dist/commands/prototype/scene-check.js +68 -0
  60. package/dist/commands/prototype/scene-layout.d.ts +17 -0
  61. package/dist/commands/prototype/scene-layout.js +57 -0
  62. package/dist/commands/prototype/scene-look.d.ts +14 -0
  63. package/dist/commands/prototype/scene-look.js +89 -0
  64. package/dist/commands/prototype/scene-ready.d.ts +46 -0
  65. package/dist/commands/prototype/scene-ready.js +122 -0
  66. package/dist/commands/prototype/scene.d.ts +37 -3
  67. package/dist/commands/prototype/scene.js +103 -36
  68. package/dist/commands/prototype/selector-answer.d.ts +43 -0
  69. package/dist/commands/prototype/selector-answer.js +73 -0
  70. package/dist/commands/prototype/selector-misses.d.ts +19 -0
  71. package/dist/commands/prototype/selector-misses.js +78 -0
  72. package/dist/commands/prototype/selector-prompt.d.ts +23 -0
  73. package/dist/commands/prototype/selector-prompt.js +32 -0
  74. package/dist/commands/prototype/selector-run.d.ts +13 -0
  75. package/dist/commands/prototype/selector-run.js +113 -0
  76. package/dist/commands/prototype/selector.d.ts +54 -0
  77. package/dist/commands/prototype/selector.js +96 -0
  78. package/dist/commands/prototype/snapshot-ancestor.js +2 -0
  79. package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
  80. package/dist/commands/prototype/snapshot-bundle.js +69 -7
  81. package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
  82. package/dist/commands/prototype/snapshot-check-files.js +41 -0
  83. package/dist/commands/prototype/snapshot-command.d.ts +2 -0
  84. package/dist/commands/prototype/snapshot-command.js +23 -10
  85. package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
  86. package/dist/commands/prototype/snapshot-completion.js +30 -2
  87. package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
  88. package/dist/commands/prototype/snapshot-dependencies.js +120 -14
  89. package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
  90. package/dist/commands/prototype/snapshot-hashes.js +28 -0
  91. package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
  92. package/dist/commands/prototype/snapshot-inputs.js +140 -190
  93. package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
  94. package/dist/commands/prototype/snapshot-matrix.js +95 -0
  95. package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
  96. package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
  97. package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
  98. package/dist/commands/prototype/snapshot-owners.js +12 -3
  99. package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
  100. package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
  101. package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
  102. package/dist/commands/prototype/snapshot-progress.js +54 -102
  103. package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
  104. package/dist/commands/prototype/snapshot-registry.js +121 -0
  105. package/dist/commands/prototype/snapshot-report.d.ts +4 -0
  106. package/dist/commands/prototype/snapshot-report.js +77 -12
  107. package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
  108. package/dist/commands/prototype/snapshot-requests.js +68 -30
  109. package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
  110. package/dist/commands/prototype/snapshot-reuse.js +17 -7
  111. package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
  112. package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
  113. package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
  114. package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
  115. package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
  116. package/dist/commands/prototype/snapshot-server-record.js +135 -0
  117. package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
  118. package/dist/commands/prototype/snapshot-servers.js +54 -4
  119. package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
  120. package/dist/commands/prototype/snapshot-setup.js +2 -1
  121. package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
  122. package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
  123. package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
  124. package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
  125. package/dist/commands/prototype/snapshot.d.ts +6 -0
  126. package/dist/commands/prototype/snapshot.js +73 -10
  127. package/dist/commands/prototype/version-commands.d.ts +4 -0
  128. package/dist/commands/prototype/version-commands.js +36 -8
  129. package/dist/commands/prototype/versions.d.ts +28 -2
  130. package/dist/commands/prototype/versions.js +25 -1
  131. package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
  132. package/dist/commands/prototype/vite-fs-path.js +15 -0
  133. package/dist/commands/remove-links.d.ts +6 -0
  134. package/dist/commands/remove-links.js +17 -0
  135. package/dist/commands/size-docs.d.ts +9 -0
  136. package/dist/commands/size-docs.en.d.ts +6 -0
  137. package/dist/commands/size-docs.en.js +6 -0
  138. package/dist/commands/size-docs.es.d.ts +2 -0
  139. package/dist/commands/size-docs.es.js +6 -0
  140. package/dist/commands/size-docs.js +28 -0
  141. package/dist/commands/size.d.ts +5 -2
  142. package/dist/commands/size.js +27 -9
  143. package/dist/commands/ui/approval-authority.d.ts +10 -2
  144. package/dist/commands/ui/approval-authority.js +1 -0
  145. package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
  146. package/dist/commands/ui/autopilot-ai-approve.js +68 -0
  147. package/dist/commands/ui/autopilot-loop.js +5 -6
  148. package/dist/commands/ui/autopilot-merge.js +3 -0
  149. package/dist/commands/ui/autopilot.en.d.ts +23 -0
  150. package/dist/commands/ui/autopilot.en.js +23 -0
  151. package/dist/commands/ui/autopilot.es.d.ts +23 -0
  152. package/dist/commands/ui/autopilot.es.js +23 -0
  153. package/dist/commands/ui/chat/find.d.ts +2 -0
  154. package/dist/commands/ui/chat/find.js +13 -0
  155. package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
  156. package/dist/commands/ui/chat/fresh-codex.js +175 -0
  157. package/dist/commands/ui/chat/fresh-critique.js +13 -5
  158. package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
  159. package/dist/commands/ui/chat/fresh-launch.js +67 -11
  160. package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
  161. package/dist/commands/ui/chat/fresh-prompts.js +2 -0
  162. package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
  163. package/dist/commands/ui/chat/fresh-secrets.js +172 -0
  164. package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
  165. package/dist/commands/ui/chat/fresh.en.js +2 -1
  166. package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
  167. package/dist/commands/ui/chat/fresh.es.js +2 -1
  168. package/dist/commands/ui/chat/worktree.js +25 -5
  169. package/dist/commands/ui/index.js +3 -0
  170. package/dist/commands/ui/loop-approve.d.ts +30 -1
  171. package/dist/commands/ui/loop-approve.js +2 -2
  172. package/dist/commands/ui/merge-route.js +3 -0
  173. package/dist/commands/ui/places-change.d.ts +4 -0
  174. package/dist/commands/ui/prototype-main.d.ts +4 -0
  175. package/dist/commands/ui/reopen-route.d.ts +117 -0
  176. package/dist/commands/ui/reopen-route.js +97 -0
  177. package/dist/commands/ui/save-route.d.ts +2 -0
  178. package/dist/commands/ui/save-route.js +4 -0
  179. package/dist/commands/ui/studio-routes.js +2 -0
  180. package/dist/commands/ui/studio-state.d.ts +33 -0
  181. package/dist/commands/ui/studio-versions.d.ts +24 -0
  182. package/dist/commands/ui/worktrees.d.ts +1 -1
  183. package/dist/commands/ui/worktrees.js +19 -3
  184. package/dist/commands/worktree-sweep.d.ts +45 -0
  185. package/dist/commands/worktree-sweep.js +188 -0
  186. package/dist/commands/worktrees-command.d.ts +32 -0
  187. package/dist/commands/worktrees-command.en.d.ts +25 -0
  188. package/dist/commands/worktrees-command.en.js +55 -0
  189. package/dist/commands/worktrees-command.js +96 -0
  190. package/dist/main.js +2 -0
  191. package/dist/ui/page.js +82 -82
  192. package/docs/PROTOTYPE.md +6 -3
  193. package/docs/WORKBENCH.md +11 -6
  194. package/package.json +11 -11
  195. package/skills/ape-critique/SKILL.md +41 -6
  196. package/skills/ape-design-system/SKILL.md +3 -0
  197. package/skills/ape-plan-change/SKILL.md +6 -0
  198. package/skills/ape-prototype/SKILL.md +8 -4
  199. package/templates/product/apps/app/app.json +3 -0
package/docs/PROTOTYPE.md CHANGED
@@ -238,9 +238,10 @@ finding at that file naming its cause (the exit code or signal, the time limit,
238
238
  no result written); a failure with problems lists only those (the problems are the cause; the file is where the whole output went, with no extra finding). The studio gives each scene 120 seconds (`--scene-timeout 120`) and draws the
239
239
  scenes this branch changed since main first (`--own-first`; a view file in the branch's diff makes
240
240
  its scenes the change's own); by hand the flag is off and the order is the report's. Take stays offered for 20 seconds after one missed probe of the app (`stack.appRecent`); the page shows the probe's own answer and a click probes again. The output cap remains 2 MiB. A stopped run records no passing proof.
241
+ Each scene is kept, outside the report and Git, once it is drawn and its per-scene check (and any redraw) has finished. A run that is killed, stopped with Ctrl+C or ends with a scene that failed both tries keeps those scenes, and the next run draws only the rest, `--scene` included (a subset leaves the other scenes' kept results alone). A kept scene is used only when all of these are unchanged: the commit and branch, every uncommitted file's bytes and `prototype/scenes.ts`, the scene list (keys, surfaces, frames), the scene's own definition, the snapshot's drawing code, the browser's version, the themes, languages and options, the inputs every picture shares (public `VITE_`/`EXPO_PUBLIC_` values from the environment and the `.env` files, settings files, the lockfile, the CLI's version, the platform) and the scene's surface inputs (its settings and the files its views load); anything else starts over. A function in a scene's props counts by its source text (the pinned source tree holds it), so a value a closure captured from outside the source (the clock, the environment) is not seen; a bound or built-in function, a class instance, an accessor or a cycle turns the journal off for that run. A scene that called the API, or made a request its inputs don't cover, is not kept. A run the studio starts never uses kept scenes, since it can issue review proof: its pictures come from that run or a committed ancestor. A run that drew every scene it picked, findings or not, drops its scenes' kept results. The terminal's full-page fallback counts cover only the scenes drawn in that run. A linked worktree's run records its dev servers' processes (each one's id, start time and command line) beside the worktree's snapshot lock and refreshes the record every minute; the next run of that worktree that starts its servers (holding the lock) stops a recorded process only when all three still match and its command line holds the checkout's own folder. A run where every scene is kept still starts its servers, to read what they serve before the journal opens. A deleted worktree's servers are not stopped.
241
242
  While writing, an unref'ed one-minute heartbeat refreshes the private folder's mtime; PID protection expires at `SNAPSHOT_OWNER_MAX_AGE_MS` (ten minutes without a beat), independently of the studio's 30-minute limit, and finished runs clear the timer before releasing PID ownership.
242
243
 
243
- 1. **`ape prototype snapshot`** (with `ape dev` running) opens every scene in the product's own theme (each starter theme when it names none or names a starter, as the playground does), in every mode (light, dark, contrast and the theme's own) and every language, pseudo-locales included. It drives Playwright's own headless Chromium, never the installed Chrome or Edge (whose fresh profiles locked a Windows account out; install it once on each machine with the command in the `ape-prototype` skill, which the snapshot also names when the browser is missing), up to four pages at once, with reduced motion and after running animations have finished. It screenshots each scene in the first language, the whole page and not only the first screen (a page taller than 8 000 CSS pixels is cut there, and the report's scene lists the looks cut in `cut`, and `ape prototype snapshot` prints them as a note, not a problem; a scroller inside a fixed-height page, such as an app screen's frame, is measured and shown whole, by making the window taller for the shot as much as the tallest scroller holds beyond it, so a small list that overflows a little makes the shot a little taller; sideways scrolling, a scroller inside an iframe and a list that draws only the rows in view are not covered): each checked theme in light mode (`<scene>.<theme>.png`), and the product's theme (else the first starter theme) in dark mode too (`<scene>.<theme>.dark.png`). It checks:
244
+ 1. **`ape prototype snapshot`** (with `ape dev` running) opens every scene it draws in one of two matrices, and copies the others from an earlier report (below). **The floor**, by default: the product's own theme (the first starter theme when it names none or names a starter, as the playground does), light and dark, the product's languages and `en-XA` (its untranslated-text check), and `ar-XB` too when one of the product's languages is written right to left. **The full matrix**: each starter theme when the product names none or names a starter, every mode (light, dark, contrast and the theme's own) and every language, both pseudo-locales included. The full matrix runs with `--full` (take it for a release's report), and by itself when an input every scene shares changed since the last full report, or none is known: the theme, `design/`, each surface's shared parts as its bundle loads them (every package, BuffCore's scene pages included, the CSS, and each local file whose name is or starts with `shell`, `rail`, `store`, `setup`, `global` or `styles`, such as `store.ts`, `shell-nav.tsx` or a file in a `store/` folder, whoever loads it; a store under another name, such as `data/state.ts`, is not one), the settings and public values, and the browser and tools. A shared component outside `design/` under another name (say `src/components/Button.tsx`, used by every view) redraws the scenes that load it, in the floor only: run `--full` after such a change. `report.json` says which it drew in `matrix` (`floor` or `full`) and why in `matrixReason` (`floor`, `switch` for `--full`, `shared`), carries the last full report's shared inputs in `fullInputs`, and marks a scene drawn in the floor with `matrix: "floor"` (absent: full, as every older report). A floor scene is copied into a floor run only; a full one into either. Every check runs on every look drawn; the contrast mode's checks, the starter themes beyond the first and, for a left-to-right product, `ar-XB` run only in the full matrix. **The selector**: before a floor run of every scene draws, two fresh turns of the product's own CLI agent and model (`plan/agents.md`'s validation work, as the critique uses; Claude Code or Codex, each in its own read-only mode, see `WORKBENCH.md`) read the repository, never write, run nothing and reach no network, through the studio's fresh-turn launch: a new process and a new session each time, never a resume, so never the agent that built the change, even when that agent's turn runs the snapshot (its session variables are not passed on). Each gets the diff since the report the floor compared with (bounded), the scene list (key, surface, view), the floor's looks, the matrix's possible looks (`<theme>.<mode>.<locale>`) and the latest 20 misses, and answers `{"picks":[{"scene","look"?,"reason"}]}`: a scene to draw again in the floor (it is not copied), or a look beyond the floor for one scene. The second turn gets the first's picks without their reasons and may only add. The union is drawn; a pick outside the scene list or the matrix, a look the floor draws already, or a repeat is dropped and noted. `report.json`'s `selector` keeps each turn's agent, model, effort, state and seconds, each pick with its reason and turn, the drops and why, and the floor; a scene with added looks lists them in `extraLooks`. The floor is drawn alone, with the reason in `selector.skipped` and one line in the terminal, when the agent set has no fresh read-only turn (`agent-unsupported`: OpenCode; without `plan/agents.md` it is Claude Code, as for the critique), in CI (`CI`, and test runs), when the host's launcher starts the turns (`APE_HOST_LAUNCHED=1`), or when the first turn cannot start, fails, takes over 120 seconds or answers out of shape (a failed second turn keeps the first's picks). `--full`, a shared change and `--scene` skip it (`skipped`: `full` or `scene`). A full run of every scene that finds a problem in a look the last selector run did not draw for that scene adds it to `prototype/snapshots/selector-misses.json` (the latest 20, once each; commit it with the report), and later selector turns get those misses as examples. Limits: the selector only adds; it does not see the pictures, and a scene copied from an earlier report keeps only that report's floor pictures. It drives Playwright's own headless Chromium, never the installed Chrome or Edge (whose fresh profiles locked a Windows account out; install it once on each machine with the command in the `ape-prototype` skill, which the snapshot also names when the browser is missing), up to four pages at once, with reduced motion and after running animations have finished. It screenshots each scene in the first language, the whole page and not only the first screen (a page taller than 8 000 CSS pixels is cut there, and the report's scene lists the looks cut in `cut`, and `ape prototype snapshot` prints them as a note, not a problem; a scroller inside a fixed-height page, such as an app screen's frame, is measured and shown whole, by making the window taller for the shot as much as the tallest scroller holds beyond it, so a small list that overflows a little makes the shot a little taller; sideways scrolling, a scroller inside an iframe and a list that draws only the rows in view are not covered): each checked theme in light mode (`<scene>.<theme>.png`), and the product's theme (else the first starter theme) in dark mode too (`<scene>.<theme>.dark.png`). It checks:
244
245
  - **text too faint to read, as drawn,** in every theme, mode and language: each piece of text on screen (not hidden, `aria-hidden` or off screen) in its computed color against what is drawn behind it, through every see-through background and opacity. It needs 4.5:1, or 3:1 for large text (24 px, or 18.66 px bold); disabled controls too, since a child still reads the button they wait on. Text over an image or a gradient isn't measured. Each color pair is reported once per scene, theme and mode, in the first language that shows it;
245
246
  - **a box past the page's edges** (`clipped`), in every mode: an element whose box runs past the viewport's inline edges, or past an ancestor that clips, with no scrolling ancestor to reach it. A cell cut off at 390 px is a problem naming the scene, the mode and the element; text cut off with an ellipsis is not;
246
247
  - in light mode: untranslated text in `en-XA` (text marked `translate="no"`, such as content shown as JSON, counts as data), text cut off, and app touch targets under 44 px;
@@ -249,6 +250,8 @@ While writing, an unref'ed one-minute heartbeat refreshes the private folder's m
249
250
 
250
251
  **Font hints.** The snapshot suggests looking at text that Chromium appears to draw in a fallback family. Each hint names the scene, sampled text, expected family and drawn family. The terminal prints these hints and `report.json` has an optional `hints` list. The hints leave the snapshot status and approval gates unchanged. In each look the snapshot samples up to 60 visible elements and up to 200 characters of direct text per element. It compares glyph counts for the first named theme family using fonts the page has already drawn with. All looks and frames share an 850 ms advisory budget per scene. The scene gives no hints if that budget runs out. System and generic stacks, Shadow DOM and canvas are outside the sample.
251
252
 
253
+ **Layout hints.** In light mode and the first language, each theme's look measures the laid-out boxes after its picture and suggests four kinds of spacing slip: two siblings in the flow that overlap (a layer, absolute, fixed or sticky, a dialog, menu, toast or popover, is left out); a box with text more than 1 and at most 4 px off the edge most of its siblings share (start, centre or end, as the parent aligns them, the start read right to left in an RTL language; a box with no background, border or shadow, or one bleeding past its parent by its own padding, is read at its content's edge, and an icon is placed by eye, so it is left out); a sibling of the same component (same tag, role, display, direction, corners and children) whose padding or gaps differ from at least three others' (the first of a list may drop its top padding, and the last its bottom); and space between neighbours in a row or column that is no step of the fine half of the theme's `space-*` scale (its six smallest steps, at the scene's `scale`), naming the nearest token. A hairline under the smallest step, wider spaces, prose (paragraphs, headings, lists) and neighbours that keep the same room outside (a margin giving back a thinner border) are left out. Each hint names the scene, the elements and the measured values; a scene has at most 20, each once. They go in `report.json`'s `hints` and the terminal like the font hints, and leave the pictures, the snapshot status and the gates unchanged; the critique confirms or dismisses each. A scene marks one it shows on purpose with `layoutExceptions` in `prototype/scenes.ts`: `{ kind: 'overlap' | 'edge' | 'padding' | 'gap', element?: <words of the element named>, reason }`. Measuring costs a few milliseconds a look (about 10 ms on the playground's median scene, 11 ms on a 600-element page).
254
+
252
255
  Before timing scenes it warms each used surface. A warm-up that times out leaves the scene to its own deadline. It opens half the machine's available cores in pages, rounded down and capped at four, with about 2 GB of free memory for each page beyond the first. A run drawing admin scenes defaults to at most two after a four-page run lost a scene in the playground. When there is too little memory for the default number of pages, it uses two, or one below 2 GB. `--pages <n>` uses the requested count from 1 to 4. A run still needs 1.5 GB of free memory to start (`APE_SNAPSHOT_MIN_FREE_MB` changes the floor, and 0 turns it off).
253
256
  Chromium relaunches after every 40 scenes once the current scenes finish. A module that fails to load gets one reload, and a page that fails to load or goes away during a check gets one retry in a fresh page. A scene check finding fails the run without a retry. The snapshot keeps drawing the other scenes and the report lists every result, with failures named. Theme checks run first and can fail before a server starts.
254
257
 
@@ -260,11 +263,11 @@ While writing, an unref'ed one-minute heartbeat refreshes the private folder's m
260
263
  - **`--scene-timeout <seconds>`** sets the render deadline (default **30 seconds**, positive seconds, fractions allowed). It covers page loading, readiness, rendering, required checks and screenshots. A scene that reaches the deadline gets one fresh page with twice the limit. The run names the retried scenes. An uncaught page exception or console error also gets one fresh page, at the same limit; the run prints the first error's redacted line, and `report.json` marks the scene (`retried`, plus `retryError` after an error). A scene gets one such retry in all: a second timeout or error fails it with that second failure, and the run keeps going. A render error while warming a surface, or after a retry for a page that didn't load, fails its scene at once. The browser closes through normal teardown, and development servers you started stay running. Text and `--json` failures name the scene and use the existing safe diagnostics, including redaction. Render failures exit **1**, and unmatched patterns exit **2**.
261
264
  - **`--remake`** makes the last committed snapshot's screenshots again, from the commit checked out (no changes allowed), into the report's folder: only the looks it photographs, without the checks; `report.json` stays as it is. Run it where the screenshots aren't: another computer, or the main checkout after a worker's change is merged.
262
265
  - If a view consumes an ignored fixture file, use `--remake` to refresh the screenshots after changing that file, since the checkout fingerprint does not see ignored fixture files.
263
- A full snapshot can copy an unchanged scene's checks and local screenshots from a committed ancestor report. The studio marks each copied scene with its source commit, and the report records each screenshot's SHA-256. Changing a scene's plain props redraws that scene. Changing an imported file redraws the scenes on the surfaces that load it, so a change confined to the admin leaves the app's scenes reusable and a shared import redraws both. Browser changes, unresolved imports, API calls, and missing or changed screenshots also require a redraw. The fingerprint does not cover views that read the clock, random values, or the development server's own environment. Post-merge snapshots use the same rule. A full snapshot therefore costs at most the scenes whose inputs changed (plus any that cannot be reused, and everything the first time): use `--scene` while you work, and take one full snapshot when a person is to look at a version, before a milestone's approval and before a release.
266
+ A full snapshot can copy an unchanged scene's checks and local screenshots from a committed ancestor report. The studio marks each copied scene with its source commit, and the report records each screenshot's SHA-256. Changing a scene's plain props redraws that scene. Changing a file a view imports redraws the scenes whose views load it. The console gets this per view only when `apps/admin/src/prototype/views.ts` registers each view with React's `lazy` and a literal relative import; a view imported directly counts as a shared part. An app on Metro is one bundle, so an app view edit redraws all the app's scenes. A change to a shared part redraws every scene: the theme, `design/`, the shells, the store, the scene pages, or the snapshot's own code and message catalogs. A scene whose props hold a function is never reused from another commit, since a function's text can stay the same while its helpers change. A scene that made a request its inputs don't cover is drawn again. Browser changes, unresolved imports, API calls, and missing or changed screenshots also require a redraw. The fingerprint does not cover views that read the clock, random values, or the development server's own environment. Post-merge snapshots use the same rule. A full snapshot therefore costs at most the scenes whose inputs changed (plus any that cannot be reused, and everything the first time): use `--scene` while you work, and take one full snapshot when a person is to look at a version, before a milestone's approval and before a release.
264
267
  In a change's own worktree the snapshot runs on its own: it starts that worktree's admin and app on ports the system gives that run (with a stand-in where the API would be, so its report says `api: "stand-in"` and a scene that calls the API is drawn without one and never reused), from an environment built only from the tracked `.env.example`; it never uses main's servers, `--remake` is refused there, and the root `.env` is not read (the admin's and the app's own gitignored `.env*` files are still loaded by Vite and Expo, and their public values count in the fingerprint). One snapshot runs per worktree and two per repository, and main's snapshots never wait for them. After a full snapshot with no problems taken over saved work, its screenshots are kept for the main checkout (`.git/ape-validation/shots/`, the newest 20 folders, each named by the exact bytes of `report.json`), so a merge's check copies unchanged scenes from them even when the worktree is gone; every copied byte is hash-checked against the committed report. A snapshot stopped by Ctrl+C, a closed terminal or a catchable stop takes its servers down with it and frees its locks. **Known limit:** on macOS and Linux a hard kill (SIGKILL, which is what the studio's Stop sends, to the snapshot process only) cannot be caught and leaves its two servers running (about 2 GB): find them with `lsof -a -d cwd -c node` (their working folder is the worktree's `admin` or `app` folder) and `kill` them; on Windows the stop takes the whole tree. **The terminal door guarantees less:** a person who runs the snapshot in their own terminal runs the CLI with that shell's variables, and the CLI imports the branch's `prototype/scenes.ts` and `buffcore.config.ts` in that process, so branch code can read them; the servers still get only the built environment. A branch an agent wrote is snapshotted from the studio.
265
268
 
266
269
  2. **Commit the change with `report.json` and `data.json`.** The commit is what gets reviewed: its views, its scenes and its snapshot's report and data model. The report's folder is named for the commit checked out when the snapshot ran, the one before; the commit that holds it is the one approved. The `ape-prototype` skill walks an agent through the loop.
267
- 3. **Record a version:** `ape prototype version C-012 --why "Simpler first journey"` records the full snapshot's source commit as the next version in `prototype/versions/C-012.json`. One run takes several changes from the same snapshot (`ape prototype version C-012 C-013 --why "..."`): all are recorded or none, `--json` then answers `records` (a list, in the order named) instead of `record`, and outside the studio (the command line and MCP `prototype_version`) another change's uncommitted record that Record could have written from this same snapshot does not count as a change to the checkout. Each change must exist in `plan/changes/`, the checkout must be unchanged, and the commit must hold a snapshot's `report.json` and `data.json`. A partial, failing or incomplete report is refused, and so is one taken over unsaved work: `report.json` says `dirty` (anything uncommitted in the repository except the untracked files in this product's `prototype/snapshots/`, asked again once the scenes are drawn), and Record refuses `dirty: true` or no `dirty` at all (an older ape): save the work and take the snapshot again. Record also derives the design hash and the sample data model again from a clean copy of the commit and refuses a report that differs or a derivation that fails. The copy holds the commit's own bytes, never the working tree, workspace packages included: each `node_modules` beside a committed `package.json` is rebuilt there, an entry that links to a folder of the repository points at the copy's folder, anything else under a `node_modules` folder is linked in and trusted as an installed package, whoever wrote it (an untracked folder a turn wrote there too), and a module the child's own thread loads from anywhere else (the real checkout, an absolute path) is refused; a Worker thread's loads are not seen. A commit whose paths are not the same files on every disk (two that differ only in case or Unicode form, a folder included, or a name with a character Windows reserves, a trailing dot or space, or a short-name alias that Windows reads as another file, such as `notes.ts::$DATA`, `notes.ts.` or `PROTOT~1`) is refused on every platform (each file of the copy is created only once), and so is a commit over 50,000 files or 1 GiB. A copy a stopped Record left is removed by the next Record after an hour. The commit's theme and sample-data code run in the copy in a separate process, not a sandbox: it has your own rights (no Node permission flags), so it can write wherever you can, the installed packages through the `node_modules` link included, and a process it starts can outlive it; Record's own process loads none of that code. That catches a snapshot whose unsaved edits were set aside before Record, and it means sample data must read only committed files and give the same values every time it is read (no dates from the clock, no random values). Not proved: Record does not draw the screens again, so screenshots made on purpose from unsaved screen code, under a hand-written report, are not caught; nor are files read with `fs` outside the copy (the real checkout included), the network or the environment, what the installed packages do, or committed code that deliberately answers Record differently (a Worker thread that loads the real checkout's files, say). A snapshot over unsaved work is still the way to look at work in progress. The CLI and the studio use one source rule: the report's source must resolve to HEAD or an ancestor, and between that source and HEAD only the version's own records may change (the set Approve accepts too: snapshots, `prototype/versions/`, `plan/changes/`, `design/approval.json`, `plan/approvals.md`, in this product's folder when it is in a repository subfolder; a name is compared exactly, leading whitespace included, and a submodule's pointer always counts as a change). Saving the snapshot files enables Record, and so does recording and approving another change first; any other changed file makes it stale and Record names up to three of them, so snapshot every scene again. The studio reads the server's `recordable` field and rechecks the proof after the file review and save. The record holds that full source commit hash, sha256 fingerprints of the exact report and data, the report's design hash, the reason and the time. Commit the version record too.
270
+ 3. **Record a version:** `ape prototype version C-012 --why "Simpler first journey"` records the full snapshot's source commit as the next version in `prototype/versions/C-012.json`. One run takes several changes from the same snapshot (`ape prototype version C-012 C-013 --why "..."`): all are recorded or none, `--json` then answers `records` (a list, in the order named) instead of `record`, and outside the studio (the command line and MCP `prototype_version`) another change's uncommitted record that Record could have written from this same snapshot does not count as a change to the checkout. Each change must exist in `plan/changes/`, the checkout must be unchanged, and the commit must hold a snapshot's `report.json` and `data.json`. A partial, failing or incomplete report is refused, and so is one that drew a scene below the floor (a floor or full report is accepted, its copied scenes keeping the matrix their report drew them in; a full report's own scenes must be full); take a milestone's or a release's report with `--full`, which copies what it can (a milestone's approval takes only a version whose report drew every scene in the full matrix, judged per scene, and otherwise asks for a full report of that commit; a change's version from a floor report is fine for building to match). At Autopilot a version may be approved by AI, through a fresh approver turn (WORKBENCH.md); its signature carries `agent` and `ai` (`model`, `reason`), and `ape prototype reopen <change>` lets a person reopen it. It also refuses one taken over unsaved work: `report.json` says `dirty` (anything uncommitted in the repository except the untracked files in this product's `prototype/snapshots/`, asked again once the scenes are drawn), and Record refuses `dirty: true` or no `dirty` at all (an older ape): save the work and take the snapshot again. Record also derives the design hash and the sample data model again from a clean copy of the commit and refuses a report that differs or a derivation that fails. The copy holds the commit's own bytes, never the working tree, workspace packages included: each `node_modules` beside a committed `package.json` is rebuilt there, an entry that links to a folder of the repository points at the copy's folder, anything else under a `node_modules` folder is linked in and trusted as an installed package, whoever wrote it (an untracked folder a turn wrote there too), and a module the child's own thread loads from anywhere else (the real checkout, an absolute path) is refused; a Worker thread's loads are not seen. A commit whose paths are not the same files on every disk (two that differ only in case or Unicode form, a folder included, or a name with a character Windows reserves, a trailing dot or space, or a short-name alias that Windows reads as another file, such as `notes.ts::$DATA`, `notes.ts.` or `PROTOT~1`) is refused on every platform (each file of the copy is created only once), and so is a commit over 50,000 files or 1 GiB. A copy a stopped Record left is removed by the next Record after an hour. The commit's theme and sample-data code run in the copy in a separate process, not a sandbox: it has your own rights (no Node permission flags), so it can write wherever you can, the installed packages through the `node_modules` link included, and a process it starts can outlive it; Record's own process loads none of that code. That catches a snapshot whose unsaved edits were set aside before Record, and it means sample data must read only committed files and give the same values every time it is read (no dates from the clock, no random values). Not proved: Record does not draw the screens again, so screenshots made on purpose from unsaved screen code, under a hand-written report, are not caught; nor are files read with `fs` outside the copy (the real checkout included), the network or the environment, what the installed packages do, or committed code that deliberately answers Record differently (a Worker thread that loads the real checkout's files, say). A snapshot over unsaved work is still the way to look at work in progress. The CLI and the studio use one source rule: the report's source must resolve to HEAD or an ancestor, and between that source and HEAD only the version's own records may change (the set Approve accepts too: snapshots, `prototype/versions/`, `plan/changes/`, `design/approval.json`, `plan/approvals.md`, in this product's folder when it is in a repository subfolder; a name is compared exactly, leading whitespace included, and a submodule's pointer always counts as a change). Saving the snapshot files enables Record, and so does recording and approving another change first; any other changed file makes it stale and Record names up to three of them, so snapshot every scene again. The studio reads the server's `recordable` field and rechecks the proof after the file review and save. The record holds that full source commit hash, sha256 fingerprints of the exact report and data, the report's design hash, the reason and the time. Commit the version record too.
268
271
  4. **Approve one version** after looking at its snapshot report (screenshots made again with `--remake` where needed), problems and viewer: `ape prototype approve C-012 [--version 2]` defaults to the latest version. For terminal approval, a person types `C-012` to confirm. The same file records the approved version and signature: git's `user.email`, time, full commit and `<report>:<data>:<design>` fingerprint. A completed person-approved version is preserved by later drafts. A person can replace it by approving the change's newest saved version (the studio's Approve button, or `ape prototype approve C-012`, which then means the latest), with the same rule and rights as a first approval; an agent or Autopilot cannot, and an older version cannot. Until the new version's signatures hold under the rule, they wait in the record's `pending` and the earlier approval stays in force (a merge in the checkout reads it; a merge through a host approval authority needs the newest snapshot approved, so it waits, as it did once that version was recorded; so does coding, which says "A newer version (v4) is recorded and waits for approval.", with "1 of 2 signed" once someone signed); recording a newer version drops them, and once the rule's window closes the round cannot complete, so record a new version. The signature that completes the rule replaces the approval in one write, and the replaced approval stays in the record's `superseded` list with its signatures. The record has no lock, as before: two signatures saved at the same moment from two places can lose one, so check the record after signing. With a host approval authority the host holds the signatures: the newest version whose grant holds under the rule stands (a partial grant displaces nothing), except that a person's approval, one with any person's signature, gives way only to a grant people alone signed, as in the record; Autopilot leaves a newer version beside a person's approval to a person. In BuffCore's repository the owner approves. Commit this record. The workbench can call the same approval write on the person's click.
269
272
  The studio's Approve answers by what the evidence covers, not by HEAD moving: it refuses, naming each difference, when snapshot files wait uncommitted (save them or set them aside), when the report, data or design the record holds is not what HEAD commits, or when any file in the repository changed between its source commit and HEAD other than the version's own records (the set listed under Record). Any other changed file makes it stale, so an upgrade's `package.json` or lockfile change makes pending versions stale: take a new snapshot. An unexpected error is logged and answered as itself, never as a stale snapshot.
270
273
 
package/docs/WORKBENCH.md CHANGED
@@ -6,7 +6,11 @@ release as a no-op and prints a notice.
6
6
  The page title, terminal help and startup address call it the studio (estudio in Spanish).
7
7
  `ape create` and the product README list its computed port beside the product's other ports.
8
8
 
9
- The studio has four levels of how much the agent does before it asks (`plan/agents.md`; the Level chooser). **You drive** proposes each step and waits for you. **Review** completes one step, then asks for your approval. **Lead** drafts only when you ask. **Autopilot** lets the agent go on by itself: at the end of a turn it takes the loop's choices, saves the step, approves where the product's rule lets an agent, and merges a finished change once its checks pass. It never starts the next build by itself, and a release, deploy or money action always waits for a person.
9
+ The studio has four levels of how much the agent does before it asks (`plan/agents.md`; the Level chooser). **You drive** proposes each step and waits for you. **Review** completes one step, then asks for your approval. **Lead** drafts only when you ask. **Autopilot** lets the agent go on by itself: at the end of a turn it takes the loop's choices, saves the step, approves where the product's rule lets an agent (a prototype version only through a fresh approver turn, below), and merges a finished change once its checks pass. It never starts the next build by itself, and a release, deploy or money action always waits for a person.
10
+
11
+ **Fresh read-only turns (the critique, the selector and the approver).** Each is a new process and a new session of the product's own CLI agent for the job (`plan/agents.md`'s validation agent), never a resume, so never the builder's session even when the builder is the same agent kind; the building turn's variables (every `CODEX_*`, `CLAUDE_CODE_*` and `CLAUDECODE`) are not passed on, except a short allowlist the turn needs (`FRESH_ALLOWED` in `fresh-codex.ts`: `CODEX_HOME`, Codex's CA certificate and Claude Code's sign-in variables); `HOME` and the CA variables pass as they are. The prompt goes in, one final answer comes out, the turn has a time limit and its process tree is stopped when it runs over, and the agent uses its own sign-in on the machine. **Claude Code**: `-p` with `--permission-mode dontAsk`, Read, Glob and Grep allowed, writes, web tools and other agents denied, secret files denied, no hooks or MCP servers. **Codex**: `codex exec --ephemeral --ignore-user-config --ignore-rules -s read-only` (a new, unsaved session; the user's config with its MCP servers, hooks and rules left out, the sign-in in `CODEX_HOME` still holds; no trust passed for the folder), `approval_policy="never"`, `--disable` for `apps`, `plugins`, `hooks`, `browser_use`, `browser_use_external`, `computer_use`, `in_app_browser`, `remote_plugin` and `skill_mcp_dependency_install`, the product's MCP server and web search off. `-s read-only` is Codex's own sandbox: no command writes or reaches the network, whatever the product's profile says. On Windows the turn also passes `windows.sandbox="elevated"` and Codex is offered only when the studio's own readiness check finds Codex's elevated Windows sandbox set up (else `codex-sandbox`, saying so). **Not proven here:** the network block and the read-only hold rest on Codex's sandbox (the elevated one on Windows), which no test here exercises live; the tests prove the arguments (Codex refuses a sandbox mode beside a permission profile override, and the sandbox mode wins over a profile in config). **Lost against Claude:** the product's deny-read profile does not apply, so the turn can read secret files in the folder (`.env*`, keys) and `design/critique.md` in the loop; it cannot write them or send them anywhere but its answer. Codex's sandbox lets any read-only command run, so its prompt names the same two checks as the loop's Claude critique (`node <cli>/bin/ape.mjs design check` and `i18n check`), or none; the sandbox, not the prompt, is the guarantee. A product whose `.codex/config.toml` (from the folder up to the repository's root) holds anything beyond `default_permissions`, `[permissions.*]` and the studio's own `[mcp_servers.ape]` (command and args), or that has a `.codex/hooks.json`, a `.codex/agents` folder or a `.agents/skills` folder, gets no fresh Codex turn (`agent-unsupported`): an MCP server or a hook runs outside the sandbox. **No secret leaves a fresh turn** (Claude Code and Codex alike): before an answer is kept, shown or passed on, the studio compares it with the values in the secret files such a turn can read: the files Claude's deny rules name in the turn's folder and, for a linked worktree, in the main checkout, every file in the home's secret folders (`.ssh`, `.aws` and the rest; caches, `buildx` and `commands` folders aside), the home's sign-in files (`.npmrc`, `.git-credentials`, `.netrc`, `.config/gh/hosts.yml`, `.pypirc`, `.claude/.credentials.json`) and `CODEX_HOME/auth.json`, at most 400 files a place (the shallowest first) and 256 KB a file, `.example` files aside. A JSON file's string values and each other line's value (an unquoted `.env` value ends at ` #`) are compared; values under 8 characters, plain lowercase words of 12 characters or fewer under a key naming no PASSWORD, SECRET, TOKEN, KEY or CREDENTIAL (`development`), and URLs without user info that are on the loopback host or have no query, fragment or path beyond `/` are not. **Not caught:** a secret the answer encodes, splits or paraphrases, and one stored anywhere else on the disk. **Not proven live:** the read-only hold and the network block rest on Codex's own sandbox; no test here runs a real Codex turn. An answer that quotes one is dropped: the selector draws the floor alone (`skipped: "secret"` with `file`), the critique is not written and the approver leaves the version waiting for a person, each naming the file, never the value. **OpenCode** has no fresh read-only turn: it has no read-only mode the studio can prove (its overlay rules cover its built-in tools, not plugins or MCP servers from the person's or project's config), so with OpenCode set for validation the selector draws the floor alone (`agent-unsupported`), the critique is left to a person and the approver leaves the version waiting for a person.
12
+
13
+ **AI approval of a prototype version (Autopilot only).** The building agent never approves its own version. At Autopilot, once a version is recorded, the studio runs its own fresh critique turn for the version's report (never a `design/critique.md` the building agent wrote), then asks one fresh, read-only turn of the agent and model `plan/agents.md` sets for validation (the critique's choice, through the same launch; Claude Code or Codex, below) to approve or decline, with a one-line reason, and only when all hold: the report drew at least the floor for every scene and records the selector (or why it did not run); every check passed; that critique names the report's commit and no P0; and every look the second selector turn added was drawn (the conservative reading: drawn and passed; a full run agrees). Any failed condition, another agent, a failure, a timeout over 180 seconds, an answer out of shape, a decline, or a turn that cannot show a session of its own leaves the version waiting for a person, with the reason. The signature records `agent` and `ai` (`model`, `reason`) beside the commit and time: an AI approval, never a person's. It counts as approved for building to match. The studio's approval card shows it as "Approved by AI (model): reason" beside the approval seal, and a person reopens it at any level with the card's Reopen button or `ape prototype reopen <change>` (it moves to `superseded` with who and when, in its own commit; behind a host, the host's `approval` hook decides). Reopen does not stop Autopilot from approving the next version: leaving Autopilot does. Behind a host, the approval request carries `ai` too, and a host that ignores it still answers a valid approval. You drive, Review and Lead never run the approver. A milestone approval, the comp, releases, deploys and money stay a person's.
10
14
 
11
15
  Before the first plan, the Plan empty state, kickoff and product README explain how to merge `{"permissions":{"additionalDirectories":["../<folder>"]}}` for one sibling notes folder into the git-ignored `.claude/settings.local.json` by hand, allowing Claude Code to read and change its files; after a refused read the agent panel can also add it with one click (below).
12
16
 
@@ -122,8 +126,8 @@ build time, or from source when running in the checkout.
122
126
  Build's Changes card says when no changes exist yet.
123
127
  - Work shows plan titles as a list, by milestone, by journey or as a board, with worktrees and clashes.
124
128
  The board is read-only: a column per state (Planned, Next up, Building, Checking, Waiting for you, and Done as a count) and a swim lane per milestone or journey, or none; a phone shows one column at a time. Checks run before
125
- and after each merge, whether started by a person or Autopilot. The server removes only
126
- clean, merged worktrees, but no button calls it yet.
129
+ and after each merge, whether started by a person or Autopilot.
130
+ **Cleaning up.** When the studio starts and after each merge that goes through (a person's or Autopilot's), it sweeps `.ape/worktrees/`: a change worktree whose branch tip main brought in by a merge, with nothing uncommitted (untracked files count) and that no studio turn (running, or recorded as holding it) and no process holds, is removed under the merge lock with the safe removal below; its branch stays. A process holds a folder when its command line names it, or (Linux, macOS) it works inside it; Windows gives only command lines. A process table that cannot be read keeps every worktree. A new branch still at main's tip is not merged, so a fresh worktree stays. Work's Worktrees list says why a merged one was kept (in use, or it could not be removed), and Other worktrees lists, read-only, the linked worktrees that are no change's (a builder's, say); `ape worktrees clean` removes those (AI_NATIVE.md).
127
131
  Every merge (the Merge button, Autopilot, a host's, `ape change merge`) holds a change that touches a protected path or lowers a coverage floor, before the branch's checks run, by the list in main's committed `buffcore.config.ts` read as text (with no `agents.protected`, the config and the files ape writes), never by the branch's copy or its hooks; a missing or unreadable list holds every merge.
128
132
  A local Autopilot merge starts after the saved successful end of a coding, tests or fixes turn. It checks the latest branch tip and the resulting merge commit. It rechecks the temporary checkout's HEAD and removes that checkout before publishing. The Git transaction verifies the branch tip and main before it moves main. A failed cleanup holds the merge. On the next merge, the studio and `ape change merge` can remove a dead owner's checkout recorded in the merge lock. Its commit subject uses the change ID and up to 100 characters of the title on one line, for example `Merge C-001: Add notes`.
129
133
  When main’s checkout has unsaved files, Autopilot names them and retries on a save or finished turn, asking for help if that event still finds unsaved files after 30 seconds.
@@ -133,7 +137,7 @@ build time, or from source when running in the checkout.
133
137
  What it stops: ape's git in a change's worktree (creating it, its status, its authority reads, a catch-up), in the merge's own checkout, and in the studio's reads of the product folder (the snapshot report's status, loop approvals) runs none of that checkout's hooks, no signing program, no global attributes file, no fsmonitor or untracked cache, no `diff.relative`, and none of the caller's `GIT_*` settings. Hooks and the attributes file point at a path where nothing can exist: `/dev/null` on POSIX; on Windows a path under this Node's own executable, since Git for Windows reads `/dev/null` as a folder on the current drive that any account may create. One helper does this, `safe-git.ts`; a test in `pnpm verify` scans every package's source for git named in code (a pattern scan over a small lexer's code and strings, not a proof) and fails on a file outside its lists, and on a pinned file that writes or refreshes the index, moves a ref or runs a hook without saying why. A product's own merge hooks (`pre-merge-commit`, `post-merge`, `post-checkout`) therefore no longer run on ape's merges. ape's merge and catch-up commits are now unsigned even when the person's config asks for signing, so a git host that requires signed commits on main refuses them, and merges no longer read the global attributes file (`core.attributesFile`). Main moves only by a compare-and-swap from the commit every check read; a main that moved during the merge fails it as moved, never as busy or uncommitted work.
134
138
  The Save still runs the product's commit and reference hooks, from the folder `core.hooksPath` names in the product's checkout, after a check (`save-hooks.ts`, whose table this is). A hook-named file (in any case) at that folder's top that differs from the last commit (changed, deleted, new, or hidden by a `.gitignore` or `info/exclude` line), or a committed file in the folder that changed or is gone (a helper a hook sources), stops the Save before any hook runs, naming the files: commit or discard them, then save again. "Differs" is a fresh hash of each file against the last commit, never git's stat cache, so a same-size edit with its time put back still stops it. Other files there (`.DS_Store`, husky 6–8's ignored `_/` folder) are ignored. So husky 6–8 (`core.hooksPath=.husky`, its hooks committed) saves as before, though the `_/husky.sh` each hook sources is not checked; husky 9 (`core.hooksPath=.husky/_`, generated, ignored hook-named files) stops every Save, naming them; `ape create` sets a committed `.githooks`. Not checked: hooks in `.git/hooks` (no `core.hooksPath`) or elsewhere under `.git`, since whoever can write there can write `.git/config` too, whose filters the Save's git runs anyway, and refusing would stop every product whose hook tool installs there; and a folder outside the checkout. Not covered either: a new helper a committed hook sources, what the hooks run from the working tree (the template's `pre-commit` runs `scripts/check-secrets.mjs` and Biome, which a turn can edit), and a write after the check by a turn still running. ape's settings above also reach the Save's staging and its hooks' own git: no `post-index-change` hook, no signing by config, no global attributes file. Its config reads (the hooks folder, signing) skip ape's settings but not the scrubbed environment, so a `GIT_CONFIG_GLOBAL` set there no longer reaches them; the Save signs with `-S` when the person's config says so.
135
139
  When the merged commit's `pnpm-lock.yaml` or `pnpm-workspace.yaml` differs from main's, the merge first installs its packages there (otherwise no package manager runs, and the checkout's `node_modules` links are made as above): `pnpm install --offline --frozen-lockfile --ignore-scripts --ignore-pnpmfile`, from this computer's store only, in the folder that holds the lockfile, with that folder as pnpm's project (`--dir`) and only workspace (never one above it), for at most 10 minutes; the merge's stop ends it. Before pnpm runs it refuses a `link:`, `file:` or `portal:` path, a `directory`, a lockfile importer or a workspace pattern that leaves the temporary checkout by its words (`..`, an absolute, drive, home or `%`-escaped path) or by its real path (through a link), except a `link:` main's committed lockfile has to the same folder from main's checkout (an `ape link` product), which is then pointed at main's folder; a commit that tracks any `node_modules` path (pnpm writes only there, in folders it makes); a dependency name that is not a plain name; any package that is neither a registry package exactly as main's committed lockfile has it (the same `packages` entry, resolved by integrity) nor a workspace, `link:` or `file:` folder inside the temporary checkout with a plain `package.json` (no `package.yaml` or `package.json5`) whose commands are plain names (`bin` as a string, the package name without its scope, or as an object; `directories.bin` refuses), so a new registry package, a tarball, or a git or URL package is not installed automatically: merge it at a terminal with git, then run `pnpm install`; it also refuses a `.npmrc` key off a closed list (`auto-install-peers`, `dedupe-peer-dependents`, `engine-strict`, `hoist`, `hoist-pattern`, `link-workspace-packages`, `node-linker`, `prefer-workspace-packages`, `public-hoist-pattern`, `resolution-mode`, `resolve-peers-from-workspace-root`, `save-exact`, `save-prefix`, `shamefully-hoist`, `strict-peer-dependencies`: no folder, store, registry, shell, hook or node version), a `pnpm-workspace.yaml` key but `packages`, `catalog` and `catalogs`, a `pnpm`, `packageManager` or `devEngines` field in the root `package.json` that is not main's, a patch file (`patchedDependencies` in the lockfile or any package's `package.json`) that is not main's byte for byte (no line-ending conversion: pnpm reads the bytes), is missing or a link, or names a path with `..`, an absolute, drive or home path, or a quoted name, each path read as pnpm reads it (pnpm applies a patch's paths with scripts off), and a lockfile with no plain `package.json` beside it (pnpm would take the nearest one above, main's). A refusal is `failure.kind` `installRefused` (`failure.name` `link`, `setting`, `patch`, `manifest` or `package`; for `package`, `failure.tail` is the first package that refused, bounded and redacted), `install` (pnpm failed, such as for a package this computer's store does not have; its error line is the tail) or `installTimeout`, each with a fixed sentence. Nothing the branch controls runs in the install (no scripts, no pnpmfile); the branch's code still runs on this computer in its done-when checks, with the person's own file access. A missing package when nothing was installed (a bare package name, not a path) gets a fixed sentence: a person can merge it at a terminal with git, then run `pnpm install`.
136
- Before the temporary checkout is deleted (`git worktree remove --force`), every link and junction in it is removed as itself, never through it, and a folder is entered only when its real path is its own, so the deletion never reaches a folder outside; when that fails, the merge refuses in a fixed sentence and leaves the folder in place. Removing a change worktree removes its links the same way first.
140
+ Before the temporary checkout is deleted (`git worktree remove --force`), every link and junction in it is removed as itself, never through it, and a folder is entered only when its real path is its own, so the deletion never reaches a folder outside; when that fails, the merge refuses in a fixed sentence and leaves the folder in place. Removing a change worktree removes its links the same way first, then its untracked top `node_modules` through Node (never through a link), which reaches the long paths Git for Windows cannot delete, and leaves the rest to `git worktree remove`, which refuses a checkout with changes.
137
141
  A merge's clean-tree check sets aside the untracked files in the snapshot folders the Prototype save leaves behind on purpose (`prototype/snapshots/<commit>/` in the product root, any commit-named folder); any other untracked or changed file, and any file reached through a link or junction, still stops it.
138
142
  Milestones and Agents group the board locally. A clash's Run both anyway starts the
139
143
  second change's coding composer; Let it wait stays disabled because there is no queue.
@@ -413,8 +417,9 @@ install hasn't finished (no `node_modules/.modules.yaml`) first runs `pnpm insta
413
417
  hooks. pnpm is found outside the product and runs with a turn's environment, corepack kept
414
418
  offline: it downloads nothing and runs no package's scripts. A package missing from this
415
419
  computer's store, no pnpm, or ten minutes stop the turn with a message naming the install;
416
- Stop ends the install too. A finished install isn't run again, so a later lockfile change (a
417
- merge of main, say) keeps the worktree's old packages until its `node_modules` is removed. Stop kills that process
420
+ Stop ends the install too. After an install ape writes a hash of the worktree's `pnpm-lock.yaml`
421
+ and `pnpm-workspace.yaml` in `node_modules/.ape-lockfile`; when either changed (a catch-up's merge
422
+ of main, say), or the file is missing, the next turn installs again. Stop kills that process
418
423
  tree. Before each Codex turn in a change's worktree, the studio compares only the repository-root
419
424
  `.codex/config.toml` with main's committed file, ignoring CRLF differences. A difference or a read
420
425
  error stops the turn; two absent files compare equal. Local edits in the product's folder do not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buffcore/cli",
3
- "version": "0.8.45",
3
+ "version": "0.8.47",
4
4
  "description": "The `ape` command: create, dev, migrate, seed, prototype, deploy and a local MCP server for coding agents.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "BuffApe",
@@ -45,20 +45,20 @@
45
45
  "playwright-core": "1.63.0",
46
46
  "yaml": "2.9.1",
47
47
  "zod": "4.6.5",
48
- "@buffcore/build-agent": "0.8.45",
49
- "@buffcore/storage": "0.8.45",
50
- "@buffcore/contracts": "0.8.45",
51
- "@buffcore/i18n": "0.8.45",
52
- "@buffcore/server": "0.8.45",
53
- "@buffcore/config": "0.8.45",
54
- "@buffcore/db": "0.8.45",
55
- "@buffcore/tokens": "0.8.45",
56
- "@buffcore/modules": "0.8.45"
48
+ "@buffcore/i18n": "0.8.47",
49
+ "@buffcore/config": "0.8.47",
50
+ "@buffcore/build-agent": "0.8.47",
51
+ "@buffcore/modules": "0.8.47",
52
+ "@buffcore/contracts": "0.8.47",
53
+ "@buffcore/db": "0.8.47",
54
+ "@buffcore/server": "0.8.47",
55
+ "@buffcore/tokens": "0.8.47",
56
+ "@buffcore/storage": "0.8.47"
57
57
  },
58
58
  "devDependencies": {
59
59
  "marked": "18.1.3",
60
60
  "tsx": "4.23.15",
61
- "@buffcore/admin-shell": "0.8.45"
61
+ "@buffcore/admin-shell": "0.8.47"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node ../../scripts/build-package.mjs && node scripts/bundle.mjs",
@@ -37,11 +37,17 @@ says the critique comes next, as a turn of its own.
37
37
  2. Write two or three plain sentences about what you see: rhythm, density, contrast and whether the
38
38
  screens feel like one app. Record the **Look** score now, before opening `design/DESIGN.md` or
39
39
  reading any contract text, including the written directions in `ape-design-system`.
40
- 3. Then read the brief (`plan/brief.md`), the core and alternate paths (`plan/journeys.md`), and the
41
- design contract (`design/DESIGN.md`).
40
+ 3. Then read only what the change touches, by heading: list the headings of the brief
41
+ (`plan/brief.md`), the core and alternate paths (`plan/journeys.md`) and the design contract
42
+ (`design/DESIGN.md`) with `grep -n '^## '`, then read the sections the change's screens and
43
+ journeys touch, plus DESIGN.md's Direction, Voice, Color roles, Typography and Layout, spacing
44
+ and density. Never read these files whole.
42
45
  4. Review the working prototype, its store and seeds, the snapshot report, `ape design check` and
43
46
  `ape prototype data`. Use journey tests or the panel replay to see each path run.
44
47
  Use the design check's advisory hints on repeated UI patterns, narrow layouts and unloaded theme fonts to locate details to review.
48
+ Read the snapshot's layout hints first (`hints` in `report.json`, the lines that start "Layout
49
+ hint"): overlaps, edges a few pixels off their siblings', a sibling's odd padding or gaps, and
50
+ space off the spacing scale. The Detail and craft pass below confirms or dismisses each one.
45
51
  5. Read the change's "What the person using it will ask" section and the questions pass's answers
46
52
  (`ape-prototype`). Find the element named for each question on each screen the change adds or changes.
47
53
  6. Score the remaining six dimensions using that evidence.
@@ -84,6 +90,25 @@ The 90/10: alignment, leading, numbers on their baseline, 44px targets, the cut-
84
90
  focus ring, the long name, the date in the reader's language. Cite the element and, where you can,
85
91
  the screenshot or the line.
86
92
 
93
+ **The spacing and layout pass.** Look at each screenshot at 1440 and at 390 for these, in order:
94
+
95
+ - **Padding inside** cards, rows, sheets and controls: the same component has the same padding
96
+ everywhere, and text never sits closer to an edge than to its neighbours.
97
+ - **Gaps between sections:** a larger gap between groups than inside one, the same step for the
98
+ same relationship on every screen, and nothing floating halfway.
99
+ - **Shared edges and the grid:** titles, fields, cards and lists start on the same edge; a box a
100
+ few pixels off its siblings is a slip; columns line up across rows.
101
+ - **Siblings that should match:** cards in a list, buttons in a row and items in a menu share size,
102
+ padding and alignment, unless one is meant to lead.
103
+ - **Crowding and emptiness:** at 390, nothing touches, wraps awkwardly or loses its padding; at
104
+ 1440, the content is not lost in empty space or stretched past a readable width.
105
+
106
+ Each finding names the screenshot, the element and the spacing token that should apply (the
107
+ theme's `space-*` steps, `design/DESIGN.md`'s layout rules). Then go through the snapshot's layout
108
+ hints: confirm each one you see in the screenshot as a finding, or dismiss it with the reason (meant,
109
+ or not visible). A meant one the scene should mark with `layoutExceptions` in
110
+ `prototype/scenes.ts`, with the reason; say so under Fix as a P1.
111
+
87
112
  - 0–4: visible tape and string. 5–6: most screens clean, a few ragged. 7–8: polished, an expert finds
88
113
  two or three misses. 9–10: nothing to apologise for.
89
114
 
@@ -141,9 +166,12 @@ for the person using the screen, not the thinnest screen.
141
166
 
142
167
  ## The report
143
168
 
144
- Write `design/critique.md` and keep it with the commit it reviews. In a fresh studio turn, which is
169
+ Write `design/critique.md` as the current review only: replace the whole file, never append to it.
170
+ Older reviews stay in git history. A recheck of the P0s edits that same report (it strikes the fixed
171
+ ones through) instead of adding a new one. In a fresh studio turn, which is
145
172
  read-only, do not write the file: reply with the whole report below and nothing else, and the studio
146
- writes `design/critique.md` from your reply (a reply without this shape is not recorded).
173
+ writes `design/critique.md` from your reply, replacing the file the same way (a reply without this
174
+ shape is not recorded).
147
175
 
148
176
  ```markdown
149
177
  # Critique · <product> · <commit>
@@ -174,7 +202,8 @@ references or write "no references on file" and name the examples. Name the appr
174
202
  …
175
203
 
176
204
  ## Detail and craft · 6/10
177
- …
205
+ <evidence; then the spacing and layout pass: each finding with its screenshot, element and token,
206
+ and each layout hint of the snapshot confirmed or dismissed with the reason>
178
207
 
179
208
  ## Journeys and functionality · 5/10
180
209
  …
@@ -208,7 +237,13 @@ turn the reply is the report itself, with no sentence before it.
208
237
  2. Rerun the critique only when the person asks, or when the fixes changed the look or a journey.
209
238
  3. The prototype's version is recorded only after the P0s are fixed (the fixes are another snapshot
210
239
  and another review). A person approves the commit. The critique is advice, never approval.
211
- 4. Update `design/critique.md`; keep it with the commit it reviewed.
240
+ `ape prototype version` refuses while `design/critique.md` marks an open P0, naming it: any line
241
+ that starts with P0 (the Fix list's `- **P0**`) or marks one (`[P0]`, `| P0 |`), as the Autopilot
242
+ approver reads it. Write P0 nowhere else. Once one is fixed, strike it through and say how:
243
+ `- ~~**P0** <what>~~ <how it was fixed>`. Commit the critique, then take the snapshot again: the
244
+ version reads the critique in the commit it records. With no critique on file the version is
245
+ recorded and the command says so.
246
+ 4. Update `design/critique.md` in place: one report, the current one; git keeps the older ones.
212
247
 
213
248
  ## Hard rules
214
249
 
@@ -14,11 +14,14 @@ A product's look and words live in one folder, `design/`, at its root (THEMING_A
14
14
  | File | Holds |
15
15
  |---|---|
16
16
  | `design/DESIGN.md` | The contract: direction; **voice, tone and character**; visual theme; color roles; typography; components; layout and density; motion; depth; do's and don'ts; the agent guide |
17
+ | `design/screens.md` | Optional: what one screen needs beyond the contract and its view (its layout, its states, a measurement the view alone doesn't explain), one `## <screen>` section each, read by heading |
17
18
  | `design/manifest.json` | Its identity and provenance: `schemaVersion` (`buffcore-design-system/v1`), `id` (the product's name), `name`, `source`, and the declared `DESIGN.md` and `theme.ts` |
18
19
  | `design/theme.ts` | The product's `theme`: a starter theme (`themes.clear`, `themes.warm` or `themes.bold`, the Brand step's three; `themes.neutral` and `themes.soft` stay) or one made with `extendTheme`. The app, the console and the prototype take it from here |
19
20
  | `design/components/` | The product's own components, one per file, named as the file (`Card.tsx` exports `Card`), built from BuffCore's and reading only tokens |
20
21
  | `design/showcase.ts` | `showcase`: one scene per component, its view (`<Name>Showcase`) showing every state side by side; `prototype/scenes.ts` adds them to its scenes |
21
22
 
23
+ **DESIGN.md stays a contract.** It holds the rules every screen follows, not specs for one screen: `Components` says what each component is for and how it behaves, never where it sits on a given screen or its pixel sizes there. A screen's detail lives in its view and scene; when words are still needed, they go in `design/screens.md` under that screen's `## ` heading, so agents read only the screen they change. `ape design check` warns, without failing, when DESIGN.md passes about 40 KB or one of its sections about 15 KB.
24
+
22
25
  ## Reference study
23
26
 
24
27
  Before choosing a direction, study real products. If the person already gave a brand or a study (a folder or file they point to), read that instead and skip the capture.
@@ -9,6 +9,10 @@ A product is built change by change. The plan lives in the repository: `plan/bri
9
9
 
10
10
  Before the first plan, if idea or journey notes are in one sibling folder, ask the person to replace `../<folder>` in `{"permissions":{"additionalDirectories":["../<folder>"]}}` with that folder and merge it into the git-ignored `.claude/settings.local.json` themselves, keeping existing settings. This lets Claude Code read and change files in that folder. Or, after a refused read, the person presses Allow this folder in the agent panel.
11
11
 
12
+ ## Read by section
13
+
14
+ Planning a change reads only what it needs. For `plan/brief.md`, `plan/journeys.md`, `plan/roadmap.md`, `design/DESIGN.md` and `design/screens.md`, list the headings first (`grep -n '^## ' plan/brief.md`), then read the sections the change touches: its milestone, its journeys and their people, the brief's sections on its scope. Read a whole file only when it is short or the change is about all of it, such as writing the brief itself.
15
+
12
16
  ## Read-back, before the plan and journeys
13
17
 
14
18
  In Brief, ask "What does it replace in their day?" Treat everything under "what they already use"
@@ -105,6 +109,8 @@ A change with no screens (an extension or a backend change, never a `design` cha
105
109
 
106
110
  Then the goal, the scope, the screens, what the person using it will ask and the data in plain words. "What the person using it will ask" is filled at planning, one bullet each, for every screen the change adds or changes ("does not apply" with a reason is allowed): who enters or is reached, and can they be seen by name; from what data, and how it is kept up to date; what it costs; what each control does. The prototype answers them (`ape-prototype`'s questions pass) and the critique checks the answers. A `hosting` change (a new service, a bigger size, more copies) also says the services and sizes it adds (the `ape-add-service` skill). Keep each change small enough for one branch. Name what exists by its manifest name, so `ape change` can find it.
107
111
 
112
+ Keep a change file under about 15 KB (`ape size` warns past it): what was built and when is in git, so a shipped change keeps no running log of rounds, `Built` lists or answered questions.
113
+
108
114
  ## Using it
109
115
 
110
116
  In a studio planning or loop turn, run only `pnpm ape change` and `pnpm ape change new`: neither loads the product's code. `pnpm ape change` reports each change file's header problems. Read existing modules, screens and tables from the product's files with read tools; `pnpm ape manifest` and `pnpm ape change C-012` load product code and are unavailable in these turns. The checks in `doneWhen` run later, in a build turn or by the person. When a studio turn needs the person's decision, ask one short question on the turn's ask line (its instructions give the exact form), then stop: the studio shows the question on the step's page and the person answers in the chat.
@@ -7,6 +7,10 @@ description: "Change the look or add a screen through the prototype, after the p
7
7
 
8
8
  A screen's look is approved in the prototype before it is built (PROTOTYPE.md). The prototype renders the product's real views with sample data, so the approved screens are the ones that ship. Versions and the one approved version per change live in `prototype/versions/<change>.json` in the product's repository (BC-D39). The product's scenes are in `prototype/scenes.ts`, its views listed in `apps/app/src/prototype/views.ts` and `apps/admin/src/prototype/views.ts`. In BuffCore's repository, the playground's `apps/playground/prototype/` is the example.
9
9
 
10
+ ## Read by section
11
+
12
+ Read only the parts of the plan and the design a change needs, never whole files. For `plan/brief.md`, `plan/journeys.md`, `design/DESIGN.md` and `design/screens.md`, list the headings first (`grep -n '^## ' plan/journeys.md`), then read the sections the change names: its journeys and the people in them, the brief's sections it touches, the contract sections its screens use (color, type, components, layout) and the `## <screen>` sections of the screens it changes. Read a whole file only when it is short or the change is about all of it.
13
+
10
14
  ## Before the first prototype
11
15
 
12
16
  Start each prototype journey from the moment in the person's normal day described in
@@ -35,7 +39,7 @@ When `prototype/versions/comp.json` holds no approved look, draw the comp first
35
39
 
36
40
  ## The working app, and the scenes
37
41
 
38
- Before drawing, read `design/references.md` (the design system's reference study and the paths of its pictures, `ape-design-system`) and look at the pictures it names, so the screens answer what the study found. Without the file, say so and draw from `design/DESIGN.md`.
42
+ Before drawing, read `design/references.md` (the design system's reference study and the paths of its pictures, `ape-design-system`) and look at the pictures it names, so the screens answer what the study found. Without the file, say so and draw from `design/DESIGN.md`'s sections the screens need.
39
43
 
40
44
  The prototype is **one app** over a small store (PROTOTYPE.md; PROCESS.md, stage 4): `prototype/store.ts` (the records and the actions), `seeds.ts` (the named states), `journeys.ts` (the journeys from `plan/journeys.md`) and `home.tsx` (the real shell and screens, with the states and journeys panel outside them). The runtime is `PrototypeHomeRoute` from `@buffcore/app-shell/prototype`: `home.tsx` passes it the store, the states, the journeys, the product's catalogs and a `render` for its screens. The dev-only `apps/app/src/app/prototype.tsx` loads it at `/prototype` behind `__DEV__`; `_layout.tsx` keeps that path outside the app shell. The app is what a person reviews and plays; the scenes are saved states for the snapshot and approval. When a screen changes, change the view and the state that shows it; when a journey changes, update `plan/journeys.md` and the prototype's journeys. After the snapshot, `ape-critique` reviews the app; the version record holds the approval. The scenes below remain the proof the snapshot checks.
41
45
 
@@ -44,9 +48,9 @@ When screens disagree about people, messages, counts or amounts, fix the shared
44
48
  1. **Change the views and the scenes.** A view is props in, UI out (`src/screens/…View.tsx` in the app, the console's equivalent in the admin); export it from the surface's `src/prototype/views.ts`. In `prototype/scenes.ts`, a scene names its view and gives it props: `{ key, title, surface: 'app' | 'admin', view: 'NotesView', props }`, plus `frame: 'tablet'` when it isn't a phone (app) or the console (admin). `props` are all of the view's props, its callbacks included (`onOpen: () => {}`), and the view types them itself, so it exists before the API does; the route maps the API's answer onto them when it is wired. A value the build will fetch later, such as a plan's price, comes from the model in the prototype. Sample data lives in `prototype/data/` and is always made up; a list of records there has an `id` on each row (that is how `ape prototype data` finds the data model). Name the product's theme once: `defineScenes({ theme, scenes, flows })`. A flow shows scenes in order, each step a scene's `key` and a plain-sentence `caption` (the viewer shows it as written, not through `t()`): `flows: [{ key: 'read-a-post', title: 'Read a post', steps: [{ scene: 'posts', caption: 'The list, newest first.' }, { scene: 'post', caption: 'One post; a paid one shows a lock.' }] }]`; `defineScenes` throws on a step naming a scene that doesn't exist.
45
49
  2. **Look at it** while `pnpm dev` runs: the app's own `/prototype` (the app's port) is the working prototype with its states and journeys; the admin's `/prototype` (the admin port) opens on the same app (when `createPrototype({ home: true })`) with every scene and flow one rail item away, in each theme, mode and language (`en-XA` and `ar-XB` included).
46
50
  3. **Check the scene you changed** (the snapshot is filed under the commit checked out, so a new product from `ape create`, which has none yet, commits first: `git add -A`, then `git commit -m "chore: the product as created"`, as `APE_ALLOW_LINKED=1 git commit …` while it is linked, or the pre-commit check refuses the linked `package.json`): `pnpm ape prototype snapshot --scene <key>` snapshots that scene alone in a few seconds, keeping the other scenes' report entries and screenshots (the development servers must be running; it drives Playwright's headless Chromium, never the installed Chrome: install it once on each machine with `pnpm dlx playwright-core@1.63.0 install chromium-headless-shell`). Look at its screenshots in `prototype/snapshots/<commit>/` and fix what the checks find: text too faint to read as drawn (4.5:1, disabled controls too; 3:1 for large text), text that skipped `t()` (in `en-XA`), text cut off by its box, touch targets under 44 px (app scenes). Font hints suggest where to look for fallback text in the declared theme and leave the snapshot status unchanged. A faint text's colors come from the theme's tokens or the view's choice of them.
47
- 4. **Save, then snapshot** for review: while you work, `pnpm ape prototype snapshot --scene <key>` for the scenes you touched; when the change is done, commit the views and scenes, then run `pnpm ape prototype snapshot` once for every scene (it copies the scenes whose inputs did not change). That full snapshot is what a version records and a person approves; a release needs one too. A snapshot taken over unsaved work says `dirty: true` in its report and cannot record a version (it is fine for looking). It screenshots each scene in the product's theme (each starter theme when it names none) in light and dark mode, in the first language, checks every theme, mode and language and each theme's tokens, and writes `report.json` and `data.json` beside the screenshots. It fails while a check finds a problem: fix it, or say in the commit why it stays. Format first (Claude Code's format hook formats each file it writes, another agent runs `pnpm format`, and `pnpm lint` reports any file left): the pre-commit hook refuses unformatted files, and the design hash reads `design/components/` as written, so a format fix made after the snapshot leaves the report's hash behind the committed files (snapshot again, and commit that folder as step 6 says).
48
- 5. **Commit** the snapshot's `report.json`, `data.json` and `design.json` (a change of `design/` follows the `ape-design-system` skill and is saved before the snapshot, like the views). Git ignores the screenshots: they stay on this computer; elsewhere, `pnpm ape prototype snapshot --remake` makes them again from the commit checked out. With the checkout unchanged, run `pnpm ape prototype version C-012 --why "<what changed and why>"`, then commit `prototype/versions/C-012.json`. It names the full source commit the snapshot was taken from and fingerprints its report, data and design. A partial, stale or unsaved snapshot is refused: only snapshot files may have changed between that source and HEAD. Record derives the design and the sample data again from the commit and refuses a report that differs, so sample data must give the same values every time it is read: no dates from the clock, no random values.
49
- 6. **Get that version approved.** A person looks at the version's snapshot report, screenshots and viewer, then runs `pnpm ape prototype approve C-012 [--version <n>]` in their own terminal (latest by default) and types `C-012` to confirm, or clicks approval in the studio. The same version record holds the one approved version and signature (git identity, time, commit and fingerprints); commit it. A second approval is refused, naming the approved version. There is no MCP approve tool: approving is a person's. An agent stops at the version record and reports that approval is waiting; it cannot run approval under `--json` or without a terminal. Asked for changes before approval: change, snapshot, commit and record another version. After approval, use a new change for a new approval; later drafts never replace the old approval.
51
+ 4. **Save, then snapshot** for review: while you work, `pnpm ape prototype snapshot --scene <key>` for the scenes you touched; when the change is done, commit the views and scenes, then run `pnpm ape prototype snapshot` once for every scene (it copies the scenes whose inputs did not change). That full snapshot is what a version records and a person approves; a release needs one too. A snapshot taken over unsaved work says `dirty: true` in its report and cannot record a version (it is fine for looking). It draws the scenes it does not copy in the floor (the product's theme, else the first starter, light and dark, its languages and `en-XA`, plus `ar-XB` for a right-to-left language), and in the full matrix (every theme, mode and pseudo-locale) with `--full`, which a release's report takes, or when the theme, `design/` or another shared input changed since the last full report; before a floor run draws, two fresh read-only turns of the agent and model `plan/agents.md` sets for validation (never your own turn) may add scenes to draw again and looks beyond the floor, each with a reason (`selector` in `report.json`; it never removes a floor look, and with an agent that has no fresh read-only turn (OpenCode), in CI, or when a turn fails, times out or answers out of shape, the floor is drawn alone and the run says why). A full run writes the looks the selector missed to `prototype/snapshots/selector-misses.json`: commit it with the report; it screenshots each drawn theme in light mode and the product's in dark, in the first language, checks every look drawn and each theme's tokens, and writes `report.json` and `data.json` beside the screenshots. It fails while a check finds a problem: fix it, or say in the commit why it stays. Format first (Claude Code's format hook formats each file it writes, another agent runs `pnpm format`, and `pnpm lint` reports any file left): the pre-commit hook refuses unformatted files, and the design hash reads `design/components/` as written, so a format fix made after the snapshot leaves the report's hash behind the committed files (snapshot again, and commit that folder as step 6 says).
52
+ 5. **Commit** the snapshot's `report.json`, `data.json` and `design.json` (a change of `design/` follows the `ape-design-system` skill and is saved before the snapshot, like the views). Git ignores the screenshots: they stay on this computer; elsewhere, `pnpm ape prototype snapshot --remake` makes them again from the commit checked out. With the checkout unchanged, run `pnpm ape prototype version C-012 --why "<what changed and why>"`, then commit `prototype/versions/C-012.json`. Then run `pnpm ape prototype prune` and commit what it removed: the committed snapshot folders no version names (each about 2 MB of data), keeping every folder a version names, the newest, HEAD's and any with unsaved changes; `--dry-run` lists them first, and git keeps their history. It names the full source commit the snapshot was taken from and fingerprints its report, data and design. A partial, stale or unsaved snapshot is refused: only snapshot files may have changed between that source and HEAD. Record derives the design and the sample data again from the commit and refuses a report that differs, so sample data must give the same values every time it is read: no dates from the clock, no random values.
53
+ 6. **Get that version approved.** A person looks at the version's snapshot report, screenshots and viewer, then runs `pnpm ape prototype approve C-012 [--version <n>]` in their own terminal (latest by default) and types `C-012` to confirm, or clicks approval in the studio. The same version record holds the one approved version and signature (git identity, time, commit and fingerprints); commit it. A second approval is refused, naming the approved version. There is no MCP approve tool: approving is a person's, except at Autopilot, where a fresh approver turn (never you) may approve a version as an AI approval when the floor, every check, a critique without P0 and the selector's second turn all hold; a person can reopen it (`ape prototype reopen C-012`). A milestone's approval needs a full report (`--full`). An agent stops at the version record and reports that approval is waiting; it cannot run approval under `--json` or without a terminal. Asked for changes before approval: change, snapshot, commit and record another version. After approval, use a new change for a new approval; later drafts never replace the old approval.
50
54
  7. **Build to match.** Wire the approved views to routes, data and actions without changing them; the screens then match the approved screenshots. `pnpm ape prototype data --check --change C-012` reads the approved version and fails (exit 1) when the data model has drifted; no approval exits 2. A later change to those screens starts again at step 1.
51
55
 
52
56
  **The questions pass.** The checks measure the surface; a person's questions are another check. For each screen the change adds or changes, name the element on it that answers each of four questions, in the commit message or the change's file (the change's "What the person using it will ask" section holds the questions): who enters or is reached, and can they be seen by name; from what data, and how it is kept up to date; what it costs; what each control does. "Does not apply" is a fine answer, with a one-line reason. Simple is for the person using the screen: hiding who is in it or what a control does is not simple for them. A screen with an unanswered question is not ready for the critique.
@@ -17,6 +17,9 @@
17
17
  "bundler": "metro",
18
18
  "output": "single"
19
19
  },
20
+ "experiments": {
21
+ "tsconfigPaths": false
22
+ },
20
23
  "plugins": ["expo-router", "expo-secure-store", "expo-localization"]
21
24
  }
22
25
  }