@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
@@ -0,0 +1,42 @@
1
+ // Approve the look: the guarded approval route's door for the comp. A person's only, at every level;
2
+ // there is no agent, MCP or Autopilot door, and `approveComp` refuses an agent's name. The record is
3
+ // saved as its own isolated commit, as a version approval is (`saveApprovalRecord`).
4
+ import { ApprovalRefusal } from '../approval-rules.js';
5
+ import { newestComp } from '../prototype/comp.js';
6
+ import { approveComp, COMP_FILE } from '../prototype/comp-record.js';
7
+ import { compT } from '../prototype/comp-words.js';
8
+ import { VersionRefusal } from '../prototype/versions.js';
9
+ import { hostGit } from '../safe-git.js';
10
+ import { HostSaveRefusal } from './host-save.js';
11
+ import { saveApprovalRecord } from './save-route.js';
12
+ const git = async (root, args) => (await hostGit(root, args)).trim();
13
+ export async function compApproval(root, fingerprint, signer, role, agent, source) {
14
+ if (agent !== undefined)
15
+ return { status: 409, body: { error: compT('comp.person') } };
16
+ const by = signer ?? (await git(root, ['config', 'user.email']).catch(() => ''));
17
+ if (!by)
18
+ return { status: 400, body: { error: compT('comp.identity') } };
19
+ const commit = await git(root, ['rev-parse', '--verify', 'HEAD']).catch(() => null);
20
+ if (!commit)
21
+ return { status: 409, body: { error: compT('comp.commitFirst') } };
22
+ try {
23
+ const record = await saveApprovalRecord(root, COMP_FILE, (write = true) => approveComp(root, { by, commit, fingerprint, role }, write), by, undefined, source);
24
+ return { status: 201, body: record.approval };
25
+ }
26
+ catch (error) {
27
+ if (error instanceof HostSaveRefusal)
28
+ return { status: 409, body: error.result() };
29
+ if (error instanceof ApprovalRefusal || error instanceof VersionRefusal)
30
+ return { status: 409, body: { error: error.message } };
31
+ throw error;
32
+ }
33
+ }
34
+ /** What a host's authority judges: the comp the page showed, at the commit checked out. */
35
+ export async function compResolver(root, fingerprint) {
36
+ const commit = await git(root, ['rev-parse', '--verify', 'HEAD']);
37
+ return () => {
38
+ if (newestComp(root)?.fingerprint !== fingerprint)
39
+ throw new Error();
40
+ return { kind: 'comp', version: null, commit, fingerprint };
41
+ };
42
+ }
@@ -54,6 +54,9 @@ export async function routeRight(route, request) {
54
54
  return route.right;
55
55
  if (route.path === '/api/approve') {
56
56
  const { kind } = approvalKind.parse(await request.body());
57
+ // The comp is the prototype's look: whoever approves prototypes approves it.
58
+ if (kind === 'comp')
59
+ return 'approve:prototype';
57
60
  return kind === 'places' ? 'approve:data' : `approve:${kind}`;
58
61
  }
59
62
  if (route.path === '/api/run') {
@@ -5,7 +5,10 @@ import { spawn } from 'node:child_process';
5
5
  import { createI18n } from '@buffcore/i18n';
6
6
  import { InvalidArgumentError } from 'commander';
7
7
  import { findRoot, loadEnv, loadProduct } from '../../project.js';
8
+ import { FreshLooks } from './chat/fresh.js';
9
+ import { freshRoutes } from './chat/fresh-routes.js';
8
10
  import { TurnMigrations } from './chat/migration-turn.js';
11
+ import { agentStart } from './chat/process.js';
9
12
  import { chatRoutes } from './chat/routes.js';
10
13
  import { installShutdown } from './chat/shutdown.js';
11
14
  import { ChatEngine } from './chat/turn.js';
@@ -52,7 +55,8 @@ export async function ui(options) {
52
55
  const token = newToken();
53
56
  const code = localCode((event) => console.log(t(`ui.code.${event}`, undefined, locale)));
54
57
  const migrations = new TurnMigrations(root, env, locale);
55
- const chats = new ChatEngine(root, { environment: agentEnvironment, migrations });
58
+ const fresh = new FreshLooks(root, agentStart(root, agentEnvironment));
59
+ const chats = new ChatEngine(root, { environment: agentEnvironment, migrations, fresh });
56
60
  await chats.ready;
57
61
  const stack = new Stack(root, {
58
62
  app: env.APE_APP_URL,
@@ -76,13 +80,17 @@ export async function ui(options) {
76
80
  runner,
77
81
  plan: () => plan,
78
82
  refreshPlan,
79
- routes: [...routes, ...chatRoutes(chats)],
83
+ routes: [...routes, ...chatRoutes(chats), ...freshRoutes(fresh, root)],
84
+ onFullSnapshot: (source, report) => void fresh.afterSnapshot(source, report),
80
85
  });
81
86
  await openStudio(server, port, token, code, options, locale);
82
- keepStudio(server, stack, chats, migrations);
87
+ keepStudio(server, stack, chats, migrations, fresh);
83
88
  }
84
- function keepStudio(server, stack, chats, migrations) {
85
- server.once('close', () => chats.stopAll());
89
+ function keepStudio(server, stack, chats, migrations, fresh) {
90
+ server.once('close', () => {
91
+ fresh.close();
92
+ void chats.stopAll();
93
+ });
86
94
  void stack.check();
87
95
  setInterval(() => void stack.check(), 2000).unref();
88
96
  installShutdown({
@@ -91,9 +99,13 @@ function keepStudio(server, stack, chats, migrations) {
91
99
  },
92
100
  release: () => stack.release(),
93
101
  stop: async () => {
102
+ fresh.close();
94
103
  await Promise.all([chats.shutdown(), migrations.idle()]);
95
104
  },
96
- force: () => chats.stopAll(true),
105
+ force: () => {
106
+ fresh.close();
107
+ return chats.stopAll(true);
108
+ },
97
109
  });
98
110
  }
99
111
  async function openStudio(server, port, token, code, options, locale) {
@@ -15,7 +15,7 @@ export function levelRoute(root) {
15
15
  const { body, identity, hosted, level: control } = request;
16
16
  if (control)
17
17
  return { status: 409, body: levelElsewhere(control) };
18
- const { level } = levelBody.parse(await body());
18
+ const { level, neverAsk } = levelBody.parse(await body());
19
19
  const person = personForTurn({ identity, hosted });
20
20
  if (!person)
21
21
  return { status: 403, body: { error: hostT('ui.host.private') } };
@@ -25,9 +25,14 @@ export function levelRoute(root) {
25
25
  work: {},
26
26
  level: 'guide',
27
27
  };
28
- const content = await agentsFileText(target, { ...file, level });
28
+ // Never ask lives only with Autopilot: another level clears it, so coming back starts off.
29
+ const { neverAsk: saved, ...rest } = file;
30
+ const next = level === 'auto' && (neverAsk ?? saved)
31
+ ? { ...rest, level, neverAsk: true }
32
+ : { ...rest, level };
33
+ const content = await agentsFileText(target, next);
29
34
  if (!request.save) {
30
- await writeAgentsFile(target, { ...file, level });
35
+ await writeAgentsFile(target, next);
31
36
  factsChanged('levels', 'unsaved');
32
37
  if (level !== 'auto')
33
38
  mergeEvent('level', target);
@@ -9,7 +9,7 @@ export declare function brandApproval(root: string, direction: keyof typeof them
9
9
  } | {
10
10
  status: number;
11
11
  body: {
12
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
12
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
13
13
  signatures: {
14
14
  by: string;
15
15
  at: string;
@@ -75,7 +75,7 @@ export declare function prototypeApproval(root: string, request: {
75
75
  approved?: {
76
76
  version: number;
77
77
  approval: {
78
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
78
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
79
79
  signatures: {
80
80
  by: string;
81
81
  at: string;
@@ -100,7 +100,7 @@ export declare function prototypeApproval(root: string, request: {
100
100
  pending?: {
101
101
  version: number;
102
102
  approval: {
103
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
103
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
104
104
  signatures: {
105
105
  by: string;
106
106
  at: string;
@@ -125,7 +125,7 @@ export declare function prototypeApproval(root: string, request: {
125
125
  superseded?: {
126
126
  version: number;
127
127
  approval: {
128
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
128
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
129
129
  signatures: {
130
130
  by: string;
131
131
  at: string;
@@ -1,4 +1,12 @@
1
1
  import { type HostPartSources } from '@buffcore/contracts/workbench';
2
+ import type { Theme } from '@buffcore/tokens';
3
+ /** What a host adds to the studio's page: its modules and its theme, both checked at start. */
4
+ export interface HostPageOptions {
5
+ /** Trusted modules served by the host, at the places `HostPartSources` names. Requires signIn. */
6
+ hostParts?: HostPartSources;
7
+ /** A host's theme, the same `Theme` as `studioTheme`; refused at start with every problem listed. */
8
+ theme?: Theme;
9
+ }
2
10
  /** The page's script, bundled from the admin shell's source (esbuild, a build-time tool). */
3
11
  export declare function bundlePage(cli?: string): Promise<string>;
4
12
  /** Where a built CLI keeps the page's script. */
@@ -6,7 +14,7 @@ export declare const builtPage: (cli: string) => string;
6
14
  /** The page's script: bundled now from source in a checkout, else the one the build made. */
7
15
  export declare function pageScript(cli?: string, locale?: 'en' | 'es'): Promise<string>;
8
16
  /** The page itself; mounting localizes the title to the studio's chosen language. */
9
- export declare const pageHtml: (product: string, hostParts?: HostPartSources, local?: boolean) => string;
17
+ export declare const pageHtml: (product: string, hostParts?: HostPartSources, local?: boolean, theme?: Theme) => string;
10
18
  /** Programmatic host setup only; reject unsafe maps before creating the server. */
11
19
  export declare function checkedHostParts(sources: HostPartSources | undefined, signedIn: boolean): {
12
20
  'top.end'?: string | undefined;
@@ -14,4 +22,14 @@ export declare function checkedHostParts(sources: HostPartSources | undefined, s
14
22
  'top.below'?: string | undefined;
15
23
  'setup.end'?: string | undefined;
16
24
  'issues.top'?: string | undefined;
25
+ 'side:prototype'?: string | undefined;
26
+ 'approve:release'?: string | undefined;
27
+ 'card:server'?: string | undefined;
28
+ rail?: {
29
+ id: string;
30
+ label: string;
31
+ source: string;
32
+ icon?: string | undefined;
33
+ }[] | undefined;
34
+ label?: string | undefined;
17
35
  } | undefined;
@@ -18,7 +18,9 @@ const token = root.hasAttribute('data-local-studio')
18
18
  : new URLSearchParams(location.search).get('token') ?? '';
19
19
  const data = document.getElementById('studio-host-parts');
20
20
  const hostParts = data ? JSON.parse(data.textContent) : undefined;
21
- mountStudio(root, { token, hostParts, locale: document.documentElement.lang || undefined });
21
+ const look = document.getElementById('studio-theme');
22
+ const theme = look ? JSON.parse(look.textContent) : undefined;
23
+ mountStudio(root, { token, hostParts, theme, locale: document.documentElement.lang || undefined });
22
24
  `;
23
25
  /** The page's script, bundled from the admin shell's source (esbuild, a build-time tool). */
24
26
  export async function bundlePage(cli = runningCli()) {
@@ -47,14 +49,15 @@ export async function pageScript(cli = runningCli(), locale) {
47
49
  }
48
50
  const escapeHtml = (s) => s.replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[c] ?? c);
49
51
  /** The page itself; mounting localizes the title to the studio's chosen language. */
50
- export const pageHtml = (product, hostParts, local = false) => `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(studioT('ui.title', { name: product }))}</title><link rel="stylesheet" href="${FONT_SHEET}" referrerpolicy="no-referrer"></head><body><div id="root"${local ? ' data-local-studio' : ''}></div>${hostPartsData(hostParts)}<script type="module" src="/page.js"></script></body></html>`;
52
+ export const pageHtml = (product, hostParts, local = false, theme) => `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(studioT('ui.title', { name: product }))}</title><link rel="stylesheet" href="${FONT_SHEET}" referrerpolicy="no-referrer"></head><body><div id="root"${local ? ' data-local-studio' : ''}></div>${hostPartsData(hostParts)}${jsonData('studio-theme', theme)}<script type="module" src="/page.js"></script></body></html>`;
51
53
  /** JSON data only; HTML delimiters cannot close this element or become executable markup. */
52
- function hostPartsData(sources) {
53
- if (!sources)
54
+ function jsonData(id, value) {
55
+ if (value === undefined)
54
56
  return '';
55
- const data = JSON.stringify(hostPartSourcesSchema.parse(sources)).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
56
- return `<script id="studio-host-parts" type="application/json">${data}</script>`;
57
+ const data = JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
58
+ return `<script id="${id}" type="application/json">${data}</script>`;
57
59
  }
60
+ const hostPartsData = (sources) => sources ? jsonData('studio-host-parts', hostPartSourcesSchema.parse(sources)) : '';
58
61
  /** Programmatic host setup only; reject unsafe maps before creating the server. */
59
62
  export function checkedHostParts(sources, signedIn) {
60
63
  if (sources === undefined)
@@ -42,7 +42,7 @@ export declare function plannedPlaceApproval(root: string, change: string): Prom
42
42
  revision: string;
43
43
  record: {
44
44
  approvals: {
45
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
45
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
46
46
  signatures: {
47
47
  by: string;
48
48
  at: string;
@@ -4,21 +4,31 @@ export interface StructureRow {
4
4
  who: string;
5
5
  place: string;
6
6
  main: boolean;
7
+ /** The change that adds this first screen, while its route does not exist yet. */
8
+ planned?: string;
7
9
  }
8
- /** Planning/build time only. Screen keys are inventory routes or console screen names. */
9
- export declare function parseStructure(text: string, screens?: readonly string[]): {
10
+ /** The screens each change file lists under `touches.screens`, by change id. */
11
+ export type ChangeScreens = ReadonlyMap<string, readonly string[]>;
12
+ /**
13
+ * Planning/build time only. Screen keys are inventory routes or console screen names, or a
14
+ * planned one (`/billing (planned, C-020)`) that the named change lists under its screens.
15
+ */
16
+ export declare function parseStructure(text: string, screens?: readonly string[], changes?: ChangeScreens): {
10
17
  rows: StructureRow[];
11
18
  notes: string[];
19
+ surface: "desktop" | "phone";
12
20
  };
13
21
  /** Reuse the inventory's discovery; no product code is loaded and no navigation is inferred. */
14
22
  export declare function readStructure(root: string): Promise<{
15
23
  rows: StructureRow[];
16
24
  notes: string[];
25
+ surface: "desktop" | "phone";
17
26
  } | null>;
18
27
  /** A malformed structure must not hide the rest of an older product's plan. */
19
28
  export declare function structureFacts(root: string): Promise<{
20
29
  rows: StructureRow[];
21
30
  notes: string[];
31
+ surface: "desktop" | "phone";
22
32
  } | {
23
33
  rows: never[];
24
34
  notes: never[];
@@ -13,8 +13,12 @@ export declare const en: {
13
13
  'structure.first': string;
14
14
  'structure.key': string;
15
15
  'structure.unknown': string;
16
+ 'structure.planned': string;
16
17
  'structure.repeated': string;
17
18
  'structure.main': string;
18
19
  'structure.empty': string;
19
20
  'structure.notes': string;
21
+ 'structure.surfaceMissing': string;
22
+ 'structure.surfaceFailed': string;
23
+ 'structure.surface': string;
20
24
  };
@@ -13,8 +13,12 @@ export const en = {
13
13
  'structure.first': '{row} needs a first screen. Choose where this section opens.',
14
14
  'structure.key': '{row}: {screen} is not a screen key. Use its route or console screen name.',
15
15
  'structure.unknown': '{row}: the first screen {screen} was not found in the product’s screens.',
16
+ 'structure.planned': '{row}: {screen} is planned in {change}, but that change does not list it under its screens. Add it there, or name an existing screen.',
16
17
  'structure.repeated': '{row}: another section has this name in the same place for the same people.',
17
18
  'structure.main': '{row}: Main must be yes or no. File order ranks the main sections.',
18
19
  'structure.empty': 'Name at least one section and its first screen.',
19
20
  'structure.notes': 'Add short notes for nested screens and their return targets, phone and wide screens.',
21
+ 'structure.surfaceMissing': 'Draft the structure first; then choose which surface comes first.',
22
+ 'structure.surfaceFailed': 'The surface could not be written. Try again.',
23
+ 'structure.surface': '{row}: write the Surface line once, before the table, as Surface: desktop or Surface: phone.',
20
24
  };
@@ -13,8 +13,12 @@ export declare const es: {
13
13
  'structure.first': string;
14
14
  'structure.key': string;
15
15
  'structure.unknown': string;
16
+ 'structure.planned': string;
16
17
  'structure.repeated': string;
17
18
  'structure.main': string;
18
19
  'structure.empty': string;
19
20
  'structure.notes': string;
21
+ 'structure.surfaceMissing': string;
22
+ 'structure.surfaceFailed': string;
23
+ 'structure.surface': string;
20
24
  };
@@ -13,8 +13,12 @@ export const es = {
13
13
  'structure.first': '{row} necesita una primera pantalla. Elige dónde se abre esta sección.',
14
14
  'structure.key': '{row}: {screen} no es una clave de pantalla. Usa su ruta o nombre de pantalla de consola.',
15
15
  'structure.unknown': '{row}: no se encontró la primera pantalla {screen} en las pantallas del producto.',
16
+ 'structure.planned': '{row}: {screen} está planificada en {change}, pero ese cambio no la incluye en sus pantallas. Añádela allí o usa una pantalla que ya exista.',
16
17
  'structure.repeated': '{row}: otra sección tiene este nombre en el mismo lugar para las mismas personas.',
17
18
  'structure.main': '{row}: Main debe ser yes o no. El orden del archivo ordena las secciones principales.',
18
19
  'structure.empty': 'Nombra al menos una sección y su primera pantalla.',
19
20
  'structure.notes': 'Añade notas breves para las pantallas anidadas y su regreso, teléfonos y pantallas anchas.',
21
+ 'structure.surfaceMissing': 'Primero haz el borrador de la estructura; luego elige qué superficie va primero.',
22
+ 'structure.surfaceFailed': 'No se pudo escribir la superficie. Inténtalo de nuevo.',
23
+ 'structure.surface': '{row}: escribe la línea Surface una vez, antes de la tabla, como Surface: desktop o Surface: phone.',
20
24
  };
@@ -1,9 +1,13 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { createI18n } from '@buffcore/i18n';
4
+ import { readChanges } from '../change-file.js';
4
5
  import { adminScreens, appScreens } from '../inventory-screens.js';
6
+ import { SURFACE_FIELD, SURFACE_LINE } from '../prototype/comp.js';
5
7
  import { en } from './plan-structure.en.js';
6
8
  import { es } from './plan-structure.es.js';
9
+ /** `/billing (planned, C-020)`: a first screen a change adds, before its route exists. */
10
+ const PLANNED = /^(.*\S) \(planned, (C-\d{3,})\)$/u;
7
11
  const messages = createI18n({ catalogs: [{ en, es }] });
8
12
  const columns = ['Section', 'First screen', 'Who', 'Place', 'Main'];
9
13
  function excerpt(value, limit = 60) {
@@ -25,6 +29,7 @@ function sourceName(line, t) {
25
29
  function structureLines(text, t, numbers) {
26
30
  const table = [];
27
31
  const notes = [];
32
+ let surface;
28
33
  let state = 'before';
29
34
  for (const [index, line] of text
30
35
  .replace(/^\uFEFF/, '')
@@ -39,7 +44,13 @@ function structureLines(text, t, numbers) {
39
44
  state = 'after';
40
45
  }
41
46
  else if (state === 'before' && /^# [\p{L}\p{N}][^<>|]*$/u.test(line)) {
42
- // Only titles and empty lines may precede the table.
47
+ // Only titles, the surface and empty lines may precede the table.
48
+ }
49
+ else if (state === 'before' && SURFACE_FIELD.test(line)) {
50
+ const found = SURFACE_LINE.exec(line);
51
+ if (surface || !found)
52
+ throw new Error(t('structure.surface', { row }));
53
+ surface = found[1]?.toLowerCase();
43
54
  }
44
55
  else if (/^\|.*(?<!\\)\|$/.test(line)) {
45
56
  if (state === 'after')
@@ -55,7 +66,7 @@ function structureLines(text, t, numbers) {
55
66
  throw new Error(t(state === 'before' ? 'structure.before' : 'structure.noteShape', { row }));
56
67
  }
57
68
  }
58
- return { table, notes };
69
+ return { table, notes, surface: surface ?? 'desktop' };
59
70
  }
60
71
  const cells = (line) => line
61
72
  .split(/(?<!\\)\|/)
@@ -83,16 +94,19 @@ function checkColumns(table, t, numbers) {
83
94
  }));
84
95
  }
85
96
  }
86
- function structureRows(table, t, screens) {
97
+ function structureRows(table, t, screens, changes) {
87
98
  const rows = [];
88
99
  const seen = new Set();
89
100
  for (const line of table.slice(2)) {
90
101
  // Escapes are text only in DATA cells, never in header/separator comparisons.
91
102
  const values = cells(line.text).map((cell) => cell.replace(/\\\|/g, '|'));
92
- const [section = '', screen = '', who = '', place = '', main = ''] = values;
103
+ const [section = '', cell = '', who = '', place = '', main = ''] = values;
104
+ const plan = PLANNED.exec(cell);
105
+ const screen = plan?.[1] ?? cell;
106
+ const change = plan?.[2] ?? '';
93
107
  const row = `${sourceName(line, t)}${section ? `: ${excerpt(section)}` : ''}`;
94
108
  const fail = (key) => {
95
- throw new Error(t(key, { row, screen: excerpt(screen) }));
109
+ throw new Error(t(key, { row, screen: excerpt(screen), change }));
96
110
  };
97
111
  if (values.length !== 5 || !section || !who || !place)
98
112
  fail('structure.fields');
@@ -101,7 +115,12 @@ function structureRows(table, t, screens) {
101
115
  if (!/^(?:\/|\/?[\p{L}\p{N}_[\]().-]+(?:\/[\p{L}\p{N}_[\]().-]+)*)$/u.test(screen) ||
102
116
  screen.split('/').some((part) => part === '.' || part === '..'))
103
117
  fail('structure.key');
104
- if (screens?.length && !screens.includes(screen))
118
+ // A planned row turns ordinary once its route exists; until then its change must list it.
119
+ const exists = !!screens?.length && screens.includes(screen);
120
+ const planned = plan && !exists ? change : undefined;
121
+ if (planned && changes && !changes.get(planned)?.includes(screen))
122
+ fail('structure.planned');
123
+ if (!planned && screens?.length && !exists)
105
124
  fail('structure.unknown');
106
125
  const identity = JSON.stringify([
107
126
  section.toLowerCase(),
@@ -113,23 +132,33 @@ function structureRows(table, t, screens) {
113
132
  if (!/^(yes|no)$/.test(main))
114
133
  fail('structure.main');
115
134
  seen.add(identity);
116
- rows.push({ section, screen, who, place, main: main === 'yes' });
135
+ rows.push({
136
+ section,
137
+ screen,
138
+ who,
139
+ place,
140
+ main: main === 'yes',
141
+ ...(planned ? { planned } : {}),
142
+ });
117
143
  }
118
144
  if (!rows.length)
119
145
  throw new Error(t('structure.empty'));
120
146
  return rows;
121
147
  }
122
- /** Planning/build time only. Screen keys are inventory routes or console screen names. */
123
- export function parseStructure(text, screens) {
148
+ /**
149
+ * Planning/build time only. Screen keys are inventory routes or console screen names, or a
150
+ * planned one (`/billing (planned, C-020)`) that the named change lists under its screens.
151
+ */
152
+ export function parseStructure(text, screens, changes) {
124
153
  const locale = /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
125
154
  const t = (key, values) => messages.t(locale, key, values);
126
155
  const numbers = new Intl.NumberFormat(locale);
127
- const { table, notes } = structureLines(text, t, numbers);
156
+ const { table, notes, surface } = structureLines(text, t, numbers);
128
157
  checkColumns(table, t, numbers);
129
- const rows = structureRows(table, t, screens);
158
+ const rows = structureRows(table, t, screens, changes);
130
159
  if (!notes.length)
131
160
  throw new Error(t('structure.notes'));
132
- return { rows, notes };
161
+ return { rows, notes, surface };
133
162
  }
134
163
  /** Reuse the inventory's discovery; no product code is loaded and no navigation is inferred. */
135
164
  export async function readStructure(root) {
@@ -140,12 +169,17 @@ export async function readStructure(root) {
140
169
  });
141
170
  if (text === null)
142
171
  return null;
143
- const [app, admin] = await Promise.all([appScreens(root, root), adminScreens(root, root)]);
172
+ const [app, admin, planned] = await Promise.all([
173
+ appScreens(root, root),
174
+ adminScreens(root, root),
175
+ readChanges(root),
176
+ ]);
144
177
  const screens = [
145
178
  ...app.map((item) => item.route),
146
179
  ...admin.flatMap((item) => [item.path, item.screen]),
147
180
  ];
148
- return parseStructure(text, screens);
181
+ const changes = new Map(planned.changes.map((c) => [c.id, c.touches.screens]));
182
+ return parseStructure(text, screens, changes);
149
183
  }
150
184
  /** A malformed structure must not hide the rest of an older product's plan. */
151
185
  export async function structureFacts(root) {
@@ -0,0 +1,7 @@
1
+ import { type PrototypeCompReply } from '@buffcore/contracts/workbench';
2
+ import type { ImageType, UiRoute } from './routes.ts';
3
+ export declare const pictureType: (file: string) => ImageType | undefined;
4
+ export declare function compReply(root: string, hosted?: boolean): Promise<PrototypeCompReply>;
5
+ /** The file a picture name stands for, or undefined: only the comp's own shots and the references. */
6
+ export declare function compPicture(root: string, name: string, hosted?: boolean): Promise<string | undefined>;
7
+ export declare function prototypeCompRoutes(root: string): UiRoute[];
@@ -0,0 +1,109 @@
1
+ // The comp page's reads: the newest comp snapshot's screens, the references beside them and the
2
+ // approval; and each picture by its name (never by a path from the request).
3
+ import { readFile } from 'node:fs/promises';
4
+ import { extname, join } from 'node:path';
5
+ import { frameSizes } from '@buffcore/config';
6
+ import { workbenchApi } from '@buffcore/contracts/workbench';
7
+ import { loadProduct } from '../../project.js';
8
+ import { referencePictures } from '../design/references.js';
9
+ import { compDir, firstSurface, newestComp } from '../prototype/comp.js';
10
+ import { compApproved, readCompApproval } from '../prototype/comp-record.js';
11
+ import { snapshotsDir } from '../prototype/report.js';
12
+ const MAX = 12;
13
+ /** The picture types the page shows, by extension; any other file is never served. */
14
+ const TYPES = {
15
+ '.png': 'image/png',
16
+ '.jpg': 'image/jpeg',
17
+ '.jpeg': 'image/jpeg',
18
+ '.webp': 'image/webp',
19
+ '.gif': 'image/gif',
20
+ '.avif': 'image/avif',
21
+ };
22
+ export const pictureType = (file) => TYPES[extname(file).toLowerCase()];
23
+ const SHOT = /^[0-9a-f]{7,64}\/[^/\\]+\.png$/;
24
+ /** A comp screen's light and dark pictures: the product's theme, as the snapshot shot them. */
25
+ function screenShots(scene) {
26
+ const looks = Object.keys(scene.screenshots ?? {});
27
+ const dark = looks.find((look) => look.endsWith('.dark'));
28
+ const light = dark && looks.includes(dark.slice(0, -5)) ? dark.slice(0, -5) : looks[0];
29
+ return { light, dark };
30
+ }
31
+ async function desktopWidth(root) {
32
+ try {
33
+ return frameSizes(await loadProduct(root)).desktop.width;
34
+ }
35
+ catch {
36
+ return frameSizes().desktop.width;
37
+ }
38
+ }
39
+ /**
40
+ * The reference files the page may show, in their places: on the person's own computer (the local
41
+ * studio) any listed picture; under a host only those inside the product's folder.
42
+ */
43
+ async function shownReferences(root, hosted) {
44
+ return (await referencePictures(root))
45
+ .slice(0, MAX)
46
+ .map(({ file, inside }) => file && (inside || !hosted) && pictureType(file) ? file : undefined);
47
+ }
48
+ export async function compReply(root, hosted = false) {
49
+ const surface = firstSurface(root);
50
+ const comp = newestComp(root);
51
+ const record = readCompApproval(root);
52
+ const references = await shownReferences(root, hosted);
53
+ const screens = (comp?.report.scenes ?? []).slice(0, MAX).map((scene, index) => {
54
+ const { light, dark } = screenShots(scene);
55
+ return {
56
+ key: scene.key.slice(0, 100),
57
+ title: String(scene.title ?? scene.key).slice(0, 200),
58
+ ...(light ? { light: `screen-${index}-light` } : {}),
59
+ ...(dark ? { dark: `screen-${index}-dark` } : {}),
60
+ };
61
+ });
62
+ return {
63
+ surface,
64
+ width: surface === 'phone' ? frameSizes().phone.width : await desktopWidth(root),
65
+ screens,
66
+ references: references.map((file, index) => (file ? `reference-${index}` : null)),
67
+ ...(comp ? { fingerprint: comp.fingerprint } : {}),
68
+ approved: compApproved(record, comp),
69
+ approval: record?.approval ?? null,
70
+ };
71
+ }
72
+ /** The file a picture name stands for, or undefined: only the comp's own shots and the references. */
73
+ export async function compPicture(root, name, hosted = false) {
74
+ const screen = /^screen-(\d{1,2})-(light|dark)$/.exec(name);
75
+ if (screen) {
76
+ const scene = newestComp(root)?.report.scenes[Number(screen[1])];
77
+ if (!scene)
78
+ return;
79
+ const look = screenShots(scene)[screen[2]];
80
+ const path = look ? scene.screenshots[look] : undefined;
81
+ return path && SHOT.test(path) ? join(compDir(snapshotsDir(root)), path) : undefined;
82
+ }
83
+ const reference = /^reference-(\d{1,2})$/.exec(name);
84
+ if (reference)
85
+ return (await shownReferences(root, hosted))[Number(reference[1])];
86
+ }
87
+ export function prototypeCompRoutes(root) {
88
+ return [
89
+ {
90
+ method: 'GET',
91
+ path: workbenchApi.prototypeComp,
92
+ right: 'read:runs',
93
+ handle: async ({ hosted }) => ({ status: 200, body: await compReply(root, !!hosted) }),
94
+ },
95
+ {
96
+ method: 'GET',
97
+ path: `${workbenchApi.prototypeComp}/picture/:name`,
98
+ right: 'read:runs',
99
+ handle: async ({ params, hosted }) => {
100
+ const file = await compPicture(root, params.name ?? '', !!hosted);
101
+ const type = file ? pictureType(file) : undefined;
102
+ const bytes = file && type ? await readFile(file).catch(() => undefined) : undefined;
103
+ return bytes && type
104
+ ? { status: 200, body: bytes, type }
105
+ : { status: 404, body: { error: 'missing' } };
106
+ },
107
+ },
108
+ ];
109
+ }
@@ -69,14 +69,16 @@ export declare function planPrototypeOnMain(root: string, plan: PlanFacts | unde
69
69
  who: string;
70
70
  place: string;
71
71
  main: boolean;
72
+ planned?: string | undefined;
72
73
  }[];
73
74
  notes: string[];
75
+ surface?: "desktop" | "phone" | undefined;
74
76
  problem?: string | undefined;
75
77
  } | null | undefined;
76
78
  themeDirection?: string | undefined;
77
79
  themeVoice?: string | undefined;
78
80
  brand: {
79
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
81
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
80
82
  signatures: {
81
83
  by: string;
82
84
  at: string;
@@ -11,10 +11,15 @@ import { writeSync } from 'node:fs';
11
11
  import { pathToFileURL } from 'node:url';
12
12
  try {
13
13
  const prototype = (await import(__rewriteRelativeImportExtension(pathToFileURL(process.argv[2] ?? '').href))).default;
14
- const scenes = prototype.scenes.map(({ key, title, surface }) => ({
14
+ // The comp's scenes (`comp/`) are snapshotted apart and never listed among the scenes.
15
+ const scenes = prototype.scenes
16
+ .filter(({ key }) => !(typeof key === 'string' && key.startsWith('comp/')))
17
+ .map(({ key, title, surface, view }) => ({
15
18
  key,
16
19
  title,
17
20
  surface,
21
+ // A named view only; a component has no name the studio can follow to its files.
22
+ ...(typeof view === 'string' ? { view } : {}),
18
23
  }));
19
24
  writeSync(3, JSON.stringify({ ok: true, scenes }));
20
25
  process.exit(0);