@vibecheckai/cli 3.2.5 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/bin/.generated +25 -25
  2. package/bin/dev/run-v2-torture.js +30 -30
  3. package/bin/registry.js +192 -5
  4. package/bin/runners/lib/__tests__/entitlements-v2.test.js +295 -295
  5. package/bin/runners/lib/agent-firewall/change-packet/builder.js +280 -6
  6. package/bin/runners/lib/agent-firewall/critic/index.js +151 -0
  7. package/bin/runners/lib/agent-firewall/critic/judge.js +432 -0
  8. package/bin/runners/lib/agent-firewall/critic/prompts.js +305 -0
  9. package/bin/runners/lib/agent-firewall/lawbook/distributor.js +465 -0
  10. package/bin/runners/lib/agent-firewall/lawbook/evaluator.js +604 -0
  11. package/bin/runners/lib/agent-firewall/lawbook/index.js +304 -0
  12. package/bin/runners/lib/agent-firewall/lawbook/registry.js +514 -0
  13. package/bin/runners/lib/agent-firewall/lawbook/schema.js +420 -0
  14. package/bin/runners/lib/agent-firewall/logger.js +141 -0
  15. package/bin/runners/lib/agent-firewall/policy/loader.js +312 -4
  16. package/bin/runners/lib/agent-firewall/policy/rules/ghost-env.js +113 -1
  17. package/bin/runners/lib/agent-firewall/policy/rules/ghost-route.js +133 -6
  18. package/bin/runners/lib/agent-firewall/proposal/extractor.js +394 -0
  19. package/bin/runners/lib/agent-firewall/proposal/index.js +212 -0
  20. package/bin/runners/lib/agent-firewall/proposal/schema.js +251 -0
  21. package/bin/runners/lib/agent-firewall/proposal/validator.js +386 -0
  22. package/bin/runners/lib/agent-firewall/reality/index.js +332 -0
  23. package/bin/runners/lib/agent-firewall/reality/state.js +625 -0
  24. package/bin/runners/lib/agent-firewall/reality/watcher.js +322 -0
  25. package/bin/runners/lib/agent-firewall/risk/index.js +173 -0
  26. package/bin/runners/lib/agent-firewall/risk/scorer.js +328 -0
  27. package/bin/runners/lib/agent-firewall/risk/thresholds.js +321 -0
  28. package/bin/runners/lib/agent-firewall/risk/vectors.js +421 -0
  29. package/bin/runners/lib/agent-firewall/simulator/diff-simulator.js +472 -0
  30. package/bin/runners/lib/agent-firewall/simulator/import-resolver.js +346 -0
  31. package/bin/runners/lib/agent-firewall/simulator/index.js +181 -0
  32. package/bin/runners/lib/agent-firewall/simulator/route-validator.js +380 -0
  33. package/bin/runners/lib/agent-firewall/time-machine/incident-correlator.js +661 -0
  34. package/bin/runners/lib/agent-firewall/time-machine/index.js +267 -0
  35. package/bin/runners/lib/agent-firewall/time-machine/replay-engine.js +436 -0
  36. package/bin/runners/lib/agent-firewall/time-machine/state-reconstructor.js +490 -0
  37. package/bin/runners/lib/agent-firewall/time-machine/timeline-builder.js +530 -0
  38. package/bin/runners/lib/analyzers.js +81 -18
  39. package/bin/runners/lib/api-client.js +269 -0
  40. package/bin/runners/lib/auth-truth.js +193 -193
  41. package/bin/runners/lib/authority-badge.js +425 -0
  42. package/bin/runners/lib/backup.js +62 -62
  43. package/bin/runners/lib/billing.js +107 -107
  44. package/bin/runners/lib/claims.js +118 -118
  45. package/bin/runners/lib/cli-output.js +7 -1
  46. package/bin/runners/lib/cli-ui.js +540 -540
  47. package/bin/runners/lib/contracts/auth-contract.js +202 -202
  48. package/bin/runners/lib/contracts/env-contract.js +181 -181
  49. package/bin/runners/lib/contracts/external-contract.js +206 -206
  50. package/bin/runners/lib/contracts/guard.js +168 -168
  51. package/bin/runners/lib/contracts/index.js +89 -89
  52. package/bin/runners/lib/contracts/plan-validator.js +311 -311
  53. package/bin/runners/lib/contracts/route-contract.js +199 -199
  54. package/bin/runners/lib/contracts.js +804 -804
  55. package/bin/runners/lib/detect.js +89 -89
  56. package/bin/runners/lib/doctor/autofix.js +254 -254
  57. package/bin/runners/lib/doctor/index.js +37 -37
  58. package/bin/runners/lib/doctor/modules/dependencies.js +325 -325
  59. package/bin/runners/lib/doctor/modules/index.js +46 -46
  60. package/bin/runners/lib/doctor/modules/network.js +250 -250
  61. package/bin/runners/lib/doctor/modules/project.js +312 -312
  62. package/bin/runners/lib/doctor/modules/runtime.js +224 -224
  63. package/bin/runners/lib/doctor/modules/security.js +348 -348
  64. package/bin/runners/lib/doctor/modules/system.js +213 -213
  65. package/bin/runners/lib/doctor/modules/vibecheck.js +394 -394
  66. package/bin/runners/lib/doctor/reporter.js +262 -262
  67. package/bin/runners/lib/doctor/service.js +262 -262
  68. package/bin/runners/lib/doctor/types.js +113 -113
  69. package/bin/runners/lib/doctor/ui.js +263 -263
  70. package/bin/runners/lib/doctor-v2.js +608 -608
  71. package/bin/runners/lib/drift.js +425 -425
  72. package/bin/runners/lib/enforcement.js +72 -72
  73. package/bin/runners/lib/enterprise-detect.js +603 -603
  74. package/bin/runners/lib/enterprise-init.js +942 -942
  75. package/bin/runners/lib/env-resolver.js +417 -417
  76. package/bin/runners/lib/env-template.js +66 -66
  77. package/bin/runners/lib/env.js +189 -189
  78. package/bin/runners/lib/error-handler.js +16 -9
  79. package/bin/runners/lib/exit-codes.js +275 -0
  80. package/bin/runners/lib/extractors/client-calls.js +990 -990
  81. package/bin/runners/lib/extractors/fastify-route-dump.js +573 -573
  82. package/bin/runners/lib/extractors/fastify-routes.js +426 -426
  83. package/bin/runners/lib/extractors/index.js +363 -363
  84. package/bin/runners/lib/extractors/next-routes.js +524 -524
  85. package/bin/runners/lib/extractors/proof-graph.js +431 -431
  86. package/bin/runners/lib/extractors/route-matcher.js +451 -451
  87. package/bin/runners/lib/extractors/truthpack-v2.js +377 -377
  88. package/bin/runners/lib/extractors/ui-bindings.js +547 -547
  89. package/bin/runners/lib/findings-schema.js +281 -281
  90. package/bin/runners/lib/firewall-prompt.js +50 -50
  91. package/bin/runners/lib/global-flags.js +37 -0
  92. package/bin/runners/lib/graph/graph-builder.js +265 -265
  93. package/bin/runners/lib/graph/html-renderer.js +413 -413
  94. package/bin/runners/lib/graph/index.js +32 -32
  95. package/bin/runners/lib/graph/runtime-collector.js +215 -215
  96. package/bin/runners/lib/graph/static-extractor.js +518 -518
  97. package/bin/runners/lib/help-formatter.js +413 -0
  98. package/bin/runners/lib/html-report.js +650 -650
  99. package/bin/runners/lib/llm.js +75 -75
  100. package/bin/runners/lib/logger.js +38 -0
  101. package/bin/runners/lib/meter.js +61 -61
  102. package/bin/runners/lib/missions/evidence.js +126 -126
  103. package/bin/runners/lib/patch.js +40 -40
  104. package/bin/runners/lib/permissions/auth-model.js +213 -213
  105. package/bin/runners/lib/permissions/idor-prover.js +205 -205
  106. package/bin/runners/lib/permissions/index.js +45 -45
  107. package/bin/runners/lib/permissions/matrix-builder.js +198 -198
  108. package/bin/runners/lib/pkgjson.js +28 -28
  109. package/bin/runners/lib/policy.js +295 -295
  110. package/bin/runners/lib/preflight.js +142 -142
  111. package/bin/runners/lib/reality/correlation-detectors.js +359 -359
  112. package/bin/runners/lib/reality/index.js +318 -318
  113. package/bin/runners/lib/reality/request-hashing.js +416 -416
  114. package/bin/runners/lib/reality/request-mapper.js +453 -453
  115. package/bin/runners/lib/reality/safety-rails.js +463 -463
  116. package/bin/runners/lib/reality/semantic-snapshot.js +408 -408
  117. package/bin/runners/lib/reality/toast-detector.js +393 -393
  118. package/bin/runners/lib/reality-findings.js +84 -84
  119. package/bin/runners/lib/receipts.js +179 -179
  120. package/bin/runners/lib/redact.js +29 -29
  121. package/bin/runners/lib/replay/capsule-manager.js +154 -154
  122. package/bin/runners/lib/replay/index.js +263 -263
  123. package/bin/runners/lib/replay/player.js +348 -348
  124. package/bin/runners/lib/replay/recorder.js +331 -331
  125. package/bin/runners/lib/report.js +135 -135
  126. package/bin/runners/lib/route-detection.js +1140 -1140
  127. package/bin/runners/lib/sandbox/index.js +59 -59
  128. package/bin/runners/lib/sandbox/proof-chain.js +399 -399
  129. package/bin/runners/lib/sandbox/sandbox-runner.js +205 -205
  130. package/bin/runners/lib/sandbox/worktree.js +174 -174
  131. package/bin/runners/lib/schema-validator.js +350 -350
  132. package/bin/runners/lib/schemas/contracts.schema.json +160 -160
  133. package/bin/runners/lib/schemas/finding.schema.json +100 -100
  134. package/bin/runners/lib/schemas/mission-pack.schema.json +206 -206
  135. package/bin/runners/lib/schemas/proof-graph.schema.json +176 -176
  136. package/bin/runners/lib/schemas/reality-report.schema.json +162 -162
  137. package/bin/runners/lib/schemas/share-pack.schema.json +180 -180
  138. package/bin/runners/lib/schemas/ship-report.schema.json +117 -117
  139. package/bin/runners/lib/schemas/truthpack-v2.schema.json +303 -303
  140. package/bin/runners/lib/schemas/validator.js +438 -438
  141. package/bin/runners/lib/score-history.js +282 -282
  142. package/bin/runners/lib/share-pack.js +239 -239
  143. package/bin/runners/lib/snippets.js +67 -67
  144. package/bin/runners/lib/unified-cli-output.js +604 -0
  145. package/bin/runners/lib/upsell.js +658 -510
  146. package/bin/runners/lib/usage.js +153 -153
  147. package/bin/runners/lib/validate-patch.js +156 -156
  148. package/bin/runners/lib/verdict-engine.js +628 -628
  149. package/bin/runners/reality/engine.js +917 -917
  150. package/bin/runners/reality/flows.js +122 -122
  151. package/bin/runners/reality/report.js +378 -378
  152. package/bin/runners/reality/session.js +193 -193
  153. package/bin/runners/runAgent.d.ts +5 -0
  154. package/bin/runners/runApprove.js +1200 -0
  155. package/bin/runners/runAuth.js +324 -95
  156. package/bin/runners/runCheckpoint.js +39 -21
  157. package/bin/runners/runClassify.js +859 -0
  158. package/bin/runners/runContext.js +136 -24
  159. package/bin/runners/runDoctor.js +108 -68
  160. package/bin/runners/runFirewall.d.ts +5 -0
  161. package/bin/runners/runFirewallHook.d.ts +5 -0
  162. package/bin/runners/runFix.js +6 -5
  163. package/bin/runners/runGuard.js +262 -168
  164. package/bin/runners/runInit.js +3 -2
  165. package/bin/runners/runMcp.js +130 -52
  166. package/bin/runners/runPolish.js +43 -20
  167. package/bin/runners/runProve.js +1 -2
  168. package/bin/runners/runReport.js +3 -2
  169. package/bin/runners/runScan.js +145 -44
  170. package/bin/runners/runShip.js +3 -4
  171. package/bin/runners/runTruth.d.ts +5 -0
  172. package/bin/runners/runValidate.js +19 -2
  173. package/bin/runners/runWatch.js +104 -53
  174. package/bin/vibecheck.js +106 -19
  175. package/mcp-server/HARDENING_SUMMARY.md +299 -0
  176. package/mcp-server/agent-firewall-interceptor.js +367 -31
  177. package/mcp-server/authority-tools.js +569 -0
  178. package/mcp-server/conductor/conflict-resolver.js +588 -0
  179. package/mcp-server/conductor/execution-planner.js +544 -0
  180. package/mcp-server/conductor/index.js +377 -0
  181. package/mcp-server/conductor/lock-manager.js +615 -0
  182. package/mcp-server/conductor/request-queue.js +550 -0
  183. package/mcp-server/conductor/session-manager.js +500 -0
  184. package/mcp-server/conductor/tools.js +510 -0
  185. package/mcp-server/index.js +1199 -208
  186. package/mcp-server/lib/api-client.cjs +305 -0
  187. package/mcp-server/lib/logger.cjs +30 -0
  188. package/mcp-server/logger.js +173 -0
  189. package/mcp-server/package.json +2 -2
  190. package/mcp-server/premium-tools.js +2 -2
  191. package/mcp-server/tier-auth.js +351 -136
  192. package/mcp-server/tools/index.js +72 -72
  193. package/mcp-server/truth-firewall-tools.js +145 -15
  194. package/mcp-server/vibecheck-tools.js +2 -2
  195. package/package.json +2 -3
  196. package/mcp-server/index.old.js +0 -4137
  197. package/mcp-server/package-lock.json +0 -165
@@ -1,650 +1,650 @@
1
- /**
2
- * HTML Report Generator v3
3
- *
4
- * Generates beautiful, interactive HTML proof pages from ship reports.
5
- * Features: Dark/light theme, SVG gauges, keyboard nav, glassmorphism UI.
6
- */
7
-
8
- "use strict";
9
-
10
- const fs = require("fs");
11
- const path = require("path");
12
-
13
- // =============================================================================
14
- // LOGO (embedded as base64)
15
- // =============================================================================
16
-
17
- function getLogoBase64() {
18
- try {
19
- const logoPath = path.join(__dirname, "assets", "vibecheck-logo.png");
20
- if (fs.existsSync(logoPath)) {
21
- const logoBuffer = fs.readFileSync(logoPath);
22
- return `data:image/png;base64,${logoBuffer.toString("base64")}`;
23
- }
24
- } catch (e) {
25
- // Fallback to emoji if logo not found
26
- }
27
- return null;
28
- }
29
-
30
- // =============================================================================
31
- // HELPERS
32
- // =============================================================================
33
-
34
- function escapeHtml(str) {
35
- if (!str) return "";
36
- return String(str)
37
- .replace(/&/g, "&")
38
- .replace(/</g, "&lt;")
39
- .replace(/>/g, "&gt;")
40
- .replace(/"/g, "&quot;")
41
- .replace(/'/g, "&#039;");
42
- }
43
-
44
- function getLevel(pct) {
45
- return pct >= 80 ? "high" : pct >= 50 ? "medium" : "low";
46
- }
47
-
48
- // =============================================================================
49
- // SVG GAUGE RENDERER
50
- // =============================================================================
51
-
52
- function renderSVGGauge(label, value) {
53
- const pct = typeof value === "number" ? Math.round(value) : 0;
54
- const level = getLevel(pct);
55
- const circumference = 2 * Math.PI * 42;
56
-
57
- return `
58
- <div class="gauge-card">
59
- <svg class="gauge-svg" viewBox="0 0 100 100">
60
- <circle class="gauge-bg" cx="50" cy="50" r="42"/>
61
- <circle class="gauge-fill ${level}" cx="50" cy="50" r="42"
62
- data-value="${pct}"
63
- style="stroke-dasharray: ${circumference}; stroke-dashoffset: ${circumference}"/>
64
- </svg>
65
- <div class="gauge-center">
66
- <div class="gauge-value ${level}">${pct}%</div>
67
- </div>
68
- <div class="gauge-label">${escapeHtml(label)}</div>
69
- </div>
70
- `;
71
- }
72
-
73
- // =============================================================================
74
- // FINDING RENDERER
75
- // =============================================================================
76
-
77
- function renderFinding(finding, index) {
78
- const evidence = finding.evidence?.[0];
79
- const evidenceStr = evidence?.file
80
- ? `${evidence.file}${evidence.lines ? `:${evidence.lines}` : ""}`
81
- : evidence?.url || null;
82
-
83
- return `
84
- <article class="finding ${finding.severity}" tabindex="0" id="finding-${index}">
85
- <div class="finding-header">
86
- <span class="finding-category">${escapeHtml(finding.category || "unknown")}</span>
87
- <span class="finding-title">${escapeHtml(finding.title)}</span>
88
- </div>
89
- ${finding.why ? `<p class="finding-description">${escapeHtml(finding.why)}</p>` : ""}
90
- ${evidenceStr ? `
91
- <div class="finding-evidence">
92
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/></svg>
93
- <a href="vscode://file/${evidenceStr}" class="finding-evidence-link" title="Open in VS Code">${escapeHtml(evidenceStr)}</a>
94
- <button class="copy-btn" data-copy="${escapeHtml(evidenceStr)}" title="Copy path" aria-label="Copy file path">
95
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
96
- </button>
97
- </div>
98
- ` : ""}
99
- </article>
100
- `;
101
- }
102
-
103
- // =============================================================================
104
- // PROOF CHAIN RENDERER
105
- // =============================================================================
106
-
107
- function renderProofChain(blocker) {
108
- return `
109
- <div class="proof-chain">
110
- <div class="proof-chain-header">
111
- <div class="proof-chain-title">${escapeHtml(blocker.title)}</div>
112
- <span class="proof-chain-severity BLOCK">BLOCKER</span>
113
- </div>
114
- ${blocker.chain?.length > 0 ? `
115
- <div class="timeline">
116
- ${blocker.chain.map((step, i) => `
117
- ${i > 0 ? '<span class="timeline-arrow">→</span>' : ""}
118
- <div class="timeline-step">
119
- <span class="timeline-step-type">${escapeHtml(step.nodeType || "STEP")}</span>
120
- <span class="timeline-step-label">${escapeHtml(step.label || "")}</span>
121
- </div>
122
- `).join("")}
123
- </div>
124
- ` : ""}
125
- </div>
126
- `;
127
- }
128
-
129
- // =============================================================================
130
- // MAIN REPORT GENERATOR
131
- // =============================================================================
132
-
133
- function generateHTMLReport(shipReport, options = {}) {
134
- const verdict = shipReport.verdict?.status || "WARN";
135
- const verdictText = { SHIP: "Ready to Ship", WARN: "Ship with Caution", BLOCK: "Do Not Ship" }[verdict] || "Unknown";
136
- const verdictEmoji = { SHIP: "✅", WARN: "⚠️", BLOCK: "🚫" }[verdict] || "❓";
137
- const verdictSubtitle = {
138
- SHIP: "All checks passed. Safe to deploy.",
139
- WARN: "Some issues detected. Review warnings before deploying.",
140
- BLOCK: "Critical issues found. Must fix before shipping."
141
- }[verdict] || "";
142
-
143
- const stats = shipReport.stats || { total: 0, bySeverity: {} };
144
- const blockers = stats.bySeverity?.BLOCK || 0;
145
- const warnings = stats.bySeverity?.WARN || 0;
146
- const infos = stats.bySeverity?.INFO || 0;
147
-
148
- const meta = shipReport.meta || {};
149
- const date = meta.generatedAt ? new Date(meta.generatedAt).toLocaleString() : new Date().toLocaleString();
150
- const branch = meta.commit?.branch || null;
151
- const sha = meta.commit?.sha ? meta.commit.sha.slice(0, 7) : null;
152
- const duration = meta.durationMs ? (meta.durationMs / 1000).toFixed(1) + "s" : "0s";
153
-
154
- // Group findings by severity
155
- const findings = shipReport.findings || [];
156
- const blockFindings = findings.filter(f => f.severity === "BLOCK").slice(0, 50);
157
- const warnFindings = findings.filter(f => f.severity === "WARN").slice(0, 100);
158
- const infoFindings = findings.filter(f => f.severity === "INFO").slice(0, 50);
159
-
160
- // Build sections
161
- let coverageSection = "";
162
- if (shipReport.coverage) {
163
- const cov = shipReport.coverage;
164
- coverageSection = `
165
- <section class="section" id="coverage">
166
- <div class="section-header">
167
- <h2 class="section-title">
168
- <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 20V10M12 20V4M6 20v-6"/></svg></span>
169
- Coverage Metrics
170
- </h2>
171
- </div>
172
- <div class="coverage-grid">
173
- ${renderSVGGauge("Client Calls Mapped", cov.clientCallsMappedPct || 0)}
174
- ${renderSVGGauge("Runtime Requests", cov.runtimeRequestsMappedPct || 0)}
175
- ${renderSVGGauge("UI Actions Verified", cov.uiActionsVerifiedPct || 0)}
176
- ${cov.authVerifiedPct !== null && cov.authVerifiedPct !== undefined ? renderSVGGauge("Auth Routes", cov.authVerifiedPct) : ""}
177
- </div>
178
- ${cov.unmappedApiRequests?.length > 0 ? `
179
- <div style="margin-top: var(--space-5);">
180
- <button class="collapsible-trigger" aria-expanded="false" aria-controls="unmapped-list">
181
- <span class="collapsible-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg></span>
182
- <span>Unmapped API Requests (${cov.unmappedApiRequests.length})</span>
183
- </button>
184
- <div class="collapsible-content" id="unmapped-list" hidden>
185
- <div style="padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-md); margin-top: var(--space-3);">
186
- ${cov.unmappedApiRequests.slice(0, 20).map(r => `<div style="font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); padding: var(--space-1) 0;"><code>${escapeHtml(r)}</code></div>`).join("")}
187
- ${cov.unmappedApiRequests.length > 20 ? `<div style="color: var(--text-tertiary); font-size: 0.8125rem; margin-top: var(--space-2);">...and ${cov.unmappedApiRequests.length - 20} more</div>` : ""}
188
- </div>
189
- </div>
190
- </div>
191
- ` : ""}
192
- </section>
193
- `;
194
- }
195
-
196
- // Proof chains section
197
- let proofChainsSection = "";
198
- if (shipReport.proofChain?.topBlockers?.length > 0) {
199
- proofChainsSection = `
200
- <section class="section" id="proof-chains">
201
- <div class="section-header">
202
- <h2 class="section-title">
203
- <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg></span>
204
- Broken User Flows
205
- </h2>
206
- <span class="section-badge">${shipReport.proofChain.topBlockers.length} critical</span>
207
- </div>
208
- ${shipReport.proofChain.topBlockers.slice(0, 10).map(b => renderProofChain(b)).join("")}
209
- </section>
210
- `;
211
- }
212
-
213
- // Findings section
214
- let findingsSection = "";
215
- if (findings.length > 0) {
216
- findingsSection = `
217
- <section class="section" id="findings">
218
- <div class="section-header">
219
- <h2 class="section-title">
220
- <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg></span>
221
- All Findings
222
- </h2>
223
- <span class="section-badge">${stats.total} total</span>
224
- </div>
225
- <p style="color: var(--text-tertiary); font-size: 0.8125rem; margin-bottom: var(--space-4);">
226
- Use <kbd style="background: var(--bg-elevated); padding: 0.125em 0.5em; border-radius: 4px; font-family: var(--font-mono);">j</kbd> / <kbd style="background: var(--bg-elevated); padding: 0.125em 0.5em; border-radius: 4px; font-family: var(--font-mono);">k</kbd> to navigate
227
- </p>
228
- <div class="findings-list">
229
- ${blockFindings.length > 0 ? `
230
- <div class="finding-group-title error">🚫 Blockers (${blockers})</div>
231
- ${blockFindings.map((f, i) => renderFinding(f, `b${i}`)).join("")}
232
- ` : ""}
233
- ${warnFindings.length > 0 ? `
234
- <div class="finding-group-title warning">⚠️ Warnings (${warnings})</div>
235
- ${warnFindings.map((f, i) => renderFinding(f, `w${i}`)).join("")}
236
- ` : ""}
237
- ${infoFindings.length > 0 ? `
238
- <div style="margin-top: var(--space-4);">
239
- <button class="collapsible-trigger" aria-expanded="false" aria-controls="info-findings">
240
- <span class="collapsible-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg></span>
241
- <span>ℹ️ Info (${infos})</span>
242
- </button>
243
- <div class="collapsible-content" id="info-findings" hidden>
244
- <div style="margin-top: var(--space-3);">
245
- ${infoFindings.map((f, i) => renderFinding(f, `i${i}`)).join("")}
246
- </div>
247
- </div>
248
- </div>
249
- ` : ""}
250
- </div>
251
- </section>
252
- `;
253
- }
254
-
255
- // Runtime section
256
- let runtimeSection = "";
257
- if (shipReport.runtime?.ran) {
258
- const rt = shipReport.runtime;
259
- runtimeSection = `
260
- <section class="section" id="runtime">
261
- <div class="section-header">
262
- <h2 class="section-title">
263
- <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M10 8l6 4-6 4V8z"/></svg></span>
264
- Runtime Verification
265
- </h2>
266
- </div>
267
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4);">
268
- <div class="quick-stat">
269
- <div class="quick-stat-value">${rt.actionsCount || 0}</div>
270
- <div class="quick-stat-label">UI Actions</div>
271
- </div>
272
- <div class="quick-stat">
273
- <div class="quick-stat-value">${rt.requestsCount || 0}</div>
274
- <div class="quick-stat-label">API Requests</div>
275
- </div>
276
- <div class="quick-stat">
277
- <div class="quick-stat-value">${rt.toastsDetected || 0}</div>
278
- <div class="quick-stat-label">Toasts</div>
279
- </div>
280
- </div>
281
- </section>
282
- `;
283
- }
284
-
285
- // Get logo
286
- const logoBase64 = getLogoBase64();
287
- const logoHtml = logoBase64
288
- ? `<img src="${logoBase64}" alt="VibeCheck Logo" class="logo-img" />`
289
- : `<div class="logo-icon">✓</div><div class="logo-text">Vibe<span>Check</span></div>`;
290
-
291
- // Generate full HTML
292
- return `<!DOCTYPE html>
293
- <html lang="en" data-theme="dark">
294
- <head>
295
- <meta charset="UTF-8">
296
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
297
- <meta name="description" content="VibeCheck Security Report - ${verdict}">
298
- <meta name="theme-color" content="#0a0a0f">
299
- <title>VibeCheck Report • ${verdict}</title>
300
- <link rel="preconnect" href="https://fonts.googleapis.com">
301
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
302
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
303
- <style>${CSS_STYLES}</style>
304
- </head>
305
- <body>
306
- <div class="container">
307
- <header class="header">
308
- <div class="header-left">
309
- <div class="logo">
310
- ${logoHtml}
311
- </div>
312
- </div>
313
- <div class="header-actions">
314
- <button class="btn btn-ghost btn-icon" onclick="window.print()" title="Print report">
315
- <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9V2h12v7M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>
316
- </button>
317
- <div class="theme-toggle" title="Toggle theme">
318
- <input type="checkbox" id="theme-toggle" aria-label="Toggle dark/light mode">
319
- <div class="theme-toggle-icon">
320
- <span class="icon-sun"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg></span>
321
- <span class="icon-moon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span>
322
- </div>
323
- </div>
324
- </div>
325
- </header>
326
-
327
- <section class="verdict-hero">
328
- <div class="verdict-hero-content">
329
- <div class="verdict-main">
330
- <div class="verdict-badge ${verdict}">
331
- <span class="verdict-badge-icon">${verdictEmoji}</span>
332
- <span>${verdictText}</span>
333
- </div>
334
- <p class="verdict-subtitle">${verdictSubtitle}</p>
335
- <div class="verdict-meta">
336
- <span class="meta-item">
337
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg>
338
- ${date}
339
- </span>
340
- ${branch ? `<span class="meta-item"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3v12"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 01-9 9"/></svg><code>${escapeHtml(branch)}</code></span>` : ""}
341
- ${sha ? `<span class="meta-item"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="4"/><path d="M1.05 12H7m10.01 0h5.95"/></svg><code>${sha}</code></span>` : ""}
342
- <span class="meta-item">
343
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
344
- ${duration}
345
- </span>
346
- </div>
347
- </div>
348
- <div class="verdict-stats">
349
- <div class="quick-stat">
350
- <div class="quick-stat-value error">${blockers}</div>
351
- <div class="quick-stat-label">Blockers</div>
352
- </div>
353
- <div class="quick-stat">
354
- <div class="quick-stat-value warning">${warnings}</div>
355
- <div class="quick-stat-label">Warnings</div>
356
- </div>
357
- <div class="quick-stat">
358
- <div class="quick-stat-value info">${infos}</div>
359
- <div class="quick-stat-label">Info</div>
360
- </div>
361
- </div>
362
- </div>
363
- </section>
364
-
365
- ${coverageSection}
366
- ${proofChainsSection}
367
- ${findingsSection}
368
- ${runtimeSection}
369
-
370
- <footer class="footer">
371
- <div class="footer-brand">
372
- Generated by <a href="https://github.com/guardiavault-oss/Vibecheck" target="_blank" rel="noopener">VibeCheck</a>
373
- &nbsp;•&nbsp; v${meta.version || "3.0.0"}
374
- &nbsp;•&nbsp; Exit code: ${shipReport.verdict?.exitCode || 0}
375
- </div>
376
- <div class="footer-links">
377
- <a href="https://github.com/guardiavault-oss/Vibecheck" target="_blank" rel="noopener">GitHub</a>
378
- </div>
379
- </footer>
380
- </div>
381
-
382
- <div class="toast" id="toast" role="alert" aria-live="polite"></div>
383
-
384
- <script>${JS_SCRIPTS}</script>
385
- </body>
386
- </html>`;
387
- }
388
-
389
- // =============================================================================
390
- // CSS STYLES (embedded)
391
- // =============================================================================
392
-
393
- const CSS_STYLES = `
394
- :root {
395
- --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
396
- --font-mono: 'JetBrains Mono', 'Menlo', 'Monaco', monospace;
397
- --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
398
- --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;
399
- --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 9999px;
400
- --transition-fast: 150ms ease; --transition-base: 250ms ease;
401
- }
402
- [data-theme="dark"] {
403
- --bg-base: #09090b; --bg-surface: #18181b; --bg-elevated: #27272a;
404
- --border-subtle: rgba(255,255,255,0.06); --border-default: rgba(255,255,255,0.1); --border-strong: rgba(255,255,255,0.15);
405
- --text-primary: #fafafa; --text-secondary: #a1a1aa; --text-tertiary: #71717a;
406
- --accent-primary: #6366f1; --accent-primary-hover: #818cf8;
407
- --status-success: #22c55e; --status-success-bg: rgba(34,197,94,0.12); --status-success-border: rgba(34,197,94,0.25);
408
- --status-warning: #f59e0b; --status-warning-bg: rgba(245,158,11,0.12); --status-warning-border: rgba(245,158,11,0.25);
409
- --status-error: #ef4444; --status-error-bg: rgba(239,68,68,0.12); --status-error-border: rgba(239,68,68,0.25);
410
- --status-info: #3b82f6; --status-info-bg: rgba(59,130,246,0.12); --status-info-border: rgba(59,130,246,0.25);
411
- --glass-bg: rgba(24,24,27,0.7); --glass-border: rgba(255,255,255,0.08); --glass-blur: 20px;
412
- --gradient-glow: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99,102,241,0.15), transparent);
413
- --gradient-hero: linear-gradient(135deg, rgba(99,102,241,0.1) 0%, rgba(236,72,153,0.05) 100%);
414
- }
415
- [data-theme="light"] {
416
- --bg-base: #fafafa; --bg-surface: #ffffff; --bg-elevated: #f4f4f5;
417
- --border-subtle: rgba(0,0,0,0.04); --border-default: rgba(0,0,0,0.08); --border-strong: rgba(0,0,0,0.12);
418
- --text-primary: #18181b; --text-secondary: #52525b; --text-tertiary: #a1a1aa;
419
- --accent-primary: #4f46e5; --accent-primary-hover: #6366f1;
420
- --status-success: #16a34a; --status-success-bg: rgba(22,163,74,0.08); --status-success-border: rgba(22,163,74,0.2);
421
- --status-warning: #d97706; --status-warning-bg: rgba(217,119,6,0.08); --status-warning-border: rgba(217,119,6,0.2);
422
- --status-error: #dc2626; --status-error-bg: rgba(220,38,38,0.08); --status-error-border: rgba(220,38,38,0.2);
423
- --status-info: #2563eb; --status-info-bg: rgba(37,99,235,0.08); --status-info-border: rgba(37,99,235,0.2);
424
- --glass-bg: rgba(255,255,255,0.8); --glass-border: rgba(0,0,0,0.06); --glass-blur: 20px;
425
- --gradient-glow: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79,70,229,0.08), transparent);
426
- --gradient-hero: linear-gradient(135deg, rgba(79,70,229,0.05) 0%, rgba(236,72,153,0.03) 100%);
427
- }
428
- *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
429
- html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
430
- body { font-family: var(--font-sans); font-size: 15px; line-height: 1.6; color: var(--text-primary); background: var(--bg-base); min-height: 100vh; }
431
- body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 600px; background: var(--gradient-glow); pointer-events: none; z-index: -1; }
432
- a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
433
- a:hover { color: var(--accent-primary-hover); }
434
- code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-elevated); padding: 0.125em 0.375em; border-radius: var(--radius-sm); }
435
- ::selection { background: var(--accent-primary); color: white; }
436
- .container { max-width: 1200px; margin: 0 auto; padding: var(--space-6); }
437
- @media (max-width: 768px) { .container { padding: var(--space-4); } }
438
- .header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-6) 0; margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-subtle); }
439
- .header-left { display: flex; align-items: center; gap: var(--space-6); }
440
- .logo { display: flex; align-items: center; gap: var(--space-3); font-size: 1.375rem; font-weight: 700; letter-spacing: -0.025em; }
441
- .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent-primary), #ec4899); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: white; font-size: 1rem; }
442
- .logo-img { height: 72px; width: auto; object-fit: contain; }
443
- .logo-text span { background: linear-gradient(135deg, var(--accent-primary), #ec4899); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
444
- .header-actions { display: flex; align-items: center; gap: var(--space-3); }
445
- .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); font-size: 0.875rem; font-weight: 500; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; transition: all var(--transition-fast); }
446
- .btn-ghost { background: transparent; border-color: var(--border-default); color: var(--text-secondary); }
447
- .btn-ghost:hover { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text-primary); }
448
- .btn-icon { width: 36px; height: 36px; padding: 0; }
449
- .theme-toggle { position: relative; width: 36px; height: 36px; }
450
- .theme-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
451
- .theme-toggle-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
452
- .theme-toggle:hover .theme-toggle-icon { border-color: var(--border-strong); }
453
- .theme-toggle .icon-sun, .theme-toggle .icon-moon { position: absolute; transition: all var(--transition-base); }
454
- [data-theme="dark"] .icon-sun { opacity: 1; transform: rotate(0deg); }
455
- [data-theme="dark"] .icon-moon { opacity: 0; transform: rotate(-90deg); }
456
- [data-theme="light"] .icon-sun { opacity: 0; transform: rotate(90deg); }
457
- [data-theme="light"] .icon-moon { opacity: 1; transform: rotate(0deg); }
458
- .verdict-hero { position: relative; background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: var(--space-8); margin-bottom: var(--space-6); overflow: hidden; }
459
- .verdict-hero::before { content: ''; position: absolute; inset: 0; background: var(--gradient-hero); pointer-events: none; }
460
- .verdict-hero-content { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
461
- .verdict-main { flex: 1; }
462
- .verdict-badge { display: inline-flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-radius: var(--radius-full); font-size: 1.5rem; font-weight: 700; margin-bottom: var(--space-4); }
463
- .verdict-badge.SHIP { background: var(--status-success-bg); border: 1px solid var(--status-success-border); color: var(--status-success); }
464
- .verdict-badge.WARN { background: var(--status-warning-bg); border: 1px solid var(--status-warning-border); color: var(--status-warning); }
465
- .verdict-badge.BLOCK { background: var(--status-error-bg); border: 1px solid var(--status-error-border); color: var(--status-error); }
466
- .verdict-badge-icon { font-size: 1.75rem; }
467
- .verdict-subtitle { color: var(--text-secondary); font-size: 1rem; max-width: 480px; }
468
- .verdict-meta { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-5); }
469
- .meta-item { display: flex; align-items: center; gap: var(--space-2); font-size: 0.8125rem; color: var(--text-tertiary); }
470
- .meta-item code { color: var(--text-secondary); }
471
- .verdict-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
472
- .quick-stat { text-align: center; padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
473
- .quick-stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
474
- .quick-stat-value.error { color: var(--status-error); }
475
- .quick-stat-value.warning { color: var(--status-warning); }
476
- .quick-stat-value.info { color: var(--status-info); }
477
- .quick-stat-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); margin-top: var(--space-2); }
478
- @media (max-width: 768px) { .verdict-hero-content { flex-direction: column; text-align: center; } .verdict-meta { justify-content: center; } }
479
- .section { background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: var(--space-6); margin-bottom: var(--space-5); animation: fadeIn 0.5s ease-out backwards; }
480
- .section:nth-child(2) { animation-delay: 0.1s; }
481
- .section:nth-child(3) { animation-delay: 0.15s; }
482
- .section:nth-child(4) { animation-delay: 0.2s; }
483
- @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
484
- .section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
485
- .section-title { display: flex; align-items: center; gap: var(--space-3); font-size: 1.125rem; font-weight: 600; }
486
- .section-title-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border-radius: var(--radius-md); }
487
- .section-badge { font-size: 0.75rem; font-weight: 500; padding: var(--space-1) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-full); color: var(--text-secondary); }
488
- .coverage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }
489
- .gauge-card { display: flex; flex-direction: column; align-items: center; padding: var(--space-5); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); transition: all var(--transition-base); }
490
- .gauge-card:hover { border-color: var(--border-default); transform: translateY(-2px); }
491
- .gauge-svg { width: 100px; height: 100px; transform: rotate(-90deg); }
492
- .gauge-bg { fill: none; stroke: var(--border-default); stroke-width: 8; }
493
- .gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease-out; }
494
- .gauge-fill.high { stroke: var(--status-success); }
495
- .gauge-fill.medium { stroke: var(--status-warning); }
496
- .gauge-fill.low { stroke: var(--status-error); }
497
- .gauge-center { position: relative; margin-top: -85px; margin-bottom: var(--space-3); text-align: center; }
498
- .gauge-value { font-size: 1.5rem; font-weight: 700; }
499
- .gauge-value.high { color: var(--status-success); }
500
- .gauge-value.medium { color: var(--status-warning); }
501
- .gauge-value.low { color: var(--status-error); }
502
- .gauge-label { font-size: 0.75rem; color: var(--text-tertiary); text-align: center; }
503
- .proof-chain { padding: var(--space-5); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); margin-bottom: var(--space-4); transition: all var(--transition-fast); }
504
- .proof-chain:hover { border-color: var(--status-error-border); }
505
- .proof-chain-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
506
- .proof-chain-title { font-weight: 600; font-size: 0.9375rem; }
507
- .proof-chain-severity { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); background: var(--status-error-bg); color: var(--status-error); }
508
- .timeline { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
509
- .timeline-step { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-sm); font-size: 0.8125rem; }
510
- .timeline-step:hover { background: var(--bg-surface); }
511
- .timeline-step-type { font-size: 0.6875rem; color: var(--text-tertiary); text-transform: uppercase; }
512
- .timeline-step-label { color: var(--text-primary); font-weight: 500; }
513
- .timeline-arrow { color: var(--text-tertiary); font-size: 0.75rem; }
514
- .findings-list { display: flex; flex-direction: column; gap: var(--space-3); }
515
- .finding-group-title { display: flex; align-items: center; gap: var(--space-2); font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; margin-top: var(--space-4); margin-bottom: var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); }
516
- .finding-group-title:first-child { margin-top: 0; }
517
- .finding-group-title.error { color: var(--status-error); }
518
- .finding-group-title.warning { color: var(--status-warning); }
519
- .finding-group-title.info { color: var(--status-info); }
520
- .finding { padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); border-left: 3px solid var(--border-default); transition: all var(--transition-fast); }
521
- .finding:hover { border-color: var(--border-default); }
522
- .finding.BLOCK { border-left-color: var(--status-error); }
523
- .finding.WARN { border-left-color: var(--status-warning); }
524
- .finding.INFO { border-left-color: var(--status-info); }
525
- .finding-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
526
- .finding-category { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; padding: var(--space-1) var(--space-2); background: var(--bg-elevated); border-radius: var(--radius-sm); color: var(--text-tertiary); }
527
- .finding-title { font-weight: 600; font-size: 0.9375rem; }
528
- .finding-description { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: var(--space-3); }
529
- .finding-evidence { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.8125rem; }
530
- .finding-evidence-link { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
531
- .finding-evidence-link:hover { color: var(--accent-primary); }
532
- .copy-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: transparent; border: none; border-radius: var(--radius-sm); color: var(--text-tertiary); cursor: pointer; }
533
- .copy-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
534
- .copy-btn.copied { color: var(--status-success); }
535
- .collapsible-trigger { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--text-secondary); font-size: 0.875rem; cursor: pointer; width: 100%; text-align: left; }
536
- .collapsible-trigger:hover { background: var(--bg-elevated); color: var(--text-primary); }
537
- .collapsible-trigger[aria-expanded="true"] .collapsible-icon { transform: rotate(90deg); }
538
- .collapsible-icon { transition: transform var(--transition-fast); }
539
- .collapsible-content { margin-top: var(--space-3); }
540
- .collapsible-content[hidden] { display: none; }
541
- .footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-6) 0; margin-top: var(--space-8); border-top: 1px solid var(--border-subtle); font-size: 0.8125rem; color: var(--text-tertiary); }
542
- .footer-brand { display: flex; align-items: center; gap: var(--space-2); }
543
- .footer-links { display: flex; gap: var(--space-4); }
544
- .footer-links a { color: var(--text-tertiary); }
545
- .footer-links a:hover { color: var(--text-secondary); }
546
- @media (max-width: 640px) { .footer { flex-direction: column; text-align: center; } }
547
- .toast { position: fixed; bottom: var(--space-6); right: var(--space-6); padding: var(--space-3) var(--space-5); background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: 0.875rem; color: var(--text-primary); box-shadow: 0 10px 40px rgba(0,0,0,0.3); transform: translateY(100px); opacity: 0; transition: all var(--transition-base); z-index: 300; }
548
- .toast.visible { transform: translateY(0); opacity: 1; }
549
- @media print { body { background: white; color: black; } .header-actions, .theme-toggle, .copy-btn { display: none !important; } .section, .verdict-hero, .finding, .proof-chain { break-inside: avoid; background: white; border: 1px solid #ddd; } a { color: inherit; text-decoration: underline; } }
550
- `;
551
-
552
- // =============================================================================
553
- // JAVASCRIPT (embedded)
554
- // =============================================================================
555
-
556
- const JS_SCRIPTS = `
557
- const html = document.documentElement;
558
- const themeInput = document.getElementById('theme-toggle');
559
- if (themeInput) {
560
- themeInput.addEventListener('change', () => {
561
- const newTheme = themeInput.checked ? 'light' : 'dark';
562
- html.dataset.theme = newTheme;
563
- localStorage.setItem('vibecheck-theme', newTheme);
564
- });
565
- const saved = localStorage.getItem('vibecheck-theme');
566
- if (saved) { html.dataset.theme = saved; themeInput.checked = saved === 'light'; }
567
- }
568
- document.querySelectorAll('.copy-btn').forEach(btn => {
569
- btn.addEventListener('click', async () => {
570
- const text = btn.dataset.copy;
571
- try {
572
- await navigator.clipboard.writeText(text);
573
- btn.classList.add('copied');
574
- btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6L9 17l-5-5"/></svg>';
575
- showToast('Copied to clipboard');
576
- setTimeout(() => { btn.classList.remove('copied'); btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>'; }, 2000);
577
- } catch (err) { showToast('Failed to copy'); }
578
- });
579
- });
580
- document.querySelectorAll('.collapsible-trigger').forEach(trigger => {
581
- trigger.addEventListener('click', () => {
582
- const expanded = trigger.getAttribute('aria-expanded') === 'true';
583
- trigger.setAttribute('aria-expanded', !expanded);
584
- const content = document.getElementById(trigger.getAttribute('aria-controls'));
585
- if (content) content.hidden = expanded;
586
- });
587
- });
588
- function showToast(message) {
589
- const toast = document.getElementById('toast');
590
- if (toast) { toast.textContent = message; toast.classList.add('visible'); setTimeout(() => toast.classList.remove('visible'), 2500); }
591
- }
592
- let currentFinding = -1;
593
- const findings = document.querySelectorAll('.finding');
594
- document.addEventListener('keydown', (e) => {
595
- if (document.activeElement.tagName === 'INPUT') return;
596
- if (e.key === 'j' || e.key === 'k') {
597
- e.preventDefault();
598
- findings.forEach(f => f.style.outline = '');
599
- if (e.key === 'j') { currentFinding = Math.min(currentFinding + 1, findings.length - 1); }
600
- else { currentFinding = Math.max(currentFinding - 1, 0); }
601
- if (findings[currentFinding]) { findings[currentFinding].style.outline = '2px solid var(--accent-primary)'; findings[currentFinding].scrollIntoView({ behavior: 'smooth', block: 'center' }); }
602
- }
603
- });
604
- document.querySelectorAll('.gauge-fill').forEach((gauge, i) => {
605
- const target = parseFloat(gauge.dataset.value) || 0;
606
- const circumference = 2 * Math.PI * 42;
607
- const offset = circumference - (target / 100) * circumference;
608
- gauge.style.strokeDasharray = circumference;
609
- gauge.style.strokeDashoffset = circumference;
610
- setTimeout(() => { gauge.style.strokeDashoffset = offset; }, 100 + i * 100);
611
- });
612
- `;
613
-
614
- // =============================================================================
615
- // LEGACY RENDERERS (for backward compatibility)
616
- // =============================================================================
617
-
618
- function renderGauge(label, value) {
619
- return renderSVGGauge(label, value);
620
- }
621
-
622
- // =============================================================================
623
- // WRITE REPORT
624
- // =============================================================================
625
-
626
- function writeHTMLReport(repoRoot, shipReport, options = {}) {
627
- const dir = path.join(repoRoot, ".vibecheck");
628
- fs.mkdirSync(dir, { recursive: true });
629
-
630
- const html = generateHTMLReport(shipReport, options);
631
- const htmlPath = path.join(dir, "last_ship.html");
632
- fs.writeFileSync(htmlPath, html);
633
-
634
- return htmlPath;
635
- }
636
-
637
- // =============================================================================
638
- // EXPORTS
639
- // =============================================================================
640
-
641
- module.exports = {
642
- generateHTMLReport,
643
- writeHTMLReport,
644
- renderSVGGauge,
645
- renderGauge,
646
- renderFinding,
647
- renderProofChain,
648
- escapeHtml,
649
- getLevel,
650
- };
1
+ /**
2
+ * HTML Report Generator v3
3
+ *
4
+ * Generates beautiful, interactive HTML proof pages from ship reports.
5
+ * Features: Dark/light theme, SVG gauges, keyboard nav, glassmorphism UI.
6
+ */
7
+
8
+ "use strict";
9
+
10
+ const fs = require("fs");
11
+ const path = require("path");
12
+
13
+ // =============================================================================
14
+ // LOGO (embedded as base64)
15
+ // =============================================================================
16
+
17
+ function getLogoBase64() {
18
+ try {
19
+ const logoPath = path.join(__dirname, "assets", "vibecheck-logo.png");
20
+ if (fs.existsSync(logoPath)) {
21
+ const logoBuffer = fs.readFileSync(logoPath);
22
+ return `data:image/png;base64,${logoBuffer.toString("base64")}`;
23
+ }
24
+ } catch (e) {
25
+ // Fallback to emoji if logo not found
26
+ }
27
+ return null;
28
+ }
29
+
30
+ // =============================================================================
31
+ // HELPERS
32
+ // =============================================================================
33
+
34
+ function escapeHtml(str) {
35
+ if (!str) return "";
36
+ return String(str)
37
+ .replace(/&/g, "&amp;")
38
+ .replace(/</g, "&lt;")
39
+ .replace(/>/g, "&gt;")
40
+ .replace(/"/g, "&quot;")
41
+ .replace(/'/g, "&#039;");
42
+ }
43
+
44
+ function getLevel(pct) {
45
+ return pct >= 80 ? "high" : pct >= 50 ? "medium" : "low";
46
+ }
47
+
48
+ // =============================================================================
49
+ // SVG GAUGE RENDERER
50
+ // =============================================================================
51
+
52
+ function renderSVGGauge(label, value) {
53
+ const pct = typeof value === "number" ? Math.round(value) : 0;
54
+ const level = getLevel(pct);
55
+ const circumference = 2 * Math.PI * 42;
56
+
57
+ return `
58
+ <div class="gauge-card">
59
+ <svg class="gauge-svg" viewBox="0 0 100 100">
60
+ <circle class="gauge-bg" cx="50" cy="50" r="42"/>
61
+ <circle class="gauge-fill ${level}" cx="50" cy="50" r="42"
62
+ data-value="${pct}"
63
+ style="stroke-dasharray: ${circumference}; stroke-dashoffset: ${circumference}"/>
64
+ </svg>
65
+ <div class="gauge-center">
66
+ <div class="gauge-value ${level}">${pct}%</div>
67
+ </div>
68
+ <div class="gauge-label">${escapeHtml(label)}</div>
69
+ </div>
70
+ `;
71
+ }
72
+
73
+ // =============================================================================
74
+ // FINDING RENDERER
75
+ // =============================================================================
76
+
77
+ function renderFinding(finding, index) {
78
+ const evidence = finding.evidence?.[0];
79
+ const evidenceStr = evidence?.file
80
+ ? `${evidence.file}${evidence.lines ? `:${evidence.lines}` : ""}`
81
+ : evidence?.url || null;
82
+
83
+ return `
84
+ <article class="finding ${finding.severity}" tabindex="0" id="finding-${index}">
85
+ <div class="finding-header">
86
+ <span class="finding-category">${escapeHtml(finding.category || "unknown")}</span>
87
+ <span class="finding-title">${escapeHtml(finding.title)}</span>
88
+ </div>
89
+ ${finding.why ? `<p class="finding-description">${escapeHtml(finding.why)}</p>` : ""}
90
+ ${evidenceStr ? `
91
+ <div class="finding-evidence">
92
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><path d="M14 2v6h6M16 13H8M16 17H8M10 9H8"/></svg>
93
+ <a href="vscode://file/${evidenceStr}" class="finding-evidence-link" title="Open in VS Code">${escapeHtml(evidenceStr)}</a>
94
+ <button class="copy-btn" data-copy="${escapeHtml(evidenceStr)}" title="Copy path" aria-label="Copy file path">
95
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
96
+ </button>
97
+ </div>
98
+ ` : ""}
99
+ </article>
100
+ `;
101
+ }
102
+
103
+ // =============================================================================
104
+ // PROOF CHAIN RENDERER
105
+ // =============================================================================
106
+
107
+ function renderProofChain(blocker) {
108
+ return `
109
+ <div class="proof-chain">
110
+ <div class="proof-chain-header">
111
+ <div class="proof-chain-title">${escapeHtml(blocker.title)}</div>
112
+ <span class="proof-chain-severity BLOCK">BLOCKER</span>
113
+ </div>
114
+ ${blocker.chain?.length > 0 ? `
115
+ <div class="timeline">
116
+ ${blocker.chain.map((step, i) => `
117
+ ${i > 0 ? '<span class="timeline-arrow">→</span>' : ""}
118
+ <div class="timeline-step">
119
+ <span class="timeline-step-type">${escapeHtml(step.nodeType || "STEP")}</span>
120
+ <span class="timeline-step-label">${escapeHtml(step.label || "")}</span>
121
+ </div>
122
+ `).join("")}
123
+ </div>
124
+ ` : ""}
125
+ </div>
126
+ `;
127
+ }
128
+
129
+ // =============================================================================
130
+ // MAIN REPORT GENERATOR
131
+ // =============================================================================
132
+
133
+ function generateHTMLReport(shipReport, options = {}) {
134
+ const verdict = shipReport.verdict?.status || "WARN";
135
+ const verdictText = { SHIP: "Ready to Ship", WARN: "Ship with Caution", BLOCK: "Do Not Ship" }[verdict] || "Unknown";
136
+ const verdictEmoji = { SHIP: "✅", WARN: "⚠️", BLOCK: "🚫" }[verdict] || "❓";
137
+ const verdictSubtitle = {
138
+ SHIP: "All checks passed. Safe to deploy.",
139
+ WARN: "Some issues detected. Review warnings before deploying.",
140
+ BLOCK: "Critical issues found. Must fix before shipping."
141
+ }[verdict] || "";
142
+
143
+ const stats = shipReport.stats || { total: 0, bySeverity: {} };
144
+ const blockers = stats.bySeverity?.BLOCK || 0;
145
+ const warnings = stats.bySeverity?.WARN || 0;
146
+ const infos = stats.bySeverity?.INFO || 0;
147
+
148
+ const meta = shipReport.meta || {};
149
+ const date = meta.generatedAt ? new Date(meta.generatedAt).toLocaleString() : new Date().toLocaleString();
150
+ const branch = meta.commit?.branch || null;
151
+ const sha = meta.commit?.sha ? meta.commit.sha.slice(0, 7) : null;
152
+ const duration = meta.durationMs ? (meta.durationMs / 1000).toFixed(1) + "s" : "0s";
153
+
154
+ // Group findings by severity
155
+ const findings = shipReport.findings || [];
156
+ const blockFindings = findings.filter(f => f.severity === "BLOCK").slice(0, 50);
157
+ const warnFindings = findings.filter(f => f.severity === "WARN").slice(0, 100);
158
+ const infoFindings = findings.filter(f => f.severity === "INFO").slice(0, 50);
159
+
160
+ // Build sections
161
+ let coverageSection = "";
162
+ if (shipReport.coverage) {
163
+ const cov = shipReport.coverage;
164
+ coverageSection = `
165
+ <section class="section" id="coverage">
166
+ <div class="section-header">
167
+ <h2 class="section-title">
168
+ <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 20V10M12 20V4M6 20v-6"/></svg></span>
169
+ Coverage Metrics
170
+ </h2>
171
+ </div>
172
+ <div class="coverage-grid">
173
+ ${renderSVGGauge("Client Calls Mapped", cov.clientCallsMappedPct || 0)}
174
+ ${renderSVGGauge("Runtime Requests", cov.runtimeRequestsMappedPct || 0)}
175
+ ${renderSVGGauge("UI Actions Verified", cov.uiActionsVerifiedPct || 0)}
176
+ ${cov.authVerifiedPct !== null && cov.authVerifiedPct !== undefined ? renderSVGGauge("Auth Routes", cov.authVerifiedPct) : ""}
177
+ </div>
178
+ ${cov.unmappedApiRequests?.length > 0 ? `
179
+ <div style="margin-top: var(--space-5);">
180
+ <button class="collapsible-trigger" aria-expanded="false" aria-controls="unmapped-list">
181
+ <span class="collapsible-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg></span>
182
+ <span>Unmapped API Requests (${cov.unmappedApiRequests.length})</span>
183
+ </button>
184
+ <div class="collapsible-content" id="unmapped-list" hidden>
185
+ <div style="padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-md); margin-top: var(--space-3);">
186
+ ${cov.unmappedApiRequests.slice(0, 20).map(r => `<div style="font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); padding: var(--space-1) 0;"><code>${escapeHtml(r)}</code></div>`).join("")}
187
+ ${cov.unmappedApiRequests.length > 20 ? `<div style="color: var(--text-tertiary); font-size: 0.8125rem; margin-top: var(--space-2);">...and ${cov.unmappedApiRequests.length - 20} more</div>` : ""}
188
+ </div>
189
+ </div>
190
+ </div>
191
+ ` : ""}
192
+ </section>
193
+ `;
194
+ }
195
+
196
+ // Proof chains section
197
+ let proofChainsSection = "";
198
+ if (shipReport.proofChain?.topBlockers?.length > 0) {
199
+ proofChainsSection = `
200
+ <section class="section" id="proof-chains">
201
+ <div class="section-header">
202
+ <h2 class="section-title">
203
+ <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71"/></svg></span>
204
+ Broken User Flows
205
+ </h2>
206
+ <span class="section-badge">${shipReport.proofChain.topBlockers.length} critical</span>
207
+ </div>
208
+ ${shipReport.proofChain.topBlockers.slice(0, 10).map(b => renderProofChain(b)).join("")}
209
+ </section>
210
+ `;
211
+ }
212
+
213
+ // Findings section
214
+ let findingsSection = "";
215
+ if (findings.length > 0) {
216
+ findingsSection = `
217
+ <section class="section" id="findings">
218
+ <div class="section-header">
219
+ <h2 class="section-title">
220
+ <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg></span>
221
+ All Findings
222
+ </h2>
223
+ <span class="section-badge">${stats.total} total</span>
224
+ </div>
225
+ <p style="color: var(--text-tertiary); font-size: 0.8125rem; margin-bottom: var(--space-4);">
226
+ Use <kbd style="background: var(--bg-elevated); padding: 0.125em 0.5em; border-radius: 4px; font-family: var(--font-mono);">j</kbd> / <kbd style="background: var(--bg-elevated); padding: 0.125em 0.5em; border-radius: 4px; font-family: var(--font-mono);">k</kbd> to navigate
227
+ </p>
228
+ <div class="findings-list">
229
+ ${blockFindings.length > 0 ? `
230
+ <div class="finding-group-title error">🚫 Blockers (${blockers})</div>
231
+ ${blockFindings.map((f, i) => renderFinding(f, `b${i}`)).join("")}
232
+ ` : ""}
233
+ ${warnFindings.length > 0 ? `
234
+ <div class="finding-group-title warning">⚠️ Warnings (${warnings})</div>
235
+ ${warnFindings.map((f, i) => renderFinding(f, `w${i}`)).join("")}
236
+ ` : ""}
237
+ ${infoFindings.length > 0 ? `
238
+ <div style="margin-top: var(--space-4);">
239
+ <button class="collapsible-trigger" aria-expanded="false" aria-controls="info-findings">
240
+ <span class="collapsible-icon"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg></span>
241
+ <span>ℹ️ Info (${infos})</span>
242
+ </button>
243
+ <div class="collapsible-content" id="info-findings" hidden>
244
+ <div style="margin-top: var(--space-3);">
245
+ ${infoFindings.map((f, i) => renderFinding(f, `i${i}`)).join("")}
246
+ </div>
247
+ </div>
248
+ </div>
249
+ ` : ""}
250
+ </div>
251
+ </section>
252
+ `;
253
+ }
254
+
255
+ // Runtime section
256
+ let runtimeSection = "";
257
+ if (shipReport.runtime?.ran) {
258
+ const rt = shipReport.runtime;
259
+ runtimeSection = `
260
+ <section class="section" id="runtime">
261
+ <div class="section-header">
262
+ <h2 class="section-title">
263
+ <span class="section-title-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M10 8l6 4-6 4V8z"/></svg></span>
264
+ Runtime Verification
265
+ </h2>
266
+ </div>
267
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4);">
268
+ <div class="quick-stat">
269
+ <div class="quick-stat-value">${rt.actionsCount || 0}</div>
270
+ <div class="quick-stat-label">UI Actions</div>
271
+ </div>
272
+ <div class="quick-stat">
273
+ <div class="quick-stat-value">${rt.requestsCount || 0}</div>
274
+ <div class="quick-stat-label">API Requests</div>
275
+ </div>
276
+ <div class="quick-stat">
277
+ <div class="quick-stat-value">${rt.toastsDetected || 0}</div>
278
+ <div class="quick-stat-label">Toasts</div>
279
+ </div>
280
+ </div>
281
+ </section>
282
+ `;
283
+ }
284
+
285
+ // Get logo
286
+ const logoBase64 = getLogoBase64();
287
+ const logoHtml = logoBase64
288
+ ? `<img src="${logoBase64}" alt="VibeCheck Logo" class="logo-img" />`
289
+ : `<div class="logo-icon">✓</div><div class="logo-text">Vibe<span>Check</span></div>`;
290
+
291
+ // Generate full HTML
292
+ return `<!DOCTYPE html>
293
+ <html lang="en" data-theme="dark">
294
+ <head>
295
+ <meta charset="UTF-8">
296
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
297
+ <meta name="description" content="VibeCheck Security Report - ${verdict}">
298
+ <meta name="theme-color" content="#0a0a0f">
299
+ <title>VibeCheck Report • ${verdict}</title>
300
+ <link rel="preconnect" href="https://fonts.googleapis.com">
301
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
302
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
303
+ <style>${CSS_STYLES}</style>
304
+ </head>
305
+ <body>
306
+ <div class="container">
307
+ <header class="header">
308
+ <div class="header-left">
309
+ <div class="logo">
310
+ ${logoHtml}
311
+ </div>
312
+ </div>
313
+ <div class="header-actions">
314
+ <button class="btn btn-ghost btn-icon" onclick="window.print()" title="Print report">
315
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9V2h12v7M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>
316
+ </button>
317
+ <div class="theme-toggle" title="Toggle theme">
318
+ <input type="checkbox" id="theme-toggle" aria-label="Toggle dark/light mode">
319
+ <div class="theme-toggle-icon">
320
+ <span class="icon-sun"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg></span>
321
+ <span class="icon-moon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span>
322
+ </div>
323
+ </div>
324
+ </div>
325
+ </header>
326
+
327
+ <section class="verdict-hero">
328
+ <div class="verdict-hero-content">
329
+ <div class="verdict-main">
330
+ <div class="verdict-badge ${verdict}">
331
+ <span class="verdict-badge-icon">${verdictEmoji}</span>
332
+ <span>${verdictText}</span>
333
+ </div>
334
+ <p class="verdict-subtitle">${verdictSubtitle}</p>
335
+ <div class="verdict-meta">
336
+ <span class="meta-item">
337
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg>
338
+ ${date}
339
+ </span>
340
+ ${branch ? `<span class="meta-item"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 3v12"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 01-9 9"/></svg><code>${escapeHtml(branch)}</code></span>` : ""}
341
+ ${sha ? `<span class="meta-item"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="4"/><path d="M1.05 12H7m10.01 0h5.95"/></svg><code>${sha}</code></span>` : ""}
342
+ <span class="meta-item">
343
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
344
+ ${duration}
345
+ </span>
346
+ </div>
347
+ </div>
348
+ <div class="verdict-stats">
349
+ <div class="quick-stat">
350
+ <div class="quick-stat-value error">${blockers}</div>
351
+ <div class="quick-stat-label">Blockers</div>
352
+ </div>
353
+ <div class="quick-stat">
354
+ <div class="quick-stat-value warning">${warnings}</div>
355
+ <div class="quick-stat-label">Warnings</div>
356
+ </div>
357
+ <div class="quick-stat">
358
+ <div class="quick-stat-value info">${infos}</div>
359
+ <div class="quick-stat-label">Info</div>
360
+ </div>
361
+ </div>
362
+ </div>
363
+ </section>
364
+
365
+ ${coverageSection}
366
+ ${proofChainsSection}
367
+ ${findingsSection}
368
+ ${runtimeSection}
369
+
370
+ <footer class="footer">
371
+ <div class="footer-brand">
372
+ Generated by <a href="https://github.com/guardiavault-oss/Vibecheck" target="_blank" rel="noopener">VibeCheck</a>
373
+ &nbsp;•&nbsp; v${meta.version || "3.0.0"}
374
+ &nbsp;•&nbsp; Exit code: ${shipReport.verdict?.exitCode || 0}
375
+ </div>
376
+ <div class="footer-links">
377
+ <a href="https://github.com/guardiavault-oss/Vibecheck" target="_blank" rel="noopener">GitHub</a>
378
+ </div>
379
+ </footer>
380
+ </div>
381
+
382
+ <div class="toast" id="toast" role="alert" aria-live="polite"></div>
383
+
384
+ <script>${JS_SCRIPTS}</script>
385
+ </body>
386
+ </html>`;
387
+ }
388
+
389
+ // =============================================================================
390
+ // CSS STYLES (embedded)
391
+ // =============================================================================
392
+
393
+ const CSS_STYLES = `
394
+ :root {
395
+ --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
396
+ --font-mono: 'JetBrains Mono', 'Menlo', 'Monaco', monospace;
397
+ --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
398
+ --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;
399
+ --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 9999px;
400
+ --transition-fast: 150ms ease; --transition-base: 250ms ease;
401
+ }
402
+ [data-theme="dark"] {
403
+ --bg-base: #09090b; --bg-surface: #18181b; --bg-elevated: #27272a;
404
+ --border-subtle: rgba(255,255,255,0.06); --border-default: rgba(255,255,255,0.1); --border-strong: rgba(255,255,255,0.15);
405
+ --text-primary: #fafafa; --text-secondary: #a1a1aa; --text-tertiary: #71717a;
406
+ --accent-primary: #6366f1; --accent-primary-hover: #818cf8;
407
+ --status-success: #22c55e; --status-success-bg: rgba(34,197,94,0.12); --status-success-border: rgba(34,197,94,0.25);
408
+ --status-warning: #f59e0b; --status-warning-bg: rgba(245,158,11,0.12); --status-warning-border: rgba(245,158,11,0.25);
409
+ --status-error: #ef4444; --status-error-bg: rgba(239,68,68,0.12); --status-error-border: rgba(239,68,68,0.25);
410
+ --status-info: #3b82f6; --status-info-bg: rgba(59,130,246,0.12); --status-info-border: rgba(59,130,246,0.25);
411
+ --glass-bg: rgba(24,24,27,0.7); --glass-border: rgba(255,255,255,0.08); --glass-blur: 20px;
412
+ --gradient-glow: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99,102,241,0.15), transparent);
413
+ --gradient-hero: linear-gradient(135deg, rgba(99,102,241,0.1) 0%, rgba(236,72,153,0.05) 100%);
414
+ }
415
+ [data-theme="light"] {
416
+ --bg-base: #fafafa; --bg-surface: #ffffff; --bg-elevated: #f4f4f5;
417
+ --border-subtle: rgba(0,0,0,0.04); --border-default: rgba(0,0,0,0.08); --border-strong: rgba(0,0,0,0.12);
418
+ --text-primary: #18181b; --text-secondary: #52525b; --text-tertiary: #a1a1aa;
419
+ --accent-primary: #4f46e5; --accent-primary-hover: #6366f1;
420
+ --status-success: #16a34a; --status-success-bg: rgba(22,163,74,0.08); --status-success-border: rgba(22,163,74,0.2);
421
+ --status-warning: #d97706; --status-warning-bg: rgba(217,119,6,0.08); --status-warning-border: rgba(217,119,6,0.2);
422
+ --status-error: #dc2626; --status-error-bg: rgba(220,38,38,0.08); --status-error-border: rgba(220,38,38,0.2);
423
+ --status-info: #2563eb; --status-info-bg: rgba(37,99,235,0.08); --status-info-border: rgba(37,99,235,0.2);
424
+ --glass-bg: rgba(255,255,255,0.8); --glass-border: rgba(0,0,0,0.06); --glass-blur: 20px;
425
+ --gradient-glow: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79,70,229,0.08), transparent);
426
+ --gradient-hero: linear-gradient(135deg, rgba(79,70,229,0.05) 0%, rgba(236,72,153,0.03) 100%);
427
+ }
428
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
429
+ html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
430
+ body { font-family: var(--font-sans); font-size: 15px; line-height: 1.6; color: var(--text-primary); background: var(--bg-base); min-height: 100vh; }
431
+ body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 600px; background: var(--gradient-glow); pointer-events: none; z-index: -1; }
432
+ a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
433
+ a:hover { color: var(--accent-primary-hover); }
434
+ code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-elevated); padding: 0.125em 0.375em; border-radius: var(--radius-sm); }
435
+ ::selection { background: var(--accent-primary); color: white; }
436
+ .container { max-width: 1200px; margin: 0 auto; padding: var(--space-6); }
437
+ @media (max-width: 768px) { .container { padding: var(--space-4); } }
438
+ .header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-6) 0; margin-bottom: var(--space-6); border-bottom: 1px solid var(--border-subtle); }
439
+ .header-left { display: flex; align-items: center; gap: var(--space-6); }
440
+ .logo { display: flex; align-items: center; gap: var(--space-3); font-size: 1.375rem; font-weight: 700; letter-spacing: -0.025em; }
441
+ .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent-primary), #ec4899); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: white; font-size: 1rem; }
442
+ .logo-img { height: 72px; width: auto; object-fit: contain; }
443
+ .logo-text span { background: linear-gradient(135deg, var(--accent-primary), #ec4899); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
444
+ .header-actions { display: flex; align-items: center; gap: var(--space-3); }
445
+ .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); font-size: 0.875rem; font-weight: 500; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; transition: all var(--transition-fast); }
446
+ .btn-ghost { background: transparent; border-color: var(--border-default); color: var(--text-secondary); }
447
+ .btn-ghost:hover { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text-primary); }
448
+ .btn-icon { width: 36px; height: 36px; padding: 0; }
449
+ .theme-toggle { position: relative; width: 36px; height: 36px; }
450
+ .theme-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
451
+ .theme-toggle-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
452
+ .theme-toggle:hover .theme-toggle-icon { border-color: var(--border-strong); }
453
+ .theme-toggle .icon-sun, .theme-toggle .icon-moon { position: absolute; transition: all var(--transition-base); }
454
+ [data-theme="dark"] .icon-sun { opacity: 1; transform: rotate(0deg); }
455
+ [data-theme="dark"] .icon-moon { opacity: 0; transform: rotate(-90deg); }
456
+ [data-theme="light"] .icon-sun { opacity: 0; transform: rotate(90deg); }
457
+ [data-theme="light"] .icon-moon { opacity: 1; transform: rotate(0deg); }
458
+ .verdict-hero { position: relative; background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: var(--space-8); margin-bottom: var(--space-6); overflow: hidden; }
459
+ .verdict-hero::before { content: ''; position: absolute; inset: 0; background: var(--gradient-hero); pointer-events: none; }
460
+ .verdict-hero-content { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
461
+ .verdict-main { flex: 1; }
462
+ .verdict-badge { display: inline-flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-radius: var(--radius-full); font-size: 1.5rem; font-weight: 700; margin-bottom: var(--space-4); }
463
+ .verdict-badge.SHIP { background: var(--status-success-bg); border: 1px solid var(--status-success-border); color: var(--status-success); }
464
+ .verdict-badge.WARN { background: var(--status-warning-bg); border: 1px solid var(--status-warning-border); color: var(--status-warning); }
465
+ .verdict-badge.BLOCK { background: var(--status-error-bg); border: 1px solid var(--status-error-border); color: var(--status-error); }
466
+ .verdict-badge-icon { font-size: 1.75rem; }
467
+ .verdict-subtitle { color: var(--text-secondary); font-size: 1rem; max-width: 480px; }
468
+ .verdict-meta { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-5); }
469
+ .meta-item { display: flex; align-items: center; gap: var(--space-2); font-size: 0.8125rem; color: var(--text-tertiary); }
470
+ .meta-item code { color: var(--text-secondary); }
471
+ .verdict-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
472
+ .quick-stat { text-align: center; padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
473
+ .quick-stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
474
+ .quick-stat-value.error { color: var(--status-error); }
475
+ .quick-stat-value.warning { color: var(--status-warning); }
476
+ .quick-stat-value.info { color: var(--status-info); }
477
+ .quick-stat-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); margin-top: var(--space-2); }
478
+ @media (max-width: 768px) { .verdict-hero-content { flex-direction: column; text-align: center; } .verdict-meta { justify-content: center; } }
479
+ .section { background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: var(--space-6); margin-bottom: var(--space-5); animation: fadeIn 0.5s ease-out backwards; }
480
+ .section:nth-child(2) { animation-delay: 0.1s; }
481
+ .section:nth-child(3) { animation-delay: 0.15s; }
482
+ .section:nth-child(4) { animation-delay: 0.2s; }
483
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
484
+ .section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
485
+ .section-title { display: flex; align-items: center; gap: var(--space-3); font-size: 1.125rem; font-weight: 600; }
486
+ .section-title-icon { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border-radius: var(--radius-md); }
487
+ .section-badge { font-size: 0.75rem; font-weight: 500; padding: var(--space-1) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-full); color: var(--text-secondary); }
488
+ .coverage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }
489
+ .gauge-card { display: flex; flex-direction: column; align-items: center; padding: var(--space-5); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); transition: all var(--transition-base); }
490
+ .gauge-card:hover { border-color: var(--border-default); transform: translateY(-2px); }
491
+ .gauge-svg { width: 100px; height: 100px; transform: rotate(-90deg); }
492
+ .gauge-bg { fill: none; stroke: var(--border-default); stroke-width: 8; }
493
+ .gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease-out; }
494
+ .gauge-fill.high { stroke: var(--status-success); }
495
+ .gauge-fill.medium { stroke: var(--status-warning); }
496
+ .gauge-fill.low { stroke: var(--status-error); }
497
+ .gauge-center { position: relative; margin-top: -85px; margin-bottom: var(--space-3); text-align: center; }
498
+ .gauge-value { font-size: 1.5rem; font-weight: 700; }
499
+ .gauge-value.high { color: var(--status-success); }
500
+ .gauge-value.medium { color: var(--status-warning); }
501
+ .gauge-value.low { color: var(--status-error); }
502
+ .gauge-label { font-size: 0.75rem; color: var(--text-tertiary); text-align: center; }
503
+ .proof-chain { padding: var(--space-5); background: var(--bg-base); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); margin-bottom: var(--space-4); transition: all var(--transition-fast); }
504
+ .proof-chain:hover { border-color: var(--status-error-border); }
505
+ .proof-chain-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
506
+ .proof-chain-title { font-weight: 600; font-size: 0.9375rem; }
507
+ .proof-chain-severity { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); background: var(--status-error-bg); color: var(--status-error); }
508
+ .timeline { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
509
+ .timeline-step { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-sm); font-size: 0.8125rem; }
510
+ .timeline-step:hover { background: var(--bg-surface); }
511
+ .timeline-step-type { font-size: 0.6875rem; color: var(--text-tertiary); text-transform: uppercase; }
512
+ .timeline-step-label { color: var(--text-primary); font-weight: 500; }
513
+ .timeline-arrow { color: var(--text-tertiary); font-size: 0.75rem; }
514
+ .findings-list { display: flex; flex-direction: column; gap: var(--space-3); }
515
+ .finding-group-title { display: flex; align-items: center; gap: var(--space-2); font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; margin-top: var(--space-4); margin-bottom: var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); }
516
+ .finding-group-title:first-child { margin-top: 0; }
517
+ .finding-group-title.error { color: var(--status-error); }
518
+ .finding-group-title.warning { color: var(--status-warning); }
519
+ .finding-group-title.info { color: var(--status-info); }
520
+ .finding { padding: var(--space-4); background: var(--bg-base); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); border-left: 3px solid var(--border-default); transition: all var(--transition-fast); }
521
+ .finding:hover { border-color: var(--border-default); }
522
+ .finding.BLOCK { border-left-color: var(--status-error); }
523
+ .finding.WARN { border-left-color: var(--status-warning); }
524
+ .finding.INFO { border-left-color: var(--status-info); }
525
+ .finding-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
526
+ .finding-category { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; padding: var(--space-1) var(--space-2); background: var(--bg-elevated); border-radius: var(--radius-sm); color: var(--text-tertiary); }
527
+ .finding-title { font-weight: 600; font-size: 0.9375rem; }
528
+ .finding-description { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: var(--space-3); }
529
+ .finding-evidence { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--bg-elevated); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.8125rem; }
530
+ .finding-evidence-link { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
531
+ .finding-evidence-link:hover { color: var(--accent-primary); }
532
+ .copy-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: transparent; border: none; border-radius: var(--radius-sm); color: var(--text-tertiary); cursor: pointer; }
533
+ .copy-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
534
+ .copy-btn.copied { color: var(--status-success); }
535
+ .collapsible-trigger { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--text-secondary); font-size: 0.875rem; cursor: pointer; width: 100%; text-align: left; }
536
+ .collapsible-trigger:hover { background: var(--bg-elevated); color: var(--text-primary); }
537
+ .collapsible-trigger[aria-expanded="true"] .collapsible-icon { transform: rotate(90deg); }
538
+ .collapsible-icon { transition: transform var(--transition-fast); }
539
+ .collapsible-content { margin-top: var(--space-3); }
540
+ .collapsible-content[hidden] { display: none; }
541
+ .footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-6) 0; margin-top: var(--space-8); border-top: 1px solid var(--border-subtle); font-size: 0.8125rem; color: var(--text-tertiary); }
542
+ .footer-brand { display: flex; align-items: center; gap: var(--space-2); }
543
+ .footer-links { display: flex; gap: var(--space-4); }
544
+ .footer-links a { color: var(--text-tertiary); }
545
+ .footer-links a:hover { color: var(--text-secondary); }
546
+ @media (max-width: 640px) { .footer { flex-direction: column; text-align: center; } }
547
+ .toast { position: fixed; bottom: var(--space-6); right: var(--space-6); padding: var(--space-3) var(--space-5); background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: 0.875rem; color: var(--text-primary); box-shadow: 0 10px 40px rgba(0,0,0,0.3); transform: translateY(100px); opacity: 0; transition: all var(--transition-base); z-index: 300; }
548
+ .toast.visible { transform: translateY(0); opacity: 1; }
549
+ @media print { body { background: white; color: black; } .header-actions, .theme-toggle, .copy-btn { display: none !important; } .section, .verdict-hero, .finding, .proof-chain { break-inside: avoid; background: white; border: 1px solid #ddd; } a { color: inherit; text-decoration: underline; } }
550
+ `;
551
+
552
+ // =============================================================================
553
+ // JAVASCRIPT (embedded)
554
+ // =============================================================================
555
+
556
+ const JS_SCRIPTS = `
557
+ const html = document.documentElement;
558
+ const themeInput = document.getElementById('theme-toggle');
559
+ if (themeInput) {
560
+ themeInput.addEventListener('change', () => {
561
+ const newTheme = themeInput.checked ? 'light' : 'dark';
562
+ html.dataset.theme = newTheme;
563
+ localStorage.setItem('vibecheck-theme', newTheme);
564
+ });
565
+ const saved = localStorage.getItem('vibecheck-theme');
566
+ if (saved) { html.dataset.theme = saved; themeInput.checked = saved === 'light'; }
567
+ }
568
+ document.querySelectorAll('.copy-btn').forEach(btn => {
569
+ btn.addEventListener('click', async () => {
570
+ const text = btn.dataset.copy;
571
+ try {
572
+ await navigator.clipboard.writeText(text);
573
+ btn.classList.add('copied');
574
+ btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6L9 17l-5-5"/></svg>';
575
+ showToast('Copied to clipboard');
576
+ setTimeout(() => { btn.classList.remove('copied'); btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>'; }, 2000);
577
+ } catch (err) { showToast('Failed to copy'); }
578
+ });
579
+ });
580
+ document.querySelectorAll('.collapsible-trigger').forEach(trigger => {
581
+ trigger.addEventListener('click', () => {
582
+ const expanded = trigger.getAttribute('aria-expanded') === 'true';
583
+ trigger.setAttribute('aria-expanded', !expanded);
584
+ const content = document.getElementById(trigger.getAttribute('aria-controls'));
585
+ if (content) content.hidden = expanded;
586
+ });
587
+ });
588
+ function showToast(message) {
589
+ const toast = document.getElementById('toast');
590
+ if (toast) { toast.textContent = message; toast.classList.add('visible'); setTimeout(() => toast.classList.remove('visible'), 2500); }
591
+ }
592
+ let currentFinding = -1;
593
+ const findings = document.querySelectorAll('.finding');
594
+ document.addEventListener('keydown', (e) => {
595
+ if (document.activeElement.tagName === 'INPUT') return;
596
+ if (e.key === 'j' || e.key === 'k') {
597
+ e.preventDefault();
598
+ findings.forEach(f => f.style.outline = '');
599
+ if (e.key === 'j') { currentFinding = Math.min(currentFinding + 1, findings.length - 1); }
600
+ else { currentFinding = Math.max(currentFinding - 1, 0); }
601
+ if (findings[currentFinding]) { findings[currentFinding].style.outline = '2px solid var(--accent-primary)'; findings[currentFinding].scrollIntoView({ behavior: 'smooth', block: 'center' }); }
602
+ }
603
+ });
604
+ document.querySelectorAll('.gauge-fill').forEach((gauge, i) => {
605
+ const target = parseFloat(gauge.dataset.value) || 0;
606
+ const circumference = 2 * Math.PI * 42;
607
+ const offset = circumference - (target / 100) * circumference;
608
+ gauge.style.strokeDasharray = circumference;
609
+ gauge.style.strokeDashoffset = circumference;
610
+ setTimeout(() => { gauge.style.strokeDashoffset = offset; }, 100 + i * 100);
611
+ });
612
+ `;
613
+
614
+ // =============================================================================
615
+ // LEGACY RENDERERS (for backward compatibility)
616
+ // =============================================================================
617
+
618
+ function renderGauge(label, value) {
619
+ return renderSVGGauge(label, value);
620
+ }
621
+
622
+ // =============================================================================
623
+ // WRITE REPORT
624
+ // =============================================================================
625
+
626
+ function writeHTMLReport(repoRoot, shipReport, options = {}) {
627
+ const dir = path.join(repoRoot, ".vibecheck");
628
+ fs.mkdirSync(dir, { recursive: true });
629
+
630
+ const html = generateHTMLReport(shipReport, options);
631
+ const htmlPath = path.join(dir, "last_ship.html");
632
+ fs.writeFileSync(htmlPath, html);
633
+
634
+ return htmlPath;
635
+ }
636
+
637
+ // =============================================================================
638
+ // EXPORTS
639
+ // =============================================================================
640
+
641
+ module.exports = {
642
+ generateHTMLReport,
643
+ writeHTMLReport,
644
+ renderSVGGauge,
645
+ renderGauge,
646
+ renderFinding,
647
+ renderProofChain,
648
+ escapeHtml,
649
+ getLevel,
650
+ };