@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.
- package/CHANGELOG.md +63 -0
- package/dist/commands/change-merge-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/design/check.d.ts +1 -1
- package/dist/commands/design/check.js +2 -1
- package/dist/commands/design/contract-size.d.ts +7 -0
- package/dist/commands/design/contract-size.js +47 -0
- package/dist/commands/design/tells.en.d.ts +2 -0
- package/dist/commands/design/tells.en.js +2 -0
- package/dist/commands/design/tells.es.js +2 -0
- package/dist/commands/extension/places-approval.d.ts +4 -0
- package/dist/commands/process-paths.d.ts +14 -0
- package/dist/commands/process-paths.js +90 -0
- package/dist/commands/prototype/ai-approval.d.ts +27 -0
- package/dist/commands/prototype/ai-approval.js +60 -0
- package/dist/commands/prototype/approver.d.ts +71 -0
- package/dist/commands/prototype/approver.js +168 -0
- package/dist/commands/prototype/browser.d.ts +4 -24
- package/dist/commands/prototype/browser.js +13 -76
- package/dist/commands/prototype/critique-gate.d.ts +14 -0
- package/dist/commands/prototype/critique-gate.js +48 -0
- package/dist/commands/prototype/fence.d.ts +1 -0
- package/dist/commands/prototype/fence.js +12 -0
- package/dist/commands/prototype/final-approval-grant.js +18 -0
- package/dist/commands/prototype/final-approval.js +4 -1
- package/dist/commands/prototype/index.js +3 -0
- package/dist/commands/prototype/layout-hints.d.ts +34 -0
- package/dist/commands/prototype/layout-hints.js +194 -0
- package/dist/commands/prototype/layout-measure.d.ts +39 -0
- package/dist/commands/prototype/layout-measure.js +97 -0
- package/dist/commands/prototype/layout-words.d.ts +2 -0
- package/dist/commands/prototype/layout-words.js +11 -0
- package/dist/commands/prototype/layout.en.d.ts +6 -0
- package/dist/commands/prototype/layout.en.js +7 -0
- package/dist/commands/prototype/load-location.js +2 -3
- package/dist/commands/prototype/loaded-garbage.d.ts +10 -0
- package/dist/commands/prototype/loaded-garbage.js +20 -0
- package/dist/commands/prototype/media-ready.d.ts +9 -3
- package/dist/commands/prototype/media-ready.js +9 -4
- package/dist/commands/prototype/messages.en.d.ts +15 -0
- package/dist/commands/prototype/messages.en.js +15 -0
- package/dist/commands/prototype/messages.js +15 -0
- package/dist/commands/prototype/milestone-versions.d.ts +4 -0
- package/dist/commands/prototype/prune-command.d.ts +5 -0
- package/dist/commands/prototype/prune-command.js +25 -0
- package/dist/commands/prototype/prune-words.d.ts +1 -0
- package/dist/commands/prototype/prune-words.js +7 -0
- package/dist/commands/prototype/prune.d.ts +16 -0
- package/dist/commands/prototype/prune.en.d.ts +9 -0
- package/dist/commands/prototype/prune.en.js +9 -0
- package/dist/commands/prototype/prune.es.d.ts +2 -0
- package/dist/commands/prototype/prune.es.js +9 -0
- package/dist/commands/prototype/prune.js +140 -0
- package/dist/commands/prototype/reopen-messages.d.ts +9 -0
- package/dist/commands/prototype/reopen-messages.js +19 -0
- package/dist/commands/prototype/report.d.ts +14 -0
- package/dist/commands/prototype/report.js +5 -1
- package/dist/commands/prototype/scene-check.d.ts +37 -0
- package/dist/commands/prototype/scene-check.js +68 -0
- package/dist/commands/prototype/scene-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-look.d.ts +14 -0
- package/dist/commands/prototype/scene-look.js +89 -0
- package/dist/commands/prototype/scene-ready.d.ts +46 -0
- package/dist/commands/prototype/scene-ready.js +122 -0
- package/dist/commands/prototype/scene.d.ts +37 -3
- package/dist/commands/prototype/scene.js +103 -36
- package/dist/commands/prototype/selector-answer.d.ts +43 -0
- package/dist/commands/prototype/selector-answer.js +73 -0
- package/dist/commands/prototype/selector-misses.d.ts +19 -0
- package/dist/commands/prototype/selector-misses.js +78 -0
- package/dist/commands/prototype/selector-prompt.d.ts +23 -0
- package/dist/commands/prototype/selector-prompt.js +32 -0
- package/dist/commands/prototype/selector-run.d.ts +13 -0
- package/dist/commands/prototype/selector-run.js +113 -0
- package/dist/commands/prototype/selector.d.ts +54 -0
- package/dist/commands/prototype/selector.js +96 -0
- package/dist/commands/prototype/snapshot-ancestor.js +2 -0
- package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
- package/dist/commands/prototype/snapshot-bundle.js +69 -7
- package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
- package/dist/commands/prototype/snapshot-check-files.js +41 -0
- package/dist/commands/prototype/snapshot-command.d.ts +2 -0
- package/dist/commands/prototype/snapshot-command.js +23 -10
- package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
- package/dist/commands/prototype/snapshot-completion.js +30 -2
- package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
- package/dist/commands/prototype/snapshot-dependencies.js +120 -14
- package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
- package/dist/commands/prototype/snapshot-hashes.js +28 -0
- package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
- package/dist/commands/prototype/snapshot-inputs.js +140 -190
- package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
- package/dist/commands/prototype/snapshot-matrix.js +95 -0
- package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
- package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
- package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
- package/dist/commands/prototype/snapshot-owners.js +12 -3
- package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
- package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
- package/dist/commands/prototype/snapshot-progress.js +54 -102
- package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-registry.js +121 -0
- package/dist/commands/prototype/snapshot-report.d.ts +4 -0
- package/dist/commands/prototype/snapshot-report.js +77 -12
- package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
- package/dist/commands/prototype/snapshot-requests.js +68 -30
- package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
- package/dist/commands/prototype/snapshot-reuse.js +17 -7
- package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
- package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
- package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
- package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
- package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
- package/dist/commands/prototype/snapshot-server-record.js +135 -0
- package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
- package/dist/commands/prototype/snapshot-servers.js +54 -4
- package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
- package/dist/commands/prototype/snapshot-setup.js +2 -1
- package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
- package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
- package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
- package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
- package/dist/commands/prototype/snapshot.d.ts +6 -0
- package/dist/commands/prototype/snapshot.js +73 -10
- package/dist/commands/prototype/version-commands.d.ts +4 -0
- package/dist/commands/prototype/version-commands.js +36 -8
- package/dist/commands/prototype/versions.d.ts +28 -2
- package/dist/commands/prototype/versions.js +25 -1
- package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
- package/dist/commands/prototype/vite-fs-path.js +15 -0
- package/dist/commands/remove-links.d.ts +6 -0
- package/dist/commands/remove-links.js +17 -0
- package/dist/commands/size-docs.d.ts +9 -0
- package/dist/commands/size-docs.en.d.ts +6 -0
- package/dist/commands/size-docs.en.js +6 -0
- package/dist/commands/size-docs.es.d.ts +2 -0
- package/dist/commands/size-docs.es.js +6 -0
- package/dist/commands/size-docs.js +28 -0
- package/dist/commands/size.d.ts +5 -2
- package/dist/commands/size.js +27 -9
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- package/dist/commands/ui/approval-authority.js +1 -0
- package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
- package/dist/commands/ui/autopilot-ai-approve.js +68 -0
- package/dist/commands/ui/autopilot-loop.js +5 -6
- package/dist/commands/ui/autopilot-merge.js +3 -0
- package/dist/commands/ui/autopilot.en.d.ts +23 -0
- package/dist/commands/ui/autopilot.en.js +23 -0
- package/dist/commands/ui/autopilot.es.d.ts +23 -0
- package/dist/commands/ui/autopilot.es.js +23 -0
- package/dist/commands/ui/chat/find.d.ts +2 -0
- package/dist/commands/ui/chat/find.js +13 -0
- package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
- package/dist/commands/ui/chat/fresh-codex.js +175 -0
- package/dist/commands/ui/chat/fresh-critique.js +13 -5
- package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
- package/dist/commands/ui/chat/fresh-launch.js +67 -11
- package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
- package/dist/commands/ui/chat/fresh-prompts.js +2 -0
- package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
- package/dist/commands/ui/chat/fresh-secrets.js +172 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.en.js +2 -1
- package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.es.js +2 -1
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/loop-approve.d.ts +30 -1
- package/dist/commands/ui/loop-approve.js +2 -2
- package/dist/commands/ui/merge-route.js +3 -0
- package/dist/commands/ui/places-change.d.ts +4 -0
- package/dist/commands/ui/prototype-main.d.ts +4 -0
- package/dist/commands/ui/reopen-route.d.ts +117 -0
- package/dist/commands/ui/reopen-route.js +97 -0
- package/dist/commands/ui/save-route.d.ts +2 -0
- package/dist/commands/ui/save-route.js +4 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +33 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/worktrees.d.ts +1 -1
- package/dist/commands/ui/worktrees.js +19 -3
- package/dist/commands/worktree-sweep.d.ts +45 -0
- package/dist/commands/worktree-sweep.js +188 -0
- package/dist/commands/worktrees-command.d.ts +32 -0
- package/dist/commands/worktrees-command.en.d.ts +25 -0
- package/dist/commands/worktrees-command.en.js +55 -0
- package/dist/commands/worktrees-command.js +96 -0
- package/dist/main.js +2 -0
- package/dist/ui/page.js +82 -82
- package/docs/PROTOTYPE.md +6 -3
- package/docs/WORKBENCH.md +11 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-design-system/SKILL.md +3 -0
- package/skills/ape-plan-change/SKILL.md +6 -0
- package/skills/ape-prototype/SKILL.md +8 -4
- package/templates/product/apps/app/app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,69 @@ One section per release (a git tag). **Upgrade notes** list anything that breaks
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## v0.8.47 (2026-12-04)
|
|
8
|
+
|
|
9
|
+
- On Linux and macOS, `ape prototype snapshot` reuses unchanged console scenes again: files Vite serves from outside the console's folder (`/@fs/…`) were read as paths under the working folder, so every console scene was drawn again. A worktree's snapshot also records its dev servers every few seconds while they start, so the next run stops the servers of a run killed during their cold start.
|
|
10
|
+
|
|
11
|
+
**Upgrade:** nothing to do.
|
|
12
|
+
|
|
13
|
+
- `ape worktrees` lists every worktree of the repository (the studio's and any other) as merged and clean, not merged, uncommitted work, in use or unknown, with `--size` for its size on disk; `ape worktrees clean` removes only the merged, clean, unused ones with the same safe removal as the studio, keeps every branch, and prints what it kept and why. `--json` for programs, exit 0, 1 (a removal failed) or 2 (nothing could be read).
|
|
14
|
+
- The studio cleans up its change worktrees: when it starts and after each merge (a person's or Autopilot's), each `.ape/worktrees/<change>` whose branch is merged into main, with nothing uncommitted and no running turn or process holding its folder, is removed with the safe removal (its packages' links and junctions first, then its `node_modules` through Node, which reaches Windows' long paths); its branch stays. Work says why a merged one was kept and lists worktrees that are no change's under Other worktrees, read-only. A change's worktree whose lockfile (or `pnpm-workspace.yaml`) changed since its last install, after a catch-up say, installs its packages again before its next turn.
|
|
15
|
+
- `ape prototype version` refuses while the critique on file (`design/critique.md`) marks an open P0, naming each line: one the Autopilot approver reads as a P0 (the report's Fix list writes `- **P0** <what>`; `[P0]` and `| P0 |` count too). A fixed P0 is struck through (`- ~~**P0** <what>~~ <how it was fixed>`). With no critique on file the version is recorded and the command says so (`note` in `--json`). The refusal is a record refusal (exit 1), at every door that records a version.
|
|
16
|
+
|
|
17
|
+
**Upgrade notes** (every product with a critique): before recording a version, strike through each fixed P0 in `design/critique.md`, commit it and take the snapshot again; an open P0 now refuses the version.
|
|
18
|
+
|
|
19
|
+
- The `ape-critique` skill gains a spacing and layout pass under Detail and craft (padding inside cards and controls, gaps between sections, shared edges and the grid, siblings that should match, crowding at 390 against emptiness at 1440), each finding naming the screenshot, the element and the spacing token; it reads the snapshot's layout hints first and confirms or dismisses each. `design/critique.md` now holds only the current review: the critique replaces the file, a recheck of the P0s edits that same report, and older reviews stay in git history (the studio's critique turn already wrote it this way). Before scoring it reads only the sections of the brief, the journeys and `design/DESIGN.md` that the change touches, found by heading, plus the contract's direction, voice, color, type and layout sections, instead of the files whole.
|
|
20
|
+
|
|
21
|
+
**Upgrade notes** (every product with a critique): `ape upgrade` refreshes the skill. Cut `design/critique.md` to its newest review (one `# Critique` section); git keeps the older ones.
|
|
22
|
+
|
|
23
|
+
- `ape prototype snapshot` suggests layout hints beside the font hints: in light mode and the first language, each theme's look measures its laid-out boxes and names siblings that overlap with neither a layer, a box with text a few pixels (up to 4) off the edge its siblings share, a sibling of the same component with other padding or gaps, and space between neighbours that is no step of the theme's spacing scale, with the nearest `space-*` token (`docs/PROTOTYPE.md` has the rules). They are advice only: the pictures, the checks, the exit code and the gates are unchanged, and the report's `hints` keeps its shape. A scene marks a hint it shows on purpose with `layoutExceptions` in `prototype/scenes.ts` (`kind`, optional `element` words, `reason`); `defineScenes` refuses one without a reason. Measuring costs a few milliseconds a look.
|
|
24
|
+
|
|
25
|
+
- The critique, the selector and the Autopilot approver now run with Codex as well as Claude Code, whichever `plan/agents.md` sets for validation: each turn is a new Codex session in its own read-only sandbox (`codex exec -s read-only`: no writes or network, no MCP servers or web search, the person's own sign-in). Unlike Claude's, a Codex turn can read secret files in the product; a product whose `.codex/` settings add MCP servers or hooks gets no Codex turn. Any fresh answer (Claude's too) that quotes a value from the product's secret files is dropped, naming the file only. The approver is still a fresh session of its own when the same agent built the change. OpenCode still has no read-only turn: with it, the floor is drawn alone and the version waits for a person, as before.
|
|
26
|
+
|
|
27
|
+
**Upgrade:** nothing to do.
|
|
28
|
+
|
|
29
|
+
- At Autopilot, a prototype version is approved only by a fresh, read-only approver turn of the agent and model `plan/agents.md` sets for validation, never by the agent that built it, and only when the report drew the floor, every check passed, the critique has no P0 and the selector's second turn agreed. Otherwise the version waits for a person, with the reason. The signature records it as an AI approval (`ai`: model and reason, beside `agent`). The studio's approval card marks it as approved by AI, with the model and reason, and a person reopens one with its Reopen button or `ape prototype reopen <change>`. A host's `approval` hook receives `ai` with an Autopilot prototype approval. A milestone's approval now takes only a version whose report drew every scene in the full matrix. You drive, Review and Lead are unchanged; releases, deploys and money still wait for a person.
|
|
30
|
+
|
|
31
|
+
**Upgrade notes** (every product): a host or tool that reads `prototype/versions/*.json` should treat a signature with `ai` as an AI approval, not a person's, and show it so. A host that implements the `approval` hook receives `ai` (model and reason) with an Autopilot prototype approval, and `agent` then names the approver's agent, not the agent that built the change; it should keep both on the signature it returns, and may answer the new `action: 'reopen'` (or refuse it, and the studio says the host cannot reopen). A hook that answers `reopen` reopens only the artifact named in the request, and only when that artifact's approval carries `ai`: never a person's approval, never another version. The studio waits 5 seconds for the answer. Reopened approvals move to `superseded` with `reopened` (who and when). A milestone approved from a floor report needs `ape prototype snapshot --full` of that commit, recorded again.
|
|
32
|
+
|
|
33
|
+
- Before a floor snapshot draws, two fresh read-only turns of the agent and model `plan/agents.md` sets for validation may add scenes to draw again and looks beyond the floor, each with a reason. The second turn only adds; nothing goes below the floor, and a pick outside the scenes or the matrix is dropped and noted. `report.json` keeps the turns, picks, drops and the reason when none ran. With an agent that has no read-only turn (OpenCode), in CI, or when a turn fails, takes over 120 seconds or answers out of shape, the floor is drawn alone and the terminal says why. `--full` skips it. A full run notes in `prototype/snapshots/selector-misses.json` the problems in looks the last selector run did not draw, and later turns learn from them.
|
|
34
|
+
|
|
35
|
+
**Upgrade:** nothing to do. Commit `selector-misses.json` with the report when a full run writes it.
|
|
36
|
+
|
|
37
|
+
- `ape prototype snapshot` draws the floor by default: the product's theme (the first starter when it names none), light and dark, its languages and `en-XA`, and `ar-XB` for a right-to-left language. The full matrix (every theme, mode and pseudo-locale) runs with the new `--full`, and by itself when the theme, `design/`, a shell or another shared input changed since the last full report. The report says which in `matrix`, `matrixReason` and each floor scene's `matrix`. `ape prototype version` accepts a floor report.
|
|
38
|
+
|
|
39
|
+
**Upgrade:** nothing to do. The first snapshot after upgrading draws the full matrix; take a release's or a milestone's report with `--full`.
|
|
40
|
+
|
|
41
|
+
- A prototype snapshot stopped half way (killed, Ctrl+C, or a scene that failed both tries) draws only the unfinished scenes when run again on the same checkout, `--scene` runs included; a `--scene` run no longer discards the kept scenes of the others, and the full-page fallback line says it counts the scenes drawn in that run. The dev servers a worktree's snapshot started are recorded (id, start time, command line), and the next run of that worktree stops the ones a hard kill left running, only while all three still match.
|
|
42
|
+
- Prototype snapshots reuse a scene's pictures from an earlier commit when nothing it draws from has changed. A view edit redraws only the scenes whose views import the changed file. 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 that made a request its inputs don't cover is drawn again. The first run after upgrading redraws every scene.
|
|
43
|
+
|
|
44
|
+
**Limits:** a scene whose props hold a function is never reused from another commit. An app on Metro is one bundle, so an app view edit redraws all the app's scenes. A stopped run keeps only scenes that called no API and whose every request was covered. A run the studio starts never uses kept scenes. Catalogs count as whole files. Data that reaches a scene only over the dev server's message socket, and a Vite optimizer file served with bytes other than the file on disk, are not seen.
|
|
45
|
+
|
|
46
|
+
**Upgrade notes** (every product): to reuse console scenes view by view, register each view in `apps/admin/src/prototype/views.ts` with React's `lazy` and a literal relative import, with the same named export in both files. A view imported directly counts as a shared part.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { lazy } from 'react';
|
|
50
|
+
|
|
51
|
+
export const NotesView = lazy(() =>
|
|
52
|
+
import('./NotesView.tsx').then((m) => ({ default: m.NotesView })),
|
|
53
|
+
);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- Process documents stay small enough to read. The `ape-prototype` and `ape-plan-change` skills read `plan/brief.md`, `plan/journeys.md`, `design/DESIGN.md` and `design/screens.md` by section (list the `## ` headings, then read the ones the change needs), not whole, and the studio's fresh review reads only the sections it needs of the earlier steps' files. A change file stays under about 15 KB: its history is in git.
|
|
57
|
+
- `design/DESIGN.md` stays a contract: the `ape-design-system` skill puts per-screen specs in `design/screens.md`, one `## <screen>` section each, and `ape design check` warns, without failing, when DESIGN.md passes about 40 KB or one of its sections about 15 KB.
|
|
58
|
+
- `ape size` (in `pnpm lint` and so `pnpm verify`) also warns, without failing, on process documents past their size: `design/critique.md` over 40 KB, `plan/changes/*.md` over 15 KB, other Markdown under `design/` and `plan/` over 50 KB. Its exit code is unchanged.
|
|
59
|
+
- `ape prototype prune [--dry-run] [--json]` removes committed snapshot folders under `prototype/snapshots/` that no record in `prototype/versions/` names (by source commit or report fingerprint), keeping the newest, HEAD's, any with unsaved changes and `comp/`; git keeps their history. The `ape-prototype` skill runs it after recording a version.
|
|
60
|
+
|
|
61
|
+
**Upgrade notes** (every product): nothing breaks; `ape upgrade` refreshes the skills. A one-time cleanup for a product that grew large process files: run `pnpm ape prototype prune --dry-run`, then `pnpm ape prototype prune`, and commit the deletion; cut `design/critique.md` to its newest review (earlier ones stay in git); move per-screen detail from `design/DESIGN.md` (often under `## Components`) into `design/screens.md`, one `## <screen>` section each, leaving the contract's rules; trim shipped change files' running logs. Then `pnpm ape design check` and `pnpm ape size` show no size warnings.
|
|
62
|
+
|
|
63
|
+
## v0.8.46 (2026-12-03)
|
|
64
|
+
|
|
65
|
+
- Prototype snapshots draw a scene's later looks in place, on the same page. Each scene starts in a fresh browser context and then checks its last look against a fresh load; when the picture or findings differ, the scene is drawn again with full loads. The terminal counts full-page fallbacks of looks and scenes. Every load now blurs a field that autofocuses late before the picture, so a scene's focus ring no longer depends on timing; this changes earlier pictures only where that ring came and went. A view that takes the focus back after the blur keeps it, as a plain load shows it. Limits: code above the scene page that reads the look or storage once at boot is not rechecked per look, and scenes whose pictures vary between loads always redraw fresh.
|
|
66
|
+
- On Linux (and likely macOS), the app's first page after its Metro server starts (in `ape dev` and in a prototype snapshot's warm-up) no longer fails with HTTP 500 "Failed to collapse": a new product's `apps/app/app.json` turns off Expo's tsconfig `paths` resolver (`"experiments": { "tsconfigPaths": false }`), which tripped on the app's tsconfig extending the root one. No product tsconfig declares `paths`.
|
|
67
|
+
|
|
68
|
+
**Upgrade notes** (every product): on Linux (and likely macOS), add `"experiments": { "tsconfigPaths": false }` under `expo` in `apps/app/app.json`. Leave it out if your app relies on tsconfig `paths`.
|
|
69
|
+
|
|
7
70
|
## v0.8.45 (2026-12-03)
|
|
8
71
|
|
|
9
72
|
- The studio's Prototype is a workspace: along the top, the change and its version (Compare, Approve), **Customer app | Console**, **Mobile | Tablet | Desktop** (Rotate for a tablet) and the tools **Select | Comment | Draw | Area**; on the left, **Journeys** (from `plan/journeys.md`, by who does them and in which app, joined to the journeys the running app plays; the open one lists its steps to jump to) and **Screens**, with the sample data at the foot; in the middle, the app in its device, zoomed to fit, with a line saying what you see and the step bar (Back, the step, Play, Next) under it. The console is a second frame at the stack's admin address: switching keeps each one's step and never reloads the other. The rail folds to its icons on this page. At phone width a phone's app takes the page (a tablet or a desktop is drawn in its bezel, zoomed to fit), the device choice shows as icons, and a bar sits at the app's foot (Journeys, Back, the step, Next, Changes); on a touch screen the Comment hint says tap. The preview's Try a journey and Preview options menus, the canvas's Full screen button and the drawn-only full-screen scenes are gone.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SafeDiagnostics } from '@buffcore/contracts/workbench';
|
|
2
|
-
import { type Reason } from './change-merge.ts';
|
|
2
|
+
import { type MergeGit, type Reason } from './change-merge.ts';
|
|
3
3
|
export type RemovalResult = {
|
|
4
4
|
ok: true;
|
|
5
5
|
} | ({
|
|
@@ -12,5 +12,12 @@ export type RemovalResult = {
|
|
|
12
12
|
diagnostics: SafeDiagnostics;
|
|
13
13
|
detail?: never;
|
|
14
14
|
}));
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Remove one linked checkout and keep its branch: only when it is clean and its HEAD is reachable
|
|
17
|
+
* from main. Throws when Git or the disk fails; the caller keeps the worktree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function removeCheckout(root: string, path: string, tools?: {
|
|
20
|
+
git: MergeGit;
|
|
21
|
+
}): Promise<RemovalResult>;
|
|
22
|
+
/** A change's worktree, under the merge lock: the same removal. */
|
|
16
23
|
export declare function removeWorktree(root: string, change: string, tools?: import("./change-merge.ts").MergeTools): Promise<RemovalResult>;
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
import { t } from './change-merge.en.js';
|
|
2
|
-
import { context, defaultMergeTools, dirty, locked, refuse } from './change-merge.js';
|
|
2
|
+
import { context, defaultMergeTools, dirty, locked, refuse, } from './change-merge.js';
|
|
3
3
|
import { mainCommit } from './main-ref.js';
|
|
4
|
-
import { removeLinks } from './remove-links.js';
|
|
5
|
-
/**
|
|
4
|
+
import { removeLinks, removePackages } from './remove-links.js';
|
|
5
|
+
/**
|
|
6
|
+
* Remove one linked checkout and keep its branch: only when it is clean and its HEAD is reachable
|
|
7
|
+
* from main. Throws when Git or the disk fails; the caller keeps the worktree.
|
|
8
|
+
*/
|
|
9
|
+
export async function removeCheckout(root, path, tools = defaultMergeTools) {
|
|
10
|
+
if (await dirty(path, tools.git))
|
|
11
|
+
return refuse('dirty', 'change.merge.dirty');
|
|
12
|
+
const [main, head] = await Promise.all([
|
|
13
|
+
mainCommit(root, tools.git),
|
|
14
|
+
tools.git(path, ['rev-parse', '--verify', 'HEAD^{commit}']),
|
|
15
|
+
]);
|
|
16
|
+
const merged = await tools.git(root, ['merge-base', '--is-ancestor', head.trim(), main]).then(() => true, () => false);
|
|
17
|
+
if (!merged)
|
|
18
|
+
return { ok: false, reason: 'unmerged', detail: t('change.merge.unmerged') };
|
|
19
|
+
// Its packages' links and junctions go first, as themselves: Git's removal never follows one.
|
|
20
|
+
await removeLinks(path);
|
|
21
|
+
// An untracked top `node_modules` (a clean status means ignored) goes through Node, which reaches
|
|
22
|
+
// the long paths Git for Windows cannot delete.
|
|
23
|
+
if (!(await tools.git(path, ['ls-files', '--', 'node_modules'])).trim())
|
|
24
|
+
await removePackages(path);
|
|
25
|
+
await tools.git(root, ['worktree', 'remove', path]);
|
|
26
|
+
return { ok: true };
|
|
27
|
+
}
|
|
28
|
+
/** A change's worktree, under the merge lock: the same removal. */
|
|
6
29
|
export async function removeWorktree(root, change, tools = defaultMergeTools) {
|
|
7
30
|
try {
|
|
8
31
|
return await locked(root, change, tools, async () => {
|
|
9
32
|
const { tree } = await context(root, change, tools.git);
|
|
10
|
-
|
|
11
|
-
return refuse('dirty', 'change.merge.dirty');
|
|
12
|
-
const main = await mainCommit(root, tools.git);
|
|
13
|
-
const merged = await tools
|
|
14
|
-
.git(root, ['merge-base', '--is-ancestor', `refs/heads/${tree.branch}`, main])
|
|
15
|
-
.then(() => true, () => false);
|
|
16
|
-
if (!merged)
|
|
17
|
-
return { ok: false, reason: 'unmerged', detail: t('change.merge.unmerged') };
|
|
18
|
-
// Its packages' links and junctions go first, as themselves: Git's removal never follows one.
|
|
19
|
-
await removeLinks(tree.path);
|
|
20
|
-
await tools.git(root, ['worktree', 'remove', tree.path]);
|
|
21
|
-
return { ok: true };
|
|
33
|
+
return removeCheckout(root, tree.path, tools);
|
|
22
34
|
});
|
|
23
35
|
}
|
|
24
36
|
catch {
|
|
@@ -9,7 +9,7 @@ export interface DesignCheckResult {
|
|
|
9
9
|
/** The product's own components, by name. */
|
|
10
10
|
components: string[];
|
|
11
11
|
problems: DesignProblem[];
|
|
12
|
-
/** Advice that never fails the check: journeys that name no role. */
|
|
12
|
+
/** Advice that never fails the check: journeys that name no role, a contract grown too big. */
|
|
13
13
|
warnings: string[];
|
|
14
14
|
}
|
|
15
15
|
export declare function designCheck(root: string, advise?: (lines: string[]) => void): Promise<DesignCheckResult>;
|
|
@@ -7,6 +7,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { findRoot } from '../../project.js';
|
|
9
9
|
import { printJson } from '../json.js';
|
|
10
|
+
import { contractSizeWarnings } from './contract-size.js';
|
|
10
11
|
import { journeyRoleWarnings } from './journey-roles.js';
|
|
11
12
|
import { missingReferences } from './references.js';
|
|
12
13
|
import { outsideComponents, rawValues } from './rules.js';
|
|
@@ -197,7 +198,7 @@ export async function designCheck(root, advise) {
|
|
|
197
198
|
files: [...scanned.map((f) => fromRoot(root, f)), DESIGN, MANIFEST],
|
|
198
199
|
components: components.map(componentName),
|
|
199
200
|
problems,
|
|
200
|
-
warnings: await journeyRoleWarnings(root),
|
|
201
|
+
warnings: [...(await journeyRoleWarnings(root)), ...(await contractSizeWarnings(root))],
|
|
201
202
|
};
|
|
202
203
|
}
|
|
203
204
|
function print(result) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** About 40 KB for the whole contract, about 15 KB for one `## ` section. */
|
|
2
|
+
export declare const CONTRACT_LIMIT: number;
|
|
3
|
+
export declare const SECTION_LIMIT: number;
|
|
4
|
+
/** The warnings for a contract's text: the whole past its limit, and each section past its own. */
|
|
5
|
+
export declare function contractSizeLines(text: string, locale?: 'en' | 'es'): string[];
|
|
6
|
+
/** `ape design check`'s size warnings for `design/DESIGN.md`, in the person's language. */
|
|
7
|
+
export declare function contractSizeWarnings(root: string): Promise<string[]>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// The design contract stays a contract: `design/DESIGN.md` says the direction, the voice, the
|
|
2
|
+
// tokens' use and the components' rules, and per-screen specs live in `design/screens.md`. A
|
|
3
|
+
// contract past its size, or one section past its own, is a warning, never a failure.
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { createI18n } from '@buffcore/i18n';
|
|
7
|
+
import { en } from './tells.en.js';
|
|
8
|
+
import { es } from './tells.es.js';
|
|
9
|
+
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
10
|
+
/** About 40 KB for the whole contract, about 15 KB for one `## ` section. */
|
|
11
|
+
export const CONTRACT_LIMIT = 40 * 1024;
|
|
12
|
+
export const SECTION_LIMIT = 15 * 1024;
|
|
13
|
+
const kb = (bytes) => Math.round(bytes / 1024);
|
|
14
|
+
/** Each `## ` heading and its size in bytes, heading line included, to the next `## `. */
|
|
15
|
+
function sectionSizes(text) {
|
|
16
|
+
const found = [];
|
|
17
|
+
for (const line of text.split('\n')) {
|
|
18
|
+
if (line.startsWith('## '))
|
|
19
|
+
found.push({ heading: line.slice(3).trim(), bytes: 0 });
|
|
20
|
+
const current = found.at(-1);
|
|
21
|
+
if (current)
|
|
22
|
+
current.bytes += Buffer.byteLength(line, 'utf8') + 1;
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
/** The warnings for a contract's text: the whole past its limit, and each section past its own. */
|
|
27
|
+
export function contractSizeLines(text, locale = 'en') {
|
|
28
|
+
const t = (key, values) => messages.t(locale, key, values);
|
|
29
|
+
const lines = [];
|
|
30
|
+
const bytes = Buffer.byteLength(text, 'utf8');
|
|
31
|
+
if (bytes > CONTRACT_LIMIT)
|
|
32
|
+
lines.push(t('design.contractSize', { size: kb(bytes), limit: kb(CONTRACT_LIMIT) }));
|
|
33
|
+
for (const section of sectionSizes(text))
|
|
34
|
+
if (section.bytes > SECTION_LIMIT)
|
|
35
|
+
lines.push(t('design.sectionSize', {
|
|
36
|
+
heading: section.heading,
|
|
37
|
+
size: kb(section.bytes),
|
|
38
|
+
limit: kb(SECTION_LIMIT),
|
|
39
|
+
}));
|
|
40
|
+
return lines;
|
|
41
|
+
}
|
|
42
|
+
/** `ape design check`'s size warnings for `design/DESIGN.md`, in the person's language. */
|
|
43
|
+
export async function contractSizeWarnings(root) {
|
|
44
|
+
const locale = /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
|
|
45
|
+
const text = await readFile(join(root, 'design', 'DESIGN.md'), 'utf8').catch(() => '');
|
|
46
|
+
return contractSizeLines(text.replace(/\r\n/g, '\n'), locale);
|
|
47
|
+
}
|
|
@@ -10,4 +10,6 @@ export const en = {
|
|
|
10
10
|
'design.font': 'No font loading or bundle found for {family}. Load that family with the app fonts.',
|
|
11
11
|
'design.journeyRole': 'Warning {file} the journey {journey} names no role: say who it is for, one of the people in plan/journeys.md.',
|
|
12
12
|
'design.reference': 'The reference picture {path} is not on this computer. Capture it again, or remove its line.',
|
|
13
|
+
'design.contractSize': 'Warning design/DESIGN.md {size} KB, over about {limit} KB: keep the contract to its rules and move per-screen specs into design/screens.md, one "## <screen>" section each.',
|
|
14
|
+
'design.sectionSize': 'Warning design/DESIGN.md the section "{heading}" is {size} KB, over about {limit} KB: move per-screen specs into design/screens.md, one "## <screen>" section each.',
|
|
13
15
|
};
|
|
@@ -10,4 +10,6 @@ export const es = {
|
|
|
10
10
|
'design.font': 'No se encontró cómo se carga ni se incluye la fuente {family}. Cárgala junto con las fuentes de la aplicación.',
|
|
11
11
|
'design.journeyRole': 'Aviso {file} el recorrido {journey} no nombra un rol: di para quién es, una de las personas de plan/journeys.md.',
|
|
12
12
|
'design.reference': 'La imagen de referencia {path} no está en este equipo. Vuelve a capturarla o quita su línea.',
|
|
13
|
+
'design.contractSize': 'Aviso design/DESIGN.md {size} KB, más de unos {limit} KB: deja en el contrato solo sus reglas y pasa las especificaciones de cada pantalla a design/screens.md, una sección "## <pantalla>" por pantalla.',
|
|
14
|
+
'design.sectionSize': 'Aviso design/DESIGN.md la sección "{heading}" tiene {size} KB, más de unos {limit} KB: pasa las especificaciones de cada pantalla a design/screens.md, una sección "## <pantalla>" por pantalla.',
|
|
13
15
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** One process's command line and, where the system says, its working folder. */
|
|
2
|
+
export interface ProcessPlace {
|
|
3
|
+
pid: number;
|
|
4
|
+
command: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Every process this account can see; throws when the table cannot be read. */
|
|
8
|
+
export declare const processPlaces: () => Promise<ProcessPlace[]>;
|
|
9
|
+
/**
|
|
10
|
+
* The folders of `paths` that some process other than this one holds: its working folder is the
|
|
11
|
+
* folder or inside it, or its command line names the folder (followed by a separator, a quote,
|
|
12
|
+
* a space or the end, so `C-001` never matches `C-0012`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function pathsHeld(paths: readonly string[], places: readonly ProcessPlace[], self?: number, win?: boolean): Set<string>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Which folders a running process holds: its command line names one, or (Linux, macOS) it works
|
|
2
|
+
// in one. Used before a worktree is removed; any failure to read the process table throws, and the
|
|
3
|
+
// caller then keeps every worktree.
|
|
4
|
+
import { execFile } from 'node:child_process';
|
|
5
|
+
import { readdir, readlink } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { readWindowsProcesses } from './stop.js';
|
|
9
|
+
const run = promisify(execFile);
|
|
10
|
+
const big = { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, windowsHide: true };
|
|
11
|
+
async function windows() {
|
|
12
|
+
const script = 'Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Compress';
|
|
13
|
+
const { stdout } = await run('powershell', ['-NoProfile', '-Command', script], big);
|
|
14
|
+
// Windows gives no other process's working folder without native code: the command line only.
|
|
15
|
+
return readWindowsProcesses(stdout).map(({ pid, command }) => ({ pid, command }));
|
|
16
|
+
}
|
|
17
|
+
async function linuxCwds() {
|
|
18
|
+
const cwds = new Map();
|
|
19
|
+
for (const name of await readdir('/proc')) {
|
|
20
|
+
if (!/^\d+$/.test(name))
|
|
21
|
+
continue;
|
|
22
|
+
// Another account's process, or one that just ended, is skipped: its command line still counts.
|
|
23
|
+
const cwd = await readlink(join('/proc', name, 'cwd')).catch(() => undefined);
|
|
24
|
+
if (cwd)
|
|
25
|
+
cwds.set(Number(name), cwd);
|
|
26
|
+
}
|
|
27
|
+
return cwds;
|
|
28
|
+
}
|
|
29
|
+
async function macCwds() {
|
|
30
|
+
const { stdout } = await run('lsof', ['-n', '-P', '-d', 'cwd', '-Fpn'], big).catch(
|
|
31
|
+
// lsof exits 1 when some processes cannot be read; what it printed still counts.
|
|
32
|
+
(error) => {
|
|
33
|
+
if (typeof error.stdout === 'string' && error.stdout)
|
|
34
|
+
return { stdout: error.stdout };
|
|
35
|
+
throw error;
|
|
36
|
+
});
|
|
37
|
+
const cwds = new Map();
|
|
38
|
+
let pid = 0;
|
|
39
|
+
for (const line of stdout.split('\n')) {
|
|
40
|
+
if (line.startsWith('p'))
|
|
41
|
+
pid = Number(line.slice(1));
|
|
42
|
+
else if (line.startsWith('n') && pid)
|
|
43
|
+
cwds.set(pid, line.slice(1));
|
|
44
|
+
}
|
|
45
|
+
return cwds;
|
|
46
|
+
}
|
|
47
|
+
async function posix() {
|
|
48
|
+
const [{ stdout }, cwds] = await Promise.all([
|
|
49
|
+
run('ps', ['-A', '-o', 'pid=,args='], big),
|
|
50
|
+
process.platform === 'linux' ? linuxCwds() : macCwds(),
|
|
51
|
+
]);
|
|
52
|
+
return stdout.split('\n').flatMap((line) => {
|
|
53
|
+
const match = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
54
|
+
if (!match)
|
|
55
|
+
return [];
|
|
56
|
+
const pid = Number(match[1]);
|
|
57
|
+
const cwd = cwds.get(pid);
|
|
58
|
+
return [{ pid, command: match[2] ?? '', ...(cwd ? { cwd } : {}) }];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Every process this account can see; throws when the table cannot be read. */
|
|
62
|
+
export const processPlaces = () => process.platform === 'win32' ? windows() : posix();
|
|
63
|
+
const escaped = (text) => text.replace(/[.*+?^$|()[\]{}\\]/g, '\\$&');
|
|
64
|
+
const windowsCase = (text, win) => {
|
|
65
|
+
const slashes = text.replaceAll('\\', '/');
|
|
66
|
+
return win ? slashes.toLowerCase() : slashes;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The folders of `paths` that some process other than this one holds: its working folder is the
|
|
70
|
+
* folder or inside it, or its command line names the folder (followed by a separator, a quote,
|
|
71
|
+
* a space or the end, so `C-001` never matches `C-0012`).
|
|
72
|
+
*/
|
|
73
|
+
export function pathsHeld(paths, places, self = process.pid, win = process.platform === 'win32') {
|
|
74
|
+
const held = new Set();
|
|
75
|
+
for (const path of paths) {
|
|
76
|
+
const folder = windowsCase(path, win).replace(/\/+$/, '');
|
|
77
|
+
const named = new RegExp(`${escaped(folder)}(?![\\w.-])`);
|
|
78
|
+
const holds = (place) => {
|
|
79
|
+
if (place.pid === self)
|
|
80
|
+
return false;
|
|
81
|
+
const cwd = place.cwd && windowsCase(place.cwd, win);
|
|
82
|
+
if (cwd && (cwd === folder || cwd.startsWith(`${folder}/`)))
|
|
83
|
+
return true;
|
|
84
|
+
return named.test(windowsCase(place.command, win));
|
|
85
|
+
};
|
|
86
|
+
if (places.some(holds))
|
|
87
|
+
held.add(path);
|
|
88
|
+
}
|
|
89
|
+
return held;
|
|
90
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SnapshotReport } from './report.ts';
|
|
2
|
+
/** Why a version waits for a person instead of an approver turn. */
|
|
3
|
+
export type AiBlock = 'floor' | 'selector' | 'checks' | 'critique' | 'p0' | 'agreement';
|
|
4
|
+
type Report = Pick<SnapshotReport, 'commit' | 'matrix' | 'scenes' | 'themes' | 'locales' | 'selector' | 'problems'>;
|
|
5
|
+
/** The commit a critique names in its first heading (`# Critique · <product> · <commit>`). */
|
|
6
|
+
export declare function critiqueCommit(text: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* A P0 anywhere a line starts with one: a bullet or numbered item (`- **P0**`, `1. **P0**`,
|
|
9
|
+
* `- **P0:**`, `- P0:`), a heading (`## P0`), the line itself (`P0 —`), or a mark inside a line
|
|
10
|
+
* (`- [P0]`, `| P0 |`, `(P0)`). The critique has no
|
|
11
|
+
* structured form (ape-critique writes Markdown), so it is read line by line, erring towards a P0.
|
|
12
|
+
*/
|
|
13
|
+
export declare const hasP0: (text: string) => boolean;
|
|
14
|
+
/** Every pick of the second selector turn was drawn: a look in the scene's extraLooks, else redrawn. */
|
|
15
|
+
export declare function secondTurnAgreed(report: Report): boolean;
|
|
16
|
+
/** What the report alone decides, before any critique turn runs. */
|
|
17
|
+
export declare function reportBlock(report: Report): AiBlock | undefined;
|
|
18
|
+
/** The critique the studio's fresh turn wrote for this report: it names the commit, and no P0. */
|
|
19
|
+
export declare function critiqueBlock(report: Report, critique: string | undefined): AiBlock | undefined;
|
|
20
|
+
/** The first condition that fails, or undefined when an approver turn may decide. */
|
|
21
|
+
export declare const aiApprovalBlock: (report: Report, critique: string | undefined) => AiBlock | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Every scene drawn in the full matrix (S4, milestones): each scene judged by its own matrix and the
|
|
24
|
+
* looks it actually has (S3b's meetsFloor), never by `report.matrix` alone. Reused scenes count.
|
|
25
|
+
*/
|
|
26
|
+
export declare const meetsFull: (report: Pick<Report, 'matrix' | 'scenes' | 'themes' | 'locales'>) => boolean;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { meetsFloor } from './snapshot-matrix.js';
|
|
2
|
+
/** The commit a critique names in its first heading (`# Critique · <product> · <commit>`). */
|
|
3
|
+
export function critiqueCommit(text) {
|
|
4
|
+
const heading = text.split('\n').find((line) => line.startsWith('# '));
|
|
5
|
+
return heading?.match(/\b([0-9a-f]{7,40})\s*$/)?.[1];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A P0 anywhere a line starts with one: a bullet or numbered item (`- **P0**`, `1. **P0**`,
|
|
9
|
+
* `- **P0:**`, `- P0:`), a heading (`## P0`), the line itself (`P0 —`), or a mark inside a line
|
|
10
|
+
* (`- [P0]`, `| P0 |`, `(P0)`). The critique has no
|
|
11
|
+
* structured form (ape-critique writes Markdown), so it is read line by line, erring towards a P0.
|
|
12
|
+
*/
|
|
13
|
+
export const hasP0 = (text) => /^\s*(?:#{1,6}\s*|[-*+]\s*|\d+[.)]\s*)?(?:\*\*|__|\*|_)?\s*P0(?![0-9])/im.test(text) ||
|
|
14
|
+
// Marked inside a line: `- [P0]`, `| P0 |`, `(P0)`.
|
|
15
|
+
/[[(|]\s*P0\s*[)\]|]/i.test(text);
|
|
16
|
+
/** Every pick of the second selector turn was drawn: a look in the scene's extraLooks, else redrawn. */
|
|
17
|
+
export function secondTurnAgreed(report) {
|
|
18
|
+
const selector = report.selector;
|
|
19
|
+
if (!selector)
|
|
20
|
+
return false;
|
|
21
|
+
if (selector.skipped === 'full')
|
|
22
|
+
return true;
|
|
23
|
+
if (selector.skipped || selector.turns[1]?.state !== 'done')
|
|
24
|
+
return false;
|
|
25
|
+
return selector.picks
|
|
26
|
+
.filter((pick) => pick.turn === 2)
|
|
27
|
+
.every((pick) => {
|
|
28
|
+
const scene = report.scenes.find((entry) => entry.key === pick.scene);
|
|
29
|
+
if (!scene)
|
|
30
|
+
return false;
|
|
31
|
+
return pick.look ? !!scene.extraLooks?.includes(pick.look) : scene.reusedFrom === undefined;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** What the report alone decides, before any critique turn runs. */
|
|
35
|
+
export function reportBlock(report) {
|
|
36
|
+
if (!meetsFloor(report))
|
|
37
|
+
return 'floor';
|
|
38
|
+
if (!report.selector)
|
|
39
|
+
return 'selector';
|
|
40
|
+
const broken = report.scenes.some((scene) => 'loadFailure' in scene || 'scriptError' in scene);
|
|
41
|
+
if (report.problems.length || broken)
|
|
42
|
+
return 'checks';
|
|
43
|
+
if (!secondTurnAgreed(report))
|
|
44
|
+
return 'agreement';
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
/** The critique the studio's fresh turn wrote for this report: it names the commit, and no P0. */
|
|
48
|
+
export function critiqueBlock(report, critique) {
|
|
49
|
+
const named = critique === undefined ? undefined : critiqueCommit(critique);
|
|
50
|
+
if (!critique || !named || !report.commit.startsWith(named))
|
|
51
|
+
return 'critique';
|
|
52
|
+
return hasP0(critique) ? 'p0' : undefined;
|
|
53
|
+
}
|
|
54
|
+
/** The first condition that fails, or undefined when an approver turn may decide. */
|
|
55
|
+
export const aiApprovalBlock = (report, critique) => reportBlock(report) ?? critiqueBlock(report, critique);
|
|
56
|
+
/**
|
|
57
|
+
* Every scene drawn in the full matrix (S4, milestones): each scene judged by its own matrix and the
|
|
58
|
+
* looks it actually has (S3b's meetsFloor), never by `report.matrix` alone. Reused scenes count.
|
|
59
|
+
*/
|
|
60
|
+
export const meetsFull = (report) => meetsFloor(report) && report.scenes.every((scene) => (scene.matrix ?? 'full') === 'full');
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { AgentsFile } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type Start, stopTree } from '../ui/runner.ts';
|
|
4
|
+
/** How long the approver turn may take. */
|
|
5
|
+
export declare const APPROVER_SECONDS = 180;
|
|
6
|
+
/** How long the critique turn may take: it runs the design and i18n checks. */
|
|
7
|
+
export declare const CRITIC_SECONDS = 600;
|
|
8
|
+
/** The fixed answer, read at this edge. */
|
|
9
|
+
export declare const ApproverAnswer: z.ZodObject<{
|
|
10
|
+
decision: z.ZodEnum<{
|
|
11
|
+
approve: "approve";
|
|
12
|
+
decline: "decline";
|
|
13
|
+
}>;
|
|
14
|
+
reason: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type ApproverAnswer = z.infer<typeof ApproverAnswer>;
|
|
17
|
+
export interface ApproverInput {
|
|
18
|
+
change: string;
|
|
19
|
+
version: number;
|
|
20
|
+
/** The report's folder, `prototype/snapshots/<commit>`. */
|
|
21
|
+
report: string;
|
|
22
|
+
/** The diff the version brings, bounded. */
|
|
23
|
+
diff: string;
|
|
24
|
+
/** The critique the studio's own fresh turn wrote for this report, in this loop. */
|
|
25
|
+
critique: string;
|
|
26
|
+
}
|
|
27
|
+
/** Why no answer: no agent that can take the turn, a test or CI run, or the turn's own failure. */
|
|
28
|
+
export type ApproverWhy = 'agent' | 'ci' | 'launch' | 'failed' | 'timeout' | 'shape' | 'secret' | 'codex-sandbox';
|
|
29
|
+
export type ApproverResult = (ApproverAnswer & {
|
|
30
|
+
state: 'done';
|
|
31
|
+
agent: string;
|
|
32
|
+
model?: string;
|
|
33
|
+
session?: string;
|
|
34
|
+
}) | {
|
|
35
|
+
state: ApproverWhy;
|
|
36
|
+
agent?: string;
|
|
37
|
+
file?: string;
|
|
38
|
+
};
|
|
39
|
+
export type Approver = (input: ApproverInput) => Promise<ApproverResult>;
|
|
40
|
+
/** The critique turn's answer (the report text), or why there is none. */
|
|
41
|
+
export type CriticResult = {
|
|
42
|
+
state: 'done';
|
|
43
|
+
text: string;
|
|
44
|
+
} | {
|
|
45
|
+
state: ApproverWhy;
|
|
46
|
+
agent?: string;
|
|
47
|
+
file?: string;
|
|
48
|
+
};
|
|
49
|
+
/** Run the studio's fresh critique turn for one report folder. */
|
|
50
|
+
export type Critic = (report: string) => Promise<CriticResult>;
|
|
51
|
+
export interface ApproverDeps {
|
|
52
|
+
root: string;
|
|
53
|
+
start: Start;
|
|
54
|
+
settings: AgentsFile | undefined;
|
|
55
|
+
env: NodeJS.ProcessEnv;
|
|
56
|
+
stop?: typeof stopTree;
|
|
57
|
+
seconds?: number;
|
|
58
|
+
home?: string;
|
|
59
|
+
}
|
|
60
|
+
/** The critique's choice: the validation agent, else the default, else Claude Code. */
|
|
61
|
+
export declare const approverAgent: (settings: AgentsFile | undefined) => "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
|
|
62
|
+
export declare function approverPrompt(input: ApproverInput): string;
|
|
63
|
+
export declare function parseApproverAnswer(text: string | undefined): ApproverAnswer | undefined;
|
|
64
|
+
/** Run the approver turn once; never throws. */
|
|
65
|
+
export declare function runApprover(input: ApproverInput, deps: ApproverDeps): Promise<ApproverResult>;
|
|
66
|
+
/** Run the studio's critique as its own fresh turn, as after a full snapshot; never throws. */
|
|
67
|
+
export declare function runCritic(report: string, deps: ApproverDeps): Promise<CriticResult>;
|
|
68
|
+
/** The CLI's approver: plan/agents.md's validation agent and model, through the studio's launch. */
|
|
69
|
+
export declare function cliApprover(root: string, env?: NodeJS.ProcessEnv): Approver;
|
|
70
|
+
/** The CLI's critique turn, the same agent and launch as the studio's own critique. */
|
|
71
|
+
export declare function cliCritic(root: string, env?: NodeJS.ProcessEnv): Critic;
|