@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.
- package/CHANGELOG.md +63 -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/browser.d.ts +4 -24
- package/dist/commands/prototype/browser.js +13 -76
- 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/loaded-garbage.d.ts +10 -0
- package/dist/commands/prototype/loaded-garbage.js +20 -0
- package/dist/commands/prototype/media-ready.d.ts +9 -3
- package/dist/commands/prototype/media-ready.js +9 -4
- package/dist/commands/prototype/messages.en.d.ts +15 -0
- package/dist/commands/prototype/messages.en.js +15 -0
- package/dist/commands/prototype/messages.js +15 -0
- 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-check.d.ts +37 -0
- package/dist/commands/prototype/scene-check.js +68 -0
- package/dist/commands/prototype/scene-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-look.d.ts +14 -0
- package/dist/commands/prototype/scene-look.js +89 -0
- package/dist/commands/prototype/scene-ready.d.ts +46 -0
- package/dist/commands/prototype/scene-ready.js +122 -0
- package/dist/commands/prototype/scene.d.ts +37 -3
- package/dist/commands/prototype/scene.js +103 -36
- 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 +23 -10
- 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 -190
- 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 +54 -4
- 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 +6 -0
- package/dist/commands/prototype/snapshot.js +73 -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
- package/templates/product/apps/app/app.json +3 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { MEDIA_WAIT, mediaReady } from './media-ready.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs inside the page (Playwright sends its source): paints two frames, then resolves when the
|
|
4
|
+
* animations have finished, so a sheet fading in is not caught half way, or after `timeout` ms.
|
|
5
|
+
* An animation that never ends (a spinner) is not waited for. Chromium paints no frame in a framed
|
|
6
|
+
* page from another origin while it is off screen, so the wait for a paint ends after a second.
|
|
7
|
+
*/
|
|
8
|
+
export async function animationsDone(timeout) {
|
|
9
|
+
const frames = () => new Promise((done) => {
|
|
10
|
+
requestAnimationFrame(() => requestAnimationFrame(done));
|
|
11
|
+
setTimeout(done, 1_000);
|
|
12
|
+
});
|
|
13
|
+
const end = performance.now() + timeout;
|
|
14
|
+
await frames();
|
|
15
|
+
while (performance.now() < end) {
|
|
16
|
+
const running = document
|
|
17
|
+
.getAnimations()
|
|
18
|
+
.filter((a) => a.playState === 'running' && a.effect?.getComputedTiming().endTime !== Infinity);
|
|
19
|
+
if (running.length === 0)
|
|
20
|
+
return;
|
|
21
|
+
const wait = Math.max(end - performance.now(), 0);
|
|
22
|
+
await Promise.race([
|
|
23
|
+
Promise.allSettled(running.map((a) => a.finished)),
|
|
24
|
+
new Promise((done) => setTimeout(done, wait)),
|
|
25
|
+
]);
|
|
26
|
+
await frames();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Set on `<html>` when the view took the focus back on purpose (`unfocused`). */
|
|
30
|
+
export const SCENE_FOCUS_KEPT = 'data-scene-focus-kept';
|
|
31
|
+
/**
|
|
32
|
+
* Runs inside the page, after `animationsDone` has painted two frames (so the view's mount effects
|
|
33
|
+
* and autofocus have had their chance): blur whatever has focus, and again after each frame until
|
|
34
|
+
* nothing does, for up to `timeout` ms. A field that autofocuses late (Expo's router can commit the
|
|
35
|
+
* root before the view) then shows no focus ring on any path. An element that takes the focus back
|
|
36
|
+
* after its blur does so on purpose (a sheet that focuses its field): it keeps the focus, as a plain
|
|
37
|
+
* load shows it, and `<html>` is marked with `data-scene-focus-kept`. True when nothing has focus.
|
|
38
|
+
*/
|
|
39
|
+
export async function unfocused(timeout) {
|
|
40
|
+
const frames = () => new Promise((done) => {
|
|
41
|
+
requestAnimationFrame(() => requestAnimationFrame(done));
|
|
42
|
+
setTimeout(done, 1_000);
|
|
43
|
+
});
|
|
44
|
+
const end = performance.now() + timeout;
|
|
45
|
+
const focused = () => {
|
|
46
|
+
const active = document.activeElement;
|
|
47
|
+
return active && active !== document.body && active !== document.documentElement
|
|
48
|
+
? active
|
|
49
|
+
: undefined;
|
|
50
|
+
};
|
|
51
|
+
// The same name as SCENE_FOCUS_KEPT: Playwright sends this function as text.
|
|
52
|
+
document.documentElement.removeAttribute('data-scene-focus-kept');
|
|
53
|
+
let blurred;
|
|
54
|
+
for (let active = focused(); active; active = focused()) {
|
|
55
|
+
if (active === blurred) {
|
|
56
|
+
document.documentElement.setAttribute('data-scene-focus-kept', '');
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (performance.now() > end)
|
|
60
|
+
return false;
|
|
61
|
+
active.blur();
|
|
62
|
+
blurred = active;
|
|
63
|
+
await frames();
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/** How long `unfocused` keeps blurring a field that takes the focus back. */
|
|
68
|
+
const FOCUS_WAIT = 1_000;
|
|
69
|
+
/** The longest `openScene` waits for animations to finish. */
|
|
70
|
+
const ANIMATION_WAIT = 2_000;
|
|
71
|
+
/**
|
|
72
|
+
* Wait until a scene page in this frame has drawn: the view rendered in the asked language, the
|
|
73
|
+
* fonts and pictures loaded (`mediaReady`), two frames painted, and animations finished within
|
|
74
|
+
* their allowance, and then nothing focused (`unfocused`), so a field that autofocuses shows no
|
|
75
|
+
* focus ring. True when fonts or pictures were still loading as their allowance ran out.
|
|
76
|
+
*/
|
|
77
|
+
async function drawn(frame, locale, live, { animationWait, mediaWait, readyWait, onMedia }) {
|
|
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 });
|
|
86
|
+
// An attempt that lost its page (a module failed, the page loaded again) does nothing more.
|
|
87
|
+
if (!live())
|
|
88
|
+
return false;
|
|
89
|
+
await frame.evaluate(() => document.activeElement?.blur());
|
|
90
|
+
const media = await frame.evaluate(mediaReady, mediaWait);
|
|
91
|
+
onMedia?.(media);
|
|
92
|
+
await frame.evaluate(animationsDone, animationWait);
|
|
93
|
+
await frame.evaluate(unfocused, FOCUS_WAIT);
|
|
94
|
+
return !media.ready;
|
|
95
|
+
}
|
|
96
|
+
/** The console can show an app scene in an iframe of its own. */
|
|
97
|
+
export async function sceneFrames(page, locale) {
|
|
98
|
+
const frames = await Promise.all((await page.$$('iframe')).map(async (iframe, index) => {
|
|
99
|
+
const src = new URL((await iframe.getAttribute('src')) ?? '', page.url());
|
|
100
|
+
if (src.pathname !== '/_scene')
|
|
101
|
+
return;
|
|
102
|
+
const frame = await iframe.contentFrame();
|
|
103
|
+
if (frame)
|
|
104
|
+
return { frame, index, locale: src.searchParams.get('locale') ?? locale };
|
|
105
|
+
}));
|
|
106
|
+
return frames.filter((entry) => entry !== undefined);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Wait for the current scene and its framed scenes to finish drawing. True when a font or picture
|
|
110
|
+
* was still loading as its allowance ran out: the page is shot as it is.
|
|
111
|
+
*/
|
|
112
|
+
export async function waitForScene(page, locale, { live = () => true, animationWait = ANIMATION_WAIT, mediaWait = MEDIA_WAIT, readyWait, unframed = false, onMedia, } = {}) {
|
|
113
|
+
const waits = { animationWait, mediaWait, readyWait, onMedia };
|
|
114
|
+
let late = await drawn(page.mainFrame(), locale, live, waits);
|
|
115
|
+
const children = await sceneFrames(page, locale);
|
|
116
|
+
if (unframed && children.length)
|
|
117
|
+
throw new Error('Framed scene appeared while settling a look');
|
|
118
|
+
for (const entry of children)
|
|
119
|
+
if (await drawn(entry.frame, entry.locale, live, waits))
|
|
120
|
+
late = true;
|
|
121
|
+
return late;
|
|
122
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { type Frame, type FrameSize, type Scene, type Surface } from '@buffcore/config';
|
|
2
|
+
import type { PrototypeProblem } from '@buffcore/contracts/prototype';
|
|
2
3
|
import { type Theme } from '@buffcore/tokens';
|
|
3
|
-
import type { Browser } from 'playwright-core';
|
|
4
|
+
import type { Browser, Page } from 'playwright-core';
|
|
4
5
|
import { type browserSession } from './browser.ts';
|
|
5
6
|
import type { SnapshotHint } from './report.ts';
|
|
6
7
|
import type { LoadFailure } from './scene-errors.ts';
|
|
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';
|
|
7
11
|
import type { SnapshotProgress } from './snapshot-progress.ts';
|
|
8
|
-
import { type SceneRequestFacts } from './snapshot-requests.ts';
|
|
12
|
+
import { type RequestCoverage, type SceneRequestFacts } from './snapshot-requests.ts';
|
|
9
13
|
import { lookKey, photographed } from './snapshot-themes.ts';
|
|
10
14
|
export { lookKey, photographed };
|
|
11
15
|
/** What every scene of one snapshot shares. */
|
|
@@ -30,10 +34,20 @@ export interface Run {
|
|
|
30
34
|
out: string;
|
|
31
35
|
session?: ReturnType<typeof browserSession> | undefined;
|
|
32
36
|
requests?: SceneRequestFacts;
|
|
33
|
-
|
|
37
|
+
onFallback?: FallbackCounter | undefined;
|
|
38
|
+
coversRequest?: RequestCoverage | undefined;
|
|
34
39
|
saveScene?: SnapshotProgress['draw'] | undefined;
|
|
35
40
|
/** The first full-run scene on each surface, even when that scene has already finished. */
|
|
36
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;
|
|
37
51
|
/** Only the screenshots, no checks: `--remake` making a committed report's screenshots again. */
|
|
38
52
|
photosOnly?: boolean;
|
|
39
53
|
/** How a server the run started itself ended, if it has: read before `.ape/dev.json`. */
|
|
@@ -51,6 +65,20 @@ export type SceneResult = Awaited<ReturnType<typeof snapScene>> & {
|
|
|
51
65
|
/** A page exception's source and first line; it is not evidence of a load failure. */
|
|
52
66
|
scriptError?: LoadFailure;
|
|
53
67
|
};
|
|
68
|
+
/** What one scene gathers as it goes. */
|
|
69
|
+
interface Found {
|
|
70
|
+
scene: Scene;
|
|
71
|
+
data: Set<string>;
|
|
72
|
+
screenshots: Record<string, string>;
|
|
73
|
+
/** The looks whose shot was cut at the height cap. */
|
|
74
|
+
cut: string[];
|
|
75
|
+
problems: PrototypeProblem[];
|
|
76
|
+
hints: SnapshotHint[];
|
|
77
|
+
/** Layout hints (`scene-layout.ts`), apart from the font advice a late scene drops. */
|
|
78
|
+
layout?: SnapshotHint[];
|
|
79
|
+
/** The color pairs already reported, by theme and mode. */
|
|
80
|
+
pairs: Set<string>;
|
|
81
|
+
}
|
|
54
82
|
/** Open the first look so the surface can finish its cold build. */
|
|
55
83
|
export declare function warmSurface(browser: Browser, scene: Scene, run: Run, signal: AbortSignal): Promise<void>;
|
|
56
84
|
/** One scene in every theme, mode and language: its screenshots and its problems. */
|
|
@@ -69,3 +97,9 @@ export declare function snapScene(browser: Browser, scene: Scene, run: Run, sign
|
|
|
69
97
|
}[];
|
|
70
98
|
hints: SnapshotHint[];
|
|
71
99
|
}>;
|
|
100
|
+
/** The scene page as it shows one look: photographed when it is reviewed, and checked. */
|
|
101
|
+
export declare function checkLook(page: Page, look: {
|
|
102
|
+
theme: string;
|
|
103
|
+
mode: string;
|
|
104
|
+
locale: string;
|
|
105
|
+
}, run: Run, found: Found): Promise<void>;
|
|
@@ -11,8 +11,12 @@ import { measure } from './measure.js';
|
|
|
11
11
|
import { MEDIA_WAIT } from './media-ready.js';
|
|
12
12
|
import { t } from './messages.js';
|
|
13
13
|
import { describe, readText } from './readable.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { freshLoadsAgree, lookEvidence } from './scene-check.js';
|
|
15
|
+
import { addLayoutHints } from './scene-layout.js';
|
|
16
|
+
import { LookMoveFailed, sceneLookLoader } from './scene-look.js';
|
|
17
|
+
import { renderScene, requireNoErrorOverlay, SceneTimeoutError } from './scene-render.js';
|
|
18
|
+
import { drawnLooks } from './snapshot-matrix.js';
|
|
19
|
+
import { sceneRequests, settleRequests, } from './snapshot-requests.js';
|
|
16
20
|
import { shotName } from './snapshot-shots.js';
|
|
17
21
|
import { lookKey, photographed } from './snapshot-themes.js';
|
|
18
22
|
export { lookKey, photographed };
|
|
@@ -21,16 +25,62 @@ const LATE_WAIT = 1_000;
|
|
|
21
25
|
/** Open the first look so the surface can finish its cold build. */
|
|
22
26
|
export async function warmSurface(browser, scene, run, signal) {
|
|
23
27
|
await renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page) => {
|
|
24
|
-
|
|
25
|
-
sceneRequests(page, run, scene);
|
|
28
|
+
const requests = run.requests && sceneRequests(page, run, scene);
|
|
26
29
|
const look = { theme: run.product, mode: 'light', locale: run.first };
|
|
27
30
|
await openScene(page, sceneUrl(run.urls[scene.surface], scene.key, look), run.first);
|
|
31
|
+
await requests?.finish();
|
|
28
32
|
}, signal, run);
|
|
29
33
|
}
|
|
34
|
+
/** The facts a scene attempt has drawn with: a second attempt (a retry) is not tracked. */
|
|
35
|
+
const attempts = new WeakSet();
|
|
30
36
|
/** One scene in every theme, mode and language: its screenshots and its problems. */
|
|
31
37
|
export async function snapScene(browser, scene, run, signal) {
|
|
38
|
+
const requests = run.requests ?? { apiCalls: false, untrackedRequests: false };
|
|
39
|
+
if (attempts.has(requests))
|
|
40
|
+
requests.untrackedRequests = true;
|
|
41
|
+
attempts.add(requests);
|
|
42
|
+
const attempt = { ...run, requests };
|
|
43
|
+
let moved = false;
|
|
44
|
+
let started = performance.now();
|
|
45
|
+
let result;
|
|
46
|
+
try {
|
|
47
|
+
result = await drawScene(browser, scene, attempt, signal, () => {
|
|
48
|
+
moved = true;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
if (!(error instanceof LookMoveFailed) && (!moved || error instanceof SceneTimeoutError))
|
|
54
|
+
throw error;
|
|
55
|
+
// The failed document may have changed storage or cookies. Replay the scene in a new
|
|
56
|
+
// context so its earlier full loads establish the same state as a run using only goto.
|
|
57
|
+
run.onFallback?.('scene');
|
|
58
|
+
started = performance.now();
|
|
59
|
+
result = await drawScene(browser, scene, attempt, signal);
|
|
60
|
+
}
|
|
61
|
+
const { checks, ...drawn } = result;
|
|
62
|
+
if (!(await freshLoadsAgree(browser, scene, attempt, signal, checks, started, checkLook))) {
|
|
63
|
+
// Something an earlier look left behind changed a checked one: draw every look fresh.
|
|
64
|
+
run.onFallback?.('scene');
|
|
65
|
+
const { checks: _, ...fresh } = await drawScene(browser, scene, attempt, signal);
|
|
66
|
+
await settleRequests(requests);
|
|
67
|
+
return { ...fresh, ...requests };
|
|
68
|
+
}
|
|
69
|
+
// Every load's requests, check loads included, are checked against the scene's fingerprint.
|
|
70
|
+
await settleRequests(requests);
|
|
71
|
+
return { ...drawn, ...requests };
|
|
72
|
+
}
|
|
73
|
+
function drawScene(browser, scene, run, signal, onMove) {
|
|
32
74
|
return renderScene(browser, run.frames[scene.frame], scene.key, run.sceneTimeout, async (page, advise) => {
|
|
33
75
|
const requests = sceneRequests(page, run, scene);
|
|
76
|
+
let moves = 0;
|
|
77
|
+
const show = sceneLookLoader(page, onMove && run.onFallback, Boolean(onMove), () => {
|
|
78
|
+
moves++;
|
|
79
|
+
onMove?.();
|
|
80
|
+
});
|
|
81
|
+
let last;
|
|
82
|
+
// The last photographed look drawn in place: its saved picture is checked as well.
|
|
83
|
+
let photo;
|
|
34
84
|
const found = {
|
|
35
85
|
scene,
|
|
36
86
|
data: dataWords(scene.props),
|
|
@@ -45,45 +95,57 @@ export async function snapScene(browser, scene, run, signal) {
|
|
|
45
95
|
const declared = run.photosOnly
|
|
46
96
|
? undefined
|
|
47
97
|
: run.looks.find((theme) => theme.key === run.fontTheme);
|
|
48
|
-
for (const theme of run.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
}),
|
|
68
118
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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 });
|
|
79
131
|
}
|
|
132
|
+
await requireNoErrorOverlay(page);
|
|
80
133
|
}
|
|
81
134
|
const { screenshots, cut, problems } = found;
|
|
82
|
-
|
|
135
|
+
// A scene with a look moved in place proves its last look against a fresh load, and its
|
|
136
|
+
// last photographed moved look when that is another one.
|
|
137
|
+
const checks = [];
|
|
138
|
+
if (moves > 0 && last) {
|
|
139
|
+
checks.push({ last, evidence: await lookEvidence(page, last, run, scene, checkLook) });
|
|
140
|
+
if (photo && photo.last !== last)
|
|
141
|
+
checks.push(photo);
|
|
142
|
+
}
|
|
143
|
+
const hints = [...found.hints, ...(found.layout ?? []), ...late];
|
|
144
|
+
return { screenshots, cut, problems, hints, checks };
|
|
83
145
|
}, signal, run);
|
|
84
146
|
}
|
|
85
147
|
/** The scene page as it shows one look: photographed when it is reviewed, and checked. */
|
|
86
|
-
async function checkLook(page, look, run, found) {
|
|
148
|
+
export async function checkLook(page, look, run, found) {
|
|
87
149
|
await requireNoErrorOverlay(page);
|
|
88
150
|
const { theme, mode, locale } = look;
|
|
89
151
|
const scene = found.scene.key;
|
|
@@ -104,6 +166,11 @@ async function checkLook(page, look, run, found) {
|
|
|
104
166
|
const where = { surface, locale, first: run.first, data: found.data, intl: run.intl };
|
|
105
167
|
for (const [check, detail] of pageProblems(measured, where))
|
|
106
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);
|
|
107
174
|
}
|
|
108
175
|
// A theme can change a box's size, so what sticks out is looked for in every mode.
|
|
109
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
|
+
}
|