@buffcore/cli 0.8.41 → 0.8.43

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 (219) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/commands/agents-file.d.ts +5 -0
  3. package/dist/commands/agents-file.js +30 -7
  4. package/dist/commands/change.d.ts +4 -0
  5. package/dist/commands/change.js +12 -5
  6. package/dist/commands/create-block.d.ts +2 -1
  7. package/dist/commands/create-block.js +7 -5
  8. package/dist/commands/create.d.ts +3 -2
  9. package/dist/commands/create.en.js +1 -1
  10. package/dist/commands/create.es.js +1 -1
  11. package/dist/commands/create.js +8 -6
  12. package/dist/commands/design/check.d.ts +2 -0
  13. package/dist/commands/design/check.js +6 -0
  14. package/dist/commands/design/journey-roles.d.ts +6 -0
  15. package/dist/commands/design/journey-roles.js +60 -0
  16. package/dist/commands/design/references.d.ts +12 -0
  17. package/dist/commands/design/references.js +44 -0
  18. package/dist/commands/design/tells-text.js +2 -2
  19. package/dist/commands/design/tells.d.ts +3 -1
  20. package/dist/commands/design/tells.en.d.ts +2 -0
  21. package/dist/commands/design/tells.en.js +2 -0
  22. package/dist/commands/design/tells.es.js +2 -0
  23. package/dist/commands/design/tells.js +10 -7
  24. package/dist/commands/dev.js +3 -0
  25. package/dist/commands/extension/places-approval.d.ts +1 -1
  26. package/dist/commands/port-claims.d.ts +23 -0
  27. package/dist/commands/port-claims.js +95 -0
  28. package/dist/commands/prototype/browser.d.ts +9 -4
  29. package/dist/commands/prototype/browser.js +26 -18
  30. package/dist/commands/prototype/comp-record.d.ts +27 -0
  31. package/dist/commands/prototype/comp-record.js +85 -0
  32. package/dist/commands/prototype/comp-words.d.ts +12 -0
  33. package/dist/commands/prototype/comp-words.js +24 -0
  34. package/dist/commands/prototype/comp.d.ts +26 -0
  35. package/dist/commands/prototype/comp.js +71 -0
  36. package/dist/commands/prototype/export-base.d.ts +27 -0
  37. package/dist/commands/prototype/export-base.js +80 -0
  38. package/dist/commands/prototype/export.d.ts +3 -2
  39. package/dist/commands/prototype/export.js +13 -6
  40. package/dist/commands/prototype/index.js +1 -0
  41. package/dist/commands/prototype/media-ready.d.ts +8 -0
  42. package/dist/commands/prototype/media-ready.js +36 -0
  43. package/dist/commands/prototype/messages.en.d.ts +6 -0
  44. package/dist/commands/prototype/messages.en.js +6 -0
  45. package/dist/commands/prototype/messages.js +6 -0
  46. package/dist/commands/prototype/milestone-versions.d.ts +1 -1
  47. package/dist/commands/prototype/record-look-child.js +4 -1
  48. package/dist/commands/prototype/scene.d.ts +3 -1
  49. package/dist/commands/prototype/scene.js +22 -6
  50. package/dist/commands/prototype/snapshot-command.js +1 -1
  51. package/dist/commands/prototype/snapshot-inputs.js +35 -7
  52. package/dist/commands/prototype/snapshot-setup.d.ts +12 -1
  53. package/dist/commands/prototype/snapshot-setup.js +31 -6
  54. package/dist/commands/prototype/snapshot.d.ts +2 -0
  55. package/dist/commands/prototype/snapshot.js +2 -1
  56. package/dist/commands/prototype/versions.d.ts +3 -3
  57. package/dist/commands/ui/agents-route.d.ts +2 -0
  58. package/dist/commands/ui/agents-route.js +8 -5
  59. package/dist/commands/ui/approval-authority.d.ts +1 -1
  60. package/dist/commands/ui/approve.js +7 -1
  61. package/dist/commands/ui/chat/allow-folder.js +23 -77
  62. package/dist/commands/ui/chat/claude-permissions.d.ts +21 -0
  63. package/dist/commands/ui/chat/claude-permissions.js +69 -0
  64. package/dist/commands/ui/chat/codex-idle.d.ts +2 -0
  65. package/dist/commands/ui/chat/codex-overrides.js +2 -1
  66. package/dist/commands/ui/chat/codex-permissions.d.ts +12 -0
  67. package/dist/commands/ui/chat/codex-permissions.js +97 -0
  68. package/dist/commands/ui/chat/command-parts.d.ts +33 -0
  69. package/dist/commands/ui/chat/command-parts.js +219 -0
  70. package/dist/commands/ui/chat/command-wrappers.d.ts +21 -0
  71. package/dist/commands/ui/chat/command-wrappers.js +100 -0
  72. package/dist/commands/ui/chat/design-deletes.d.ts +1 -0
  73. package/dist/commands/ui/chat/design-deletes.js +39 -0
  74. package/dist/commands/ui/chat/fresh-critique.d.ts +28 -0
  75. package/dist/commands/ui/chat/fresh-critique.js +121 -0
  76. package/dist/commands/ui/chat/fresh-launch.d.ts +31 -0
  77. package/dist/commands/ui/chat/fresh-launch.js +122 -0
  78. package/dist/commands/ui/chat/fresh-prompts.d.ts +17 -0
  79. package/dist/commands/ui/chat/fresh-prompts.js +76 -0
  80. package/dist/commands/ui/chat/fresh-report.d.ts +8 -0
  81. package/dist/commands/ui/chat/fresh-report.js +36 -0
  82. package/dist/commands/ui/chat/fresh-routes.d.ts +3 -0
  83. package/dist/commands/ui/chat/fresh-routes.js +64 -0
  84. package/dist/commands/ui/chat/fresh-settings.d.ts +12 -0
  85. package/dist/commands/ui/chat/fresh-settings.js +66 -0
  86. package/dist/commands/ui/chat/fresh-store.d.ts +17 -0
  87. package/dist/commands/ui/chat/fresh-store.js +67 -0
  88. package/dist/commands/ui/chat/fresh.d.ts +31 -0
  89. package/dist/commands/ui/chat/fresh.en.d.ts +7 -0
  90. package/dist/commands/ui/chat/fresh.en.js +7 -0
  91. package/dist/commands/ui/chat/fresh.es.d.ts +7 -0
  92. package/dist/commands/ui/chat/fresh.es.js +7 -0
  93. package/dist/commands/ui/chat/fresh.js +112 -0
  94. package/dist/commands/ui/chat/launch-input.d.ts +4 -2
  95. package/dist/commands/ui/chat/launch-input.js +16 -3
  96. package/dist/commands/ui/chat/limit-mentions.d.ts +5 -0
  97. package/dist/commands/ui/chat/limit-mentions.js +94 -0
  98. package/dist/commands/ui/chat/limit-patterns.d.ts +15 -0
  99. package/dist/commands/ui/chat/limit-patterns.js +182 -0
  100. package/dist/commands/ui/chat/limits-hook.d.ts +1 -0
  101. package/dist/commands/ui/chat/limits-hook.js +30 -0
  102. package/dist/commands/ui/chat/limits.d.ts +44 -0
  103. package/dist/commands/ui/chat/limits.en.d.ts +20 -0
  104. package/dist/commands/ui/chat/limits.en.js +20 -0
  105. package/dist/commands/ui/chat/limits.es.d.ts +2 -0
  106. package/dist/commands/ui/chat/limits.es.js +19 -0
  107. package/dist/commands/ui/chat/limits.js +236 -0
  108. package/dist/commands/ui/chat/local-settings.d.ts +17 -0
  109. package/dist/commands/ui/chat/local-settings.js +73 -0
  110. package/dist/commands/ui/chat/opencode-config.d.ts +22 -0
  111. package/dist/commands/ui/chat/opencode-config.js +83 -0
  112. package/dist/commands/ui/chat/parse-claude.js +25 -5
  113. package/dist/commands/ui/chat/permission-ask.d.ts +44 -0
  114. package/dist/commands/ui/chat/permission-ask.js +145 -0
  115. package/dist/commands/ui/chat/permission-channel.d.ts +18 -0
  116. package/dist/commands/ui/chat/permission-channel.js +67 -0
  117. package/dist/commands/ui/chat/permission-route.d.ts +10 -0
  118. package/dist/commands/ui/chat/permission-route.js +47 -0
  119. package/dist/commands/ui/chat/permission-tool.d.ts +1 -0
  120. package/dist/commands/ui/chat/permission-tool.js +86 -0
  121. package/dist/commands/ui/chat/permissions.d.ts +11 -12
  122. package/dist/commands/ui/chat/permissions.js +20 -102
  123. package/dist/commands/ui/chat/planning-limits.d.ts +12 -0
  124. package/dist/commands/ui/chat/planning-limits.js +46 -0
  125. package/dist/commands/ui/chat/process.js +4 -1
  126. package/dist/commands/ui/chat/prompt.d.ts +8 -1
  127. package/dist/commands/ui/chat/prompt.en.d.ts +4 -0
  128. package/dist/commands/ui/chat/prompt.en.js +4 -0
  129. package/dist/commands/ui/chat/prompt.es.d.ts +4 -0
  130. package/dist/commands/ui/chat/prompt.es.js +4 -0
  131. package/dist/commands/ui/chat/prompt.js +18 -50
  132. package/dist/commands/ui/chat/publish-limits.d.ts +4 -0
  133. package/dist/commands/ui/chat/publish-limits.js +97 -0
  134. package/dist/commands/ui/chat/recorded-turn.js +6 -0
  135. package/dist/commands/ui/chat/routes.js +2 -0
  136. package/dist/commands/ui/chat/secret-folders.d.ts +16 -0
  137. package/dist/commands/ui/chat/secret-folders.js +35 -0
  138. package/dist/commands/ui/chat/stdin-shells.d.ts +8 -0
  139. package/dist/commands/ui/chat/stdin-shells.js +102 -0
  140. package/dist/commands/ui/chat/step-rules.d.ts +13 -0
  141. package/dist/commands/ui/chat/step-rules.js +47 -0
  142. package/dist/commands/ui/chat/store.js +11 -2
  143. package/dist/commands/ui/chat/stream.en.d.ts +6 -0
  144. package/dist/commands/ui/chat/stream.en.js +6 -0
  145. package/dist/commands/ui/chat/stream.es.d.ts +6 -0
  146. package/dist/commands/ui/chat/stream.es.js +6 -0
  147. package/dist/commands/ui/chat/stream.js +8 -2
  148. package/dist/commands/ui/chat/turn-guard.d.ts +27 -0
  149. package/dist/commands/ui/chat/turn-guard.js +86 -0
  150. package/dist/commands/ui/chat/turn-input.d.ts +3 -2
  151. package/dist/commands/ui/chat/turn-input.js +3 -1
  152. package/dist/commands/ui/chat/turn-scenes.d.ts +19 -0
  153. package/dist/commands/ui/chat/turn-scenes.js +44 -0
  154. package/dist/commands/ui/chat/turn-state.d.ts +11 -0
  155. package/dist/commands/ui/chat/turn.js +9 -3
  156. package/dist/commands/ui/comp-approval.d.ts +6 -0
  157. package/dist/commands/ui/comp-approval.js +42 -0
  158. package/dist/commands/ui/host.js +3 -0
  159. package/dist/commands/ui/index.js +18 -6
  160. package/dist/commands/ui/level-route.js +8 -3
  161. package/dist/commands/ui/loop-approve.d.ts +4 -4
  162. package/dist/commands/ui/page.d.ts +19 -1
  163. package/dist/commands/ui/page.js +9 -6
  164. package/dist/commands/ui/places-change.d.ts +1 -1
  165. package/dist/commands/ui/plan-structure.d.ts +12 -2
  166. package/dist/commands/ui/plan-structure.en.d.ts +4 -0
  167. package/dist/commands/ui/plan-structure.en.js +4 -0
  168. package/dist/commands/ui/plan-structure.es.d.ts +4 -0
  169. package/dist/commands/ui/plan-structure.es.js +4 -0
  170. package/dist/commands/ui/plan-structure.js +48 -14
  171. package/dist/commands/ui/prototype-comp-route.d.ts +7 -0
  172. package/dist/commands/ui/prototype-comp-route.js +109 -0
  173. package/dist/commands/ui/prototype-main.d.ts +3 -1
  174. package/dist/commands/ui/prototype-scenes-child.js +6 -1
  175. package/dist/commands/ui/prototype-scenes-read.d.ts +1 -0
  176. package/dist/commands/ui/prototype-scenes-route.js +7 -1
  177. package/dist/commands/ui/prototype-snapshot-session.d.ts +1 -1
  178. package/dist/commands/ui/prototype-snapshot-session.js +3 -0
  179. package/dist/commands/ui/prototype-snapshot.d.ts +1 -1
  180. package/dist/commands/ui/routes.d.ts +6 -3
  181. package/dist/commands/ui/routes.js +3 -3
  182. package/dist/commands/ui/save-commit.js +6 -2
  183. package/dist/commands/ui/save-publish.js +3 -0
  184. package/dist/commands/ui/server-options.js +2 -0
  185. package/dist/commands/ui/server.d.ts +12 -22
  186. package/dist/commands/ui/server.js +10 -48
  187. package/dist/commands/ui/snapshot-runners.d.ts +22 -0
  188. package/dist/commands/ui/snapshot-runners.js +45 -0
  189. package/dist/commands/ui/structure-surface.d.ts +6 -0
  190. package/dist/commands/ui/structure-surface.js +94 -0
  191. package/dist/commands/ui/studio-routes.d.ts +1 -0
  192. package/dist/commands/ui/studio-routes.js +5 -0
  193. package/dist/commands/ui/studio-state.d.ts +9 -4
  194. package/dist/commands/ui/studio-state.js +1 -0
  195. package/dist/commands/ui/studio-versions.d.ts +3 -3
  196. package/dist/commands/ui/studio.en.d.ts +13 -0
  197. package/dist/commands/ui/studio.en.js +13 -0
  198. package/dist/commands/ui/studio.es.d.ts +13 -0
  199. package/dist/commands/ui/studio.es.js +13 -0
  200. package/dist/commands/ui/theme-option.d.ts +8 -0
  201. package/dist/commands/ui/theme-option.js +40 -0
  202. package/dist/commands/ui/theme-values.d.ts +5 -0
  203. package/dist/commands/ui/theme-values.js +113 -0
  204. package/dist/ui/page.js +94 -94
  205. package/docs/PROCESS.md +5 -0
  206. package/docs/PROTOTYPE.md +24 -1
  207. package/docs/WORKBENCH.md +76 -22
  208. package/package.json +11 -11
  209. package/skills/ape-critique/SKILL.md +16 -6
  210. package/skills/ape-design-system/SKILL.md +4 -3
  211. package/skills/ape-plan-change/SKILL.md +7 -3
  212. package/skills/ape-prototype/SKILL.md +12 -1
  213. package/templates/example/apps/app/src/i18n/en.ts +2 -0
  214. package/templates/example/apps/app/src/i18n/es.json +2 -0
  215. package/templates/product/apps/admin/src/fonts.ts +2 -1
  216. package/templates/product/apps/app/src/fonts.ts +5 -1
  217. package/templates/product/apps/app/src/i18n/en.ts +2 -0
  218. package/templates/product/apps/app/src/i18n/es.json +2 -0
  219. package/templates/product/prototype/journeys.ts +3 -0
@@ -2,12 +2,14 @@
2
2
  // file server, with no API, database or development server. A scene needs no backend (its view
3
3
  // gets everything as props, sample data included), so the export is two development builds of the
4
4
  // commit checked out: the app's scene pages (Expo's web export) at the root, and the viewer with
5
- // the admin's scene pages (Vite, under `prototype/`).
5
+ // the admin's scene pages (Vite, under `prototype/`). `--base` serves it under another path.
6
6
  import { spawnSync } from 'node:child_process';
7
7
  import { existsSync } from 'node:fs';
8
8
  import { cp, mkdir, readdir, rm, writeFile } from 'node:fs/promises';
9
9
  import { join, relative, resolve } from 'node:path';
10
10
  import { findRoot } from '../../project.js';
11
+ import { exportBase, ROOT_BASE, relocate, viewerBase } from './export-base.js';
12
+ import { t } from './messages.js';
11
13
  import { checkedOut, git, requireCommitted } from './report.js';
12
14
  /** The root page: the export opens on the viewer. */
13
15
  const OPEN_VIEWER = `<!doctype html>
@@ -72,7 +74,8 @@ async function requireExportFolder(out) {
72
74
  * and name the commit in its `export.json`. Development builds: production ones leave the scenes
73
75
  * and the sample data out.
74
76
  */
75
- export async function buildSite(root, out, exported) {
77
+ export async function buildSite(root, out, exported, given = ROOT_BASE) {
78
+ const base = exportBase(given);
76
79
  const admin = surfaceDir(root, 'admin');
77
80
  if (!admin)
78
81
  throw new Error('No admin console here: the viewer is part of it.');
@@ -81,21 +84,25 @@ export async function buildSite(root, out, exported) {
81
84
  await rm(out, { recursive: true, force: true });
82
85
  if (app)
83
86
  build(app, `pnpm exec expo export --platform web --dev --output-dir "${out}"`);
84
- build(admin, `pnpm exec vite build --base /prototype/ --outDir "${out}/prototype" --emptyOutDir`, {
87
+ build(admin, `pnpm exec vite build --base ${viewerBase(base)} --outDir "${out}/prototype" --emptyOutDir`, {
85
88
  NODE_ENV: 'development',
86
89
  // The app's scene pages are on the same site, at its root.
87
90
  VITE_APP_URL: '',
88
91
  });
89
92
  await arrange(out, exported, Boolean(app));
93
+ if (base !== ROOT_BASE)
94
+ await relocate(out, Boolean(app), base);
90
95
  }
91
- /** `ape prototype export [<commit>] [--out <dir>]` */
96
+ /** `ape prototype export [<commit>] [--out <dir>] [--base <path>]` */
92
97
  export async function exportCommit(text, options) {
98
+ const base = exportBase(options.base);
93
99
  const root = findRoot();
94
100
  const commit = commitToExport(root, text);
95
101
  const out = resolve(options.out ?? join(root, 'dist', `prototype-${commit}`));
96
102
  const started = performance.now();
97
- await buildSite(root, out, { commit, exportedAt: new Date().toISOString() });
103
+ await buildSite(root, out, { commit, exportedAt: new Date().toISOString() }, base);
98
104
  const seconds = Math.round((performance.now() - started) / 1000);
99
105
  console.log(`\nThe prototype of commit ${commit} is in ${relative(process.cwd(), out) || '.'}, in ${seconds} s.`);
100
- console.log('Serve that folder at the root of any static file server (e.g. python -m http.server) and open it: no API, database or development server.');
106
+ const serve = base === ROOT_BASE ? 'exportServe' : base === './' ? 'exportServeRelative' : 'exportServeBase';
107
+ console.log(t(`prototype.${serve}`, { base }));
101
108
  }
@@ -23,6 +23,7 @@ export function addPrototypeCommand(program) {
23
23
  .command('export [commit]')
24
24
  .description('A commit (the one checked out, unchanged) as static files that run from a plain file server')
25
25
  .option('--out <dir>', 'where to write it (default dist/prototype-<commit>)')
26
+ .option('--base <path>', t('prototype.baseHelp'))
26
27
  .action(exportCommit);
27
28
  prototype
28
29
  .command('data')
@@ -0,0 +1,8 @@
1
+ /** The longest a scene page waits for its fonts and pictures; then it is shot anyway, with a hint. */
2
+ export declare const MEDIA_WAIT = 10000;
3
+ /**
4
+ * Runs in the page: wait until its fonts are ready and every picture has finished, loaded or
5
+ * failed (a lazy picture loads now: the shot is of the whole page). False when `timeout` ran out
6
+ * first. Self-contained, since Playwright sends it to the page as text.
7
+ */
8
+ export declare function mediaReady(timeout: number): Promise<boolean>;
@@ -0,0 +1,36 @@
1
+ /// <reference lib="dom" />
2
+ // Fonts and pictures a scene page is still loading: the snapshot waits for them before a picture.
3
+ /** The longest a scene page waits for its fonts and pictures; then it is shot anyway, with a hint. */
4
+ export const MEDIA_WAIT = 10_000;
5
+ /**
6
+ * Runs in the page: wait until its fonts are ready and every picture has finished, loaded or
7
+ * failed (a lazy picture loads now: the shot is of the whole page). False when `timeout` ran out
8
+ * first. Self-contained, since Playwright sends it to the page as text.
9
+ */
10
+ export async function mediaReady(timeout) {
11
+ // Layout first, so the fonts the text needs have started loading before `fonts.ready` is read.
12
+ document.body?.getBoundingClientRect();
13
+ const pictures = [...document.images].flatMap((image) => {
14
+ if (image.loading === 'lazy')
15
+ image.loading = 'eager';
16
+ if (image.complete)
17
+ return [];
18
+ return [
19
+ new Promise((done) => {
20
+ image.addEventListener('load', () => done(), { once: true });
21
+ image.addEventListener('error', () => done(), { once: true });
22
+ }),
23
+ ];
24
+ });
25
+ let timer;
26
+ const late = new Promise((done) => {
27
+ timer = setTimeout(() => done(false), timeout);
28
+ });
29
+ const ready = Promise.all([document.fonts.ready, ...pictures]).then(() => true);
30
+ try {
31
+ return await Promise.race([ready, late]);
32
+ }
33
+ finally {
34
+ clearTimeout(timer);
35
+ }
36
+ }
@@ -25,6 +25,7 @@ export declare const en: {
25
25
  'prototype.renderFailed': string;
26
26
  'prototype.devOverlay': string;
27
27
  'prototype.fontMismatch': string;
28
+ 'prototype.mediaLate': string;
28
29
  'prototype.identicalMore': string;
29
30
  'prototype.identical': string;
30
31
  'prototype.sceneStart': string;
@@ -164,4 +165,9 @@ export declare const en: {
164
165
  'prototype.lowMemory': string;
165
166
  'prototype.noRender': string;
166
167
  'prototype.drift': string;
168
+ 'prototype.baseHelp': string;
169
+ 'prototype.baseInvalid': string;
170
+ 'prototype.exportServe': string;
171
+ 'prototype.exportServeBase': string;
172
+ 'prototype.exportServeRelative': string;
167
173
  };
@@ -26,6 +26,7 @@ export const en = {
26
26
  'prototype.renderFailed': 'Scene rendering failed.',
27
27
  'prototype.devOverlay': 'A development error overlay was showing.',
28
28
  'prototype.fontMismatch': 'Hint to review: scene "{scene}" renders "{text}" in "{rendered}" instead of "{expected}".',
29
+ 'prototype.mediaLate': 'Hint to review: scene "{scene}" was still loading a font or picture after {seconds} seconds; its pictures show it as it was.',
29
30
  'prototype.identicalMore': '{scenes}, and {count} more',
30
31
  'prototype.identical': 'These scenes look exactly alike: {scenes}. Make them differ, or remove one.',
31
32
  'prototype.sceneStart': ' Snapshotting scene "{scene}"…',
@@ -165,4 +166,9 @@ export const en = {
165
166
  'prototype.lowMemory': 'This computer has {free} MB of free memory and a snapshot needs at least {need} MB. Close some programs and take the snapshot again, or set APE_SNAPSHOT_MIN_FREE_MB to change this.',
166
167
  'prototype.noRender': "No scene was drawn: the theme checks failed. Fix the theme, then snapshot again to see each scene's findings.",
167
168
  'prototype.drift': 'This change has sample data edits beyond its approved version.',
169
+ 'prototype.baseHelp': 'the path its root is served from (default /), e.g. /s/abc/, or ./ for paths relative to the page',
170
+ 'prototype.baseInvalid': '--base "{base}" is not a plain path. Use ./ or a path like /s/abc/: letters, digits, - _ ~ and dots, no .. and no address.',
171
+ 'prototype.exportServe': 'Serve that folder at the root of any static file server (e.g. python -m http.server) and open it: no API, database or development server.',
172
+ 'prototype.exportServeBase': 'Serve that folder at {base} of any static file server and open it there: no API, database or development server.',
173
+ 'prototype.exportServeRelative': 'Serve that folder under any path of any static file server and open it there: no API, database or development server.',
168
174
  };
@@ -27,6 +27,7 @@ const es = {
27
27
  'prototype.renderFailed': 'El renderizado de la escena falló.',
28
28
  'prototype.devOverlay': 'Se estaba mostrando una superposición de error de desarrollo.',
29
29
  'prototype.fontMismatch': 'Sugerencia para revisar: la escena "{scene}" muestra "{text}" con "{rendered}" en vez de "{expected}".',
30
+ 'prototype.mediaLate': 'Sugerencia para revisar: la escena "{scene}" seguía cargando una fuente o una imagen después de {seconds} segundos; sus capturas la muestran como estaba.',
30
31
  'prototype.identicalMore': '{scenes}, y {count} más',
31
32
  'prototype.identical': 'Estas escenas se ven exactamente iguales: {scenes}. Haz que se diferencien, o quita una.',
32
33
  'prototype.sceneStart': ' Capturando la escena "{scene}"…',
@@ -166,6 +167,11 @@ const es = {
166
167
  'prototype.lowMemory': 'Este equipo tiene {free} MB de memoria libre y una captura necesita al menos {need} MB. Cierra algunos programas y toma la captura de nuevo, o define APE_SNAPSHOT_MIN_FREE_MB para cambiarlo.',
167
168
  'prototype.noRender': 'No se dibujó ninguna escena: fallaron las comprobaciones del tema. Corrige el tema y toma la captura de nuevo para ver los hallazgos de cada escena.',
168
169
  'prototype.drift': 'Este cambio tiene ediciones en los datos de ejemplo posteriores a su versión aprobada.',
170
+ 'prototype.baseHelp': 'la ruta desde la que se sirve su raíz (/ por defecto), p. ej. /s/abc/, o ./ para rutas relativas a la página',
171
+ 'prototype.baseInvalid': '--base "{base}" no es una ruta simple. Usa ./ o una ruta como /s/abc/: letras, dígitos, - _ ~ y puntos, sin .. y sin dirección.',
172
+ 'prototype.exportServe': 'Sirve esa carpeta en la raíz de cualquier servidor de archivos estáticos (p. ej. python -m http.server) y ábrela: sin API, base de datos ni servidor de desarrollo.',
173
+ 'prototype.exportServeBase': 'Sirve esa carpeta en {base} de cualquier servidor de archivos estáticos y ábrela ahí: sin API, base de datos ni servidor de desarrollo.',
174
+ 'prototype.exportServeRelative': 'Sirve esa carpeta bajo cualquier ruta de cualquier servidor de archivos estáticos y ábrela ahí: sin API, base de datos ni servidor de desarrollo.',
169
175
  };
170
176
  /** The locale the prototype's words are shown in (also for the lists inside them). */
171
177
  export const locale = () => /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
@@ -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 ?? '';
@@ -1,4 +1,4 @@
1
- import { type Scene, type Surface } from '@buffcore/config';
1
+ import { type Frame, type FrameSize, type Scene, type Surface } from '@buffcore/config';
2
2
  import { type Theme } from '@buffcore/tokens';
3
3
  import type { Browser } from 'playwright-core';
4
4
  import { type browserSession } from './browser.ts';
@@ -14,6 +14,8 @@ export interface Run {
14
14
  sceneTimeout?: number | undefined;
15
15
  checkCheckout?: (() => void) | undefined;
16
16
  looks: readonly Theme[];
17
+ /** Each frame's size: the presets, with the product's own desktop frame (`frameSizes`). */
18
+ frames: Record<Frame, FrameSize>;
17
19
  /** The theme also photographed in dark mode: the product's. */
18
20
  product: string;
19
21
  /** The declared theme. Implicit starter looks carry no font requirement. */
@@ -1,22 +1,26 @@
1
1
  // One scene of a snapshot: opened in every theme, mode and language, checked in each, and
2
2
  // screenshotted in the looks a person reviews.
3
3
  import { join } from 'node:path';
4
- import { FRAME_SIZES, sceneUrl } from '@buffcore/config';
4
+ import { sceneUrl } from '@buffcore/config';
5
5
  import { setAsideWords } from '@buffcore/tokens';
6
6
  import { openScene, PageLoadError, pageGone } from './browser.js';
7
7
  import { clippedEdges, dataWords, pageProblems } from './checks.js';
8
8
  import { watchFonts } from './fonts.js';
9
9
  import { fullShot } from './full-shot.js';
10
10
  import { measure } from './measure.js';
11
+ import { MEDIA_WAIT } from './media-ready.js';
12
+ import { t } from './messages.js';
11
13
  import { describe, readText } from './readable.js';
12
14
  import { renderScene, requireNoErrorOverlay } from './scene-render.js';
13
15
  import { sceneRequests } from './snapshot-requests.js';
14
16
  import { shotName } from './snapshot-shots.js';
15
17
  import { lookKey, photographed } from './snapshot-themes.js';
16
18
  export { lookKey, photographed };
19
+ /** How long a scene's later looks wait for fonts and pictures once one look ran out of time. */
20
+ const LATE_WAIT = 1_000;
17
21
  /** Open the first look so the surface can finish its cold build. */
18
22
  export async function warmSurface(browser, scene, run, signal) {
19
- await renderScene(browser, FRAME_SIZES[scene.frame], scene.key, run.sceneTimeout, async (page) => {
23
+ await renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page) => {
20
24
  if (run.requests)
21
25
  sceneRequests(page, run, scene);
22
26
  const look = { theme: run.product, mode: 'light', locale: run.first };
@@ -25,7 +29,7 @@ export async function warmSurface(browser, scene, run, signal) {
25
29
  }
26
30
  /** One scene in every theme, mode and language: its screenshots and its problems. */
27
31
  export async function snapScene(browser, scene, run, signal) {
28
- return renderScene(browser, FRAME_SIZES[scene.frame], scene.key, run.sceneTimeout, async (page, advise) => {
32
+ return renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page, advise) => {
29
33
  const requests = sceneRequests(page, run, scene);
30
34
  const found = {
31
35
  scene,
@@ -36,6 +40,8 @@ export async function snapScene(browser, scene, run, signal) {
36
40
  hints: [],
37
41
  pairs: new Set(),
38
42
  };
43
+ // A font or picture still loading is noted once; the scene's other looks wait a second.
44
+ const late = [];
39
45
  const declared = run.photosOnly
40
46
  ? undefined
41
47
  : run.looks.find((theme) => theme.key === run.fontTheme);
@@ -46,7 +52,17 @@ export async function snapScene(browser, scene, run, signal) {
46
52
  if (run.photosOnly &&
47
53
  !(locale === run.first && photographed(theme.key, mode, run.product)))
48
54
  continue;
49
- await openScene(page, sceneUrl(run.urls[scene.surface], scene.key, look), locale);
55
+ const url = sceneUrl(run.urls[scene.surface], scene.key, look);
56
+ if (await openScene(page, url, locale, late.length ? LATE_WAIT : undefined))
57
+ if (!late.length)
58
+ late.push({
59
+ scene: scene.key,
60
+ ...look,
61
+ detail: t('prototype.mediaLate', {
62
+ scene: scene.key,
63
+ seconds: MEDIA_WAIT / 1000,
64
+ }),
65
+ });
50
66
  await checkLook(page, look, run, found).catch((error) => {
51
67
  throw pageGone(error) ? new PageLoadError(String(error), { cause: error }) : error;
52
68
  });
@@ -62,8 +78,8 @@ export async function snapScene(browser, scene, run, signal) {
62
78
  }
63
79
  }
64
80
  }
65
- const { screenshots, cut, problems, hints } = found;
66
- return { screenshots, cut, problems, hints, ...requests };
81
+ const { screenshots, cut, problems } = found;
82
+ return { screenshots, cut, problems, hints: [...found.hints, ...late], ...requests };
67
83
  }, signal, run);
68
84
  }
69
85
  /** The scene page as it shows one look: photographed when it is reviewed, and checked. */
@@ -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));
@@ -1,7 +1,7 @@
1
- import { existsSync } from 'node:fs';
1
+ import { existsSync, readdirSync } from 'node:fs';
2
2
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
3
3
  import { parseEnv } from 'node:util';
4
- import { FRAME_SIZES, SURFACES } from '@buffcore/config';
4
+ import { SURFACES } from '@buffcore/config';
5
5
  import { pageOptions } from './browser.js';
6
6
  import { surfaceDir } from './export.js';
7
7
  import { locale } from './messages.js';
@@ -88,6 +88,19 @@ async function settingHashes(root, files, dependencies) {
88
88
  return [name, sha256(JSON.stringify(environment))];
89
89
  }));
90
90
  }
91
+ /** The design system's font files the console serves under `_fonts/`, as its Vite plugin lists them. */
92
+ function designFonts(root) {
93
+ const dir = join(root, 'design', 'fonts');
94
+ try {
95
+ return readdirSync(dir, { withFileTypes: true })
96
+ .filter((entry) => entry.isFile() && /\.(?:woff2?|ttf|otf)$/i.test(entry.name))
97
+ .map((entry) => join(dir, entry.name))
98
+ .sort();
99
+ }
100
+ catch {
101
+ return [];
102
+ }
103
+ }
91
104
  /** The HTML can load public fonts or images without a JavaScript import. */
92
105
  async function pageAssets(dir, read) {
93
106
  const page = join(dir, 'index.html');
@@ -115,9 +128,10 @@ async function surfaceEntry(root, surface, dependencies) {
115
128
  const configuration = await toolchains(dir, surface, dependencies.read);
116
129
  if (!configuration)
117
130
  return;
118
- const assets = await pageAssets(dir, dependencies.read).catch(() => undefined);
119
- if (!assets)
131
+ const page = await pageAssets(dir, dependencies.read).catch(() => undefined);
132
+ if (!page)
120
133
  return;
134
+ const assets = [...page, ...(surface === 'admin' ? designFonts(root) : [])];
121
135
  const entry = {
122
136
  surface,
123
137
  dir,
@@ -132,6 +146,9 @@ function hasSurfaceAsset(surface, url) {
132
146
  if (!surface)
133
147
  return false;
134
148
  const path = decodeURIComponent(url.pathname);
149
+ const { fonts } = surface;
150
+ if (fonts && path.startsWith(fonts.path))
151
+ return surface.assets.has(join(fonts.dir, path.slice(fonts.path.length)));
135
152
  if (path.startsWith('/@fs/'))
136
153
  return surface.assets.has(resolve(path.slice(5)));
137
154
  const metroAsset = url.searchParams.get('unstable_path');
@@ -140,6 +157,11 @@ function hasSurfaceAsset(surface, url) {
140
157
  return (surface.assets.has(resolve(surface.dir, `.${path}`)) ||
141
158
  surface.assets.has(resolve(surface.dir, 'public', `.${path}`)));
142
159
  }
160
+ /** The console's `_fonts/` under the base its address names (`/`, or `/s/abc/`). */
161
+ function fontPath(address) {
162
+ const base = decodeURIComponent(URL.parse(address)?.pathname ?? '/');
163
+ return `${base.endsWith('/') ? base : `${base}/`}_fonts/`;
164
+ }
143
165
  /** The surface loads its whole view registry. Scene definitions still identify individual scenes. */
144
166
  export async function snapshotInputs(root, scenes, run, browser, design,
145
167
  /** What the fingerprint reads public values from: the process's, or a linked run's own. */
@@ -162,6 +184,9 @@ environment = process.env) {
162
184
  dir: setup.entry.dir,
163
185
  hash: sha256(JSON.stringify([setup.settings, files])),
164
186
  assets: new Set([...setup.assets, ...files.map(([file]) => resolve(root, file))]),
187
+ ...(surface === 'admin' && {
188
+ fonts: { path: fontPath(run.urls.admin), dir: join(root, 'design', 'fonts') },
189
+ }),
165
190
  });
166
191
  }
167
192
  if (!inputs.size)
@@ -174,7 +199,11 @@ environment = process.env) {
174
199
  const surface = inputs.get(scene.surface);
175
200
  if (!surface || typeof scene.view !== 'string' || !plainData(scene))
176
201
  continue;
177
- fingerprints.set(scene.key, sha256(JSON.stringify([shared, surface.hash, scene, pageOptions(FRAME_SIZES[scene.frame])])));
202
+ // Each scene holds its own frame's size, in one key order: a new desktop frame re-shoots
203
+ // only the scenes shown in it.
204
+ const { width, height } = run.frames[scene.frame];
205
+ const page = pageOptions({ width, height });
206
+ fingerprints.set(scene.key, sha256(JSON.stringify([shared, surface.hash, scene, page])));
178
207
  }
179
208
  return result;
180
209
  }
@@ -184,10 +213,9 @@ environment = process.env) {
184
213
  */
185
214
  function sharedFingerprint(run, browser, common, design, environment) {
186
215
  return sha256(JSON.stringify([
187
- 'snapshot-inputs-v3',
216
+ 'snapshot-inputs-v4',
188
217
  dependencyVersion,
189
218
  browser,
190
- FRAME_SIZES,
191
219
  run.looks,
192
220
  run.fontTheme,
193
221
  run.first,
@@ -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;
@@ -28,7 +30,7 @@ export interface Setup {
28
30
  progress: SnapshotProgressSource | undefined;
29
31
  urls: SnapshotOptions['urls'];
30
32
  dir: string;
31
- options: Pick<SnapshotOptions, 'scenes' | 'locales' | 'urls' | 'dir' | 'scene' | 'sceneTimeout' | 'root' | 'pages' | 'ownScenes'>;
33
+ options: Pick<SnapshotOptions, 'scenes' | 'locales' | 'frames' | 'urls' | 'dir' | 'scene' | 'sceneTimeout' | 'root' | 'pages' | 'ownScenes'>;
32
34
  seconds(): number;
33
35
  }
34
36
  export type Servers = {
@@ -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
+ };
@@ -10,9 +10,11 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
10
10
  import { existsSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
12
  import { pathToFileURL } from 'node:url';
13
- import { coreEnvSchema, defineEnv, isContainer, } from '@buffcore/config';
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,
@@ -108,9 +112,11 @@ export async function setup(flags, servers) {
108
112
  options: {
109
113
  scenes,
110
114
  locales: product.locales,
115
+ frames: frameSizes(product),
111
116
  urls,
112
117
  dir,
113
- scene,
118
+ // The comp's run is whole: its own report, never a part of the scenes'.
119
+ scene: comp ? undefined : scene,
114
120
  sceneTimeout,
115
121
  root,
116
122
  pages: flags.pages,
@@ -119,3 +125,22 @@ export async function setup(flags, servers) {
119
125
  seconds: () => Math.round((performance.now() - started) / 1000),
120
126
  };
121
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
+ }
@@ -10,6 +10,8 @@ export interface SnapshotOptions {
10
10
  scenes: Scenes;
11
11
  /** The product's languages, its first the default. */
12
12
  locales: readonly string[];
13
+ /** Each frame's size (`frameSizes` of the product); unset, the presets. */
14
+ frames?: Run['frames'] | undefined;
13
15
  urls: Run['urls'];
14
16
  commit: string;
15
17
  /** `prototype/snapshots/`: the screenshots go in `<commit>/` there. */
@@ -29,6 +29,7 @@ function runOf(options) {
29
29
  sceneTimeout: options.sceneTimeout,
30
30
  checkCheckout: options.checkCheckout,
31
31
  looks,
32
+ frames: options.frames ?? FRAME_SIZES,
32
33
  product: (scenes.theme ?? looks[0])?.key ?? '',
33
34
  fontTheme: scenes.theme?.key,
34
35
  locales,
@@ -78,7 +79,7 @@ async function writeRun(options, run, picked) {
78
79
  return await withSnapshotProgress(options.progress, async () => {
79
80
  return [
80
81
  picked,
81
- picked.map(({ surface, frame }) => [surface, FRAME_SIZES[frame]]),
82
+ picked.map(({ surface, frame }) => [surface, run.frames[frame]]),
82
83
  picked.length ? await browserVersion() : null,
83
84
  run.looks,
84
85
  run.fontTheme,
@@ -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);