@buffcore/cli 0.8.45 → 0.8.47

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 (199) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/commands/change-merge-remove.d.ts +9 -2
  3. package/dist/commands/change-merge-remove.js +27 -15
  4. package/dist/commands/design/check.d.ts +1 -1
  5. package/dist/commands/design/check.js +2 -1
  6. package/dist/commands/design/contract-size.d.ts +7 -0
  7. package/dist/commands/design/contract-size.js +47 -0
  8. package/dist/commands/design/tells.en.d.ts +2 -0
  9. package/dist/commands/design/tells.en.js +2 -0
  10. package/dist/commands/design/tells.es.js +2 -0
  11. package/dist/commands/extension/places-approval.d.ts +4 -0
  12. package/dist/commands/process-paths.d.ts +14 -0
  13. package/dist/commands/process-paths.js +90 -0
  14. package/dist/commands/prototype/ai-approval.d.ts +27 -0
  15. package/dist/commands/prototype/ai-approval.js +60 -0
  16. package/dist/commands/prototype/approver.d.ts +71 -0
  17. package/dist/commands/prototype/approver.js +168 -0
  18. package/dist/commands/prototype/browser.d.ts +4 -24
  19. package/dist/commands/prototype/browser.js +13 -76
  20. package/dist/commands/prototype/critique-gate.d.ts +14 -0
  21. package/dist/commands/prototype/critique-gate.js +48 -0
  22. package/dist/commands/prototype/fence.d.ts +1 -0
  23. package/dist/commands/prototype/fence.js +12 -0
  24. package/dist/commands/prototype/final-approval-grant.js +18 -0
  25. package/dist/commands/prototype/final-approval.js +4 -1
  26. package/dist/commands/prototype/index.js +3 -0
  27. package/dist/commands/prototype/layout-hints.d.ts +34 -0
  28. package/dist/commands/prototype/layout-hints.js +194 -0
  29. package/dist/commands/prototype/layout-measure.d.ts +39 -0
  30. package/dist/commands/prototype/layout-measure.js +97 -0
  31. package/dist/commands/prototype/layout-words.d.ts +2 -0
  32. package/dist/commands/prototype/layout-words.js +11 -0
  33. package/dist/commands/prototype/layout.en.d.ts +6 -0
  34. package/dist/commands/prototype/layout.en.js +7 -0
  35. package/dist/commands/prototype/load-location.js +2 -3
  36. package/dist/commands/prototype/loaded-garbage.d.ts +10 -0
  37. package/dist/commands/prototype/loaded-garbage.js +20 -0
  38. package/dist/commands/prototype/media-ready.d.ts +9 -3
  39. package/dist/commands/prototype/media-ready.js +9 -4
  40. package/dist/commands/prototype/messages.en.d.ts +15 -0
  41. package/dist/commands/prototype/messages.en.js +15 -0
  42. package/dist/commands/prototype/messages.js +15 -0
  43. package/dist/commands/prototype/milestone-versions.d.ts +4 -0
  44. package/dist/commands/prototype/prune-command.d.ts +5 -0
  45. package/dist/commands/prototype/prune-command.js +25 -0
  46. package/dist/commands/prototype/prune-words.d.ts +1 -0
  47. package/dist/commands/prototype/prune-words.js +7 -0
  48. package/dist/commands/prototype/prune.d.ts +16 -0
  49. package/dist/commands/prototype/prune.en.d.ts +9 -0
  50. package/dist/commands/prototype/prune.en.js +9 -0
  51. package/dist/commands/prototype/prune.es.d.ts +2 -0
  52. package/dist/commands/prototype/prune.es.js +9 -0
  53. package/dist/commands/prototype/prune.js +140 -0
  54. package/dist/commands/prototype/reopen-messages.d.ts +9 -0
  55. package/dist/commands/prototype/reopen-messages.js +19 -0
  56. package/dist/commands/prototype/report.d.ts +14 -0
  57. package/dist/commands/prototype/report.js +5 -1
  58. package/dist/commands/prototype/scene-check.d.ts +37 -0
  59. package/dist/commands/prototype/scene-check.js +68 -0
  60. package/dist/commands/prototype/scene-layout.d.ts +17 -0
  61. package/dist/commands/prototype/scene-layout.js +57 -0
  62. package/dist/commands/prototype/scene-look.d.ts +14 -0
  63. package/dist/commands/prototype/scene-look.js +89 -0
  64. package/dist/commands/prototype/scene-ready.d.ts +46 -0
  65. package/dist/commands/prototype/scene-ready.js +122 -0
  66. package/dist/commands/prototype/scene.d.ts +37 -3
  67. package/dist/commands/prototype/scene.js +103 -36
  68. package/dist/commands/prototype/selector-answer.d.ts +43 -0
  69. package/dist/commands/prototype/selector-answer.js +73 -0
  70. package/dist/commands/prototype/selector-misses.d.ts +19 -0
  71. package/dist/commands/prototype/selector-misses.js +78 -0
  72. package/dist/commands/prototype/selector-prompt.d.ts +23 -0
  73. package/dist/commands/prototype/selector-prompt.js +32 -0
  74. package/dist/commands/prototype/selector-run.d.ts +13 -0
  75. package/dist/commands/prototype/selector-run.js +113 -0
  76. package/dist/commands/prototype/selector.d.ts +54 -0
  77. package/dist/commands/prototype/selector.js +96 -0
  78. package/dist/commands/prototype/snapshot-ancestor.js +2 -0
  79. package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
  80. package/dist/commands/prototype/snapshot-bundle.js +69 -7
  81. package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
  82. package/dist/commands/prototype/snapshot-check-files.js +41 -0
  83. package/dist/commands/prototype/snapshot-command.d.ts +2 -0
  84. package/dist/commands/prototype/snapshot-command.js +23 -10
  85. package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
  86. package/dist/commands/prototype/snapshot-completion.js +30 -2
  87. package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
  88. package/dist/commands/prototype/snapshot-dependencies.js +120 -14
  89. package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
  90. package/dist/commands/prototype/snapshot-hashes.js +28 -0
  91. package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
  92. package/dist/commands/prototype/snapshot-inputs.js +140 -190
  93. package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
  94. package/dist/commands/prototype/snapshot-matrix.js +95 -0
  95. package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
  96. package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
  97. package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
  98. package/dist/commands/prototype/snapshot-owners.js +12 -3
  99. package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
  100. package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
  101. package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
  102. package/dist/commands/prototype/snapshot-progress.js +54 -102
  103. package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
  104. package/dist/commands/prototype/snapshot-registry.js +121 -0
  105. package/dist/commands/prototype/snapshot-report.d.ts +4 -0
  106. package/dist/commands/prototype/snapshot-report.js +77 -12
  107. package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
  108. package/dist/commands/prototype/snapshot-requests.js +68 -30
  109. package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
  110. package/dist/commands/prototype/snapshot-reuse.js +17 -7
  111. package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
  112. package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
  113. package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
  114. package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
  115. package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
  116. package/dist/commands/prototype/snapshot-server-record.js +135 -0
  117. package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
  118. package/dist/commands/prototype/snapshot-servers.js +54 -4
  119. package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
  120. package/dist/commands/prototype/snapshot-setup.js +2 -1
  121. package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
  122. package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
  123. package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
  124. package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
  125. package/dist/commands/prototype/snapshot.d.ts +6 -0
  126. package/dist/commands/prototype/snapshot.js +73 -10
  127. package/dist/commands/prototype/version-commands.d.ts +4 -0
  128. package/dist/commands/prototype/version-commands.js +36 -8
  129. package/dist/commands/prototype/versions.d.ts +28 -2
  130. package/dist/commands/prototype/versions.js +25 -1
  131. package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
  132. package/dist/commands/prototype/vite-fs-path.js +15 -0
  133. package/dist/commands/remove-links.d.ts +6 -0
  134. package/dist/commands/remove-links.js +17 -0
  135. package/dist/commands/size-docs.d.ts +9 -0
  136. package/dist/commands/size-docs.en.d.ts +6 -0
  137. package/dist/commands/size-docs.en.js +6 -0
  138. package/dist/commands/size-docs.es.d.ts +2 -0
  139. package/dist/commands/size-docs.es.js +6 -0
  140. package/dist/commands/size-docs.js +28 -0
  141. package/dist/commands/size.d.ts +5 -2
  142. package/dist/commands/size.js +27 -9
  143. package/dist/commands/ui/approval-authority.d.ts +10 -2
  144. package/dist/commands/ui/approval-authority.js +1 -0
  145. package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
  146. package/dist/commands/ui/autopilot-ai-approve.js +68 -0
  147. package/dist/commands/ui/autopilot-loop.js +5 -6
  148. package/dist/commands/ui/autopilot-merge.js +3 -0
  149. package/dist/commands/ui/autopilot.en.d.ts +23 -0
  150. package/dist/commands/ui/autopilot.en.js +23 -0
  151. package/dist/commands/ui/autopilot.es.d.ts +23 -0
  152. package/dist/commands/ui/autopilot.es.js +23 -0
  153. package/dist/commands/ui/chat/find.d.ts +2 -0
  154. package/dist/commands/ui/chat/find.js +13 -0
  155. package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
  156. package/dist/commands/ui/chat/fresh-codex.js +175 -0
  157. package/dist/commands/ui/chat/fresh-critique.js +13 -5
  158. package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
  159. package/dist/commands/ui/chat/fresh-launch.js +67 -11
  160. package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
  161. package/dist/commands/ui/chat/fresh-prompts.js +2 -0
  162. package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
  163. package/dist/commands/ui/chat/fresh-secrets.js +172 -0
  164. package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
  165. package/dist/commands/ui/chat/fresh.en.js +2 -1
  166. package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
  167. package/dist/commands/ui/chat/fresh.es.js +2 -1
  168. package/dist/commands/ui/chat/worktree.js +25 -5
  169. package/dist/commands/ui/index.js +3 -0
  170. package/dist/commands/ui/loop-approve.d.ts +30 -1
  171. package/dist/commands/ui/loop-approve.js +2 -2
  172. package/dist/commands/ui/merge-route.js +3 -0
  173. package/dist/commands/ui/places-change.d.ts +4 -0
  174. package/dist/commands/ui/prototype-main.d.ts +4 -0
  175. package/dist/commands/ui/reopen-route.d.ts +117 -0
  176. package/dist/commands/ui/reopen-route.js +97 -0
  177. package/dist/commands/ui/save-route.d.ts +2 -0
  178. package/dist/commands/ui/save-route.js +4 -0
  179. package/dist/commands/ui/studio-routes.js +2 -0
  180. package/dist/commands/ui/studio-state.d.ts +33 -0
  181. package/dist/commands/ui/studio-versions.d.ts +24 -0
  182. package/dist/commands/ui/worktrees.d.ts +1 -1
  183. package/dist/commands/ui/worktrees.js +19 -3
  184. package/dist/commands/worktree-sweep.d.ts +45 -0
  185. package/dist/commands/worktree-sweep.js +188 -0
  186. package/dist/commands/worktrees-command.d.ts +32 -0
  187. package/dist/commands/worktrees-command.en.d.ts +25 -0
  188. package/dist/commands/worktrees-command.en.js +55 -0
  189. package/dist/commands/worktrees-command.js +96 -0
  190. package/dist/main.js +2 -0
  191. package/dist/ui/page.js +82 -82
  192. package/docs/PROTOTYPE.md +6 -3
  193. package/docs/WORKBENCH.md +11 -6
  194. package/package.json +11 -11
  195. package/skills/ape-critique/SKILL.md +41 -6
  196. package/skills/ape-design-system/SKILL.md +3 -0
  197. package/skills/ape-plan-change/SKILL.md +6 -0
  198. package/skills/ape-prototype/SKILL.md +8 -4
  199. package/templates/product/apps/app/app.json +3 -0
@@ -0,0 +1,194 @@
1
+ /** Pixels below which two boxes count as touching, and edges as shared (subpixel rounding). */
2
+ const SLACK = 1;
3
+ /** An edge further off than this is an indent on purpose, not a slip. */
4
+ const NEAR = 4;
5
+ /** Pairs looked at in one parent before only neighbours are compared. */
6
+ const PAIRS = 200;
7
+ /** Siblings that share a padding before one with another padding is a slip. */
8
+ const SAME = 3;
9
+ /** The fine steps of the scale: wider spaces are set by widths, centring or growth. */
10
+ const FINE = 6;
11
+ /** Prose, spaced by its type's own rhythm (em), not by the spacing scale. */
12
+ const PROSE = /^(p|h[1-6]|ul|ol|li|dl|dt|dd|blockquote|pre|hr|figure|table)$/;
13
+ const round = (n) => Math.round(n * 10) / 10;
14
+ const spacing = (box) => `${box.padding.map(round).join(' ')} / ${box.gap.map(round).join(' ')}`;
15
+ /** Siblings in the flow (layers are left out before) that cover each other. */
16
+ function overlaps(kids) {
17
+ const found = [];
18
+ const flat = kids.filter((box) => box.w > SLACK && box.h > SLACK);
19
+ for (let i = 0; i < flat.length; i++) {
20
+ const last = flat.length > PAIRS ? Math.min(i + 2, flat.length) : flat.length;
21
+ for (let j = i + 1; j < last; j++) {
22
+ const a = flat[i];
23
+ const b = flat[j];
24
+ const width = Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x);
25
+ const height = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);
26
+ if (width > SLACK && height > SLACK)
27
+ found.push({
28
+ kind: 'overlap',
29
+ element: b.name,
30
+ other: a.name,
31
+ width: round(width),
32
+ height: round(height),
33
+ });
34
+ }
35
+ }
36
+ return found;
37
+ }
38
+ /** Where a child shows on its parent's cross axis: its start, centre or end edge. */
39
+ function crossEdge(parent, box) {
40
+ const own = box.self === 'auto' || box.self === 'normal' ? parent.align : box.self;
41
+ const at = /center/.test(own) ? 'center' : /end/.test(own) ? 'end' : /base/.test(own) ? '' : 's';
42
+ if (!at)
43
+ return undefined;
44
+ const row = parent.flow === 'row';
45
+ // An unframed box shows only its content: its edge is inside its padding. So does a box that
46
+ // bleeds past its parent by its own padding (a negative margin, room for a focus ring).
47
+ const bleeds = box.margin.every((side, i) => side < 0 && side === -(box.padding[i] ?? 0));
48
+ const [top, inlineEnd, bottom, inlineStart] = box.framed && !bleeds ? [0, 0, 0, 0] : box.padding;
49
+ const sign = parent.rtl ? -1 : 1;
50
+ const start = row ? box.y + top : (parent.rtl ? box.x + box.w : box.x) + sign * inlineStart;
51
+ const end = row
52
+ ? box.y + box.h - bottom
53
+ : (parent.rtl ? box.x : box.x + box.w) - sign * inlineEnd;
54
+ return at === 'center' ? (start + end) / 2 : at === 'end' ? end : start;
55
+ }
56
+ function edges(parent, kids) {
57
+ if (parent.flow === 'other' || parent.wrap)
58
+ return [];
59
+ // An icon or decoration is aligned by eye (optically), so only boxes with text are compared.
60
+ const placed = kids.flatMap((box) => {
61
+ const edge = !box.bare ? crossEdge(parent, box) : undefined;
62
+ return edge === undefined ? [] : [{ box, edge }];
63
+ });
64
+ // The edge most children share (sorted, so each count is one sweep), when at least two do.
65
+ const sorted = placed.map((one) => one.edge).sort((a, b) => a - b);
66
+ let shared = { edge: 0, count: 0 };
67
+ for (let i = 0, from = 0, to = 0; i < sorted.length; i++) {
68
+ const edge = sorted[i];
69
+ while (sorted[from] < edge - SLACK)
70
+ from++;
71
+ while (to < sorted.length && sorted[to] <= edge + SLACK)
72
+ to++;
73
+ if (to - from > shared.count)
74
+ shared = { edge, count: to - from };
75
+ }
76
+ // A child off it, when the others sharing it are most of the others.
77
+ const most = shared.count >= 2 && shared.count * 2 > placed.length - 1;
78
+ return placed.flatMap(({ box, edge }) => {
79
+ const offset = Math.abs(edge - shared.edge);
80
+ if (!most || offset <= SLACK || offset > NEAR)
81
+ return [];
82
+ const { count } = shared;
83
+ return [
84
+ {
85
+ kind: 'edge',
86
+ element: box.name,
87
+ offset: round(offset),
88
+ edge: round(shared.edge),
89
+ count,
90
+ },
91
+ ];
92
+ });
93
+ }
94
+ function paddings(kids) {
95
+ const found = [];
96
+ for (const group of Object.values(Object.groupBy(kids, (box) => box.kind))) {
97
+ if (!group || group.length < 3)
98
+ continue;
99
+ const counts = Object.groupBy(group, spacing);
100
+ const [usual, same] = Object.entries(counts).sort((a, b) => (b[1]?.length ?? 0) - (a[1]?.length ?? 0))[0] ?? [];
101
+ const sample = same?.[0];
102
+ // Only a component that has padding of its own: a bare wrapper beside a padded one is two kinds.
103
+ if (!usual || !same || !sample || same.length < SAME || same.length * 2 <= group.length)
104
+ continue;
105
+ if (!sample.padding.some((side) => side > SLACK))
106
+ continue;
107
+ const usualSides = [...sample.padding, ...sample.gap];
108
+ for (const [at, box] of group.entries()) {
109
+ const off = [...box.padding, ...box.gap].flatMap((n, i) => Math.abs(n - (usualSides[i] ?? 0)) > SLACK ? [i] : []);
110
+ // The first of a list may drop its top padding and the last its bottom (a list's ends).
111
+ const end = off.length === 1 &&
112
+ ((at === 0 && off[0] === 0) || (at === group.length - 1 && off[0] === 2));
113
+ if (off.length && !end)
114
+ found.push({
115
+ kind: 'padding',
116
+ element: box.name,
117
+ own: spacing(box),
118
+ usual,
119
+ count: same.length,
120
+ });
121
+ }
122
+ }
123
+ return found;
124
+ }
125
+ function gaps(parent, kids, steps) {
126
+ if (parent.flow === 'other' || /space|stretch/.test(parent.justify))
127
+ return [];
128
+ const row = parent.flow === 'row';
129
+ const fine = steps.slice(0, FINE);
130
+ const widest = fine.at(-1)?.[1] ?? 0;
131
+ const found = [];
132
+ for (let i = 1; i < kids.length; i++) {
133
+ const a = kids[i - 1];
134
+ const b = kids[i];
135
+ // A wrapped row's next line, or boxes not side by side, have no gap between them to measure.
136
+ const across = row
137
+ ? Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y)
138
+ : Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x);
139
+ if (across <= 0 || PROSE.test(a.tag) || PROSE.test(b.tag))
140
+ continue;
141
+ const between = row
142
+ ? Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w))
143
+ : Math.max(b.y - (a.y + a.h), a.y - (b.y + b.h));
144
+ // Neighbours that keep the same room outside (a margin giving back a thinner border, so a
145
+ // selected one's thicker border moves nothing) are spaced by their outer edges.
146
+ const [after, before] = row ? [1, 3] : [2, 0];
147
+ const kept = a.outside[after] === b.outside[before] && (a.outside[after] ?? 0) > 0;
148
+ const gap = kept ? between - (a.margin[after] ?? 0) - (b.margin[before] ?? 0) : between;
149
+ // A hairline under the smallest step is a separator, not spacing.
150
+ if (gap < (steps[0]?.[1] ?? 0) - SLACK / 2 || gap > widest + SLACK / 2)
151
+ continue;
152
+ if (steps.some(([, value]) => Math.abs(gap - value) <= SLACK / 2))
153
+ continue;
154
+ const [token, value] = fine.reduce((best, step) => Math.abs(step[1] - gap) < Math.abs(best[1] - gap) ? step : best);
155
+ found.push({
156
+ kind: 'gap',
157
+ element: b.name,
158
+ other: a.name,
159
+ gap: round(gap),
160
+ token,
161
+ value: round(value),
162
+ });
163
+ }
164
+ return found;
165
+ }
166
+ /** Every hint on one look's boxes, given its spacing scale. */
167
+ export function layoutFindings(boxes, steps) {
168
+ const kids = new Map();
169
+ for (const box of boxes) {
170
+ if (box.parent < 0)
171
+ continue;
172
+ const list = kids.get(box.parent) ?? [];
173
+ list.push(box);
174
+ kids.set(box.parent, list);
175
+ }
176
+ const found = [];
177
+ for (const [at, all] of kids) {
178
+ const parent = boxes[at];
179
+ if (!parent)
180
+ continue;
181
+ const flowing = all.filter((box) => box.flows);
182
+ found.push(...overlaps(flowing), ...edges(parent, flowing), ...paddings(all));
183
+ if (steps.length)
184
+ found.push(...gaps(parent, flowing, steps));
185
+ }
186
+ return found;
187
+ }
188
+ /** The theme's spacing scale at a scene's scale, smallest first, without `0`. */
189
+ export function spacingSteps(space, scale = 1) {
190
+ return Object.entries(space)
191
+ .filter(([, value]) => value > 0)
192
+ .map(([token, value]) => [token, value * scale])
193
+ .sort((a, b) => a[1] - b[1]);
194
+ }
@@ -0,0 +1,39 @@
1
+ /** One shown element, in document order; `parent` is the index of its shown parent, or -1. */
2
+ export interface LayoutBox {
3
+ parent: number;
4
+ tag: string;
5
+ /** `tag[role=…]` and a few words of its text, label or test id. */
6
+ name: string;
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ /** Holds no text: an icon or a decoration, placed by eye. */
12
+ bare: boolean;
13
+ /** Drawn with a background, border or shadow: its box shows, not only its content. */
14
+ framed: boolean;
15
+ /** Placed over the flow on purpose: absolute, fixed or sticky, a dialog, menu, toast or popover. */
16
+ layer: boolean;
17
+ /** In the flow beside its siblings: not a layer, not inline, not floated. */
18
+ flows: boolean;
19
+ /** How it lays out its children: a flex row or column, block boxes stacked, or anything else. */
20
+ flow: 'row' | 'column' | 'other';
21
+ wrap: boolean;
22
+ rtl: boolean;
23
+ /** Its own `align-items` and `justify-content`, and `align-self` as its parent's child. */
24
+ align: string;
25
+ justify: string;
26
+ self: string;
27
+ /** Top, inline end, bottom, inline start; then the row and column gaps. */
28
+ padding: [number, number, number, number];
29
+ /** Each side's margin plus border, in the same order: the room it keeps outside its padding. */
30
+ outside: [number, number, number, number];
31
+ /** Each side's margin alone. */
32
+ margin: [number, number, number, number];
33
+ gap: [number, number];
34
+ /** What makes two siblings the same component: tag, role, display, direction, corners, and its
35
+ * children's tags and roles. */
36
+ kind: string;
37
+ }
38
+ /** The boxes as JSON: Playwright's own transfer of hundreds of objects costs far more. */
39
+ export declare function measureLayout(): string;
@@ -0,0 +1,97 @@
1
+ /// <reference lib="dom" />
2
+ // Runs inside the scene page (Playwright sends its source): no imports or outer variables.
3
+ // The laid-out boxes the layout hints read (`layout-hints.ts`): each shown element with its box,
4
+ // its parent's layout and its own spacing. Reads only what the page has already laid out.
5
+ /** The boxes as JSON: Playwright's own transfer of hundreds of objects costs far more. */
6
+ export function measureLayout() {
7
+ const layerRoles = ['dialog', 'alertdialog', 'menu', 'listbox', 'tooltip', 'alert', 'status'];
8
+ const blockish = ['block', 'flex', 'grid', 'table', 'list-item', 'flow-root'];
9
+ const boxes = [];
10
+ const shapes = [];
11
+ const px = (value) => Number.parseFloat(value) || 0;
12
+ const textOf = (el) => (el.textContent ?? '').replace(/\s+/g, ' ').trim();
13
+ const words = (el) => {
14
+ const text = textOf(el);
15
+ const said = text || el.getAttribute('aria-label') || el.getAttribute('data-testid') || el.id || '';
16
+ return said.length > 40 ? `${said.slice(0, 39)}…` : said;
17
+ };
18
+ const walk = (parent, at) => {
19
+ for (const el of parent.children) {
20
+ if (!(el instanceof HTMLElement) || el.matches('script,style,template,noscript'))
21
+ continue;
22
+ if (el.getAttribute('aria-hidden') === 'true')
23
+ continue;
24
+ const s = getComputedStyle(el);
25
+ if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0')
26
+ continue;
27
+ if (s.display === 'contents') {
28
+ walk(el, at);
29
+ continue;
30
+ }
31
+ const r = el.getBoundingClientRect();
32
+ const role = el.getAttribute('role');
33
+ const layer = ['absolute', 'fixed', 'sticky'].includes(s.position) ||
34
+ layerRoles.includes(role ?? '') ||
35
+ el.hasAttribute('popover') ||
36
+ el.getAttribute('aria-modal') === 'true';
37
+ const flex = s.display === 'flex' || s.display === 'inline-flex';
38
+ const reversed = s.flexDirection.endsWith('reverse');
39
+ const index = boxes.length;
40
+ const rtl = s.direction === 'rtl';
41
+ // Top, inline end, bottom, inline start.
42
+ const sides = (top, right, bottom, left) => {
43
+ const [t = 0, r = 0, b = 0, l = 0] = [top, right, bottom, left].map(px);
44
+ return (rtl ? [t, l, b, r] : [t, r, b, l]);
45
+ };
46
+ const margin = sides(s.marginTop, s.marginRight, s.marginBottom, s.marginLeft);
47
+ const border = sides(s.borderTopWidth, s.borderRightWidth, s.borderBottomWidth, s.borderLeftWidth);
48
+ const tag = el.tagName.toLowerCase();
49
+ boxes.push({
50
+ parent: at,
51
+ tag,
52
+ name: `${tag}${role ? `[role=${role}]` : ''} "${words(el)}"`,
53
+ x: r.x,
54
+ y: r.y,
55
+ w: r.width,
56
+ h: r.height,
57
+ bare: !textOf(el),
58
+ framed: !/^rgba\(.*, 0\)$|transparent/.test(s.backgroundColor) ||
59
+ s.backgroundImage !== 'none' ||
60
+ s.boxShadow !== 'none' ||
61
+ border.some((width) => width > 0),
62
+ layer,
63
+ flows: !layer &&
64
+ r.width >= 1 &&
65
+ r.height >= 1 &&
66
+ s.float === 'none' &&
67
+ blockish.includes(s.display),
68
+ flow: flex && !reversed
69
+ ? s.flexDirection === 'row'
70
+ ? 'row'
71
+ : 'column'
72
+ : ['block', 'flow-root', 'list-item'].includes(s.display)
73
+ ? 'column'
74
+ : 'other',
75
+ wrap: flex && s.flexWrap !== 'nowrap',
76
+ rtl,
77
+ align: s.alignItems,
78
+ justify: s.justifyContent,
79
+ self: s.alignSelf,
80
+ padding: sides(s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft),
81
+ outside: margin.map((m, i) => m + (border[i] ?? 0)),
82
+ margin,
83
+ gap: [px(s.rowGap), px(s.columnGap)],
84
+ kind: '',
85
+ });
86
+ shapes.push('');
87
+ if (at >= 0)
88
+ shapes[at] += `${tag}${role ?? ''},`;
89
+ walk(el, index);
90
+ const box = boxes[index];
91
+ if (box)
92
+ box.kind = [tag, role, s.display, s.flexDirection, s.borderRadius, shapes[index]].join('|');
93
+ }
94
+ };
95
+ walk(document.body, -1);
96
+ return JSON.stringify(boxes);
97
+ }
@@ -0,0 +1,2 @@
1
+ import { en } from './layout.en.ts';
2
+ export declare const layoutText: (key: keyof typeof en, values?: Record<string, unknown>) => string;
@@ -0,0 +1,11 @@
1
+ import { createI18n } from '@buffcore/i18n';
2
+ import { en } from './layout.en.js';
3
+ import { locale } from './messages.js';
4
+ const es = {
5
+ 'layout.overlap': 'Sugerencia de maquetación: escena "{scene}": {element} se superpone a {other} en {width} x {height} px, y ninguno es una capa (un menú, una hoja, un aviso).',
6
+ 'layout.edge': 'Sugerencia de maquetación: escena "{scene}": {element} queda {offset} px fuera del borde que comparten {count} de sus hermanos.',
7
+ 'layout.padding': 'Sugerencia de maquetación: escena "{scene}": {element} tiene un relleno de {own} px donde {count} hermanos del mismo tipo tienen {usual} px (arriba, final, abajo, inicio / huecos entre filas y columnas).',
8
+ 'layout.gap': 'Sugerencia de maquetación: escena "{scene}": los {gap} px entre {other} y {element} no son un paso de la escala de espaciado; el más cercano es {token} ({value} px).',
9
+ };
10
+ const translator = createI18n({ catalogs: [{ en, es }] });
11
+ export const layoutText = (key, values) => translator.t(locale(), key, values);
@@ -0,0 +1,6 @@
1
+ export declare const en: {
2
+ 'layout.overlap': string;
3
+ 'layout.edge': string;
4
+ 'layout.padding': string;
5
+ 'layout.gap': string;
6
+ };
@@ -0,0 +1,7 @@
1
+ // The layout hints' words (`scene-layout.ts`); Spanish in `layout-words.ts`.
2
+ export const en = {
3
+ 'layout.overlap': 'Layout hint: scene "{scene}": {element} overlaps {other} by {width} x {height} px, and neither is a layer (a menu, a sheet, a toast).',
4
+ 'layout.edge': 'Layout hint: scene "{scene}": {element} sits {offset} px off the edge {count} of its siblings share.',
5
+ 'layout.padding': 'Layout hint: scene "{scene}": {element} has padding {own} px where {count} siblings of the same kind have {usual} px (top, end, bottom, start / row and column gaps).',
6
+ 'layout.gap': 'Layout hint: scene "{scene}": {gap} px between {other} and {element} is not a step of the spacing scale; the nearest is {token} ({value} px).',
7
+ };
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
3
3
  import { surfaceDir } from './export.js';
4
+ import { viteFsFile } from './vite-fs-path.js';
4
5
  /** Only the run's configured loopback surfaces may be read again. */
5
6
  export function ownSurface(context, input) {
6
7
  try {
@@ -50,9 +51,7 @@ export function loadLocation(root, input, context) {
50
51
  if (!base)
51
52
  return url.origin;
52
53
  const pathname = decodeURIComponent(url.pathname);
53
- const file = pathname.startsWith('/@fs/')
54
- ? pathname.slice(5).replace(/^\/([a-z]:\/)/i, '$1')
55
- : resolve(base, `.${pathname}`);
54
+ const file = viteFsFile(pathname) ?? resolve(base, `.${pathname}`);
56
55
  const path = relative(root, file);
57
56
  if (!isAbsolute(path) && path !== '..' && !path.startsWith(`..${sep}`) && existsSync(file))
58
57
  return path.replaceAll('\\', '/');
@@ -0,0 +1,10 @@
1
+ import type { Page } from 'playwright-core';
2
+ /**
3
+ * On Linux, Chromium keeps each loaded response in a shared-memory file of about 2 MB, which it
4
+ * reserves on disk (Playwright moves it from /dev/shm to /tmp), until the page's garbage is
5
+ * collected. Its scripts' heap stays small, so no collection comes: a console page served as
6
+ * about 1,250 separate modules held about 1.2 GB per full load, in the renderer that every
7
+ * context shares, until the disk was full and loads failed with net::ERR_INSUFFICIENT_RESOURCES.
8
+ * Collecting before each full load (about 60 ms) keeps that to the page being replaced.
9
+ */
10
+ export declare function collectLoadedGarbage(page: Page, platform?: NodeJS.Platform): Promise<void>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * On Linux, Chromium keeps each loaded response in a shared-memory file of about 2 MB, which it
3
+ * reserves on disk (Playwright moves it from /dev/shm to /tmp), until the page's garbage is
4
+ * collected. Its scripts' heap stays small, so no collection comes: a console page served as
5
+ * about 1,250 separate modules held about 1.2 GB per full load, in the renderer that every
6
+ * context shares, until the disk was full and loads failed with net::ERR_INSUFFICIENT_RESOURCES.
7
+ * Collecting before each full load (about 60 ms) keeps that to the page being replaced.
8
+ */
9
+ export async function collectLoadedGarbage(page, platform = process.platform) {
10
+ if (platform !== 'linux')
11
+ return;
12
+ // Only an aid: a page that cannot collect still loads.
13
+ try {
14
+ const session = await page.context().newCDPSession(page);
15
+ await session
16
+ .send('HeapProfiler.collectGarbage')
17
+ .finally(() => session.detach().catch(() => { }));
18
+ }
19
+ catch { }
20
+ }
@@ -1,8 +1,14 @@
1
1
  /** The longest a scene page waits for its fonts and pictures; then it is shot anyway, with a hint. */
2
2
  export declare const MEDIA_WAIT = 10000;
3
+ /** `ready`: all loaded in time. `failed`: a picture or font failed. `elapsed`: ms spent waiting. */
4
+ export interface MediaState {
5
+ ready: boolean;
6
+ failed: boolean;
7
+ elapsed: number;
8
+ }
3
9
  /**
4
10
  * Runs in the page: wait until its fonts are ready and every picture has finished, loaded or
5
- * failed (a lazy picture loads now: the shot is of the whole page). False when `timeout` ran out
6
- * first. Self-contained, since Playwright sends it to the page as text.
11
+ * failed (a lazy picture loads now: the shot is of the whole page). Also say whether any failed
12
+ * and how long the wait took. Self-contained, since Playwright sends it to the page as text.
7
13
  */
8
- export declare function mediaReady(timeout: number): Promise<boolean>;
14
+ export declare function mediaReady(timeout: number): Promise<MediaState>;
@@ -4,13 +4,15 @@
4
4
  export const MEDIA_WAIT = 10_000;
5
5
  /**
6
6
  * Runs in the page: wait until its fonts are ready and every picture has finished, loaded or
7
- * failed (a lazy picture loads now: the shot is of the whole page). False when `timeout` ran out
8
- * first. Self-contained, since Playwright sends it to the page as text.
7
+ * failed (a lazy picture loads now: the shot is of the whole page). Also say whether any failed
8
+ * and how long the wait took. Self-contained, since Playwright sends it to the page as text.
9
9
  */
10
10
  export async function mediaReady(timeout) {
11
11
  // Layout first, so the fonts the text needs have started loading before `fonts.ready` is read.
12
+ const start = performance.now();
12
13
  document.body?.getBoundingClientRect();
13
- const pictures = [...document.images].flatMap((image) => {
14
+ const images = [...document.images];
15
+ const pictures = images.flatMap((image) => {
14
16
  if (image.loading === 'lazy')
15
17
  image.loading = 'eager';
16
18
  if (image.complete)
@@ -28,7 +30,10 @@ export async function mediaReady(timeout) {
28
30
  });
29
31
  const ready = Promise.all([document.fonts.ready, ...pictures]).then(() => true);
30
32
  try {
31
- return await Promise.race([ready, late]);
33
+ const finished = await Promise.race([ready, late]);
34
+ const failed = images.some((image) => image.naturalWidth === 0) ||
35
+ [...document.fonts].some((font) => font.status === 'error');
36
+ return { ready: finished, failed, elapsed: performance.now() - start };
32
37
  }
33
38
  finally {
34
39
  clearTimeout(timer);
@@ -42,6 +42,7 @@ export declare const en: {
42
42
  'prototype.remade': string;
43
43
  'prototype.problems': string;
44
44
  'prototype.sceneResult': string;
45
+ 'prototype.drawFallbacks': string;
45
46
  'prototype.sceneFailed': string;
46
47
  'prototype.serverUnavailable': string;
47
48
  'prototype.serverExitCode': string;
@@ -160,6 +161,19 @@ export declare const en: {
160
161
  'prototype.worktreeBusy': string;
161
162
  'prototype.noSlot': string;
162
163
  'prototype.ownFirstHelp': string;
164
+ 'prototype.belowFloor': string;
165
+ 'prototype.selectorSkipped': string;
166
+ 'prototype.selectorAdded': string;
167
+ 'prototype.selector.agent-unsupported': string;
168
+ 'prototype.selector.codex-sandbox': string;
169
+ 'prototype.selector.ci': string;
170
+ 'prototype.selector.host': string;
171
+ 'prototype.selector.launch': string;
172
+ 'prototype.selector.failed': string;
173
+ 'prototype.selector.timeout': string;
174
+ 'prototype.selector.secret': string;
175
+ 'prototype.selector.shape': string;
176
+ 'prototype.fullHelp': string;
163
177
  'prototype.pagesHelp': string;
164
178
  'prototype.invalidPages': string;
165
179
  'prototype.lowMemory': string;
@@ -170,4 +184,5 @@ export declare const en: {
170
184
  'prototype.exportServe': string;
171
185
  'prototype.exportServeBase': string;
172
186
  'prototype.exportServeRelative': string;
187
+ 'prototype.milestoneFull': string;
173
188
  };
@@ -43,6 +43,7 @@ export const en = {
43
43
  'prototype.remade': 'remade',
44
44
  'prototype.problems': '{count} problem(s)',
45
45
  'prototype.sceneResult': ' {title}: {result}{retry}',
46
+ 'prototype.drawFallbacks': 'Full-page fallbacks in the scenes drawn this run: {looks} looks, {scenes} scenes.',
46
47
  'prototype.sceneFailed': 'Scene "{scene}" failed{retry}: {detail}',
47
48
  'prototype.serverUnavailable': 'Server "{server}" is not answering for scene "{scene}". {status}.',
48
49
  'prototype.serverExitCode': 'Last exit code was {code}',
@@ -161,6 +162,19 @@ export const en = {
161
162
  'prototype.worktreeBusy': 'Another snapshot of this change is already running. Take this one when it has finished.',
162
163
  'prototype.noSlot': 'Two snapshots are already running in this repository. Take this one when one has finished.',
163
164
  'prototype.ownFirstHelp': "draw the scenes this branch changed before the others (the report's order stays)",
165
+ 'prototype.belowFloor': 'This snapshot has a scene drawn in fewer looks than its matrix needs (the floor: the product’s theme, light and dark, its languages and en-XA), or a floor scene in a full report. Take the snapshot again with ape prototype snapshot (with --full for a full report).',
166
+ 'prototype.selectorSkipped': 'No looks were added beyond the floor: {why}. This snapshot draws the floor alone.',
167
+ 'prototype.selectorAdded': 'The selector added {count, plural, one {# pick} other {# picks}} beyond the floor; report.json lists them in selector.',
168
+ 'prototype.selector.agent-unsupported': 'the selector runs only with Claude Code or Codex ({agent} is set in plan/agents.md and has no read-only turn)',
169
+ 'prototype.selector.codex-sandbox': 'Codex’s elevated Windows sandbox is not set up (set it up once in Codex, then try again)',
170
+ 'prototype.selector.ci': 'this is a CI or test run',
171
+ 'prototype.selector.host': 'the host starts every agent turn, so this run cannot',
172
+ 'prototype.selector.launch': 'the agent could not be started',
173
+ 'prototype.selector.failed': 'the agent turn failed',
174
+ 'prototype.selector.timeout': 'the agent turn took longer than {seconds} seconds',
175
+ 'prototype.selector.secret': 'the agent’s answer quoted a value from {file}, so it was dropped',
176
+ 'prototype.selector.shape': 'the agent answered out of shape',
177
+ 'prototype.fullHelp': 'draw every theme, mode and pseudo-locale (the full matrix), not only the floor',
164
178
  'prototype.pagesHelp': 'scene pages open at once, 1 to 4 (default uses cores and free memory, up to 2 with admin scenes)',
165
179
  'prototype.invalidPages': '--pages must be a whole number from 1 to {max}.',
166
180
  'prototype.lowMemory': 'This computer has {free} MB of free memory and a snapshot needs at least {need} MB. Close some programs and take the snapshot again, or set APE_SNAPSHOT_MIN_FREE_MB to change this.',
@@ -171,4 +185,5 @@ export const en = {
171
185
  'prototype.exportServe': 'Serve that folder at the root of any static file server (e.g. python -m http.server) and open it: no API, database or development server.',
172
186
  'prototype.exportServeBase': 'Serve that folder at {base} of any static file server and open it there: no API, database or development server.',
173
187
  'prototype.exportServeRelative': 'Serve that folder under any path of any static file server and open it there: no API, database or development server.',
188
+ 'prototype.milestoneFull': 'A milestone needs every scene drawn in the full matrix: take a full report of this commit (ape prototype snapshot --full, which reuses what it can) and record it.',
174
189
  };
@@ -44,6 +44,7 @@ const es = {
44
44
  'prototype.remade': 'regenerada',
45
45
  'prototype.problems': '{count} problema(s)',
46
46
  'prototype.sceneResult': ' {title}: {result}{retry}',
47
+ 'prototype.drawFallbacks': 'Recargas completas en las escenas dibujadas en esta ejecución: {looks} apariencias, {scenes} escenas.',
47
48
  'prototype.sceneFailed': 'La escena "{scene}" falló{retry}: {detail}',
48
49
  'prototype.serverUnavailable': 'El servidor "{server}" no responde para la escena "{scene}". {status}.',
49
50
  'prototype.serverExitCode': 'El último código de salida fue {code}',
@@ -162,6 +163,19 @@ const es = {
162
163
  'prototype.worktreeBusy': 'Ya se está tomando otra captura de este cambio. Toma esta cuando termine.',
163
164
  'prototype.noSlot': 'Ya se están tomando dos capturas en este repositorio. Toma esta cuando termine una.',
164
165
  'prototype.ownFirstHelp': 'dibuja primero las escenas que cambió esta rama (el informe conserva su orden)',
166
+ 'prototype.belowFloor': 'Esta captura tiene una escena dibujada en menos aspectos de los que necesita su matriz (la base: el tema del producto, claro y oscuro, sus idiomas y en-XA), o una escena de la base en un informe completo. Toma la captura de nuevo con ape prototype snapshot (con --full para un informe completo).',
167
+ 'prototype.selectorSkipped': 'No se añadieron aspectos además de la base: {why}. Esta captura dibuja solo la base.',
168
+ 'prototype.selectorAdded': 'El selector añadió {count, plural, one {# elección} other {# elecciones}} además de la base; report.json las lista en selector.',
169
+ 'prototype.selector.agent-unsupported': 'el selector solo funciona con Claude Code o Codex (plan/agents.md indica {agent}, que no tiene un turno de solo lectura)',
170
+ 'prototype.selector.codex-sandbox': 'el sandbox elevado de Windows de Codex no está configurado (configúralo una vez en Codex y vuelve a intentarlo)',
171
+ 'prototype.selector.ci': 'es una ejecución de CI o de pruebas',
172
+ 'prototype.selector.host': 'el anfitrión inicia cada turno de agente, así que esta ejecución no puede',
173
+ 'prototype.selector.secret': 'la respuesta del agente citaba un valor de {file}, así que se descartó',
174
+ 'prototype.selector.launch': 'no se pudo iniciar el agente',
175
+ 'prototype.selector.failed': 'el turno del agente falló',
176
+ 'prototype.selector.timeout': 'el turno del agente tardó más de {seconds} segundos',
177
+ 'prototype.selector.shape': 'el agente respondió con una forma no válida',
178
+ 'prototype.fullHelp': 'dibuja todos los temas, modos y pseudoidiomas (la matriz completa), no solo la base',
165
179
  'prototype.pagesHelp': 'páginas de escena abiertas a la vez, de 1 a 4 (por defecto, según los núcleos y la memoria libre, hasta 2 con escenas de administración)',
166
180
  'prototype.invalidPages': '--pages debe ser un número entero de 1 a {max}.',
167
181
  'prototype.lowMemory': 'Este equipo tiene {free} MB de memoria libre y una captura necesita al menos {need} MB. Cierra algunos programas y toma la captura de nuevo, o define APE_SNAPSHOT_MIN_FREE_MB para cambiarlo.',
@@ -172,6 +186,7 @@ const es = {
172
186
  'prototype.exportServe': 'Sirve esa carpeta en la raíz de cualquier servidor de archivos estáticos (p. ej. python -m http.server) y ábrela: sin API, base de datos ni servidor de desarrollo.',
173
187
  'prototype.exportServeBase': 'Sirve esa carpeta en {base} de cualquier servidor de archivos estáticos y ábrela ahí: sin API, base de datos ni servidor de desarrollo.',
174
188
  'prototype.exportServeRelative': 'Sirve esa carpeta bajo cualquier ruta de cualquier servidor de archivos estáticos y ábrela ahí: sin API, base de datos ni servidor de desarrollo.',
189
+ 'prototype.milestoneFull': 'Un hito necesita cada escena dibujada en la matriz completa: toma un informe completo de este commit (ape prototype snapshot --full, que reutiliza lo que puede) y regístralo.',
175
190
  };
176
191
  /** The locale the prototype's words are shown in (also for the lists inside them). */
177
192
  export const locale = () => /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
@@ -30,6 +30,10 @@ export declare function readMilestoneVersions(root: string, milestone: string, r
30
30
  fingerprint: string;
31
31
  role?: string | undefined;
32
32
  agent?: string | undefined;
33
+ ai?: {
34
+ model?: string | undefined;
35
+ reason: string;
36
+ } | undefined;
33
37
  }[];
34
38
  rule?: {
35
39
  kind: "one";
@@ -0,0 +1,5 @@
1
+ import type { Command } from 'commander';
2
+ import { type PruneResult } from './prune.ts';
3
+ /** The person's summary of a prune. */
4
+ export declare function pruneLine(result: PruneResult): string;
5
+ export declare function addPruneCommand(prototype: Command): void;
@@ -0,0 +1,25 @@
1
+ import { findRoot } from '../../project.js';
2
+ import { printJson } from '../json.js';
3
+ import { pruneSnapshots } from './prune.js';
4
+ import { pruneText } from './prune-words.js';
5
+ /** The person's summary of a prune. */
6
+ export function pruneLine(result) {
7
+ const count = result.removed.length;
8
+ if (count === 0)
9
+ return pruneText('prune.nothing');
10
+ const folders = result.removed.join(', ');
11
+ return pruneText(result.dryRun ? 'prune.wouldRemove' : 'prune.removed', { count, folders });
12
+ }
13
+ export function addPruneCommand(prototype) {
14
+ prototype
15
+ .command('prune')
16
+ .description(pruneText('prune.help'))
17
+ .option('--dry-run', pruneText('prune.dryRunHelp'))
18
+ .option('--json', pruneText('prune.jsonHelp'))
19
+ .action(async (flags) => {
20
+ const work = async () => pruneSnapshots(findRoot(), { dryRun: flags.dryRun === true });
21
+ if (flags.json)
22
+ return printJson(work);
23
+ console.log(pruneLine(await work()));
24
+ });
25
+ }
@@ -0,0 +1 @@
1
+ export declare const pruneText: (key: string, values?: Record<string, unknown>) => string;
@@ -0,0 +1,7 @@
1
+ // The words `ape prototype prune` prints, in the person's language.
2
+ import { createI18n } from '@buffcore/i18n';
3
+ import { en } from './prune.en.js';
4
+ import { es } from './prune.es.js';
5
+ const messages = createI18n({ catalogs: [{ en, es }] });
6
+ const locale = () => /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
7
+ export const pruneText = (key, values) => messages.t(locale(), key, values);