@mushi-mushi/ux 0.3.0 → 0.4.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/LICENSE +1 -1
- package/README.md +30 -8
- package/dist/cli.js +984 -102
- package/dist/index.d.ts +475 -1
- package/dist/index.js +921 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1390,6 +1390,480 @@ declare function routesFromSource(root: string): string[];
|
|
|
1390
1390
|
/** Paths listed in /sitemap.xml on the same origin; empty when there is none. */
|
|
1391
1391
|
declare function sitemapPaths(baseUrl: string): Promise<string[]>;
|
|
1392
1392
|
|
|
1393
|
+
/**
|
|
1394
|
+
* FILE: _shared/ux-scorecard.ts (kept byte-identical in packages/ux/src/scorecard-rubric.ts)
|
|
1395
|
+
* PURPOSE: The UX scorecard's rules (ADR 0067): the written rubric, the
|
|
1396
|
+
* prompts, how a model's answer is read, how a page's score is
|
|
1397
|
+
* computed, how issues on many pages group into one root cause, and
|
|
1398
|
+
* which causes are filed as reports.
|
|
1399
|
+
*
|
|
1400
|
+
* The server (api/routes/ux-scorecard.ts, the platform route `ux-scorecard`)
|
|
1401
|
+
* and the CLI (`mushi-ux scorecard`, the local transports) run these same
|
|
1402
|
+
* functions, so a page scored either way reads the same.
|
|
1403
|
+
*
|
|
1404
|
+
* Facts stay in code (ADR 0039): the model gives each rubric dimension a 1–10
|
|
1405
|
+
* score and names issues with quoted evidence; the measured settle time and
|
|
1406
|
+
* the axe counts cap the performance and accessibility scores, the overall
|
|
1407
|
+
* score is computed here from the eight, and only causes with evidence seen on
|
|
1408
|
+
* the page are filed.
|
|
1409
|
+
*
|
|
1410
|
+
* No imports, no Deno or Node globals: vitest and Deno both load it as is.
|
|
1411
|
+
*/
|
|
1412
|
+
declare const UX_SCORECARD_PROMPT_VERSION = "ux-scorecard-2026-11-21.2";
|
|
1413
|
+
declare const UX_DIMENSIONS: readonly ["clarity", "hierarchy", "consistency", "states", "truthfulness", "copy", "accessibility", "performance"];
|
|
1414
|
+
type UxDimension = (typeof UX_DIMENSIONS)[number];
|
|
1415
|
+
type UxSeverity = 'high' | 'medium' | 'low';
|
|
1416
|
+
/** What each dimension asks. The prompt quotes it; the console shows it. */
|
|
1417
|
+
declare const UX_RUBRIC: Readonly<Record<UxDimension, {
|
|
1418
|
+
label: string;
|
|
1419
|
+
asks: string;
|
|
1420
|
+
}>>;
|
|
1421
|
+
/** The words every score anchors to, the same for each dimension. */
|
|
1422
|
+
declare const UX_SCORE_ANCHORS: readonly ["9–10: nothing a user would trip on.", "7–8: small polish only; the page does its job.", "5–6: a user notices a real problem but can still get the job done.", "3–4: a problem misleads the user or stops the page doing its job.", "1–2: the page is broken, empty where it should not be, or says something false."];
|
|
1423
|
+
declare const UX_SCORECARD_LIMITS: {
|
|
1424
|
+
/** Visible text sent per page. */
|
|
1425
|
+
readonly text: 6000;
|
|
1426
|
+
/** Issues kept per page. */
|
|
1427
|
+
readonly issues: 5;
|
|
1428
|
+
/** Claims kept per page, for the cross-page contradiction check. */
|
|
1429
|
+
readonly claims: 12;
|
|
1430
|
+
/** An issue under this confidence is dropped. */
|
|
1431
|
+
readonly minConfidence: 0.5;
|
|
1432
|
+
/** A cause is filed only at or above this confidence. */
|
|
1433
|
+
readonly fileConfidence: 0.6;
|
|
1434
|
+
/** Reports one run may file (one per root cause). */
|
|
1435
|
+
readonly filePerRun: 5;
|
|
1436
|
+
/** Causes a run keeps (stored, synced, shown, filed from): cross-page first, then by rank (topCauses). */
|
|
1437
|
+
readonly causes: 60;
|
|
1438
|
+
};
|
|
1439
|
+
interface UxPageFacts {
|
|
1440
|
+
/** The page's identity across runs: path plus its view-like query (scorecardPageKey). */
|
|
1441
|
+
key: string;
|
|
1442
|
+
/** Same-origin path with query. */
|
|
1443
|
+
path: string;
|
|
1444
|
+
/** What the app calls the page: its nav label, else its heading. */
|
|
1445
|
+
label: string;
|
|
1446
|
+
/** document.title once settled. */
|
|
1447
|
+
title: string;
|
|
1448
|
+
breadcrumb?: string;
|
|
1449
|
+
headings: string[];
|
|
1450
|
+
/** Visible text of the settled page, trimmed. */
|
|
1451
|
+
text: string;
|
|
1452
|
+
/** Visible button and link labels in the main content. */
|
|
1453
|
+
controls: string[];
|
|
1454
|
+
/** Visible text early in the load (about 1 s), when it differs: loading and placeholder states. */
|
|
1455
|
+
earlyText?: string;
|
|
1456
|
+
/** Milliseconds until the page stopped changing; null when it never settled within the wait. */
|
|
1457
|
+
settleMs: number | null;
|
|
1458
|
+
/** Serious and critical axe results; null when axe could not run on the page. */
|
|
1459
|
+
axe: {
|
|
1460
|
+
critical: number;
|
|
1461
|
+
serious: number;
|
|
1462
|
+
rules: string[];
|
|
1463
|
+
} | null;
|
|
1464
|
+
overflowX: boolean;
|
|
1465
|
+
consoleErrors: number;
|
|
1466
|
+
cls: number;
|
|
1467
|
+
viewport: {
|
|
1468
|
+
width: number;
|
|
1469
|
+
height: number;
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
interface UxIssue {
|
|
1473
|
+
dimension: UxDimension;
|
|
1474
|
+
severity: UxSeverity;
|
|
1475
|
+
title: string;
|
|
1476
|
+
problem: string;
|
|
1477
|
+
/** Text quoted from the page (or the screenshot) that shows the problem. */
|
|
1478
|
+
evidence: string;
|
|
1479
|
+
fix: string;
|
|
1480
|
+
/** The shared thing one fix would land in, when it likely repeats on other pages. Empty: this page only. */
|
|
1481
|
+
cause: string;
|
|
1482
|
+
confidence: number;
|
|
1483
|
+
/** The evidence was found in the page's own text, title or controls. */
|
|
1484
|
+
evidenceSeen: boolean;
|
|
1485
|
+
}
|
|
1486
|
+
interface UxClaim {
|
|
1487
|
+
subject: string;
|
|
1488
|
+
value: string;
|
|
1489
|
+
}
|
|
1490
|
+
interface UxPageScore {
|
|
1491
|
+
key: string;
|
|
1492
|
+
/** One line: what the page is. */
|
|
1493
|
+
page: string;
|
|
1494
|
+
scores: Record<UxDimension, number>;
|
|
1495
|
+
why: Partial<Record<UxDimension, string>>;
|
|
1496
|
+
/** Dimensions a measured fact capped below the model's score, with the model's number. */
|
|
1497
|
+
capped: Partial<Record<UxDimension, number>>;
|
|
1498
|
+
overall: number;
|
|
1499
|
+
issues: UxIssue[];
|
|
1500
|
+
claims: UxClaim[];
|
|
1501
|
+
promptVersion: string;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* A page's identity across runs: the path, plus only the query params that
|
|
1505
|
+
* pick a view (`/team?view=sso` and `/team?view=billing` are two pages; a
|
|
1506
|
+
* `?project=` or a record id in the query is not a page). Trailing slashes and
|
|
1507
|
+
* the hash are dropped.
|
|
1508
|
+
*/
|
|
1509
|
+
declare function scorecardPageKey(path: string): string;
|
|
1510
|
+
interface UxPagePromptContext {
|
|
1511
|
+
app: string;
|
|
1512
|
+
/** Labels of the app's other pages in this run: what "consistent" means here. */
|
|
1513
|
+
otherPages: string[];
|
|
1514
|
+
/** What the app is and who uses it, when known. */
|
|
1515
|
+
about?: string;
|
|
1516
|
+
/** Screenshot file names the model can read, in order (local transports). */
|
|
1517
|
+
images?: string[];
|
|
1518
|
+
}
|
|
1519
|
+
/** Pure: the system text for one page's score. */
|
|
1520
|
+
declare function pageSystemPrompt(): string;
|
|
1521
|
+
/** Pure: the user text for one page's score. The screenshots go with it. */
|
|
1522
|
+
declare function pageUserPrompt(f: UxPageFacts, ctx: UxPagePromptContext): string;
|
|
1523
|
+
/** Pure: the first JSON object in a model's text answer, or null. */
|
|
1524
|
+
declare function firstJsonObject(text: string | null | undefined): Record<string, unknown> | null;
|
|
1525
|
+
/** Pure: lower-case, collapsed whitespace, typographic quotes and dashes folded. */
|
|
1526
|
+
declare function normText(s: string): string;
|
|
1527
|
+
/**
|
|
1528
|
+
* Pure: whether quoted evidence appears in the page's own words. The model
|
|
1529
|
+
* often quotes a phrase with quotes or an ellipsis around it; any quoted
|
|
1530
|
+
* fragment of 6+ characters found in the page counts.
|
|
1531
|
+
*/
|
|
1532
|
+
declare function evidenceSeenIn(evidence: string, f: Pick<UxPageFacts, 'text' | 'title' | 'controls' | 'headings' | 'earlyText' | 'breadcrumb'>): boolean;
|
|
1533
|
+
/** Pure: the performance score the measured settle time allows. */
|
|
1534
|
+
declare function performanceCap(settleMs: number | null): number;
|
|
1535
|
+
/** Pure: the accessibility score the measured axe results and sideways scroll allow. */
|
|
1536
|
+
declare function accessibilityCap(f: Pick<UxPageFacts, 'axe' | 'overflowX'>): number;
|
|
1537
|
+
/**
|
|
1538
|
+
* Pure: the page's overall score from its eight. A page is as good as its
|
|
1539
|
+
* worst problem lets it be: one terrible dimension drags it down as much as
|
|
1540
|
+
* the average does (0.5 × mean + 0.5 × min), rounded to a whole number.
|
|
1541
|
+
*/
|
|
1542
|
+
declare function overallScore(scores: Record<UxDimension, number>): number;
|
|
1543
|
+
type ParsedPageScore = {
|
|
1544
|
+
ok: true;
|
|
1545
|
+
value: UxPageScore;
|
|
1546
|
+
} | {
|
|
1547
|
+
ok: false;
|
|
1548
|
+
error: string;
|
|
1549
|
+
};
|
|
1550
|
+
/**
|
|
1551
|
+
* Pure: read a model's answer for one page. All eight scores must be there
|
|
1552
|
+
* (whole numbers 1–10, clamped); the measured facts cap performance and
|
|
1553
|
+
* accessibility; issues without a known dimension, severity, title, evidence
|
|
1554
|
+
* or fix, worded as taste, or under the confidence floor are dropped.
|
|
1555
|
+
*/
|
|
1556
|
+
declare function parsePageAnswer(answer: unknown, facts: UxPageFacts): ParsedPageScore;
|
|
1557
|
+
interface UxCausePage {
|
|
1558
|
+
key: string;
|
|
1559
|
+
label: string;
|
|
1560
|
+
issueTitle: string;
|
|
1561
|
+
evidence: string;
|
|
1562
|
+
}
|
|
1563
|
+
interface UxCause {
|
|
1564
|
+
/** ux:<dimension>:<slug>, the report's pattern_key. */
|
|
1565
|
+
patternKey: string;
|
|
1566
|
+
dimension: UxDimension;
|
|
1567
|
+
severity: UxSeverity;
|
|
1568
|
+
kind: 'shared' | 'contradiction' | 'page';
|
|
1569
|
+
title: string;
|
|
1570
|
+
problem: string;
|
|
1571
|
+
fix: string;
|
|
1572
|
+
pages: UxCausePage[];
|
|
1573
|
+
confidence: number;
|
|
1574
|
+
/** At least one page's evidence was found in its own text. */
|
|
1575
|
+
evidenceSeen: boolean;
|
|
1576
|
+
}
|
|
1577
|
+
/** Pure: the meaningful words of a phrase, for matching causes. */
|
|
1578
|
+
declare function causeTokens(s: string): string[];
|
|
1579
|
+
/** Pure: a short slug of a phrase (at most 6 meaningful words). */
|
|
1580
|
+
declare function causeSlug(s: string): string;
|
|
1581
|
+
/** Pure: whether two cause phrases name the same shared thing. */
|
|
1582
|
+
declare function sameCause(a: string, b: string): boolean;
|
|
1583
|
+
/**
|
|
1584
|
+
* Pure: the pattern key of a cause. When an earlier run's open key names the
|
|
1585
|
+
* same thing in the same dimension, it is reused, so a reworded cause keeps
|
|
1586
|
+
* its report (ADR 0065's lesson: free-text slugs drift; 521 slugs for 550
|
|
1587
|
+
* reports).
|
|
1588
|
+
*/
|
|
1589
|
+
declare function patternKeyFor(dimension: UxDimension, phrase: string, priorKeys?: readonly string[]): string;
|
|
1590
|
+
interface ScoredPage {
|
|
1591
|
+
key: string;
|
|
1592
|
+
label: string;
|
|
1593
|
+
score: UxPageScore;
|
|
1594
|
+
/** The facts it was scored on, when kept: a contradiction's evidence is checked against them. */
|
|
1595
|
+
facts?: UxPageFacts;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Pure: group the run's issues into root causes, without a model. Issues on
|
|
1599
|
+
* different pages join when their `cause` names the same shared thing in the
|
|
1600
|
+
* same dimension, or when they quote the same evidence (the same banner text
|
|
1601
|
+
* on ten pages). Everything else stays a one-page cause.
|
|
1602
|
+
*/
|
|
1603
|
+
declare function groupCauses(pages: readonly ScoredPage[], priorKeys?: readonly string[]): UxCause[];
|
|
1604
|
+
/** Pure: how much fixing a cause is worth: severity × reach × confidence. */
|
|
1605
|
+
declare function causeRank(c: Pick<UxCause, 'severity' | 'pages' | 'confidence' | 'kind'>): number;
|
|
1606
|
+
/**
|
|
1607
|
+
* Pure: the causes a run keeps, at most `max`: causes that span pages or
|
|
1608
|
+
* contradict come first, then one-page causes, each by rank. The first real
|
|
1609
|
+
* run (Mushi console, 74 pages, 2026-11-21) grouped 299 issues into 235
|
|
1610
|
+
* causes, past what the routes stored, so every route and the CLI keep these.
|
|
1611
|
+
*/
|
|
1612
|
+
declare function topCauses<T extends Pick<UxCause, 'kind' | 'severity' | 'pages' | 'confidence' | 'patternKey'>>(causes: readonly T[], max?: number): T[];
|
|
1613
|
+
/** Pure: the system and user text of the cross-page pass (text only, one call per run). */
|
|
1614
|
+
declare function groupingPrompt(pages: readonly ScoredPage[], priorKeys?: readonly string[]): {
|
|
1615
|
+
system: string;
|
|
1616
|
+
user: string;
|
|
1617
|
+
};
|
|
1618
|
+
/**
|
|
1619
|
+
* Pure: merge the cross-page pass into the code's grouping. A model cause
|
|
1620
|
+
* must reference issues or pages that exist; its issues leave the groups they
|
|
1621
|
+
* were in, and groups left empty go. A contradiction may cite pages only.
|
|
1622
|
+
*/
|
|
1623
|
+
declare function mergeGrouping(pages: readonly ScoredPage[], base: readonly UxCause[], answer: unknown, priorKeys?: readonly string[]): UxCause[];
|
|
1624
|
+
/** Pure: whether a cause is worth a report: it spans pages, contradicts, or is a high-severity problem, with evidence and confidence. */
|
|
1625
|
+
declare function causeIsFileable(c: UxCause): boolean;
|
|
1626
|
+
interface UxFilingPlan {
|
|
1627
|
+
/** New reports, one per root cause, best first. */
|
|
1628
|
+
file: UxCause[];
|
|
1629
|
+
/** Causes whose pattern already has an open report: its screens are refreshed, no new report. */
|
|
1630
|
+
update: UxCause[];
|
|
1631
|
+
/** Fileable causes left over the run's cap. */
|
|
1632
|
+
overCap: UxCause[];
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Pure: which causes a run files. One report per root cause (pattern key);
|
|
1636
|
+
* a cause whose key has an open report only refreshes that report's pages,
|
|
1637
|
+
* and does not count toward the cap.
|
|
1638
|
+
*/
|
|
1639
|
+
declare function planFiling(causes: readonly UxCause[], openKeys: readonly string[], cap?: number): UxFilingPlan;
|
|
1640
|
+
/** The marker a filed report carries, found by the reports search. */
|
|
1641
|
+
declare function scorecardMarker(patternKey: string): string;
|
|
1642
|
+
/** Pure: the report a cause files. */
|
|
1643
|
+
declare function causeReportBody(c: UxCause, ctx: {
|
|
1644
|
+
baseUrl: string;
|
|
1645
|
+
runId: string;
|
|
1646
|
+
pageScores: Readonly<Record<string, number>>;
|
|
1647
|
+
}): {
|
|
1648
|
+
title: string;
|
|
1649
|
+
description: string;
|
|
1650
|
+
severity: UxSeverity;
|
|
1651
|
+
component: string;
|
|
1652
|
+
};
|
|
1653
|
+
interface ScorecardRow {
|
|
1654
|
+
key: string;
|
|
1655
|
+
label: string;
|
|
1656
|
+
overall: number;
|
|
1657
|
+
scores: Record<UxDimension, number>;
|
|
1658
|
+
issues: UxIssue[];
|
|
1659
|
+
/** Earlier runs' overall scores for this page, oldest first. */
|
|
1660
|
+
history: number[];
|
|
1661
|
+
/** This run minus the previous run, when there is one. */
|
|
1662
|
+
delta: number | null;
|
|
1663
|
+
}
|
|
1664
|
+
/** Pure: pages worst first, each with its trend from earlier runs. */
|
|
1665
|
+
declare function scorecardRows(pages: readonly ScoredPage[], history?: ReadonlyArray<{
|
|
1666
|
+
key: string;
|
|
1667
|
+
overall: number;
|
|
1668
|
+
at: string;
|
|
1669
|
+
}>): ScorecardRow[];
|
|
1670
|
+
/** Pure: the scorecard as Markdown: cross-cutting causes, then pages worst first. */
|
|
1671
|
+
declare function scorecardMarkdown(input: {
|
|
1672
|
+
app: string;
|
|
1673
|
+
url: string;
|
|
1674
|
+
at: string;
|
|
1675
|
+
viewport: {
|
|
1676
|
+
width: number;
|
|
1677
|
+
height: number;
|
|
1678
|
+
};
|
|
1679
|
+
rows: readonly ScorecardRow[];
|
|
1680
|
+
causes: readonly UxCause[];
|
|
1681
|
+
}): string;
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* `mushi-ux scorecard`: score every page of a live app against a written
|
|
1685
|
+
* rubric (ADR 0067), group what is wrong into root causes, and file the top
|
|
1686
|
+
* ones as Mushi reports.
|
|
1687
|
+
*
|
|
1688
|
+
* - Pages: `--path` / `--paths-file` (a route list), else the routes in the
|
|
1689
|
+
* app's source (`--routes-from`), else a crawl under the URL. A page keeps
|
|
1690
|
+
* its view (`/team?view=sso` is its own page).
|
|
1691
|
+
* - Capture: the audit's read-only session (a cached, signed-in profile, the
|
|
1692
|
+
* write guard), one viewport (desktop-first; the app's setting or
|
|
1693
|
+
* `--viewport`). Each page gives an early screenshot (about 1 s), a settled
|
|
1694
|
+
* one, its tab title, text, controls, settle time and axe counts.
|
|
1695
|
+
* `--from-captures` scores captures another browser driver made in the same
|
|
1696
|
+
* layout, so no second browser opens on a profile already in use.
|
|
1697
|
+
* - Score: `--score-via server` sends each page to the `ux-scorecard`
|
|
1698
|
+
* platform route (the app's own key first); `claude-code`, `cursor` and
|
|
1699
|
+
* `anthropic-api` score on this machine. Both run the same rubric module
|
|
1700
|
+
* (scorecard-rubric.ts, byte-identical to the server's).
|
|
1701
|
+
* - Output: scorecard.md and scorecard.json in the run folder; `--sync` puts
|
|
1702
|
+
* it on the console (Check → UX runs → Scorecard); `--file` files one report
|
|
1703
|
+
* per root cause, at most five a run.
|
|
1704
|
+
*/
|
|
1705
|
+
|
|
1706
|
+
type ScoreVia = 'server' | 'claude-code' | 'cursor' | 'anthropic-api';
|
|
1707
|
+
declare const DEFAULT_SCORECARD_VIEWPORT: {
|
|
1708
|
+
readonly width: 1440;
|
|
1709
|
+
readonly height: 900;
|
|
1710
|
+
};
|
|
1711
|
+
/** Model for the local transports (claude-code, anthropic-api): the standard tier. */
|
|
1712
|
+
declare const DEFAULT_SCORECARD_MODEL = "claude-sonnet-5-5";
|
|
1713
|
+
/** In-page: the facts a reader of the page gets, and whether it still looks busy. Kept as source so any driver can evaluate it. */
|
|
1714
|
+
declare const FACTS_SCRIPT = "(() => {\n const visible = (el) => { const r = el.getBoundingClientRect(); const s = getComputedStyle(el); return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none' }\n const clean = (t) => (t || '').replace(/\\s+/g, ' ').trim()\n const main = document.querySelector('main, [role=\"main\"]') || document.body\n const outside = []\n for (const el of document.querySelectorAll('[role=\"alert\"], [role=\"status\"], [aria-live], header, [class*=\"toast\" i], [class*=\"banner\" i]')) {\n if (main.contains(el) || !visible(el)) continue\n const t = clean(el.innerText)\n if (t && t.length < 400 && !outside.includes(t)) outside.push(t)\n }\n const crumb = document.querySelector('nav[aria-label*=\"readcrumb\" i], [class*=\"breadcrumb\" i]')\n const headings = [...main.querySelectorAll('h1, h2, h3')].filter(visible).map((h) => clean(h.innerText)).filter(Boolean)\n const controls = []\n for (const el of main.querySelectorAll('button, a[href], [role=\"button\"], [role=\"tab\"], select')) {\n if (!visible(el)) continue\n const t = clean(el.getAttribute('aria-label') || el.innerText || el.getAttribute('title') || '')\n if (t && t.length <= 80 && !controls.includes(t)) controls.push(t)\n if (controls.length >= 100) break\n }\n const text = clean(main.innerText)\n const busy = !!document.querySelector('[aria-busy=\"true\"]') || [...document.querySelectorAll('[class*=\"skeleton\" i], .animate-pulse')].some(visible) || /\\b(loading|checking|reading|fetching|composing)\\b[^.\\n]{0,40}(\u2026|\\.\\.\\.)/i.test(text)\n return {\n title: document.title,\n breadcrumb: crumb ? clean(crumb.innerText) : '',\n headings: headings.slice(0, 40),\n text: (outside.length ? 'Outside the page content: ' + outside.join(' | ') + '\\n' : '') + text,\n controls,\n overflowX: document.documentElement.scrollWidth > document.documentElement.clientWidth + 1,\n busy,\n sig: text.length + ':' + text.slice(0, 400),\n }\n})()";
|
|
1715
|
+
interface PageCapture {
|
|
1716
|
+
facts: UxPageFacts;
|
|
1717
|
+
early: Buffer;
|
|
1718
|
+
settled: Buffer;
|
|
1719
|
+
}
|
|
1720
|
+
/** Load one page and capture what a person sees early and once it settles. Works on any Playwright page. */
|
|
1721
|
+
declare function capturePage(page: Page, input: {
|
|
1722
|
+
baseUrl: string;
|
|
1723
|
+
path: string;
|
|
1724
|
+
label?: string;
|
|
1725
|
+
viewport: {
|
|
1726
|
+
width: number;
|
|
1727
|
+
height: number;
|
|
1728
|
+
};
|
|
1729
|
+
ignore?: readonly string[];
|
|
1730
|
+
axe?: boolean;
|
|
1731
|
+
}): Promise<PageCapture>;
|
|
1732
|
+
/** Pure: a folder name for a page key. */
|
|
1733
|
+
declare function captureFolder(key: string): string;
|
|
1734
|
+
/** Captures in `<dir>/pages/<page>/{facts.json, early.png, settled.png}`, as this tool or another driver wrote them. */
|
|
1735
|
+
declare function readCaptures(dir: string): Array<{
|
|
1736
|
+
folder: string;
|
|
1737
|
+
facts: UxPageFacts;
|
|
1738
|
+
}>;
|
|
1739
|
+
interface Scorer {
|
|
1740
|
+
readonly name: string;
|
|
1741
|
+
score(facts: UxPageFacts, folder: string, ctx: {
|
|
1742
|
+
app: string;
|
|
1743
|
+
otherPages: string[];
|
|
1744
|
+
about?: string;
|
|
1745
|
+
}): Promise<{
|
|
1746
|
+
score?: UxPageScore;
|
|
1747
|
+
error?: string;
|
|
1748
|
+
}>;
|
|
1749
|
+
group(pages: readonly ScoredPage[], base: readonly UxCause[], priorKeys: readonly string[]): Promise<{
|
|
1750
|
+
causes: UxCause[];
|
|
1751
|
+
error?: string;
|
|
1752
|
+
}>;
|
|
1753
|
+
/** Screenshot names this scorer already uploaded, per page key (the server scorer uploads as it scores). */
|
|
1754
|
+
readonly uploaded?: ReadonlyMap<string, string[]>;
|
|
1755
|
+
}
|
|
1756
|
+
/** Score on this machine through one of the checker's transports. */
|
|
1757
|
+
declare function localScorer(via: Exclude<ScoreVia, 'server'>, model: string, client?: Anthropic): Scorer;
|
|
1758
|
+
/** Score on the server through the `ux-scorecard` platform route (the app's own key first). */
|
|
1759
|
+
declare function serverScorer(cfg: SyncConfig, runId: string): Scorer;
|
|
1760
|
+
interface ScorecardOptions {
|
|
1761
|
+
url: string;
|
|
1762
|
+
app: string;
|
|
1763
|
+
about?: string;
|
|
1764
|
+
/** Pages to score (paths with their view query). Default: the routes in `routesFrom`, else a crawl. */
|
|
1765
|
+
paths?: string[];
|
|
1766
|
+
routesFrom?: string;
|
|
1767
|
+
maxPages?: number;
|
|
1768
|
+
viewport?: {
|
|
1769
|
+
width: number;
|
|
1770
|
+
height: number;
|
|
1771
|
+
};
|
|
1772
|
+
/** Score captures already on disk instead of opening a browser. */
|
|
1773
|
+
fromCaptures?: string;
|
|
1774
|
+
profileDir?: string;
|
|
1775
|
+
channel?: 'chrome' | 'chromium';
|
|
1776
|
+
allow?: AllowRule[];
|
|
1777
|
+
ignore?: string[];
|
|
1778
|
+
scorer: Scorer;
|
|
1779
|
+
/** Pages scored at once (local transports are slow; the server takes one page a request). */
|
|
1780
|
+
concurrency?: number;
|
|
1781
|
+
/** Earlier runs' pattern keys, so a reworded cause keeps its report. */
|
|
1782
|
+
priorKeys?: string[];
|
|
1783
|
+
/** Earlier runs' page scores, for the trend in scorecard.md. */
|
|
1784
|
+
history?: Array<{
|
|
1785
|
+
key: string;
|
|
1786
|
+
overall: number;
|
|
1787
|
+
at: string;
|
|
1788
|
+
}>;
|
|
1789
|
+
runId: string;
|
|
1790
|
+
outDir?: string;
|
|
1791
|
+
onProgress?: (msg: string) => void;
|
|
1792
|
+
/** After each page is captured or scored (the CLI syncs the run as it goes). */
|
|
1793
|
+
onPage?: (page: ScorecardPageResult) => Promise<void> | void;
|
|
1794
|
+
}
|
|
1795
|
+
interface ScorecardPageResult {
|
|
1796
|
+
facts: UxPageFacts;
|
|
1797
|
+
folder: string;
|
|
1798
|
+
score?: UxPageScore;
|
|
1799
|
+
error?: string;
|
|
1800
|
+
}
|
|
1801
|
+
interface ScorecardResult {
|
|
1802
|
+
runId: string;
|
|
1803
|
+
dir: string;
|
|
1804
|
+
pages: ScorecardPageResult[];
|
|
1805
|
+
causes: UxCause[];
|
|
1806
|
+
groupError?: string;
|
|
1807
|
+
markdown: string;
|
|
1808
|
+
}
|
|
1809
|
+
/** Pure: a scorecard run id in the console's format (yyyymmdd-hhmmss-xxxx). */
|
|
1810
|
+
declare function scorecardRunId(now: Date, rand?: () => number): string;
|
|
1811
|
+
declare function runScorecard(opts: ScorecardOptions): Promise<ScorecardResult>;
|
|
1812
|
+
/** Put the run on the console. Pages scored on the server are left as the server scored them. */
|
|
1813
|
+
declare function syncScorecard(cfg: SyncConfig, input: {
|
|
1814
|
+
runId: string;
|
|
1815
|
+
url: string;
|
|
1816
|
+
viewport: {
|
|
1817
|
+
width: number;
|
|
1818
|
+
height: number;
|
|
1819
|
+
};
|
|
1820
|
+
scoredBy: string;
|
|
1821
|
+
startedAt: string;
|
|
1822
|
+
finished: boolean;
|
|
1823
|
+
error?: string;
|
|
1824
|
+
pages: readonly ScorecardPageResult[];
|
|
1825
|
+
causes?: readonly UxCause[];
|
|
1826
|
+
cliVersion?: string;
|
|
1827
|
+
uploaded?: ReadonlyMap<string, string[]>;
|
|
1828
|
+
}): Promise<string | null>;
|
|
1829
|
+
/** Upload every page's screenshots (local scoring: the server scorer uploads as it scores). */
|
|
1830
|
+
declare function uploadAllShots(cfg: SyncConfig, runId: string, pages: readonly ScorecardPageResult[]): Promise<Map<string, string[]>>;
|
|
1831
|
+
interface ScorecardFileOutcome {
|
|
1832
|
+
filed: Array<{
|
|
1833
|
+
reportId: string;
|
|
1834
|
+
patternKey: string;
|
|
1835
|
+
title: string;
|
|
1836
|
+
}>;
|
|
1837
|
+
updated: Array<{
|
|
1838
|
+
reportId: string;
|
|
1839
|
+
patternKey: string;
|
|
1840
|
+
}>;
|
|
1841
|
+
skipped: Array<{
|
|
1842
|
+
patternKey: string;
|
|
1843
|
+
reason: string;
|
|
1844
|
+
}>;
|
|
1845
|
+
wouldFile?: Array<{
|
|
1846
|
+
patternKey: string;
|
|
1847
|
+
title: string;
|
|
1848
|
+
pages: number;
|
|
1849
|
+
}>;
|
|
1850
|
+
}
|
|
1851
|
+
/** File the run's top root causes (the server plans: one per pattern, the run and app caps). */
|
|
1852
|
+
declare function fileScorecard(cfg: SyncConfig, runId: string, input: {
|
|
1853
|
+
causes?: readonly UxCause[];
|
|
1854
|
+
dryRun?: boolean;
|
|
1855
|
+
}): Promise<ScorecardFileOutcome>;
|
|
1856
|
+
/** The app's earlier scorecard: its viewport setting, open pattern keys and page history, for a new run. */
|
|
1857
|
+
declare function scorecardContext(cfg: SyncConfig): Promise<{
|
|
1858
|
+
viewport: string | null;
|
|
1859
|
+
history: Array<{
|
|
1860
|
+
key: string;
|
|
1861
|
+
overall: number;
|
|
1862
|
+
at: string;
|
|
1863
|
+
}>;
|
|
1864
|
+
priorKeys: string[];
|
|
1865
|
+
}>;
|
|
1866
|
+
|
|
1393
1867
|
/**
|
|
1394
1868
|
* The cheap, objective keep-or-revert decision after one agent run. It only
|
|
1395
1869
|
* uses measurements (probes, pixel diff, files changed), never a model's
|
|
@@ -1419,4 +1893,4 @@ interface Verdict {
|
|
|
1419
1893
|
}
|
|
1420
1894
|
declare function decide(input: VerdictInput): Verdict;
|
|
1421
1895
|
|
|
1422
|
-
export { AGENTS, type AgentAdapter, type AgentName, type AgentRunOptions, type AllowRule, type AxeViolation, type BrowserSession, type Candidate, type Capture, type CursorCloudDeps, DEFAULT_JUDGE_MODEL, DEFAULT_SETUP_COMMAND, type Dashboard, type DiscoverOptions, 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 PageFacts, type Phase, type PhaseName, type ProbeResult, type ReplayStep, type RequirementKind, type RunState, type StallReason, type StepOutcome, type SuccessCheck, type Surface, type SurfaceKind, type SurfaceState, type SurfaceStatus, type SyncConfig, type SyncHandle, type TerminalHandoff, type TerminalOptions, type TerminalResult, VIEWPORTS, type Verdict, type VerdictInput, type Viewport, type WriteMode, buildPacket, captureSurface, cropTop, cursorCloudAdapter, cursorModel, dHash, decide, discover, findDesignFiles, getAgent, hammingHex, httpsRepoUrl, installGuard, isDestructiveLabel, isRequestAllowed, judgeSurface, loadState, newRunId, nextRoutePath, normalizeLink, openSession, pixelDiff, probePenalty, quoteArg, reactRouterPaths, routesFromSource, runDir, runFreshEyes, runProbes, runTerminalSetup, safeShotPath, saveState, settle, sitemapPaths, startDashboard, startLoop, startSync, surfaceKey, syncConfigFromEnv, toSnapshot, unshuffle };
|
|
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 };
|