@buffcore/cli 0.8.47 → 0.8.49

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 (175) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/commands/build/server-text.en.d.ts +5 -0
  3. package/dist/commands/build/server-text.en.js +5 -0
  4. package/dist/commands/build/server-text.js +5 -0
  5. package/dist/commands/build/server.d.ts +4 -0
  6. package/dist/commands/build/server.js +10 -1
  7. package/dist/commands/change-merge-serial.d.ts +6 -2
  8. package/dist/commands/change-merge-serial.js +5 -1
  9. package/dist/commands/change-merge.d.ts +2 -2
  10. package/dist/commands/change.js +3 -0
  11. package/dist/commands/check-skills.d.ts +16 -0
  12. package/dist/commands/check-skills.en.d.ts +14 -0
  13. package/dist/commands/check-skills.en.js +14 -0
  14. package/dist/commands/check-skills.es.d.ts +2 -0
  15. package/dist/commands/check-skills.es.js +14 -0
  16. package/dist/commands/check-skills.js +146 -0
  17. package/dist/commands/check.js +5 -0
  18. package/dist/commands/dev.d.ts +9 -2
  19. package/dist/commands/dev.js +24 -5
  20. package/dist/commands/extension/config-text.d.ts +2 -0
  21. package/dist/commands/extension/config-text.js +2 -0
  22. package/dist/commands/extension/index.js +14 -2
  23. package/dist/commands/extension/new.d.ts +16 -0
  24. package/dist/commands/extension/new.js +52 -0
  25. package/dist/commands/extension/pack-files.d.ts +23 -0
  26. package/dist/commands/extension/pack-files.js +78 -0
  27. package/dist/commands/extension/pack-scan.d.ts +24 -0
  28. package/dist/commands/extension/pack-scan.js +131 -0
  29. package/dist/commands/extension/pack.d.ts +48 -0
  30. package/dist/commands/extension/pack.js +142 -0
  31. package/dist/commands/extension/share-text.d.ts +3 -0
  32. package/dist/commands/extension/share-text.js +6 -0
  33. package/dist/commands/extension/share.en.d.ts +32 -0
  34. package/dist/commands/extension/share.en.js +32 -0
  35. package/dist/commands/extension/share.es.d.ts +2 -0
  36. package/dist/commands/extension/share.es.js +32 -0
  37. package/dist/commands/hardening.d.ts +3 -0
  38. package/dist/commands/hardening.en.d.ts +3 -0
  39. package/dist/commands/hardening.en.js +3 -0
  40. package/dist/commands/hardening.es.d.ts +2 -0
  41. package/dist/commands/hardening.es.js +3 -0
  42. package/dist/commands/hardening.js +19 -0
  43. package/dist/commands/prototype/comp-record.d.ts +5 -0
  44. package/dist/commands/prototype/comp-record.js +22 -0
  45. package/dist/commands/server/build.d.ts +2 -1
  46. package/dist/commands/server/build.js +10 -2
  47. package/dist/commands/server/deploy-local.d.ts +3 -0
  48. package/dist/commands/server/deploy-local.js +9 -0
  49. package/dist/commands/server/deploy-plan.d.ts +5 -0
  50. package/dist/commands/server/deploy-plan.js +56 -0
  51. package/dist/commands/server/deploy-result.d.ts +7 -0
  52. package/dist/commands/server/deploy-result.js +1 -0
  53. package/dist/commands/server/deploy-script.d.ts +2 -0
  54. package/dist/commands/server/deploy-script.js +3 -2
  55. package/dist/commands/server/deploy.d.ts +9 -6
  56. package/dist/commands/server/deploy.js +39 -61
  57. package/dist/commands/server/files.d.ts +9 -1
  58. package/dist/commands/server/files.js +25 -5
  59. package/dist/commands/server/image.d.ts +4 -2
  60. package/dist/commands/server/image.js +6 -5
  61. package/dist/commands/server/setup.d.ts +1 -0
  62. package/dist/commands/server/setup.js +4 -0
  63. package/dist/commands/server/system-packages.d.ts +29 -0
  64. package/dist/commands/server/system-packages.js +103 -0
  65. package/dist/commands/services/compose.d.ts +1 -1
  66. package/dist/commands/services/compose.js +5 -3
  67. package/dist/commands/ui/agents-route.js +2 -0
  68. package/dist/commands/ui/approval-authority.en.d.ts +1 -0
  69. package/dist/commands/ui/approval-authority.en.js +1 -0
  70. package/dist/commands/ui/approval-authority.es.d.ts +1 -0
  71. package/dist/commands/ui/approval-authority.es.js +1 -0
  72. package/dist/commands/ui/approval-authority.js +7 -2
  73. package/dist/commands/ui/approve.js +2 -4
  74. package/dist/commands/ui/autopilot-records.d.ts +2 -0
  75. package/dist/commands/ui/autopilot-records.js +5 -0
  76. package/dist/commands/ui/brand-approval.js +5 -1
  77. package/dist/commands/ui/chat/permissions.js +1 -1
  78. package/dist/commands/ui/chat/routes.js +4 -0
  79. package/dist/commands/ui/comp-approval.d.ts +14 -2
  80. package/dist/commands/ui/comp-approval.js +45 -8
  81. package/dist/commands/ui/index.d.ts +1 -0
  82. package/dist/commands/ui/level-route.js +3 -0
  83. package/dist/commands/ui/merge-authority.d.ts +4 -1
  84. package/dist/commands/ui/merge-authority.en.d.ts +4 -0
  85. package/dist/commands/ui/merge-authority.en.js +5 -1
  86. package/dist/commands/ui/merge-authority.es.d.ts +4 -0
  87. package/dist/commands/ui/merge-authority.es.js +5 -1
  88. package/dist/commands/ui/merge-authority.js +6 -3
  89. package/dist/commands/ui/merge-claims.d.ts +7 -0
  90. package/dist/commands/ui/merge-claims.js +21 -0
  91. package/dist/commands/ui/merge-delegation.js +8 -3
  92. package/dist/commands/ui/merge-hold-name.d.ts +5 -0
  93. package/dist/commands/ui/merge-hold-name.js +5 -0
  94. package/dist/commands/ui/merge-hold.d.ts +6 -1
  95. package/dist/commands/ui/merge-hold.js +23 -5
  96. package/dist/commands/ui/merge-publish-host.d.ts +1 -0
  97. package/dist/commands/ui/merge-publish-host.js +2 -2
  98. package/dist/commands/ui/merge-record.d.ts +2 -0
  99. package/dist/commands/ui/merge-record.js +1 -1
  100. package/dist/commands/ui/merge-route.js +17 -1
  101. package/dist/commands/ui/merge-settle.d.ts +32 -0
  102. package/dist/commands/ui/merge-settle.js +133 -0
  103. package/dist/commands/ui/merge-state.d.ts +5 -0
  104. package/dist/commands/ui/merge-state.js +7 -1
  105. package/dist/commands/ui/merge-withdraw.d.ts +9 -0
  106. package/dist/commands/ui/merge-withdraw.js +29 -0
  107. package/dist/commands/ui/outside-merge.d.ts +13 -0
  108. package/dist/commands/ui/outside-merge.js +84 -0
  109. package/dist/commands/ui/outside.d.ts +7 -4
  110. package/dist/commands/ui/outside.js +3 -0
  111. package/dist/commands/ui/plan-extensions.d.ts +34 -0
  112. package/dist/commands/ui/plan-extensions.en.d.ts +4 -0
  113. package/dist/commands/ui/plan-extensions.en.js +4 -0
  114. package/dist/commands/ui/plan-extensions.es.d.ts +2 -0
  115. package/dist/commands/ui/plan-extensions.es.js +4 -0
  116. package/dist/commands/ui/plan-extensions.js +86 -0
  117. package/dist/commands/ui/plan-files.js +9 -3
  118. package/dist/commands/ui/plan-structure.js +5 -7
  119. package/dist/commands/ui/prototype-comp-route.d.ts +12 -3
  120. package/dist/commands/ui/prototype-comp-route.js +35 -17
  121. package/dist/commands/ui/prototype-main.d.ts +6 -0
  122. package/dist/commands/ui/real-file.d.ts +11 -0
  123. package/dist/commands/ui/real-file.js +84 -0
  124. package/dist/commands/ui/save-route.js +4 -1
  125. package/dist/commands/ui/server.d.ts +1 -0
  126. package/dist/commands/ui/server.js +1 -0
  127. package/dist/commands/ui/studio-routes.js +2 -0
  128. package/dist/commands/ui/studio-state.d.ts +8 -0
  129. package/dist/commands/ui/studio-versions.js +19 -3
  130. package/dist/commands/ui/studio.en.d.ts +2 -0
  131. package/dist/commands/ui/studio.en.js +2 -0
  132. package/dist/commands/ui/studio.es.d.ts +2 -0
  133. package/dist/commands/ui/studio.es.js +2 -0
  134. package/dist/commands/upgrade.js +1 -1
  135. package/dist/ui/page.js +91 -91
  136. package/docs/EXTENSIONS.md +6 -0
  137. package/docs/PROTOTYPE.md +13 -0
  138. package/docs/WORKBENCH.md +55 -2
  139. package/package.json +11 -11
  140. package/skills/ape-add-ai-purpose/SKILL.md +1 -1
  141. package/skills/ape-add-event/SKILL.md +1 -1
  142. package/skills/ape-add-extension/SKILL.md +5 -1
  143. package/skills/ape-add-feature/SKILL.md +1 -1
  144. package/skills/ape-add-generator/SKILL.md +1 -1
  145. package/skills/ape-add-module/SKILL.md +1 -1
  146. package/skills/ape-add-route/SKILL.md +3 -1
  147. package/skills/ape-add-service/SKILL.md +1 -1
  148. package/skills/ape-add-translations/SKILL.md +2 -2
  149. package/skills/ape-admin-screen/SKILL.md +1 -1
  150. package/skills/ape-app-screen/SKILL.md +1 -1
  151. package/skills/ape-critique/SKILL.md +11 -32
  152. package/skills/ape-critique/references/after.md +15 -0
  153. package/skills/ape-critique/references/spacing-pass.md +20 -0
  154. package/skills/ape-deploy/SKILL.md +8 -3
  155. package/skills/ape-design-system/SKILL.md +15 -15
  156. package/skills/ape-design-system/references/by-hand.md +7 -0
  157. package/skills/ape-design-system/references/reference-study.md +11 -0
  158. package/skills/ape-diagnose/SKILL.md +24 -0
  159. package/skills/ape-migration/SKILL.md +1 -1
  160. package/skills/ape-plan-change/SKILL.md +37 -31
  161. package/skills/ape-plan-change/references/change-file-fields.md +5 -0
  162. package/skills/ape-plan-change/references/extensions.md +25 -0
  163. package/skills/ape-plan-change/references/finishing.md +3 -0
  164. package/skills/ape-plan-change/references/fix-from-error.md +3 -0
  165. package/skills/ape-plan-change/references/refactor.md +9 -0
  166. package/skills/ape-plan-change/references/structure.md +19 -0
  167. package/skills/ape-prototype/SKILL.md +13 -23
  168. package/skills/ape-prototype/references/comp.md +3 -0
  169. package/skills/ape-prototype/references/scope-and-export.md +5 -0
  170. package/skills/ape-prototype/references/snapshot.md +3 -0
  171. package/skills/ape-prototype/references/structure.md +11 -0
  172. package/skills/ape-prototype/references/working-app.md +7 -0
  173. package/skills/ape-request/SKILL.md +1 -1
  174. package/skills/ape-upgrade/SKILL.md +4 -1
  175. package/templates/product/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: ape-diagnose
3
+ description: "Diagnosing a bug: a failing command first, a cut-down case, hypotheses, tagged logs, a regression test. Use when something is broken, an error repeats, or recent_errors shows a group."
4
+ ---
5
+
6
+ # Diagnose a bug
7
+
8
+ A gated loop: each gate ends with something you can check, and the next starts only when it holds. Work on the development server with seed data and sandbox keys, never on production.
9
+
10
+ ## Where the bug is seen
11
+
12
+ - From the running product: the `ape mcp` tool `recent_errors` lists the recent error groups (scrubbed), each with its id, where it happened, how often, since when and its latest stack. Pick the group the report points at.
13
+ - Once you know which group it is, `change_from_error` with that `group` (or `pnpm ape change new --from-error <group>`) writes the `fix` change file in `plan/changes/`; build the fix on that change's branch (`ape-plan-change`). A second ask for the same group returns the same file.
14
+
15
+ ## The gates
16
+
17
+ 1. **A command that fails because of the bug.** First write the one command that shows it: a test (`pnpm --filter <package> test -- <file>`), a script or a request that fails now. No guessing at causes before it exists. Done when the command fails, and fails for this bug, not for another reason.
18
+ 2. **Cut the case down.** Remove data, steps, screens and settings one at a time while the command still fails, until every part left matters: take any one away and it passes. Done when the case is that small and still fails.
19
+ 3. **Three to five hypotheses that can be proven wrong.** Write each with the check that would prove it wrong (a value to print, a line to step over, an input to change), then run the checks, cheapest first. Drop each one its check rules out. Done when one hypothesis has survived its check and the others are ruled out, or you have written the next round of three to five.
20
+ 4. **Debug logging with one prefix.** Every line you add to look inside is tagged with the same prefix, such as `[diag-C-031]`, so removing them all is one search. Done when a search for the prefix finds none of them before you commit.
21
+ 5. **A regression test that fails before the fix and passes after.** Turn the cut-down case into a test beside the code. Run it without the fix (it fails), then with it (it passes). Done when both runs are seen and the change's `doneWhen` checks pass (`pnpm ape change <id> --check`).
22
+ 6. **Secrets redacted in anything quoted.** In the change file, a commit message, a report or a test fixture, quote logs, stacks and requests with tokens, passwords, keys, cookies, email addresses and phone numbers replaced by `<redacted>`; refer to a person by ID only. Done when nothing quoted holds a secret or a person's details.
23
+
24
+ When the loop needs the owner (a behavior the brief does not settle, or a fix that changes what people see), ask in a round, as `ape-plan-change` says under "Questions in rounds".
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ape-migration
3
- description: "Create or change database tables: change entities, generate the module migration, review up and down, round-trip."
3
+ description: "Database migrations: change entities, generate, review up and down, round-trip. Use when creating or changing tables."
4
4
  ---
5
5
 
6
6
  # Migrations
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ape-plan-change
3
- description: "Plan a product change by change from the brief, journeys and app structure: the roadmap's milestones, one change file each in plan/changes with its header, ape change to see one and run its checks, the chain (plan, structure, design system, prototype, build) with its ape mcp tools, the branch and the Change and Task trailers."
3
+ description: "Planning: brief read-back, journeys, structure, roadmap, change files, ape change and its checks, the branch and its Change and Task trailers. Use when planning a feature or fix, or asking the owner."
4
4
  ---
5
5
 
6
6
  # Planning a change
@@ -13,6 +13,12 @@ Before the first plan, if idea or journey notes are in one sibling folder, ask t
13
13
 
14
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
15
 
16
+ Done when you can name the sections you read and why each one matters to the change.
17
+
18
+ ## Questions in rounds
19
+
20
+ Whenever you need the owner to decide, here or in any skill: ask every question that is ready to decide in one numbered round, not one at a time. Give each a recommendation, worded so that "yes" accepts it ("1. Start with SMS only? I recommend yes: ..."). Look facts up in the repository, the brief and `ape mcp` instead of asking them. Ask the next round only when the answers open new questions. Done when every question ready to decide is in the round and each has a recommendation.
21
+
16
22
  ## Read-back, before the plan and journeys
17
23
 
18
24
  In Brief, ask "What does it replace in their day?" Treat everything under "what they already use"
@@ -26,6 +32,8 @@ If they correct it, update the brief and ask them to confirm the revised read-ba
26
32
  confirmation on the `Owner confirmation` line. For ongoing work from an older brief without the
27
33
  section, use its agreed scope and suggest adding the section for the next plan.
28
34
 
35
+ Done when the `Owner confirmation` line in `plan/brief.md` records the owner's confirmation.
36
+
29
37
  ## A summary line under each heading
30
38
 
31
39
  The studio's Brief reads short first: under each `##` heading of `plan/brief.md`, write the
@@ -34,6 +42,8 @@ section's short form as `> Summary: <one line>` and keep it current when the sec
34
42
  do` and `Later`, one per item worth seeing first. The rest of the section stays as written: Read
35
43
  more opens it whole. A section without a summary shows its first sentence.
36
44
 
45
+ Done when every `##` heading of `plan/brief.md` has its `> Summary:` line.
46
+
37
47
  ## Journeys from a normal day
38
48
 
39
49
  Start each journey in `plan/journeys.md` with a moment in the person's normal day,
@@ -41,6 +51,8 @@ such as "8:00, a customer calls." Follow their actions through to the outcome in
41
51
  Show where the new way takes over a job and where the person continues using something
42
52
  the owner kept. Give each core path a base state, steps, branches and an end state.
43
53
 
54
+ Done when each core path in `plan/journeys.md` has its base state, steps, branches and end state.
55
+
44
56
  ## Structure, after Journeys
45
57
 
46
58
  Keep the studio loop's order: Brief, Plan, Brand, Journeys, Structure, Prototype, Build,
@@ -51,28 +63,20 @@ Write `plan/structure.md` before the first prototype. Ask again only when sectio
51
63
  audiences or screen ownership change. An existing product without this file keeps working:
52
64
  propose a draft to review before its next affected prototype; never invent past approval.
53
65
 
54
- Use one table, one row per section, with this exact header:
55
- `| Section | First screen | Who | Place | Main |`. Main is `yes` or `no`; several rows can
56
- be main (the starter has Home and Settings both main). File order ranks the main sections.
57
- Names must be distinct within the same place and audience; Settings in app and console is fine.
58
- First screen uses an existing inventory route (`/`, `/settings`) or console screen name.
59
- A section a planned change adds names that change: `/billing (planned, C-020)`, where
60
- C-020's file lists `'/billing'` under `touches.screens`. The studio shows it as planned until
61
- the route exists, then as an ordinary row (the suffix can stay or go). Never invent a route
62
- no change plans. The small CLI plan reader refuses missing or unknown first screens, a
63
- planned screen its change does not list, repeated names, malformed rows and absent notes,
64
- naming the offending row.
65
- Nested screens go in short notes after the table: name their owning section and return target.
66
- Sign-in/out and denied paths name a return or safe next destination. Add phone and wide-screen
67
- notes: up to five phone places; over five, first four main sections plus More; wider, a labelled
68
- rail; wide lists beside detail with selection preserved on resize. Console and public sections
69
- keep separate frames. Audience is intent; existing access controls decide access.
70
- SA4 will add section/screen coverage and traversal evidence; this file alone proves neither.
66
+ Write it as one table, `| Section | First screen | Who | Place | Main |`, with short notes for nested screens and for phone and wide screens: the rules are in `references/structure.md`. Done when `plan/structure.md` exists in that form.
71
67
 
72
68
  ## The roadmap
73
69
 
74
70
  `plan/roadmap.md` lists the milestones in order. Each is a `## ` heading with the outcome in the owner's words ("Customers can call your number"), a sentence of what they can try, and its changes as a list (`- C-012 SMS inbox`).
75
71
 
72
+ Done when every change file's `milestone` is a `## ` heading of `plan/roadmap.md` and each milestone lists its changes.
73
+
74
+ ## What to build, use or share
75
+
76
+ `plan/extensions.md` gives each capability the product needs one answer, one line each: `- <kind>: <name> - <why>`, the kind one of `use`, `improve`, `build to share`, `request`, `product only`, and `(extra: <cost>)` ending a `build to share` line. Ask of each: "would another product need it the same way?" When unclear, `product only`. Ask the answers in one round, each with a recommendation; the person can change any. What each kind starts: `references/extensions.md`.
77
+
78
+ Done when `pnpm ape change` reports no problem in `plan/extensions.md`.
79
+
76
80
  ## A change file
77
81
 
78
82
  `plan/changes/C-012-sms-inbox.md`: the id, then a short slug. The header is YAML between `---` lines:
@@ -103,23 +107,25 @@ doneWhen: # commands, run from the product's root
103
107
 
104
108
  Quote every route in `screens`: it is YAML, and an unquoted `[id]` ends the list early (`ape change` then reports "Missing , or :").
105
109
 
106
- For work finished without a `Change` trailer, set `doneIn` to the quoted commit ID (7–40 hex digits) that finished the change, and Work shows Done once main contains that commit.
107
-
108
- A change with no screens (an extension or a backend change, never a `design` change) says so with `noScreens: true` in the header, beside `touches` and with no `screens` listed. It is coded with no prototype once main commits it. The line takes effect only once main commits it and the change has no prototype versions; Autopilot's automatic save of a step that changes whether a change needs its prototype waits for a person's own save (merging a coding branch that adds the line is not checked yet). A change with prototype versions, or any other value, keeps the prototype step.
110
+ Two optional header fields are in `references/change-file-fields.md`: `doneIn` (work finished without a `Change` trailer) and `noScreens: true` (a change with no screens).
109
111
 
110
112
  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.
111
113
 
112
114
  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
115
 
116
+ Done when `pnpm ape change` reports no problem with the file.
117
+
114
118
  ## Using it
115
119
 
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.
120
+ 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. That one line carries the round: number the questions ready to decide, each with its recommendation.
117
121
 
118
122
  - `pnpm ape change` lists the changes and reports any malformed file with the file and the field.
119
123
  - Outside studio planning, `pnpm ape change C-012` prints the change, its branch and what it touches: each module, screen and table found in `pnpm ape manifest` (with its file), or new.
120
124
  - In a build turn or by the person, `pnpm ape change C-012 --check` runs its `doneWhen` checks; `--json` for programs.
121
125
  - Outside studio planning, an agent has the same through the `ape mcp` tools `change_show` (`id`) and `change_check` (`id`).
122
126
 
127
+ Done when `pnpm ape change` lists every change with no problem.
128
+
123
129
  ## The chain: plan, structure, design system, prototype, build
124
130
 
125
131
  A change with screens, or a change of look, goes through these steps in order; each has a skill (how) and `ape mcp` tools (state and actions). A step that has nothing to do is skipped, never reordered.
@@ -130,19 +136,15 @@ A change with screens, or a change of look, goes through these steps in order; e
130
136
  4. **Prototype** (the `ape-prototype` skill). Views and scenes for every screen the change writes, the console's too (list them all in the change's `screens`), then `ape mcp`: `prototype_snapshot` with the scene's key while you work and with none before the commit, `prototype_data` with `change` to read its approved version. Stop at the snapshot commit until a person approves it.
131
137
  5. **Build to match,** with the skill for each part (`ape-add-feature`, `ape-add-service`), then `change_check` runs `doneWhen`. `ape mcp`: `run_tests` for one package, `services_list` when the change adds or resizes a service.
132
138
 
139
+ Done when each step that had work ends in its check: `pnpm ape change`, `pnpm ape design check`, an approved prototype version, then `pnpm ape change C-012 --check`.
140
+
133
141
  ## A fix from an error
134
142
 
135
- `pnpm ape change new --from-error <group>` (or the `ape mcp` tool `change_from_error`) writes a `fix` change from an error group in the development database: what failed, where, how often, since when, and the top frames as `function@file`. `recent_errors` gives each group's id. The group was scrubbed when it was stored, and the file holds no person beyond an ID. Its header names the group (`error: <id>`), so a second ask returns the same file. It starts in the milestone `Fixes`; move it into a roadmap milestone if it belongs there, then build it as any change.
143
+ `pnpm ape change new --from-error <group>` writes a `fix` change from an error group. Find the bug first with `ape-diagnose`; what the file holds and where it starts are in `references/fix-from-error.md`. Done when `pnpm ape change` lists it with no problem.
136
144
 
137
145
  ## A refactor
138
146
 
139
- `type: refactor` changes how the code reads, never what it does. Its proof runs later, in a build turn or by the person: `pnpm ape change C-012 --check` on a refactor first proves the behavior unchanged against its base (its merge base with `main`, or `--base <ref>`), then runs `doneWhen`:
140
- - `ape manifest --json` is identical, and so is every route's schema and every package's exports;
141
- - no migration added or changed;
142
- - no more files over the size limit, no more reaches past a boundary;
143
- - `pnpm test` passes, and no package's coverage falls below the base's.
144
-
145
- It checks the base out in a scratch worktree and installs it, then runs the tests on both, so it takes a while. Since it runs the tests, `doneWhen` can be `pnpm typecheck` and `pnpm lint`. A failing part names where it changed (`changed at identity.get_me GET /v1/me.response…`): put that part in a change of its own.
147
+ `type: refactor` changes how the code reads, never what it does. In a build turn or by the person, `pnpm ape change C-012 --check` first proves the behavior unchanged against its base, then runs `doneWhen`: `references/refactor.md` says what it compares and what a failure names. Done when that check passes.
146
148
 
147
149
  ## The branch and the trailers
148
150
 
@@ -156,6 +158,10 @@ Task: add the inbox screen
156
158
  The product's `.githooks/commit-msg` refuses a commit on a change's branch without them; other branches are untouched.
157
159
  CI repeats the chain with `pnpm ape change --check` (the branch supplies the id) and `pnpm ape change trailers origin/main..HEAD` (every non-merge commit must carry its Change and Task trailers).
158
160
 
161
+ Done when `pnpm ape change trailers origin/main..HEAD` passes.
162
+
159
163
  ## Finishing a change
160
164
 
161
- When `pnpm ape change C-012 --check` passes (and a prototype commit it needs is approved), merge through `pnpm ape change merge C-012`. Worktree checks receive no product settings and keep the person's own file access: a development computer's `.env` holds only development and sandbox values, never production secrets. After merging, use Snapshot in the studio on main, with its development servers running. Products with a prototype need a passing Snapshot record for main's exact HEAD before release approval or deployment; no owed list is kept. Missing, unreadable, failed or stale evidence closes release. On failure, fix or revert the change and run Snapshot for the new HEAD. The product's `.githooks/pre-merge-commit` holds protected paths (the `agents.protected` list in `buffcore.config.ts`) for a person. `pnpm ape agents held main`, run on the branch, names those paths before merging. A held merge stops there: report it and name the paths, and tell a person who doesn't use git that saying "merge it" is enough. Keep the hook and the Snapshot evidence check in place.
165
+ When `pnpm ape change C-012 --check` passes (and a prototype commit it needs is approved), merge through `pnpm ape change merge C-012`. A merge the product's `.githooks/pre-merge-commit` holds (protected paths) stops there: report it and name the paths (`pnpm ape agents held main`). After merging, the Snapshot rules: `references/finishing.md`.
166
+
167
+ Done when `main` holds the merge and a passing Snapshot for its HEAD, or you have reported the held paths.
@@ -0,0 +1,5 @@
1
+ # Two optional fields of a change file
2
+
3
+ For work finished without a `Change` trailer, set `doneIn` to the quoted commit ID (7–40 hex digits) that finished the change, and Work shows Done once main contains that commit.
4
+
5
+ A change with no screens (an extension or a backend change, never a `design` change) says so with `noScreens: true` in the header, beside `touches` and with no `screens` listed. It is coded with no prototype once main commits it. The line takes effect only once main commits it and the change has no prototype versions; Autopilot's automatic save of a step that changes whether a change needs its prototype waits for a person's own save (merging a coding branch that adds the line is not checked yet). A change with prototype versions, or any other value, keeps the prototype step.
@@ -0,0 +1,25 @@
1
+ # What to build, use or share
2
+
3
+ `plan/extensions.md` holds one line per capability the product needs. Only its bullet lines are read; headings, notes and comments stay as the person writes them.
4
+
5
+ ```markdown
6
+ # Extensions
7
+
8
+ - use: uploads - photos on each job
9
+ - improve: @buffcore/feedback - a screenshot with each note
10
+ - build to share: sms - texting customers, as any shop would (extra: about half a day)
11
+ - request: calendar - most products book time
12
+ - product only: quotes - only this shop prices jobs this way
13
+ ```
14
+
15
+ The kinds, and what each one starts:
16
+
17
+ - **use:** BuffCore, an installed extension or the catalog already has it. A catalog one is installed with `pnpm ape add <name>` (the `ape-add-extension` skill).
18
+ - **improve:** a catalog extension almost fits. Change a local copy in `packages/<key>`, and offer the change upstream.
19
+ - **build to share:** another product would need it the same way. Start it as an extension from the first day: `pnpm ape extension new <key>` (the `ape-add-extension` skill). Write its extra cost against building it inside the product, in the person's words: `(extra: about half a day)`.
20
+ - **request:** most products would need it. File a request to BuffCore (the `ape-request` skill) and build it to share meanwhile.
21
+ - **product only:** only this product needs it, or the answer is unclear. Build it in the product's own modules.
22
+
23
+ The test is "would another product need it the same way?". Put every answer in one round, each with a recommendation the person can accept with "yes": "3. Build texting to share? I recommend yes: any shop texts its customers the same way; it costs about half a day more."
24
+
25
+ An unknown kind is a problem `pnpm ape change` names by its line. The studio's Plan page shows the answers in groups, with the extra cost of building to share.
@@ -0,0 +1,3 @@
1
+ # Finishing a change
2
+
3
+ When `pnpm ape change C-012 --check` passes (and a prototype commit it needs is approved), merge through `pnpm ape change merge C-012`. Worktree checks receive no product settings and keep the person's own file access: a development computer's `.env` holds only development and sandbox values, never production secrets. After merging, use Snapshot in the studio on main, with its development servers running. Products with a prototype need a passing Snapshot record for main's exact HEAD before release approval or deployment; no owed list is kept. Missing, unreadable, failed or stale evidence closes release. On failure, fix or revert the change and run Snapshot for the new HEAD. The product's `.githooks/pre-merge-commit` holds protected paths (the `agents.protected` list in `buffcore.config.ts`) for a person. `pnpm ape agents held main`, run on the branch, names those paths before merging. A held merge stops there: report it and name the paths, and tell a person who doesn't use git that saying "merge it" is enough. Keep the hook and the Snapshot evidence check in place.
@@ -0,0 +1,3 @@
1
+ # A fix from an error
2
+
3
+ `pnpm ape change new --from-error <group>` (or the `ape mcp` tool `change_from_error`) writes a `fix` change from an error group in the development database: what failed, where, how often, since when, and the top frames as `function@file`. `recent_errors` gives each group's id. The group was scrubbed when it was stored, and the file holds no person beyond an ID. Its header names the group (`error: <id>`), so a second ask returns the same file. It starts in the milestone `Fixes`; move it into a roadmap milestone if it belongs there, then build it as any change.
@@ -0,0 +1,9 @@
1
+ # A refactor
2
+
3
+ `type: refactor` changes how the code reads, never what it does. Its proof runs later, in a build turn or by the person: `pnpm ape change C-012 --check` on a refactor first proves the behavior unchanged against its base (its merge base with `main`, or `--base <ref>`), then runs `doneWhen`:
4
+ - `ape manifest --json` is identical, and so is every route's schema and every package's exports;
5
+ - no migration added or changed;
6
+ - no more files over the size limit, no more reaches past a boundary;
7
+ - `pnpm test` passes, and no package's coverage falls below the base's.
8
+
9
+ It checks the base out in a scratch worktree and installs it, then runs the tests on both, so it takes a while. Since it runs the tests, `doneWhen` can be `pnpm typecheck` and `pnpm lint`. A failing part names where it changed (`changed at identity.get_me GET /v1/me.response…`): put that part in a change of its own.
@@ -0,0 +1,19 @@
1
+ # plan/structure.md: the table and its notes
2
+
3
+ Use one table, one row per section, with this exact header:
4
+ `| Section | First screen | Who | Place | Main |`. Main is `yes` or `no`; several rows can
5
+ be main (the starter has Home and Settings both main). File order ranks the main sections.
6
+ Names must be distinct within the same place and audience; Settings in app and console is fine.
7
+ First screen uses an existing inventory route (`/`, `/settings`) or console screen name.
8
+ A section a planned change adds names that change: `/billing (planned, C-020)`, where
9
+ C-020's file lists `'/billing'` under `touches.screens`. The studio shows it as planned until
10
+ the route exists, then as an ordinary row (the suffix can stay or go). Never invent a route
11
+ no change plans. The small CLI plan reader refuses missing or unknown first screens, a
12
+ planned screen its change does not list, repeated names, malformed rows and absent notes,
13
+ naming the offending row.
14
+ Nested screens go in short notes after the table: name their owning section and return target.
15
+ Sign-in/out and denied paths name a return or safe next destination. Add phone and wide-screen
16
+ notes: up to five phone places; over five, first four main sections plus More; wider, a labelled
17
+ rail; wide lists beside detail with selection preserved on resize. Console and public sections
18
+ keep separate frames. Audience is intent; existing access controls decide access.
19
+ SA4 will add section/screen coverage and traversal evidence; this file alone proves neither.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ape-prototype
3
- description: "Change the look or add a screen through the prototype, after the plan, journeys, app structure and design system: the working app on a store (states and journeys) and the scenes, ape prototype snapshot (one scene while you work, a complete report with eligible scenes reused before review), the critique, commit the report, approval of that commit, a commit's data model and export, then build to match."
3
+ description: "The prototype: views, scenes, the comp, snapshots, versions, approval, the data model and export, then build to match. Use when changing the look, adding a screen, or snapshotting for review."
4
4
  ---
5
5
 
6
6
  # Change the prototype, get it approved
@@ -23,46 +23,36 @@ them in the Actor column, and its entry in `prototype/journeys.ts` has a `role`
23
23
  studio's picker groups by. Ask the person when a journey's role is unclear. `ape design check`
24
24
  warns, without failing, about a journey that names none.
25
25
 
26
- After Journeys, use `ape-plan-change`'s Structure questions and write `plan/structure.md`:
27
- one table (Section, First screen, Who, Place, Main), followed by short notes for nested
28
- screens' owning sections and return targets, phone and wide screens. Offer a draft from the
29
- journeys, then let the person correct it. Keep Brief, Plan, Brand, Journeys, Structure,
30
- Prototype in that order in the studio. Review structure again only when sections, audiences
31
- or screen ownership change. Existing products without the file keep working; propose it for
32
- review before their next affected prototype, with no invented past approval. Use existing
33
- inventory routes or console screen names as first screens. The file describes intent and
34
- grants no access. SA4 adds coverage and traversal evidence later; do not claim them from a table.
26
+ Ask the person in rounds, as `ape-plan-change` says under "Questions in rounds": every question ready to decide, numbered, each with your recommendation.
27
+
28
+ After Journeys, `plan/structure.md` (one table of the sections) comes before the first prototype: write or review it as `references/structure.md` says. Done when the file exists, or the person has said the one on file still holds.
35
29
 
36
30
  ## The comp, before the scenes
37
31
 
38
- When `prototype/versions/comp.json` holds no approved look, draw the comp first and nothing else. Pick the three deciding screens from `plan/journeys.md` and `plan/structure.md` (the ones people see most) and add them to `prototype/scenes.ts` as scenes keyed `comp/<name>`. `plan/structure.md`'s `Surface:` line says which surface comes first (absent, desktop): the snapshot shoots the comp at that width, the product's desktop frame (`prototype.frame`, 1440 by default) or the phone's 390, light and dark. Shoot it with `pnpm ape prototype snapshot --scene 'comp/*'`: it goes to `prototype/snapshots/comp/<commit>/`, apart from the scenes, and never counts toward their totals, completeness or reuse. The studio's Prototype page shows the three beside `design/references.md`'s pictures; the person asks for changes in the chat (redraw and shoot the three again) and approves the look there. Only a person approves it, at every level, Autopilot included. Once approved, the comp's screenshots are the reference every scene must match: its type, color, density and spacing. Judge the first surface first.
32
+ When `prototype/versions/comp.json` holds no approved look, draw the comp first and nothing else: the three deciding screens as scenes keyed `comp/<name>`, shot with `pnpm ape prototype snapshot --scene 'comp/*'` at the first surface's width, as `references/comp.md` says. Only a person approves it, at every level, Autopilot included. Done when `prototype/versions/comp.json` holds an approved look: its screenshots are then the reference every scene must match.
39
33
 
40
34
  ## The working app, and the scenes
41
35
 
42
36
  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.
43
37
 
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.
45
-
46
- When screens disagree about people, messages, counts or amounts, fix the shared model or how the screens read it and add an invariant to the product's tests. Never patch a single screen to make its numbers agree. Check the invariant in each named state and after each journey step. Pass derived counts and amounts through `t()` placeholders formatted with `Intl`.
38
+ The prototype is **one app** over a small store (`prototype/store.ts`, `seeds.ts`, `journeys.ts`, `home.tsx`), served at the app's `/prototype` in development; how it is wired, and what to do when screens disagree about people, counts or amounts, is in `references/working-app.md`. 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. The scenes below are saved states for the snapshot and approval.
47
39
 
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.
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).
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.
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.
40
+ 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. Done when `pnpm typecheck` passes.
41
+ 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). Done when the scene you changed opens there.
42
+ 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. Done when `pnpm ape prototype snapshot --scene <key>` passes for each scene you changed.
43
+ 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, format (`pnpm format`), 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; one taken over unsaved work says `dirty: true` in its report and cannot record a version. Read `references/snapshot.md` for the floor and the full matrix (`--full`, which a release and a milestone take), the selector's turns and `selector-misses.json`, the checks it runs, and formatting after a snapshot. Done when the full snapshot passes on committed work.
44
+ 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. Done when `prototype/versions/C-012.json` is committed.
45
+ 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. Done when the version record holds an approval, or you have reported that approval is waiting.
54
46
  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.
55
47
 
56
48
  **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.
57
49
 
58
50
  **The critique, by a fresh agent, in its own turn.** After the full snapshot passes and before `ape prototype version`, an agent that did not draw the looks runs `ape-critique` on it, and its P0s are fixed first. In the studio a passing full snapshot from the Prototype page starts it by itself, as a fresh read-only turn whose answer the studio writes to `design/critique.md`; elsewhere, run it in a new session. If you drew the scenes, never run `ape-critique` yourself, not even at the end of your turn: end the turn after the passing full snapshot and say the critique comes next. This is words for now: nothing blocks the version yet, so the agent that records a version says in its report that both were done.
59
51
 
60
- **What needs a prototype.** Every screen the product writes itself, in its app or its admin console (an extension in the product's own `packages/` included), and any change of look; the screens that come with BuffCore (sign-in, sign-up, the account, settings) or with an installed extension (`@buffcore/payments`' billing, the waitlist) are already approved and wear the product's theme, so make no scenes for them and wait for no approval of them (to see one in the product's theme, list its exported view in the surface's `src/prototype/views.ts` and give it a scene).
52
+ **What needs a prototype:** every screen the product writes itself and any change of look; the screens that come with BuffCore or an installed extension need none. The details, and the static export for people outside the development server, are in `references/scope-and-export.md`.
61
53
 
62
54
  Draw the small visual inside a 44 px hit area, for example a 24 px icon inside a 44 px button.
63
55
 
64
56
  **The chain.** A prototype comes after the change's plan and its design system (the `ape-plan-change` skill's chain): a component a screen needs that `design/components/` lacks is added first (the `ape-design-system` skill), and `pnpm ape design check` passes before the snapshot.
65
57
 
66
58
  **For agents:** `ape mcp` offers `prototype_snapshot` (`scene` for one), `prototype_version` (`change`, `why`), `prototype_versions` (optional `change`), `prototype_compare` (`change`, `a`, optional `b`) and `prototype_data` (`change`); `design_check` checks the design system. Approving stays a person's, with no MCP tool.
67
-
68
- **For people and programs outside the development server:** `pnpm ape prototype export [<commit>]`, with that commit checked out, writes its prototype as static files that run from any plain file server. `--json` on `snapshot` and `data` gives a stable result and exit codes (AI_NATIVE.md).
@@ -0,0 +1,3 @@
1
+ # The comp, before the scenes
2
+
3
+ When `prototype/versions/comp.json` holds no approved look, draw the comp first and nothing else. Pick the three deciding screens from `plan/journeys.md` and `plan/structure.md` (the ones people see most) and add them to `prototype/scenes.ts` as scenes keyed `comp/<name>`. `plan/structure.md`'s `Surface:` line says which surface comes first (absent, desktop): the snapshot shoots the comp at that width, the product's desktop frame (`prototype.frame`, 1440 by default) or the phone's 390, light and dark. Shoot it with `pnpm ape prototype snapshot --scene 'comp/*'`: it goes to `prototype/snapshots/comp/<commit>/`, apart from the scenes, and never counts toward their totals, completeness or reuse. The studio's Prototype page shows the three beside `design/references.md`'s pictures; the person asks for changes in the chat (redraw and shoot the three again) and approves the look there. Only a person approves it, at every level, Autopilot included. Once approved, the comp's screenshots are the reference every scene must match: its type, color, density and spacing. Judge the first surface first.
@@ -0,0 +1,5 @@
1
+ # What needs a prototype, and the export
2
+
3
+ **What needs a prototype.** Every screen the product writes itself, in its app or its admin console (an extension in the product's own `packages/` included), and any change of look; the screens that come with BuffCore (sign-in, sign-up, the account, settings) or with an installed extension (`@buffcore/payments`' billing, the waitlist) are already approved and wear the product's theme, so make no scenes for them and wait for no approval of them (to see one in the product's theme, list its exported view in the surface's `src/prototype/views.ts` and give it a scene).
4
+
5
+ **For people and programs outside the development server:** `pnpm ape prototype export [<commit>]`, with that commit checked out, writes its prototype as static files that run from any plain file server. `--json` on `snapshot` and `data` gives a stable result and exit codes (AI_NATIVE.md).
@@ -0,0 +1,3 @@
1
+ # The full snapshot: the floor, the full matrix and the selector
2
+
3
+ 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).
@@ -0,0 +1,11 @@
1
+ # plan/structure.md, before the first prototype
2
+
3
+ After Journeys, use `ape-plan-change`'s Structure questions and write `plan/structure.md`:
4
+ one table (Section, First screen, Who, Place, Main), followed by short notes for nested
5
+ screens' owning sections and return targets, phone and wide screens. Offer a draft from the
6
+ journeys, then let the person correct it. Keep Brief, Plan, Brand, Journeys, Structure,
7
+ Prototype in that order in the studio. Review structure again only when sections, audiences
8
+ or screen ownership change. Existing products without the file keep working; propose it for
9
+ review before their next affected prototype, with no invented past approval. Use existing
10
+ inventory routes or console screen names as first screens. The file describes intent and
11
+ grants no access. SA4 adds coverage and traversal evidence later; do not claim them from a table.
@@ -0,0 +1,7 @@
1
+ # The working app
2
+
3
+ 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.
4
+
5
+ ## When screens disagree
6
+
7
+ When screens disagree about people, messages, counts or amounts, fix the shared model or how the screens read it and add an invariant to the product's tests. Never patch a single screen to make its numbers agree. Check the invariant in each named state and after each journey step. Pass derived counts and amounts through `t()` placeholders formatted with `Intl`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ape-request
3
- description: "File a request to BuffCore when configuration, hooks, slots or theme tokens cannot express what a product needs."
3
+ description: "Requests to BuffCore. Use when configuration, hooks, slots or theme tokens cannot express what a product needs."
4
4
  ---
5
5
 
6
6
  # Request something from BuffCore
@@ -1,10 +1,13 @@
1
1
  ---
2
2
  name: ape-upgrade
3
- description: "Upgrade a product to a new BuffCore release and handle its upgrade notes."
3
+ description: "Upgrading a product to a new BuffCore release, with its upgrade notes. Use when a person asks to upgrade BuffCore; read it by path to work through the notes after an upgrade."
4
+ disable-model-invocation: true
4
5
  ---
5
6
 
6
7
  # Upgrade BuffCore in a product
7
8
 
9
+ Only a person starts an upgrade (`disable-model-invocation: true`). After one, an agent reads this file by path, `.claude/skills/ape-upgrade/SKILL.md`, to work through the notes.
10
+
8
11
  1. Stop `ape dev` first (`pnpm stop`): the upgrade refuses while it runs. Then run `pnpm ape upgrade --to <version>` (development only; for example `0.6.0` or `v0.6.0`). It sets the version in every `@buffcore/*` range and in the `buffcore` pin, installs, replaces BuffCore's skills (`.claude/skills/ape-*`) with the release's, refreshes their list in `AGENTS.md` and names those that changed, prints the upgrade notes for every release crossed (read by the release it installed), runs `pnpm ape migrate` (BuffCore's migrations first) and `pnpm test`. Before migrating, it runs `pnpm services:up` when the product has that script. It refuses a downgrade, puts your files and lockfile back and reinstalls them (`pnpm install --frozen-lockfile`) if the install fails (usually because the release isn't published yet), and keeps the links from `pnpm ape link`. The next `pnpm ape dev` starts the app with Expo's cache cleared once, so it runs the new release.
9
12
  2. Skills named `ape-*` are BuffCore's: never edit them in the product, since the next upgrade replaces them (ask BuffCore for a change with the ape-request skill). Put the product's own steps in a skill with another name; the upgrade leaves those alone. Read the skills it says changed before you build on them.
10
13
  3. Work through the notes it printed, oldest release first. Each group names its feature, and it already left out the features the product hasn't turned on (it lists them at the end: read those when you turn the feature on later). A failing test usually points at a note. If the migration or the tests fail, the upgrade stands: fix the cause, then rerun `pnpm ape migrate` and `pnpm test`.
@@ -14,7 +14,7 @@
14
14
  "services:down": "docker compose -f infra/docker/compose.yml down --remove-orphans",
15
15
  "build": "turbo run build",
16
16
  "typecheck": "turbo run typecheck",
17
- "lint": "biome check . && ape size && ape design check && ape check boundaries && ape check secrets && ape agents check",
17
+ "lint": "biome check . && ape size && ape design check && ape check boundaries && ape check secrets && ape check skills && ape agents check",
18
18
  "format": "biome check --write .",
19
19
  "test": "turbo run test --concurrency=2",
20
20
  "coverage": "pnpm test && ape coverage",