@vibecheckai/cli 3.2.4 → 3.2.6

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 (123) hide show
  1. package/bin/.generated +25 -25
  2. package/bin/dev/run-v2-torture.js +30 -30
  3. package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -295
  4. package/bin/runners/lib/api-client.js +269 -0
  5. package/bin/runners/lib/auth-truth.js +193 -193
  6. package/bin/runners/lib/backup.js +62 -62
  7. package/bin/runners/lib/billing.js +107 -107
  8. package/bin/runners/lib/claims.js +118 -118
  9. package/bin/runners/lib/cli-ui.js +540 -540
  10. package/bin/runners/lib/contracts/auth-contract.js +202 -202
  11. package/bin/runners/lib/contracts/env-contract.js +181 -181
  12. package/bin/runners/lib/contracts/external-contract.js +206 -206
  13. package/bin/runners/lib/contracts/guard.js +168 -168
  14. package/bin/runners/lib/contracts/index.js +89 -89
  15. package/bin/runners/lib/contracts/plan-validator.js +311 -311
  16. package/bin/runners/lib/contracts/route-contract.js +199 -199
  17. package/bin/runners/lib/contracts.js +804 -804
  18. package/bin/runners/lib/detect.js +89 -89
  19. package/bin/runners/lib/doctor/autofix.js +254 -254
  20. package/bin/runners/lib/doctor/index.js +37 -37
  21. package/bin/runners/lib/doctor/modules/dependencies.js +325 -325
  22. package/bin/runners/lib/doctor/modules/index.js +46 -46
  23. package/bin/runners/lib/doctor/modules/network.js +250 -250
  24. package/bin/runners/lib/doctor/modules/project.js +312 -312
  25. package/bin/runners/lib/doctor/modules/runtime.js +224 -224
  26. package/bin/runners/lib/doctor/modules/security.js +348 -348
  27. package/bin/runners/lib/doctor/modules/system.js +213 -213
  28. package/bin/runners/lib/doctor/modules/vibecheck.js +394 -394
  29. package/bin/runners/lib/doctor/reporter.js +262 -262
  30. package/bin/runners/lib/doctor/service.js +262 -262
  31. package/bin/runners/lib/doctor/types.js +113 -113
  32. package/bin/runners/lib/doctor/ui.js +263 -263
  33. package/bin/runners/lib/doctor-v2.js +608 -608
  34. package/bin/runners/lib/drift.js +425 -425
  35. package/bin/runners/lib/enforcement.js +72 -72
  36. package/bin/runners/lib/enterprise-detect.js +603 -603
  37. package/bin/runners/lib/enterprise-init.js +942 -942
  38. package/bin/runners/lib/env-resolver.js +417 -417
  39. package/bin/runners/lib/env-template.js +66 -66
  40. package/bin/runners/lib/env.js +189 -189
  41. package/bin/runners/lib/extractors/client-calls.js +990 -990
  42. package/bin/runners/lib/extractors/fastify-route-dump.js +573 -573
  43. package/bin/runners/lib/extractors/fastify-routes.js +426 -426
  44. package/bin/runners/lib/extractors/index.js +363 -363
  45. package/bin/runners/lib/extractors/next-routes.js +524 -524
  46. package/bin/runners/lib/extractors/proof-graph.js +431 -431
  47. package/bin/runners/lib/extractors/route-matcher.js +451 -451
  48. package/bin/runners/lib/extractors/truthpack-v2.js +377 -377
  49. package/bin/runners/lib/extractors/ui-bindings.js +547 -547
  50. package/bin/runners/lib/findings-schema.js +281 -281
  51. package/bin/runners/lib/firewall-prompt.js +50 -50
  52. package/bin/runners/lib/graph/graph-builder.js +265 -265
  53. package/bin/runners/lib/graph/html-renderer.js +413 -413
  54. package/bin/runners/lib/graph/index.js +32 -32
  55. package/bin/runners/lib/graph/runtime-collector.js +215 -215
  56. package/bin/runners/lib/graph/static-extractor.js +518 -518
  57. package/bin/runners/lib/html-report.js +650 -650
  58. package/bin/runners/lib/llm.js +75 -75
  59. package/bin/runners/lib/meter.js +61 -61
  60. package/bin/runners/lib/missions/evidence.js +126 -126
  61. package/bin/runners/lib/patch.js +40 -40
  62. package/bin/runners/lib/permissions/auth-model.js +213 -213
  63. package/bin/runners/lib/permissions/idor-prover.js +205 -205
  64. package/bin/runners/lib/permissions/index.js +45 -45
  65. package/bin/runners/lib/permissions/matrix-builder.js +198 -198
  66. package/bin/runners/lib/pkgjson.js +28 -28
  67. package/bin/runners/lib/policy.js +295 -295
  68. package/bin/runners/lib/preflight.js +142 -142
  69. package/bin/runners/lib/reality/correlation-detectors.js +359 -359
  70. package/bin/runners/lib/reality/index.js +318 -318
  71. package/bin/runners/lib/reality/request-hashing.js +416 -416
  72. package/bin/runners/lib/reality/request-mapper.js +453 -453
  73. package/bin/runners/lib/reality/safety-rails.js +463 -463
  74. package/bin/runners/lib/reality/semantic-snapshot.js +408 -408
  75. package/bin/runners/lib/reality/toast-detector.js +393 -393
  76. package/bin/runners/lib/reality-findings.js +84 -84
  77. package/bin/runners/lib/receipts.js +179 -179
  78. package/bin/runners/lib/redact.js +29 -29
  79. package/bin/runners/lib/replay/capsule-manager.js +154 -154
  80. package/bin/runners/lib/replay/index.js +263 -263
  81. package/bin/runners/lib/replay/player.js +348 -348
  82. package/bin/runners/lib/replay/recorder.js +331 -331
  83. package/bin/runners/lib/report.js +135 -135
  84. package/bin/runners/lib/route-detection.js +1140 -1140
  85. package/bin/runners/lib/sandbox/index.js +59 -59
  86. package/bin/runners/lib/sandbox/proof-chain.js +399 -399
  87. package/bin/runners/lib/sandbox/sandbox-runner.js +205 -205
  88. package/bin/runners/lib/sandbox/worktree.js +174 -174
  89. package/bin/runners/lib/schema-validator.js +350 -350
  90. package/bin/runners/lib/schemas/contracts.schema.json +160 -160
  91. package/bin/runners/lib/schemas/finding.schema.json +100 -100
  92. package/bin/runners/lib/schemas/mission-pack.schema.json +206 -206
  93. package/bin/runners/lib/schemas/proof-graph.schema.json +176 -176
  94. package/bin/runners/lib/schemas/reality-report.schema.json +162 -162
  95. package/bin/runners/lib/schemas/share-pack.schema.json +180 -180
  96. package/bin/runners/lib/schemas/ship-report.schema.json +117 -117
  97. package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -303
  98. package/bin/runners/lib/schemas/validator.js +438 -438
  99. package/bin/runners/lib/score-history.js +282 -282
  100. package/bin/runners/lib/share-pack.js +239 -239
  101. package/bin/runners/lib/snippets.js +67 -67
  102. package/bin/runners/lib/upsell.js +510 -510
  103. package/bin/runners/lib/usage.js +153 -153
  104. package/bin/runners/lib/validate-patch.js +156 -156
  105. package/bin/runners/lib/verdict-engine.js +628 -628
  106. package/bin/runners/reality/engine.js +917 -917
  107. package/bin/runners/reality/flows.js +122 -122
  108. package/bin/runners/reality/report.js +378 -378
  109. package/bin/runners/reality/session.js +193 -193
  110. package/bin/runners/runAgent.d.ts +5 -0
  111. package/bin/runners/runFirewall.d.ts +5 -0
  112. package/bin/runners/runFirewallHook.d.ts +5 -0
  113. package/bin/runners/runGuard.js +168 -168
  114. package/bin/runners/runScan.js +82 -0
  115. package/bin/runners/runTruth.d.ts +5 -0
  116. package/bin/vibecheck.js +45 -20
  117. package/mcp-server/index.js +85 -0
  118. package/mcp-server/lib/api-client.js +269 -0
  119. package/mcp-server/package.json +1 -1
  120. package/mcp-server/tier-auth.js +173 -113
  121. package/mcp-server/tools/index.js +72 -72
  122. package/mcp-server/vibecheck-mcp-server-3.2.0.tgz +0 -0
  123. 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, "&lt;")
10
- .replace(/>/g, "&gt;")
11
- .replace(/"/g, "&quot;");
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, "&amp;")
9
+ .replace(/</g, "&lt;")
10
+ .replace(/>/g, "&gt;")
11
+ .replace(/"/g, "&quot;");
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 };