@buffcore/cli 0.8.42 → 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 (96) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/commands/design/references.d.ts +9 -0
  3. package/dist/commands/design/references.js +20 -1
  4. package/dist/commands/extension/places-approval.d.ts +1 -1
  5. package/dist/commands/prototype/comp-record.d.ts +27 -0
  6. package/dist/commands/prototype/comp-record.js +85 -0
  7. package/dist/commands/prototype/comp-words.d.ts +12 -0
  8. package/dist/commands/prototype/comp-words.js +24 -0
  9. package/dist/commands/prototype/comp.d.ts +26 -0
  10. package/dist/commands/prototype/comp.js +71 -0
  11. package/dist/commands/prototype/milestone-versions.d.ts +1 -1
  12. package/dist/commands/prototype/record-look-child.js +4 -1
  13. package/dist/commands/prototype/snapshot-command.js +1 -1
  14. package/dist/commands/prototype/snapshot-setup.d.ts +11 -0
  15. package/dist/commands/prototype/snapshot-setup.js +29 -5
  16. package/dist/commands/prototype/versions.d.ts +3 -3
  17. package/dist/commands/ui/agents-route.d.ts +2 -0
  18. package/dist/commands/ui/agents-route.js +8 -5
  19. package/dist/commands/ui/approval-authority.d.ts +1 -1
  20. package/dist/commands/ui/approve.js +7 -1
  21. package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
  22. package/dist/commands/ui/chat/fresh-critique.d.ts +28 -0
  23. package/dist/commands/ui/chat/fresh-critique.js +121 -0
  24. package/dist/commands/ui/chat/fresh-launch.d.ts +31 -0
  25. package/dist/commands/ui/chat/fresh-launch.js +122 -0
  26. package/dist/commands/ui/chat/fresh-prompts.d.ts +17 -0
  27. package/dist/commands/ui/chat/fresh-prompts.js +76 -0
  28. package/dist/commands/ui/chat/fresh-report.d.ts +8 -0
  29. package/dist/commands/ui/chat/fresh-report.js +36 -0
  30. package/dist/commands/ui/chat/fresh-routes.d.ts +3 -0
  31. package/dist/commands/ui/chat/fresh-routes.js +64 -0
  32. package/dist/commands/ui/chat/fresh-settings.d.ts +12 -0
  33. package/dist/commands/ui/chat/fresh-settings.js +66 -0
  34. package/dist/commands/ui/chat/fresh-store.d.ts +17 -0
  35. package/dist/commands/ui/chat/fresh-store.js +67 -0
  36. package/dist/commands/ui/chat/fresh.d.ts +31 -0
  37. package/dist/commands/ui/chat/fresh.en.d.ts +7 -0
  38. package/dist/commands/ui/chat/fresh.en.js +7 -0
  39. package/dist/commands/ui/chat/fresh.es.d.ts +7 -0
  40. package/dist/commands/ui/chat/fresh.es.js +7 -0
  41. package/dist/commands/ui/chat/fresh.js +112 -0
  42. package/dist/commands/ui/chat/limit-mentions.d.ts +2 -2
  43. package/dist/commands/ui/chat/limit-mentions.js +22 -2
  44. package/dist/commands/ui/chat/limits.d.ts +8 -1
  45. package/dist/commands/ui/chat/limits.en.d.ts +2 -0
  46. package/dist/commands/ui/chat/limits.en.js +2 -0
  47. package/dist/commands/ui/chat/limits.es.js +2 -0
  48. package/dist/commands/ui/chat/limits.js +13 -1
  49. package/dist/commands/ui/chat/parse-claude.js +7 -3
  50. package/dist/commands/ui/chat/permission-ask.js +3 -0
  51. package/dist/commands/ui/chat/planning-limits.js +15 -0
  52. package/dist/commands/ui/chat/publish-limits.d.ts +4 -0
  53. package/dist/commands/ui/chat/publish-limits.js +97 -0
  54. package/dist/commands/ui/chat/recorded-turn.js +3 -0
  55. package/dist/commands/ui/chat/stream.js +4 -1
  56. package/dist/commands/ui/chat/turn-guard.d.ts +2 -0
  57. package/dist/commands/ui/chat/turn-guard.js +12 -0
  58. package/dist/commands/ui/chat/turn-state.d.ts +5 -0
  59. package/dist/commands/ui/chat/turn.js +1 -0
  60. package/dist/commands/ui/comp-approval.d.ts +6 -0
  61. package/dist/commands/ui/comp-approval.js +42 -0
  62. package/dist/commands/ui/host.js +3 -0
  63. package/dist/commands/ui/index.js +18 -6
  64. package/dist/commands/ui/loop-approve.d.ts +4 -4
  65. package/dist/commands/ui/places-change.d.ts +1 -1
  66. package/dist/commands/ui/plan-structure.d.ts +3 -0
  67. package/dist/commands/ui/plan-structure.en.d.ts +3 -0
  68. package/dist/commands/ui/plan-structure.en.js +3 -0
  69. package/dist/commands/ui/plan-structure.es.d.ts +3 -0
  70. package/dist/commands/ui/plan-structure.es.js +3 -0
  71. package/dist/commands/ui/plan-structure.js +12 -4
  72. package/dist/commands/ui/prototype-comp-route.d.ts +7 -0
  73. package/dist/commands/ui/prototype-comp-route.js +109 -0
  74. package/dist/commands/ui/prototype-main.d.ts +2 -1
  75. package/dist/commands/ui/prototype-scenes-child.js +4 -1
  76. package/dist/commands/ui/prototype-snapshot-session.d.ts +1 -1
  77. package/dist/commands/ui/prototype-snapshot-session.js +3 -0
  78. package/dist/commands/ui/prototype-snapshot.d.ts +1 -1
  79. package/dist/commands/ui/routes.d.ts +6 -3
  80. package/dist/commands/ui/routes.js +3 -3
  81. package/dist/commands/ui/save-publish.js +3 -0
  82. package/dist/commands/ui/server.d.ts +7 -0
  83. package/dist/commands/ui/server.js +7 -3
  84. package/dist/commands/ui/structure-surface.d.ts +6 -0
  85. package/dist/commands/ui/structure-surface.js +94 -0
  86. package/dist/commands/ui/studio-routes.js +4 -0
  87. package/dist/commands/ui/studio-state.d.ts +6 -4
  88. package/dist/commands/ui/studio-versions.d.ts +3 -3
  89. package/dist/ui/page.js +81 -81
  90. package/docs/PROCESS.md +5 -0
  91. package/docs/PROTOTYPE.md +20 -0
  92. package/docs/WORKBENCH.md +2 -2
  93. package/package.json +11 -11
  94. package/skills/ape-critique/SKILL.md +9 -3
  95. package/skills/ape-design-system/SKILL.md +2 -1
  96. package/skills/ape-prototype/SKILL.md +5 -1
@@ -0,0 +1,94 @@
1
+ // "Which surface comes first?": the person's answer, kept in `plan/structure.md`'s header line
2
+ // (`Surface: desktop` or `Surface: phone`), written to the working copy; Structure's Save commits it.
3
+ import { randomUUID } from 'node:crypto';
4
+ import { existsSync } from 'node:fs';
5
+ import { readFile, rename, rm, writeFile } from 'node:fs/promises';
6
+ import { join } from 'node:path';
7
+ import { structureSurfaceBodySchema, workbenchApi, } from '@buffcore/contracts/workbench';
8
+ import { createI18n } from '@buffcore/i18n';
9
+ import { SURFACE_FIELD } from '../prototype/comp.js';
10
+ import { VersionRefusal } from '../prototype/versions.js';
11
+ import { personForTurn } from './chat/person.js';
12
+ import { hostT } from './host.js';
13
+ import { en } from './plan-structure.en.js';
14
+ import { es } from './plan-structure.es.js';
15
+ import { parseStructure } from './plan-structure.js';
16
+ import { savePathReason } from './save-paths.js';
17
+ import { withStudioSave } from './save-route.js';
18
+ const FILE = 'plan/structure.md';
19
+ const messages = createI18n({ catalogs: [{ en, es }] });
20
+ const surfaceT = (key) => messages.t(/^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en', key);
21
+ /** The structure's text with its surface line set: replaced where it is, else after the title. */
22
+ export function withSurface(source, surface) {
23
+ // A byte-order mark stays the file's first character.
24
+ const bom = source.startsWith('') ? '' : '';
25
+ const text = source.slice(bom.length);
26
+ const eol = text.includes('\r\n') ? '\r\n' : '\n';
27
+ const lines = text.split(/\r\n|\n/);
28
+ const line = `Surface: ${surface}`;
29
+ const table = lines.findIndex((entry) => entry.startsWith('|'));
30
+ const head = lines.slice(0, table === -1 ? lines.length : table);
31
+ const at = head.findIndex((entry) => SURFACE_FIELD.test(entry));
32
+ if (at !== -1)
33
+ lines[at] = line;
34
+ else {
35
+ const title = head.findIndex((entry) => entry.startsWith('# '));
36
+ if (title === -1)
37
+ lines.splice(0, 0, line, '');
38
+ else
39
+ lines.splice(title + 1, 0, '', line);
40
+ }
41
+ return bom + lines.join(eol);
42
+ }
43
+ async function writeSurface(root, surface) {
44
+ const file = join(root, FILE);
45
+ if (!existsSync(file))
46
+ return surfaceT('structure.surfaceMissing');
47
+ const reason = savePathReason(root, [FILE]);
48
+ if (reason)
49
+ return reason;
50
+ const next = withSurface(await readFile(file, 'utf8'), surface);
51
+ try {
52
+ parseStructure(next);
53
+ }
54
+ catch (error) {
55
+ return error instanceof Error ? error.message : surfaceT('structure.surfaceFailed');
56
+ }
57
+ const temp = `${file}.${randomUUID()}.tmp`;
58
+ try {
59
+ await writeFile(temp, next, { flag: 'wx' });
60
+ await rename(temp, file);
61
+ }
62
+ catch {
63
+ await rm(temp, { force: true });
64
+ return surfaceT('structure.surfaceFailed');
65
+ }
66
+ }
67
+ /** A person with the build right answers; Structure's Save commits the file as it does the rest. */
68
+ export function structureSurfaceRoute(root) {
69
+ return {
70
+ method: 'POST',
71
+ path: workbenchApi.structureSurface,
72
+ right: 'build',
73
+ handle: async (request) => {
74
+ if (!personForTurn(request))
75
+ return { status: 403, body: { error: hostT('ui.host.private') } };
76
+ const body = structureSurfaceBodySchema.safeParse(await request.body());
77
+ if (!body.success)
78
+ return { status: 400, body: { error: surfaceT('structure.surfaceFailed') } };
79
+ try {
80
+ const answer = await withStudioSave(root, () => writeSurface(root, body.data.surface));
81
+ if (typeof answer === 'object')
82
+ return { status: 409, body: { error: answer.detail } };
83
+ if (answer)
84
+ return { status: 409, body: { error: answer } };
85
+ }
86
+ catch (error) {
87
+ if (error instanceof VersionRefusal)
88
+ return { status: 409, body: { error: error.message } };
89
+ return { status: 500, body: { error: surfaceT('structure.surfaceFailed') } };
90
+ }
91
+ return { status: 202, body: { surface: body.data.surface } };
92
+ },
93
+ };
94
+ }
@@ -12,9 +12,11 @@ import { mergeRoutes } from './merge-route.js';
12
12
  import { mergeStudio } from './merge-state.js';
13
13
  import { outsideState } from './outside.js';
14
14
  import { outsideRoute } from './outside-route.js';
15
+ import { prototypeCompRoutes } from './prototype-comp-route.js';
15
16
  import { planPrototypeOnMain } from './prototype-main.js';
16
17
  import { prototypeScenesRoute } from './prototype-scenes-route.js';
17
18
  import { saveRoute } from './save-route.js';
19
+ import { structureSurfaceRoute } from './structure-surface.js';
18
20
  import { Latest } from './studio-facts.js';
19
21
  export const studioAccess = {
20
22
  viewer: true,
@@ -83,6 +85,8 @@ cached = false) {
83
85
  agentsRoute(root),
84
86
  agentCheckRoute(root),
85
87
  prototypeScenesRoute(root),
88
+ ...prototypeCompRoutes(root),
89
+ structureSurfaceRoute(root),
86
90
  outsideRoute,
87
91
  {
88
92
  method: 'GET',
@@ -35,6 +35,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
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
37
  neverAsk?: boolean | undefined;
38
+ review?: boolean | undefined;
38
39
  } | null;
39
40
  found: {
40
41
  id: "antigravity" | "claude" | "codex" | "cursor" | "grok" | "muse" | "opencode";
@@ -89,7 +90,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
89
90
  approved?: {
90
91
  version: number;
91
92
  approval: {
92
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
93
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
93
94
  signatures: {
94
95
  by: string;
95
96
  at: string;
@@ -114,7 +115,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
114
115
  pending?: {
115
116
  version: number;
116
117
  approval: {
117
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
118
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
118
119
  signatures: {
119
120
  by: string;
120
121
  at: string;
@@ -139,7 +140,7 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
139
140
  superseded?: {
140
141
  version: number;
141
142
  approval: {
142
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
143
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
143
144
  signatures: {
144
145
  by: string;
145
146
  at: string;
@@ -235,12 +236,13 @@ export declare function studioState(root: string, options: Pick<UiServerOptions,
235
236
  planned?: string | undefined;
236
237
  }[];
237
238
  notes: string[];
239
+ surface?: "desktop" | "phone" | undefined;
238
240
  problem?: string | undefined;
239
241
  } | null | undefined;
240
242
  themeDirection?: string | undefined;
241
243
  themeVoice?: string | undefined;
242
244
  brand: {
243
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
245
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
244
246
  signatures: {
245
247
  by: string;
246
248
  at: string;
@@ -14,7 +14,7 @@ export declare function authorityVersion(root: string, change: string): {
14
14
  approved?: {
15
15
  version: number;
16
16
  approval: {
17
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
17
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
18
18
  signatures: {
19
19
  by: string;
20
20
  at: string;
@@ -39,7 +39,7 @@ export declare function authorityVersion(root: string, change: string): {
39
39
  pending?: {
40
40
  version: number;
41
41
  approval: {
42
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
42
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
43
43
  signatures: {
44
44
  by: string;
45
45
  at: string;
@@ -64,7 +64,7 @@ export declare function authorityVersion(root: string, change: string): {
64
64
  superseded?: {
65
65
  version: number;
66
66
  approval: {
67
- kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
67
+ kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
68
68
  signatures: {
69
69
  by: string;
70
70
  at: string;