@mushi-mushi/ux 0.5.0 → 0.5.2

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
@@ -393,8 +393,8 @@ declare const DEFAULT_JUDGE_MODEL = "claude-opus-5-5";
393
393
  declare const JudgeOutput: z.ZodObject<{
394
394
  preferred: z.ZodEnum<{
395
395
  A: "A";
396
- tie: "tie";
397
396
  B: "B";
397
+ tie: "tie";
398
398
  }>;
399
399
  confidence: z.ZodEnum<{
400
400
  low: "low";
@@ -735,7 +735,7 @@ declare function toSnapshot(state: RunState, finished: boolean, uploaded: Readon
735
735
  note: string | null;
736
736
  plan: {
737
737
  text: string;
738
- status: "done" | "pending" | "skipped" | "failed";
738
+ status: "done" | "failed" | "pending" | "skipped";
739
739
  attempt: number | null;
740
740
  }[] | null;
741
741
  penalty_before: number | null;
@@ -768,7 +768,7 @@ declare function toSnapshot(state: RunState, finished: boolean, uploaded: Readon
768
768
  error?: string | undefined;
769
769
  viewport: string;
770
770
  model: string;
771
- preferred: "before" | "after" | "tie";
771
+ preferred: "tie" | "before" | "after";
772
772
  confidence: "low" | "medium" | "high";
773
773
  summary: string;
774
774
  better: {
@@ -1620,12 +1620,21 @@ declare function sitemapPaths(baseUrl: string): Promise<string[]>;
1620
1620
  * Facts stay in code (ADR 0039): the model gives each rubric dimension a 1–10
1621
1621
  * score and names issues with quoted evidence; the measured settle time and
1622
1622
  * the axe counts cap the performance and accessibility scores, the overall
1623
- * score is computed here from the eight, and only causes with evidence seen on
1624
- * the page are filed.
1623
+ * score is computed here from the dimensions that were measured, and only
1624
+ * causes with evidence seen on the page are filed.
1625
+ *
1626
+ * Not measured is left out, never guessed (ADR 0067 corrections, 2026-11-30):
1627
+ * a page with no settle time keeps its speed score out of the overall and
1628
+ * uncapped; a page with no axe run and no screen hierarchy (no controls, no
1629
+ * headings) keeps its accessibility issues but not the score.
1630
+ *
1631
+ * A low number drags the page only with evidence (2026-12-02): a measured
1632
+ * fact that capped it, or a serious finding (high, evidence seen) that a
1633
+ * person has not marked "not a problem" (anchoredDimensions).
1625
1634
  *
1626
1635
  * No imports, no Deno or Node globals: vitest and Deno both load it as is.
1627
1636
  */
1628
- declare const UX_SCORECARD_PROMPT_VERSION = "ux-scorecard-2026-11-21.2";
1637
+ declare const UX_SCORECARD_PROMPT_VERSION = "ux-scorecard-2026-12-02.2";
1629
1638
  declare const UX_DIMENSIONS: readonly ["clarity", "hierarchy", "consistency", "states", "truthfulness", "copy", "accessibility", "performance"];
1630
1639
  type UxDimension = (typeof UX_DIMENSIONS)[number];
1631
1640
  type UxSeverity = 'high' | 'medium' | 'low';
@@ -1669,7 +1678,11 @@ interface UxPageFacts {
1669
1678
  controls: string[];
1670
1679
  /** Visible text early in the load (about 1 s), when it differs: loading and placeholder states. */
1671
1680
  earlyText?: string;
1672
- /** Milliseconds until the page stopped changing; null when it never settled within the wait. */
1681
+ /**
1682
+ * Milliseconds until the page stopped changing; null when it was not
1683
+ * measured (a phone screenshot). A web page still changing at the end of
1684
+ * the wait reports the wait it took, never null.
1685
+ */
1673
1686
  settleMs: number | null;
1674
1687
  /** Serious and critical axe results; null when axe could not run on the page. */
1675
1688
  axe: {
@@ -1715,12 +1728,15 @@ interface UxPageScore {
1715
1728
  issues: UxIssue[];
1716
1729
  claims: UxClaim[];
1717
1730
  promptVersion: string;
1731
+ /** The model that scored the page, when the scorer knows it. */
1732
+ model?: string;
1718
1733
  }
1719
1734
  /**
1720
1735
  * A page's identity across runs: the path, plus only the query params that
1721
1736
  * pick a view (`/team?view=sso` and `/team?view=billing` are two pages; a
1722
1737
  * `?project=` or a record id in the query is not a page). Trailing slashes and
1723
- * the hash are dropped.
1738
+ * the hash are dropped. It always starts with `/` (`01-home` → `/01-home`):
1739
+ * ux_surfaces.path must, and a screen name is not a path (live 2026-11-30).
1724
1740
  */
1725
1741
  declare function scorecardPageKey(path: string): string;
1726
1742
  interface UxPagePromptContext {
@@ -1746,16 +1762,73 @@ declare function normText(s: string): string;
1746
1762
  * fragment of 6+ characters found in the page counts.
1747
1763
  */
1748
1764
  declare function evidenceSeenIn(evidence: string, f: Pick<UxPageFacts, 'text' | 'title' | 'controls' | 'headings' | 'earlyText' | 'breadcrumb'>): boolean;
1749
- /** Pure: the performance score the measured settle time allows. */
1765
+ /** Pure: the performance score the measured settle time allows. Not measured caps nothing (it is left out of the overall instead). */
1750
1766
  declare function performanceCap(settleMs: number | null): number;
1751
1767
  /** Pure: the accessibility score the measured axe results and sideways scroll allow. */
1752
1768
  declare function accessibilityCap(f: Pick<UxPageFacts, 'axe' | 'overflowX'>): number;
1753
1769
  /**
1754
- * Pure: the page's overall score from its eight. A page is as good as its
1755
- * worst problem lets it be: one terrible dimension drags it down as much as
1756
- * the average does (0.5 × mean + 0.5 × min), rounded to a whole number.
1770
+ * Pure: the dimensions a page's overall score counts. Performance counts only
1771
+ * with a measured settle time. Accessibility counts with an axe run or a
1772
+ * screen hierarchy (controls or headings read from the screen); from the
1773
+ * pixels alone it is checked by eye only: its issues stay, its score does not
1774
+ * count.
1775
+ */
1776
+ declare function countedDimensions(f: Pick<UxPageFacts, 'settleMs' | 'axe' | 'controls' | 'headings'>): UxDimension[];
1777
+ /**
1778
+ * Pure: the dimensions whose low score is backed by evidence, so they may
1779
+ * drag the page's overall score down (ADR 0067 corrections, 2026-12-02):
1780
+ *
1781
+ * - a measured fact capped it: a settle time slower than 1.5 s
1782
+ * (performance), serious or critical axe results or a sideways scroll
1783
+ * (accessibility);
1784
+ * - or one of the page's findings in it is high impact with its evidence
1785
+ * seen on the page (what the console calls "serious").
1786
+ *
1787
+ * A low number with neither is the model's unanchored guess. The 21 Nov check
1788
+ * of Mushi's console showed this: axe passed on 72 of 74 pages, yet
1789
+ * accessibility was the weakest dimension on 27 of them, at 5–7 from pixels
1790
+ * alone. Such a number still counts in the mean, but it cannot drag the page.
1791
+ * Callers leave out findings a person marked "not a problem".
1792
+ */
1793
+ declare function anchoredDimensions(facts: Pick<UxPageFacts, 'settleMs' | 'axe' | 'overflowX'>, issues: ReadonlyArray<Pick<UxIssue, 'dimension' | 'severity' | 'evidenceSeen'>>): UxDimension[];
1794
+ /**
1795
+ * Pure: the page's overall score from the dimensions it counts (all eight
1796
+ * when none are named). A page is as good as its worst evidenced problem lets
1797
+ * it be: 0.5 × mean + 0.5 × the lowest anchored dimension (never above the
1798
+ * mean), rounded to a whole number. With no anchored dimension it is the mean.
1799
+ * `anchored` defaults to every counted dimension (the plain mean-and-min rule).
1800
+ */
1801
+ declare function overallScore(scores: Record<UxDimension, number>, counted?: readonly UxDimension[], anchored?: readonly UxDimension[]): number;
1802
+ /**
1803
+ * Pure: the model's own numbers with the facts applied: performance and
1804
+ * accessibility capped by what was measured, the overall from the counted
1805
+ * dimensions, dragged only by anchored ones (anchoredDimensions over
1806
+ * `issues`, the findings that count). `raw` is what the model said
1807
+ * (rawScores of a stored score).
1808
+ */
1809
+ declare function applyFacts(raw: Record<UxDimension, number>, facts: UxPageFacts, issues: ReadonlyArray<Pick<UxIssue, 'dimension' | 'severity' | 'evidenceSeen'>>): {
1810
+ scores: Record<UxDimension, number>;
1811
+ capped: Partial<Record<UxDimension, number>>;
1812
+ overall: number;
1813
+ };
1814
+ /** Pure: what the model said for each dimension, before any fact capped it (NaN where a stored score lacks one). */
1815
+ declare function rawScores(s: Pick<UxPageScore, 'scores' | 'capped'>): Record<UxDimension, number>;
1816
+ /**
1817
+ * Pure: a stored page score read under today's rules (caps and counted
1818
+ * dimensions), from the per-dimension numbers it kept. Stored rows are never
1819
+ * rewritten: a run scored under an older rule shows the corrected score when
1820
+ * it is read. Without the facts it was scored on, or with a dimension
1821
+ * missing, the score stays as stored and says so (`rescored: false`).
1822
+ *
1823
+ * `notCounted` names findings that no longer count (a person marked their
1824
+ * cause "not a problem"): they stay on the page but cannot drag its score.
1757
1825
  */
1758
- declare function overallScore(scores: Record<UxDimension, number>): number;
1826
+ declare function rescorePage(score: UxPageScore, facts: UxPageFacts | undefined, notCounted?: (issue: UxIssue) => boolean): {
1827
+ score: UxPageScore;
1828
+ rescored: boolean;
1829
+ };
1830
+ /** Pure: the typical score of a set of pages: the median, the lower middle one when the count is even (a score some page really has). */
1831
+ declare function typicalScore(overalls: readonly number[]): number | null;
1759
1832
  type ParsedPageScore = {
1760
1833
  ok: true;
1761
1834
  value: UxPageScore;
@@ -1896,6 +1969,26 @@ declare function scorecardMarkdown(input: {
1896
1969
  causes: readonly UxCause[];
1897
1970
  }): string;
1898
1971
 
1972
+ /**
1973
+ * Which build a capture folder shows, for `mushi-ux upload` (migration
1974
+ * 20261130233000_ux_run_provenance): `<dir>/build.json`, which the capture
1975
+ * templates write (versionName/versionCode from `dumpsys package`, the OTA
1976
+ * id, the commit), then the --app-version/--build/--ota/--commit flags, then
1977
+ * the CI's GITHUB_SHA. Its own file, without Playwright or pngjs, so it tests
1978
+ * on its own.
1979
+ */
1980
+ /** Which build the screens show (the server's provenance fields on POST /v1/ux/captures). */
1981
+ interface UploadBuild {
1982
+ appVersion?: string;
1983
+ buildNumber?: string;
1984
+ otaId?: string;
1985
+ commitSha?: string;
1986
+ envUrl?: string;
1987
+ capturedAt?: string;
1988
+ osVersion?: string;
1989
+ deviceModel?: string;
1990
+ }
1991
+
1899
1992
  /**
1900
1993
  * `mushi-ux scorecard`: score every page of a live app against a written
1901
1994
  * rubric (ADR 0067), group what is wrong into root causes, and file the top
@@ -2021,6 +2114,8 @@ interface ScorecardResult {
2021
2114
  causes: UxCause[];
2022
2115
  groupError?: string;
2023
2116
  markdown: string;
2117
+ /** Which build the pages show, when the app publishes it (build-info.ts webBuild). */
2118
+ build?: UploadBuild;
2024
2119
  }
2025
2120
  /** Pure: a scorecard run id in the console's format (yyyymmdd-hhmmss-xxxx). */
2026
2121
  declare function scorecardRunId(now: Date, rand?: () => number): string;
@@ -2041,6 +2136,7 @@ declare function syncScorecard(cfg: SyncConfig, input: {
2041
2136
  causes?: readonly UxCause[];
2042
2137
  cliVersion?: string;
2043
2138
  uploaded?: ReadonlyMap<string, string[]>;
2139
+ build?: UploadBuild;
2044
2140
  }): Promise<string | null>;
2045
2141
  /** Upload every page's screenshots (local scoring: the server scorer uploads as it scores). */
2046
2142
  declare function uploadAllShots(cfg: SyncConfig, runId: string, pages: readonly ScorecardPageResult[]): Promise<Map<string, string[]>>;
@@ -2199,6 +2295,10 @@ interface UploadOptions {
2199
2295
  file?: boolean;
2200
2296
  /** With file: show what would be filed. */
2201
2297
  dryRun?: boolean;
2298
+ /** Which build the screens show; a field given here wins over `<dir>/build.json`. */
2299
+ build?: UploadBuild;
2300
+ /** The CI's commit (GITHUB_SHA), used when neither the flags nor build.json name one. */
2301
+ ciCommit?: string;
2202
2302
  concurrency?: number;
2203
2303
  onProgress?: (msg: string) => void;
2204
2304
  fetchImpl?: typeof fetch;
@@ -2210,6 +2310,8 @@ interface UploadResult {
2210
2310
  reservedUsd: number | null;
2211
2311
  scored: number;
2212
2312
  mean: number | null;
2313
+ /** The median page score, a whole number (what the CLI prints). */
2314
+ typical: number | null;
2213
2315
  causes: UxCause[];
2214
2316
  errors: string[];
2215
2317
  filed?: ScorecardFileOutcome;
@@ -2246,4 +2348,5 @@ interface Verdict {
2246
2348
  }
2247
2349
  declare function decide(input: VerdictInput): Verdict;
2248
2350
 
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 };
2351
+ export { AGENTS, CLIP_LIMITS, DEFAULT_CLIP_VIEWPORT, DEFAULT_JUDGE_MODEL, DEFAULT_SCORECARD_MODEL, DEFAULT_SCORECARD_VIEWPORT, DEFAULT_SETUP_COMMAND, FACTS_SCRIPT, POINTER_PROMPT, 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, VIEWPORTS, accessibilityCap, anchoredDimensions, applyFacts, buildPacket, capFlows, captureFolder, capturePage, captureSurface, causeIsFileable, causeRank, causeReportBody, causeSlug, causeTokens, clampCaps, clipSlug, clipUploadBody, countedDimensions, 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, rawScores, reactRouterPaths, readCaptures, readScreens, recordClips, rescorePage, 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, typicalScore, unshuffle, uploadAllShots, uploadCaptures, uploadClips };
2352
+ export type { AgentAdapter, AgentName, AgentRunOptions, AllowRule, AxeViolation, BrowserSession, Candidate, Capture, CapturedScreen, ClipFlow, ClipResult, ClipSkip, ClipUploadOutcome, CursorCloudDeps, Dashboard, DiscoverOptions, FreshAction, FreshAsk, FreshEyesFinding, FreshEyesOptions, FreshEyesPersona, FreshEyesResult, FreshEyesSession, FreshEyesStep, GuardPolicy, Identity, IterationRecord, JudgeClaim, JudgeOptions, JudgeVerdict, LayoutIssue, LoopEvent, LoopHandle, LoopOptions, NativeNode, Opinion, OpinionCategory, PacketInput, PageCapture, PageFacts, ParsedPageScore, Phase, PhaseName, ProbeResult, RecordClipsOptions, ReplayStep, RequirementKind, RunState, ScoreVia, ScorecardFileOutcome, ScorecardOptions, ScorecardPageResult, ScorecardResult, ScorecardRow, ScoredPage, Scorer, ServerClipCaps, StallReason, StepOutcome, SuccessCheck, Surface, SurfaceKind, SurfaceState, SurfaceStatus, SyncConfig, SyncHandle, TerminalHandoff, TerminalOptions, TerminalResult, UploadOptions, UploadPlatform, UploadResult, UploadSource, UxCause, UxCausePage, UxClaim, UxDimension, UxFilingPlan, UxIssue, UxPageFacts, UxPagePromptContext, UxPageScore, UxSeverity, Verdict, VerdictInput, Viewport, WriteMode };