@mushi-mushi/ux 0.4.0 → 0.5.0

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BrowserContext, Page } from 'playwright';
2
- import { EventEmitter } from 'node:events';
3
2
  import Anthropic from '@anthropic-ai/sdk';
4
3
  import { z } from 'zod';
4
+ import { EventEmitter } from 'node:events';
5
5
 
6
6
  /**
7
7
  * Child processes for agents, installs and dev servers. Prompts go on stdin
@@ -218,6 +218,14 @@ interface LayoutIssue {
218
218
  * never named to the coding agent (ADR 0006).
219
219
  */
220
220
 
221
+ /** What a fresh context may differ in: a device's scale, touch, language and motion. */
222
+ interface FreshContextExtra {
223
+ deviceScaleFactor?: number;
224
+ isMobile?: boolean;
225
+ hasTouch?: boolean;
226
+ locale?: string;
227
+ reducedMotion?: 'reduce';
228
+ }
221
229
  interface BrowserSession {
222
230
  /** Discovery browses here; app state it leaves behind stays here. */
223
231
  context: BrowserContext;
@@ -227,8 +235,10 @@ interface BrowserSession {
227
235
  * Captures share no client state, so a screen looks the same however many
228
236
  * other screens were visited before it (glot.it /words lost its empty
229
237
  * state after other screens wrote to localStorage, 2026-10-07).
238
+ * `extra` is a persona's device, language and motion (fresh-eyes, ADR 0073);
239
+ * never a User-Agent.
230
240
  */
231
- freshContext(): Promise<BrowserContext>;
241
+ freshContext(extra?: FreshContextExtra): Promise<BrowserContext>;
232
242
  /**
233
243
  * Visit each path once in the shared context, then seed every later capture
234
244
  * from the storage that leaves behind. A first-ever visit can sit on a boot
@@ -272,85 +282,6 @@ interface Capture {
272
282
  /** Load one surface at one viewport, screenshot it, and measure it. */
273
283
  declare function captureSurface(session: BrowserSession, baseUrl: string, surface: Pick<Surface, 'path' | 'steps'>, viewport: Viewport): Promise<Capture>;
274
284
 
275
- interface ResolvedSkill {
276
- name: string;
277
- /** Skills this one hands over to, from its "## Related" list and "→ skill" mentions. */
278
- related?: string[];
279
- /** SKILL.md text. */
280
- text: string;
281
- /** Every file of the skill folder, by path relative to it (includes SKILL.md). */
282
- files: Record<string, Buffer>;
283
- /** Where it came from: a path, or owner/repo@ref. */
284
- source: string;
285
- }
286
-
287
- /**
288
- * The local studio: start a run (agent, model, skill, pages) and watch it:
289
- * phase and progress, the burndown, every attempt's screenshot against the
290
- * baseline with a slider and a diff overlay, problem scores, and the agent's
291
- * output as it streams. Served on 127.0.0.1 only, behind a random token,
292
- * reading nothing but `.mushi/ux/` in the repo.
293
- *
294
- * `mushi-ux ui` opens it with the launcher; `mushi-ux run` and `open` open it
295
- * on one run, read-only.
296
- */
297
-
298
- interface Dashboard {
299
- url: string;
300
- close(): Promise<void>;
301
- }
302
- /** Pure: resolve a requested shot path inside the run dir, or null if it escapes. */
303
- declare function safeShotPath(runDirPath: string, requested: string): string | null;
304
- /** One run, read-only (used by `mushi-ux run` and `open`). `dir` is `<repo>/.mushi/ux/<runId>`. */
305
- declare function startDashboard(dir: string, events?: EventEmitter, port?: number): Promise<Dashboard>;
306
-
307
- /**
308
- * Turns a running app into a list of surfaces: every same-origin page
309
- * reachable from the start paths, plus the tabs, dialogs and menus each page
310
- * opens. Runs inside a guarded session, so nothing it clicks can write.
311
- *
312
- * Pages whose DOM structure matches one already seen (`/reports/1` and
313
- * `/reports/2`) are kept once.
314
- */
315
-
316
- interface DiscoverOptions {
317
- baseUrl: string;
318
- startPaths?: string[];
319
- /** Repo (or app) directory to read routes from; see routes.ts. */
320
- sourceDir?: string;
321
- maxPages?: number;
322
- maxStatesPerPage?: number;
323
- /** Paths never visited (globs on pathname), on top of sign-out routes. */
324
- excludePaths?: string[];
325
- /**
326
- * Only pathnames equal to or under this prefix are visited, e.g.
327
- * `/mushi-mushi/admin` for a console that shares its origin with docs and
328
- * a landing site. Omit for the whole origin.
329
- */
330
- scopePath?: string;
331
- /**
332
- * When two pages count as the same: 'shape' (default) by DOM structure, so
333
- * `/reports/1` and `/reports/2` are worked on once; 'route' by pathname with
334
- * ids collapsed and the query ignored, for an app shell whose sidebar and
335
- * header make every page hash alike (the console kept 3 of 75 loads by
336
- * shape, 2026-10-24).
337
- */
338
- dedupe?: 'shape' | 'route';
339
- /**
340
- * Visit only startPaths (and the tabs, dialogs and menus they open): no
341
- * routes from the source or sitemap, no following links. Set when the
342
- * person named the pages.
343
- */
344
- onlyStartPaths?: boolean;
345
- onProgress?: (msg: string) => void;
346
- /** Stops discovery between pages (the studio's Stop button). */
347
- signal?: AbortSignal;
348
- }
349
- /** Pure: same-origin, normalized path (no hash), or null to skip. */
350
- declare function normalizeLink(href: string, baseUrl: string): string | null;
351
- declare function surfaceKey(path: string, steps: readonly ReplayStep[]): string;
352
- declare function discover(session: BrowserSession, opts: DiscoverOptions): Promise<Surface[]>;
353
-
354
285
  /**
355
286
  * PNG helpers: decode, pad two captures to one size, pixel diff, and a
356
287
  * difference hash (dHash) for "is this the same screen" checks. No native
@@ -542,12 +473,28 @@ interface JudgeVerdict {
542
473
  droppedClaims: number;
543
474
  /** Set when the model declined or the call failed; no verdict then. */
544
475
  error?: string;
476
+ /**
477
+ * ADR 0072 (P8): no model call was made. `unchanged`: the kept version
478
+ * looks the same as the original; `cache`: the same pair was reviewed
479
+ * before and that verdict is reused.
480
+ */
481
+ reused?: 'cache' | 'unchanged';
482
+ /** Tokens the call used (absent when reused or failed before an answer). */
483
+ usage?: JudgeUsage;
484
+ }
485
+ interface JudgeUsage {
486
+ input_tokens: number;
487
+ output_tokens: number;
488
+ cache_read_input_tokens: number;
489
+ cache_creation_input_tokens: number;
545
490
  }
546
491
  interface JudgeOptions {
547
492
  dir: string;
548
493
  repoRoot: string;
549
494
  designFiles: string[];
550
495
  model?: string;
496
+ /** Folder of reviewed pairs (ADR 0072): the same two images, model and rules are not reviewed twice. */
497
+ cacheDir?: string;
551
498
  client?: Anthropic;
552
499
  /** Deterministic order for tests; defaults to Math.random. */
553
500
  random?: () => number;
@@ -709,6 +656,18 @@ interface SavedRunOptions {
709
656
  /** Keep edits with nothing visible, flagged for review. */
710
657
  keepInvisible?: boolean;
711
658
  }
659
+ /** ADR 0072: the final review's spend, synced so the console can show what a run cost. */
660
+ interface JudgeUsageTotals {
661
+ model: string;
662
+ /** Verdicts that were a model call. */
663
+ judged: number;
664
+ /** Verdicts reused: the same pair reviewed before, or a kept version that looks unchanged. */
665
+ reused: number;
666
+ input_tokens: number;
667
+ output_tokens: number;
668
+ cache_read_input_tokens: number;
669
+ cache_creation_input_tokens: number;
670
+ }
712
671
  interface RunState {
713
672
  version: 1;
714
673
  runId: string;
@@ -736,6 +695,8 @@ interface RunState {
736
695
  stopped?: boolean;
737
696
  /** Model of the final review; null when the review is off. */
738
697
  judgeModel?: string | null;
698
+ /** What the final review spent (ADR 0072): model calls, reused verdicts and tokens. */
699
+ judgeUsage?: JudgeUsageTotals | null;
739
700
  /** Settings to resume with; absent on runs from before 2026-10-06. */
740
701
  options?: SavedRunOptions;
741
702
  /** The worktree's install finished; a run killed mid-install installs again. */
@@ -844,11 +805,6 @@ declare function toSnapshot(state: RunState, finished: boolean, uploaded: Readon
844
805
  url: string;
845
806
  number: number;
846
807
  } | undefined;
847
- mode: "local" | "cloud";
848
- status: string;
849
- agent: string;
850
- model: string | null;
851
- judge_model: string | null;
852
808
  skill: string | null;
853
809
  base_ref: string | null;
854
810
  phase: RunPhase | null;
@@ -866,6 +822,12 @@ declare function toSnapshot(state: RunState, finished: boolean, uploaded: Readon
866
822
  branch: string | null;
867
823
  base_sha: string | null;
868
824
  cli_version: null;
825
+ judge_usage?: JudgeUsageTotals | undefined;
826
+ mode: "local" | "cloud";
827
+ status: string;
828
+ agent: string;
829
+ model: string | null;
830
+ judge_model: string | null;
869
831
  };
870
832
  interface SyncHandle {
871
833
  /** Final sync; resolves with an error message when it did not land. */
@@ -873,6 +835,244 @@ interface SyncHandle {
873
835
  }
874
836
  declare function startSync(dir: string, cfg: SyncConfig, events: EventEmitter, log: (m: string) => void): SyncHandle;
875
837
 
838
+ /**
839
+ * Release-kit clips (Plan 025 P5, ADR 0074): short Playwright `recordVideo`
840
+ * recordings of an app's top flows, uploaded into one release's kit so a
841
+ * product-video tool (lazycow `make_product_video`) has real footage.
842
+ *
843
+ * Opt-in and capped: the app turns clips on in its release kit (the server
844
+ * answers 403 CLIPS_OFF otherwise), at most 5 flows of 6 screens, each clip
845
+ * stops before maxSeconds (hard cap 60 s) and is dropped above maxBytes
846
+ * (hard cap 100 MB). Every recording context goes through the write guard,
847
+ * like every other capture.
848
+ *
849
+ * The clips are WebM: source footage the video tool transcodes, never an App
850
+ * Store preview on their own. Mushi does not transcode.
851
+ */
852
+
853
+ declare const CLIP_LIMITS: {
854
+ readonly maxFlows: 5;
855
+ readonly maxPathsPerFlow: 6;
856
+ readonly defaultSeconds: 30;
857
+ readonly maxSeconds: 60;
858
+ readonly minSeconds: 5;
859
+ readonly defaultBytes: number;
860
+ readonly maxBytes: number;
861
+ /** How long each screen stays on camera after it settles. */
862
+ readonly dwellMs: 1500;
863
+ };
864
+ declare const DEFAULT_CLIP_VIEWPORT: {
865
+ readonly width: 390;
866
+ readonly height: 844;
867
+ };
868
+ interface ClipFlow {
869
+ name: string;
870
+ paths: string[];
871
+ }
872
+ interface ClipResult {
873
+ name: string;
874
+ file: string;
875
+ bytes: number;
876
+ durationMs: number;
877
+ width: number;
878
+ height: number;
879
+ /** The paths the clip actually shows (a flow is cut short when it runs out of time). */
880
+ paths: string[];
881
+ }
882
+ interface ClipSkip {
883
+ name: string;
884
+ reason: string;
885
+ }
886
+ /** Pure: a file-safe name for a flow ("Sign up!" → "sign-up"). */
887
+ declare function clipSlug(name: string): string;
888
+ /**
889
+ * Pure: one `--flow` value, `name:/a,/b` (or just `/a,/b`, named after its
890
+ * first path). Paths must start with `/`. Throws with a plain reason.
891
+ */
892
+ declare function parseFlow(value: string): ClipFlow;
893
+ /** Pure: cap the flows (count, paths each, unique names) and say what was cut. */
894
+ declare function capFlows(flows: readonly ClipFlow[]): {
895
+ flows: ClipFlow[];
896
+ notes: string[];
897
+ };
898
+ /** Pure: the caps clamped to their hard limits. */
899
+ declare function clampCaps(input: {
900
+ maxSeconds?: number;
901
+ maxBytes?: number;
902
+ }): {
903
+ maxSeconds: number;
904
+ maxBytes: number;
905
+ };
906
+ /**
907
+ * Pure: whether there is time for one more screen. A screen costs its
908
+ * navigation and settle (estimated from the slowest so far, at least 3 s)
909
+ * plus the dwell; the clip stops before it would run past maxSeconds.
910
+ */
911
+ declare function hasTimeForScreen(elapsedMs: number, slowestScreenMs: number, maxSeconds: number): boolean;
912
+ interface RecordClipsOptions {
913
+ baseUrl: string;
914
+ flows: readonly ClipFlow[];
915
+ outDir: string;
916
+ viewport?: {
917
+ width: number;
918
+ height: number;
919
+ };
920
+ maxSeconds?: number;
921
+ maxBytes?: number;
922
+ allow?: readonly AllowRule[];
923
+ /** A cached, signed-in profile: its storage seeds every recording context. */
924
+ profileDir?: string;
925
+ channel?: 'chrome' | 'chromium';
926
+ headless?: boolean;
927
+ log?: (m: string) => void;
928
+ }
929
+ /** Record one clip per flow. Returns the clips kept and the ones dropped (with why). */
930
+ declare function recordClips(opts: RecordClipsOptions): Promise<{
931
+ clips: ClipResult[];
932
+ skipped: ClipSkip[];
933
+ notes: string[];
934
+ guard: GuardLog;
935
+ }>;
936
+ /** Pure: the POST …/kit/uploads body for these clips. */
937
+ declare function clipUploadBody(clips: readonly ClipResult[]): {
938
+ files: {
939
+ name: string;
940
+ kind: "clip";
941
+ mime: "video/webm";
942
+ bytes: number;
943
+ source: "playwright";
944
+ platform: "web";
945
+ durationMs: number;
946
+ width: number;
947
+ height: number;
948
+ surfacePath: string;
949
+ label: string;
950
+ }[];
951
+ };
952
+ type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
953
+ /** The app's clip settings as the kit route serves them (project_settings.release_kit_clip_*). */
954
+ interface ServerClipCaps {
955
+ clipsEnabled: boolean;
956
+ maxSeconds: number;
957
+ maxBytes: number;
958
+ }
959
+ /**
960
+ * Read the app's clip caps from the release's kit before recording, so a
961
+ * clip is never recorded that the server will refuse. `null` = could not
962
+ * read them (offline, old server, no access): the caller falls back to the
963
+ * local defaults and the server still enforces its caps on upload.
964
+ */
965
+ declare function fetchClipCaps(cfg: SyncConfig, releaseId: string, fetchImpl?: FetchLike): Promise<ServerClipCaps | null>;
966
+ /**
967
+ * Pure: the caps a recording uses. The lower of what was asked and what the
968
+ * app allows, clamped to the hard limits; `blocked` (with the reason) when
969
+ * the app has clips turned off, so nothing is recorded only to be refused.
970
+ */
971
+ declare function effectiveClipCaps(requested: {
972
+ maxSeconds?: number;
973
+ maxBytes?: number;
974
+ }, server: ServerClipCaps | null): {
975
+ maxSeconds: number;
976
+ maxBytes: number;
977
+ notes: string[];
978
+ blocked: string | null;
979
+ };
980
+ interface ClipUploadOutcome {
981
+ uploaded: Array<{
982
+ name: string;
983
+ assetId: string;
984
+ }>;
985
+ failed: Array<{
986
+ name: string;
987
+ reason: string;
988
+ }>;
989
+ }
990
+ /**
991
+ * Upload clips into one release's kit: reserve signed URLs, PUT each file,
992
+ * then finalize it with its SHA-256 so the server can prove the bytes. The
993
+ * server's refusal (CLIPS_OFF: turn clips on in the kit) is thrown as is.
994
+ */
995
+ declare function uploadClips(cfg: SyncConfig, releaseId: string, clips: readonly ClipResult[], fetchImpl?: FetchLike): Promise<ClipUploadOutcome>;
996
+
997
+ interface ResolvedSkill {
998
+ name: string;
999
+ /** Skills this one hands over to, from its "## Related" list and "→ skill" mentions. */
1000
+ related?: string[];
1001
+ /** SKILL.md text. */
1002
+ text: string;
1003
+ /** Every file of the skill folder, by path relative to it (includes SKILL.md). */
1004
+ files: Record<string, Buffer>;
1005
+ /** Where it came from: a path, or owner/repo@ref. */
1006
+ source: string;
1007
+ }
1008
+
1009
+ /**
1010
+ * The local studio: start a run (agent, model, skill, pages) and watch it:
1011
+ * phase and progress, the burndown, every attempt's screenshot against the
1012
+ * baseline with a slider and a diff overlay, problem scores, and the agent's
1013
+ * output as it streams. Served on 127.0.0.1 only, behind a random token,
1014
+ * reading nothing but `.mushi/ux/` in the repo.
1015
+ *
1016
+ * `mushi-ux ui` opens it with the launcher; `mushi-ux run` and `open` open it
1017
+ * on one run, read-only.
1018
+ */
1019
+
1020
+ interface Dashboard {
1021
+ url: string;
1022
+ close(): Promise<void>;
1023
+ }
1024
+ /** Pure: resolve a requested shot path inside the run dir, or null if it escapes. */
1025
+ declare function safeShotPath(runDirPath: string, requested: string): string | null;
1026
+ /** One run, read-only (used by `mushi-ux run` and `open`). `dir` is `<repo>/.mushi/ux/<runId>`. */
1027
+ declare function startDashboard(dir: string, events?: EventEmitter, port?: number): Promise<Dashboard>;
1028
+
1029
+ /**
1030
+ * Turns a running app into a list of surfaces: every same-origin page
1031
+ * reachable from the start paths, plus the tabs, dialogs and menus each page
1032
+ * opens. Runs inside a guarded session, so nothing it clicks can write.
1033
+ *
1034
+ * Pages whose DOM structure matches one already seen (`/reports/1` and
1035
+ * `/reports/2`) are kept once.
1036
+ */
1037
+
1038
+ interface DiscoverOptions {
1039
+ baseUrl: string;
1040
+ startPaths?: string[];
1041
+ /** Repo (or app) directory to read routes from; see routes.ts. */
1042
+ sourceDir?: string;
1043
+ maxPages?: number;
1044
+ maxStatesPerPage?: number;
1045
+ /** Paths never visited (globs on pathname), on top of sign-out routes. */
1046
+ excludePaths?: string[];
1047
+ /**
1048
+ * Only pathnames equal to or under this prefix are visited, e.g.
1049
+ * `/mushi-mushi/admin` for a console that shares its origin with docs and
1050
+ * a landing site. Omit for the whole origin.
1051
+ */
1052
+ scopePath?: string;
1053
+ /**
1054
+ * When two pages count as the same: 'shape' (default) by DOM structure, so
1055
+ * `/reports/1` and `/reports/2` are worked on once; 'route' by pathname with
1056
+ * ids collapsed and the query ignored, for an app shell whose sidebar and
1057
+ * header make every page hash alike (the console kept 3 of 75 loads by
1058
+ * shape, 2026-10-24).
1059
+ */
1060
+ dedupe?: 'shape' | 'route';
1061
+ /**
1062
+ * Visit only startPaths (and the tabs, dialogs and menus they open): no
1063
+ * routes from the source or sitemap, no following links. Set when the
1064
+ * person named the pages.
1065
+ */
1066
+ onlyStartPaths?: boolean;
1067
+ onProgress?: (msg: string) => void;
1068
+ /** Stops discovery between pages (the studio's Stop button). */
1069
+ signal?: AbortSignal;
1070
+ }
1071
+ /** Pure: same-origin, normalized path (no hash), or null to skip. */
1072
+ declare function normalizeLink(href: string, baseUrl: string): string | null;
1073
+ declare function surfaceKey(path: string, steps: readonly ReplayStep[]): string;
1074
+ declare function discover(session: BrowserSession, opts: DiscoverOptions): Promise<Surface[]>;
1075
+
876
1076
  /**
877
1077
  * `mushi-ux audit`: find UI/UX bugs on the signed-in screens of a live app
878
1078
  * and file each one as a Mushi report, so the fix loop picks it up (ADR 0045).
@@ -1026,6 +1226,20 @@ interface SuccessCheck {
1026
1226
  /** GET in the session's own browser context (its cookies); passes on 2xx with a non-empty JSON body. */
1027
1227
  api?: string;
1028
1228
  }
1229
+ /**
1230
+ * Who the visitor is (ADR 0073): a project persona as the worker claim carries
1231
+ * it. The brief is plain words the visitor model reads; the device, language
1232
+ * and needs change the browser itself, so the app sees a phone, Japanese or
1233
+ * reduced motion for real, not only in the prompt.
1234
+ */
1235
+ interface FreshEyesPersona {
1236
+ name: string;
1237
+ brief: string;
1238
+ locale: string;
1239
+ device: 'desktop' | 'mobile' | 'tablet';
1240
+ needs: string[];
1241
+ steps: number;
1242
+ }
1029
1243
  /** The question to the model: the prompt in a file in an empty folder, so ask mode reads nothing else. */
1030
1244
  type FreshAsk = (prompt: string, dir: string) => Promise<{
1031
1245
  text: string | null;
@@ -1177,6 +1391,8 @@ interface FreshEyesOptions {
1177
1391
  session?: () => Promise<BrowserSession>;
1178
1392
  /** The run id to use, when the console queued the run and already named it (`20261028-091500-ab12`). */
1179
1393
  runId?: string;
1394
+ /** Who the visitors are (ADR 0073): their brief, device, language and needs. */
1395
+ persona?: FreshEyesPersona;
1180
1396
  }
1181
1397
  declare function runFreshEyes(opts: FreshEyesOptions): Promise<FreshEyesResult>;
1182
1398
 
@@ -1864,6 +2080,143 @@ declare function scorecardContext(cfg: SyncConfig): Promise<{
1864
2080
  priorKeys: string[];
1865
2081
  }>;
1866
2082
 
2083
+ /**
2084
+ * What a native screen says (ADR 0073), from the files a phone driver can
2085
+ * write next to its screenshot, with no device access here:
2086
+ *
2087
+ * - `window.xml` Android `uiautomator dump` (adb exec-out uiautomator dump /dev/tty)
2088
+ * - `hierarchy.json` `maestro hierarchy` (Android and iOS)
2089
+ * - `facts.json` any subset of the scorecard's page facts the driver wrote itself
2090
+ *
2091
+ * The scorecard judges a page on its facts (text, controls, headings) and its
2092
+ * screenshots; a phone screen with only pixels would be judged blind. This
2093
+ * reads the visible text and the tappable labels from whichever file is
2094
+ * there, fills every other fact with an honest "not measured" (axe null,
2095
+ * settle time null), and keeps the screen's own name as its path.
2096
+ *
2097
+ * Pure: strings in, facts out. No XML library: uiautomator's dump is flat
2098
+ * attribute soup, and a small attribute reader is enough and safe (it never
2099
+ * resolves entities beyond the five XML ones, never fetches anything).
2100
+ */
2101
+
2102
+ interface NativeNode {
2103
+ text: string;
2104
+ /** content-desc / accessibilityText: what a screen reader announces. */
2105
+ label: string;
2106
+ className: string;
2107
+ clickable: boolean;
2108
+ heading: boolean;
2109
+ /** Visible on screen (non-empty bounds, not hidden). */
2110
+ visible: boolean;
2111
+ }
2112
+ /** Pure: the nodes of an Android `uiautomator dump`. */
2113
+ declare function parseUiautomator(xml: string): NativeNode[];
2114
+ /** Pure: the nodes of a `maestro hierarchy` dump (depth-first, at most 5,000). */
2115
+ declare function parseMaestroHierarchy(json: string): NativeNode[];
2116
+ /** Pure: the scorecard's text, controls and headings of a screen's nodes. */
2117
+ declare function nodesToContent(nodes: readonly NativeNode[]): {
2118
+ text: string;
2119
+ controls: string[];
2120
+ headings: string[];
2121
+ };
2122
+ /** Pure: width and height of a PNG from its header, or null when the bytes are not a PNG. */
2123
+ declare function pngSize(bytes: Uint8Array): {
2124
+ width: number;
2125
+ height: number;
2126
+ } | null;
2127
+ /** Pure: a screen name as a page key and path (`Onboarding step 1` → `/onboarding-step-1`). */
2128
+ declare function screenPath(name: string): string;
2129
+ /**
2130
+ * Pure: complete scorecard facts for one native screen. `given` is what the
2131
+ * driver wrote in facts.json (any subset; a field there wins), `nodes` the
2132
+ * hierarchy when one was dumped, `png` the settled screenshot's size, `scale`
2133
+ * the device's pixel ratio (pixels per point; 1 keeps pixels).
2134
+ */
2135
+ declare function nativeFacts(input: {
2136
+ folder: string;
2137
+ given?: Partial<UxPageFacts> | null;
2138
+ nodes?: readonly NativeNode[] | null;
2139
+ png?: {
2140
+ width: number;
2141
+ height: number;
2142
+ } | null;
2143
+ scale?: number;
2144
+ }): UxPageFacts;
2145
+
2146
+ /**
2147
+ * `mushi-ux upload <dir>`: put screenshots any driver made into a UX scorecard
2148
+ * run (ADR 0073), so a native app's screens are scored on the same rubric,
2149
+ * probes and judge as a web page.
2150
+ *
2151
+ * Layout (the scorecard's own capture layout, as `--from-captures` reads it):
2152
+ *
2153
+ * <dir>/pages/<screen>/settled.png required (or early.png)
2154
+ * <dir>/pages/<screen>/early.png optional: the screen about 1 s in
2155
+ * <dir>/pages/<screen>/facts.json optional: any of the page facts
2156
+ * <dir>/pages/<screen>/window.xml optional: `adb exec-out uiautomator dump /dev/tty`
2157
+ * <dir>/pages/<screen>/hierarchy.json optional: `maestro hierarchy`
2158
+ *
2159
+ * Steps: read and check every screen (a real PNG, at most 8 MB), POST
2160
+ * /v1/ux/captures (one run, its scoring budget reserved), PUT each PNG to its
2161
+ * signed URL, then with `--score` score each screen on the server, group the
2162
+ * causes, close the run, and with `--file` file the top causes as reports.
2163
+ * Templates for Maestro, adb and the iOS simulator: docs/templates/ux-native/.
2164
+ */
2165
+
2166
+ declare const UPLOAD_PLATFORMS: readonly ["ios", "android", "flutter", "react_native", "capacitor", "web", "other"];
2167
+ type UploadPlatform = (typeof UPLOAD_PLATFORMS)[number];
2168
+ declare const UPLOAD_SOURCES: readonly ["maestro", "adb", "simctl", "sdk", "playwright", "other"];
2169
+ type UploadSource = (typeof UPLOAD_SOURCES)[number];
2170
+ /** The server's caps (POST /v1/ux/captures). */
2171
+ declare const UPLOAD_MAX_PAGES = 60;
2172
+ declare const UPLOAD_MAX_PNG_BYTES: number;
2173
+ interface CapturedScreen {
2174
+ folder: string;
2175
+ facts: UxPageFacts;
2176
+ shots: Array<'early' | 'settled'>;
2177
+ }
2178
+ /** Read every screen under `<dir>/pages`; throws with a plain message on a screen that cannot be uploaded. */
2179
+ declare function readScreens(dir: string, opts?: {
2180
+ scale?: number;
2181
+ }): CapturedScreen[];
2182
+ interface UploadOptions {
2183
+ dir: string;
2184
+ platform: UploadPlatform;
2185
+ device?: string;
2186
+ source?: UploadSource;
2187
+ /** What to call the app in prompts and on the run. */
2188
+ app?: string;
2189
+ about?: string;
2190
+ /** Pixels per point of the device, to record the viewport in points (default 1: pixels). */
2191
+ scale?: number;
2192
+ /** WIDTHxHEIGHT for the run (default: the first screen's). */
2193
+ viewport?: string;
2194
+ /** The most the run may spend on server scoring. */
2195
+ maxCostUsd?: number;
2196
+ /** Score each screen on the server after the upload, group the causes and close the run. */
2197
+ score?: boolean;
2198
+ /** With score: file the top causes as reports. */
2199
+ file?: boolean;
2200
+ /** With file: show what would be filed. */
2201
+ dryRun?: boolean;
2202
+ concurrency?: number;
2203
+ onProgress?: (msg: string) => void;
2204
+ fetchImpl?: typeof fetch;
2205
+ }
2206
+ interface UploadResult {
2207
+ runId: string;
2208
+ pages: number;
2209
+ uploaded: number;
2210
+ reservedUsd: number | null;
2211
+ scored: number;
2212
+ mean: number | null;
2213
+ causes: UxCause[];
2214
+ errors: string[];
2215
+ filed?: ScorecardFileOutcome;
2216
+ consoleUrl: string;
2217
+ }
2218
+ declare function uploadCaptures(cfg: SyncConfig, opts: UploadOptions): Promise<UploadResult>;
2219
+
1867
2220
  /**
1868
2221
  * The cheap, objective keep-or-revert decision after one agent run. It only
1869
2222
  * uses measurements (probes, pixel diff, files changed), never a model's
@@ -1893,4 +2246,4 @@ interface Verdict {
1893
2246
  }
1894
2247
  declare function decide(input: VerdictInput): Verdict;
1895
2248
 
1896
- export { AGENTS, type AgentAdapter, type AgentName, type AgentRunOptions, type AllowRule, type AxeViolation, type BrowserSession, type Candidate, type Capture, type CursorCloudDeps, DEFAULT_JUDGE_MODEL, DEFAULT_SCORECARD_MODEL, DEFAULT_SCORECARD_VIEWPORT, DEFAULT_SETUP_COMMAND, type Dashboard, type DiscoverOptions, FACTS_SCRIPT, type FreshAction, type FreshAsk, type FreshEyesFinding, type FreshEyesOptions, type FreshEyesResult, type FreshEyesSession, type FreshEyesStep, type GuardPolicy, type Identity, type IterationRecord, type JudgeClaim, type JudgeOptions, type JudgeVerdict, type LayoutIssue, type LoopEvent, type LoopHandle, type LoopOptions, type Opinion, type OpinionCategory, POINTER_PROMPT, type PacketInput, type PageCapture, type PageFacts, type ParsedPageScore, type Phase, type PhaseName, type ProbeResult, type ReplayStep, type RequirementKind, type RunState, type ScoreVia, type ScorecardFileOutcome, type ScorecardOptions, type ScorecardPageResult, type ScorecardResult, type ScorecardRow, type ScoredPage, type Scorer, type StallReason, type StepOutcome, type SuccessCheck, type Surface, type SurfaceKind, type SurfaceState, type SurfaceStatus, type SyncConfig, type SyncHandle, type TerminalHandoff, type TerminalOptions, type TerminalResult, UX_DIMENSIONS, UX_RUBRIC, UX_SCORECARD_LIMITS, UX_SCORECARD_PROMPT_VERSION, UX_SCORE_ANCHORS, type UxCause, type UxCausePage, type UxClaim, type UxDimension, type UxFilingPlan, type UxIssue, type UxPageFacts, type UxPagePromptContext, type UxPageScore, type UxSeverity, VIEWPORTS, type Verdict, type VerdictInput, type Viewport, type WriteMode, accessibilityCap, buildPacket, captureFolder, capturePage, captureSurface, causeIsFileable, causeRank, causeReportBody, causeSlug, causeTokens, cropTop, cursorCloudAdapter, cursorModel, dHash, decide, discover, evidenceSeenIn, fileScorecard, findDesignFiles, firstJsonObject, getAgent, groupCauses, groupingPrompt, hammingHex, httpsRepoUrl, installGuard, isDestructiveLabel, isRequestAllowed, judgeSurface, loadState, localScorer, mergeGrouping, newRunId, nextRoutePath, normText, normalizeLink, openSession, overallScore, pageSystemPrompt, pageUserPrompt, parsePageAnswer, patternKeyFor, performanceCap, pixelDiff, planFiling, probePenalty, quoteArg, reactRouterPaths, readCaptures, routesFromSource, runDir, runFreshEyes, runProbes, runScorecard, runTerminalSetup, safeShotPath, sameCause, saveState, scorecardContext, scorecardMarkdown, scorecardMarker, scorecardPageKey, scorecardRows, scorecardRunId, serverScorer, settle, sitemapPaths, startDashboard, startLoop, startSync, surfaceKey, syncConfigFromEnv, syncScorecard, toSnapshot, topCauses, unshuffle, uploadAllShots };
2249
+ export { AGENTS, type AgentAdapter, type AgentName, type AgentRunOptions, type AllowRule, type AxeViolation, type BrowserSession, CLIP_LIMITS, type Candidate, type Capture, type CapturedScreen, type ClipFlow, type ClipResult, type ClipSkip, type ClipUploadOutcome, type CursorCloudDeps, DEFAULT_CLIP_VIEWPORT, DEFAULT_JUDGE_MODEL, DEFAULT_SCORECARD_MODEL, DEFAULT_SCORECARD_VIEWPORT, DEFAULT_SETUP_COMMAND, type Dashboard, type DiscoverOptions, FACTS_SCRIPT, type FreshAction, type FreshAsk, type FreshEyesFinding, type FreshEyesOptions, type FreshEyesPersona, type FreshEyesResult, type FreshEyesSession, type FreshEyesStep, type GuardPolicy, type Identity, type IterationRecord, type JudgeClaim, type JudgeOptions, type JudgeVerdict, type LayoutIssue, type LoopEvent, type LoopHandle, type LoopOptions, type NativeNode, type Opinion, type OpinionCategory, POINTER_PROMPT, type PacketInput, type PageCapture, type PageFacts, type ParsedPageScore, type Phase, type PhaseName, type ProbeResult, type RecordClipsOptions, type ReplayStep, type RequirementKind, type RunState, type ScoreVia, type ScorecardFileOutcome, type ScorecardOptions, type ScorecardPageResult, type ScorecardResult, type ScorecardRow, type ScoredPage, type Scorer, type ServerClipCaps, type StallReason, type StepOutcome, type SuccessCheck, type Surface, type SurfaceKind, type SurfaceState, type SurfaceStatus, type SyncConfig, type SyncHandle, type TerminalHandoff, type TerminalOptions, type TerminalResult, UPLOAD_MAX_PAGES, UPLOAD_MAX_PNG_BYTES, UPLOAD_PLATFORMS, UPLOAD_SOURCES, UX_DIMENSIONS, UX_RUBRIC, UX_SCORECARD_LIMITS, UX_SCORECARD_PROMPT_VERSION, UX_SCORE_ANCHORS, type UploadOptions, type UploadPlatform, type UploadResult, type UploadSource, type UxCause, type UxCausePage, type UxClaim, type UxDimension, type UxFilingPlan, type UxIssue, type UxPageFacts, type UxPagePromptContext, type UxPageScore, type UxSeverity, VIEWPORTS, type Verdict, type VerdictInput, type Viewport, type WriteMode, accessibilityCap, buildPacket, capFlows, captureFolder, capturePage, captureSurface, causeIsFileable, causeRank, causeReportBody, causeSlug, causeTokens, clampCaps, clipSlug, clipUploadBody, cropTop, cursorCloudAdapter, cursorModel, dHash, decide, discover, effectiveClipCaps, evidenceSeenIn, fetchClipCaps, fileScorecard, findDesignFiles, firstJsonObject, getAgent, groupCauses, groupingPrompt, hammingHex, hasTimeForScreen, httpsRepoUrl, installGuard, isDestructiveLabel, isRequestAllowed, judgeSurface, loadState, localScorer, mergeGrouping, nativeFacts, newRunId, nextRoutePath, nodesToContent, normText, normalizeLink, openSession, overallScore, pageSystemPrompt, pageUserPrompt, parseFlow, parseMaestroHierarchy, parsePageAnswer, parseUiautomator, patternKeyFor, performanceCap, pixelDiff, planFiling, pngSize, probePenalty, quoteArg, reactRouterPaths, readCaptures, readScreens, recordClips, routesFromSource, runDir, runFreshEyes, runProbes, runScorecard, runTerminalSetup, safeShotPath, sameCause, saveState, scorecardContext, scorecardMarkdown, scorecardMarker, scorecardPageKey, scorecardRows, scorecardRunId, screenPath, serverScorer, settle, sitemapPaths, startDashboard, startLoop, startSync, surfaceKey, syncConfigFromEnv, syncScorecard, toSnapshot, topCauses, unshuffle, uploadAllShots, uploadCaptures, uploadClips };