@buffcore/cli 0.8.46 → 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.
- package/CHANGELOG.md +56 -0
- package/dist/commands/change-merge-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/design/check.d.ts +1 -1
- package/dist/commands/design/check.js +2 -1
- package/dist/commands/design/contract-size.d.ts +7 -0
- package/dist/commands/design/contract-size.js +47 -0
- package/dist/commands/design/tells.en.d.ts +2 -0
- package/dist/commands/design/tells.en.js +2 -0
- package/dist/commands/design/tells.es.js +2 -0
- package/dist/commands/extension/places-approval.d.ts +4 -0
- package/dist/commands/process-paths.d.ts +14 -0
- package/dist/commands/process-paths.js +90 -0
- package/dist/commands/prototype/ai-approval.d.ts +27 -0
- package/dist/commands/prototype/ai-approval.js +60 -0
- package/dist/commands/prototype/approver.d.ts +71 -0
- package/dist/commands/prototype/approver.js +168 -0
- package/dist/commands/prototype/critique-gate.d.ts +14 -0
- package/dist/commands/prototype/critique-gate.js +48 -0
- package/dist/commands/prototype/fence.d.ts +1 -0
- package/dist/commands/prototype/fence.js +12 -0
- package/dist/commands/prototype/final-approval-grant.js +18 -0
- package/dist/commands/prototype/final-approval.js +4 -1
- package/dist/commands/prototype/index.js +3 -0
- package/dist/commands/prototype/layout-hints.d.ts +34 -0
- package/dist/commands/prototype/layout-hints.js +194 -0
- package/dist/commands/prototype/layout-measure.d.ts +39 -0
- package/dist/commands/prototype/layout-measure.js +97 -0
- package/dist/commands/prototype/layout-words.d.ts +2 -0
- package/dist/commands/prototype/layout-words.js +11 -0
- package/dist/commands/prototype/layout.en.d.ts +6 -0
- package/dist/commands/prototype/layout.en.js +7 -0
- package/dist/commands/prototype/load-location.js +2 -3
- package/dist/commands/prototype/messages.en.d.ts +14 -0
- package/dist/commands/prototype/messages.en.js +15 -1
- package/dist/commands/prototype/messages.js +15 -1
- package/dist/commands/prototype/milestone-versions.d.ts +4 -0
- package/dist/commands/prototype/prune-command.d.ts +5 -0
- package/dist/commands/prototype/prune-command.js +25 -0
- package/dist/commands/prototype/prune-words.d.ts +1 -0
- package/dist/commands/prototype/prune-words.js +7 -0
- package/dist/commands/prototype/prune.d.ts +16 -0
- package/dist/commands/prototype/prune.en.d.ts +9 -0
- package/dist/commands/prototype/prune.en.js +9 -0
- package/dist/commands/prototype/prune.es.d.ts +2 -0
- package/dist/commands/prototype/prune.es.js +9 -0
- package/dist/commands/prototype/prune.js +140 -0
- package/dist/commands/prototype/reopen-messages.d.ts +9 -0
- package/dist/commands/prototype/reopen-messages.js +19 -0
- package/dist/commands/prototype/report.d.ts +14 -0
- package/dist/commands/prototype/report.js +5 -1
- package/dist/commands/prototype/scene-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-ready.js +8 -2
- package/dist/commands/prototype/scene.d.ts +15 -2
- package/dist/commands/prototype/scene.js +54 -42
- package/dist/commands/prototype/selector-answer.d.ts +43 -0
- package/dist/commands/prototype/selector-answer.js +73 -0
- package/dist/commands/prototype/selector-misses.d.ts +19 -0
- package/dist/commands/prototype/selector-misses.js +78 -0
- package/dist/commands/prototype/selector-prompt.d.ts +23 -0
- package/dist/commands/prototype/selector-prompt.js +32 -0
- package/dist/commands/prototype/selector-run.d.ts +13 -0
- package/dist/commands/prototype/selector-run.js +113 -0
- package/dist/commands/prototype/selector.d.ts +54 -0
- package/dist/commands/prototype/selector.js +96 -0
- package/dist/commands/prototype/snapshot-ancestor.js +2 -0
- package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
- package/dist/commands/prototype/snapshot-bundle.js +69 -7
- package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
- package/dist/commands/prototype/snapshot-check-files.js +41 -0
- package/dist/commands/prototype/snapshot-command.d.ts +2 -0
- package/dist/commands/prototype/snapshot-command.js +3 -0
- package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
- package/dist/commands/prototype/snapshot-completion.js +30 -2
- package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
- package/dist/commands/prototype/snapshot-dependencies.js +120 -14
- package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
- package/dist/commands/prototype/snapshot-hashes.js +28 -0
- package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
- package/dist/commands/prototype/snapshot-inputs.js +140 -197
- package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
- package/dist/commands/prototype/snapshot-matrix.js +95 -0
- package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
- package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
- package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
- package/dist/commands/prototype/snapshot-owners.js +12 -3
- package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
- package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
- package/dist/commands/prototype/snapshot-progress.js +54 -102
- package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-registry.js +121 -0
- package/dist/commands/prototype/snapshot-report.d.ts +4 -0
- package/dist/commands/prototype/snapshot-report.js +77 -12
- package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
- package/dist/commands/prototype/snapshot-requests.js +68 -30
- package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
- package/dist/commands/prototype/snapshot-reuse.js +17 -7
- package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
- package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
- package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
- package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
- package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
- package/dist/commands/prototype/snapshot-server-record.js +135 -0
- package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
- package/dist/commands/prototype/snapshot-servers.js +50 -2
- package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
- package/dist/commands/prototype/snapshot-setup.js +2 -1
- package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
- package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
- package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
- package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
- package/dist/commands/prototype/snapshot.d.ts +5 -0
- package/dist/commands/prototype/snapshot.js +72 -10
- package/dist/commands/prototype/version-commands.d.ts +4 -0
- package/dist/commands/prototype/version-commands.js +36 -8
- package/dist/commands/prototype/versions.d.ts +28 -2
- package/dist/commands/prototype/versions.js +25 -1
- package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
- package/dist/commands/prototype/vite-fs-path.js +15 -0
- package/dist/commands/remove-links.d.ts +6 -0
- package/dist/commands/remove-links.js +17 -0
- package/dist/commands/size-docs.d.ts +9 -0
- package/dist/commands/size-docs.en.d.ts +6 -0
- package/dist/commands/size-docs.en.js +6 -0
- package/dist/commands/size-docs.es.d.ts +2 -0
- package/dist/commands/size-docs.es.js +6 -0
- package/dist/commands/size-docs.js +28 -0
- package/dist/commands/size.d.ts +5 -2
- package/dist/commands/size.js +27 -9
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- package/dist/commands/ui/approval-authority.js +1 -0
- package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
- package/dist/commands/ui/autopilot-ai-approve.js +68 -0
- package/dist/commands/ui/autopilot-loop.js +5 -6
- package/dist/commands/ui/autopilot-merge.js +3 -0
- package/dist/commands/ui/autopilot.en.d.ts +23 -0
- package/dist/commands/ui/autopilot.en.js +23 -0
- package/dist/commands/ui/autopilot.es.d.ts +23 -0
- package/dist/commands/ui/autopilot.es.js +23 -0
- package/dist/commands/ui/chat/find.d.ts +2 -0
- package/dist/commands/ui/chat/find.js +13 -0
- package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
- package/dist/commands/ui/chat/fresh-codex.js +175 -0
- package/dist/commands/ui/chat/fresh-critique.js +13 -5
- package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
- package/dist/commands/ui/chat/fresh-launch.js +67 -11
- package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
- package/dist/commands/ui/chat/fresh-prompts.js +2 -0
- package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
- package/dist/commands/ui/chat/fresh-secrets.js +172 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.en.js +2 -1
- package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.es.js +2 -1
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/loop-approve.d.ts +30 -1
- package/dist/commands/ui/loop-approve.js +2 -2
- package/dist/commands/ui/merge-route.js +3 -0
- package/dist/commands/ui/places-change.d.ts +4 -0
- package/dist/commands/ui/prototype-main.d.ts +4 -0
- package/dist/commands/ui/reopen-route.d.ts +117 -0
- package/dist/commands/ui/reopen-route.js +97 -0
- package/dist/commands/ui/save-route.d.ts +2 -0
- package/dist/commands/ui/save-route.js +4 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +33 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/worktrees.d.ts +1 -1
- package/dist/commands/ui/worktrees.js +19 -3
- package/dist/commands/worktree-sweep.d.ts +45 -0
- package/dist/commands/worktree-sweep.js +188 -0
- package/dist/commands/worktrees-command.d.ts +32 -0
- package/dist/commands/worktrees-command.en.d.ts +25 -0
- package/dist/commands/worktrees-command.en.js +55 -0
- package/dist/commands/worktrees-command.js +96 -0
- package/dist/main.js +2 -0
- package/dist/ui/page.js +82 -82
- package/docs/PROTOTYPE.md +6 -3
- package/docs/WORKBENCH.md +11 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-design-system/SKILL.md +3 -0
- package/skills/ape-plan-change/SKILL.md +6 -0
- package/skills/ape-prototype/SKILL.md +8 -4
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { layoutFindings, spacingSteps } from './layout-hints.js';
|
|
2
|
+
import { measureLayout } from './layout-measure.js';
|
|
3
|
+
import { layoutText } from './layout-words.js';
|
|
4
|
+
import { number } from './messages.js';
|
|
5
|
+
/** A scene's layout hints in the report, at most: past this, its layout wants a look as a whole. */
|
|
6
|
+
export const MAX_LAYOUT_HINTS = 20;
|
|
7
|
+
/** True when the scene marks this finding as meant. */
|
|
8
|
+
export function setAside(finding, exceptions = []) {
|
|
9
|
+
const names = [finding.element, 'other' in finding ? finding.other : ''];
|
|
10
|
+
return exceptions.some((one) => one.kind === finding.kind &&
|
|
11
|
+
(!one.element || names.some((n) => n.includes(one.element ?? ''))));
|
|
12
|
+
}
|
|
13
|
+
/** The finding in the reader's words. */
|
|
14
|
+
export function layoutDetail(scene, finding) {
|
|
15
|
+
switch (finding.kind) {
|
|
16
|
+
case 'overlap':
|
|
17
|
+
return layoutText('layout.overlap', {
|
|
18
|
+
scene,
|
|
19
|
+
element: finding.element,
|
|
20
|
+
other: finding.other,
|
|
21
|
+
width: number(finding.width),
|
|
22
|
+
height: number(finding.height),
|
|
23
|
+
});
|
|
24
|
+
case 'edge':
|
|
25
|
+
return layoutText('layout.edge', {
|
|
26
|
+
scene,
|
|
27
|
+
element: finding.element,
|
|
28
|
+
offset: number(finding.offset),
|
|
29
|
+
count: number(finding.count),
|
|
30
|
+
});
|
|
31
|
+
case 'padding':
|
|
32
|
+
return layoutText('layout.padding', { scene, ...finding, count: number(finding.count) });
|
|
33
|
+
case 'gap':
|
|
34
|
+
return layoutText('layout.gap', {
|
|
35
|
+
scene,
|
|
36
|
+
...finding,
|
|
37
|
+
gap: number(finding.gap),
|
|
38
|
+
value: number(finding.value),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Measure the page as it shows `look` and add its new layout hints to the scene's `hints`. */
|
|
43
|
+
export async function addLayoutHints(page, scene, theme, look, hints) {
|
|
44
|
+
if (!theme)
|
|
45
|
+
return;
|
|
46
|
+
const boxes = JSON.parse(await page.evaluate(measureLayout));
|
|
47
|
+
const scale = scene.surface === 'app' ? (scene.scale ?? 1) : 1;
|
|
48
|
+
for (const finding of layoutFindings(boxes, spacingSteps(theme.space, scale))) {
|
|
49
|
+
if (hints.length >= MAX_LAYOUT_HINTS)
|
|
50
|
+
return;
|
|
51
|
+
if (setAside(finding, scene.layoutExceptions))
|
|
52
|
+
continue;
|
|
53
|
+
const detail = layoutDetail(scene.key, finding);
|
|
54
|
+
if (!hints.some((hint) => hint.detail === detail))
|
|
55
|
+
hints.push({ scene: scene.key, ...look, detail });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -75,8 +75,14 @@ const ANIMATION_WAIT = 2_000;
|
|
|
75
75
|
* focus ring. True when fonts or pictures were still loading as their allowance ran out.
|
|
76
76
|
*/
|
|
77
77
|
async function drawn(frame, locale, live, { animationWait, mediaWait, readyWait, onMedia }) {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// A lazy view still loading (`data-prototype-pending`) has not drawn yet.
|
|
79
|
+
await frame.waitForFunction((lang) => {
|
|
80
|
+
const root = document.getElementById('root');
|
|
81
|
+
return (document.documentElement.lang === lang &&
|
|
82
|
+
!!root &&
|
|
83
|
+
root.childElementCount > 0 &&
|
|
84
|
+
!root.querySelector('[data-prototype-pending]'));
|
|
85
|
+
}, locale, readyWait === undefined ? undefined : { timeout: readyWait });
|
|
80
86
|
// An attempt that lost its page (a module failed, the page loaded again) does nothing more.
|
|
81
87
|
if (!live())
|
|
82
88
|
return false;
|
|
@@ -6,8 +6,10 @@ import { type browserSession } from './browser.ts';
|
|
|
6
6
|
import type { SnapshotHint } from './report.ts';
|
|
7
7
|
import type { LoadFailure } from './scene-errors.ts';
|
|
8
8
|
import { type FallbackCounter } from './scene-look.ts';
|
|
9
|
+
import type { SelectorRecord } from './selector.ts';
|
|
10
|
+
import { type Matrix, type MatrixReason } from './snapshot-matrix.ts';
|
|
9
11
|
import type { SnapshotProgress } from './snapshot-progress.ts';
|
|
10
|
-
import { type SceneRequestFacts } from './snapshot-requests.ts';
|
|
12
|
+
import { type RequestCoverage, type SceneRequestFacts } from './snapshot-requests.ts';
|
|
11
13
|
import { lookKey, photographed } from './snapshot-themes.ts';
|
|
12
14
|
export { lookKey, photographed };
|
|
13
15
|
/** What every scene of one snapshot shares. */
|
|
@@ -33,10 +35,19 @@ export interface Run {
|
|
|
33
35
|
session?: ReturnType<typeof browserSession> | undefined;
|
|
34
36
|
requests?: SceneRequestFacts;
|
|
35
37
|
onFallback?: FallbackCounter | undefined;
|
|
36
|
-
|
|
38
|
+
coversRequest?: RequestCoverage | undefined;
|
|
37
39
|
saveScene?: SnapshotProgress['draw'] | undefined;
|
|
38
40
|
/** The first full-run scene on each surface, even when that scene has already finished. */
|
|
39
41
|
warmScenes?: ReadonlySet<string> | undefined;
|
|
42
|
+
/** The looks drawn (`snapshot-matrix.ts`); unset, the full matrix. */
|
|
43
|
+
matrix?: Matrix | undefined;
|
|
44
|
+
/** Why, and the shared inputs of the last full report, for `report.json`. */
|
|
45
|
+
matrixReason?: MatrixReason | undefined;
|
|
46
|
+
fullInputs?: string | undefined;
|
|
47
|
+
/** The selector (S3c): its record, the scenes it drew again and the looks it added, by scene. */
|
|
48
|
+
selector?: SelectorRecord | undefined;
|
|
49
|
+
redraw?: ReadonlySet<string> | undefined;
|
|
50
|
+
extraLooks?: ReadonlyMap<string, ReadonlySet<string>> | undefined;
|
|
40
51
|
/** Only the screenshots, no checks: `--remake` making a committed report's screenshots again. */
|
|
41
52
|
photosOnly?: boolean;
|
|
42
53
|
/** How a server the run started itself ended, if it has: read before `.ape/dev.json`. */
|
|
@@ -63,6 +74,8 @@ interface Found {
|
|
|
63
74
|
cut: string[];
|
|
64
75
|
problems: PrototypeProblem[];
|
|
65
76
|
hints: SnapshotHint[];
|
|
77
|
+
/** Layout hints (`scene-layout.ts`), apart from the font advice a late scene drops. */
|
|
78
|
+
layout?: SnapshotHint[];
|
|
66
79
|
/** The color pairs already reported, by theme and mode. */
|
|
67
80
|
pairs: Set<string>;
|
|
68
81
|
}
|
|
@@ -12,9 +12,11 @@ import { MEDIA_WAIT } from './media-ready.js';
|
|
|
12
12
|
import { t } from './messages.js';
|
|
13
13
|
import { describe, readText } from './readable.js';
|
|
14
14
|
import { freshLoadsAgree, lookEvidence } from './scene-check.js';
|
|
15
|
+
import { addLayoutHints } from './scene-layout.js';
|
|
15
16
|
import { LookMoveFailed, sceneLookLoader } from './scene-look.js';
|
|
16
17
|
import { renderScene, requireNoErrorOverlay, SceneTimeoutError } from './scene-render.js';
|
|
17
|
-
import {
|
|
18
|
+
import { drawnLooks } from './snapshot-matrix.js';
|
|
19
|
+
import { sceneRequests, settleRequests, } from './snapshot-requests.js';
|
|
18
20
|
import { shotName } from './snapshot-shots.js';
|
|
19
21
|
import { lookKey, photographed } from './snapshot-themes.js';
|
|
20
22
|
export { lookKey, photographed };
|
|
@@ -23,15 +25,20 @@ const LATE_WAIT = 1_000;
|
|
|
23
25
|
/** Open the first look so the surface can finish its cold build. */
|
|
24
26
|
export async function warmSurface(browser, scene, run, signal) {
|
|
25
27
|
await renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page) => {
|
|
26
|
-
|
|
27
|
-
sceneRequests(page, run, scene);
|
|
28
|
+
const requests = run.requests && sceneRequests(page, run, scene);
|
|
28
29
|
const look = { theme: run.product, mode: 'light', locale: run.first };
|
|
29
30
|
await openScene(page, sceneUrl(run.urls[scene.surface], scene.key, look), run.first);
|
|
31
|
+
await requests?.finish();
|
|
30
32
|
}, signal, run);
|
|
31
33
|
}
|
|
34
|
+
/** The facts a scene attempt has drawn with: a second attempt (a retry) is not tracked. */
|
|
35
|
+
const attempts = new WeakSet();
|
|
32
36
|
/** One scene in every theme, mode and language: its screenshots and its problems. */
|
|
33
37
|
export async function snapScene(browser, scene, run, signal) {
|
|
34
38
|
const requests = run.requests ?? { apiCalls: false, untrackedRequests: false };
|
|
39
|
+
if (attempts.has(requests))
|
|
40
|
+
requests.untrackedRequests = true;
|
|
41
|
+
attempts.add(requests);
|
|
35
42
|
const attempt = { ...run, requests };
|
|
36
43
|
let moved = false;
|
|
37
44
|
let started = performance.now();
|
|
@@ -56,13 +63,16 @@ export async function snapScene(browser, scene, run, signal) {
|
|
|
56
63
|
// Something an earlier look left behind changed a checked one: draw every look fresh.
|
|
57
64
|
run.onFallback?.('scene');
|
|
58
65
|
const { checks: _, ...fresh } = await drawScene(browser, scene, attempt, signal);
|
|
66
|
+
await settleRequests(requests);
|
|
59
67
|
return { ...fresh, ...requests };
|
|
60
68
|
}
|
|
69
|
+
// Every load's requests, check loads included, are checked against the scene's fingerprint.
|
|
70
|
+
await settleRequests(requests);
|
|
61
71
|
return { ...drawn, ...requests };
|
|
62
72
|
}
|
|
63
73
|
function drawScene(browser, scene, run, signal, onMove) {
|
|
64
74
|
return renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page, advise) => {
|
|
65
|
-
sceneRequests(page, run, scene);
|
|
75
|
+
const requests = sceneRequests(page, run, scene);
|
|
66
76
|
let moves = 0;
|
|
67
77
|
const show = sceneLookLoader(page, onMove && run.onFallback, Boolean(onMove), () => {
|
|
68
78
|
moves++;
|
|
@@ -85,45 +95,41 @@ function drawScene(browser, scene, run, signal, onMove) {
|
|
|
85
95
|
const declared = run.photosOnly
|
|
86
96
|
? undefined
|
|
87
97
|
: run.looks.find((theme) => theme.key === run.fontTheme);
|
|
88
|
-
for (const theme of run.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
seconds: MEDIA_WAIT / 1000,
|
|
109
|
-
}),
|
|
110
|
-
});
|
|
111
|
-
await checkLook(page, look, run, found).catch((error) => {
|
|
112
|
-
throw pageGone(error) ? new PageLoadError(String(error), { cause: error }) : error;
|
|
98
|
+
for (const { theme, mode, locale } of drawnLooks(run, scene.key)) {
|
|
99
|
+
const look = { theme: theme.key, mode, locale };
|
|
100
|
+
if (run.photosOnly && !(locale === run.first && photographed(theme.key, mode, run.product)))
|
|
101
|
+
continue;
|
|
102
|
+
const url = sceneUrl(run.urls[scene.surface], scene.key, look);
|
|
103
|
+
const mediaWait = late.length ? LATE_WAIT : undefined;
|
|
104
|
+
const before = moves;
|
|
105
|
+
requests.look();
|
|
106
|
+
const lateNow = await show(url, locale, mediaWait);
|
|
107
|
+
last = { look, url, mediaWait, late: lateNow };
|
|
108
|
+
const photoMoved = moves > before && locale === run.first && photographed(theme.key, mode, run.product);
|
|
109
|
+
if (lateNow)
|
|
110
|
+
if (!late.length)
|
|
111
|
+
late.push({
|
|
112
|
+
scene: scene.key,
|
|
113
|
+
...look,
|
|
114
|
+
detail: t('prototype.mediaLate', {
|
|
115
|
+
scene: scene.key,
|
|
116
|
+
seconds: MEDIA_WAIT / 1000,
|
|
117
|
+
}),
|
|
113
118
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
await checkLook(page, look, run, found).catch((error) => {
|
|
120
|
+
throw pageGone(error) ? new PageLoadError(String(error), { cause: error }) : error;
|
|
121
|
+
});
|
|
122
|
+
if (photoMoved)
|
|
123
|
+
photo = { last, evidence: await lookEvidence(page, last, run, scene, checkLook) };
|
|
124
|
+
if (theme === declared) {
|
|
125
|
+
const details = await advise(async (timeLeft) => (await watchFonts(page, scene.key, theme)?.(timeLeft)) ?? []);
|
|
126
|
+
if (!details)
|
|
127
|
+
found.hints.length = 0;
|
|
128
|
+
else
|
|
129
|
+
for (const detail of details)
|
|
130
|
+
found.hints.push({ scene: scene.key, ...look, detail });
|
|
126
131
|
}
|
|
132
|
+
await requireNoErrorOverlay(page);
|
|
127
133
|
}
|
|
128
134
|
const { screenshots, cut, problems } = found;
|
|
129
135
|
// A scene with a look moved in place proves its last look against a fresh load, and its
|
|
@@ -134,7 +140,8 @@ function drawScene(browser, scene, run, signal, onMove) {
|
|
|
134
140
|
if (photo && photo.last !== last)
|
|
135
141
|
checks.push(photo);
|
|
136
142
|
}
|
|
137
|
-
|
|
143
|
+
const hints = [...found.hints, ...(found.layout ?? []), ...late];
|
|
144
|
+
return { screenshots, cut, problems, hints, checks };
|
|
138
145
|
}, signal, run);
|
|
139
146
|
}
|
|
140
147
|
/** The scene page as it shows one look: photographed when it is reviewed, and checked. */
|
|
@@ -159,6 +166,11 @@ export async function checkLook(page, look, run, found) {
|
|
|
159
166
|
const where = { surface, locale, first: run.first, data: found.data, intl: run.intl };
|
|
160
167
|
for (const [check, detail] of pageProblems(measured, where))
|
|
161
168
|
found.problems.push({ check, scene, theme, locale, detail });
|
|
169
|
+
// Layout doesn't change with the mode either; measured in the first language.
|
|
170
|
+
found.layout ??= [];
|
|
171
|
+
const shown = run.looks.find((t) => t.key === theme);
|
|
172
|
+
if (locale === run.first)
|
|
173
|
+
await addLayoutHints(page, found.scene, shown, look, found.layout);
|
|
162
174
|
}
|
|
163
175
|
// A theme can change a box's size, so what sticks out is looked for in every mode.
|
|
164
176
|
for (const detail of clippedEdges(measured.edges))
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** One turn's answer: at most 40 picks, each with a one-line reason. */
|
|
3
|
+
export declare const SelectorAnswer: z.ZodObject<{
|
|
4
|
+
picks: z.ZodArray<z.ZodObject<{
|
|
5
|
+
scene: z.ZodString;
|
|
6
|
+
look: z.ZodOptional<z.ZodString>;
|
|
7
|
+
reason: z.ZodString;
|
|
8
|
+
}, z.core.$strict>>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type SelectorAnswer = z.infer<typeof SelectorAnswer>;
|
|
11
|
+
export type SelectorTurnNumber = 1 | 2;
|
|
12
|
+
export interface SelectorPick {
|
|
13
|
+
scene: string;
|
|
14
|
+
look?: string;
|
|
15
|
+
reason: string;
|
|
16
|
+
turn: SelectorTurnNumber;
|
|
17
|
+
}
|
|
18
|
+
/** Why a pick was dropped: an unknown scene or look, a look the floor draws already, a repeat. */
|
|
19
|
+
export type DropReason = 'scene' | 'look' | 'floor' | 'repeat';
|
|
20
|
+
export interface SelectorDrop {
|
|
21
|
+
scene: string;
|
|
22
|
+
look?: string;
|
|
23
|
+
turn: SelectorTurnNumber;
|
|
24
|
+
why: DropReason;
|
|
25
|
+
}
|
|
26
|
+
/** The answer in a turn's final text (bare, or in a fenced block), or undefined when out of shape. */
|
|
27
|
+
export declare function parseAnswer(text: string | undefined): SelectorAnswer | undefined;
|
|
28
|
+
/** The scenes and looks a run may add: every scene's key, the matrix's looks and the floor's. */
|
|
29
|
+
export interface SelectorBounds {
|
|
30
|
+
scenes: ReadonlySet<string>;
|
|
31
|
+
looks: ReadonlySet<string>;
|
|
32
|
+
floor: ReadonlySet<string>;
|
|
33
|
+
}
|
|
34
|
+
/** Both turns' picks, kept in order; the second turn's repeats of the first are dropped. */
|
|
35
|
+
export declare function unionPicks(answers: readonly (SelectorAnswer | undefined)[], bounds: SelectorBounds): {
|
|
36
|
+
picks: SelectorPick[];
|
|
37
|
+
dropped: SelectorDrop[];
|
|
38
|
+
};
|
|
39
|
+
/** What the run draws beyond the floor: scenes drawn again, and each scene's added looks. */
|
|
40
|
+
export declare function extrasOf(picks: readonly SelectorPick[]): {
|
|
41
|
+
scenes: Set<string>;
|
|
42
|
+
looks: Map<string, Set<string>>;
|
|
43
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The selector's answer (S3c): a fixed JSON shape, read at this edge with Zod, and the union of
|
|
2
|
+
// both turns' picks with the floor. A pick only adds: a scene to draw again in the floor, or a look
|
|
3
|
+
// beyond the floor for one scene. Anything outside the scene list or the matrix is dropped and noted.
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/** One turn's answer: at most 40 picks, each with a one-line reason. */
|
|
6
|
+
export const SelectorAnswer = z
|
|
7
|
+
.object({
|
|
8
|
+
picks: z
|
|
9
|
+
.array(z
|
|
10
|
+
.object({
|
|
11
|
+
scene: z.string().min(1).max(100),
|
|
12
|
+
/** `<theme>.<mode>.<locale>`, one of the matrix's looks; absent: the scene in the floor. */
|
|
13
|
+
look: z.string().min(1).max(140).optional(),
|
|
14
|
+
reason: z.string().trim().min(1).max(200),
|
|
15
|
+
})
|
|
16
|
+
.strict())
|
|
17
|
+
.max(40),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
/** The answer in a turn's final text (bare, or in a fenced block), or undefined when out of shape. */
|
|
21
|
+
export function parseAnswer(text) {
|
|
22
|
+
if (!text)
|
|
23
|
+
return;
|
|
24
|
+
const start = text.indexOf('{');
|
|
25
|
+
const end = text.lastIndexOf('}');
|
|
26
|
+
if (start < 0 || end <= start)
|
|
27
|
+
return;
|
|
28
|
+
try {
|
|
29
|
+
const parsed = SelectorAnswer.safeParse(JSON.parse(text.slice(start, end + 1)));
|
|
30
|
+
return parsed.success ? parsed.data : undefined;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Both turns' picks, kept in order; the second turn's repeats of the first are dropped. */
|
|
37
|
+
export function unionPicks(answers, bounds) {
|
|
38
|
+
const picks = [];
|
|
39
|
+
const dropped = [];
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
answers.forEach((answer, index) => {
|
|
42
|
+
const turn = (index + 1);
|
|
43
|
+
for (const { scene, look, reason } of answer?.picks ?? []) {
|
|
44
|
+
const where = { scene, ...(look ? { look } : {}), turn };
|
|
45
|
+
const key = JSON.stringify([scene, look ?? null]);
|
|
46
|
+
const why = !bounds.scenes.has(scene)
|
|
47
|
+
? 'scene'
|
|
48
|
+
: look !== undefined && !bounds.looks.has(look)
|
|
49
|
+
? 'look'
|
|
50
|
+
: look !== undefined && bounds.floor.has(look)
|
|
51
|
+
? 'floor'
|
|
52
|
+
: seen.has(key)
|
|
53
|
+
? 'repeat'
|
|
54
|
+
: undefined;
|
|
55
|
+
if (why)
|
|
56
|
+
dropped.push({ ...where, why });
|
|
57
|
+
else {
|
|
58
|
+
seen.add(key);
|
|
59
|
+
picks.push({ ...where, reason });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return { picks, dropped };
|
|
64
|
+
}
|
|
65
|
+
/** What the run draws beyond the floor: scenes drawn again, and each scene's added looks. */
|
|
66
|
+
export function extrasOf(picks) {
|
|
67
|
+
const scenes = new Set(picks.map((pick) => pick.scene));
|
|
68
|
+
const looks = new Map();
|
|
69
|
+
for (const { scene, look } of picks)
|
|
70
|
+
if (look)
|
|
71
|
+
looks.set(scene, (looks.get(scene) ?? new Set()).add(look));
|
|
72
|
+
return { scenes, looks };
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SnapshotReport } from './report.ts';
|
|
2
|
+
export declare const MISSES_FILE = "selector-misses.json";
|
|
3
|
+
/** The misses kept, newest last. */
|
|
4
|
+
export declare const MAX_MISSES = 20;
|
|
5
|
+
export interface SelectorMiss {
|
|
6
|
+
/** The full report that found it. */
|
|
7
|
+
report: string;
|
|
8
|
+
scene: string;
|
|
9
|
+
check: string;
|
|
10
|
+
theme: string;
|
|
11
|
+
mode?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The latest misses in the snapshots folder; none when the file is missing or unreadable. */
|
|
15
|
+
export declare function readMisses(dir: string): SelectorMiss[];
|
|
16
|
+
/** The problems of a full report that the last selector run (`last`) did not draw. */
|
|
17
|
+
export declare function findMisses(full: SnapshotReport, last: SnapshotReport | undefined): SelectorMiss[];
|
|
18
|
+
/** Add the new misses, once each, and keep the latest; true when the file changed. */
|
|
19
|
+
export declare function recordMisses(dir: string, found: readonly SelectorMiss[]): boolean;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Learning without a person (S3c): a full run that finds a problem in a look the last selector run
|
|
2
|
+
// didn't draw for that scene records the miss in `prototype/snapshots/selector-misses.json`
|
|
3
|
+
// (committed with the report), and later selector turns get the latest misses as examples.
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
export const MISSES_FILE = 'selector-misses.json';
|
|
7
|
+
/** The misses kept, newest last. */
|
|
8
|
+
export const MAX_MISSES = 20;
|
|
9
|
+
const isMiss = (value) => {
|
|
10
|
+
const miss = value;
|
|
11
|
+
return (!!miss &&
|
|
12
|
+
typeof miss.report === 'string' &&
|
|
13
|
+
typeof miss.scene === 'string' &&
|
|
14
|
+
typeof miss.check === 'string' &&
|
|
15
|
+
typeof miss.theme === 'string');
|
|
16
|
+
};
|
|
17
|
+
/** The latest misses in the snapshots folder; none when the file is missing or unreadable. */
|
|
18
|
+
export function readMisses(dir) {
|
|
19
|
+
try {
|
|
20
|
+
const value = JSON.parse(readFileSync(join(dir, MISSES_FILE), 'utf8'));
|
|
21
|
+
const misses = value?.misses;
|
|
22
|
+
return Array.isArray(misses) ? misses.filter(isMiss).slice(-MAX_MISSES) : [];
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Whether the selector run drew this problem's look for its scene: a floor look or a pick. */
|
|
29
|
+
function drawn(selector, problem) {
|
|
30
|
+
const looks = [
|
|
31
|
+
...selector.floor,
|
|
32
|
+
...selector.picks.flatMap((pick) => pick.scene === problem.scene && pick.look ? [pick.look] : []),
|
|
33
|
+
];
|
|
34
|
+
return looks.some((look) => {
|
|
35
|
+
const [theme, mode, locale] = look.split('.');
|
|
36
|
+
return (theme === problem.theme &&
|
|
37
|
+
(problem.mode === undefined || mode === problem.mode) &&
|
|
38
|
+
(problem.locale === undefined || locale === problem.locale));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** The problems of a full report that the last selector run (`last`) did not draw. */
|
|
42
|
+
export function findMisses(full, last) {
|
|
43
|
+
const selector = last?.selector;
|
|
44
|
+
if (full.matrix !== 'full' || full.scene !== undefined || !selector)
|
|
45
|
+
return [];
|
|
46
|
+
return full.problems.flatMap((problem) => {
|
|
47
|
+
if (!problem.scene)
|
|
48
|
+
return [];
|
|
49
|
+
const miss = {
|
|
50
|
+
report: full.commit,
|
|
51
|
+
scene: problem.scene,
|
|
52
|
+
check: problem.check,
|
|
53
|
+
theme: problem.theme,
|
|
54
|
+
...(problem.mode ? { mode: problem.mode } : {}),
|
|
55
|
+
...(problem.locale ? { locale: problem.locale } : {}),
|
|
56
|
+
};
|
|
57
|
+
return drawn(selector, miss) ? [] : [miss];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Add the new misses, once each, and keep the latest; true when the file changed. */
|
|
61
|
+
export function recordMisses(dir, found) {
|
|
62
|
+
if (!found.length)
|
|
63
|
+
return false;
|
|
64
|
+
const known = readMisses(dir);
|
|
65
|
+
const keys = new Set(known.map((miss) => JSON.stringify({ ...miss, report: '' })));
|
|
66
|
+
const added = found.filter((miss) => {
|
|
67
|
+
const key = JSON.stringify({ ...miss, report: '' });
|
|
68
|
+
if (keys.has(key))
|
|
69
|
+
return false;
|
|
70
|
+
keys.add(key);
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
if (!added.length)
|
|
74
|
+
return false;
|
|
75
|
+
const misses = [...known, ...added].slice(-MAX_MISSES);
|
|
76
|
+
writeFileSync(join(dir, MISSES_FILE), `${JSON.stringify({ misses }, null, 2)}\n`);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SelectorMiss } from './selector-misses.ts';
|
|
2
|
+
export interface SelectorInput {
|
|
3
|
+
/** The commit of the report the floor compared with; absent when there is none. */
|
|
4
|
+
base?: string;
|
|
5
|
+
/** `git diff` since that commit (stat and patch, bounded). */
|
|
6
|
+
diff: string;
|
|
7
|
+
scenes: readonly {
|
|
8
|
+
key: string;
|
|
9
|
+
surface: string;
|
|
10
|
+
view: string;
|
|
11
|
+
}[];
|
|
12
|
+
/** The looks every scene is drawn in, `<theme>.<mode>.<locale>`. */
|
|
13
|
+
floor: readonly string[];
|
|
14
|
+
/** Every look a pick may name. */
|
|
15
|
+
looks: readonly string[];
|
|
16
|
+
/** Recent looks a full run found a problem in that the selector had not drawn. */
|
|
17
|
+
misses: readonly SelectorMiss[];
|
|
18
|
+
}
|
|
19
|
+
/** The prompt of one selector turn; `first` holds the first turn's picks (the second turn only). */
|
|
20
|
+
export declare function selectorPrompt(input: SelectorInput, first?: readonly {
|
|
21
|
+
scene: string;
|
|
22
|
+
look?: string;
|
|
23
|
+
}[]): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// What the selector's turns are asked (S3c). Both turns get the same input; the second also gets the
|
|
2
|
+
// first answer's picks without their reasons, and may only add. The agent reads; it writes nothing.
|
|
3
|
+
import { fenceData } from './fence.js';
|
|
4
|
+
const SHAPE = '{"picks":[{"scene":"<scene key>","look":"<theme>.<mode>.<locale>","reason":"<one line>"}]}';
|
|
5
|
+
/** The prompt of one selector turn; `first` holds the first turn's picks (the second turn only). */
|
|
6
|
+
export function selectorPrompt(input, first) {
|
|
7
|
+
return [
|
|
8
|
+
'You choose extra screenshots for a prototype snapshot. Read the repository as you need; change nothing.',
|
|
9
|
+
'Every scene that changed is drawn in the floor looks below. Name the scenes and looks the change could',
|
|
10
|
+
'break that the floor does not draw: a scene to draw again in the floor (omit "look"), or one look from the',
|
|
11
|
+
'list of possible looks for a scene. You can only add; the floor always stays. Name nothing you cannot',
|
|
12
|
+
'justify in one line. An empty list is a good answer when the floor is enough.',
|
|
13
|
+
`Answer with JSON only, exactly this shape, at most 40 picks: ${SHAPE}`,
|
|
14
|
+
...(first
|
|
15
|
+
? [
|
|
16
|
+
'Another reviewer already picked the following; it stays. Add only what it missed, or answer {"picks":[]}.',
|
|
17
|
+
JSON.stringify(first),
|
|
18
|
+
]
|
|
19
|
+
: []),
|
|
20
|
+
`Floor looks: ${JSON.stringify(input.floor)}`,
|
|
21
|
+
`Possible looks: ${JSON.stringify(input.looks)}`,
|
|
22
|
+
`Scenes (key, surface, view it imports): ${JSON.stringify(input.scenes.map((s) => [s.key, s.surface, s.view]))}`,
|
|
23
|
+
...(input.misses.length
|
|
24
|
+
? [
|
|
25
|
+
'Earlier misses (a full run found a problem in a look the selector had not drawn):',
|
|
26
|
+
JSON.stringify(input.misses),
|
|
27
|
+
]
|
|
28
|
+
: []),
|
|
29
|
+
input.base ? `Changes since ${input.base}:` : 'No earlier report: the changes are unknown.',
|
|
30
|
+
fenceData('diff', input.diff),
|
|
31
|
+
].join('\n');
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SnapshotReport } from './report.ts';
|
|
2
|
+
import type { Run } from './scene.ts';
|
|
3
|
+
import { type SelectorRecord } from './selector.ts';
|
|
4
|
+
import type { SelectorInput } from './selector-prompt.ts';
|
|
5
|
+
import type { SnapshotOptions } from './snapshot.ts';
|
|
6
|
+
/** How a snapshot run asks the selector: the CLI's real turns, or a test's fake. */
|
|
7
|
+
export type Selector = (folder: string, input: SelectorInput) => Promise<SelectorRecord>;
|
|
8
|
+
/** The CLI's selector: plan/agents.md's validation agent and model, through the studio's launch. */
|
|
9
|
+
export declare function cliSelector(root: string, env?: NodeJS.ProcessEnv): Selector;
|
|
10
|
+
/** Ask the selector (whole floor runs only) and add its picks to the run; never throws. */
|
|
11
|
+
export declare function selectForRun(options: SnapshotOptions, run: Run): Promise<void>;
|
|
12
|
+
/** After a whole full run: note the problems in looks the last selector run didn't draw. */
|
|
13
|
+
export declare function afterFullRun(options: SnapshotOptions, report: SnapshotReport): void;
|