literally-aeo 0.4.1 → 0.4.3

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.
Files changed (133) hide show
  1. package/README.md +16 -0
  2. package/dist/cli.mjs +1505 -549
  3. package/dist/lib/agents/copy-validation.js +3 -1
  4. package/dist/lib/agents/methodology.js +3 -3
  5. package/dist/lib/agents/verifier.js +2 -2
  6. package/dist/lib/bundle/contracts.js +1 -1
  7. package/dist/lib/bundle/export.js +13 -13
  8. package/dist/lib/bundle/journal.js +2 -2
  9. package/dist/lib/bundle/project-journal.js +5 -5
  10. package/dist/lib/bundle/project.js +11 -11
  11. package/dist/lib/bundle/read.js +14 -14
  12. package/dist/lib/bundle/recorder.js +3 -3
  13. package/dist/lib/bundle/redact.js +2 -2
  14. package/dist/lib/bundle/trace-coverage.js +2 -2
  15. package/dist/lib/bundle/verify-integrity.js +4 -4
  16. package/dist/lib/bundle/verify-measurement.js +2 -2
  17. package/dist/lib/bundle/verify-report.js +3 -3
  18. package/dist/lib/bundle/verify.js +8 -8
  19. package/dist/lib/checks/run-checks.js +4 -4
  20. package/dist/lib/chunks/{chunk-4KF5EVLI.js → chunk-2ANSPIUT.js} +2 -2
  21. package/dist/lib/chunks/{chunk-G22MXBBM.js → chunk-54GMIPWV.js} +1 -1
  22. package/dist/lib/chunks/{chunk-PI7PZKHP.js → chunk-65OIYOUH.js} +2 -2
  23. package/dist/lib/chunks/{chunk-2XMVEGQG.js → chunk-6MGXILUJ.js} +1 -1
  24. package/dist/lib/chunks/chunk-6OURIXQZ.js +472 -0
  25. package/dist/lib/chunks/{chunk-OBSW2WKF.js → chunk-746643QV.js} +1 -1
  26. package/dist/lib/chunks/{chunk-7DR2X7SF.js → chunk-74K4E3ZS.js} +1 -1
  27. package/dist/lib/chunks/{chunk-JVIOWZPG.js → chunk-7HCVSLVG.js} +1 -1
  28. package/dist/lib/chunks/{chunk-XX2TK6FI.js → chunk-7K2XT3WI.js} +5 -5
  29. package/dist/lib/chunks/{chunk-ABS5TK73.js → chunk-7K6CXSTL.js} +3 -1
  30. package/dist/lib/chunks/{chunk-CBOETT4C.js → chunk-7L4Y6N3V.js} +1 -1
  31. package/dist/lib/chunks/{chunk-FDCM7554.js → chunk-7QWT7LFM.js} +2 -2
  32. package/dist/lib/chunks/{chunk-4UN3YD5Z.js → chunk-7SA2CRSS.js} +1 -1
  33. package/dist/lib/chunks/{chunk-P7LGJGDL.js → chunk-ARKZ5PJN.js} +1 -1
  34. package/dist/lib/chunks/{chunk-4WPG2O2S.js → chunk-B6XGNJUU.js} +1 -1
  35. package/dist/lib/chunks/{chunk-5OL67GMN.js → chunk-BNX7S4GK.js} +4 -4
  36. package/dist/lib/chunks/chunk-BWBPEXEU.js +83 -0
  37. package/dist/lib/chunks/{chunk-U53GT2R7.js → chunk-BZAPAGXM.js} +1 -1
  38. package/dist/lib/chunks/{chunk-BNPWAQQG.js → chunk-C2Q7YE7Y.js} +6 -6
  39. package/dist/lib/chunks/{chunk-LYOCWN3R.js → chunk-D2LJMNH3.js} +2 -2
  40. package/dist/lib/chunks/{chunk-32HYNVPR.js → chunk-EVEJ3MFU.js} +3 -3
  41. package/dist/lib/chunks/{chunk-DGOFCRZM.js → chunk-GC7DISQO.js} +1 -1
  42. package/dist/lib/chunks/{chunk-BTRBLG6S.js → chunk-I6PQUKKF.js} +1 -1
  43. package/dist/lib/chunks/{chunk-6FGVCN4H.js → chunk-J5RYDPGP.js} +1 -1
  44. package/dist/lib/chunks/{chunk-JIUBLXR7.js → chunk-JHUI2K5X.js} +3 -3
  45. package/dist/lib/chunks/chunk-JQFLWUCA.js +123 -0
  46. package/dist/lib/chunks/{chunk-4RB3AOPT.js → chunk-JREYIUNG.js} +5 -5
  47. package/dist/lib/chunks/{chunk-42QARLUQ.js → chunk-JXQOWHWB.js} +3 -3
  48. package/dist/lib/chunks/{chunk-66BTHIL3.js → chunk-KFJ5O5CL.js} +2 -2
  49. package/dist/lib/chunks/{chunk-6P7EZJI7.js → chunk-KSJ3NZIJ.js} +4 -2
  50. package/dist/lib/chunks/{chunk-3RGUIUKU.js → chunk-L5HFTFFG.js} +2 -2
  51. package/dist/lib/chunks/{chunk-WBSJVDS2.js → chunk-LJD37WAV.js} +2 -2
  52. package/dist/lib/chunks/{chunk-QT5GTQGD.js → chunk-MKA2EP7M.js} +1 -1
  53. package/dist/lib/chunks/{chunk-CZMQ2DVJ.js → chunk-MMJ5UR2E.js} +1 -1
  54. package/dist/lib/chunks/{chunk-BWUOUP4J.js → chunk-MQFFMD4Q.js} +1 -1
  55. package/dist/lib/chunks/{chunk-7D7EOET3.js → chunk-NM2LUMQT.js} +4 -4
  56. package/dist/lib/chunks/{chunk-IJQEQL5Q.js → chunk-P5VVHTZU.js} +1 -1
  57. package/dist/lib/chunks/{chunk-OJQ66533.js → chunk-PFG3ESJE.js} +9 -9
  58. package/dist/lib/chunks/{chunk-WSATQQJI.js → chunk-Q7CWM6LZ.js} +6 -6
  59. package/dist/lib/chunks/{chunk-F6CC4WLO.js → chunk-R4HYBSQB.js} +1 -1
  60. package/dist/lib/chunks/{chunk-FWH3LYHG.js → chunk-R5NLULQW.js} +1 -1
  61. package/dist/lib/chunks/{chunk-WUDXMAJS.js → chunk-RM7U5M5L.js} +1 -1
  62. package/dist/lib/chunks/{chunk-3G6COT6E.js → chunk-RQ6GUJI5.js} +1 -1
  63. package/dist/lib/chunks/{chunk-TNTTIT2R.js → chunk-RUSMX6JH.js} +16 -7
  64. package/dist/lib/chunks/{chunk-G4GAGKSG.js → chunk-UNNRLD2U.js} +4 -4
  65. package/dist/lib/chunks/chunk-VFN2J4Z3.js +626 -0
  66. package/dist/lib/chunks/{chunk-BLDOQAEW.js → chunk-VPJN2GNC.js} +1 -1
  67. package/dist/lib/chunks/{chunk-3GDCPD5P.js → chunk-XSOTCSD3.js} +3 -3
  68. package/dist/lib/chunks/{chunk-WHW3NOG5.js → chunk-YX4EH6FR.js} +1 -1
  69. package/dist/lib/chunks/{chunk-TXGVQ6CN.js → chunk-ZC4MKS3J.js} +12 -12
  70. package/dist/lib/chunks/{chunk-VXO5RAR4.js → chunk-ZM4RHMBI.js} +1 -1
  71. package/dist/lib/cli/bundle-commands.js +60 -35
  72. package/dist/lib/cli/guide-command.js +1 -1
  73. package/dist/lib/cli/run-commands.js +40 -40
  74. package/dist/lib/cli/status-command.js +21 -21
  75. package/dist/lib/codex-workflow/aggregate.js +2 -2
  76. package/dist/lib/codex-workflow/author.js +5 -5
  77. package/dist/lib/codex-workflow/capture.js +5 -5
  78. package/dist/lib/codex-workflow/copy-editor.js +5 -5
  79. package/dist/lib/codex-workflow/copy.js +4 -4
  80. package/dist/lib/codex-workflow/finish.js +5 -5
  81. package/dist/lib/codex-workflow/loop.js +15 -15
  82. package/dist/lib/codex-workflow/run-source.js +5 -5
  83. package/dist/lib/codex-workflow/stage.js +6 -6
  84. package/dist/lib/engine/audit-file.js +3 -3
  85. package/dist/lib/engine/author.js +12 -12
  86. package/dist/lib/engine/cost-estimate.js +3 -3
  87. package/dist/lib/engine/local-run.js +20 -20
  88. package/dist/lib/engine/preflight.js +3 -3
  89. package/dist/lib/engine/rejudge.js +27 -27
  90. package/dist/lib/engine/resources.js +1 -1
  91. package/dist/lib/engine/run-bindings.js +3 -3
  92. package/dist/lib/engine/run-method.js +3 -3
  93. package/dist/lib/engine/run-models.js +4 -4
  94. package/dist/lib/engine/run-status.js +21 -21
  95. package/dist/lib/engine/templates.js +4 -4
  96. package/dist/lib/grounding/grounding-runtime.js +5 -5
  97. package/dist/lib/grounding/recorded-tools.js +4 -4
  98. package/dist/lib/pipeline.js +4 -4
  99. package/dist/lib/probes/bindings.js +2 -2
  100. package/dist/lib/probes/charged-trace.js +3 -3
  101. package/dist/lib/probes/probes.js +3 -3
  102. package/dist/lib/stores/files.js +3 -3
  103. package/dist/lib/stores/memory.js +2 -2
  104. package/dist/lib/stores/publication.js +2 -2
  105. package/dist/lib/viewer/alternatives.js +8 -0
  106. package/dist/lib/viewer/cited-domains.js +8 -0
  107. package/dist/lib/viewer/page.js +3 -1
  108. package/dist/lib/viewer/presentation.js +41 -0
  109. package/dist/lib/viewer/server.js +15 -10
  110. package/dist/types/agents/copy-validation.d.ts +2 -1
  111. package/dist/types/bundle/contracts.d.ts +1 -1
  112. package/dist/types/engine/resources.d.ts +2 -0
  113. package/dist/types/viewer/alternatives.d.ts +16 -0
  114. package/dist/types/viewer/cited-domains.d.ts +22 -0
  115. package/dist/types/viewer/page.d.ts +9 -2
  116. package/dist/types/viewer/presentation.d.ts +112 -0
  117. package/dist/types/viewer/server.d.ts +7 -3
  118. package/package.json +2 -1
  119. package/resources/fonts/Mulish-OFL.txt +93 -0
  120. package/resources/fonts/Mulish-VariableFont_wght.ttf +0 -0
  121. package/resources/fonts/SourceCodePro-OFL.txt +93 -0
  122. package/resources/fonts/SourceCodePro-VariableFont_wght.ttf +0 -0
  123. package/src/agents/copy-validation.ts +8 -2
  124. package/src/bundle/contracts.ts +1 -1
  125. package/src/cli/bundle-commands.ts +21 -0
  126. package/src/engine/resources.ts +9 -5
  127. package/src/report/core/rate-interval.ts +1 -2
  128. package/src/viewer/alternatives.ts +202 -0
  129. package/src/viewer/cited-domains.ts +127 -0
  130. package/src/viewer/page.ts +549 -236
  131. package/src/viewer/presentation.ts +759 -0
  132. package/src/viewer/server.ts +25 -4
  133. package/dist/lib/chunks/chunk-3TF4JGQA.js +0 -323
@@ -1,65 +1,227 @@
1
1
  // ============================================================================
2
2
  // The local report viewer's page (specs/aeo-open-source-cli-spec.md §4.3,
3
- // §10, §12): one self-contained document, no remote fonts, scripts or
4
- // images. Every captured or model-written string is inserted with
5
- // textContent, never as markup, and source links open only when clicked.
6
- // The script reads bundle files through the launch token it was served with.
3
+ // §10, §12), in the hosted report's design language: a pale amber hero with
4
+ // the hard-shadow measurement card, then full-width bands that alternate
5
+ // white and grey, one per market section. One self-contained document, no
6
+ // remote fonts, scripts or images. The server derives every figure
7
+ // (presentation.ts); this script only renders it. Every captured or
8
+ // model-written string is inserted with textContent, never as markup, and
9
+ // source links open only when clicked.
7
10
  // ============================================================================
8
11
 
9
12
  const styles = `
10
13
  :root {
11
- --bg: #ffffff; --fg: #16181d; --muted: #5d6470; --line: #e3e6eb;
12
- --panel: #f6f7f9; --accent: #3651d4; --pass: #1f7a46; --fail: #b3261e;
13
- --warn: #8a5a00;
14
+ --darkest: #000; --lightest: #fff; --brand-1: #ffd08a; --brand-1-light: #ffedd2;
15
+ --neutral-1: #f1f1f1; --neutral-2: #c8c8c8; --positive: #059669;
16
+ --positive-deep: #065f46; --mention: #8b5cf6; --mention-deep: #5b21b6;
17
+ --negative: #ef4444; --muted: rgb(0 0 0 / 0.6); --muted-strong: rgb(0 0 0 / 0.7);
18
+ --backdrop: rgb(0 0 0 / 0.25);
19
+ --font-body: Mulish, system-ui, -apple-system, "Segoe UI", sans-serif;
20
+ --font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;
21
+ /* Light only, as the hosted report is, whatever the system theme. */
14
22
  color-scheme: light;
15
23
  }
16
- @media (prefers-color-scheme: dark) {
17
- :root {
18
- --bg: #111317; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
19
- --panel: #181b21; --accent: #8fa2ff; --pass: #5fd08f; --fail: #ff8a80;
20
- --warn: #e5b45a;
21
- color-scheme: dark;
22
- }
23
- }
24
24
  * { box-sizing: border-box; }
25
- body { margin: 0; background: var(--bg); color: var(--fg);
26
- font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
27
- main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
28
- h1 { font-size: 24px; margin: 0 0 4px; }
29
- h2 { font-size: 18px; margin: 32px 0 12px; }
30
- h3 { font-size: 15px; margin: 20px 0 8px; }
25
+ html { -webkit-text-size-adjust: 100%; }
26
+ body { margin: 0; background: var(--lightest); color: var(--darkest);
27
+ font: 16px/1.5 var(--font-body); }
28
+ p, h1, h2, h3, ul { margin: 0; }
29
+ ul { padding: 0; list-style: none; }
30
+ button { font: inherit; color: inherit; }
31
+ button:not(:disabled) { cursor: pointer; }
32
+ :focus-visible { outline: 2px solid var(--darkest); outline-offset: 2px; }
33
+ .mono { font-family: var(--font-mono); }
31
34
  .muted { color: var(--muted); }
32
- .banner { border: 1px solid var(--line); background: var(--panel);
33
- padding: 12px 14px; border-radius: 8px; margin: 16px 0; }
34
- .banner.warn { border-color: var(--warn); }
35
- .grid { display: grid; gap: 12px;
36
- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
37
- .stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
38
- .stat b { display: block; font-size: 22px; }
39
- .interval { display: block; color: var(--muted); font-size: 13px; }
40
- button.tip-trigger { background: none; border: 0; padding: 0; color: inherit; font: inherit;
41
- text-align: left; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
42
- button.tip-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
43
- .tip { display: block; color: var(--fg); }
35
+ .container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
36
+ .band { background: var(--lightest); }
37
+ .band.soft { background: var(--neutral-1); }
38
+ .band > .container > .band-inner { padding: 60px 0; }
39
+ .banner { background: var(--darkest); color: var(--lightest); padding: 12px 20px;
40
+ text-align: center; font-size: 14px; }
41
+ .eyebrow { font-family: var(--font-mono); font-size: 14px; line-height: 20px;
42
+ font-weight: 500; text-transform: uppercase; }
43
+ .h1 { font-size: 32px; line-height: 37px; font-weight: 900; text-wrap: balance; }
44
+ .h2 { font-size: 28px; line-height: 34px; font-weight: 900; text-wrap: balance; }
45
+ .h5 { font-size: 18px; line-height: 25px; font-weight: 800; }
46
+ .body-1 { font-size: 20px; line-height: 24px; font-weight: 500; }
47
+ .body-2 { font-size: 18px; line-height: 22px; font-weight: 500; }
48
+ .hero { background: var(--brand-1-light); }
49
+ .hero-grid { display: grid; gap: 40px; padding: 40px 0 60px; }
50
+ .hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
51
+ .hero-copy .body-1 { max-width: 720px; }
52
+ .measured { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--muted); }
53
+ .measurement { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--lightest);
54
+ padding: 20px; box-shadow: 8px 8px var(--neutral-2); }
55
+ .measurement-figure { font-size: 50px; line-height: 56px; font-weight: 900; margin-top: 12px; }
56
+ .facts { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
57
+ .facts li { font-family: var(--font-mono); font-size: 14px; line-height: 20px; font-weight: 500;
58
+ border: 1px solid var(--neutral-2); border-radius: 4px; background: var(--neutral-1); padding: 12px; }
59
+ .header { display: grid; gap: 16px; }
60
+ .header-title { display: flex; flex-direction: column; gap: 12px; }
61
+ .header.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
62
+ .header.center .body-2 { max-width: 820px; }
63
+ .scorecards { margin-top: 40px; border-radius: 16px; background: var(--brand-1-light); padding: 30px 20px; }
64
+ .scorecards-grid { display: grid; grid-template-columns: 1fr; gap: 30px; }
65
+ .stat { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
66
+ .stat-figure { font-family: var(--font-mono); font-size: 40px; line-height: 36px;
67
+ font-variant-numeric: tabular-nums; }
68
+ .stat-label { font-size: 16px; font-weight: 700; }
69
+ .stat-detail { font-size: 14px; color: var(--muted-strong); }
70
+ .interval { display: block; }
71
+ .tip-trigger { background: none; border: 0; padding: 0; margin: 0; text-align: left;
72
+ font-size: 14px; color: var(--muted-strong); text-decoration: underline dotted;
73
+ text-underline-offset: 4px; cursor: help; }
74
+ .tip { display: block; margin-top: 4px; font-size: 12px; color: var(--muted-strong); }
44
75
  .tip[hidden] { display: none; }
45
- table { width: 100%; border-collapse: collapse; font-size: 14px; }
46
- th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
47
- vertical-align: top; }
48
- th { color: var(--muted); font-weight: 600; }
49
- tr.row { cursor: pointer; }
50
- tr.row:hover, tr.row:focus { background: var(--panel); outline: none; }
51
- .pass { color: var(--pass); } .fail { color: var(--fail); }
52
- .limited { color: var(--warn); }
53
- .drawer { border: 1px solid var(--line); border-radius: 8px; padding: 14px;
54
- margin-top: 12px; background: var(--panel); }
55
- pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace,
56
- SFMono-Regular, Menlo, monospace; margin: 8px 0 0; }
57
- button.link { background: none; border: 0; color: var(--accent); padding: 0;
58
- font: inherit; cursor: pointer; text-decoration: underline; }
59
- .table-wrap { overflow-x: auto; }
60
- ul.methodology { padding-left: 20px; color: var(--muted); font-size: 14px; }
61
- ul.methodology li { margin: 6px 0; }
62
- footer { margin-top: 48px; color: var(--muted); font-size: 13px; }
76
+ .subsection { margin-top: 40px; }
77
+ .card { margin-top: 20px; border: 1px solid var(--neutral-2); border-radius: 8px;
78
+ background: var(--lightest); padding: 20px; }
79
+ .card-title { font-size: 16px; font-weight: 700; }
80
+ .card-lead { margin-top: 4px; font-size: 14px; color: var(--muted); }
81
+ .scroll { overflow-x: auto; }
82
+ table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
83
+ th { font-family: var(--font-mono); font-weight: 500; color: var(--muted); text-align: left;
84
+ border-bottom: 1px solid var(--neutral-2); padding: 8px 12px; }
85
+ td { border-bottom: 1px solid var(--neutral-2); padding: 10px 12px; vertical-align: top; }
86
+ .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
87
+ .rate { font-weight: 600; font-variant-numeric: tabular-nums; }
88
+ tr.total td { border-bottom: 0; font-weight: 700; color: var(--darkest); }
89
+ tr.selectable { cursor: pointer; }
90
+ tr.selectable:hover { background: var(--neutral-1); }
91
+ .row-button { background: none; border: 0; padding: 0; text-align: left; }
92
+ .matrix-card { margin-top: 40px; padding: 16px; }
93
+ .matrix { min-width: 640px; }
94
+ .matrix th, .matrix td { text-align: center; padding: 8px 12px; }
95
+ .matrix th.prompt-head, .matrix td.prompt { text-align: left; position: sticky; left: 0;
96
+ z-index: 1; background: var(--lightest); }
97
+ .matrix td.prompt { max-width: 280px; }
98
+ .matrix .group { border-bottom: 0; padding-bottom: 4px; font-size: 11px; letter-spacing: 0.05em;
99
+ text-transform: uppercase; }
100
+ .matrix .agents-start { border-left: 1px solid var(--neutral-2); }
101
+ .prompt-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
102
+ overflow: hidden; font-size: 12px; line-height: 1.375; }
103
+ .prompt-category { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
104
+ text-transform: uppercase; color: var(--muted); }
105
+ .cell { display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
106
+ gap: 2px; min-width: 36px; min-height: 36px; padding: 4px 6px; border: 1px solid transparent;
107
+ border-radius: 6px; background: none; }
108
+ .cell:hover { border-color: var(--neutral-2); background: var(--neutral-1); }
109
+ .cell-count { font-size: 9px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
110
+ .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--neutral-2); }
111
+ .dot.primary { width: 10px; height: 10px; background: var(--positive); }
112
+ .dot.mentioned { background: var(--mention); }
113
+ .dot.absent { background: var(--negative); opacity: 0.7; }
114
+ .legend { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; font-size: 11px; color: var(--muted); }
115
+ .legend li { display: flex; align-items: center; gap: 8px; }
116
+ .hint { margin-top: 12px; border: 1px solid var(--brand-1); border-radius: 6px;
117
+ background: var(--brand-1-light); padding: 8px 12px; font-size: 12px; line-height: 1.625; }
118
+ .bars { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
119
+ .bars li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr auto; align-items: center; gap: 12px; }
120
+ .bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
121
+ .bar-domain { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
122
+ .bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--neutral-1); }
123
+ .bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--darkest); }
124
+ .bar-value { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
125
+ .hosts { margin-left: 8px; font-size: 12px; color: var(--muted); }
126
+ .more { margin-top: 12px; background: none; border: 0; padding: 0; font-family: var(--font-mono);
127
+ font-size: 12px; text-decoration: underline; text-decoration-color: var(--brand-1);
128
+ text-decoration-thickness: 2px; text-underline-offset: 4px; }
129
+ .label { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.14em;
130
+ text-transform: uppercase; color: var(--muted); }
131
+ .pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
132
+ .pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--neutral-2);
133
+ border-radius: 999px; background: var(--neutral-1); padding: 4px 10px; font-size: 12px; }
134
+ .pill.plain { background: var(--lightest); }
135
+ .pill.dashed { border-style: dashed; background: none; color: var(--muted); }
136
+ .pill.mono { font-family: var(--font-mono); }
137
+ .pill.pass, .pill.primary { border-color: rgb(5 150 105 / 0.3); background: rgb(5 150 105 / 0.1);
138
+ color: var(--positive-deep); font-weight: 500; }
139
+ .pill.mentioned { border-color: rgb(139 92 246 / 0.3); background: rgb(139 92 246 / 0.1);
140
+ color: var(--mention-deep); font-weight: 500; }
141
+ .pill.fail, .pill.absent { border-color: rgb(239 68 68 / 0.2); background: rgb(239 68 68 / 0.1);
142
+ font-weight: 500; }
143
+ .pill-count { color: var(--muted); font-variant-numeric: tabular-nums; }
144
+ .verification td:nth-child(2) { white-space: nowrap; }
145
+ .footer { max-width: 720px; margin: 0 auto; text-align: center; font-size: 14px;
146
+ line-height: 1.625; color: var(--muted); }
147
+ .footer > * + * { margin-top: 12px; }
148
+ .footer h2 { margin-top: 24px; font-size: 14px; font-weight: 700; color: var(--muted-strong); }
149
+ .footer ul { margin-top: 8px; padding-left: 20px; list-style: disc; text-align: left; }
150
+ .footer ul li + li { margin-top: 4px; }
151
+ .footer-note { margin-top: 32px; border-top: 1px solid var(--neutral-2); padding-top: 24px; }
152
+ .sheet-backdrop { position: fixed; inset: 0; z-index: 1000; background: var(--backdrop); cursor: pointer; }
153
+ .sheet { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1001; display: flex;
154
+ flex-direction: column; width: 100%; max-width: 560px; background: var(--lightest);
155
+ padding: 20px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); }
156
+ .sheet[hidden], .sheet-backdrop[hidden] { display: none; }
157
+ .sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
158
+ .sheet-description { margin-top: 4px; font-size: 14px; color: var(--muted); }
159
+ .sheet-close { flex-shrink: 0; border: 1px solid var(--neutral-2); border-radius: 6px;
160
+ background: none; padding: 4px 10px; font-family: var(--font-mono); font-size: 14px; }
161
+ .sheet-close:hover { background: var(--neutral-1); }
162
+ .sheet-body { display: flex; flex-direction: column; gap: 20px; flex: 1; min-height: 0;
163
+ margin-top: 20px; padding-right: 4px; overflow-y: auto; }
164
+ .prompt-box { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--neutral-1); padding: 16px; }
165
+ .prompt-box p { margin-top: 8px; font-size: 14px; line-height: 1.625; }
166
+ .prompt-box p.prompt-category { font-size: 11px; letter-spacing: 0.14em; }
167
+ .run { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--lightest); padding: 16px; }
168
+ .run-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
169
+ .run-head .pills { margin-top: 0; justify-content: flex-end; }
170
+ .run-title { font-size: 14px; font-weight: 700; }
171
+ .run-surface { font-size: 12px; color: var(--muted); }
172
+ .run-block { margin-top: 16px; }
173
+ .snippet { margin-top: 16px; border-radius: 6px; background: var(--neutral-1); padding: 12px; }
174
+ .answer { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.625; }
175
+ .answer mark { background: var(--brand-1-light); color: inherit; border-radius: 2px;
176
+ box-shadow: 0 0 0 1px var(--brand-1); }
177
+ .links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
178
+ .source { max-width: 100%; background: none; border: 0; padding: 0; text-align: left;
179
+ overflow-wrap: anywhere; font-size: 12px; font-weight: 500; text-decoration: underline;
180
+ text-decoration-color: var(--brand-1); text-decoration-thickness: 2px; text-underline-offset: 4px; }
181
+ .source:hover { text-decoration-color: var(--darkest); }
182
+ .source-meta { margin-top: 2px; font-size: 11px; color: var(--muted); }
183
+ .empty { border: 1px dashed var(--neutral-2); border-radius: 6px; padding: 12px; font-size: 14px; color: var(--muted); }
184
+ @media (min-width: 480px) {
185
+ .h1 { font-size: 40px; line-height: 50px; }
186
+ .h2 { font-size: 32px; line-height: 38px; }
187
+ .scorecards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
188
+ .sheet { padding: 32px; }
189
+ }
190
+ @media (min-width: 768px) {
191
+ .container { padding: 0 30px; }
192
+ .h1 { font-size: 44px; line-height: 56px; }
193
+ .h2 { font-size: 36px; line-height: 42px; }
194
+ .h5 { font-size: 20px; }
195
+ .body-1 { font-size: 22px; line-height: 28px; }
196
+ .body-2 { font-size: 20px; line-height: 25px; }
197
+ .hero-grid { padding-top: 80px; }
198
+ .measurement { padding: 30px; }
199
+ .header.split { grid-template-columns: 0.8fr 1fr; align-items: start; gap: 40px; }
200
+ .scorecards { padding: 30px 40px; }
201
+ .scorecards-grid { gap: 40px; }
202
+ .matrix-card { padding: 20px; }
203
+ }
204
+ @media (min-width: 992px) {
205
+ .container { padding: 0 40px; }
206
+ .band > .container > .band-inner { padding: 100px 0; }
207
+ .eyebrow { font-size: 16px; }
208
+ .h2 { font-size: 42px; line-height: 50px; }
209
+ .body-1 { font-size: 24px; line-height: 30px; }
210
+ .hero-grid { grid-template-columns: minmax(0, 1fr) minmax(340px, 0.62fr); align-items: center;
211
+ padding: 100px 0; }
212
+ .measurement-figure { font-size: 72px; line-height: 78px; }
213
+ .facts li { font-size: 16px; }
214
+ .scorecards { padding: 40px 60px; }
215
+ .scorecards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
216
+ .scorecards-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
217
+ .stat-figure { font-size: 56px; line-height: 48px; }
218
+ }
219
+ @media (min-width: 1280px) {
220
+ .scorecards-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
221
+ }
222
+ @media (prefers-reduced-motion: reduce) {
223
+ * { scroll-behavior: auto; transition: none; }
224
+ }
63
225
  `;
64
226
 
65
227
  const script = `
@@ -76,46 +238,31 @@ const el = (tag, attrs = {}, ...children) => {
76
238
  else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
77
239
  else node.setAttribute(key, value);
78
240
  }
79
- for (const child of children) {
80
- if (child === null || child === undefined) continue;
241
+ for (const child of children.flat()) {
242
+ if (child === null || child === undefined || child === false) continue;
81
243
  node.append(typeof child === 'string' ? document.createTextNode(child) : child);
82
244
  }
83
245
  return node;
84
246
  };
85
- const percent = (value) =>
86
- typeof value === 'number' && Number.isFinite(value) ? Math.round(value * 100) + '%' : 'n/a';
87
- const isShare = (value) => typeof value === 'number' && value >= 0 && value <= 1;
88
- const isCount = (value) => Number.isSafeInteger(value) && value >= 0;
89
- // The evidence beside a rate (calculation version 2), or null when the
90
- // bundle has none or it is malformed: a bundle is shown even when it fails
91
- // verification, so its numbers are checked before they are displayed.
92
- const evidenceOf = (evidence) =>
93
- evidence && isShare(evidence.low) && isShare(evidence.high) && evidence.low <= evidence.high
94
- && isCount(evidence.count) && isCount(evidence.captured) && isCount(evidence.planned)
95
- ? evidence : null;
96
- // Outward to whole percents, so the range shown always contains the computed
97
- // interval. The bounds are stored to 6 decimals; scaling them to an integer
98
- // first keeps a bound of 0.07 (7.000000000000001 once multiplied) at 7%.
99
- // The rule of report/core/rate-interval.ts, repeated here because this page
100
- // is one self-contained script; page.spec.ts holds the two to the same
101
- // answers.
102
- const intervalText = (evidence) =>
103
- Math.floor(Math.round(evidence.low * 1e6) / 1e4) + '–'
104
- + Math.ceil(Math.round(evidence.high * 1e6) / 1e4) + '%';
247
+ const plural = (count, noun) => count + ' ' + noun + (count === 1 ? '' : 's');
248
+
249
+ // Escape closes whatever is open: a tooltip, or the evidence sheet.
250
+ const dismissals = [];
251
+ document.addEventListener('keydown', (event) => {
252
+ if (event.key === 'Escape') for (const dismiss of dismissals) dismiss();
253
+ });
254
+
105
255
  // The counts behind an interval, in a tooltip (WCAG 1.4.13). It opens on
106
256
  // hover, on keyboard focus and on a tap; it stays open while the pointer is
107
257
  // over it; Escape closes it; and a screen reader reads it as the interval's
108
258
  // description. It sits in the flow under the interval, so a scrolling table
109
259
  // cannot clip it and it hides nothing.
110
- const tipDismissals = [];
111
- document.addEventListener('keydown', (event) => {
112
- if (event.key === 'Escape') for (const dismiss of tipDismissals) dismiss();
113
- });
114
260
  let tipCount = 0;
115
- const withTip = (label, name, text) => {
261
+ const intervalOf = (interval) => {
262
+ if (!interval) return null;
116
263
  tipCount += 1;
117
264
  const id = 'tip-' + tipCount;
118
- const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' }, text);
265
+ const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' }, interval.counts);
119
266
  let hovered = false;
120
267
  let focused = false;
121
268
  const sync = () => {
@@ -123,186 +270,330 @@ const withTip = (label, name, text) => {
123
270
  else tip.setAttribute('hidden', '');
124
271
  };
125
272
  const trigger = el('button', { type: 'button', class: 'tip-trigger',
126
- 'aria-label': name, 'aria-describedby': id,
273
+ 'aria-label': interval.label, 'aria-describedby': id,
127
274
  // Safari focuses no button on a click or a tap, and a button that kept
128
275
  // focus through Escape gets no new focus event: a click (or Enter or
129
276
  // Space) opens the tip itself, until focus moves on.
130
277
  onclick: () => { trigger.focus(); focused = true; sync(); },
131
278
  onfocus: () => { focused = true; sync(); },
132
279
  onblur: () => { focused = false; sync(); },
133
- }, label);
134
- tipDismissals.push(() => { hovered = false; focused = false; sync(); });
280
+ }, interval.text);
281
+ dismissals.push(() => { hovered = false; focused = false; sync(); });
135
282
  return el('span', { class: 'interval',
136
283
  onmouseenter: () => { hovered = true; sync(); },
137
284
  onmouseleave: () => { hovered = false; sync(); },
138
285
  }, trigger, tip);
139
286
  };
140
- // A rate, with its interval and counts beneath when the bundle carries them.
141
- // subject names the rate for a screen reader, which reaches the interval
142
- // without the label or the column heading beside it.
143
- const rateFigure = (rate, recorded, subject, counted) => {
144
- const figure = el('b', {}, percent(rate));
145
- const evidence = evidenceOf(recorded);
146
- if (!evidence) return [figure];
147
- const interval = 'approx. 95% interval ' + intervalText(evidence);
148
- return [figure, withTip(interval, interval + ' for ' + subject,
149
- counted + ' in ' + evidence.count + ' of ' + evidence.planned + ' planned answers; '
150
- + evidence.captured + ' captured')];
287
+
288
+ // External sources open only on a deliberate click, in a new context.
289
+ const sourceLink = (url) => el('button', { class: 'source', type: 'button',
290
+ onclick: () => { if (/^https?:\\/\\//.test(url)) window.open(url, '_blank', 'noopener,noreferrer'); },
291
+ }, url);
292
+
293
+ // The brand's name marked in a captured answer, every piece of it text.
294
+ const highlighted = (text, term) => {
295
+ const needle = term.trim().toLowerCase();
296
+ if (!needle) return [text];
297
+ const haystack = text.toLowerCase();
298
+ const pieces = [];
299
+ let from = 0;
300
+ for (let at = haystack.indexOf(needle); at !== -1; at = haystack.indexOf(needle, from)) {
301
+ pieces.push(text.slice(from, at), el('mark', {}, text.slice(at, at + needle.length)));
302
+ from = at + needle.length;
303
+ }
304
+ pieces.push(text.slice(from));
305
+ return pieces.filter((piece) => piece !== '');
306
+ };
307
+
308
+ // The side sheet behind a matrix cell or a cited domain.
309
+ const createSheet = () => {
310
+ const title = el('h2', { class: 'h5', id: 'sheet-title' });
311
+ const description = el('p', { class: 'sheet-description' });
312
+ const body = el('div', { class: 'sheet-body' });
313
+ let opener = null;
314
+ let isOpen = false;
315
+ const backdrop = el('div', { class: 'sheet-backdrop', hidden: '', onclick: () => close() });
316
+ const closeButton = el('button', { type: 'button', class: 'sheet-close', onclick: () => close() }, 'Close');
317
+ const panel = el('div', { class: 'sheet', role: 'dialog', 'aria-modal': 'true',
318
+ 'aria-labelledby': 'sheet-title', hidden: '' },
319
+ el('div', { class: 'sheet-head' }, el('div', {}, title, description), closeButton), body);
320
+ const close = () => {
321
+ if (!isOpen) return;
322
+ isOpen = false;
323
+ backdrop.setAttribute('hidden', '');
324
+ panel.setAttribute('hidden', '');
325
+ // Focus returns to what opened the sheet.
326
+ opener?.focus();
327
+ };
328
+ dismissals.push(close);
329
+ const open = (from, heading, summary, content) => {
330
+ opener = from;
331
+ title.replaceChildren(heading);
332
+ description.replaceChildren(summary);
333
+ body.replaceChildren(...content);
334
+ backdrop.removeAttribute('hidden');
335
+ panel.removeAttribute('hidden');
336
+ isOpen = true;
337
+ closeButton.focus();
338
+ };
339
+ return { nodes: [backdrop, panel], open };
340
+ };
341
+
342
+ const band = (tone, ...content) => el('section', { class: tone === 'soft' ? 'band soft' : 'band' },
343
+ el('div', { class: 'container' }, el('div', { class: 'band-inner' }, ...content)));
344
+
345
+ const sectionHeader = (eyebrow, heading, lead, layout) => {
346
+ const title = el('div', { class: 'header-title' },
347
+ el('p', { class: 'eyebrow' }, eyebrow), el('h2', { class: 'h2' }, heading));
348
+ return el('div', { class: 'header ' + (layout || (lead ? 'split' : '')) },
349
+ title, lead ? el('p', { class: 'body-2' }, lead) : null);
350
+ };
351
+
352
+ const statusLabels = { primary: 'Primary', mentioned: 'Mentioned', absent: 'Absent', no_overview: 'No AI Overview' };
353
+ const retrievalLabels = { searched: 'searched the web', memory: 'answered from memory', unknown: 'retrieval unknown' };
354
+
355
+ const runCard = (run, brandName) => el('article', { class: 'run' },
356
+ el('div', { class: 'run-head' },
357
+ el('div', {}, el('p', { class: 'run-title' }, 'Run ' + run.runNumber),
358
+ el('p', { class: 'run-surface' }, run.surface + (run.cliVersion ? ' · ' + run.cliVersion : ''))),
359
+ el('div', { class: 'pills' },
360
+ run.retrieval ? el('span', { class: 'pill mono' + (run.retrieval === 'unknown' ? ' dashed' : '') },
361
+ retrievalLabels[run.retrieval]) : null,
362
+ el('span', { class: 'pill ' + (run.status === 'no_overview' ? 'dashed' : run.status) }, statusLabels[run.status]))),
363
+ run.snippet ? el('div', { class: 'snippet' }, el('p', { class: 'label' }, 'Detected mention'),
364
+ el('p', { class: 'answer' }, ...highlighted(run.snippet, brandName))) : null,
365
+ run.answer ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'Full captured answer'),
366
+ el('p', { class: 'answer' }, ...highlighted(run.answer, brandName)))
367
+ : el('p', { class: 'empty run-block' }, run.status === 'no_overview'
368
+ ? 'The results page showed no AI Overview: there is no answer to show.'
369
+ : 'No captured answer in this bundle matches this run.'),
370
+ run.mentionedBrands.length ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'Mentioned companies'),
371
+ el('ul', { class: 'pills' }, run.mentionedBrands.map((brand) => el('li', {}, el('span', { class: 'pill plain' }, brand))))) : null,
372
+ run.citedUrls.length ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'URLs in response'),
373
+ el('ul', { class: 'links' }, run.citedUrls.map((url) => el('li', {}, sourceLink(url))))) : null,
374
+ );
375
+
376
+ const scorecards = (cards) => el('div', { class: 'scorecards' },
377
+ el('div', { class: cards.length >= 5 ? 'scorecards-grid five' : 'scorecards-grid' },
378
+ cards.map((card) => el('div', { class: 'stat' },
379
+ el('p', { class: 'stat-figure' }, card.headline),
380
+ intervalOf(card.headlineInterval),
381
+ el('p', { class: 'stat-label' }, card.label),
382
+ card.detail ? el('p', { class: 'stat-detail' }, card.detail) : null,
383
+ intervalOf(card.detailInterval)))));
384
+
385
+ const surfaceRates = (rows) => rows.length === 0 ? null : el('section', { class: 'subsection', 'aria-label': 'Rates by AI surface' },
386
+ el('p', { class: 'h5' }, 'By AI surface'),
387
+ el('div', { class: 'scroll' }, el('table', { class: 'by-model' },
388
+ el('thead', {}, el('tr', {}, el('th', {}, 'AI surface'), el('th', {}, 'Share of voice'), el('th', {}, 'Citation rate'))),
389
+ el('tbody', {}, rows.map((row) => el('tr', {},
390
+ el('td', {}, row.surface),
391
+ el('td', {}, el('span', { class: 'rate' }, row.shareOfVoice.percent), intervalOf(row.shareOfVoice.interval)),
392
+ el('td', {}, el('span', { class: 'rate' }, row.citationRate.percent), intervalOf(row.citationRate.interval))))))));
393
+
394
+ const dot = (status) => el('span', { class: 'dot ' + status, role: 'img',
395
+ 'aria-label': { primary: 'Primary mention', mentioned: 'Secondary mention', absent: 'Not mentioned', no_data: 'No data' }[status] });
396
+
397
+ const matrix = (section, brandName, sheet) => {
398
+ const { assistantSurfaces, agentSurfaces, rows } = section.matrix;
399
+ const surfaces = [...assistantSurfaces, ...agentSurfaces];
400
+ const firstAgent = assistantSurfaces.length;
401
+ const edge = (index, base) => base + (agentSurfaces.length && index === firstAgent ? ' agents-start' : '');
402
+ const groups = agentSurfaces.length === 0 ? null : el('tr', {},
403
+ el('td', { class: 'prompt group', 'aria-hidden': 'true' }),
404
+ assistantSurfaces.length ? el('th', { class: 'group', colspan: String(assistantSurfaces.length), scope: 'colgroup' }, 'AI assistants') : null,
405
+ el('th', { class: 'group agents-start', colspan: String(agentSurfaces.length), scope: 'colgroup' }, 'Coding agents'));
406
+ const body = rows.map((row, promptIdx) => el('tr', {},
407
+ el('td', { class: 'prompt', title: row.prompt },
408
+ el('span', { class: 'prompt-text' }, row.prompt), el('span', { class: 'prompt-category' }, row.category)),
409
+ row.cells.map((cell, index) => el('td', { class: edge(index, '') },
410
+ cell.status === 'no_data' ? dot('no_data') : (() => {
411
+ const button = el('button', { type: 'button', class: 'cell',
412
+ 'aria-label': surfaces[index] + ', prompt ' + (promptIdx + 1) + ': ' + cell.status + '. Inspect evidence.',
413
+ onclick: () => sheet.open(button, surfaces[index] + ' evidence',
414
+ 'Prompt ' + (promptIdx + 1) + ' · ' + cell.mentioned + '/' + cell.runs.length + ' runs mentioned ' + brandName,
415
+ [el('section', { class: 'prompt-box' }, el('h3', { class: 'label' }, 'Prompt'), el('p', {}, row.prompt),
416
+ el('p', { class: 'prompt-category' }, row.category)),
417
+ ...cell.runs.map((run) => runCard(run, brandName))]),
418
+ }, dot(cell.status), el('span', { class: 'cell-count' }, cell.mentioned + '/' + cell.runs.length));
419
+ return button;
420
+ })()))));
421
+ return el('div', { class: 'card matrix-card' },
422
+ el('div', { class: 'scroll', role: 'group', 'aria-label': 'AI answer evidence matrix', tabindex: '0' },
423
+ el('table', { class: 'matrix' },
424
+ el('thead', {}, groups, el('tr', {}, el('th', { class: 'prompt-head' }, 'Prompt'),
425
+ surfaces.map((surface, index) => el('th', { class: edge(index, '') }, surface)))),
426
+ el('tbody', {}, body))),
427
+ el('ul', { class: 'legend' },
428
+ [['primary', 'Primary recommendation'], ['mentioned', 'Mentioned secondarily'], ['absent', 'Not mentioned'], ['no_data', 'No data']]
429
+ .map(([status, text]) => el('li', {}, el('span', { class: 'dot ' + status }), text))),
430
+ el('p', { class: 'hint' }, 'Click any dot with a run count to inspect the captured AI answers, cited URLs, and highlighted mentions behind that result.'));
151
431
  };
152
- const rateStat = (label, rate, recorded, counted) =>
153
- el('div', { class: 'stat' }, ...rateFigure(rate, recorded, label.toLowerCase(), counted), label);
154
- // Every surface that ran, each with its own pair of rates.
155
- const modelTable = (byModel, labelOf) => {
156
- const rows = Object.entries(byModel && typeof byModel === 'object' ? byModel : {})
157
- .map(([surface, rates]) => {
158
- const { shareOfVoice, citationRate, shareOfVoiceEvidence, citationRateEvidence } = rates || {};
159
- const model = labelOf(surface);
160
- return el('tr', {},
161
- el('td', {}, model),
162
- el('td', {}, ...rateFigure(shareOfVoice, shareOfVoiceEvidence, model + ' share of voice', 'Mentioned')),
163
- el('td', {}, ...rateFigure(citationRate, citationRateEvidence, model + ' citation rate', 'Cited')),
164
- );
165
- });
166
- if (!rows.length) return [];
167
- return [el('h3', {}, 'By model'), el('table', { class: 'by-model' },
168
- el('thead', {}, el('tr', {}, el('th', {}, 'Model'), el('th', {}, 'Share of voice'),
169
- el('th', {}, 'Citation rate'))),
170
- el('tbody', {}, ...rows))];
432
+
433
+ const alternatives = (rows) => rows.length === 0 ? null : el('div', { class: 'card' },
434
+ el('h3', { class: 'card-title' }, 'Who buyers hear about instead'),
435
+ el('p', { class: 'card-lead' }, 'Competing companies and products named in the answers, ranked by share of voice (answers that mention them / answers captured).'),
436
+ el('ul', { class: 'bars' }, rows.map((row) => {
437
+ const fill = el('span', { class: 'bar-fill' });
438
+ // CSSOM, which the page's Content Security Policy allows, unlike a style attribute.
439
+ if (fill.style) fill.style.width = (row.share * 100) + '%';
440
+ return el('li', {},
441
+ el('span', { class: 'bar-name', title: row.domain || row.name }, row.name,
442
+ row.domain && row.domain.toLowerCase() !== row.name.trim().toLowerCase() ? el('span', { class: 'bar-domain' }, row.domain) : null),
443
+ el('span', { class: 'bar' }, fill),
444
+ el('span', { class: 'bar-value' }, row.percent + ' ' + row.mentioning + '/' + row.captured));
445
+ })));
446
+
447
+ const citedDomains = (domains, sheet) => {
448
+ const total = domains.reduce((sum, domain) => sum + domain.count, 0);
449
+ const shown = 10;
450
+ const body = el('tbody');
451
+ const more = el('button', { type: 'button', class: 'more' });
452
+ let showAll = false;
453
+ const rowOf = (domain) => {
454
+ const inspect = (from) => sheet.open(from, domain.domain, plural(domain.count, 'citation') + ' across the captured answers',
455
+ [el('ul', { class: 'links' }, domain.urls.map((url) => el('li', {}, sourceLink(url.url),
456
+ el('p', { class: 'source-meta' }, plural(url.count, 'citation') + ' · ' + url.surfaces.join(', ')),
457
+ ...url.prompts.map((prompt) => el('p', { class: 'source-meta' }, prompt)))))]);
458
+ const name = el('span', { class: domain.isBrand ? 'rate' : '' }, domain.domain);
459
+ const hosts = domain.hosts ? el('span', { class: 'hosts' }, domain.hosts.map((host) => host.label + ' ' + host.count).join(' · ')) : null;
460
+ if (domain.count === 0) return el('tr', {}, el('td', {}, name, hosts), el('td', { class: 'num' }, '0'));
461
+ const button = el('button', { type: 'button', class: 'row-button',
462
+ 'aria-label': 'Inspect the ' + domain.count + ' cited URLs behind ' + domain.domain,
463
+ onclick: (event) => { event.stopPropagation?.(); inspect(button); } }, name, hosts);
464
+ return el('tr', { class: 'selectable', onclick: () => inspect(button) },
465
+ el('td', {}, button), el('td', { class: 'num' }, String(domain.count)));
466
+ };
467
+ const sync = () => {
468
+ body.replaceChildren(...(showAll ? domains : domains.slice(0, shown)).map(rowOf));
469
+ const hidden = domains.length - shown;
470
+ more.replaceChildren(showAll ? 'Show fewer domains' : '+' + plural(hidden, 'more domain'));
471
+ if (hidden > 0) more.removeAttribute('hidden'); else more.setAttribute('hidden', '');
472
+ };
473
+ more.addEventListener('click', () => { showAll = !showAll; sync(); });
474
+ sync();
475
+ return el('div', { class: 'card' },
476
+ el('h3', { class: 'card-title' }, 'What gets cited'),
477
+ el('p', { class: 'card-lead' }, 'Domains behind the URLs cited in these answers'
478
+ + (total > 0 ? ' (' + total + ' citations captured). Click a domain to inspect the URLs behind it.' : '.')),
479
+ el('div', { class: 'scroll' }, el('table', {},
480
+ el('thead', {}, el('tr', {}, el('th', {}, 'Domain'), el('th', { class: 'num' }, 'Citations'))), body)),
481
+ more);
171
482
  };
172
- const answerKey = (section, promptId, surface, runIndex) =>
173
- section + '|' + promptId + '|' + surface + '|' + runIndex;
174
483
 
175
- const sourceLink = (url) => {
176
- // External sources open only on a deliberate click, in a new context.
177
- const button = el('button', { class: 'link', type: 'button' }, url);
178
- button.addEventListener('click', () => {
179
- if (/^https?:\\/\\//.test(url)) window.open(url, '_blank', 'noopener,noreferrer');
180
- });
181
- return button;
484
+ const sourceCategories = [['owned', 'Owned'], ['competitor', 'Competitor'], ['social', 'Social & community'],
485
+ ['institutional', 'Institutional'], ['earned', 'Earned']];
486
+
487
+ const sourceMix = (mix) => !mix || mix.rows.length === 0 ? null : el('div', { class: 'card' },
488
+ el('h3', { class: 'card-title' }, 'Where the citations come from'),
489
+ el('p', { class: 'card-lead' }, 'Every cited URL classified: the brand’s own pages, competitor pages, social and community threads, institutional references, or earned media. Each surface leans differently.'),
490
+ el('div', { class: 'scroll', role: 'group', 'aria-label': 'Citation sources by AI surface', tabindex: '0' },
491
+ el('table', {},
492
+ el('thead', {}, el('tr', {}, el('th', {}, 'Surface'), sourceCategories.map(([, label]) => el('th', { class: 'num' }, label)))),
493
+ el('tbody', {},
494
+ mix.rows.map((row) => el('tr', {}, el('td', { class: 'rate' }, row.surface),
495
+ sourceCategories.map(([key]) => el('td', { class: 'num' }, row.counts[key] ? String(row.counts[key]) : '—')))),
496
+ el('tr', { class: 'total' }, el('td', {}, 'All surfaces'),
497
+ sourceCategories.map(([key]) => el('td', { class: 'num' }, mix.total[key] ? String(mix.total[key]) : '—')))))));
498
+
499
+ const perception = (view, brandName) => {
500
+ if (!view) return null;
501
+ const mentions = view.positive + view.neutral + view.negative;
502
+ if (mentions === 0 && view.phrases.length === 0) return null;
503
+ return el('div', { class: 'card' },
504
+ el('h3', { class: 'card-title' }, 'How the answers talk about ' + brandName),
505
+ mentions > 0 ? el('p', { class: 'card-lead' }, 'Across ' + mentions + ' answers that mention ' + brandName + ': '
506
+ + view.positive + ' positive, ' + view.neutral + ' neutral, ' + view.negative + ' negative.') : null,
507
+ view.phrases.length ? el('div', { class: 'run-block' },
508
+ el('p', { class: 'label' }, 'Phrases the answers attach to ' + brandName),
509
+ el('ul', { class: 'pills' }, view.phrases.map((phrase) => el('li', {},
510
+ el('span', { class: 'pill', title: 'Said by ' + phrase.surfaces.join(', ') },
511
+ el('span', {}, '“' + phrase.text + '”'),
512
+ phrase.count > 1 ? el('span', { class: 'pill-count' }, '×' + phrase.count) : null))))) : null);
182
513
  };
183
514
 
515
+ const verification = (result) => el('div', { class: 'card' },
516
+ el('h3', { class: 'card-title' }, 'Checks'),
517
+ el('p', { class: 'card-lead' }, 'Capture authenticity: self-reported. Checks run on this machine, offline.'),
518
+ el('div', { class: 'scroll' }, el('table', { class: 'verification' },
519
+ el('thead', {}, el('tr', {}, el('th', {}, 'Check'), el('th', {}, 'Outcome'), el('th', {}, 'Why'))),
520
+ el('tbody', {}, result.checks.map((check) => el('tr', {},
521
+ el('td', {}, check.title),
522
+ el('td', {}, el('span', { class: 'pill ' + (check.outcome === 'pass' ? 'pass' : check.outcome === 'fail' ? 'fail' : 'dashed') },
523
+ check.outcome.replace('_', ' '))),
524
+ el('td', { class: 'muted' }, check.outcome === 'pass' ? '' : check.explanation)))))));
525
+
526
+ const hero = (report, info) => el('section', { class: 'hero' }, el('div', { class: 'container' },
527
+ el('div', { class: 'hero-grid' },
528
+ el('div', { class: 'hero-copy' },
529
+ el('p', { class: 'eyebrow' }, 'AI visibility audit'),
530
+ el('h1', { class: 'h1' }, report.hero.title),
531
+ el('p', { class: 'body-1' }, report.hero.subtitle),
532
+ el('p', { class: 'measured' }, 'Measured ' + report.hero.measuredOn + ' · ' + info.originLabel)),
533
+ el('div', { class: 'measurement' },
534
+ el('p', { class: 'eyebrow' }, 'The measurement'),
535
+ el('p', { class: 'measurement-figure' }, String(report.hero.probeCount)),
536
+ el('p', { class: 'h5' }, 'captured AI answers'),
537
+ el('ul', { class: 'facts' }, report.hero.facts.map((fact) => el('li', {}, fact)))))));
538
+
539
+ const plainHero = (info) => el('section', { class: 'hero' }, el('div', { class: 'container' },
540
+ el('div', { class: 'hero-grid' }, el('div', { class: 'hero-copy' },
541
+ el('p', { class: 'eyebrow' }, 'Literally.dev AEO'),
542
+ el('h1', { class: 'h1' }, 'AI visibility audit'),
543
+ el('p', { class: 'measured' }, info.originLabel)))));
544
+
184
545
  const render = async () => {
185
546
  const root = document.getElementById('app');
186
- const [info, verification, snapshot, captures, config] = await Promise.all([
187
- get('__viewer'), get('__verification'), get('report/snapshot.json'),
188
- get('captures/units.json'), get('inputs/config.json'),
189
- ]);
547
+ const [info, result, report] = await Promise.all([get('__viewer'), get('__verification'), get('__report')]);
190
548
  root.replaceChildren();
191
- if (!info) {
192
- root.append(el('p', {}, 'This viewer link is not valid. Start it again with literally-aeo view.'));
549
+ if (!info || !report) {
550
+ root.append(el('p', { class: 'container' }, 'This viewer link is not valid. Start it again with literally-aeo view.'));
193
551
  return;
194
552
  }
195
- const brand = (snapshot && snapshot.brand && snapshot.brand.name)
196
- || (config && config.brand && config.brand.name) || 'Audit';
197
- root.append(
198
- el('h1', {}, brand + ': AI visibility audit'),
199
- el('p', { class: 'muted' }, info.originLabel + ' · ' + info.source),
200
- );
553
+ const sheet = createSheet();
554
+ const shown = report.outcome === 'shown';
201
555
  if (info.workingState) {
202
- root.append(el('div', { class: 'banner warn' },
556
+ root.append(el('div', { class: 'banner' },
203
557
  'Working state, not a finalized revision: this is not an integrity receipt. Export the run to finalize it.'));
204
558
  }
205
- if (verification) {
206
- const rows = verification.checks.map((check) => el('tr', {},
207
- el('td', {}, check.title),
208
- el('td', { class: check.outcome === 'pass' ? 'pass' : check.outcome === 'fail' ? 'fail' : 'limited' },
209
- check.outcome.replace('_', ' ')),
210
- el('td', { class: 'muted' }, check.outcome === 'pass' ? '' : check.explanation),
211
- ));
212
- root.append(el('h2', {}, 'Verification'),
213
- el('p', { class: 'muted' }, 'Capture authenticity: self-reported. Checks run on this machine, offline.'),
214
- el('div', { class: 'table-wrap' }, el('table', {}, el('tbody', {}, ...rows))));
215
- }
216
- if (!snapshot) {
217
- root.append(el('div', { class: 'banner' }, 'This run has no report yet: the measurement did not finish.'));
218
- return;
219
- }
220
- const answers = new Map();
221
- for (const record of captures || []) {
222
- answers.set(answerKey(record.sectionKey, record.promptId, record.surface, record.runIndex), record);
559
+ root.append(shown ? hero(report, info) : plainHero(info));
560
+ const bands = [];
561
+ if (shown && report.intro) {
562
+ bands.push([sectionHeader('AI search visibility', report.intro.heading, report.intro.lead, 'center')]);
223
563
  }
224
- // The snapshot names prompts by text; their ids, which key the captured
225
- // answers, come from the frozen configuration in the same order.
226
- const promptIds = new Map();
227
- for (const configured of (config && config.sections) || []) {
228
- promptIds.set(configured.key, configured.prompts.map((prompt) => prompt.id));
229
- }
230
-
231
- // A surface asked of another model than its default, and every custom
232
- // surface, carries its own label in the snapshot; any other is shown by
233
- // its ID. Like every string of a bundle, a label is inserted as text.
234
- const labels = (snapshot.meta && snapshot.meta.surfaceLabels) || {};
235
- const labelOf = (surface) =>
236
- typeof labels[surface] === 'string' && labels[surface] ? labels[surface] : surface;
237
-
238
- for (const section of snapshot.sections) {
239
- const { summary, matrix, prompts } = section.visibility;
240
- root.append(el('h2', {}, 'Section ' + section.key));
241
- root.append(el('div', { class: 'grid' },
242
- rateStat('Assistant share of voice', summary.prospectShareOfVoice,
243
- summary.prospectShareOfVoiceEvidence, 'Mentioned'),
244
- rateStat('Assistant citation rate', summary.prospectCitationRate,
245
- summary.prospectCitationRateEvidence, 'Cited'),
246
- rateStat('Coding-agent share of voice', summary.agentShareOfVoice,
247
- summary.agentShareOfVoiceEvidence, 'Mentioned'),
248
- rateStat('Coding-agent citation rate', summary.agentCitationRate,
249
- summary.agentCitationRateEvidence, 'Cited'),
250
- // The scraped consumer apps, only for a run that planned one.
251
- ...(summary.consumerShareOfVoice === undefined ? [] : [
252
- rateStat('Consumer-app share of voice', summary.consumerShareOfVoice,
253
- summary.consumerShareOfVoiceEvidence, 'Mentioned'),
254
- rateStat('Consumer-app citation rate', summary.consumerCitationRate,
255
- summary.consumerCitationRateEvidence, 'Cited'),
256
- ]),
257
- el('div', { class: 'stat' }, el('b', {}, summary.topCompetitorDomain || 'none'), 'Most mentioned competitor'),
258
- ));
259
- root.append(el('p', { class: 'muted' },
260
- 'Share of voice is how often the measured answers name the product, not market share.'));
261
- root.append(...modelTable(summary.byModel, labelOf));
262
- const drawer = el('div', { class: 'drawer', hidden: '' });
263
- const body = el('tbody');
264
- for (const row of matrix) {
265
- const prompt = prompts[row.promptIdx] || { text: '' };
266
- const promptId = (promptIds.get(section.key) || [])[row.promptIdx];
267
- const record = answers.get(answerKey(section.key, promptId, row.surface, row.runIndex || 0));
268
- const open = () => {
269
- drawer.removeAttribute('hidden');
270
- drawer.replaceChildren(
271
- el('h3', {}, labelOf(row.surface) + ', run ' + (row.runIndex || 0)),
272
- el('p', {}, prompt.text),
273
- record ? el('pre', {}, record.probe.text)
274
- : el('p', { class: 'limited' }, 'The answer is not in this bundle.'),
275
- ...(row.citedUrls && row.citedUrls.length
276
- ? [el('h3', {}, 'Cited sources'), ...row.citedUrls.map((url) => el('div', {}, sourceLink(url)))]
277
- : []),
278
- );
279
- drawer.scrollIntoView({ block: 'nearest' });
280
- };
281
- body.append(el('tr', { class: 'row', tabindex: '0', onclick: open,
282
- onkeydown: (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); open(); } } },
283
- el('td', {}, prompt.text),
284
- el('td', {}, labelOf(row.surface)),
285
- el('td', {}, String(row.runIndex || 0)),
286
- el('td', {}, row.prospectMentioned ? 'mentioned' + (row.prospectPosition ? ' (' + row.prospectPosition + ')' : '') : 'not mentioned'),
287
- el('td', {}, (row.qualifiedCompetitors || []).map((entry) => entry.name).join(', ')),
288
- ));
289
- }
290
- root.append(el('div', { class: 'table-wrap' }, el('table', {},
291
- el('thead', {}, el('tr', {}, el('th', {}, 'Question'), el('th', {}, 'Surface'),
292
- el('th', {}, 'Run'), el('th', {}, 'Product'), el('th', {}, 'Alternatives named'))),
293
- body)), drawer);
564
+ if (result || !shown) {
565
+ // A working state is not verified: no claim that it was.
566
+ bands.push([sectionHeader('Evidence', 'Verification', result
567
+ ? 'The bundle re-checked on this machine: its hashes, its event chain and every metric recomputed from its own judgments. A check that cannot run says so.'
568
+ : undefined),
569
+ result ? verification(result) : null,
570
+ shown ? null : el('p', { class: 'card empty' }, report.outcome === 'missing'
571
+ ? 'This run has no report yet: the measurement did not finish.'
572
+ : 'The report cannot be shown: ' + report.reason)]);
294
573
  }
295
- const methodology = snapshot.meta && Array.isArray(snapshot.meta.methodology)
296
- ? snapshot.meta.methodology.filter((sentence) => typeof sentence === 'string')
297
- : [];
298
- if (methodology.length) {
299
- root.append(el('h2', {}, 'Methodology'),
300
- el('ul', { class: 'methodology' },
301
- ...methodology.map((sentence) => el('li', {}, sentence))));
574
+ for (const section of shown ? report.sections : []) {
575
+ bands.push([
576
+ sectionHeader('AI search visibility', section.title),
577
+ scorecards(section.scorecards),
578
+ surfaceRates(section.surfaceRates),
579
+ matrix(section, report.brand.name, sheet),
580
+ alternatives(section.alternatives),
581
+ citedDomains(section.citedDomains, sheet),
582
+ sourceMix(section.sourceMix),
583
+ perception(section.perception, report.brand.name),
584
+ ]);
302
585
  }
303
- root.append(el('footer', {},
304
- 'Generated with Literally.dev AEO, an open-source AI visibility audit tool. ',
305
- info.originLabel + '. Literally.dev did not review this result. Engine ' + info.toolVersion + '.'));
586
+ bands.push([el('div', { class: 'footer' },
587
+ shown ? el('p', {}, report.footer.baseline) : null,
588
+ shown && report.footer.methodology.length ? el('section', { 'aria-labelledby': 'methodology' },
589
+ el('h2', { id: 'methodology' }, 'Methodology'),
590
+ el('ul', { class: 'methodology' }, report.footer.methodology.map((sentence) => el('li', {}, sentence)))) : null,
591
+ ...(shown ? report.footer.notes : []).map((note) => el('p', {}, note)),
592
+ el('p', { class: 'footer-note' },
593
+ 'Generated with Literally.dev AEO ' + info.toolVersion + ', an open-source AI visibility audit tool. '
594
+ + info.originLabel + '. Literally.dev did not review this result. Bundle: ' + info.source + '.'))]);
595
+ bands.forEach((content, index) => root.append(band(index % 2 === 1 ? 'soft' : 'plain', ...content)));
596
+ root.append(...sheet.nodes);
306
597
  };
307
598
 
308
599
  render().catch((error) => {
@@ -310,8 +601,30 @@ render().catch((error) => {
310
601
  });
311
602
  `;
312
603
 
313
- /** viewerPage is the document served at /, bound to one launch's nonce. */
314
- export const viewerPage = (nonce: string): string => {
604
+ /** The hosted report's two typefaces, shipped unmodified under the SIL Open
605
+ * Font License (src/viewer/fonts) and served by the viewer itself. */
606
+ export const viewerFontFiles = {
607
+ body: 'Mulish-VariableFont_wght.ttf',
608
+ mono: 'SourceCodePro-VariableFont_wght.ttf',
609
+ } as const;
610
+
611
+ const fontFaces = (token: string): string => {
612
+ const source = (file: string) =>
613
+ `url("/fonts/${file}?t=${encodeURIComponent(token)}") format("truetype")`;
614
+
615
+ return `
616
+ @font-face { font-family: Mulish; font-weight: 200 1000; font-display: swap;
617
+ src: ${source(viewerFontFiles.body)}; }
618
+ @font-face { font-family: "Source Code Pro"; font-weight: 200 900; font-display: swap;
619
+ src: ${source(viewerFontFiles.mono)}; }
620
+ `;
621
+ };
622
+
623
+ /** viewerPage is the document served at /, bound to one launch's nonce. The
624
+ * launch token, when the viewer serves fonts, is what their URLs carry. */
625
+ export const viewerPage = (nonce: string, fontToken?: string): string => {
626
+ const faces = fontToken === undefined ? '' : fontFaces(fontToken);
627
+
315
628
  return `<!doctype html>
316
629
  <html lang="en">
317
630
  <head>
@@ -319,10 +632,10 @@ export const viewerPage = (nonce: string): string => {
319
632
  <meta name="viewport" content="width=device-width, initial-scale=1">
320
633
  <meta name="referrer" content="no-referrer">
321
634
  <title>Literally.dev AEO</title>
322
- <style nonce="${nonce}">${styles}</style>
635
+ <style nonce="${nonce}">${faces}${styles}</style>
323
636
  </head>
324
637
  <body>
325
- <main id="app"><p class="muted">Loading the audit…</p></main>
638
+ <main id="app"><p class="container">Loading the audit…</p></main>
326
639
  <script nonce="${nonce}">${script}</script>
327
640
  </body>
328
641
  </html>`;