literally-aeo 0.4.2 → 0.4.4
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/README.md +21 -1
- package/dist/cli.mjs +1528 -551
- package/dist/lib/agents/methodology.js +9 -9
- package/dist/lib/bundle/contracts.js +1 -1
- package/dist/lib/bundle/export.js +18 -18
- package/dist/lib/bundle/journal.js +2 -2
- package/dist/lib/bundle/project-journal.js +5 -5
- package/dist/lib/bundle/project.js +16 -16
- package/dist/lib/bundle/read.js +19 -19
- package/dist/lib/bundle/recorder.js +3 -3
- package/dist/lib/bundle/redact.js +2 -2
- package/dist/lib/bundle/trace-coverage.js +2 -2
- package/dist/lib/bundle/verify-integrity.js +4 -4
- package/dist/lib/bundle/verify-measurement.js +2 -2
- package/dist/lib/bundle/verify-report.js +3 -3
- package/dist/lib/bundle/verify.js +8 -8
- package/dist/lib/checks/run-checks.js +4 -4
- package/dist/lib/chunks/{chunk-U4AROC2Z.js → chunk-22QIMTQJ.js} +1 -1
- package/dist/lib/chunks/{chunk-KFYTORIT.js → chunk-2IZ2LTBQ.js} +4 -4
- package/dist/lib/chunks/{chunk-22SP35NA.js → chunk-2S2NKIK2.js} +1 -1
- package/dist/lib/chunks/{chunk-3USKGGFT.js → chunk-2WBJER62.js} +15 -5
- package/dist/lib/chunks/{chunk-DU3MAXVC.js → chunk-3RSF2PY4.js} +6 -1
- package/dist/lib/chunks/{chunk-ITLJZUKL.js → chunk-4M6CQKSH.js} +1 -1
- package/dist/lib/chunks/{chunk-RR63UE5H.js → chunk-4SPKLFJK.js} +4 -4
- package/dist/lib/chunks/{chunk-5EM6J7TG.js → chunk-4VURIRL7.js} +2 -2
- package/dist/lib/chunks/{chunk-T4Z3GAEH.js → chunk-5EE3IOLY.js} +1 -1
- package/dist/lib/chunks/{chunk-ATKP5ZW6.js → chunk-5YXU5WAK.js} +1 -1
- package/dist/lib/chunks/{chunk-RWVXK7XE.js → chunk-6OV2GIKK.js} +5 -5
- package/dist/lib/chunks/{chunk-XT5M3PPQ.js → chunk-6ZZ4MHYW.js} +3 -3
- package/dist/lib/chunks/{chunk-T5Q5CBTA.js → chunk-AC5YND5N.js} +1 -1
- package/dist/lib/chunks/{chunk-NZOKSFIA.js → chunk-ALORJCG4.js} +3 -3
- package/dist/lib/chunks/{chunk-OF3WIGG7.js → chunk-AQVARUFR.js} +6 -6
- package/dist/lib/chunks/{chunk-BKAERR7J.js → chunk-AR2LGUP4.js} +2 -2
- package/dist/lib/chunks/{chunk-EZ23TKTX.js → chunk-ATYDD4EM.js} +2 -2
- package/dist/lib/chunks/{chunk-ENPRRXH5.js → chunk-BC53CVOM.js} +1 -1
- package/dist/lib/chunks/chunk-BWBPEXEU.js +83 -0
- package/dist/lib/chunks/chunk-C34NR35E.js +472 -0
- package/dist/lib/chunks/{chunk-32LZRJ3P.js → chunk-CYTHCMYY.js} +2 -2
- package/dist/lib/chunks/{chunk-WIRVKAYB.js → chunk-DH7D4KNR.js} +12 -12
- package/dist/lib/chunks/{chunk-QJX6YXXQ.js → chunk-DOV622W3.js} +3 -3
- package/dist/lib/chunks/{chunk-DI4LZR37.js → chunk-EI6P2B4R.js} +3 -3
- package/dist/lib/chunks/{chunk-CRXJFOCK.js → chunk-FX4Y7GVR.js} +4 -4
- package/dist/lib/chunks/{chunk-R2HFGAOO.js → chunk-GKLCM5K2.js} +2 -2
- package/dist/lib/chunks/{chunk-BWI4M36B.js → chunk-GTQORFWR.js} +4 -4
- package/dist/lib/chunks/{chunk-HJEIEMPE.js → chunk-GV47I7MF.js} +4 -4
- package/dist/lib/chunks/{chunk-M4XGUJMO.js → chunk-GVDOWLYF.js} +1 -1
- package/dist/lib/chunks/{chunk-JGBJQ3TO.js → chunk-GZRG3QSS.js} +1 -1
- package/dist/lib/chunks/{chunk-JKBXKACC.js → chunk-J66AN3MF.js} +7 -7
- package/dist/lib/chunks/{chunk-YRXYTCMY.js → chunk-JHUI2K5X.js} +1 -1
- package/dist/lib/chunks/{chunk-3DVFQMJT.js → chunk-JMWS4PZR.js} +8 -3
- package/dist/lib/chunks/chunk-JQFLWUCA.js +123 -0
- package/dist/lib/chunks/{chunk-FXCUGNFL.js → chunk-JXQOWHWB.js} +1 -1
- package/dist/lib/chunks/{chunk-STNUFF7H.js → chunk-K6MHEUSS.js} +2 -2
- package/dist/lib/chunks/{chunk-CMB2KSW2.js → chunk-KNX75J6T.js} +16 -7
- package/dist/lib/chunks/{chunk-6P7EZJI7.js → chunk-KSJ3NZIJ.js} +4 -2
- package/dist/lib/chunks/{chunk-FBMO6UV4.js → chunk-L5FM3KGF.js} +1 -1
- package/dist/lib/chunks/{chunk-7QYZSP7Q.js → chunk-LQIBRJWR.js} +4 -0
- package/dist/lib/chunks/{chunk-A2RW4ZMR.js → chunk-MI4GIMHK.js} +1 -1
- package/dist/lib/chunks/{chunk-YPGJN232.js → chunk-MKA2EP7M.js} +1 -1
- package/dist/lib/chunks/{chunk-NWABYXDQ.js → chunk-NAFSRHVZ.js} +2 -2
- package/dist/lib/chunks/{chunk-JN4332MJ.js → chunk-OSELZPPA.js} +1 -1
- package/dist/lib/chunks/{chunk-TD47AB37.js → chunk-OXNS5JNZ.js} +2 -2
- package/dist/lib/chunks/{chunk-KC35BXW7.js → chunk-R5VAHYBF.js} +1 -1
- package/dist/lib/chunks/{chunk-Q6TZB2OQ.js → chunk-RF2V6XQ3.js} +1 -1
- package/dist/lib/chunks/{chunk-AMK6IHJD.js → chunk-SVVA7MIE.js} +1 -1
- package/dist/lib/chunks/{chunk-RYV25YGT.js → chunk-V4VBRJEK.js} +1 -1
- package/dist/lib/chunks/chunk-VFN2J4Z3.js +626 -0
- package/dist/lib/chunks/{chunk-AMF3T5A3.js → chunk-WQXXNDBO.js} +1 -1
- package/dist/lib/chunks/{chunk-VOK4TUXV.js → chunk-WZ5A77WN.js} +1 -1
- package/dist/lib/chunks/{chunk-DKR7LSP2.js → chunk-YGW3HTTH.js} +1 -1
- package/dist/lib/chunks/{chunk-FFDMGNRO.js → chunk-YHHWIOO5.js} +6 -6
- package/dist/lib/cli/bundle-commands.js +64 -39
- package/dist/lib/cli/guide-command.js +1 -1
- package/dist/lib/cli/run-commands.js +43 -43
- package/dist/lib/cli/status-command.js +25 -25
- package/dist/lib/codex-workflow/aggregate.js +2 -2
- package/dist/lib/codex-workflow/author.js +3 -3
- package/dist/lib/codex-workflow/capture.js +12 -12
- package/dist/lib/codex-workflow/copy-editor.js +3 -3
- package/dist/lib/codex-workflow/copy.js +2 -2
- package/dist/lib/codex-workflow/finish.js +11 -11
- package/dist/lib/codex-workflow/loop.js +19 -19
- package/dist/lib/codex-workflow/run-source.js +5 -5
- package/dist/lib/codex-workflow/stage.js +5 -5
- package/dist/lib/engine/audit-file.js +9 -9
- package/dist/lib/engine/author.js +16 -16
- package/dist/lib/engine/cost-estimate.js +9 -9
- package/dist/lib/engine/local-run.js +24 -24
- package/dist/lib/engine/preflight.js +10 -10
- package/dist/lib/engine/rejudge.js +31 -31
- package/dist/lib/engine/resources.js +1 -1
- package/dist/lib/engine/run-bindings.js +9 -9
- package/dist/lib/engine/run-method.js +2 -2
- package/dist/lib/engine/run-models.js +4 -4
- package/dist/lib/engine/run-status.js +25 -25
- package/dist/lib/engine/templates.js +10 -10
- package/dist/lib/grounding/grounding-runtime.js +5 -5
- package/dist/lib/grounding/recorded-tools.js +4 -4
- package/dist/lib/pipeline.js +11 -11
- package/dist/lib/probes/adapters/cli-agents.js +6 -6
- package/dist/lib/probes/adapters/cli-claude-code.js +3 -3
- package/dist/lib/probes/adapters/cli-codex.js +3 -3
- package/dist/lib/probes/adapters/cli-cursor.js +3 -3
- package/dist/lib/probes/adapters/cli-process.js +2 -2
- package/dist/lib/probes/agent-clis.js +7 -7
- package/dist/lib/probes/bindings.js +8 -8
- package/dist/lib/probes/charged-trace.js +9 -9
- package/dist/lib/probes/child-process.js +1 -1
- package/dist/lib/probes/probes.js +9 -9
- package/dist/lib/viewer/alternatives.js +8 -0
- package/dist/lib/viewer/cited-domains.js +8 -0
- package/dist/lib/viewer/page.js +3 -1
- package/dist/lib/viewer/presentation.js +41 -0
- package/dist/lib/viewer/server.js +15 -10
- package/dist/types/bundle/contracts.d.ts +1 -1
- package/dist/types/engine/resources.d.ts +2 -0
- package/dist/types/engine/templates.d.ts +1 -1
- package/dist/types/viewer/alternatives.d.ts +16 -0
- package/dist/types/viewer/cited-domains.d.ts +22 -0
- package/dist/types/viewer/page.d.ts +9 -2
- package/dist/types/viewer/presentation.d.ts +112 -0
- package/dist/types/viewer/server.d.ts +7 -3
- package/package.json +2 -1
- package/resources/fonts/Mulish-OFL.txt +93 -0
- package/resources/fonts/Mulish-VariableFont_wght.ttf +0 -0
- package/resources/fonts/SourceCodePro-OFL.txt +93 -0
- package/resources/fonts/SourceCodePro-VariableFont_wght.ttf +0 -0
- package/resources/guide/OPERATOR.md +4 -1
- package/src/bundle/contracts.ts +1 -1
- package/src/cli/bundle-commands.ts +21 -0
- package/src/engine/guide/OPERATOR.md +4 -1
- package/src/engine/preflight.ts +4 -1
- package/src/engine/resources.ts +9 -5
- package/src/engine/templates.ts +5 -0
- package/src/probes/adapters/cli-claude-code.ts +14 -4
- package/src/probes/child-process.ts +4 -0
- package/src/report/core/rate-interval.ts +1 -2
- package/src/viewer/alternatives.ts +202 -0
- package/src/viewer/cited-domains.ts +127 -0
- package/src/viewer/page.ts +549 -236
- package/src/viewer/presentation.ts +759 -0
- package/src/viewer/server.ts +25 -4
- package/dist/lib/chunks/chunk-3TF4JGQA.js +0 -323
package/src/viewer/server.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { RunOrigin, toolVersion } from '../bundle/contracts';
|
|
|
9
9
|
import { parseBundleJson } from '../bundle/json';
|
|
10
10
|
import { verifyBundle } from '../bundle/verify';
|
|
11
11
|
import { viewerPage } from './page';
|
|
12
|
+
import { presentReport } from './presentation';
|
|
12
13
|
|
|
13
14
|
// ============================================================================
|
|
14
15
|
// `literally-aeo view` (specs/aeo-open-source-cli-spec.md §4.3). Any local
|
|
@@ -78,7 +79,8 @@ const plain = (status: number, body: string): Reply => {
|
|
|
78
79
|
return { status, body, contentType: 'text/plain; charset=utf-8' };
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
/** The page's metadata
|
|
82
|
+
/** The page's metadata, the verifier's result and the report the page
|
|
83
|
+
* shows, served beside the files. */
|
|
82
84
|
const derivedDocuments = (bundle: ViewerBundle) => {
|
|
83
85
|
const verification = verifyBundle(bundle.files, bundle.description);
|
|
84
86
|
const manifest = bundle.files.get('manifest.json');
|
|
@@ -110,13 +112,21 @@ const derivedDocuments = (bundle: ViewerBundle) => {
|
|
|
110
112
|
},
|
|
111
113
|
],
|
|
112
114
|
['__verification', bundle.workingState ? null : verification],
|
|
115
|
+
['__report', presentReport(bundle.files)],
|
|
113
116
|
]);
|
|
114
117
|
};
|
|
115
118
|
|
|
119
|
+
export type ViewerOptions = {
|
|
120
|
+
port?: number;
|
|
121
|
+
/** The page's fonts by file name (viewerFontFiles), from the engine's
|
|
122
|
+
* resources; without them the page falls back to system fonts. */
|
|
123
|
+
fonts?: ReadonlyMap<string, Buffer>;
|
|
124
|
+
};
|
|
125
|
+
|
|
116
126
|
/** startViewer serves a bundle on loopback until closed. */
|
|
117
127
|
export const startViewer = async (
|
|
118
128
|
bundle: ViewerBundle,
|
|
119
|
-
{ port = 0
|
|
129
|
+
{ port = 0, fonts = new Map() }: ViewerOptions = {},
|
|
120
130
|
): Promise<ViewerServer> => {
|
|
121
131
|
const token = randomBytes(32).toString('hex');
|
|
122
132
|
const derived = derivedDocuments(bundle);
|
|
@@ -143,14 +153,25 @@ export const startViewer = async (
|
|
|
143
153
|
|
|
144
154
|
send(response, {
|
|
145
155
|
status: 200,
|
|
146
|
-
body: viewerPage(nonce),
|
|
156
|
+
body: viewerPage(nonce, fonts.size > 0 ? token : undefined),
|
|
147
157
|
contentType: 'text/html; charset=utf-8',
|
|
148
|
-
csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; img-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
158
|
+
csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; font-src 'self'; connect-src 'self'; img-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`,
|
|
149
159
|
});
|
|
150
160
|
|
|
151
161
|
return;
|
|
152
162
|
}
|
|
153
163
|
|
|
164
|
+
// Font names are plain ASCII: the path is looked up as sent.
|
|
165
|
+
const font = url.pathname.startsWith('/fonts/')
|
|
166
|
+
? fonts.get(url.pathname.slice('/fonts/'.length))
|
|
167
|
+
: undefined;
|
|
168
|
+
|
|
169
|
+
if (font !== undefined) {
|
|
170
|
+
send(response, { status: 200, body: font, contentType: 'font/ttf' });
|
|
171
|
+
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
154
175
|
const file = decodeURIComponent(url.pathname.replace(/^\/data\//, ''));
|
|
155
176
|
const derivedDocument = derived.get(file);
|
|
156
177
|
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
// src/viewer/page.ts
|
|
2
|
-
var styles = `
|
|
3
|
-
:root {
|
|
4
|
-
--bg: #ffffff; --fg: #16181d; --muted: #5d6470; --line: #e3e6eb;
|
|
5
|
-
--panel: #f6f7f9; --accent: #3651d4; --pass: #1f7a46; --fail: #b3261e;
|
|
6
|
-
--warn: #8a5a00;
|
|
7
|
-
color-scheme: light;
|
|
8
|
-
}
|
|
9
|
-
@media (prefers-color-scheme: dark) {
|
|
10
|
-
:root {
|
|
11
|
-
--bg: #111317; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
|
|
12
|
-
--panel: #181b21; --accent: #8fa2ff; --pass: #5fd08f; --fail: #ff8a80;
|
|
13
|
-
--warn: #e5b45a;
|
|
14
|
-
color-scheme: dark;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
* { box-sizing: border-box; }
|
|
18
|
-
body { margin: 0; background: var(--bg); color: var(--fg);
|
|
19
|
-
font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
|
|
20
|
-
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
|
|
21
|
-
h1 { font-size: 24px; margin: 0 0 4px; }
|
|
22
|
-
h2 { font-size: 18px; margin: 32px 0 12px; }
|
|
23
|
-
h3 { font-size: 15px; margin: 20px 0 8px; }
|
|
24
|
-
.muted { color: var(--muted); }
|
|
25
|
-
.banner { border: 1px solid var(--line); background: var(--panel);
|
|
26
|
-
padding: 12px 14px; border-radius: 8px; margin: 16px 0; }
|
|
27
|
-
.banner.warn { border-color: var(--warn); }
|
|
28
|
-
.grid { display: grid; gap: 12px;
|
|
29
|
-
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
|
|
30
|
-
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
|
|
31
|
-
.stat b { display: block; font-size: 22px; }
|
|
32
|
-
.interval { display: block; color: var(--muted); font-size: 13px; }
|
|
33
|
-
button.tip-trigger { background: none; border: 0; padding: 0; color: inherit; font: inherit;
|
|
34
|
-
text-align: left; cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
|
|
35
|
-
button.tip-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
36
|
-
.tip { display: block; color: var(--fg); }
|
|
37
|
-
.tip[hidden] { display: none; }
|
|
38
|
-
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
39
|
-
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
|
|
40
|
-
vertical-align: top; }
|
|
41
|
-
th { color: var(--muted); font-weight: 600; }
|
|
42
|
-
tr.row { cursor: pointer; }
|
|
43
|
-
tr.row:hover, tr.row:focus { background: var(--panel); outline: none; }
|
|
44
|
-
.pass { color: var(--pass); } .fail { color: var(--fail); }
|
|
45
|
-
.limited { color: var(--warn); }
|
|
46
|
-
.drawer { border: 1px solid var(--line); border-radius: 8px; padding: 14px;
|
|
47
|
-
margin-top: 12px; background: var(--panel); }
|
|
48
|
-
pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace,
|
|
49
|
-
SFMono-Regular, Menlo, monospace; margin: 8px 0 0; }
|
|
50
|
-
button.link { background: none; border: 0; color: var(--accent); padding: 0;
|
|
51
|
-
font: inherit; cursor: pointer; text-decoration: underline; }
|
|
52
|
-
.table-wrap { overflow-x: auto; }
|
|
53
|
-
ul.methodology { padding-left: 20px; color: var(--muted); font-size: 14px; }
|
|
54
|
-
ul.methodology li { margin: 6px 0; }
|
|
55
|
-
footer { margin-top: 48px; color: var(--muted); font-size: 13px; }
|
|
56
|
-
`;
|
|
57
|
-
var script = `
|
|
58
|
-
const token = new URLSearchParams(location.search).get('t');
|
|
59
|
-
const get = async (path) => {
|
|
60
|
-
const response = await fetch('/data/' + path + '?t=' + encodeURIComponent(token));
|
|
61
|
-
if (!response.ok) return null;
|
|
62
|
-
return response.json();
|
|
63
|
-
};
|
|
64
|
-
const el = (tag, attrs = {}, ...children) => {
|
|
65
|
-
const node = document.createElement(tag);
|
|
66
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
67
|
-
if (key === 'class') node.className = value;
|
|
68
|
-
else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
|
|
69
|
-
else node.setAttribute(key, value);
|
|
70
|
-
}
|
|
71
|
-
for (const child of children) {
|
|
72
|
-
if (child === null || child === undefined) continue;
|
|
73
|
-
node.append(typeof child === 'string' ? document.createTextNode(child) : child);
|
|
74
|
-
}
|
|
75
|
-
return node;
|
|
76
|
-
};
|
|
77
|
-
const percent = (value) =>
|
|
78
|
-
typeof value === 'number' && Number.isFinite(value) ? Math.round(value * 100) + '%' : 'n/a';
|
|
79
|
-
const isShare = (value) => typeof value === 'number' && value >= 0 && value <= 1;
|
|
80
|
-
const isCount = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
81
|
-
// The evidence beside a rate (calculation version 2), or null when the
|
|
82
|
-
// bundle has none or it is malformed: a bundle is shown even when it fails
|
|
83
|
-
// verification, so its numbers are checked before they are displayed.
|
|
84
|
-
const evidenceOf = (evidence) =>
|
|
85
|
-
evidence && isShare(evidence.low) && isShare(evidence.high) && evidence.low <= evidence.high
|
|
86
|
-
&& isCount(evidence.count) && isCount(evidence.captured) && isCount(evidence.planned)
|
|
87
|
-
? evidence : null;
|
|
88
|
-
// Outward to whole percents, so the range shown always contains the computed
|
|
89
|
-
// interval. The bounds are stored to 6 decimals; scaling them to an integer
|
|
90
|
-
// first keeps a bound of 0.07 (7.000000000000001 once multiplied) at 7%.
|
|
91
|
-
// The rule of report/core/rate-interval.ts, repeated here because this page
|
|
92
|
-
// is one self-contained script; page.spec.ts holds the two to the same
|
|
93
|
-
// answers.
|
|
94
|
-
const intervalText = (evidence) =>
|
|
95
|
-
Math.floor(Math.round(evidence.low * 1e6) / 1e4) + '\u2013'
|
|
96
|
-
+ Math.ceil(Math.round(evidence.high * 1e6) / 1e4) + '%';
|
|
97
|
-
// The counts behind an interval, in a tooltip (WCAG 1.4.13). It opens on
|
|
98
|
-
// hover, on keyboard focus and on a tap; it stays open while the pointer is
|
|
99
|
-
// over it; Escape closes it; and a screen reader reads it as the interval's
|
|
100
|
-
// description. It sits in the flow under the interval, so a scrolling table
|
|
101
|
-
// cannot clip it and it hides nothing.
|
|
102
|
-
const tipDismissals = [];
|
|
103
|
-
document.addEventListener('keydown', (event) => {
|
|
104
|
-
if (event.key === 'Escape') for (const dismiss of tipDismissals) dismiss();
|
|
105
|
-
});
|
|
106
|
-
let tipCount = 0;
|
|
107
|
-
const withTip = (label, name, text) => {
|
|
108
|
-
tipCount += 1;
|
|
109
|
-
const id = 'tip-' + tipCount;
|
|
110
|
-
const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' }, text);
|
|
111
|
-
let hovered = false;
|
|
112
|
-
let focused = false;
|
|
113
|
-
const sync = () => {
|
|
114
|
-
if (hovered || focused) tip.removeAttribute('hidden');
|
|
115
|
-
else tip.setAttribute('hidden', '');
|
|
116
|
-
};
|
|
117
|
-
const trigger = el('button', { type: 'button', class: 'tip-trigger',
|
|
118
|
-
'aria-label': name, 'aria-describedby': id,
|
|
119
|
-
// Safari focuses no button on a click or a tap, and a button that kept
|
|
120
|
-
// focus through Escape gets no new focus event: a click (or Enter or
|
|
121
|
-
// Space) opens the tip itself, until focus moves on.
|
|
122
|
-
onclick: () => { trigger.focus(); focused = true; sync(); },
|
|
123
|
-
onfocus: () => { focused = true; sync(); },
|
|
124
|
-
onblur: () => { focused = false; sync(); },
|
|
125
|
-
}, label);
|
|
126
|
-
tipDismissals.push(() => { hovered = false; focused = false; sync(); });
|
|
127
|
-
return el('span', { class: 'interval',
|
|
128
|
-
onmouseenter: () => { hovered = true; sync(); },
|
|
129
|
-
onmouseleave: () => { hovered = false; sync(); },
|
|
130
|
-
}, trigger, tip);
|
|
131
|
-
};
|
|
132
|
-
// A rate, with its interval and counts beneath when the bundle carries them.
|
|
133
|
-
// subject names the rate for a screen reader, which reaches the interval
|
|
134
|
-
// without the label or the column heading beside it.
|
|
135
|
-
const rateFigure = (rate, recorded, subject, counted) => {
|
|
136
|
-
const figure = el('b', {}, percent(rate));
|
|
137
|
-
const evidence = evidenceOf(recorded);
|
|
138
|
-
if (!evidence) return [figure];
|
|
139
|
-
const interval = 'approx. 95% interval ' + intervalText(evidence);
|
|
140
|
-
return [figure, withTip(interval, interval + ' for ' + subject,
|
|
141
|
-
counted + ' in ' + evidence.count + ' of ' + evidence.planned + ' planned answers; '
|
|
142
|
-
+ evidence.captured + ' captured')];
|
|
143
|
-
};
|
|
144
|
-
const rateStat = (label, rate, recorded, counted) =>
|
|
145
|
-
el('div', { class: 'stat' }, ...rateFigure(rate, recorded, label.toLowerCase(), counted), label);
|
|
146
|
-
// Every surface that ran, each with its own pair of rates.
|
|
147
|
-
const modelTable = (byModel, labelOf) => {
|
|
148
|
-
const rows = Object.entries(byModel && typeof byModel === 'object' ? byModel : {})
|
|
149
|
-
.map(([surface, rates]) => {
|
|
150
|
-
const { shareOfVoice, citationRate, shareOfVoiceEvidence, citationRateEvidence } = rates || {};
|
|
151
|
-
const model = labelOf(surface);
|
|
152
|
-
return el('tr', {},
|
|
153
|
-
el('td', {}, model),
|
|
154
|
-
el('td', {}, ...rateFigure(shareOfVoice, shareOfVoiceEvidence, model + ' share of voice', 'Mentioned')),
|
|
155
|
-
el('td', {}, ...rateFigure(citationRate, citationRateEvidence, model + ' citation rate', 'Cited')),
|
|
156
|
-
);
|
|
157
|
-
});
|
|
158
|
-
if (!rows.length) return [];
|
|
159
|
-
return [el('h3', {}, 'By model'), el('table', { class: 'by-model' },
|
|
160
|
-
el('thead', {}, el('tr', {}, el('th', {}, 'Model'), el('th', {}, 'Share of voice'),
|
|
161
|
-
el('th', {}, 'Citation rate'))),
|
|
162
|
-
el('tbody', {}, ...rows))];
|
|
163
|
-
};
|
|
164
|
-
const answerKey = (section, promptId, surface, runIndex) =>
|
|
165
|
-
section + '|' + promptId + '|' + surface + '|' + runIndex;
|
|
166
|
-
|
|
167
|
-
const sourceLink = (url) => {
|
|
168
|
-
// External sources open only on a deliberate click, in a new context.
|
|
169
|
-
const button = el('button', { class: 'link', type: 'button' }, url);
|
|
170
|
-
button.addEventListener('click', () => {
|
|
171
|
-
if (/^https?:\\/\\//.test(url)) window.open(url, '_blank', 'noopener,noreferrer');
|
|
172
|
-
});
|
|
173
|
-
return button;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const render = async () => {
|
|
177
|
-
const root = document.getElementById('app');
|
|
178
|
-
const [info, verification, snapshot, captures, config] = await Promise.all([
|
|
179
|
-
get('__viewer'), get('__verification'), get('report/snapshot.json'),
|
|
180
|
-
get('captures/units.json'), get('inputs/config.json'),
|
|
181
|
-
]);
|
|
182
|
-
root.replaceChildren();
|
|
183
|
-
if (!info) {
|
|
184
|
-
root.append(el('p', {}, 'This viewer link is not valid. Start it again with literally-aeo view.'));
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const brand = (snapshot && snapshot.brand && snapshot.brand.name)
|
|
188
|
-
|| (config && config.brand && config.brand.name) || 'Audit';
|
|
189
|
-
root.append(
|
|
190
|
-
el('h1', {}, brand + ': AI visibility audit'),
|
|
191
|
-
el('p', { class: 'muted' }, info.originLabel + ' \xB7 ' + info.source),
|
|
192
|
-
);
|
|
193
|
-
if (info.workingState) {
|
|
194
|
-
root.append(el('div', { class: 'banner warn' },
|
|
195
|
-
'Working state, not a finalized revision: this is not an integrity receipt. Export the run to finalize it.'));
|
|
196
|
-
}
|
|
197
|
-
if (verification) {
|
|
198
|
-
const rows = verification.checks.map((check) => el('tr', {},
|
|
199
|
-
el('td', {}, check.title),
|
|
200
|
-
el('td', { class: check.outcome === 'pass' ? 'pass' : check.outcome === 'fail' ? 'fail' : 'limited' },
|
|
201
|
-
check.outcome.replace('_', ' ')),
|
|
202
|
-
el('td', { class: 'muted' }, check.outcome === 'pass' ? '' : check.explanation),
|
|
203
|
-
));
|
|
204
|
-
root.append(el('h2', {}, 'Verification'),
|
|
205
|
-
el('p', { class: 'muted' }, 'Capture authenticity: self-reported. Checks run on this machine, offline.'),
|
|
206
|
-
el('div', { class: 'table-wrap' }, el('table', {}, el('tbody', {}, ...rows))));
|
|
207
|
-
}
|
|
208
|
-
if (!snapshot) {
|
|
209
|
-
root.append(el('div', { class: 'banner' }, 'This run has no report yet: the measurement did not finish.'));
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const answers = new Map();
|
|
213
|
-
for (const record of captures || []) {
|
|
214
|
-
answers.set(answerKey(record.sectionKey, record.promptId, record.surface, record.runIndex), record);
|
|
215
|
-
}
|
|
216
|
-
// The snapshot names prompts by text; their ids, which key the captured
|
|
217
|
-
// answers, come from the frozen configuration in the same order.
|
|
218
|
-
const promptIds = new Map();
|
|
219
|
-
for (const configured of (config && config.sections) || []) {
|
|
220
|
-
promptIds.set(configured.key, configured.prompts.map((prompt) => prompt.id));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// A surface asked of another model than its default, and every custom
|
|
224
|
-
// surface, carries its own label in the snapshot; any other is shown by
|
|
225
|
-
// its ID. Like every string of a bundle, a label is inserted as text.
|
|
226
|
-
const labels = (snapshot.meta && snapshot.meta.surfaceLabels) || {};
|
|
227
|
-
const labelOf = (surface) =>
|
|
228
|
-
typeof labels[surface] === 'string' && labels[surface] ? labels[surface] : surface;
|
|
229
|
-
|
|
230
|
-
for (const section of snapshot.sections) {
|
|
231
|
-
const { summary, matrix, prompts } = section.visibility;
|
|
232
|
-
root.append(el('h2', {}, 'Section ' + section.key));
|
|
233
|
-
root.append(el('div', { class: 'grid' },
|
|
234
|
-
rateStat('Assistant share of voice', summary.prospectShareOfVoice,
|
|
235
|
-
summary.prospectShareOfVoiceEvidence, 'Mentioned'),
|
|
236
|
-
rateStat('Assistant citation rate', summary.prospectCitationRate,
|
|
237
|
-
summary.prospectCitationRateEvidence, 'Cited'),
|
|
238
|
-
rateStat('Coding-agent share of voice', summary.agentShareOfVoice,
|
|
239
|
-
summary.agentShareOfVoiceEvidence, 'Mentioned'),
|
|
240
|
-
rateStat('Coding-agent citation rate', summary.agentCitationRate,
|
|
241
|
-
summary.agentCitationRateEvidence, 'Cited'),
|
|
242
|
-
// The scraped consumer apps, only for a run that planned one.
|
|
243
|
-
...(summary.consumerShareOfVoice === undefined ? [] : [
|
|
244
|
-
rateStat('Consumer-app share of voice', summary.consumerShareOfVoice,
|
|
245
|
-
summary.consumerShareOfVoiceEvidence, 'Mentioned'),
|
|
246
|
-
rateStat('Consumer-app citation rate', summary.consumerCitationRate,
|
|
247
|
-
summary.consumerCitationRateEvidence, 'Cited'),
|
|
248
|
-
]),
|
|
249
|
-
el('div', { class: 'stat' }, el('b', {}, summary.topCompetitorDomain || 'none'), 'Most mentioned competitor'),
|
|
250
|
-
));
|
|
251
|
-
root.append(el('p', { class: 'muted' },
|
|
252
|
-
'Share of voice is how often the measured answers name the product, not market share.'));
|
|
253
|
-
root.append(...modelTable(summary.byModel, labelOf));
|
|
254
|
-
const drawer = el('div', { class: 'drawer', hidden: '' });
|
|
255
|
-
const body = el('tbody');
|
|
256
|
-
for (const row of matrix) {
|
|
257
|
-
const prompt = prompts[row.promptIdx] || { text: '' };
|
|
258
|
-
const promptId = (promptIds.get(section.key) || [])[row.promptIdx];
|
|
259
|
-
const record = answers.get(answerKey(section.key, promptId, row.surface, row.runIndex || 0));
|
|
260
|
-
const open = () => {
|
|
261
|
-
drawer.removeAttribute('hidden');
|
|
262
|
-
drawer.replaceChildren(
|
|
263
|
-
el('h3', {}, labelOf(row.surface) + ', run ' + (row.runIndex || 0)),
|
|
264
|
-
el('p', {}, prompt.text),
|
|
265
|
-
record ? el('pre', {}, record.probe.text)
|
|
266
|
-
: el('p', { class: 'limited' }, 'The answer is not in this bundle.'),
|
|
267
|
-
...(row.citedUrls && row.citedUrls.length
|
|
268
|
-
? [el('h3', {}, 'Cited sources'), ...row.citedUrls.map((url) => el('div', {}, sourceLink(url)))]
|
|
269
|
-
: []),
|
|
270
|
-
);
|
|
271
|
-
drawer.scrollIntoView({ block: 'nearest' });
|
|
272
|
-
};
|
|
273
|
-
body.append(el('tr', { class: 'row', tabindex: '0', onclick: open,
|
|
274
|
-
onkeydown: (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); open(); } } },
|
|
275
|
-
el('td', {}, prompt.text),
|
|
276
|
-
el('td', {}, labelOf(row.surface)),
|
|
277
|
-
el('td', {}, String(row.runIndex || 0)),
|
|
278
|
-
el('td', {}, row.prospectMentioned ? 'mentioned' + (row.prospectPosition ? ' (' + row.prospectPosition + ')' : '') : 'not mentioned'),
|
|
279
|
-
el('td', {}, (row.qualifiedCompetitors || []).map((entry) => entry.name).join(', ')),
|
|
280
|
-
));
|
|
281
|
-
}
|
|
282
|
-
root.append(el('div', { class: 'table-wrap' }, el('table', {},
|
|
283
|
-
el('thead', {}, el('tr', {}, el('th', {}, 'Question'), el('th', {}, 'Surface'),
|
|
284
|
-
el('th', {}, 'Run'), el('th', {}, 'Product'), el('th', {}, 'Alternatives named'))),
|
|
285
|
-
body)), drawer);
|
|
286
|
-
}
|
|
287
|
-
const methodology = snapshot.meta && Array.isArray(snapshot.meta.methodology)
|
|
288
|
-
? snapshot.meta.methodology.filter((sentence) => typeof sentence === 'string')
|
|
289
|
-
: [];
|
|
290
|
-
if (methodology.length) {
|
|
291
|
-
root.append(el('h2', {}, 'Methodology'),
|
|
292
|
-
el('ul', { class: 'methodology' },
|
|
293
|
-
...methodology.map((sentence) => el('li', {}, sentence))));
|
|
294
|
-
}
|
|
295
|
-
root.append(el('footer', {},
|
|
296
|
-
'Generated with Literally.dev AEO, an open-source AI visibility audit tool. ',
|
|
297
|
-
info.originLabel + '. Literally.dev did not review this result. Engine ' + info.toolVersion + '.'));
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
render().catch((error) => {
|
|
301
|
-
document.getElementById('app').textContent = 'The viewer could not load this bundle: ' + error.message;
|
|
302
|
-
});
|
|
303
|
-
`;
|
|
304
|
-
var viewerPage = (nonce) => {
|
|
305
|
-
return `<!doctype html>
|
|
306
|
-
<html lang="en">
|
|
307
|
-
<head>
|
|
308
|
-
<meta charset="utf-8">
|
|
309
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
310
|
-
<meta name="referrer" content="no-referrer">
|
|
311
|
-
<title>Literally.dev AEO</title>
|
|
312
|
-
<style nonce="${nonce}">${styles}</style>
|
|
313
|
-
</head>
|
|
314
|
-
<body>
|
|
315
|
-
<main id="app"><p class="muted">Loading the audit\u2026</p></main>
|
|
316
|
-
<script nonce="${nonce}">${script}</script>
|
|
317
|
-
</body>
|
|
318
|
-
</html>`;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
export {
|
|
322
|
-
viewerPage
|
|
323
|
-
};
|