@buffcore/cli 0.8.42 → 0.8.44

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 (119) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/commands/design/references.d.ts +9 -0
  3. package/dist/commands/design/references.js +20 -1
  4. package/dist/commands/extension/places-approval.d.ts +1 -1
  5. package/dist/commands/prototype/comp-record.d.ts +27 -0
  6. package/dist/commands/prototype/comp-record.js +85 -0
  7. package/dist/commands/prototype/comp-words.d.ts +12 -0
  8. package/dist/commands/prototype/comp-words.js +24 -0
  9. package/dist/commands/prototype/comp.d.ts +26 -0
  10. package/dist/commands/prototype/comp.js +71 -0
  11. package/dist/commands/prototype/milestone-versions.d.ts +1 -1
  12. package/dist/commands/prototype/record-look-child.js +4 -1
  13. package/dist/commands/prototype/snapshot-command.js +1 -1
  14. package/dist/commands/prototype/snapshot-setup.d.ts +11 -0
  15. package/dist/commands/prototype/snapshot-setup.js +29 -5
  16. package/dist/commands/prototype/versions.d.ts +3 -3
  17. package/dist/commands/ui/agents-route.d.ts +2 -0
  18. package/dist/commands/ui/agents-route.js +8 -5
  19. package/dist/commands/ui/approval-authority.d.ts +1 -1
  20. package/dist/commands/ui/approve.js +7 -1
  21. package/dist/commands/ui/chat/approval-folders.d.ts +20 -0
  22. package/dist/commands/ui/chat/approval-folders.js +134 -0
  23. package/dist/commands/ui/chat/approval-text.d.ts +11 -0
  24. package/dist/commands/ui/chat/approval-text.js +69 -0
  25. package/dist/commands/ui/chat/approval-writes.d.ts +32 -0
  26. package/dist/commands/ui/chat/approval-writes.js +179 -0
  27. package/dist/commands/ui/chat/claude-permissions.d.ts +4 -4
  28. package/dist/commands/ui/chat/claude-permissions.js +32 -4
  29. package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
  30. package/dist/commands/ui/chat/commit-limits.d.ts +36 -0
  31. package/dist/commands/ui/chat/commit-limits.js +164 -0
  32. package/dist/commands/ui/chat/fresh-critique.d.ts +28 -0
  33. package/dist/commands/ui/chat/fresh-critique.js +123 -0
  34. package/dist/commands/ui/chat/fresh-launch.d.ts +36 -0
  35. package/dist/commands/ui/chat/fresh-launch.js +125 -0
  36. package/dist/commands/ui/chat/fresh-prompts.d.ts +17 -0
  37. package/dist/commands/ui/chat/fresh-prompts.js +76 -0
  38. package/dist/commands/ui/chat/fresh-report.d.ts +8 -0
  39. package/dist/commands/ui/chat/fresh-report.js +36 -0
  40. package/dist/commands/ui/chat/fresh-routes.d.ts +3 -0
  41. package/dist/commands/ui/chat/fresh-routes.js +64 -0
  42. package/dist/commands/ui/chat/fresh-settings.d.ts +12 -0
  43. package/dist/commands/ui/chat/fresh-settings.js +66 -0
  44. package/dist/commands/ui/chat/fresh-store.d.ts +17 -0
  45. package/dist/commands/ui/chat/fresh-store.js +67 -0
  46. package/dist/commands/ui/chat/fresh.d.ts +31 -0
  47. package/dist/commands/ui/chat/fresh.en.d.ts +7 -0
  48. package/dist/commands/ui/chat/fresh.en.js +7 -0
  49. package/dist/commands/ui/chat/fresh.es.d.ts +7 -0
  50. package/dist/commands/ui/chat/fresh.es.js +7 -0
  51. package/dist/commands/ui/chat/fresh.js +118 -0
  52. package/dist/commands/ui/chat/gh-api-limits.d.ts +14 -0
  53. package/dist/commands/ui/chat/gh-api-limits.js +74 -0
  54. package/dist/commands/ui/chat/git-words.d.ts +10 -0
  55. package/dist/commands/ui/chat/git-words.js +26 -0
  56. package/dist/commands/ui/chat/host-launched.d.ts +11 -0
  57. package/dist/commands/ui/chat/host-launched.js +35 -0
  58. package/dist/commands/ui/chat/limit-mentions.d.ts +2 -2
  59. package/dist/commands/ui/chat/limit-mentions.js +36 -2
  60. package/dist/commands/ui/chat/limit-text.d.ts +15 -0
  61. package/dist/commands/ui/chat/limit-text.js +36 -0
  62. package/dist/commands/ui/chat/limits-hook.js +2 -2
  63. package/dist/commands/ui/chat/limits.d.ts +11 -9
  64. package/dist/commands/ui/chat/limits.en.d.ts +4 -0
  65. package/dist/commands/ui/chat/limits.en.js +4 -0
  66. package/dist/commands/ui/chat/limits.es.js +4 -0
  67. package/dist/commands/ui/chat/limits.js +67 -51
  68. package/dist/commands/ui/chat/parse-claude.js +7 -3
  69. package/dist/commands/ui/chat/permission-ask.js +3 -0
  70. package/dist/commands/ui/chat/planning-limits.js +26 -0
  71. package/dist/commands/ui/chat/publish-limits.d.ts +4 -0
  72. package/dist/commands/ui/chat/publish-limits.js +113 -0
  73. package/dist/commands/ui/chat/recorded-turn.js +3 -0
  74. package/dist/commands/ui/chat/stream.js +4 -1
  75. package/dist/commands/ui/chat/turn-guard.d.ts +10 -2
  76. package/dist/commands/ui/chat/turn-guard.js +20 -3
  77. package/dist/commands/ui/chat/turn-state.d.ts +5 -0
  78. package/dist/commands/ui/chat/turn.js +1 -0
  79. package/dist/commands/ui/comp-approval.d.ts +6 -0
  80. package/dist/commands/ui/comp-approval.js +42 -0
  81. package/dist/commands/ui/host.js +3 -0
  82. package/dist/commands/ui/index.d.ts +42 -0
  83. package/dist/commands/ui/index.js +32 -8
  84. package/dist/commands/ui/loop-approve.d.ts +4 -4
  85. package/dist/commands/ui/places-change.d.ts +1 -1
  86. package/dist/commands/ui/plan-structure.d.ts +3 -0
  87. package/dist/commands/ui/plan-structure.en.d.ts +3 -0
  88. package/dist/commands/ui/plan-structure.en.js +3 -0
  89. package/dist/commands/ui/plan-structure.es.d.ts +3 -0
  90. package/dist/commands/ui/plan-structure.es.js +3 -0
  91. package/dist/commands/ui/plan-structure.js +12 -4
  92. package/dist/commands/ui/prototype-comp-route.d.ts +7 -0
  93. package/dist/commands/ui/prototype-comp-route.js +109 -0
  94. package/dist/commands/ui/prototype-main.d.ts +2 -1
  95. package/dist/commands/ui/prototype-scenes-child.js +4 -1
  96. package/dist/commands/ui/prototype-snapshot-session.d.ts +1 -1
  97. package/dist/commands/ui/prototype-snapshot-session.js +3 -0
  98. package/dist/commands/ui/prototype-snapshot.d.ts +1 -1
  99. package/dist/commands/ui/routes.d.ts +8 -3
  100. package/dist/commands/ui/routes.js +3 -3
  101. package/dist/commands/ui/save-publish.js +3 -0
  102. package/dist/commands/ui/server-options.js +1 -0
  103. package/dist/commands/ui/server-request.js +5 -0
  104. package/dist/commands/ui/server.d.ts +14 -0
  105. package/dist/commands/ui/server.js +10 -3
  106. package/dist/commands/ui/structure-surface.d.ts +6 -0
  107. package/dist/commands/ui/structure-surface.js +94 -0
  108. package/dist/commands/ui/studio-routes.d.ts +1 -0
  109. package/dist/commands/ui/studio-routes.js +7 -1
  110. package/dist/commands/ui/studio-state.d.ts +7 -4
  111. package/dist/commands/ui/studio-versions.d.ts +3 -3
  112. package/dist/ui/page.js +98 -89
  113. package/docs/PROCESS.md +5 -0
  114. package/docs/PROTOTYPE.md +31 -0
  115. package/docs/WORKBENCH.md +11 -2
  116. package/package.json +11 -11
  117. package/skills/ape-critique/SKILL.md +9 -3
  118. package/skills/ape-design-system/SKILL.md +2 -1
  119. package/skills/ape-prototype/SKILL.md +5 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ One section per release (a git tag). **Upgrade notes** list anything that breaks
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## v0.8.44 (2026-12-02)
8
+
9
+ - A host whose own trusted launcher starts the agent's turns can say so: `createUiServer({ hostLaunched: true })`, or `APE_HOST_LAUNCHED=1` in the environment of `ape ui` (exactly `1`). Every Claude Code turn (coding, Build, design, validation, tests, fixes, planning on Autopilot) then launches exactly as a 0.8.41 turn did: no per-turn `--settings` file with the limits hook, no `--mcp-config` with the permission tool, no `--permission-prompt-tool` and no per-turn socket; `acceptEdits`, or `dontAsk` with hooks off for planning, at every level (never `auto` or `bypassPermissions`, Autopilot and Never ask included), with 0.8.41's allow and deny lists. Fresh turns (the review before Save and the critique) follow it: hooks off through the inline `--settings` JSON, no settings file and no `--setting-sources=`. Settings says once that the host starts the agents and applies their limits (English and Spanish), and the studio state gains an optional `hostLaunched`. Off by default: nothing changes for a host that passes nothing.
10
+
11
+ **Upgrade notes** (hosts that build their own studio server): with `hostLaunched` on, the studio's limits hook, its permission card and its later deny rules are not in the turns, so your launcher must enforce everything the hook does, through every wrapper and shell it reads: the limit commands (`git push`; downloads with `curl`, `wget`, `iwr`, `irm`, `Invoke-WebRequest`, `Invoke-RestMethod` and `Start-BitsTransfer`, which the hook holds for the person; `ape deploy` and `ape server deploy` however started; `npm publish` with npm's short forms `npm pu`, `npm pub`, `npm publ`, `npm publi` and `npm publis`, `pnpm publish`, `yarn publish` and `yarn npm publish`; `gh release create`, `new`, `upload`, `edit` and `delete`), reads and writes of production settings files (`.env.production`, `.env.prod*`, `.env.staging*`) and of the secret folders (`.ssh`, `.gnupg`, `.aws`, `.azure`, `.kube`, `.docker`, `.gcloud`, `.password-store`, `secrets`), WebFetch, and the calls it refuses when unsure: a command it cannot read or that is too long or too deeply nested, a here-document whose end line never comes, a shell or interpreter given its script on standard input, `Invoke-Expression` (`iex`), and a file pattern or mention that could reach a limit. The source of truth, which later releases add to, is the limits files in `packages/cli/src/commands/ui/chat/`: `limits.ts`, `planning-limits.ts`, `publish-limits.ts`, `limit-patterns.ts`, `limit-mentions.ts`, `stdin-shells.ts` and `secret-folders.ts`. Your launcher also checks the turn's arguments and decides which settings files a turn loads (the person's and the product's allow rules widen what a fresh turn's `dontAsk` runs unless it keeps them out). The mode belongs to the product folder of the `runner` you pass (`runner.cwd`), one mode per folder (the last server created for it decides), and ends when the server closes; build `ChatEngine` and `FreshLooks` on that same folder. `APE_HOST_LAUNCHED` counts only from the environment `ape ui` starts with, never from the product's `.env`.
12
+ - The studio's chat box empties the moment Send (or Enter) is pressed; the words show in the chat as sending, and a refused or interrupted send puts them back in the box, with the reason under it, never losing them: anything typed meanwhile follows them after a blank line.
13
+ - Play on the Journeys page opens the Prototype with that journey selected at its first step, once the app lists it (by its key, or else by its planned name).
14
+ - The Prototype preview's step bar (Back, the step and its caption, Next) sits under the device frame at every device and width, no longer over the app.
15
+ - Stepping through a journey, choosing one and choosing sample data no longer reload the app: the studio tells the running prototype home what to show by an `ape:prototype:show` message on the private port its hello opened, and the home answers the new step's caption on that port. A home that reloads itself gets the current choice again; one that does not say it plays (`ape:prototype:player`) is reloaded at each step, as before. The app reloads only when its address, the language or the mode changes. The message carries only a journey key and step, or a data state, and the studio still takes nothing from the app but its journey list, liveness and that caption.
16
+
17
+ **Upgrade notes** (every product): keep `@buffcore/app-shell` and `@buffcore/admin-shell` on the same release (`ape upgrade` does); an older prototype home still plays, reloading at each step.
18
+ - The studio's scroll bars are thin and drawn in the theme's colors, light and dark, in every panel inside the studio frame.
19
+ - An agent cannot make its own approval from the shell, "Never ask" included. A shell command that could write into the approval records, `prototype/versions/`, is refused at every level: a redirect into the folder (`>`, `>>`, `&>`, `2>`, `>|`), or any program that names a path in it other than a read (`cp`, `mv`, `tee`, `sed -i`, `node -e`, `python -c`, `git checkout … --`, `Set-Content`, `Out-File` and the rest), read against the shell's folder with `..`, case and patterns counted; on design and validation turns at any level, and planning and loop turns on Autopilot, so is a program that writes the paths it names aimed at a folder that holds the records, `prototype` taking only a single file copied in (`cp design/logo.svg prototype/`), and a patch or archive (`git apply`, `git am`, `patch`, `Expand-Archive`), with `$PWD`, `~+`, `$OLDPWD` and `(Get-Location)` read as folders (coding, tests and fixes turns keep writing their own tree; `rm -rf prototype`, `cp -r x/. prototype/`, `cp x .`, `git checkout <ref> -- .`, `find prototype … -delete` or `-exec`, `tar -x` or `unzip` into the shell's folder, `Copy-Item -Recurse … prototype`, `ls prototype | xargs rm`, `gci -r prototype | Set-Content`). A command whose text names both folders and looks like a write is refused when any part of it is more than a read, and goes to the card when every part only reads. A design or validation turn on Autopilot, and a planning or loop turn on Autopilot, (or one whose level the hook was not told) makes no commit and moves no branch: `git commit`, `commit-tree`, `update-ref`, `merge`, `cherry-pick`, `revert`, `rebase`, `am`, `pull`, `hash-object`, `fast-import`, `stash` (but `list` and `show`), `reset` to a commit, `branch -f`/`-M`/`-C`, `checkout -B`, `switch -C`, `fetch` into a branch, `git subtree add|merge|pull` and `split --rejoin`, and git with a configuration set anywhere in the command (`-c alias.…`, `-c include.path=…`, `export HOME=…`, `$env:GIT_CONFIG_GLOBAL=…`) beside a subcommand that commits or is not git's own are refused there (`export HOME=x; git log` runs), a git subcommand that is not git's own (an alias such as `git ci`) goes to the card, and a shape the parse cannot follow (`$g commit`) goes to the card; coding turns still commit in their own change tree. Reads still run, their output redirected anywhere else too (`cat`, `ls`, `grep`, `head`, `tail`, `wc`, `sed -n`, `awk`, `sort`, `find`, `git log --grep merge`, `git show`, `git diff`, `Get-Content`). The limit card names each: **Writing an approval record**, **Committing from a design step on Autopilot**; the chat contract's limit gains `approval` and `commit`. The limits hook now takes the turn's level after its work (`limits-hook.ts <work> <level>`). On those turns a write the parse cannot place goes to the card: a write after a `cd` in the same command, a write to a `$variable` path, `bsdtar -x` and `7z x … -o…`; `sed` counts as a pipe writer only with `-i`, and `%`/`ForEach-Object` only when its block holds a writer. Not caught (known limits): a write that reaches the folder through a `cd` earlier in the same command and is otherwise only reads (it goes to the card); a variable, an alias, a function or a symbolic link set in an earlier call (`d=prototype/versions` then `cp x $d`, `ln -s prototype/versions v` then `cp x v/`); a path built from strings (`printf`, string joins in `node -e` or `python -c`); a script file written earlier and run later; a commit through an alias already in the product's own git configuration (it goes to the card), or through a tool other than git (a library from `node -e`); and OpenCode and planning turns below Autopilot, which use prefix rules and have none for these writes.
20
+ - More publishing commands are limits at every level, "Never ask" included: `bun publish`, `lerna publish` and `changeset publish` (also as `npx @changesets/cli publish`) are refused as publishing a package, and `gh api` calls that create or change a release (a method other than GET or HEAD on `repos/{owner}/{repo}/releases`, or fields or a body with no method named, an asset upload included) as publishing a release, through every wrapper the limits read. `gh api` reads of releases (`gh api repos/o/r/releases`, `-X GET … -f per_page=5`), `changeset version`, `lerna run` and `bun install` still run.
21
+
22
+ ## v0.8.43 (2026-12-02)
23
+
24
+ - Publishing is a limit at every level, "Never ask" included: `npm publish` (and the short names npm accepts, `npm pu` to `npm publis`), `pnpm publish`, `yarn publish`, `yarn npm publish` and `gh release create|new|upload|edit|delete` are refused through every wrapper the limits read; `npm view`, `gh release list` and other reads still run, and a command that only asks for `--help` runs. A command a limit refused now shows a card in the step's chat, **This can't be allowed here**, naming the limit and the command, with **Copy the command** and no Allow (Claude Code turns; the card is marked from the hook's own refusal). The chat contract's refused event gains an optional `limit`. Not caught: `bun publish`, `lerna publish`, `changeset publish` and `gh api` release calls.
25
+ - A fresh look before Save on Brief, Plan, Journeys and Structure: when the step's agent finishes a turn that changed the step's files, the studio starts a second, read-only turn (Claude Code, a new session, the step's model) that reads the step, the earlier steps and AGENTS.md and lists at most seven findings beside Save, each with **Take** (sent to the step's chat) or **Leave**. Save never waits for it; on Autopilot the step saves as before and the findings stay beside it. Findings are kept in `.ape/fresh/`, never in git; Settings › Agents turns it off (`review: false` in `plan/agents.md`).
26
+ - The critique runs as its own turn: after a full snapshot passes on the Prototype page, the studio starts a fresh, read-only turn with the `ape-critique` skill (the validation agent, Claude Code) and writes its answer to `design/critique.md`; the page shows it running, then names the file. A passing full snapshot the Prototype step's agent took itself starts it too, when that turn ends. One runs at a time, and never twice for the same snapshot. Fresh turns run with Claude Code only; with Codex or OpenCode there is none.
27
+
28
+ **Upgrade notes** (hosts that build their own studio server): the fresh turns are wired in `ape ui` only. To offer them, create a `FreshLooks` with your agent start, pass it to `ChatEngine` as `fresh`, add `freshRoutes(fresh, root)` to the routes and `onFullSnapshot: (source, report) => fresh.afterSnapshot(source, report)` to `createUiServer`. Without them the studio shows no findings and no critique.
29
+ - The look is agreed on three screens first. Structure asks **Which surface comes first?** (Desktop or Phone) and keeps the answer as a `Surface:` line in `plan/structure.md`'s header (absent, desktop). The agent draws the comp, scenes keyed `comp/<name>`, and `ape prototype snapshot --scene 'comp/*'` shoots them at that surface's width into `prototype/snapshots/comp/<commit>/`, apart from the scenes: they never count toward totals, completeness, reuse or versions. The Prototype page shows **The look, on three screens** beside the pictures `design/references.md` lists (a placeholder when there are none), with **Approve the look**: a person's at every level, recorded in `prototype/versions/comp.json`, refused for an agent. The approval kinds gain `comp` (person only); the workbench contracts gain the comp read, its pictures and the surface answer ([PROTOTYPE.md](docs/PROTOTYPE.md#the-comp)). The `ape-prototype`, `ape-critique` and `ape-design-system` skills draw and judge against the approved comp. The approval is saved as its own commit (`prototype: approve the look`) in `prototype/versions/comp.json`, where agents' file tools, coding commands and merged branches cannot write, and a record made any other way does not count. Reference pictures are served with their own type (PNG, JPEG, WebP, GIF or AVIF); a host serves only those inside the product's folder, the local `ape ui` any listed path. Structure's `Surface:` line is read in any case, trimmed, and a wrong one is refused naming its line. The studio's scene list and default app screen leave `comp/` scenes out.
30
+
31
+ **Upgrade notes** (every product): a host whose authority approves the comp (`createUiServer({ approval })`) gets the comp approval sent to it as for other kinds (`kind: 'comp'`), but the studio shows the look as approved only from the product's `prototype/versions/comp.json`: write the approved record there, or the page keeps asking.
32
+
7
33
  ## v0.8.42 (2026-12-02)
8
34
 
9
35
  - A host fills more of the studio (`createUiServer({ signIn, hostParts })`): modules at `side:prototype` (beside the prototype; a tab named with the host's label on a phone), `approve:release` and `card:server`, each mounted as `mount(element, viewer, subject)` with plain JSON (`HostSubjects`: the change and version, the release, and the server; the release's `approval` is absent until release approval records exist); `rail: [{ id, label, source, icon? }]` entries at the rail's end, drawn as rail rows, each opening its module on the `page` place; and `label`, the host's name over its rail entries and on its badges. A changed subject remounts only that place. The same trust rules apply: root-relative same-origin URLs, only with `signIn`. React `parts` at those three places get the same subject as a third argument of `draw` ([WORKBENCH.md](docs/WORKBENCH.md#modules-through-the-built-in-page)).
@@ -1,3 +1,12 @@
1
1
  import type { Tell } from './tells.ts';
2
2
  /** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
3
3
  export declare function missingReferences(root: string): Promise<Tell[]>;
4
+ /** One picture `design/references.md` lists, in its place: where it is, if on this computer. */
5
+ export interface ReferencePicture {
6
+ /** The file, when the line names one on this computer that exists; a web address has none. */
7
+ file?: string;
8
+ /** Whether the file is inside the product's folder (a host serves only those). */
9
+ inside: boolean;
10
+ }
11
+ /** Every picture `design/references.md` lists, in its order, so screen n meets the nth. */
12
+ export declare function referencePictures(root: string): Promise<ReferencePicture[]>;
@@ -3,7 +3,7 @@
3
3
  import { existsSync } from 'node:fs';
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { homedir } from 'node:os';
6
- import { join, resolve } from 'node:path';
6
+ import { isAbsolute, join, relative, resolve, sep } from 'node:path';
7
7
  const PICTURE = /`([^`\r\n]+?\.(?:png|jpe?g|webp|gif|avif))`|\]\(([^)\s]+?\.(?:png|jpe?g|webp|gif|avif))\)/gi;
8
8
  /** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
9
9
  export async function missingReferences(root) {
@@ -23,3 +23,22 @@ export async function missingReferences(root) {
23
23
  }
24
24
  return tells;
25
25
  }
26
+ /** Every picture `design/references.md` lists, in its order, so screen n meets the nth. */
27
+ export async function referencePictures(root) {
28
+ const file = join(root, 'design', 'references.md');
29
+ if (!existsSync(file))
30
+ return [];
31
+ const found = [];
32
+ for (const [, quoted, linked] of (await readFile(file, 'utf8')).matchAll(PICTURE)) {
33
+ const path = quoted ?? linked ?? '';
34
+ if (/^(?:https?:\/\/|\\\\|\/\/)/i.test(path)) {
35
+ found.push({ inside: false });
36
+ continue;
37
+ }
38
+ const full = /^~[/]/.test(path) ? join(homedir(), path.slice(2)) : resolve(root, path);
39
+ const from = relative(root, full);
40
+ const inside = !!from && !isAbsolute(from) && from !== '..' && !from.startsWith(`..${sep}`);
41
+ found.push(existsSync(full) ? { file: full, inside } : { inside });
42
+ }
43
+ return found;
44
+ }
@@ -14,7 +14,7 @@ export declare const placesGit: (root: string, args: string[]) => string;
14
14
  export declare function localSigner(root: string): string;
15
15
  export declare const parsePlaces: (text?: string) => {
16
16
  approvals: {
17
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
17
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
18
18
  signatures: {
19
19
  by: string;
20
20
  at: string;
@@ -0,0 +1,27 @@
1
+ import { type Approval } from '@buffcore/contracts/approvals';
2
+ import { type CompSnapshot } from './comp.ts';
3
+ export declare const COMP_FILE = "prototype/versions/comp.json";
4
+ /** The subject of the one commit that may write the record (`stepMessage`). */
5
+ export declare const COMP_SUBJECT = "prototype: approve the look";
6
+ export interface CompRecord {
7
+ folder: string;
8
+ approval: Approval;
9
+ }
10
+ /** The record as the approval commit left it: committed at HEAD by that commit, unchanged on disk. */
11
+ export declare function readCompApproval(root: string): CompRecord | undefined;
12
+ /** Whether a person's approval holds for this comp: its folder and the pictures it showed. */
13
+ export declare function compApproved(record: CompRecord | undefined, comp: CompSnapshot | undefined): boolean;
14
+ export interface CompSigner {
15
+ by: string;
16
+ /** The commit checked out when the person approved. */
17
+ commit: string;
18
+ fingerprint: string;
19
+ role?: string;
20
+ /** Set when an agent asks: always refused, at every level. */
21
+ agent?: string;
22
+ }
23
+ /**
24
+ * A person approves the comp the page showed; an agent never does. Writes the record when `write`
25
+ * (the studio's approval save commits it on its own); returns what the file holds.
26
+ */
27
+ export declare function approveComp(root: string, signer: CompSigner, write?: boolean): CompRecord;
@@ -0,0 +1,85 @@
1
+ // The comp's approval record, `prototype/versions/comp.json`: inside the folder the file tools,
2
+ // the coding commands and the merge guard keep from agents, as version approvals are, and saved
3
+ // only as the studio's own isolated commit (`saveApprovalRecord`, subject COMP_SUBJECT). A record
4
+ // put there any other way, or edited after that commit, does not count.
5
+ import { randomUUID } from 'node:crypto';
6
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { approvalHolds, approvalSchema } from '@buffcore/contracts/approvals';
9
+ import { ApprovalRefusal, approvalRule, signApproval } from '../approval-rules.js';
10
+ import { hostGitBytes } from '../safe-git.js';
11
+ import { newestComp } from './comp.js';
12
+ import { compT } from './comp-words.js';
13
+ export const COMP_FILE = 'prototype/versions/comp.json';
14
+ /** The subject of the one commit that may write the record (`stepMessage`). */
15
+ export const COMP_SUBJECT = 'prototype: approve the look';
16
+ const lf = (text) => text.replace(/\r\n/g, '\n');
17
+ /** The record as the approval commit left it: committed at HEAD by that commit, unchanged on disk. */
18
+ export function readCompApproval(root) {
19
+ try {
20
+ const git = (args) => hostGitBytes(root, args).toString('utf8');
21
+ const committed = git(['show', `HEAD:./${COMP_FILE}`]);
22
+ const subject = git(['log', '-1', '--format=%s', 'HEAD', '--', `./${COMP_FILE}`]).trim();
23
+ if (subject !== COMP_SUBJECT)
24
+ return;
25
+ if (lf(readFileSync(join(root, COMP_FILE), 'utf8')) !== lf(committed))
26
+ return;
27
+ const record = JSON.parse(committed);
28
+ const approval = approvalSchema.parse(record?.approval);
29
+ if (typeof record.folder !== 'string' || approval.kind !== 'comp')
30
+ return;
31
+ return { folder: record.folder, approval };
32
+ }
33
+ catch {
34
+ return;
35
+ }
36
+ }
37
+ /** Whether a person's approval holds for this comp: its folder and the pictures it showed. */
38
+ export function compApproved(record, comp) {
39
+ return (!!record &&
40
+ !!comp &&
41
+ record.folder === comp.folder &&
42
+ approvalHolds(record.approval, new Date()) &&
43
+ record.approval.signatures.every((s) => s.fingerprint === comp.fingerprint));
44
+ }
45
+ /**
46
+ * A person approves the comp the page showed; an agent never does. Writes the record when `write`
47
+ * (the studio's approval save commits it on its own); returns what the file holds.
48
+ */
49
+ export function approveComp(root, signer, write = true) {
50
+ if (signer.agent !== undefined)
51
+ throw new ApprovalRefusal(compT('comp.person'));
52
+ const comp = newestComp(root);
53
+ if (!comp)
54
+ throw new ApprovalRefusal(compT('comp.missing'));
55
+ if (!comp.report.scenes.length)
56
+ throw new ApprovalRefusal(compT('comp.empty'));
57
+ if (comp.fingerprint !== signer.fingerprint)
58
+ throw new ApprovalRefusal(compT('comp.changed'));
59
+ const earlier = readCompApproval(root);
60
+ if (compApproved(earlier, comp))
61
+ throw new ApprovalRefusal(compT('comp.approved'));
62
+ // A partial rule's signatures carry on for the same comp; a new comp starts a new approval.
63
+ const previous = earlier?.folder === comp.folder &&
64
+ earlier.approval.signatures.every((s) => s.fingerprint === comp.fingerprint)
65
+ ? earlier.approval
66
+ : undefined;
67
+ const approval = signApproval(previous, 'comp', {
68
+ by: signer.by.trim(),
69
+ at: new Date().toISOString(),
70
+ commit: signer.commit,
71
+ fingerprint: comp.fingerprint,
72
+ ...(signer.role ? { role: signer.role } : {}),
73
+ }, approvalRule(root, 'comp'));
74
+ const record = { folder: comp.folder, approval };
75
+ if (write)
76
+ writeRecord(root, record);
77
+ return record;
78
+ }
79
+ function writeRecord(root, record) {
80
+ const file = join(root, COMP_FILE);
81
+ mkdirSync(join(root, 'prototype', 'versions'), { recursive: true });
82
+ const temporary = `${file}.${randomUUID()}.tmp`;
83
+ writeFileSync(temporary, `${JSON.stringify(record, null, 2)}\n`);
84
+ renameSync(temporary, file);
85
+ }
@@ -0,0 +1,12 @@
1
+ declare const en: {
2
+ 'comp.person': string;
3
+ 'comp.missing': string;
4
+ 'comp.changed': string;
5
+ 'comp.empty': string;
6
+ 'comp.approved': string;
7
+ 'comp.identity': string;
8
+ 'comp.commitFirst': string;
9
+ 'comp.mixed': string;
10
+ };
11
+ export declare const compT: (key: keyof typeof en) => string;
12
+ export {};
@@ -0,0 +1,24 @@
1
+ import { createI18n } from '@buffcore/i18n';
2
+ import { locale } from './messages.js';
3
+ const en = {
4
+ 'comp.person': 'A person approves the look, at every level. An agent cannot.',
5
+ 'comp.missing': 'There is no comp to approve yet: ask the agent to draw the three screens and snapshot them.',
6
+ 'comp.changed': 'The comp changed since this page showed it. Look at the new screens, then approve.',
7
+ 'comp.empty': 'The comp snapshot lists no screens: snapshot the comp again.',
8
+ 'comp.approved': 'This look is already approved.',
9
+ 'comp.identity': 'Set your name in Git (git config user.email) so the approval can name you.',
10
+ 'comp.commitFirst': 'Commit first, so the approval can name a commit.',
11
+ 'comp.mixed': "Snapshot the comp on its own (--scene 'comp/*'): its screens are kept apart from the scenes.",
12
+ };
13
+ const es = {
14
+ 'comp.person': 'Una persona aprueba el aspecto, en todos los niveles. Un agente no puede.',
15
+ 'comp.missing': 'Aún no hay un boceto que aprobar: pide al agente que dibuje las tres pantallas y las capture.',
16
+ 'comp.changed': 'El boceto cambió desde que esta página lo mostró. Mira las pantallas nuevas y luego aprueba.',
17
+ 'comp.empty': 'La captura del boceto no tiene pantallas: vuelve a capturar el boceto.',
18
+ 'comp.approved': 'Este aspecto ya está aprobado.',
19
+ 'comp.identity': 'Pon tu nombre en Git (git config user.email) para que la aprobación te nombre.',
20
+ 'comp.commitFirst': 'Haz un commit primero, para que la aprobación nombre uno.',
21
+ 'comp.mixed': "Captura el boceto por separado (--scene 'comp/*'): sus pantallas se guardan aparte de las escenas.",
22
+ };
23
+ const translator = createI18n({ catalogs: [{ en, es }] });
24
+ export const compT = (key) => translator.t(locale(), key);
@@ -0,0 +1,26 @@
1
+ import type { Frame } from '@buffcore/config';
2
+ import type { FirstSurface } from '@buffcore/contracts/workbench';
3
+ import { type SnapshotReport } from './report.ts';
4
+ export declare const COMP_PREFIX = "comp/";
5
+ /**
6
+ * `plan/structure.md`'s one header field, before its table; absent, desktop comes first. Any case,
7
+ * spaces around the value allowed. `SURFACE_FIELD` finds a line meant as one, right or wrong.
8
+ */
9
+ export declare const SURFACE_LINE: RegExp;
10
+ export declare const SURFACE_FIELD: RegExp;
11
+ export declare const isCompScene: (key: string) => boolean;
12
+ /** Where a snapshot folder's comp runs go: beside the commits, never inside one. */
13
+ export declare const compDir: (snapshots: string) => string;
14
+ /** The frame the comp is judged in: the product's desktop frame, or the phone's 390. */
15
+ export declare const compFrame: (surface: FirstSurface) => Frame;
16
+ /** Which surface comes first, as `plan/structure.md` says (the parser's rule); absent, desktop. */
17
+ export declare function firstSurface(root: string): FirstSurface;
18
+ export interface CompSnapshot {
19
+ /** `prototype/snapshots/comp/<commit>`, from the product's root. */
20
+ folder: string;
21
+ report: SnapshotReport;
22
+ /** What Approve the look signs: the comp report's bytes (they hold each picture's hash). */
23
+ fingerprint: string;
24
+ }
25
+ /** The newest finished comp snapshot, by its report's date. */
26
+ export declare function newestComp(root: string): CompSnapshot | undefined;
@@ -0,0 +1,71 @@
1
+ // The comp (docs/PROTOTYPE.md): the three deciding screens, scenes under `comp/`, shot at the first
2
+ // surface's width into their own folder (`prototype/snapshots/comp/<commit>/`), never into the
3
+ // scenes' report. A person approves the look; `comp-record.ts` keeps that approval.
4
+ import { readdirSync, readFileSync } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ import { snapshotsDir } from './report.js';
7
+ import { sha256 } from './snapshot-hashes.js';
8
+ export const COMP_PREFIX = 'comp/';
9
+ /**
10
+ * `plan/structure.md`'s one header field, before its table; absent, desktop comes first. Any case,
11
+ * spaces around the value allowed. `SURFACE_FIELD` finds a line meant as one, right or wrong.
12
+ */
13
+ export const SURFACE_LINE = /^surface:[ \t]*(desktop|phone)[ \t]*$/i;
14
+ export const SURFACE_FIELD = /^surface[ \t]*:/i;
15
+ export const isCompScene = (key) => key.startsWith(COMP_PREFIX);
16
+ /** Where a snapshot folder's comp runs go: beside the commits, never inside one. */
17
+ export const compDir = (snapshots) => join(snapshots, 'comp');
18
+ /** The frame the comp is judged in: the product's desktop frame, or the phone's 390. */
19
+ export const compFrame = (surface) => surface === 'phone' ? 'phone' : 'desktop';
20
+ /** Which surface comes first, as `plan/structure.md` says (the parser's rule); absent, desktop. */
21
+ export function firstSurface(root) {
22
+ let text = '';
23
+ try {
24
+ text = readFileSync(join(root, 'plan', 'structure.md'), 'utf8');
25
+ }
26
+ catch {
27
+ return 'desktop';
28
+ }
29
+ for (const line of text.replace(/^\uFEFF/, '').split(/\r\n|\r|\n/)) {
30
+ if (line.startsWith('|'))
31
+ break;
32
+ const found = SURFACE_LINE.exec(line);
33
+ if (found)
34
+ return found[1]?.toLowerCase();
35
+ }
36
+ return 'desktop';
37
+ }
38
+ /** The newest finished comp snapshot, by its report's date. */
39
+ export function newestComp(root) {
40
+ const dir = compDir(snapshotsDir(root));
41
+ let best;
42
+ let entries = [];
43
+ try {
44
+ entries = readdirSync(dir).filter((name) => /^[0-9a-f]{7,64}$/.test(name));
45
+ }
46
+ catch {
47
+ return;
48
+ }
49
+ for (const name of entries) {
50
+ let bytes;
51
+ let report;
52
+ try {
53
+ bytes = readFileSync(join(dir, name, 'report.json'));
54
+ report = JSON.parse(String(bytes));
55
+ }
56
+ catch {
57
+ continue;
58
+ }
59
+ const at = Date.parse(report?.createdAt ?? '');
60
+ if (!Array.isArray(report?.scenes) || report.commit !== name || !Number.isFinite(at))
61
+ continue;
62
+ if (best && best.at >= at)
63
+ continue;
64
+ const folder = `prototype/snapshots/comp/${name}`;
65
+ best = { folder, report, fingerprint: `comp:${sha256(bytes)}`, at };
66
+ }
67
+ if (!best)
68
+ return;
69
+ const { at: _at, ...comp } = best;
70
+ return comp;
71
+ }
@@ -22,7 +22,7 @@ export declare function readMilestoneVersions(root: string, milestone: string, r
22
22
  at: string;
23
23
  covers: string[];
24
24
  approval?: {
25
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
25
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
26
26
  signatures: {
27
27
  by: string;
28
28
  at: string;
@@ -45,7 +45,10 @@ async function sceneKeys(dir) {
45
45
  if (!existsSync(file))
46
46
  return undefined;
47
47
  const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
48
- return module.default.scenes.map((scene) => scene.key);
48
+ // The comp's scenes (`comp/`) are snapshotted apart and never belong to a version's report.
49
+ return module.default.scenes
50
+ .map((scene) => scene.key)
51
+ .filter((key) => !key.startsWith('comp/'));
49
52
  }
50
53
  try {
51
54
  const design = (await designState(root, theme))?.hash ?? '';
@@ -104,7 +104,7 @@ async function drawn(flags, hints, servers) {
104
104
  : `${run.scenes.scenes.length} scenes`;
105
105
  console.log(`Snapshot of ${count}:`);
106
106
  const report = await taken(run, commit);
107
- if (own && report.scene === undefined && !report.problems.length)
107
+ if (own && !run.comp && report.scene === undefined && !report.problems.length)
108
108
  await shareShots(root, join(dir, commit), report);
109
109
  const selected = new Set(picked.map((scene) => scene.key));
110
110
  const fresh = report.scenes.filter((scene) => selected.has(scene.key));
@@ -19,6 +19,8 @@ export interface SetupFlags {
19
19
  }
20
20
  export interface Setup {
21
21
  root: string;
22
+ /** A run of the comp's scenes alone, into the comp's own folder (`comp.ts`). */
23
+ comp: boolean;
22
24
  own: SnapshotEnvironment | undefined;
23
25
  servers: Servers;
24
26
  scene: SceneSelection | undefined;
@@ -39,3 +41,12 @@ export type Servers = {
39
41
  };
40
42
  /** Everything a run needs before it draws: the environment, the locks, the pin, the servers. */
41
43
  export declare function setup(flags: SetupFlags, servers: Servers): Promise<Setup>;
44
+ /**
45
+ * The scenes a run draws: the comp's alone (every picked scene under `comp/`, shot in the first
46
+ * surface's frame), or the others with the comp left out, so it never counts toward their totals,
47
+ * completeness or fingerprints. A selection that mixes the two is refused.
48
+ */
49
+ export declare function runScenes(root: string, scenes: Scenes, scene: SceneSelection | undefined): {
50
+ comp: boolean;
51
+ scenes: Scenes;
52
+ };
@@ -13,6 +13,8 @@ import { pathToFileURL } from 'node:url';
13
13
  import { coreEnvSchema, defineEnv, frameSizes, isContainer, } from '@buffcore/config';
14
14
  import { developmentOnly, findRoot, loadEnv, loadProduct } from '../../project.js';
15
15
  import { loadTheme } from '../design/sources.js';
16
+ import { compDir, compFrame, firstSurface, isCompScene } from './comp.js';
17
+ import { compT } from './comp-words.js';
16
18
  import { ownSceneKeys } from './own-scenes.js';
17
19
  import { sceneTimeoutSeconds } from './scene-render.js';
18
20
  import { sceneSelection } from './scene-selection.js';
@@ -69,8 +71,9 @@ export async function setup(flags, servers) {
69
71
  await pruneShots(root);
70
72
  }
71
73
  const checkout = flags.remake ? undefined : pinSnapshotCheckout(root);
72
- const progress = scene === undefined ? checkout?.progress() : undefined;
73
- const [product, scenes] = await Promise.all([loadProduct(root), loadScenes(root)]);
74
+ const [product, all] = await Promise.all([loadProduct(root), loadScenes(root)]);
75
+ const { comp, scenes } = runScenes(root, all, scene);
76
+ const progress = scene === undefined && !comp ? checkout?.progress() : undefined;
74
77
  // A linked worktree's addresses are the run's own: they are filled in when its servers start.
75
78
  const urls = own
76
79
  ? {}
@@ -82,7 +85,7 @@ export async function setup(flags, servers) {
82
85
  urls[process.name] = `http://127.0.0.1:${process.port}`;
83
86
  }
84
87
  // An unknown scene is refused before anything runs; only the surfaces snapshotted must answer.
85
- const picked = pickScenes(scenes, scene);
88
+ const picked = pickScenes(scenes, comp ? undefined : scene);
86
89
  if (servers.own) {
87
90
  if (scene !== undefined)
88
91
  await servers.own.prepare(picked);
@@ -92,10 +95,11 @@ export async function setup(flags, servers) {
92
95
  if (process.env.APE_SNAPSHOT_VALIDATION_COMMIT !== undefined)
93
96
  checkout?.check();
94
97
  const ownScenes = flags.ownFirst ? await ownSceneKeys(root, picked) : undefined;
95
- const dir = validationDirectory(root);
98
+ const dir = comp ? compDir(validationDirectory(root)) : validationDirectory(root);
96
99
  const started = performance.now();
97
100
  return {
98
101
  root,
102
+ comp,
99
103
  own,
100
104
  servers,
101
105
  scene,
@@ -111,7 +115,8 @@ export async function setup(flags, servers) {
111
115
  frames: frameSizes(product),
112
116
  urls,
113
117
  dir,
114
- scene,
118
+ // The comp's run is whole: its own report, never a part of the scenes'.
119
+ scene: comp ? undefined : scene,
115
120
  sceneTimeout,
116
121
  root,
117
122
  pages: flags.pages,
@@ -120,3 +125,22 @@ export async function setup(flags, servers) {
120
125
  seconds: () => Math.round((performance.now() - started) / 1000),
121
126
  };
122
127
  }
128
+ /**
129
+ * The scenes a run draws: the comp's alone (every picked scene under `comp/`, shot in the first
130
+ * surface's frame), or the others with the comp left out, so it never counts toward their totals,
131
+ * completeness or fingerprints. A selection that mixes the two is refused.
132
+ */
133
+ export function runScenes(root, scenes, scene) {
134
+ const picked = scene === undefined ? [] : pickScenes(scenes, scene);
135
+ const comp = picked.filter((s) => isCompScene(s.key));
136
+ if (comp.length && comp.length !== picked.length)
137
+ throw new Error(compT('comp.mixed'));
138
+ if (comp.length) {
139
+ const frame = compFrame(firstSurface(root));
140
+ return { comp: true, scenes: { ...scenes, scenes: comp.map((s) => ({ ...s, frame })) } };
141
+ }
142
+ return {
143
+ comp: false,
144
+ scenes: { ...scenes, scenes: scenes.scenes.filter((s) => !isCompScene(s.key)) },
145
+ };
146
+ }
@@ -37,7 +37,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
37
37
  approved?: {
38
38
  version: number;
39
39
  approval: {
40
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
40
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
41
41
  signatures: {
42
42
  by: string;
43
43
  at: string;
@@ -62,7 +62,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
62
62
  pending?: {
63
63
  version: number;
64
64
  approval: {
65
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
65
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
66
66
  signatures: {
67
67
  by: string;
68
68
  at: string;
@@ -87,7 +87,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
87
87
  superseded?: {
88
88
  version: number;
89
89
  approval: {
90
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
90
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
91
91
  signatures: {
92
92
  by: string;
93
93
  at: string;
@@ -1,3 +1,5 @@
1
1
  import type { UiRoute } from './routes.ts';
2
+ /** One queue per product for every write of plan/agents.md: each applies to the file the last left. */
3
+ export declare function queueAgentsWrite(root: string, write: () => Promise<void>): Promise<void>;
2
4
  /** The UI server checks the viewer's settings right before this handler. */
3
5
  export declare function agentsRoute(root: string): UiRoute;
@@ -38,19 +38,22 @@ async function saveAssignment(root, { role, agent }, local) {
38
38
  if (file.level !== 'auto')
39
39
  mergeEvent('level', root);
40
40
  }
41
+ const queues = new Map();
42
+ /** One queue per product for every write of plan/agents.md: each applies to the file the last left. */
43
+ export function queueAgentsWrite(root, write) {
44
+ const next = (queues.get(root) ?? Promise.resolve()).then(write);
45
+ queues.set(root, next.catch(() => { }));
46
+ return next;
47
+ }
41
48
  /** The UI server checks the viewer's settings right before this handler. */
42
49
  export function agentsRoute(root) {
43
- // Each request applies to the file left by the preceding assignment.
44
- let pending = Promise.resolve();
45
50
  return {
46
51
  method: 'POST',
47
52
  path: '/api/agents',
48
53
  right: 'settings',
49
54
  handle: async ({ body, level }) => {
50
55
  const assignment = agentAssignmentSchema.parse(await body());
51
- const write = pending.then(() => saveAssignment(root, assignment, !level));
52
- pending = write.catch(() => { });
53
- await write;
56
+ await queueAgentsWrite(root, () => saveAssignment(root, assignment, !level));
54
57
  return { status: 202, body: { ok: true } };
55
58
  },
56
59
  };
@@ -61,7 +61,7 @@ export declare function hostedApproval(context: ApprovalContext, resolve: () =>
61
61
  } | {
62
62
  status: number;
63
63
  body: {
64
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
64
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
65
65
  signatures: {
66
66
  by: string;
67
67
  at: string;
@@ -1,9 +1,10 @@
1
- import { brandApprovalBody, changePlacesApprovalBody } from '@buffcore/contracts/workbench';
1
+ import { brandApprovalBody, changePlacesApprovalBody, compApprovalBodySchema, } from '@buffcore/contracts/workbench';
2
2
  import { z } from 'zod';
3
3
  import { ApprovalRefusal } from '../approval-rules.js';
4
4
  import { requireLegacyChange } from '../prototype/milestone-key.js';
5
5
  import { brandResolver, prototypeArtifact, releaseArtifact } from './approval-artifact.js';
6
6
  import { authorityFor, hostedApproval } from './approval-authority.js';
7
+ import { compApproval, compResolver } from './comp-approval.js';
7
8
  import { brandApproval, prototypeApproval } from './loop-approve.js';
8
9
  import { placesApproval } from './places-approval.js';
9
10
  import { approveChangePlaces } from './places-change-approval.js';
@@ -21,6 +22,7 @@ const approvalBody = z.union([
21
22
  z.discriminatedUnion('kind', [
22
23
  brandApprovalBody,
23
24
  prototypeBody,
25
+ compApprovalBodySchema,
24
26
  z.strictObject({ kind: z.literal('release') }),
25
27
  z.strictObject({
26
28
  kind: z.literal('places'),
@@ -57,6 +59,10 @@ export function brandApprovalRoute(root) {
57
59
  const role = hosted ? identity?.viewer.role : undefined;
58
60
  if (request.kind === 'places')
59
61
  return placesApproval(root, request, signer, role, context, source);
62
+ if (request.kind === 'comp')
63
+ return context
64
+ ? hostedApproval(context, await compResolver(root, request.fingerprint))
65
+ : compApproval(root, request.fingerprint, signer, role, undefined, source);
60
66
  if (context) {
61
67
  if (request.kind === 'brand') {
62
68
  const resolve = await brandResolver(root, request.direction);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * On the turns that write the product's own folder (design and validation at any level;
3
+ * planning and loop on Autopilot), a write aimed at a folder that holds the approval records is
4
+ * refused as well as one into them: `rm -rf prototype`, `cp -r x/. prototype/`, `cp x .`,
5
+ * `git checkout <ref> -- .`, `find prototype … -delete`, `tar -x` or `unzip` into the shell's
6
+ * folder, `Copy-Item -Recurse … prototype`. `prototype` itself takes a single file copied in
7
+ * (`cp design/logo.svg prototype/`); a whole folder copied, moved or linked there could become
8
+ * `prototype/versions`. A patch or an archive that could reach anywhere (`git apply`, `git am`,
9
+ * `patch`, `Expand-Archive`) is refused there outright. Plain Node only: the hook runs it.
10
+ */
11
+ /** True when a part writes into, or is aimed at, a folder that holds the approval records. */
12
+ export declare function folderWrite(words: string[], cwd: string): boolean;
13
+ /**
14
+ * What a design turn's command could write that the parse cannot place, for the person's card:
15
+ * a write after a `cd` in the same command, a write to a `$variable` path, `bsdtar -x`, and
16
+ * `7z x … -o…` (its folder is fused to the option).
17
+ */
18
+ export declare function folderUnsure(parts: string[][]): boolean;
19
+ /** A word that names a folder holding the records (a pipe's source, for the fallback). */
20
+ export declare const holdsRecords: (word: string, cwd: string) => boolean;