@buffcore/cli 0.8.46 → 0.8.48

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 (271) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/commands/build/server-text.en.d.ts +5 -0
  3. package/dist/commands/build/server-text.en.js +5 -0
  4. package/dist/commands/build/server-text.js +5 -0
  5. package/dist/commands/build/server.d.ts +4 -0
  6. package/dist/commands/build/server.js +10 -1
  7. package/dist/commands/change-merge-remove.d.ts +9 -2
  8. package/dist/commands/change-merge-remove.js +27 -15
  9. package/dist/commands/change-merge.d.ts +2 -2
  10. package/dist/commands/design/check.d.ts +1 -1
  11. package/dist/commands/design/check.js +2 -1
  12. package/dist/commands/design/contract-size.d.ts +7 -0
  13. package/dist/commands/design/contract-size.js +47 -0
  14. package/dist/commands/design/tells.en.d.ts +2 -0
  15. package/dist/commands/design/tells.en.js +2 -0
  16. package/dist/commands/design/tells.es.js +2 -0
  17. package/dist/commands/dev.d.ts +9 -2
  18. package/dist/commands/dev.js +24 -5
  19. package/dist/commands/extension/places-approval.d.ts +4 -0
  20. package/dist/commands/hardening.d.ts +3 -0
  21. package/dist/commands/hardening.en.d.ts +3 -0
  22. package/dist/commands/hardening.en.js +3 -0
  23. package/dist/commands/hardening.es.d.ts +2 -0
  24. package/dist/commands/hardening.es.js +3 -0
  25. package/dist/commands/hardening.js +19 -0
  26. package/dist/commands/process-paths.d.ts +14 -0
  27. package/dist/commands/process-paths.js +90 -0
  28. package/dist/commands/prototype/ai-approval.d.ts +27 -0
  29. package/dist/commands/prototype/ai-approval.js +60 -0
  30. package/dist/commands/prototype/approver.d.ts +71 -0
  31. package/dist/commands/prototype/approver.js +168 -0
  32. package/dist/commands/prototype/comp-record.d.ts +5 -0
  33. package/dist/commands/prototype/comp-record.js +22 -0
  34. package/dist/commands/prototype/critique-gate.d.ts +14 -0
  35. package/dist/commands/prototype/critique-gate.js +48 -0
  36. package/dist/commands/prototype/fence.d.ts +1 -0
  37. package/dist/commands/prototype/fence.js +12 -0
  38. package/dist/commands/prototype/final-approval-grant.js +18 -0
  39. package/dist/commands/prototype/final-approval.js +4 -1
  40. package/dist/commands/prototype/index.js +3 -0
  41. package/dist/commands/prototype/layout-hints.d.ts +34 -0
  42. package/dist/commands/prototype/layout-hints.js +194 -0
  43. package/dist/commands/prototype/layout-measure.d.ts +39 -0
  44. package/dist/commands/prototype/layout-measure.js +97 -0
  45. package/dist/commands/prototype/layout-words.d.ts +2 -0
  46. package/dist/commands/prototype/layout-words.js +11 -0
  47. package/dist/commands/prototype/layout.en.d.ts +6 -0
  48. package/dist/commands/prototype/layout.en.js +7 -0
  49. package/dist/commands/prototype/load-location.js +2 -3
  50. package/dist/commands/prototype/messages.en.d.ts +14 -0
  51. package/dist/commands/prototype/messages.en.js +15 -1
  52. package/dist/commands/prototype/messages.js +15 -1
  53. package/dist/commands/prototype/milestone-versions.d.ts +4 -0
  54. package/dist/commands/prototype/prune-command.d.ts +5 -0
  55. package/dist/commands/prototype/prune-command.js +25 -0
  56. package/dist/commands/prototype/prune-words.d.ts +1 -0
  57. package/dist/commands/prototype/prune-words.js +7 -0
  58. package/dist/commands/prototype/prune.d.ts +16 -0
  59. package/dist/commands/prototype/prune.en.d.ts +9 -0
  60. package/dist/commands/prototype/prune.en.js +9 -0
  61. package/dist/commands/prototype/prune.es.d.ts +2 -0
  62. package/dist/commands/prototype/prune.es.js +9 -0
  63. package/dist/commands/prototype/prune.js +140 -0
  64. package/dist/commands/prototype/reopen-messages.d.ts +9 -0
  65. package/dist/commands/prototype/reopen-messages.js +19 -0
  66. package/dist/commands/prototype/report.d.ts +14 -0
  67. package/dist/commands/prototype/report.js +5 -1
  68. package/dist/commands/prototype/scene-layout.d.ts +17 -0
  69. package/dist/commands/prototype/scene-layout.js +57 -0
  70. package/dist/commands/prototype/scene-ready.js +8 -2
  71. package/dist/commands/prototype/scene.d.ts +15 -2
  72. package/dist/commands/prototype/scene.js +54 -42
  73. package/dist/commands/prototype/selector-answer.d.ts +43 -0
  74. package/dist/commands/prototype/selector-answer.js +73 -0
  75. package/dist/commands/prototype/selector-misses.d.ts +19 -0
  76. package/dist/commands/prototype/selector-misses.js +78 -0
  77. package/dist/commands/prototype/selector-prompt.d.ts +23 -0
  78. package/dist/commands/prototype/selector-prompt.js +32 -0
  79. package/dist/commands/prototype/selector-run.d.ts +13 -0
  80. package/dist/commands/prototype/selector-run.js +113 -0
  81. package/dist/commands/prototype/selector.d.ts +54 -0
  82. package/dist/commands/prototype/selector.js +96 -0
  83. package/dist/commands/prototype/snapshot-ancestor.js +2 -0
  84. package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
  85. package/dist/commands/prototype/snapshot-bundle.js +69 -7
  86. package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
  87. package/dist/commands/prototype/snapshot-check-files.js +41 -0
  88. package/dist/commands/prototype/snapshot-command.d.ts +2 -0
  89. package/dist/commands/prototype/snapshot-command.js +3 -0
  90. package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
  91. package/dist/commands/prototype/snapshot-completion.js +30 -2
  92. package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
  93. package/dist/commands/prototype/snapshot-dependencies.js +120 -14
  94. package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
  95. package/dist/commands/prototype/snapshot-hashes.js +28 -0
  96. package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
  97. package/dist/commands/prototype/snapshot-inputs.js +140 -197
  98. package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
  99. package/dist/commands/prototype/snapshot-matrix.js +95 -0
  100. package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
  101. package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
  102. package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
  103. package/dist/commands/prototype/snapshot-owners.js +12 -3
  104. package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
  105. package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
  106. package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
  107. package/dist/commands/prototype/snapshot-progress.js +54 -102
  108. package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
  109. package/dist/commands/prototype/snapshot-registry.js +121 -0
  110. package/dist/commands/prototype/snapshot-report.d.ts +4 -0
  111. package/dist/commands/prototype/snapshot-report.js +77 -12
  112. package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
  113. package/dist/commands/prototype/snapshot-requests.js +68 -30
  114. package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
  115. package/dist/commands/prototype/snapshot-reuse.js +17 -7
  116. package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
  117. package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
  118. package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
  119. package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
  120. package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
  121. package/dist/commands/prototype/snapshot-server-record.js +135 -0
  122. package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
  123. package/dist/commands/prototype/snapshot-servers.js +50 -2
  124. package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
  125. package/dist/commands/prototype/snapshot-setup.js +2 -1
  126. package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
  127. package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
  128. package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
  129. package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
  130. package/dist/commands/prototype/snapshot.d.ts +5 -0
  131. package/dist/commands/prototype/snapshot.js +72 -10
  132. package/dist/commands/prototype/version-commands.d.ts +4 -0
  133. package/dist/commands/prototype/version-commands.js +36 -8
  134. package/dist/commands/prototype/versions.d.ts +28 -2
  135. package/dist/commands/prototype/versions.js +25 -1
  136. package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
  137. package/dist/commands/prototype/vite-fs-path.js +15 -0
  138. package/dist/commands/remove-links.d.ts +6 -0
  139. package/dist/commands/remove-links.js +17 -0
  140. package/dist/commands/server/build.d.ts +2 -1
  141. package/dist/commands/server/build.js +10 -2
  142. package/dist/commands/server/deploy-local.d.ts +3 -0
  143. package/dist/commands/server/deploy-local.js +9 -0
  144. package/dist/commands/server/deploy-plan.d.ts +5 -0
  145. package/dist/commands/server/deploy-plan.js +56 -0
  146. package/dist/commands/server/deploy-result.d.ts +7 -0
  147. package/dist/commands/server/deploy-result.js +1 -0
  148. package/dist/commands/server/deploy-script.d.ts +2 -0
  149. package/dist/commands/server/deploy-script.js +3 -2
  150. package/dist/commands/server/deploy.d.ts +9 -6
  151. package/dist/commands/server/deploy.js +39 -61
  152. package/dist/commands/server/files.d.ts +9 -1
  153. package/dist/commands/server/files.js +25 -5
  154. package/dist/commands/server/image.d.ts +4 -2
  155. package/dist/commands/server/image.js +6 -5
  156. package/dist/commands/server/setup.js +4 -0
  157. package/dist/commands/server/system-packages.d.ts +29 -0
  158. package/dist/commands/server/system-packages.js +103 -0
  159. package/dist/commands/services/compose.d.ts +1 -1
  160. package/dist/commands/services/compose.js +5 -3
  161. package/dist/commands/size-docs.d.ts +9 -0
  162. package/dist/commands/size-docs.en.d.ts +6 -0
  163. package/dist/commands/size-docs.en.js +6 -0
  164. package/dist/commands/size-docs.es.d.ts +2 -0
  165. package/dist/commands/size-docs.es.js +6 -0
  166. package/dist/commands/size-docs.js +28 -0
  167. package/dist/commands/size.d.ts +5 -2
  168. package/dist/commands/size.js +27 -9
  169. package/dist/commands/ui/agents-route.js +2 -0
  170. package/dist/commands/ui/approval-authority.d.ts +10 -2
  171. package/dist/commands/ui/approval-authority.en.d.ts +1 -0
  172. package/dist/commands/ui/approval-authority.en.js +1 -0
  173. package/dist/commands/ui/approval-authority.es.d.ts +1 -0
  174. package/dist/commands/ui/approval-authority.es.js +1 -0
  175. package/dist/commands/ui/approval-authority.js +8 -2
  176. package/dist/commands/ui/approve.js +2 -4
  177. package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
  178. package/dist/commands/ui/autopilot-ai-approve.js +68 -0
  179. package/dist/commands/ui/autopilot-loop.js +5 -6
  180. package/dist/commands/ui/autopilot-merge.js +3 -0
  181. package/dist/commands/ui/autopilot-records.d.ts +2 -0
  182. package/dist/commands/ui/autopilot-records.js +5 -0
  183. package/dist/commands/ui/autopilot.en.d.ts +23 -0
  184. package/dist/commands/ui/autopilot.en.js +23 -0
  185. package/dist/commands/ui/autopilot.es.d.ts +23 -0
  186. package/dist/commands/ui/autopilot.es.js +23 -0
  187. package/dist/commands/ui/brand-approval.js +5 -1
  188. package/dist/commands/ui/chat/find.d.ts +2 -0
  189. package/dist/commands/ui/chat/find.js +13 -0
  190. package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
  191. package/dist/commands/ui/chat/fresh-codex.js +175 -0
  192. package/dist/commands/ui/chat/fresh-critique.js +13 -5
  193. package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
  194. package/dist/commands/ui/chat/fresh-launch.js +67 -11
  195. package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
  196. package/dist/commands/ui/chat/fresh-prompts.js +2 -0
  197. package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
  198. package/dist/commands/ui/chat/fresh-secrets.js +172 -0
  199. package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
  200. package/dist/commands/ui/chat/fresh.en.js +2 -1
  201. package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
  202. package/dist/commands/ui/chat/fresh.es.js +2 -1
  203. package/dist/commands/ui/chat/permissions.js +1 -1
  204. package/dist/commands/ui/chat/routes.js +4 -0
  205. package/dist/commands/ui/chat/worktree.js +25 -5
  206. package/dist/commands/ui/comp-approval.d.ts +14 -2
  207. package/dist/commands/ui/comp-approval.js +45 -8
  208. package/dist/commands/ui/index.js +3 -0
  209. package/dist/commands/ui/level-route.js +3 -0
  210. package/dist/commands/ui/loop-approve.d.ts +30 -1
  211. package/dist/commands/ui/loop-approve.js +2 -2
  212. package/dist/commands/ui/merge-authority.d.ts +4 -1
  213. package/dist/commands/ui/merge-authority.en.d.ts +4 -0
  214. package/dist/commands/ui/merge-authority.en.js +5 -1
  215. package/dist/commands/ui/merge-authority.es.d.ts +4 -0
  216. package/dist/commands/ui/merge-authority.es.js +5 -1
  217. package/dist/commands/ui/merge-authority.js +6 -3
  218. package/dist/commands/ui/merge-claims.d.ts +7 -0
  219. package/dist/commands/ui/merge-claims.js +21 -0
  220. package/dist/commands/ui/merge-delegation.js +8 -3
  221. package/dist/commands/ui/merge-hold-name.d.ts +5 -0
  222. package/dist/commands/ui/merge-hold-name.js +5 -0
  223. package/dist/commands/ui/merge-hold.d.ts +6 -1
  224. package/dist/commands/ui/merge-hold.js +23 -5
  225. package/dist/commands/ui/merge-publish-host.d.ts +1 -0
  226. package/dist/commands/ui/merge-publish-host.js +2 -2
  227. package/dist/commands/ui/merge-record.d.ts +2 -0
  228. package/dist/commands/ui/merge-record.js +1 -1
  229. package/dist/commands/ui/merge-route.js +20 -1
  230. package/dist/commands/ui/merge-settle.d.ts +32 -0
  231. package/dist/commands/ui/merge-settle.js +133 -0
  232. package/dist/commands/ui/merge-state.d.ts +5 -0
  233. package/dist/commands/ui/merge-state.js +7 -1
  234. package/dist/commands/ui/merge-withdraw.d.ts +9 -0
  235. package/dist/commands/ui/merge-withdraw.js +29 -0
  236. package/dist/commands/ui/places-change.d.ts +4 -0
  237. package/dist/commands/ui/plan-files.js +5 -2
  238. package/dist/commands/ui/plan-structure.js +5 -7
  239. package/dist/commands/ui/prototype-comp-route.d.ts +12 -3
  240. package/dist/commands/ui/prototype-comp-route.js +35 -17
  241. package/dist/commands/ui/prototype-main.d.ts +4 -0
  242. package/dist/commands/ui/real-file.d.ts +11 -0
  243. package/dist/commands/ui/real-file.js +84 -0
  244. package/dist/commands/ui/reopen-route.d.ts +117 -0
  245. package/dist/commands/ui/reopen-route.js +97 -0
  246. package/dist/commands/ui/save-route.d.ts +2 -0
  247. package/dist/commands/ui/save-route.js +8 -1
  248. package/dist/commands/ui/server.d.ts +1 -0
  249. package/dist/commands/ui/server.js +1 -0
  250. package/dist/commands/ui/studio-routes.js +2 -0
  251. package/dist/commands/ui/studio-state.d.ts +34 -0
  252. package/dist/commands/ui/studio-versions.d.ts +24 -0
  253. package/dist/commands/ui/studio-versions.js +19 -3
  254. package/dist/commands/ui/worktrees.d.ts +1 -1
  255. package/dist/commands/ui/worktrees.js +19 -3
  256. package/dist/commands/worktree-sweep.d.ts +45 -0
  257. package/dist/commands/worktree-sweep.js +188 -0
  258. package/dist/commands/worktrees-command.d.ts +32 -0
  259. package/dist/commands/worktrees-command.en.d.ts +25 -0
  260. package/dist/commands/worktrees-command.en.js +55 -0
  261. package/dist/commands/worktrees-command.js +96 -0
  262. package/dist/main.js +2 -0
  263. package/dist/ui/page.js +89 -89
  264. package/docs/PROTOTYPE.md +19 -3
  265. package/docs/WORKBENCH.md +41 -6
  266. package/package.json +11 -11
  267. package/skills/ape-critique/SKILL.md +41 -6
  268. package/skills/ape-deploy/SKILL.md +4 -2
  269. package/skills/ape-design-system/SKILL.md +3 -0
  270. package/skills/ape-plan-change/SKILL.md +6 -0
  271. package/skills/ape-prototype/SKILL.md +8 -4
@@ -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('\\', '/');
@@ -161,6 +161,19 @@ export declare const en: {
161
161
  'prototype.worktreeBusy': string;
162
162
  'prototype.noSlot': string;
163
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;
164
177
  'prototype.pagesHelp': string;
165
178
  'prototype.invalidPages': string;
166
179
  'prototype.lowMemory': string;
@@ -171,4 +184,5 @@ export declare const en: {
171
184
  'prototype.exportServe': string;
172
185
  'prototype.exportServeBase': string;
173
186
  'prototype.exportServeRelative': string;
187
+ 'prototype.milestoneFull': string;
174
188
  };
@@ -43,7 +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: {looks} looks, {scenes} scenes.',
46
+ 'prototype.drawFallbacks': 'Full-page fallbacks in the scenes drawn this run: {looks} looks, {scenes} scenes.',
47
47
  'prototype.sceneFailed': 'Scene "{scene}" failed{retry}: {detail}',
48
48
  'prototype.serverUnavailable': 'Server "{server}" is not answering for scene "{scene}". {status}.',
49
49
  'prototype.serverExitCode': 'Last exit code was {code}',
@@ -162,6 +162,19 @@ export const en = {
162
162
  'prototype.worktreeBusy': 'Another snapshot of this change is already running. Take this one when it has finished.',
163
163
  'prototype.noSlot': 'Two snapshots are already running in this repository. Take this one when one has finished.',
164
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',
165
178
  'prototype.pagesHelp': 'scene pages open at once, 1 to 4 (default uses cores and free memory, up to 2 with admin scenes)',
166
179
  'prototype.invalidPages': '--pages must be a whole number from 1 to {max}.',
167
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.',
@@ -172,4 +185,5 @@ export const en = {
172
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.',
173
186
  'prototype.exportServeBase': 'Serve that folder at {base} of any static file server and open it there: no API, database or development server.',
174
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.',
175
189
  };
@@ -44,7 +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: {looks} apariencias, {scenes} escenas.',
47
+ 'prototype.drawFallbacks': 'Recargas completas en las escenas dibujadas en esta ejecución: {looks} apariencias, {scenes} escenas.',
48
48
  'prototype.sceneFailed': 'La escena "{scene}" falló{retry}: {detail}',
49
49
  'prototype.serverUnavailable': 'El servidor "{server}" no responde para la escena "{scene}". {status}.',
50
50
  'prototype.serverExitCode': 'El último código de salida fue {code}',
@@ -163,6 +163,19 @@ const es = {
163
163
  'prototype.worktreeBusy': 'Ya se está tomando otra captura de este cambio. Toma esta cuando termine.',
164
164
  'prototype.noSlot': 'Ya se están tomando dos capturas en este repositorio. Toma esta cuando termine una.',
165
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',
166
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)',
167
180
  'prototype.invalidPages': '--pages debe ser un número entero de 1 a {max}.',
168
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.',
@@ -173,6 +186,7 @@ const es = {
173
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.',
174
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.',
175
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.',
176
190
  };
177
191
  /** The locale the prototype's words are shown in (also for the lists inside them). */
178
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);
@@ -0,0 +1,16 @@
1
+ /** Why a committed folder stays. */
2
+ export type KeptBecause = 'version' | 'newest' | 'head' | 'unsaved';
3
+ export interface PruneResult {
4
+ ok: true;
5
+ dryRun: boolean;
6
+ /** The folders removed (with `--dry-run`, the ones that would be), under `prototype/snapshots/`. */
7
+ removed: string[];
8
+ kept: {
9
+ folder: string;
10
+ because: KeptBecause;
11
+ }[];
12
+ }
13
+ /** Remove (or, with `dryRun`, list) the committed snapshot folders nothing needs. */
14
+ export declare function pruneSnapshots(root: string, { dryRun }?: {
15
+ dryRun?: boolean | undefined;
16
+ }): PruneResult;
@@ -0,0 +1,9 @@
1
+ export declare const en: {
2
+ 'prune.help': string;
3
+ 'prune.dryRunHelp': string;
4
+ 'prune.jsonHelp': string;
5
+ 'prune.unreadable': string;
6
+ 'prune.nothing': string;
7
+ 'prune.wouldRemove': string;
8
+ 'prune.removed': string;
9
+ };
@@ -0,0 +1,9 @@
1
+ export const en = {
2
+ 'prune.help': 'Remove committed snapshot folders no version names (keeps the newest, HEAD’s and unsaved ones); their history stays in git',
3
+ 'prune.dryRunHelp': 'list what would be removed, and remove nothing',
4
+ 'prune.jsonHelp': 'the result as JSON; exit 0 done, 2 could not run',
5
+ 'prune.unreadable': 'Could not read {file}: fix it, then prune again.',
6
+ 'prune.nothing': 'Nothing to remove: every committed snapshot folder is named by a version, the newest, HEAD’s or unsaved.',
7
+ 'prune.wouldRemove': '{count, plural, one {Would remove # snapshot folder} other {Would remove # snapshot folders}} no version names: {folders}. Run without --dry-run to remove them.',
8
+ 'prune.removed': '{count, plural, one {Removed # snapshot folder} other {Removed # snapshot folders}} no version names: {folders}. Commit the deletion: their history stays in git.',
9
+ };
@@ -0,0 +1,2 @@
1
+ import type { en } from './prune.en.ts';
2
+ export declare const es: typeof en;
@@ -0,0 +1,9 @@
1
+ export const es = {
2
+ 'prune.help': 'Quita las carpetas de capturas guardadas que ninguna versión nombra (conserva la más reciente, la de HEAD y las que tienen cambios sin guardar); su historial queda en git',
3
+ 'prune.dryRunHelp': 'lista lo que se quitaría, sin quitar nada',
4
+ 'prune.jsonHelp': 'el resultado en JSON; sale con 0 si terminó, 2 si no pudo ejecutarse',
5
+ 'prune.unreadable': 'No se pudo leer {file}: corrígelo y vuelve a ejecutar prune.',
6
+ 'prune.nothing': 'No hay nada que quitar: cada carpeta de capturas guardada la nombra una versión, es la más reciente, la de HEAD o tiene cambios sin guardar.',
7
+ 'prune.wouldRemove': '{count, plural, one {Se quitaría # carpeta de capturas} other {Se quitarían # carpetas de capturas}} que ninguna versión nombra: {folders}. Ejecuta sin --dry-run para quitarlas.',
8
+ 'prune.removed': '{count, plural, one {Se quitó # carpeta de capturas} other {Se quitaron # carpetas de capturas}} que ninguna versión nombra: {folders}. Guarda el borrado en un commit: su historial queda en git.',
9
+ };