@buffcore/cli 0.8.41 → 0.8.42

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 (164) hide show
  1. package/CHANGELOG.md +25 -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 +3 -0
  17. package/dist/commands/design/references.js +25 -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/port-claims.d.ts +23 -0
  26. package/dist/commands/port-claims.js +95 -0
  27. package/dist/commands/prototype/browser.d.ts +9 -4
  28. package/dist/commands/prototype/browser.js +26 -18
  29. package/dist/commands/prototype/export-base.d.ts +27 -0
  30. package/dist/commands/prototype/export-base.js +80 -0
  31. package/dist/commands/prototype/export.d.ts +3 -2
  32. package/dist/commands/prototype/export.js +13 -6
  33. package/dist/commands/prototype/index.js +1 -0
  34. package/dist/commands/prototype/media-ready.d.ts +8 -0
  35. package/dist/commands/prototype/media-ready.js +36 -0
  36. package/dist/commands/prototype/messages.en.d.ts +6 -0
  37. package/dist/commands/prototype/messages.en.js +6 -0
  38. package/dist/commands/prototype/messages.js +6 -0
  39. package/dist/commands/prototype/scene.d.ts +3 -1
  40. package/dist/commands/prototype/scene.js +22 -6
  41. package/dist/commands/prototype/snapshot-inputs.js +35 -7
  42. package/dist/commands/prototype/snapshot-setup.d.ts +1 -1
  43. package/dist/commands/prototype/snapshot-setup.js +2 -1
  44. package/dist/commands/prototype/snapshot.d.ts +2 -0
  45. package/dist/commands/prototype/snapshot.js +2 -1
  46. package/dist/commands/ui/chat/allow-folder.js +23 -77
  47. package/dist/commands/ui/chat/claude-permissions.d.ts +21 -0
  48. package/dist/commands/ui/chat/claude-permissions.js +69 -0
  49. package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
  50. package/dist/commands/ui/chat/codex-overrides.js +2 -1
  51. package/dist/commands/ui/chat/codex-permissions.d.ts +12 -0
  52. package/dist/commands/ui/chat/codex-permissions.js +97 -0
  53. package/dist/commands/ui/chat/command-parts.d.ts +33 -0
  54. package/dist/commands/ui/chat/command-parts.js +219 -0
  55. package/dist/commands/ui/chat/command-wrappers.d.ts +21 -0
  56. package/dist/commands/ui/chat/command-wrappers.js +100 -0
  57. package/dist/commands/ui/chat/design-deletes.d.ts +1 -0
  58. package/dist/commands/ui/chat/design-deletes.js +39 -0
  59. package/dist/commands/ui/chat/launch-input.d.ts +4 -2
  60. package/dist/commands/ui/chat/launch-input.js +16 -3
  61. package/dist/commands/ui/chat/limit-mentions.d.ts +5 -0
  62. package/dist/commands/ui/chat/limit-mentions.js +74 -0
  63. package/dist/commands/ui/chat/limit-patterns.d.ts +15 -0
  64. package/dist/commands/ui/chat/limit-patterns.js +182 -0
  65. package/dist/commands/ui/chat/limits-hook.d.ts +1 -0
  66. package/dist/commands/ui/chat/limits-hook.js +30 -0
  67. package/dist/commands/ui/chat/limits.d.ts +37 -0
  68. package/dist/commands/ui/chat/limits.en.d.ts +18 -0
  69. package/dist/commands/ui/chat/limits.en.js +18 -0
  70. package/dist/commands/ui/chat/limits.es.d.ts +2 -0
  71. package/dist/commands/ui/chat/limits.es.js +17 -0
  72. package/dist/commands/ui/chat/limits.js +224 -0
  73. package/dist/commands/ui/chat/local-settings.d.ts +17 -0
  74. package/dist/commands/ui/chat/local-settings.js +73 -0
  75. package/dist/commands/ui/chat/opencode-config.d.ts +22 -0
  76. package/dist/commands/ui/chat/opencode-config.js +83 -0
  77. package/dist/commands/ui/chat/parse-claude.js +18 -2
  78. package/dist/commands/ui/chat/permission-ask.d.ts +44 -0
  79. package/dist/commands/ui/chat/permission-ask.js +142 -0
  80. package/dist/commands/ui/chat/permission-channel.d.ts +18 -0
  81. package/dist/commands/ui/chat/permission-channel.js +67 -0
  82. package/dist/commands/ui/chat/permission-route.d.ts +10 -0
  83. package/dist/commands/ui/chat/permission-route.js +47 -0
  84. package/dist/commands/ui/chat/permission-tool.d.ts +1 -0
  85. package/dist/commands/ui/chat/permission-tool.js +86 -0
  86. package/dist/commands/ui/chat/permissions.d.ts +11 -12
  87. package/dist/commands/ui/chat/permissions.js +20 -102
  88. package/dist/commands/ui/chat/planning-limits.d.ts +12 -0
  89. package/dist/commands/ui/chat/planning-limits.js +31 -0
  90. package/dist/commands/ui/chat/process.js +4 -1
  91. package/dist/commands/ui/chat/prompt.d.ts +8 -1
  92. package/dist/commands/ui/chat/prompt.en.d.ts +4 -0
  93. package/dist/commands/ui/chat/prompt.en.js +4 -0
  94. package/dist/commands/ui/chat/prompt.es.d.ts +4 -0
  95. package/dist/commands/ui/chat/prompt.es.js +4 -0
  96. package/dist/commands/ui/chat/prompt.js +18 -50
  97. package/dist/commands/ui/chat/recorded-turn.js +3 -0
  98. package/dist/commands/ui/chat/routes.js +2 -0
  99. package/dist/commands/ui/chat/secret-folders.d.ts +16 -0
  100. package/dist/commands/ui/chat/secret-folders.js +35 -0
  101. package/dist/commands/ui/chat/stdin-shells.d.ts +8 -0
  102. package/dist/commands/ui/chat/stdin-shells.js +102 -0
  103. package/dist/commands/ui/chat/step-rules.d.ts +13 -0
  104. package/dist/commands/ui/chat/step-rules.js +47 -0
  105. package/dist/commands/ui/chat/store.js +11 -2
  106. package/dist/commands/ui/chat/stream.en.d.ts +6 -0
  107. package/dist/commands/ui/chat/stream.en.js +6 -0
  108. package/dist/commands/ui/chat/stream.es.d.ts +6 -0
  109. package/dist/commands/ui/chat/stream.es.js +6 -0
  110. package/dist/commands/ui/chat/stream.js +4 -1
  111. package/dist/commands/ui/chat/turn-guard.d.ts +25 -0
  112. package/dist/commands/ui/chat/turn-guard.js +74 -0
  113. package/dist/commands/ui/chat/turn-input.d.ts +3 -2
  114. package/dist/commands/ui/chat/turn-input.js +3 -1
  115. package/dist/commands/ui/chat/turn-scenes.d.ts +19 -0
  116. package/dist/commands/ui/chat/turn-scenes.js +44 -0
  117. package/dist/commands/ui/chat/turn-state.d.ts +6 -0
  118. package/dist/commands/ui/chat/turn.js +8 -3
  119. package/dist/commands/ui/level-route.js +8 -3
  120. package/dist/commands/ui/page.d.ts +19 -1
  121. package/dist/commands/ui/page.js +9 -6
  122. package/dist/commands/ui/plan-structure.d.ts +9 -2
  123. package/dist/commands/ui/plan-structure.en.d.ts +1 -0
  124. package/dist/commands/ui/plan-structure.en.js +1 -0
  125. package/dist/commands/ui/plan-structure.es.d.ts +1 -0
  126. package/dist/commands/ui/plan-structure.es.js +1 -0
  127. package/dist/commands/ui/plan-structure.js +36 -10
  128. package/dist/commands/ui/prototype-main.d.ts +1 -0
  129. package/dist/commands/ui/prototype-scenes-child.js +3 -1
  130. package/dist/commands/ui/prototype-scenes-read.d.ts +1 -0
  131. package/dist/commands/ui/prototype-scenes-route.js +7 -1
  132. package/dist/commands/ui/save-commit.js +6 -2
  133. package/dist/commands/ui/server-options.js +2 -0
  134. package/dist/commands/ui/server.d.ts +5 -22
  135. package/dist/commands/ui/server.js +3 -45
  136. package/dist/commands/ui/snapshot-runners.d.ts +22 -0
  137. package/dist/commands/ui/snapshot-runners.js +45 -0
  138. package/dist/commands/ui/studio-routes.d.ts +1 -0
  139. package/dist/commands/ui/studio-routes.js +1 -0
  140. package/dist/commands/ui/studio-state.d.ts +3 -0
  141. package/dist/commands/ui/studio-state.js +1 -0
  142. package/dist/commands/ui/studio.en.d.ts +13 -0
  143. package/dist/commands/ui/studio.en.js +13 -0
  144. package/dist/commands/ui/studio.es.d.ts +13 -0
  145. package/dist/commands/ui/studio.es.js +13 -0
  146. package/dist/commands/ui/theme-option.d.ts +8 -0
  147. package/dist/commands/ui/theme-option.js +40 -0
  148. package/dist/commands/ui/theme-values.d.ts +5 -0
  149. package/dist/commands/ui/theme-values.js +113 -0
  150. package/dist/ui/page.js +93 -93
  151. package/docs/PROTOTYPE.md +4 -1
  152. package/docs/WORKBENCH.md +76 -22
  153. package/package.json +11 -11
  154. package/skills/ape-critique/SKILL.md +8 -4
  155. package/skills/ape-design-system/SKILL.md +3 -3
  156. package/skills/ape-plan-change/SKILL.md +7 -3
  157. package/skills/ape-prototype/SKILL.md +8 -1
  158. package/templates/example/apps/app/src/i18n/en.ts +2 -0
  159. package/templates/example/apps/app/src/i18n/es.json +2 -0
  160. package/templates/product/apps/admin/src/fonts.ts +2 -1
  161. package/templates/product/apps/app/src/fonts.ts +5 -1
  162. package/templates/product/apps/app/src/i18n/en.ts +2 -0
  163. package/templates/product/apps/app/src/i18n/es.json +2 -0
  164. package/templates/product/prototype/journeys.ts +3 -0
@@ -4,9 +4,16 @@ 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[];
12
19
  };
@@ -13,6 +13,7 @@ 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;
@@ -13,6 +13,7 @@ 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.',
@@ -13,6 +13,7 @@ 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;
@@ -13,6 +13,7 @@ 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.',
@@ -1,9 +1,12 @@
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';
5
6
  import { en } from './plan-structure.en.js';
6
7
  import { es } from './plan-structure.es.js';
8
+ /** `/billing (planned, C-020)`: a first screen a change adds, before its route exists. */
9
+ const PLANNED = /^(.*\S) \(planned, (C-\d{3,})\)$/u;
7
10
  const messages = createI18n({ catalogs: [{ en, es }] });
8
11
  const columns = ['Section', 'First screen', 'Who', 'Place', 'Main'];
9
12
  function excerpt(value, limit = 60) {
@@ -83,16 +86,19 @@ function checkColumns(table, t, numbers) {
83
86
  }));
84
87
  }
85
88
  }
86
- function structureRows(table, t, screens) {
89
+ function structureRows(table, t, screens, changes) {
87
90
  const rows = [];
88
91
  const seen = new Set();
89
92
  for (const line of table.slice(2)) {
90
93
  // Escapes are text only in DATA cells, never in header/separator comparisons.
91
94
  const values = cells(line.text).map((cell) => cell.replace(/\\\|/g, '|'));
92
- const [section = '', screen = '', who = '', place = '', main = ''] = values;
95
+ const [section = '', cell = '', who = '', place = '', main = ''] = values;
96
+ const plan = PLANNED.exec(cell);
97
+ const screen = plan?.[1] ?? cell;
98
+ const change = plan?.[2] ?? '';
93
99
  const row = `${sourceName(line, t)}${section ? `: ${excerpt(section)}` : ''}`;
94
100
  const fail = (key) => {
95
- throw new Error(t(key, { row, screen: excerpt(screen) }));
101
+ throw new Error(t(key, { row, screen: excerpt(screen), change }));
96
102
  };
97
103
  if (values.length !== 5 || !section || !who || !place)
98
104
  fail('structure.fields');
@@ -101,7 +107,12 @@ function structureRows(table, t, screens) {
101
107
  if (!/^(?:\/|\/?[\p{L}\p{N}_[\]().-]+(?:\/[\p{L}\p{N}_[\]().-]+)*)$/u.test(screen) ||
102
108
  screen.split('/').some((part) => part === '.' || part === '..'))
103
109
  fail('structure.key');
104
- if (screens?.length && !screens.includes(screen))
110
+ // A planned row turns ordinary once its route exists; until then its change must list it.
111
+ const exists = !!screens?.length && screens.includes(screen);
112
+ const planned = plan && !exists ? change : undefined;
113
+ if (planned && changes && !changes.get(planned)?.includes(screen))
114
+ fail('structure.planned');
115
+ if (!planned && screens?.length && !exists)
105
116
  fail('structure.unknown');
106
117
  const identity = JSON.stringify([
107
118
  section.toLowerCase(),
@@ -113,20 +124,30 @@ function structureRows(table, t, screens) {
113
124
  if (!/^(yes|no)$/.test(main))
114
125
  fail('structure.main');
115
126
  seen.add(identity);
116
- rows.push({ section, screen, who, place, main: main === 'yes' });
127
+ rows.push({
128
+ section,
129
+ screen,
130
+ who,
131
+ place,
132
+ main: main === 'yes',
133
+ ...(planned ? { planned } : {}),
134
+ });
117
135
  }
118
136
  if (!rows.length)
119
137
  throw new Error(t('structure.empty'));
120
138
  return rows;
121
139
  }
122
- /** Planning/build time only. Screen keys are inventory routes or console screen names. */
123
- export function parseStructure(text, screens) {
140
+ /**
141
+ * Planning/build time only. Screen keys are inventory routes or console screen names, or a
142
+ * planned one (`/billing (planned, C-020)`) that the named change lists under its screens.
143
+ */
144
+ export function parseStructure(text, screens, changes) {
124
145
  const locale = /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
125
146
  const t = (key, values) => messages.t(locale, key, values);
126
147
  const numbers = new Intl.NumberFormat(locale);
127
148
  const { table, notes } = structureLines(text, t, numbers);
128
149
  checkColumns(table, t, numbers);
129
- const rows = structureRows(table, t, screens);
150
+ const rows = structureRows(table, t, screens, changes);
130
151
  if (!notes.length)
131
152
  throw new Error(t('structure.notes'));
132
153
  return { rows, notes };
@@ -140,12 +161,17 @@ export async function readStructure(root) {
140
161
  });
141
162
  if (text === null)
142
163
  return null;
143
- const [app, admin] = await Promise.all([appScreens(root, root), adminScreens(root, root)]);
164
+ const [app, admin, planned] = await Promise.all([
165
+ appScreens(root, root),
166
+ adminScreens(root, root),
167
+ readChanges(root),
168
+ ]);
144
169
  const screens = [
145
170
  ...app.map((item) => item.route),
146
171
  ...admin.flatMap((item) => [item.path, item.screen]),
147
172
  ];
148
- return parseStructure(text, screens);
173
+ const changes = new Map(planned.changes.map((c) => [c.id, c.touches.screens]));
174
+ return parseStructure(text, screens, changes);
149
175
  }
150
176
  /** A malformed structure must not hide the rest of an older product's plan. */
151
177
  export async function structureFacts(root) {
@@ -69,6 +69,7 @@ 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[];
74
75
  problem?: string | undefined;
@@ -11,10 +11,12 @@ 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
+ const scenes = prototype.scenes.map(({ key, title, surface, view }) => ({
15
15
  key,
16
16
  title,
17
17
  surface,
18
+ // A named view only; a component has no name the studio can follow to its files.
19
+ ...(typeof view === 'string' ? { view } : {}),
18
20
  }));
19
21
  writeSync(3, JSON.stringify({ ok: true, scenes }));
20
22
  process.exit(0);
@@ -7,6 +7,7 @@ export declare function prototypeSceneReader(root: string): () => Promise<{
7
7
  key: string;
8
8
  title: string;
9
9
  surface: "admin" | "app";
10
+ view?: string | undefined;
10
11
  }[];
11
12
  } | {
12
13
  ok: false;
@@ -1,5 +1,11 @@
1
1
  import { workbenchApi } from '@buffcore/contracts/workbench';
2
2
  import { prototypeSceneReader } from './prototype-scenes-read.js';
3
+ /** The route answers scene identities only: a scene's view name stays inside the studio. */
4
+ function identities(reply) {
5
+ return reply.ok
6
+ ? { ok: true, scenes: reply.scenes.map(({ key, title, surface }) => ({ key, title, surface })) }
7
+ : reply;
8
+ }
3
9
  /** Loading project code needs snapshot authority before the reader can run. */
4
10
  export function prototypeScenesRoute(root) {
5
11
  const read = prototypeSceneReader(root);
@@ -9,6 +15,6 @@ export function prototypeScenesRoute(root) {
9
15
  readable: true,
10
16
  right: 'build',
11
17
  origin: true,
12
- handle: async () => ({ status: 200, body: await read() }),
18
+ handle: async () => ({ status: 200, body: identities(await read()) }),
13
19
  };
14
20
  }
@@ -30,10 +30,14 @@ async function workingChanged(git, index, files) {
30
30
  const changed = new Set(diff.split('\0'));
31
31
  return files.some((file) => changed.has(file));
32
32
  }
33
- /** Read the exact saved tree, never a working file that can change after the snapshot. */
33
+ /**
34
+ * Read the exact saved tree, never a working file that can change after the snapshot. Never ask
35
+ * counts as part of the level: a generic save may change neither.
36
+ */
34
37
  async function levelAt(git, ref, path) {
35
38
  try {
36
- return parseCommittedAgents(await git(['show', `${ref}:./${path}`])).level;
39
+ const file = parseCommittedAgents(await git(['show', `${ref}:./${path}`]));
40
+ return file.neverAsk ? `${file.level}+neverAsk` : file.level;
37
41
  }
38
42
  catch (error) {
39
43
  if (error.code === 'ETIMEDOUT')
@@ -3,6 +3,7 @@ import { saveHostT, saveTimeout } from './host-save.js';
3
3
  import { mergeT, mergeTimeout } from './merge-authority.js';
4
4
  import { checkedOutside } from './outside.js';
5
5
  import { checkedHostParts } from './page.js';
6
+ import { checkedTheme } from './theme-option.js';
6
7
  /** Validate host-owned registration before the server starts listening. */
7
8
  export function checkedUiOptions(input) {
8
9
  if (input.approval && !input.signIn)
@@ -21,5 +22,6 @@ export function checkedUiOptions(input) {
21
22
  contained: input.contained === true,
22
23
  hostParts: checkedHostParts(input.hostParts, signedIn),
23
24
  outside: checkedOutside(input.outside, signedIn),
25
+ theme: checkedTheme(input.theme),
24
26
  };
25
27
  }
@@ -1,17 +1,16 @@
1
1
  import { type Server } from 'node:http';
2
- import type { CommandRun, PlannedChange } from '@buffcore/admin-shell/workbench';
3
- import { type HostPartSources } from '@buffcore/contracts/workbench';
2
+ import type { PlannedChange } from '@buffcore/admin-shell/workbench';
4
3
  import type { HostApproval } from './approval-authority.ts';
5
4
  import type { TurnMigrations } from './chat/migration-turn.ts';
6
5
  import { type LocalCode } from './code.ts';
7
- import { type CommandSpec } from './commands.ts';
6
+ import type { CommandSpec } from './commands.ts';
8
7
  import { type HostLevel, type SignIn } from './host.ts';
9
8
  import type { SaveConfiguration } from './host-save.ts';
10
9
  import type { HostMerge } from './merge-authority.ts';
11
10
  import type { OutsideConfiguration } from './outside.ts';
11
+ import { type HostPageOptions } from './page.ts';
12
12
  import { type UiRoute } from './routes.ts';
13
13
  import type { Runner } from './runner.ts';
14
- import { type DiagnosticRun } from './snapshot-diagnostics.ts';
15
14
  import type { Stack } from './stack.ts';
16
15
  export type { Machine, Right, Viewer } from '@buffcore/contracts/workbench';
17
16
  export type { ApprovalArtifact, HostApproval, HostApprovalAnswer } from './approval-authority.ts';
@@ -28,6 +27,7 @@ export { type AgentTurn, Runner, type Start } from './runner.ts';
28
27
  export { coreRoutes, stateAccess } from './server-core.ts';
29
28
  export { listenLocal } from './server-request.ts';
30
29
  export type { DiagnosticRun, StoredRuns } from './snapshot-diagnostics.ts';
30
+ export { recordPrototypeRun, runPrototypeSnapshot } from './snapshot-runners.ts';
31
31
  export { diagnosticsView, runView, visibleRuns } from './snapshot-view.ts';
32
32
  export { Stack } from './stack.ts';
33
33
  export { studioRoutes } from './studio-routes.ts';
@@ -39,7 +39,7 @@ export interface Plan {
39
39
  /** The product has `prototype/home.tsx`. */
40
40
  prototypeHome: boolean;
41
41
  }
42
- export interface UiServerOptions extends SaveConfiguration, OutsideConfiguration {
42
+ export interface UiServerOptions extends SaveConfiguration, OutsideConfiguration, HostPageOptions {
43
43
  turnMigrations?: TurnMigrations;
44
44
  snapshotLimits?: CommandSpec['limits'];
45
45
  /** Required for local use; ignored when the host supplies signIn. */
@@ -51,8 +51,6 @@ export interface UiServerOptions extends SaveConfiguration, OutsideConfiguration
51
51
  approval?: HostApproval;
52
52
  merge?: HostMerge;
53
53
  mergeTimeoutMs?: number;
54
- /** Trusted modules served by the host, at five existing places. Requires signIn. */
55
- hostParts?: HostPartSources;
56
54
  /** Host-owned isolation boundary; never inferred from product inputs. */
57
55
  contained?: boolean;
58
56
  product: string;
@@ -65,20 +63,5 @@ export interface UiServerOptions extends SaveConfiguration, OutsideConfiguration
65
63
  /** More of the API: each part of the workbench adds its routes (routes.ts). */
66
64
  routes?: readonly UiRoute[];
67
65
  }
68
- type DiagnosticId = 'snapshot' | 'post-merge' | `snapshot:${string}` | `post-merge:${string}` | `snapshot-check:${string}` | `compare:${string}`;
69
- export declare function recordPrototypeRun<T extends string>(root: string, id: T, run?: T extends DiagnosticId ? DiagnosticRun : CommandRun | DiagnosticRun): void;
70
- /** Autopilot starts its own fresh run on the same runner as the person's Snapshot command. */
71
- export declare function runPrototypeSnapshot(root: string, signal?: AbortSignal, id?: string, options?: {
72
- cwd: string;
73
- scenes?: readonly string[];
74
- commit?: string;
75
- command?: string;
76
- json?: boolean;
77
- limits?: CommandSpec['limits'];
78
- snapshotRunId?: string;
79
- /** Keep only the problems the result lists, not the progress lines the tool printed. */
80
- listedOnly?: boolean;
81
- onSnapshotProgress?: CommandSpec['onSnapshotProgress'];
82
- }): Promise<DiagnosticRun | undefined>;
83
66
  /** The server, not yet listening. Local callers use listenLocal; a host owns its listener. */
84
67
  export declare function createUiServer(input: UiServerOptions): Server;
@@ -1,15 +1,10 @@
1
1
  // The workbench's page and JSON API: local Host/token guards, or the host's sign-in per request.
2
- import { existsSync, realpathSync } from 'node:fs';
3
2
  import { createServer } from 'node:http';
4
- import { resolve } from 'node:path';
5
3
  import { workbenchApi } from '@buffcore/contracts/workbench';
6
4
  import { migrationRoute } from '../migrate-create-protocol.js';
7
5
  import { MilestoneVersionsPending } from '../prototype/milestone-key.js';
8
- import { snapshotsDir } from '../prototype/report.js';
9
- import { cleanSnapshotChild } from '../prototype/snapshot-storage.js';
10
6
  import { scrubLaunchIds } from './chat/launch-ids.js';
11
7
  import { exchangeCode } from './code.js';
12
- import { commandFor } from './commands.js';
13
8
  import { studioFont } from './fonts.js';
14
9
  import { allowedHost, allowedToken } from './guard.js';
15
10
  import { denied, hostT, localIdentity, requestRefusal, routeRight, signedIn, } from './host.js';
@@ -19,7 +14,7 @@ import { matchRoute, sendPng } from './routes.js';
19
14
  import { coreRoutes } from './server-core.js';
20
15
  import { checkedUiOptions } from './server-options.js';
21
16
  import { localListener, migrationSignal, requestContext } from './server-request.js';
22
- import { captureRecordedRun } from './snapshot-diagnostics.js';
17
+ import { runnerKey, snapshotRunners } from './snapshot-runners.js';
23
18
  import { studioT } from './studio-messages.js';
24
19
  export { chatRoutes } from './chat/routes.js';
25
20
  export { ChatEngine } from './chat/turn.js';
@@ -28,6 +23,7 @@ export { readProductPlan } from './product-plan.js';
28
23
  export { Runner } from './runner.js';
29
24
  export { coreRoutes, stateAccess } from './server-core.js';
30
25
  export { listenLocal } from './server-request.js';
26
+ export { recordPrototypeRun, runPrototypeSnapshot } from './snapshot-runners.js';
31
27
  export { diagnosticsView, runView, visibleRuns } from './snapshot-view.js';
32
28
  export { Stack } from './stack.js';
33
29
  export { studioRoutes } from './studio-routes.js';
@@ -37,44 +33,6 @@ const LOCAL_PAGE_HEADERS = {
37
33
  'x-frame-options': 'DENY',
38
34
  'referrer-policy': 'no-referrer',
39
35
  };
40
- const snapshotRunners = new Map();
41
- const runnerKey = (root) => (existsSync(root) ? realpathSync.native(root) : resolve(root));
42
- export function recordPrototypeRun(root, id, run) {
43
- snapshotRunners.get(runnerKey(root))?.record(id, run);
44
- }
45
- /** Autopilot starts its own fresh run on the same runner as the person's Snapshot command. */
46
- export function runPrototypeSnapshot(root, signal, id = 'snapshot', options) {
47
- const runner = snapshotRunners.get(runnerKey(root));
48
- const spec = options?.command
49
- ? { program: 'shell', args: [options.command], json: options.json ?? false }
50
- : commandFor('snapshot', { seeds: [], changes: [], scenes: options?.scenes });
51
- if (!runner || !spec)
52
- return Promise.resolve(undefined);
53
- const child = options
54
- ? {
55
- ...spec,
56
- cwd: options.cwd,
57
- validationCommit: options.commit,
58
- limits: options.limits,
59
- onSnapshotProgress: options.onSnapshotProgress,
60
- ...(options.snapshotRunId ? { snapshotRunId: options.snapshotRunId } : {}),
61
- }
62
- : spec;
63
- return new Promise((resolve) => {
64
- const finish = async () => {
65
- const run = runner.all()[id];
66
- if (options?.snapshotRunId) {
67
- // Leftover folders are tidied here, not judged: a child that published its whole snapshot
68
- // passed, and a folder that cannot be removed now is removed by the next recovery.
69
- await cleanSnapshotChild(snapshotsDir(options.cwd), options.snapshotRunId).catch(() => { });
70
- }
71
- resolve(run ? captureRecordedRun(options?.cwd ?? root, run) : undefined);
72
- };
73
- const started = runner.run(id, child, finish, signal);
74
- if (!started)
75
- resolve(undefined);
76
- });
77
- }
78
36
  function send(res, status, body, type = 'application/json', extra = {}) {
79
37
  res.writeHead(status, {
80
38
  'content-type': `${type}; charset=utf-8`,
@@ -136,7 +94,7 @@ async function handleRequest(options, routes, req, res, port, script, shutdown)
136
94
  ...headers,
137
95
  location: `${localStudioOrigin(port)}/${search}`,
138
96
  });
139
- return send(res, 200, pageHtml(options.product, options.hostParts, !options.signIn), 'text/html', headers);
97
+ return send(res, 200, pageHtml(options.product, options.hostParts, !options.signIn, options.theme), 'text/html', headers);
140
98
  }
141
99
  if (req.method === 'GET' && path === '/page.js')
142
100
  return send(res, 200, await script(), 'text/javascript');
@@ -0,0 +1,22 @@
1
+ import type { CommandRun } from '@buffcore/admin-shell/workbench';
2
+ import { type CommandSpec } from './commands.ts';
3
+ import type { Runner } from './runner.ts';
4
+ import { type DiagnosticRun } from './snapshot-diagnostics.ts';
5
+ export declare const snapshotRunners: Map<string, Runner>;
6
+ export declare const runnerKey: (root: string) => string;
7
+ type DiagnosticId = 'snapshot' | 'post-merge' | `snapshot:${string}` | `post-merge:${string}` | `snapshot-check:${string}` | `compare:${string}`;
8
+ export declare function recordPrototypeRun<T extends string>(root: string, id: T, run?: T extends DiagnosticId ? DiagnosticRun : CommandRun | DiagnosticRun): void;
9
+ /** Autopilot starts its own fresh run on the same runner as the person's Snapshot command. */
10
+ export declare function runPrototypeSnapshot(root: string, signal?: AbortSignal, id?: string, options?: {
11
+ cwd: string;
12
+ scenes?: readonly string[];
13
+ commit?: string;
14
+ command?: string;
15
+ json?: boolean;
16
+ limits?: CommandSpec['limits'];
17
+ snapshotRunId?: string;
18
+ /** Keep only the problems the result lists, not the progress lines the tool printed. */
19
+ listedOnly?: boolean;
20
+ onSnapshotProgress?: CommandSpec['onSnapshotProgress'];
21
+ }): Promise<DiagnosticRun | undefined>;
22
+ export {};
@@ -0,0 +1,45 @@
1
+ // The prototype snapshot runners the studio's servers register, one per product folder.
2
+ import { existsSync, realpathSync } from 'node:fs';
3
+ import { resolve } from 'node:path';
4
+ import { snapshotsDir } from '../prototype/report.js';
5
+ import { cleanSnapshotChild } from '../prototype/snapshot-storage.js';
6
+ import { commandFor } from './commands.js';
7
+ import { captureRecordedRun } from './snapshot-diagnostics.js';
8
+ export const snapshotRunners = new Map();
9
+ export const runnerKey = (root) => existsSync(root) ? realpathSync.native(root) : resolve(root);
10
+ export function recordPrototypeRun(root, id, run) {
11
+ snapshotRunners.get(runnerKey(root))?.record(id, run);
12
+ }
13
+ /** Autopilot starts its own fresh run on the same runner as the person's Snapshot command. */
14
+ export function runPrototypeSnapshot(root, signal, id = 'snapshot', options) {
15
+ const runner = snapshotRunners.get(runnerKey(root));
16
+ const spec = options?.command
17
+ ? { program: 'shell', args: [options.command], json: options.json ?? false }
18
+ : commandFor('snapshot', { seeds: [], changes: [], scenes: options?.scenes });
19
+ if (!runner || !spec)
20
+ return Promise.resolve(undefined);
21
+ const child = options
22
+ ? {
23
+ ...spec,
24
+ cwd: options.cwd,
25
+ validationCommit: options.commit,
26
+ limits: options.limits,
27
+ onSnapshotProgress: options.onSnapshotProgress,
28
+ ...(options.snapshotRunId ? { snapshotRunId: options.snapshotRunId } : {}),
29
+ }
30
+ : spec;
31
+ return new Promise((resolve) => {
32
+ const finish = async () => {
33
+ const run = runner.all()[id];
34
+ if (options?.snapshotRunId) {
35
+ // Leftover folders are tidied here, not judged: a child that published its whole snapshot
36
+ // passed, and a folder that cannot be removed now is removed by the next recovery.
37
+ await cleanSnapshotChild(snapshotsDir(options.cwd), options.snapshotRunId).catch(() => { });
38
+ }
39
+ resolve(run ? captureRecordedRun(options?.cwd ?? root, run) : undefined);
40
+ };
41
+ const started = runner.run(id, child, finish, signal);
42
+ if (!started)
43
+ resolve(undefined);
44
+ });
45
+ }
@@ -20,6 +20,7 @@ export declare const studioAccess: {
20
20
  appIcon: "read:runs";
21
21
  committedLevel: "read:agents";
22
22
  effectiveLevel: "read:agents";
23
+ neverAsk: "read:agents";
23
24
  level: true;
24
25
  levelCommit: "read:agents";
25
26
  stale: "read:runs";
@@ -36,6 +36,7 @@ export const studioAccess = {
36
36
  appIcon: 'read:runs',
37
37
  committedLevel: 'read:agents',
38
38
  effectiveLevel: 'read:agents',
39
+ neverAsk: 'read:agents',
39
40
  level: true,
40
41
  levelCommit: 'read:agents',
41
42
  stale: 'read:runs',
@@ -34,6 +34,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
34
34
  model?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", string>> | undefined;
35
35
  effort?: Partial<Record<"coding" | "design" | "fixes" | "planning" | "tests" | "validation", "auto" | "high" | "low" | "max" | "medium" | "xhigh">> | undefined;
36
36
  level: "auto" | "guide" | "lead" | "review";
37
+ neverAsk?: boolean | undefined;
37
38
  } | null;
38
39
  found: {
39
40
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -231,6 +232,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
231
232
  who: string;
232
233
  place: string;
233
234
  main: boolean;
235
+ planned?: string | undefined;
234
236
  }[];
235
237
  notes: string[];
236
238
  problem?: string | undefined;
@@ -340,6 +342,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
340
342
  } | undefined;
341
343
  committedLevel?: "auto" | "guide" | "lead" | "review" | undefined;
342
344
  effectiveLevel?: "auto" | "guide" | "lead" | "review" | undefined;
345
+ neverAsk?: boolean | undefined;
343
346
  level?: {
344
347
  source: "host";
345
348
  where: string;
@@ -153,6 +153,7 @@ export function studioState(root, options, detect = findAgents, held = () => fal
153
153
  ? {
154
154
  committedLevel: levels.committed,
155
155
  effectiveLevel: levels.effective,
156
+ ...(levels.neverAsk ? { neverAsk: true } : {}),
156
157
  ...(levels.commit ? { levelCommit: levels.commit } : {}),
157
158
  }
158
159
  : {}),
@@ -1,5 +1,18 @@
1
1
  export declare const en: {
2
2
  'ui.title': string;
3
+ 'ui.theme.refused': string;
4
+ 'ui.theme.shape': string;
5
+ 'ui.theme.mode': string;
6
+ 'ui.theme.name': string;
7
+ 'ui.theme.color': string;
8
+ 'ui.theme.shadow': string;
9
+ 'ui.theme.tokens': string;
10
+ 'ui.theme.number': string;
11
+ 'ui.theme.easing': string;
12
+ 'ui.theme.font': string;
13
+ 'ui.theme.key': string;
14
+ 'ui.theme.label': string;
15
+ 'ui.theme.allow': string;
3
16
  'ui.request.invalid': string;
4
17
  'ui.outside.signIn': string;
5
18
  'ui.outside.timeout': string;
@@ -1,5 +1,18 @@
1
1
  export const en = {
2
2
  'ui.title': '{name} studio',
3
+ 'ui.theme.refused': 'The studio cannot start with this theme ({count} problems):',
4
+ 'ui.theme.shape': "theme: not a theme like studioTheme; make one with extendStudioTheme('{ key, label, color, … }')",
5
+ 'ui.theme.mode': "{mode}: not one of the studio's modes (light, dark, contrast)",
6
+ 'ui.theme.name': '{where}: {name} is not a token name (lowercase letters, digits and dashes)',
7
+ 'ui.theme.color': '{where}: {name} must be a #rrggbb, rgb() or rgba() color',
8
+ 'ui.theme.shadow': '{where}: {name} must be none, or shadows made of lengths, #colors, rgb() or rgba(), and inset',
9
+ 'ui.theme.tokens': '{where}: {name} must be a #rrggbb color, a length, a number or a shadow',
10
+ 'ui.theme.number': '{where}: {name} must be a number',
11
+ 'ui.theme.easing': 'easing: {name} must be four numbers',
12
+ 'ui.theme.font': 'font: {name} must list family names of letters, digits, spaces, dashes and underscores',
13
+ 'ui.theme.key': 'key: must be 1 to 64 letters, digits, dashes or underscores',
14
+ 'ui.theme.label': 'label: must be one line of text',
15
+ 'ui.theme.allow': "allow: a host's theme may set aside only the studio's own checks (control-edges, status-words)",
3
16
  'ui.request.invalid': 'Not a request the studio takes.',
4
17
  'ui.outside.signIn': 'Outside sources need host sign-in.',
5
18
  'ui.outside.timeout': 'The outside source time limit must be a whole number from 1 to 30,000 milliseconds.',
@@ -4,6 +4,19 @@ export declare const es: {
4
4
  'ui.outside.source': string;
5
5
  'ui.outside.unavailable': string;
6
6
  'ui.title': string;
7
+ 'ui.theme.refused': string;
8
+ 'ui.theme.shape': string;
9
+ 'ui.theme.mode': string;
10
+ 'ui.theme.name': string;
11
+ 'ui.theme.color': string;
12
+ 'ui.theme.shadow': string;
13
+ 'ui.theme.tokens': string;
14
+ 'ui.theme.number': string;
15
+ 'ui.theme.easing': string;
16
+ 'ui.theme.font': string;
17
+ 'ui.theme.key': string;
18
+ 'ui.theme.label': string;
19
+ 'ui.theme.allow': string;
7
20
  'ui.request.invalid': string;
8
21
  'ui.address.local': string;
9
22
  'ui.studio': string;
@@ -4,6 +4,19 @@ export const es = {
4
4
  'ui.outside.source': 'Una fuente externa necesita un nombre en texto sin formato de 1 a 40 caracteres y una función de lectura.',
5
5
  'ui.outside.unavailable': 'No hay fuentes externas disponibles.',
6
6
  'ui.title': 'Estudio de {name}',
7
+ 'ui.theme.refused': 'El estudio no puede iniciarse con este tema ({count} problemas):',
8
+ 'ui.theme.shape': "tema: no es un tema como studioTheme; créalo con extendStudioTheme('{ key, label, color, … }')",
9
+ 'ui.theme.mode': '{mode}: no es uno de los modos del estudio (light, dark, contrast)',
10
+ 'ui.theme.name': '{where}: {name} no es un nombre de token (minúsculas, dígitos y guiones)',
11
+ 'ui.theme.color': '{where}: {name} debe ser un color #rrggbb, rgb() o rgba()',
12
+ 'ui.theme.shadow': '{where}: {name} debe ser none, o sombras hechas de longitudes, #colores, rgb() o rgba(), e inset',
13
+ 'ui.theme.tokens': '{where}: {name} debe ser un color #rrggbb, una longitud, un número o una sombra',
14
+ 'ui.theme.number': '{where}: {name} debe ser un número',
15
+ 'ui.theme.easing': 'easing: {name} debe ser cuatro números',
16
+ 'ui.theme.font': 'font: {name} debe listar nombres de familia de letras, dígitos, espacios, guiones y guiones bajos',
17
+ 'ui.theme.key': 'key: debe tener de 1 a 64 letras, dígitos, guiones o guiones bajos',
18
+ 'ui.theme.label': 'label: debe ser una sola línea de texto',
19
+ 'ui.theme.allow': 'allow: el tema de un anfitrión solo puede apartar las comprobaciones propias del estudio (control-edges, status-words)',
7
20
  'ui.request.invalid': 'El estudio no admite esta solicitud.',
8
21
  'ui.address.local': 'Solo la dirección de este equipo abre el estudio.',
9
22
  'ui.studio': 'Abrir el estudio con datos reales (vista previa)',
@@ -0,0 +1,8 @@
1
+ import { type Theme } from '@buffcore/tokens';
2
+ /**
3
+ * Every value's shape (`themeValueProblems`), then `checkTheme`'s colors and contrast. What the
4
+ * checks cannot read is one problem; each problem is listed once.
5
+ */
6
+ export declare function themeProblems(theme: Theme): string[];
7
+ /** The theme as plain data for the page, or a refusal listing every problem. */
8
+ export declare function checkedTheme(theme: Theme | undefined): Theme | undefined;