@vibecheckai/cli 3.2.2 → 3.2.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/bin/.generated +25 -25
- package/bin/dev/run-v2-torture.js +30 -30
- package/bin/runners/ENHANCEMENT_GUIDE.md +121 -121
- package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -295
- package/bin/runners/lib/agent-firewall/ai/false-positive-analyzer.js +474 -0
- package/bin/runners/lib/agent-firewall/claims/extractor.js +117 -28
- package/bin/runners/lib/agent-firewall/evidence/env-evidence.js +23 -14
- package/bin/runners/lib/agent-firewall/evidence/route-evidence.js +72 -1
- package/bin/runners/lib/agent-firewall/interceptor/base.js +2 -2
- package/bin/runners/lib/agent-firewall/policy/default-policy.json +6 -0
- package/bin/runners/lib/agent-firewall/policy/engine.js +34 -3
- package/bin/runners/lib/agent-firewall/policy/rules/fake-success.js +29 -4
- package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +12 -0
- package/bin/runners/lib/agent-firewall/truthpack/loader.js +21 -0
- package/bin/runners/lib/agent-firewall/utils/ignore-checker.js +118 -0
- package/bin/runners/lib/analyzers.js +606 -325
- package/bin/runners/lib/auth-truth.js +193 -193
- package/bin/runners/lib/backup.js +62 -62
- package/bin/runners/lib/billing.js +107 -107
- package/bin/runners/lib/claims.js +118 -118
- package/bin/runners/lib/cli-ui.js +540 -540
- package/bin/runners/lib/contracts/auth-contract.js +202 -202
- package/bin/runners/lib/contracts/env-contract.js +181 -181
- package/bin/runners/lib/contracts/external-contract.js +206 -206
- package/bin/runners/lib/contracts/guard.js +168 -168
- package/bin/runners/lib/contracts/index.js +89 -89
- package/bin/runners/lib/contracts/plan-validator.js +311 -311
- package/bin/runners/lib/contracts/route-contract.js +199 -199
- package/bin/runners/lib/contracts.js +804 -804
- package/bin/runners/lib/detect.js +89 -89
- package/bin/runners/lib/doctor/autofix.js +254 -254
- package/bin/runners/lib/doctor/index.js +37 -37
- package/bin/runners/lib/doctor/modules/dependencies.js +325 -325
- package/bin/runners/lib/doctor/modules/index.js +46 -46
- package/bin/runners/lib/doctor/modules/network.js +250 -250
- package/bin/runners/lib/doctor/modules/project.js +312 -312
- package/bin/runners/lib/doctor/modules/runtime.js +224 -224
- package/bin/runners/lib/doctor/modules/security.js +348 -348
- package/bin/runners/lib/doctor/modules/system.js +213 -213
- package/bin/runners/lib/doctor/modules/vibecheck.js +394 -394
- package/bin/runners/lib/doctor/reporter.js +262 -262
- package/bin/runners/lib/doctor/service.js +262 -262
- package/bin/runners/lib/doctor/types.js +113 -113
- package/bin/runners/lib/doctor/ui.js +263 -263
- package/bin/runners/lib/doctor-v2.js +608 -608
- package/bin/runners/lib/drift.js +425 -425
- package/bin/runners/lib/enforcement.js +72 -72
- package/bin/runners/lib/engines/accessibility-engine.js +190 -0
- package/bin/runners/lib/engines/api-consistency-engine.js +162 -0
- package/bin/runners/lib/engines/ast-cache.js +99 -0
- package/bin/runners/lib/engines/code-quality-engine.js +255 -0
- package/bin/runners/lib/engines/console-logs-engine.js +115 -0
- package/bin/runners/lib/engines/cross-file-analysis-engine.js +268 -0
- package/bin/runners/lib/engines/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/deprecated-api-engine.js +226 -0
- package/bin/runners/lib/engines/empty-catch-engine.js +150 -0
- package/bin/runners/lib/engines/file-filter.js +131 -0
- package/bin/runners/lib/engines/hardcoded-secrets-engine.js +251 -0
- package/bin/runners/lib/engines/mock-data-engine.js +272 -0
- package/bin/runners/lib/engines/parallel-processor.js +71 -0
- package/bin/runners/lib/engines/performance-issues-engine.js +265 -0
- package/bin/runners/lib/engines/security-vulnerabilities-engine.js +243 -0
- package/bin/runners/lib/engines/todo-fixme-engine.js +115 -0
- package/bin/runners/lib/engines/type-aware-engine.js +152 -0
- package/bin/runners/lib/engines/unsafe-regex-engine.js +225 -0
- package/bin/runners/lib/engines/vibecheck-engines/README.md +53 -0
- package/bin/runners/lib/engines/vibecheck-engines/index.js +15 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/ast-cache.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/code-quality-engine.js +291 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/console-logs-engine.js +83 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/dead-code-engine.js +198 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/deprecated-api-engine.js +275 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/empty-catch-engine.js +167 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/file-filter.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/hardcoded-secrets-engine.js +139 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/mock-data-engine.js +140 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/parallel-processor.js +164 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/performance-issues-engine.js +234 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/type-aware-engine.js +217 -0
- package/bin/runners/lib/engines/vibecheck-engines/lib/unsafe-regex-engine.js +78 -0
- package/bin/runners/lib/engines/vibecheck-engines/package.json +13 -0
- package/bin/runners/lib/enterprise-detect.js +603 -603
- package/bin/runners/lib/enterprise-init.js +942 -942
- package/bin/runners/lib/env-resolver.js +417 -417
- package/bin/runners/lib/env-template.js +66 -66
- package/bin/runners/lib/env.js +189 -189
- package/bin/runners/lib/extractors/client-calls.js +990 -990
- package/bin/runners/lib/extractors/fastify-route-dump.js +573 -573
- package/bin/runners/lib/extractors/fastify-routes.js +426 -426
- package/bin/runners/lib/extractors/index.js +363 -363
- package/bin/runners/lib/extractors/next-routes.js +524 -524
- package/bin/runners/lib/extractors/proof-graph.js +431 -431
- package/bin/runners/lib/extractors/route-matcher.js +451 -451
- package/bin/runners/lib/extractors/truthpack-v2.js +377 -377
- package/bin/runners/lib/extractors/ui-bindings.js +547 -547
- package/bin/runners/lib/findings-schema.js +281 -281
- package/bin/runners/lib/firewall-prompt.js +50 -50
- package/bin/runners/lib/global-flags.js +213 -213
- package/bin/runners/lib/graph/graph-builder.js +265 -265
- package/bin/runners/lib/graph/html-renderer.js +413 -413
- package/bin/runners/lib/graph/index.js +32 -32
- package/bin/runners/lib/graph/runtime-collector.js +215 -215
- package/bin/runners/lib/graph/static-extractor.js +518 -518
- package/bin/runners/lib/html-report.js +650 -650
- package/bin/runners/lib/interactive-menu.js +1496 -1496
- package/bin/runners/lib/llm.js +75 -75
- package/bin/runners/lib/meter.js +61 -61
- package/bin/runners/lib/missions/evidence.js +126 -126
- package/bin/runners/lib/patch.js +40 -40
- package/bin/runners/lib/permissions/auth-model.js +213 -213
- package/bin/runners/lib/permissions/idor-prover.js +205 -205
- package/bin/runners/lib/permissions/index.js +45 -45
- package/bin/runners/lib/permissions/matrix-builder.js +198 -198
- package/bin/runners/lib/pkgjson.js +28 -28
- package/bin/runners/lib/policy.js +295 -295
- package/bin/runners/lib/preflight.js +142 -142
- package/bin/runners/lib/reality/correlation-detectors.js +359 -359
- package/bin/runners/lib/reality/index.js +318 -318
- package/bin/runners/lib/reality/request-hashing.js +416 -416
- package/bin/runners/lib/reality/request-mapper.js +453 -453
- package/bin/runners/lib/reality/safety-rails.js +463 -463
- package/bin/runners/lib/reality/semantic-snapshot.js +408 -408
- package/bin/runners/lib/reality/toast-detector.js +393 -393
- package/bin/runners/lib/reality-findings.js +84 -84
- package/bin/runners/lib/receipts.js +179 -179
- package/bin/runners/lib/redact.js +29 -29
- package/bin/runners/lib/replay/capsule-manager.js +154 -154
- package/bin/runners/lib/replay/index.js +263 -263
- package/bin/runners/lib/replay/player.js +348 -348
- package/bin/runners/lib/replay/recorder.js +331 -331
- package/bin/runners/lib/report-output.js +187 -187
- package/bin/runners/lib/report.js +135 -135
- package/bin/runners/lib/route-detection.js +1140 -1140
- package/bin/runners/lib/sandbox/index.js +59 -59
- package/bin/runners/lib/sandbox/proof-chain.js +399 -399
- package/bin/runners/lib/sandbox/sandbox-runner.js +205 -205
- package/bin/runners/lib/sandbox/worktree.js +174 -174
- package/bin/runners/lib/scan-output.js +525 -190
- package/bin/runners/lib/schema-validator.js +350 -350
- package/bin/runners/lib/schemas/contracts.schema.json +160 -160
- package/bin/runners/lib/schemas/finding.schema.json +100 -100
- package/bin/runners/lib/schemas/mission-pack.schema.json +206 -206
- package/bin/runners/lib/schemas/proof-graph.schema.json +176 -176
- package/bin/runners/lib/schemas/reality-report.schema.json +162 -162
- package/bin/runners/lib/schemas/share-pack.schema.json +180 -180
- package/bin/runners/lib/schemas/ship-report.schema.json +117 -117
- package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -303
- package/bin/runners/lib/schemas/validator.js +438 -438
- package/bin/runners/lib/score-history.js +282 -282
- package/bin/runners/lib/share-pack.js +239 -239
- package/bin/runners/lib/snippets.js +67 -67
- package/bin/runners/lib/status-output.js +253 -253
- package/bin/runners/lib/terminal-ui.js +351 -271
- package/bin/runners/lib/upsell.js +510 -510
- package/bin/runners/lib/usage.js +153 -153
- package/bin/runners/lib/validate-patch.js +156 -156
- package/bin/runners/lib/verdict-engine.js +628 -628
- package/bin/runners/reality/engine.js +917 -917
- package/bin/runners/reality/flows.js +122 -122
- package/bin/runners/reality/report.js +378 -378
- package/bin/runners/reality/session.js +193 -193
- package/bin/runners/runGuard.js +168 -168
- package/bin/runners/runProof.zip +0 -0
- package/bin/runners/runProve.js +8 -0
- package/bin/runners/runReality.js +14 -0
- package/bin/runners/runScan.js +17 -1
- package/bin/runners/runTruth.js +15 -3
- package/mcp-server/tier-auth.js +4 -4
- package/mcp-server/tools/index.js +72 -72
- package/package.json +1 -1
|
@@ -1,378 +1,378 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reality Mode Report Generators
|
|
3
|
-
* HTML Report, Timeline, JUnit XML, SARIF
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
function esc(s) {
|
|
7
|
-
return String(s ?? "")
|
|
8
|
-
.replace(/&/g, "&")
|
|
9
|
-
.replace(/</g, "<")
|
|
10
|
-
.replace(/>/g, ">")
|
|
11
|
-
.replace(/"/g, """);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function badge(status) {
|
|
15
|
-
const s = String(status || "").toLowerCase();
|
|
16
|
-
if (s === "success" || s === "pass") return `<span class="b b-ok">${esc(status)}</span>`;
|
|
17
|
-
if (s === "skipped") return `<span class="b b-skip">skipped</span>`;
|
|
18
|
-
if (s === "blocked") return `<span class="b b-block">blocked</span>`;
|
|
19
|
-
if (s === "unknown") return `<span class="b b-warn">unknown</span>`;
|
|
20
|
-
if (s === "fail" || s === "error") return `<span class="b b-bad">${esc(status)}</span>`;
|
|
21
|
-
return `<span class="b b-warn">${esc(status)}</span>`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function writeHtmlReport(results) {
|
|
25
|
-
const score = results.score ?? 0;
|
|
26
|
-
const grade = score >= 90 ? "A" : score >= 80 ? "B" : score >= 70 ? "C" : score >= 60 ? "D" : "F";
|
|
27
|
-
const verdict = score >= 80 ? "✅ Ready to ship" : score >= 60 ? "⚠️ Needs work" : "❌ Not shippable";
|
|
28
|
-
const scoreColor = score >= 80 ? "#22c55e" : score >= 60 ? "#eab308" : "#ef4444";
|
|
29
|
-
|
|
30
|
-
const flowsHtml = (results.flows || []).map(f => {
|
|
31
|
-
const steps = (f.steps || []).slice(0, 50).map(s => `
|
|
32
|
-
<div class="row">
|
|
33
|
-
<div class="k">${esc(s.action)} <span class="dim">${esc(s.name || "")}</span></div>
|
|
34
|
-
<div class="v">${badge(s.status)} ${s.danger?.dangerous ? `<span class="danger-tag">⚠️ destructive</span>` : ""} <span class="dim">${esc(s.error || "")}</span></div>
|
|
35
|
-
</div>
|
|
36
|
-
`).join("");
|
|
37
|
-
|
|
38
|
-
const asserts = (f.assertions || []).map(a => `
|
|
39
|
-
<div class="row">
|
|
40
|
-
<div class="k">${esc(a.type)} ${a.critical ? `<span class="critical-tag">critical</span>` : ""}</div>
|
|
41
|
-
<div class="v">${badge(a.status)} <span class="dim">${esc(a.message || "")}</span></div>
|
|
42
|
-
</div>
|
|
43
|
-
`).join("");
|
|
44
|
-
|
|
45
|
-
return `
|
|
46
|
-
<div class="card">
|
|
47
|
-
<div class="card-h">
|
|
48
|
-
<div>
|
|
49
|
-
<div class="t">${esc(f.name || f.id)}</div>
|
|
50
|
-
<div class="dim">${esc(f.source || "")}</div>
|
|
51
|
-
</div>
|
|
52
|
-
<div>${badge(f.status)} <span class="dim">${Math.round((f.durationMs || 0) / 1000)}s</span></div>
|
|
53
|
-
</div>
|
|
54
|
-
<div class="split">
|
|
55
|
-
<div>
|
|
56
|
-
<div class="h2">Steps (${(f.steps || []).length})</div>
|
|
57
|
-
${steps || `<div class="dim">No steps</div>`}
|
|
58
|
-
</div>
|
|
59
|
-
<div>
|
|
60
|
-
<div class="h2">Assertions (${(f.assertions || []).length})</div>
|
|
61
|
-
${asserts || `<div class="dim">No assertions</div>`}
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
`;
|
|
66
|
-
}).join("");
|
|
67
|
-
|
|
68
|
-
const routesHtml = (results.routes || []).slice(0, 50).map(r => `
|
|
69
|
-
<div class="row">
|
|
70
|
-
<div class="k mono">${esc(r.path)}</div>
|
|
71
|
-
<div class="v">${badge(r.status)} <span class="dim">${r.httpStatus || ""}</span></div>
|
|
72
|
-
</div>
|
|
73
|
-
`).join("");
|
|
74
|
-
|
|
75
|
-
const errHtml = (results.errors || []).slice(0, 30).map(e => `
|
|
76
|
-
<div class="err">[${esc(e.type)}] ${esc(e.message)} <span class="dim">${esc(e.url || "")}</span></div>
|
|
77
|
-
`).join("");
|
|
78
|
-
|
|
79
|
-
const cov = results.coverage || {};
|
|
80
|
-
|
|
81
|
-
return `<!doctype html>
|
|
82
|
-
<html lang="en">
|
|
83
|
-
<head>
|
|
84
|
-
<meta charset="utf-8" />
|
|
85
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
86
|
-
<title>Reality Mode Report - vibecheck</title>
|
|
87
|
-
<style>
|
|
88
|
-
*{box-sizing:border-box}
|
|
89
|
-
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#0b0b0f;color:#eaeaf0;line-height:1.5}
|
|
90
|
-
.wrap{max-width:1100px;margin:0 auto;padding:28px}
|
|
91
|
-
.top{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;flex-wrap:wrap}
|
|
92
|
-
.title{font-size:22px;font-weight:800}
|
|
93
|
-
.dim{color:#9aa0aa;font-size:12px}
|
|
94
|
-
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}
|
|
95
|
-
.score{display:flex;gap:14px;align-items:center;background:#11131a;border:1px solid #222634;border-radius:16px;padding:18px 20px}
|
|
96
|
-
.num{font-size:48px;font-weight:900;line-height:1;color:${scoreColor}}
|
|
97
|
-
.meta{display:flex;flex-direction:column;gap:2px}
|
|
98
|
-
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin-top:14px}
|
|
99
|
-
.stat{background:#11131a;border:1px solid #222634;border-radius:14px;padding:12px}
|
|
100
|
-
.stat .v{font-weight:800;font-size:18px}
|
|
101
|
-
.card{background:#0f1118;border:1px solid #222634;border-radius:16px;margin-top:14px;overflow:hidden}
|
|
102
|
-
.card-h{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;background:#11131a;border-bottom:1px solid #222634}
|
|
103
|
-
.t{font-weight:800}
|
|
104
|
-
.split{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:14px 16px}
|
|
105
|
-
@media(max-width:700px){.split{grid-template-columns:1fr}}
|
|
106
|
-
.h2{font-size:12px;font-weight:800;color:#c8ccd6;margin-bottom:8px;text-transform:uppercase;letter-spacing:0.5px}
|
|
107
|
-
.row{display:flex;justify-content:space-between;gap:10px;border-bottom:1px solid #171a24;padding:8px 0;align-items:center}
|
|
108
|
-
.row:last-child{border-bottom:none}
|
|
109
|
-
.k{font-size:12px;overflow:hidden;text-overflow:ellipsis}
|
|
110
|
-
.v{font-size:12px;text-align:right;white-space:nowrap}
|
|
111
|
-
.b{font-size:11px;font-weight:800;padding:3px 8px;border-radius:999px;border:1px solid transparent;text-transform:uppercase}
|
|
112
|
-
.b-ok{background:rgba(34,197,94,.12);border-color:rgba(34,197,94,.25);color:#22c55e}
|
|
113
|
-
.b-bad{background:rgba(239,68,68,.12);border-color:rgba(239,68,68,.25);color:#ef4444}
|
|
114
|
-
.b-warn{background:rgba(234,179,8,.12);border-color:rgba(234,179,8,.25);color:#eab308}
|
|
115
|
-
.b-skip{background:rgba(59,130,246,.10);border-color:rgba(59,130,246,.25);color:#60a5fa}
|
|
116
|
-
.b-block{background:rgba(244,63,94,.10);border-color:rgba(244,63,94,.25);color:#fb7185}
|
|
117
|
-
.danger-tag{font-size:10px;color:#fb7185;margin-left:4px}
|
|
118
|
-
.critical-tag{font-size:10px;color:#f59e0b;background:rgba(245,158,11,.15);padding:2px 6px;border-radius:4px;margin-left:4px}
|
|
119
|
-
.err{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:12px;color:#fca5a5;padding:8px 0;border-bottom:1px solid #171a24}
|
|
120
|
-
.err:last-child{border-bottom:none}
|
|
121
|
-
a{color:#60a5fa;text-decoration:none}
|
|
122
|
-
a:hover{text-decoration:underline}
|
|
123
|
-
.footer{margin-top:20px;padding-top:16px;border-top:1px solid #222634;text-align:center}
|
|
124
|
-
</style>
|
|
125
|
-
</head>
|
|
126
|
-
<body>
|
|
127
|
-
<div class="wrap">
|
|
128
|
-
<div class="top">
|
|
129
|
-
<div>
|
|
130
|
-
<div class="title">🔍 Reality Mode Report</div>
|
|
131
|
-
<div class="dim">${esc(results.meta?.baseUrl)} • ${esc(results.meta?.startedAt)} • ${Math.round((results.duration || 0)/1000)}s</div>
|
|
132
|
-
</div>
|
|
133
|
-
<div class="score">
|
|
134
|
-
<div class="num">${score}</div>
|
|
135
|
-
<div class="meta">
|
|
136
|
-
<div><b>Grade:</b> ${grade}</div>
|
|
137
|
-
<div class="dim">${esc(verdict)}</div>
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
|
|
142
|
-
<div class="grid">
|
|
143
|
-
<div class="stat"><div class="dim">Routes Working</div><div class="v">${cov.routesWorking || 0}/${cov.routesDiscovered || 0}</div></div>
|
|
144
|
-
<div class="stat"><div class="dim">Elements Working</div><div class="v">${cov.elementsWorking || 0}/${cov.elementsDiscovered || 0}</div></div>
|
|
145
|
-
<div class="stat"><div class="dim">Forms Discovered</div><div class="v">${cov.formsDiscovered || 0}</div></div>
|
|
146
|
-
<div class="stat"><div class="dim">Flows Executed</div><div class="v">${(results.flows || []).length}</div></div>
|
|
147
|
-
<div class="stat"><div class="dim">Errors Captured</div><div class="v">${(results.errors || []).length}</div></div>
|
|
148
|
-
</div>
|
|
149
|
-
|
|
150
|
-
${flowsHtml || `<div class="card"><div class="card-h"><div class="t">Flows</div></div><div style="padding:14px 16px" class="dim">No flows ran. Add flow packs to .vibecheck/flows/ or use --flows-dir</div></div>`}
|
|
151
|
-
|
|
152
|
-
${(results.routes || []).length ? `
|
|
153
|
-
<div class="card">
|
|
154
|
-
<div class="card-h"><div class="t">Routes Discovered</div><span class="dim">${(results.routes || []).length}</span></div>
|
|
155
|
-
<div style="padding:0 16px;max-height:300px;overflow-y:auto">${routesHtml}</div>
|
|
156
|
-
</div>` : ""}
|
|
157
|
-
|
|
158
|
-
${(results.errors || []).length ? `
|
|
159
|
-
<div class="card">
|
|
160
|
-
<div class="card-h"><div class="t">Errors</div>${badge("error")}</div>
|
|
161
|
-
<div style="padding:0 16px;max-height:250px;overflow-y:auto">${errHtml}</div>
|
|
162
|
-
</div>` : ""}
|
|
163
|
-
|
|
164
|
-
<div class="footer dim">
|
|
165
|
-
Generated by vibecheck Reality Mode • <a href="https://vibecheckai.dev">vibecheckai.dev</a>
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
</body>
|
|
169
|
-
</html>`;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function writeTimelineHtml(results) {
|
|
173
|
-
const items = (results.timeline || []).map((t, idx) => `
|
|
174
|
-
<div class="it ${esc(t.status)}">
|
|
175
|
-
<div class="h">
|
|
176
|
-
<div class="num">${idx + 1}</div>
|
|
177
|
-
<div class="info">
|
|
178
|
-
<div><b>${esc(t.flowId)}</b> • step ${esc(t.step)} • <span class="action">${esc(t.action)}</span> <span class="dim">${esc(t.name)}</span></div>
|
|
179
|
-
<div class="dim">${esc(t.url)}</div>
|
|
180
|
-
</div>
|
|
181
|
-
<div>${badge(t.status)}</div>
|
|
182
|
-
</div>
|
|
183
|
-
<div class="shots">
|
|
184
|
-
${t.before ? `<a href="${esc(t.before)}" target="_blank">📷 before</a>` : ""}
|
|
185
|
-
${t.after ? `<a href="${esc(t.after)}" target="_blank">📷 after</a>` : ""}
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
188
|
-
`).join("");
|
|
189
|
-
|
|
190
|
-
return `<!doctype html>
|
|
191
|
-
<html lang="en">
|
|
192
|
-
<head>
|
|
193
|
-
<meta charset="utf-8"/>
|
|
194
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
195
|
-
<title>Reality Timeline - vibecheck</title>
|
|
196
|
-
<style>
|
|
197
|
-
*{box-sizing:border-box}
|
|
198
|
-
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#0b0b0f;color:#eaeaf0;line-height:1.5}
|
|
199
|
-
.wrap{max-width:1100px;margin:0 auto;padding:24px}
|
|
200
|
-
h2{margin:0 0 8px 0;font-size:20px}
|
|
201
|
-
.dim{color:#9aa0aa;font-size:12px}
|
|
202
|
-
.it{background:#0f1118;border:1px solid #222634;border-radius:14px;padding:12px 14px;margin-top:10px}
|
|
203
|
-
.h{display:flex;gap:12px;align-items:center}
|
|
204
|
-
.num{width:28px;height:28px;background:#1e2130;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800;flex-shrink:0}
|
|
205
|
-
.info{flex:1;min-width:0}
|
|
206
|
-
.action{color:#60a5fa}
|
|
207
|
-
.shots{margin-top:8px;font-size:12px;padding-left:40px}
|
|
208
|
-
a{color:#60a5fa;margin-right:12px;text-decoration:none}
|
|
209
|
-
a:hover{text-decoration:underline}
|
|
210
|
-
.b{font-size:10px;font-weight:800;padding:2px 6px;border-radius:999px;text-transform:uppercase}
|
|
211
|
-
.b-ok{background:rgba(34,197,94,.12);color:#22c55e}
|
|
212
|
-
.b-bad{background:rgba(239,68,68,.12);color:#ef4444}
|
|
213
|
-
.b-warn{background:rgba(234,179,8,.12);color:#eab308}
|
|
214
|
-
.b-skip{background:rgba(59,130,246,.10);color:#60a5fa}
|
|
215
|
-
.b-block{background:rgba(244,63,94,.10);color:#fb7185}
|
|
216
|
-
</style>
|
|
217
|
-
</head>
|
|
218
|
-
<body>
|
|
219
|
-
<div class="wrap">
|
|
220
|
-
<h2>🧭 Reality Timeline</h2>
|
|
221
|
-
<div class="dim" style="margin-bottom:16px">${esc(results.meta?.baseUrl)} • ${esc(results.meta?.startedAt)} • ${(results.timeline || []).length} steps</div>
|
|
222
|
-
${items || `<div class="dim">No timeline items recorded.</div>`}
|
|
223
|
-
</div>
|
|
224
|
-
</body>
|
|
225
|
-
</html>`;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function writeJUnitXml(results) {
|
|
229
|
-
const ts = new Date().toISOString();
|
|
230
|
-
const flows = results.flows || [];
|
|
231
|
-
let tests = 0;
|
|
232
|
-
let failures = 0;
|
|
233
|
-
|
|
234
|
-
let cases = "";
|
|
235
|
-
|
|
236
|
-
for (const f of flows) {
|
|
237
|
-
for (const s of (f.steps || [])) {
|
|
238
|
-
tests++;
|
|
239
|
-
const name = `Step: ${f.id} / ${s.action} ${s.name || ""}`.trim();
|
|
240
|
-
if (s.status === "error" || s.status === "blocked") {
|
|
241
|
-
failures++;
|
|
242
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.steps" time="${((s.durationMs || 0) / 1000).toFixed(2)}">
|
|
243
|
-
<failure message="${esc(s.error || s.status)}">${esc(s.error || s.status)}</failure>
|
|
244
|
-
</testcase>\n`;
|
|
245
|
-
} else {
|
|
246
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.steps" time="${((s.durationMs || 0) / 1000).toFixed(2)}"/>\n`;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
for (const a of (f.assertions || [])) {
|
|
251
|
-
if (a.status === "skip") continue;
|
|
252
|
-
tests++;
|
|
253
|
-
const name = `Assert: ${f.id} / ${a.type}`;
|
|
254
|
-
if (a.status === "fail") {
|
|
255
|
-
failures++;
|
|
256
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.assertions">
|
|
257
|
-
<failure message="${esc(a.message)}">${esc(a.message)}</failure>
|
|
258
|
-
</testcase>\n`;
|
|
259
|
-
} else {
|
|
260
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.assertions"/>\n`;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Routes as test cases
|
|
266
|
-
for (const r of (results.routes || [])) {
|
|
267
|
-
tests++;
|
|
268
|
-
const name = `Route: ${r.path}`;
|
|
269
|
-
if (r.status !== "success") {
|
|
270
|
-
failures++;
|
|
271
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.routes">
|
|
272
|
-
<failure message="HTTP ${r.httpStatus || 0}">${esc(r.error || `HTTP ${r.httpStatus}`)}</failure>
|
|
273
|
-
</testcase>\n`;
|
|
274
|
-
} else {
|
|
275
|
-
cases += ` <testcase name="${esc(name)}" classname="reality.routes"/>\n`;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
280
|
-
<testsuites name="vibecheck Reality Mode" tests="${tests}" failures="${failures}" timestamp="${ts}" time="${((results.duration || 0) / 1000).toFixed(2)}">
|
|
281
|
-
<testsuite name="Reality Explorer" tests="${tests}" failures="${failures}" time="${((results.duration || 0) / 1000).toFixed(2)}">
|
|
282
|
-
<properties>
|
|
283
|
-
<property name="score" value="${results.score || 0}"/>
|
|
284
|
-
<property name="baseUrl" value="${esc(results.meta?.baseUrl || "")}"/>
|
|
285
|
-
</properties>
|
|
286
|
-
${cases} </testsuite>
|
|
287
|
-
</testsuites>`;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function writeSarif(results, baseUrl) {
|
|
291
|
-
const sarifResults = [];
|
|
292
|
-
const rules = new Map();
|
|
293
|
-
|
|
294
|
-
function addRule(id, name, level) {
|
|
295
|
-
if (rules.has(id)) return;
|
|
296
|
-
rules.set(id, {
|
|
297
|
-
id,
|
|
298
|
-
shortDescription: { text: name },
|
|
299
|
-
fullDescription: { text: name },
|
|
300
|
-
defaultConfiguration: { level },
|
|
301
|
-
helpUri: "https://vibecheckai.dev/docs/reality-mode",
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Step failures
|
|
306
|
-
for (const f of (results.flows || [])) {
|
|
307
|
-
for (const s of (f.steps || [])) {
|
|
308
|
-
if (s.status === "error" || s.status === "blocked") {
|
|
309
|
-
addRule("reality/step-failed", "Flow step failed", "warning");
|
|
310
|
-
sarifResults.push({
|
|
311
|
-
ruleId: "reality/step-failed",
|
|
312
|
-
level: "warning",
|
|
313
|
-
message: { text: `${f.id}: ${s.action} failed - ${s.error || s.status}` },
|
|
314
|
-
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl } } }],
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
for (const a of (f.assertions || [])) {
|
|
320
|
-
if (a.status === "fail") {
|
|
321
|
-
const level = a.critical ? "error" : "warning";
|
|
322
|
-
addRule("reality/assertion-failed", "Assertion failed", level);
|
|
323
|
-
sarifResults.push({
|
|
324
|
-
ruleId: "reality/assertion-failed",
|
|
325
|
-
level,
|
|
326
|
-
message: { text: `${f.id}: ${a.type} - ${a.message}` },
|
|
327
|
-
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl } } }],
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Route errors
|
|
334
|
-
for (const r of (results.routes || [])) {
|
|
335
|
-
if (r.status !== "success") {
|
|
336
|
-
addRule("reality/route-error", "Route error", "warning");
|
|
337
|
-
sarifResults.push({
|
|
338
|
-
ruleId: "reality/route-error",
|
|
339
|
-
level: "warning",
|
|
340
|
-
message: { text: `Route ${r.path} failed: HTTP ${r.httpStatus || 0}` },
|
|
341
|
-
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl + (r.path || "") } } }],
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Console/page errors
|
|
347
|
-
for (const e of (results.errors || [])) {
|
|
348
|
-
addRule("reality/runtime-error", "Runtime error detected", "error");
|
|
349
|
-
sarifResults.push({
|
|
350
|
-
ruleId: "reality/runtime-error",
|
|
351
|
-
level: "error",
|
|
352
|
-
message: { text: `[${e.type}] ${e.message}` },
|
|
353
|
-
locations: [{ physicalLocation: { artifactLocation: { uri: e.url || baseUrl } } }],
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return {
|
|
358
|
-
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
|
|
359
|
-
version: "2.1.0",
|
|
360
|
-
runs: [{
|
|
361
|
-
tool: {
|
|
362
|
-
driver: {
|
|
363
|
-
name: "vibecheck Reality Mode",
|
|
364
|
-
version: "2.0.0",
|
|
365
|
-
informationUri: "https://vibecheckai.dev",
|
|
366
|
-
rules: Array.from(rules.values()),
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
results: sarifResults,
|
|
370
|
-
invocations: [{
|
|
371
|
-
executionSuccessful: sarifResults.filter(r => r.level === "error").length === 0,
|
|
372
|
-
endTimeUtc: new Date().toISOString(),
|
|
373
|
-
}],
|
|
374
|
-
}],
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
module.exports = { writeHtmlReport, writeTimelineHtml, writeJUnitXml, writeSarif };
|
|
1
|
+
/**
|
|
2
|
+
* Reality Mode Report Generators
|
|
3
|
+
* HTML Report, Timeline, JUnit XML, SARIF
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function esc(s) {
|
|
7
|
+
return String(s ?? "")
|
|
8
|
+
.replace(/&/g, "&")
|
|
9
|
+
.replace(/</g, "<")
|
|
10
|
+
.replace(/>/g, ">")
|
|
11
|
+
.replace(/"/g, """);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function badge(status) {
|
|
15
|
+
const s = String(status || "").toLowerCase();
|
|
16
|
+
if (s === "success" || s === "pass") return `<span class="b b-ok">${esc(status)}</span>`;
|
|
17
|
+
if (s === "skipped") return `<span class="b b-skip">skipped</span>`;
|
|
18
|
+
if (s === "blocked") return `<span class="b b-block">blocked</span>`;
|
|
19
|
+
if (s === "unknown") return `<span class="b b-warn">unknown</span>`;
|
|
20
|
+
if (s === "fail" || s === "error") return `<span class="b b-bad">${esc(status)}</span>`;
|
|
21
|
+
return `<span class="b b-warn">${esc(status)}</span>`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function writeHtmlReport(results) {
|
|
25
|
+
const score = results.score ?? 0;
|
|
26
|
+
const grade = score >= 90 ? "A" : score >= 80 ? "B" : score >= 70 ? "C" : score >= 60 ? "D" : "F";
|
|
27
|
+
const verdict = score >= 80 ? "✅ Ready to ship" : score >= 60 ? "⚠️ Needs work" : "❌ Not shippable";
|
|
28
|
+
const scoreColor = score >= 80 ? "#22c55e" : score >= 60 ? "#eab308" : "#ef4444";
|
|
29
|
+
|
|
30
|
+
const flowsHtml = (results.flows || []).map(f => {
|
|
31
|
+
const steps = (f.steps || []).slice(0, 50).map(s => `
|
|
32
|
+
<div class="row">
|
|
33
|
+
<div class="k">${esc(s.action)} <span class="dim">${esc(s.name || "")}</span></div>
|
|
34
|
+
<div class="v">${badge(s.status)} ${s.danger?.dangerous ? `<span class="danger-tag">⚠️ destructive</span>` : ""} <span class="dim">${esc(s.error || "")}</span></div>
|
|
35
|
+
</div>
|
|
36
|
+
`).join("");
|
|
37
|
+
|
|
38
|
+
const asserts = (f.assertions || []).map(a => `
|
|
39
|
+
<div class="row">
|
|
40
|
+
<div class="k">${esc(a.type)} ${a.critical ? `<span class="critical-tag">critical</span>` : ""}</div>
|
|
41
|
+
<div class="v">${badge(a.status)} <span class="dim">${esc(a.message || "")}</span></div>
|
|
42
|
+
</div>
|
|
43
|
+
`).join("");
|
|
44
|
+
|
|
45
|
+
return `
|
|
46
|
+
<div class="card">
|
|
47
|
+
<div class="card-h">
|
|
48
|
+
<div>
|
|
49
|
+
<div class="t">${esc(f.name || f.id)}</div>
|
|
50
|
+
<div class="dim">${esc(f.source || "")}</div>
|
|
51
|
+
</div>
|
|
52
|
+
<div>${badge(f.status)} <span class="dim">${Math.round((f.durationMs || 0) / 1000)}s</span></div>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="split">
|
|
55
|
+
<div>
|
|
56
|
+
<div class="h2">Steps (${(f.steps || []).length})</div>
|
|
57
|
+
${steps || `<div class="dim">No steps</div>`}
|
|
58
|
+
</div>
|
|
59
|
+
<div>
|
|
60
|
+
<div class="h2">Assertions (${(f.assertions || []).length})</div>
|
|
61
|
+
${asserts || `<div class="dim">No assertions</div>`}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
`;
|
|
66
|
+
}).join("");
|
|
67
|
+
|
|
68
|
+
const routesHtml = (results.routes || []).slice(0, 50).map(r => `
|
|
69
|
+
<div class="row">
|
|
70
|
+
<div class="k mono">${esc(r.path)}</div>
|
|
71
|
+
<div class="v">${badge(r.status)} <span class="dim">${r.httpStatus || ""}</span></div>
|
|
72
|
+
</div>
|
|
73
|
+
`).join("");
|
|
74
|
+
|
|
75
|
+
const errHtml = (results.errors || []).slice(0, 30).map(e => `
|
|
76
|
+
<div class="err">[${esc(e.type)}] ${esc(e.message)} <span class="dim">${esc(e.url || "")}</span></div>
|
|
77
|
+
`).join("");
|
|
78
|
+
|
|
79
|
+
const cov = results.coverage || {};
|
|
80
|
+
|
|
81
|
+
return `<!doctype html>
|
|
82
|
+
<html lang="en">
|
|
83
|
+
<head>
|
|
84
|
+
<meta charset="utf-8" />
|
|
85
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
86
|
+
<title>Reality Mode Report - vibecheck</title>
|
|
87
|
+
<style>
|
|
88
|
+
*{box-sizing:border-box}
|
|
89
|
+
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#0b0b0f;color:#eaeaf0;line-height:1.5}
|
|
90
|
+
.wrap{max-width:1100px;margin:0 auto;padding:28px}
|
|
91
|
+
.top{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;flex-wrap:wrap}
|
|
92
|
+
.title{font-size:22px;font-weight:800}
|
|
93
|
+
.dim{color:#9aa0aa;font-size:12px}
|
|
94
|
+
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}
|
|
95
|
+
.score{display:flex;gap:14px;align-items:center;background:#11131a;border:1px solid #222634;border-radius:16px;padding:18px 20px}
|
|
96
|
+
.num{font-size:48px;font-weight:900;line-height:1;color:${scoreColor}}
|
|
97
|
+
.meta{display:flex;flex-direction:column;gap:2px}
|
|
98
|
+
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin-top:14px}
|
|
99
|
+
.stat{background:#11131a;border:1px solid #222634;border-radius:14px;padding:12px}
|
|
100
|
+
.stat .v{font-weight:800;font-size:18px}
|
|
101
|
+
.card{background:#0f1118;border:1px solid #222634;border-radius:16px;margin-top:14px;overflow:hidden}
|
|
102
|
+
.card-h{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;background:#11131a;border-bottom:1px solid #222634}
|
|
103
|
+
.t{font-weight:800}
|
|
104
|
+
.split{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:14px 16px}
|
|
105
|
+
@media(max-width:700px){.split{grid-template-columns:1fr}}
|
|
106
|
+
.h2{font-size:12px;font-weight:800;color:#c8ccd6;margin-bottom:8px;text-transform:uppercase;letter-spacing:0.5px}
|
|
107
|
+
.row{display:flex;justify-content:space-between;gap:10px;border-bottom:1px solid #171a24;padding:8px 0;align-items:center}
|
|
108
|
+
.row:last-child{border-bottom:none}
|
|
109
|
+
.k{font-size:12px;overflow:hidden;text-overflow:ellipsis}
|
|
110
|
+
.v{font-size:12px;text-align:right;white-space:nowrap}
|
|
111
|
+
.b{font-size:11px;font-weight:800;padding:3px 8px;border-radius:999px;border:1px solid transparent;text-transform:uppercase}
|
|
112
|
+
.b-ok{background:rgba(34,197,94,.12);border-color:rgba(34,197,94,.25);color:#22c55e}
|
|
113
|
+
.b-bad{background:rgba(239,68,68,.12);border-color:rgba(239,68,68,.25);color:#ef4444}
|
|
114
|
+
.b-warn{background:rgba(234,179,8,.12);border-color:rgba(234,179,8,.25);color:#eab308}
|
|
115
|
+
.b-skip{background:rgba(59,130,246,.10);border-color:rgba(59,130,246,.25);color:#60a5fa}
|
|
116
|
+
.b-block{background:rgba(244,63,94,.10);border-color:rgba(244,63,94,.25);color:#fb7185}
|
|
117
|
+
.danger-tag{font-size:10px;color:#fb7185;margin-left:4px}
|
|
118
|
+
.critical-tag{font-size:10px;color:#f59e0b;background:rgba(245,158,11,.15);padding:2px 6px;border-radius:4px;margin-left:4px}
|
|
119
|
+
.err{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:12px;color:#fca5a5;padding:8px 0;border-bottom:1px solid #171a24}
|
|
120
|
+
.err:last-child{border-bottom:none}
|
|
121
|
+
a{color:#60a5fa;text-decoration:none}
|
|
122
|
+
a:hover{text-decoration:underline}
|
|
123
|
+
.footer{margin-top:20px;padding-top:16px;border-top:1px solid #222634;text-align:center}
|
|
124
|
+
</style>
|
|
125
|
+
</head>
|
|
126
|
+
<body>
|
|
127
|
+
<div class="wrap">
|
|
128
|
+
<div class="top">
|
|
129
|
+
<div>
|
|
130
|
+
<div class="title">🔍 Reality Mode Report</div>
|
|
131
|
+
<div class="dim">${esc(results.meta?.baseUrl)} • ${esc(results.meta?.startedAt)} • ${Math.round((results.duration || 0)/1000)}s</div>
|
|
132
|
+
</div>
|
|
133
|
+
<div class="score">
|
|
134
|
+
<div class="num">${score}</div>
|
|
135
|
+
<div class="meta">
|
|
136
|
+
<div><b>Grade:</b> ${grade}</div>
|
|
137
|
+
<div class="dim">${esc(verdict)}</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div class="grid">
|
|
143
|
+
<div class="stat"><div class="dim">Routes Working</div><div class="v">${cov.routesWorking || 0}/${cov.routesDiscovered || 0}</div></div>
|
|
144
|
+
<div class="stat"><div class="dim">Elements Working</div><div class="v">${cov.elementsWorking || 0}/${cov.elementsDiscovered || 0}</div></div>
|
|
145
|
+
<div class="stat"><div class="dim">Forms Discovered</div><div class="v">${cov.formsDiscovered || 0}</div></div>
|
|
146
|
+
<div class="stat"><div class="dim">Flows Executed</div><div class="v">${(results.flows || []).length}</div></div>
|
|
147
|
+
<div class="stat"><div class="dim">Errors Captured</div><div class="v">${(results.errors || []).length}</div></div>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
${flowsHtml || `<div class="card"><div class="card-h"><div class="t">Flows</div></div><div style="padding:14px 16px" class="dim">No flows ran. Add flow packs to .vibecheck/flows/ or use --flows-dir</div></div>`}
|
|
151
|
+
|
|
152
|
+
${(results.routes || []).length ? `
|
|
153
|
+
<div class="card">
|
|
154
|
+
<div class="card-h"><div class="t">Routes Discovered</div><span class="dim">${(results.routes || []).length}</span></div>
|
|
155
|
+
<div style="padding:0 16px;max-height:300px;overflow-y:auto">${routesHtml}</div>
|
|
156
|
+
</div>` : ""}
|
|
157
|
+
|
|
158
|
+
${(results.errors || []).length ? `
|
|
159
|
+
<div class="card">
|
|
160
|
+
<div class="card-h"><div class="t">Errors</div>${badge("error")}</div>
|
|
161
|
+
<div style="padding:0 16px;max-height:250px;overflow-y:auto">${errHtml}</div>
|
|
162
|
+
</div>` : ""}
|
|
163
|
+
|
|
164
|
+
<div class="footer dim">
|
|
165
|
+
Generated by vibecheck Reality Mode • <a href="https://vibecheckai.dev">vibecheckai.dev</a>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</body>
|
|
169
|
+
</html>`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function writeTimelineHtml(results) {
|
|
173
|
+
const items = (results.timeline || []).map((t, idx) => `
|
|
174
|
+
<div class="it ${esc(t.status)}">
|
|
175
|
+
<div class="h">
|
|
176
|
+
<div class="num">${idx + 1}</div>
|
|
177
|
+
<div class="info">
|
|
178
|
+
<div><b>${esc(t.flowId)}</b> • step ${esc(t.step)} • <span class="action">${esc(t.action)}</span> <span class="dim">${esc(t.name)}</span></div>
|
|
179
|
+
<div class="dim">${esc(t.url)}</div>
|
|
180
|
+
</div>
|
|
181
|
+
<div>${badge(t.status)}</div>
|
|
182
|
+
</div>
|
|
183
|
+
<div class="shots">
|
|
184
|
+
${t.before ? `<a href="${esc(t.before)}" target="_blank">📷 before</a>` : ""}
|
|
185
|
+
${t.after ? `<a href="${esc(t.after)}" target="_blank">📷 after</a>` : ""}
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
`).join("");
|
|
189
|
+
|
|
190
|
+
return `<!doctype html>
|
|
191
|
+
<html lang="en">
|
|
192
|
+
<head>
|
|
193
|
+
<meta charset="utf-8"/>
|
|
194
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
195
|
+
<title>Reality Timeline - vibecheck</title>
|
|
196
|
+
<style>
|
|
197
|
+
*{box-sizing:border-box}
|
|
198
|
+
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#0b0b0f;color:#eaeaf0;line-height:1.5}
|
|
199
|
+
.wrap{max-width:1100px;margin:0 auto;padding:24px}
|
|
200
|
+
h2{margin:0 0 8px 0;font-size:20px}
|
|
201
|
+
.dim{color:#9aa0aa;font-size:12px}
|
|
202
|
+
.it{background:#0f1118;border:1px solid #222634;border-radius:14px;padding:12px 14px;margin-top:10px}
|
|
203
|
+
.h{display:flex;gap:12px;align-items:center}
|
|
204
|
+
.num{width:28px;height:28px;background:#1e2130;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800;flex-shrink:0}
|
|
205
|
+
.info{flex:1;min-width:0}
|
|
206
|
+
.action{color:#60a5fa}
|
|
207
|
+
.shots{margin-top:8px;font-size:12px;padding-left:40px}
|
|
208
|
+
a{color:#60a5fa;margin-right:12px;text-decoration:none}
|
|
209
|
+
a:hover{text-decoration:underline}
|
|
210
|
+
.b{font-size:10px;font-weight:800;padding:2px 6px;border-radius:999px;text-transform:uppercase}
|
|
211
|
+
.b-ok{background:rgba(34,197,94,.12);color:#22c55e}
|
|
212
|
+
.b-bad{background:rgba(239,68,68,.12);color:#ef4444}
|
|
213
|
+
.b-warn{background:rgba(234,179,8,.12);color:#eab308}
|
|
214
|
+
.b-skip{background:rgba(59,130,246,.10);color:#60a5fa}
|
|
215
|
+
.b-block{background:rgba(244,63,94,.10);color:#fb7185}
|
|
216
|
+
</style>
|
|
217
|
+
</head>
|
|
218
|
+
<body>
|
|
219
|
+
<div class="wrap">
|
|
220
|
+
<h2>🧭 Reality Timeline</h2>
|
|
221
|
+
<div class="dim" style="margin-bottom:16px">${esc(results.meta?.baseUrl)} • ${esc(results.meta?.startedAt)} • ${(results.timeline || []).length} steps</div>
|
|
222
|
+
${items || `<div class="dim">No timeline items recorded.</div>`}
|
|
223
|
+
</div>
|
|
224
|
+
</body>
|
|
225
|
+
</html>`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function writeJUnitXml(results) {
|
|
229
|
+
const ts = new Date().toISOString();
|
|
230
|
+
const flows = results.flows || [];
|
|
231
|
+
let tests = 0;
|
|
232
|
+
let failures = 0;
|
|
233
|
+
|
|
234
|
+
let cases = "";
|
|
235
|
+
|
|
236
|
+
for (const f of flows) {
|
|
237
|
+
for (const s of (f.steps || [])) {
|
|
238
|
+
tests++;
|
|
239
|
+
const name = `Step: ${f.id} / ${s.action} ${s.name || ""}`.trim();
|
|
240
|
+
if (s.status === "error" || s.status === "blocked") {
|
|
241
|
+
failures++;
|
|
242
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.steps" time="${((s.durationMs || 0) / 1000).toFixed(2)}">
|
|
243
|
+
<failure message="${esc(s.error || s.status)}">${esc(s.error || s.status)}</failure>
|
|
244
|
+
</testcase>\n`;
|
|
245
|
+
} else {
|
|
246
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.steps" time="${((s.durationMs || 0) / 1000).toFixed(2)}"/>\n`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
for (const a of (f.assertions || [])) {
|
|
251
|
+
if (a.status === "skip") continue;
|
|
252
|
+
tests++;
|
|
253
|
+
const name = `Assert: ${f.id} / ${a.type}`;
|
|
254
|
+
if (a.status === "fail") {
|
|
255
|
+
failures++;
|
|
256
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.assertions">
|
|
257
|
+
<failure message="${esc(a.message)}">${esc(a.message)}</failure>
|
|
258
|
+
</testcase>\n`;
|
|
259
|
+
} else {
|
|
260
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.assertions"/>\n`;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Routes as test cases
|
|
266
|
+
for (const r of (results.routes || [])) {
|
|
267
|
+
tests++;
|
|
268
|
+
const name = `Route: ${r.path}`;
|
|
269
|
+
if (r.status !== "success") {
|
|
270
|
+
failures++;
|
|
271
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.routes">
|
|
272
|
+
<failure message="HTTP ${r.httpStatus || 0}">${esc(r.error || `HTTP ${r.httpStatus}`)}</failure>
|
|
273
|
+
</testcase>\n`;
|
|
274
|
+
} else {
|
|
275
|
+
cases += ` <testcase name="${esc(name)}" classname="reality.routes"/>\n`;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
280
|
+
<testsuites name="vibecheck Reality Mode" tests="${tests}" failures="${failures}" timestamp="${ts}" time="${((results.duration || 0) / 1000).toFixed(2)}">
|
|
281
|
+
<testsuite name="Reality Explorer" tests="${tests}" failures="${failures}" time="${((results.duration || 0) / 1000).toFixed(2)}">
|
|
282
|
+
<properties>
|
|
283
|
+
<property name="score" value="${results.score || 0}"/>
|
|
284
|
+
<property name="baseUrl" value="${esc(results.meta?.baseUrl || "")}"/>
|
|
285
|
+
</properties>
|
|
286
|
+
${cases} </testsuite>
|
|
287
|
+
</testsuites>`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function writeSarif(results, baseUrl) {
|
|
291
|
+
const sarifResults = [];
|
|
292
|
+
const rules = new Map();
|
|
293
|
+
|
|
294
|
+
function addRule(id, name, level) {
|
|
295
|
+
if (rules.has(id)) return;
|
|
296
|
+
rules.set(id, {
|
|
297
|
+
id,
|
|
298
|
+
shortDescription: { text: name },
|
|
299
|
+
fullDescription: { text: name },
|
|
300
|
+
defaultConfiguration: { level },
|
|
301
|
+
helpUri: "https://vibecheckai.dev/docs/reality-mode",
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Step failures
|
|
306
|
+
for (const f of (results.flows || [])) {
|
|
307
|
+
for (const s of (f.steps || [])) {
|
|
308
|
+
if (s.status === "error" || s.status === "blocked") {
|
|
309
|
+
addRule("reality/step-failed", "Flow step failed", "warning");
|
|
310
|
+
sarifResults.push({
|
|
311
|
+
ruleId: "reality/step-failed",
|
|
312
|
+
level: "warning",
|
|
313
|
+
message: { text: `${f.id}: ${s.action} failed - ${s.error || s.status}` },
|
|
314
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl } } }],
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
for (const a of (f.assertions || [])) {
|
|
320
|
+
if (a.status === "fail") {
|
|
321
|
+
const level = a.critical ? "error" : "warning";
|
|
322
|
+
addRule("reality/assertion-failed", "Assertion failed", level);
|
|
323
|
+
sarifResults.push({
|
|
324
|
+
ruleId: "reality/assertion-failed",
|
|
325
|
+
level,
|
|
326
|
+
message: { text: `${f.id}: ${a.type} - ${a.message}` },
|
|
327
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl } } }],
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Route errors
|
|
334
|
+
for (const r of (results.routes || [])) {
|
|
335
|
+
if (r.status !== "success") {
|
|
336
|
+
addRule("reality/route-error", "Route error", "warning");
|
|
337
|
+
sarifResults.push({
|
|
338
|
+
ruleId: "reality/route-error",
|
|
339
|
+
level: "warning",
|
|
340
|
+
message: { text: `Route ${r.path} failed: HTTP ${r.httpStatus || 0}` },
|
|
341
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: baseUrl + (r.path || "") } } }],
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Console/page errors
|
|
347
|
+
for (const e of (results.errors || [])) {
|
|
348
|
+
addRule("reality/runtime-error", "Runtime error detected", "error");
|
|
349
|
+
sarifResults.push({
|
|
350
|
+
ruleId: "reality/runtime-error",
|
|
351
|
+
level: "error",
|
|
352
|
+
message: { text: `[${e.type}] ${e.message}` },
|
|
353
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: e.url || baseUrl } } }],
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
|
|
359
|
+
version: "2.1.0",
|
|
360
|
+
runs: [{
|
|
361
|
+
tool: {
|
|
362
|
+
driver: {
|
|
363
|
+
name: "vibecheck Reality Mode",
|
|
364
|
+
version: "2.0.0",
|
|
365
|
+
informationUri: "https://vibecheckai.dev",
|
|
366
|
+
rules: Array.from(rules.values()),
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
results: sarifResults,
|
|
370
|
+
invocations: [{
|
|
371
|
+
executionSuccessful: sarifResults.filter(r => r.level === "error").length === 0,
|
|
372
|
+
endTimeUtc: new Date().toISOString(),
|
|
373
|
+
}],
|
|
374
|
+
}],
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
module.exports = { writeHtmlReport, writeTimelineHtml, writeJUnitXml, writeSarif };
|