@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
@@ -0,0 +1,604 @@
1
+ /**
2
+ * Unified CLI Output - Enterprise-Grade Terminal Experience
3
+ *
4
+ * ═══════════════════════════════════════════════════════════════════════════════
5
+ * VIBECHECK DESIGN SYSTEM
6
+ * ═══════════════════════════════════════════════════════════════════════════════
7
+ *
8
+ * This module provides consistent, professional output formatting for all CLI
9
+ * commands. Use these functions to ensure a unified enterprise-grade experience.
10
+ */
11
+
12
+ "use strict";
13
+
14
+ const { getApiKey } = require("./auth");
15
+
16
+ // ═══════════════════════════════════════════════════════════════════════════════
17
+ // CONSTANTS
18
+ // ═══════════════════════════════════════════════════════════════════════════════
19
+
20
+ const WIDTH = 72;
21
+ const SUPPORTS_COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
22
+ const SUPPORTS_UNICODE = !process.env.NO_UNICODE && process.platform !== "win32" || process.env.WT_SESSION;
23
+
24
+ // ═══════════════════════════════════════════════════════════════════════════════
25
+ // ANSI CODES
26
+ // ═══════════════════════════════════════════════════════════════════════════════
27
+
28
+ const ESC = "\x1b";
29
+ const ansi = SUPPORTS_COLOR ? {
30
+ reset: `${ESC}[0m`,
31
+ bold: `${ESC}[1m`,
32
+ dim: `${ESC}[2m`,
33
+ italic: `${ESC}[3m`,
34
+ underline: `${ESC}[4m`,
35
+ red: `${ESC}[31m`,
36
+ green: `${ESC}[32m`,
37
+ yellow: `${ESC}[33m`,
38
+ blue: `${ESC}[34m`,
39
+ magenta: `${ESC}[35m`,
40
+ cyan: `${ESC}[36m`,
41
+ white: `${ESC}[37m`,
42
+ gray: `${ESC}[90m`,
43
+ bgGreen: `${ESC}[42m`,
44
+ bgRed: `${ESC}[41m`,
45
+ bgYellow: `${ESC}[43m`,
46
+ bgCyan: `${ESC}[46m`,
47
+ bgMagenta: `${ESC}[45m`,
48
+ } : Object.fromEntries([
49
+ "reset", "bold", "dim", "italic", "underline",
50
+ "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray",
51
+ "bgGreen", "bgRed", "bgYellow", "bgCyan", "bgMagenta"
52
+ ].map(k => [k, ""]));
53
+
54
+ // ═══════════════════════════════════════════════════════════════════════════════
55
+ // SYMBOLS
56
+ // ═══════════════════════════════════════════════════════════════════════════════
57
+
58
+ const sym = SUPPORTS_UNICODE ? {
59
+ check: "✓",
60
+ cross: "✗",
61
+ warning: "⚠",
62
+ info: "ℹ",
63
+ arrow: "→",
64
+ bullet: "•",
65
+ star: "★",
66
+ rocket: "🚀",
67
+ shield: "🛡️",
68
+ lock: "🔒",
69
+ key: "🔑",
70
+ gear: "⚙",
71
+ search: "🔍",
72
+ chart: "📊",
73
+ file: "📄",
74
+ folder: "📁",
75
+ clock: "⏱",
76
+ lightning: "⚡",
77
+ sparkle: "✨",
78
+ fire: "🔥",
79
+ target: "🎯",
80
+ trophy: "🏆",
81
+ box: {
82
+ tl: "╔", tr: "╗", bl: "╚", br: "╝", h: "═", v: "║",
83
+ ltl: "┌", ltr: "┐", lbl: "└", lbr: "┘", lh: "─", lv: "│",
84
+ lt: "┬", lb: "┴", lx: "┼", ltrT: "├", ltlT: "┤",
85
+ },
86
+ } : {
87
+ check: "+",
88
+ cross: "x",
89
+ warning: "!",
90
+ info: "i",
91
+ arrow: "->",
92
+ bullet: "*",
93
+ star: "*",
94
+ rocket: ">",
95
+ shield: "[S]",
96
+ lock: "[L]",
97
+ key: "[K]",
98
+ gear: "[G]",
99
+ search: "[?]",
100
+ chart: "[C]",
101
+ file: "[F]",
102
+ folder: "[D]",
103
+ clock: "[T]",
104
+ lightning: "[!]",
105
+ sparkle: "*",
106
+ fire: "(!)",
107
+ target: "(>)",
108
+ trophy: "[W]",
109
+ box: {
110
+ tl: "+", tr: "+", bl: "+", br: "+", h: "-", v: "|",
111
+ ltl: "+", ltr: "+", lbl: "+", lbr: "+", lh: "-", lv: "|",
112
+ lt: "+", lb: "+", lx: "+", ltrT: "+", ltlT: "+",
113
+ },
114
+ };
115
+
116
+ // ═══════════════════════════════════════════════════════════════════════════════
117
+ // TIER BADGES
118
+ // ═══════════════════════════════════════════════════════════════════════════════
119
+
120
+ const TIER = {
121
+ free: { label: "FREE", color: ansi.green, bg: ansi.bgGreen },
122
+ starter: { label: "STARTER", color: ansi.cyan, bg: ansi.bgCyan },
123
+ pro: { label: "PRO", color: ansi.magenta, bg: ansi.bgMagenta },
124
+ complete: { label: "COMPLETE", color: ansi.yellow, bg: ansi.bgYellow },
125
+ };
126
+
127
+ function getTierBadge(tier) {
128
+ const t = TIER[tier] || TIER.free;
129
+ return `${t.color}[${t.label}]${ansi.reset}`;
130
+ }
131
+
132
+ function getTierFromKey() {
133
+ const { key } = getApiKey();
134
+ if (!key) return "free";
135
+ // Simplified tier detection - in real app would check entitlements
136
+ return "starter";
137
+ }
138
+
139
+ // ═══════════════════════════════════════════════════════════════════════════════
140
+ // UTILITY FUNCTIONS
141
+ // ═══════════════════════════════════════════════════════════════════════════════
142
+
143
+ function stripAnsi(str) {
144
+ return str.replace(/\x1b\[\d+m/g, "").replace(/\x1b\[38;2;\d+;\d+;\d+m/g, "");
145
+ }
146
+
147
+ function padCenter(str, width = WIDTH) {
148
+ const len = stripAnsi(str).length;
149
+ const padding = Math.max(0, width - len);
150
+ const left = Math.floor(padding / 2);
151
+ return " ".repeat(left) + str + " ".repeat(padding - left);
152
+ }
153
+
154
+ function padRight(str, width) {
155
+ const len = stripAnsi(str).length;
156
+ return str + " ".repeat(Math.max(0, width - len));
157
+ }
158
+
159
+ function truncate(str, maxLen) {
160
+ const clean = stripAnsi(str);
161
+ if (clean.length <= maxLen) return str;
162
+ return clean.slice(0, maxLen - 3) + "...";
163
+ }
164
+
165
+ function formatDuration(ms) {
166
+ if (ms < 1000) return `${ms}ms`;
167
+ if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
168
+ return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
169
+ }
170
+
171
+ // ═══════════════════════════════════════════════════════════════════════════════
172
+ // HEADER / BANNER
173
+ // ═══════════════════════════════════════════════════════════════════════════════
174
+
175
+ /**
176
+ * Render a compact enterprise header for any command
177
+ * @param {object} opts - Header options
178
+ * @param {string} opts.command - Command name (e.g., "scan", "ship")
179
+ * @param {string} opts.title - Title text
180
+ * @param {string} opts.tier - Tier requirement (free, starter, pro)
181
+ * @param {string} [opts.subtitle] - Optional subtitle
182
+ */
183
+ function renderHeader(opts) {
184
+ const { command, title, tier = "free", subtitle } = opts;
185
+ const tierBadge = getTierBadge(tier);
186
+ const b = sym.box;
187
+
188
+ const lines = [];
189
+
190
+ // Top border
191
+ lines.push(`${ansi.gray}${b.tl}${b.h.repeat(WIDTH - 2)}${b.tr}${ansi.reset}`);
192
+
193
+ // Title line
194
+ const titleStr = `${ansi.bold}${title}${ansi.reset} ${tierBadge}`;
195
+ lines.push(`${ansi.gray}${b.v}${ansi.reset}${padCenter(titleStr, WIDTH - 2)}${ansi.gray}${b.v}${ansi.reset}`);
196
+
197
+ // Subtitle if provided
198
+ if (subtitle) {
199
+ const subStr = `${ansi.dim}${subtitle}${ansi.reset}`;
200
+ lines.push(`${ansi.gray}${b.v}${ansi.reset}${padCenter(subStr, WIDTH - 2)}${ansi.gray}${b.v}${ansi.reset}`);
201
+ }
202
+
203
+ // Bottom border
204
+ lines.push(`${ansi.gray}${b.bl}${b.h.repeat(WIDTH - 2)}${b.br}${ansi.reset}`);
205
+
206
+ console.log(lines.join("\n"));
207
+ }
208
+
209
+ /**
210
+ * Render a minimal header (single line)
211
+ */
212
+ function renderMinimalHeader(command, tier = "free") {
213
+ const tierBadge = getTierBadge(tier);
214
+ console.log(`\n ${ansi.bold}vibecheck ${command}${ansi.reset} ${tierBadge}\n`);
215
+ }
216
+
217
+ // ═══════════════════════════════════════════════════════════════════════════════
218
+ // SECTION DIVIDERS
219
+ // ═══════════════════════════════════════════════════════════════════════════════
220
+
221
+ function renderDivider(style = "single") {
222
+ const char = style === "double" ? sym.box.h : sym.box.lh;
223
+ console.log(` ${ansi.gray}${char.repeat(WIDTH - 4)}${ansi.reset}`);
224
+ }
225
+
226
+ function renderSectionHeader(title, icon = sym.bullet) {
227
+ console.log(`\n ${ansi.cyan}${icon}${ansi.reset} ${ansi.bold}${title}${ansi.reset}`);
228
+ console.log(` ${ansi.gray}${sym.box.lh.repeat(WIDTH - 4)}${ansi.reset}`);
229
+ }
230
+
231
+ // ═══════════════════════════════════════════════════════════════════════════════
232
+ // STATUS INDICATORS
233
+ // ═══════════════════════════════════════════════════════════════════════════════
234
+
235
+ function renderSuccess(message) {
236
+ console.log(` ${ansi.green}${sym.check}${ansi.reset} ${message}`);
237
+ }
238
+
239
+ function renderError(message) {
240
+ console.log(` ${ansi.red}${sym.cross}${ansi.reset} ${message}`);
241
+ }
242
+
243
+ function renderWarning(message) {
244
+ console.log(` ${ansi.yellow}${sym.warning}${ansi.reset} ${message}`);
245
+ }
246
+
247
+ function renderInfo(message) {
248
+ console.log(` ${ansi.cyan}${sym.info}${ansi.reset} ${message}`);
249
+ }
250
+
251
+ function renderBullet(message, indent = 2) {
252
+ console.log(`${" ".repeat(indent)}${ansi.gray}${sym.bullet}${ansi.reset} ${message}`);
253
+ }
254
+
255
+ function renderStep(number, message, status = "pending") {
256
+ const statusIcon = status === "done" ? `${ansi.green}${sym.check}${ansi.reset}` :
257
+ status === "error" ? `${ansi.red}${sym.cross}${ansi.reset}` :
258
+ status === "running" ? `${ansi.cyan}${sym.gear}${ansi.reset}` :
259
+ `${ansi.gray}${number}${ansi.reset}`;
260
+ console.log(` ${statusIcon} ${message}`);
261
+ }
262
+
263
+ // ═══════════════════════════════════════════════════════════════════════════════
264
+ // VERDICT / RESULT BOX
265
+ // ═══════════════════════════════════════════════════════════════════════════════
266
+
267
+ /**
268
+ * Render a verdict box (SHIP/WARN/BLOCK)
269
+ * @param {string} verdict - SHIP, WARN, or BLOCK
270
+ * @param {object} [stats] - Optional statistics
271
+ */
272
+ function renderVerdict(verdict, stats = {}) {
273
+ const b = sym.box;
274
+ const v = String(verdict).toUpperCase();
275
+
276
+ let bg, icon, label;
277
+ switch (v) {
278
+ case "SHIP":
279
+ case "PASS":
280
+ case "SUCCESS":
281
+ bg = ansi.bgGreen;
282
+ icon = sym.rocket;
283
+ label = "SHIP";
284
+ break;
285
+ case "WARN":
286
+ case "WARNING":
287
+ bg = ansi.bgYellow;
288
+ icon = sym.warning;
289
+ label = "WARN";
290
+ break;
291
+ case "BLOCK":
292
+ case "FAIL":
293
+ case "ERROR":
294
+ bg = ansi.bgRed;
295
+ icon = sym.cross;
296
+ label = "BLOCK";
297
+ break;
298
+ default:
299
+ bg = ansi.bgCyan;
300
+ icon = sym.info;
301
+ label = v;
302
+ }
303
+
304
+ console.log();
305
+ console.log(` ${ansi.gray}${b.tl}${b.h.repeat(WIDTH - 6)}${b.tr}${ansi.reset}`);
306
+
307
+ // Verdict line
308
+ const verdictStr = `${bg}${ansi.bold}${ansi.white} ${icon} ${label} ${ansi.reset}`;
309
+ console.log(` ${ansi.gray}${b.v}${ansi.reset}${padCenter(verdictStr, WIDTH - 4)}${ansi.gray}${b.v}${ansi.reset}`);
310
+
311
+ // Stats line if provided
312
+ if (stats.findings !== undefined || stats.duration !== undefined) {
313
+ const parts = [];
314
+ if (stats.critical !== undefined) parts.push(`${ansi.red}${stats.critical} critical${ansi.reset}`);
315
+ if (stats.warnings !== undefined) parts.push(`${ansi.yellow}${stats.warnings} warnings${ansi.reset}`);
316
+ if (stats.findings !== undefined && stats.critical === undefined) parts.push(`${stats.findings} findings`);
317
+ if (stats.duration !== undefined) parts.push(`${ansi.dim}${formatDuration(stats.duration)}${ansi.reset}`);
318
+
319
+ const statsStr = parts.join(` ${ansi.gray}${sym.bullet}${ansi.reset} `);
320
+ console.log(` ${ansi.gray}${b.v}${ansi.reset}${padCenter(statsStr, WIDTH - 4)}${ansi.gray}${b.v}${ansi.reset}`);
321
+ }
322
+
323
+ console.log(` ${ansi.gray}${b.bl}${b.h.repeat(WIDTH - 6)}${b.br}${ansi.reset}`);
324
+ console.log();
325
+ }
326
+
327
+ // ═══════════════════════════════════════════════════════════════════════════════
328
+ // FINDINGS TABLE
329
+ // ═══════════════════════════════════════════════════════════════════════════════
330
+
331
+ /**
332
+ * Render a findings table
333
+ * @param {Array} findings - Array of finding objects
334
+ * @param {object} opts - Options
335
+ * @param {number} [opts.limit=5] - Max findings to show
336
+ */
337
+ function renderFindingsTable(findings, opts = {}) {
338
+ const { limit = 5 } = opts;
339
+ const b = sym.box;
340
+
341
+ if (!findings || findings.length === 0) {
342
+ console.log(` ${ansi.green}${sym.check}${ansi.reset} ${ansi.dim}No issues found${ansi.reset}`);
343
+ return;
344
+ }
345
+
346
+ const COL1 = 10; // Severity
347
+ const COL2 = 18; // Category
348
+ const COL3 = WIDTH - COL1 - COL2 - 12; // Message
349
+
350
+ // Header
351
+ console.log(` ${ansi.gray}${b.ltl}${b.lh.repeat(COL1)}${b.lt}${b.lh.repeat(COL2)}${b.lt}${b.lh.repeat(COL3)}${b.ltr}${ansi.reset}`);
352
+ console.log(` ${ansi.gray}${b.lv}${ansi.reset}${ansi.bold}${padRight(" SEVERITY", COL1)}${ansi.reset}${ansi.gray}${b.lv}${ansi.reset}${ansi.bold}${padRight(" CATEGORY", COL2)}${ansi.reset}${ansi.gray}${b.lv}${ansi.reset}${ansi.bold}${padRight(" MESSAGE", COL3)}${ansi.reset}${ansi.gray}${b.lv}${ansi.reset}`);
353
+ console.log(` ${ansi.gray}${b.ltrT}${b.lh.repeat(COL1)}${b.lx}${b.lh.repeat(COL2)}${b.lx}${b.lh.repeat(COL3)}${b.ltlT}${ansi.reset}`);
354
+
355
+ // Rows
356
+ const shown = findings.slice(0, limit);
357
+ for (const f of shown) {
358
+ const sev = f.severity?.toUpperCase() || "INFO";
359
+ let sevStr;
360
+ switch (sev) {
361
+ case "BLOCK":
362
+ case "CRITICAL":
363
+ sevStr = `${ansi.red} ${sym.cross} BLOCK${ansi.reset}`;
364
+ break;
365
+ case "WARN":
366
+ case "WARNING":
367
+ case "HIGH":
368
+ sevStr = `${ansi.yellow} ${sym.warning} WARN${ansi.reset}`;
369
+ break;
370
+ default:
371
+ sevStr = `${ansi.gray} ${sym.info} INFO${ansi.reset}`;
372
+ }
373
+
374
+ const cat = truncate(f.category || f.type || "General", COL2 - 1);
375
+ const msg = truncate(f.message || f.title || f.id || "", COL3 - 1);
376
+
377
+ console.log(` ${ansi.gray}${b.lv}${ansi.reset}${padRight(sevStr, COL1 + 9)}${ansi.gray}${b.lv}${ansi.reset}${padRight(" " + cat, COL2)}${ansi.gray}${b.lv}${ansi.reset}${padRight(" " + msg, COL3)}${ansi.gray}${b.lv}${ansi.reset}`);
378
+ }
379
+
380
+ // Footer
381
+ console.log(` ${ansi.gray}${b.lbl}${b.lh.repeat(COL1)}${b.lb}${b.lh.repeat(COL2)}${b.lb}${b.lh.repeat(COL3)}${b.lbr}${ansi.reset}`);
382
+
383
+ // More indicator
384
+ if (findings.length > limit) {
385
+ console.log(` ${ansi.dim}... and ${findings.length - limit} more findings${ansi.reset}`);
386
+ }
387
+ }
388
+
389
+ // ═══════════════════════════════════════════════════════════════════════════════
390
+ // KEY-VALUE LIST
391
+ // ═══════════════════════════════════════════════════════════════════════════════
392
+
393
+ /**
394
+ * Render a key-value list
395
+ * @param {Array<{label: string, value: string}>} items
396
+ */
397
+ function renderKeyValue(items) {
398
+ const maxLabel = Math.max(...items.map(i => stripAnsi(i.label).length));
399
+
400
+ for (const item of items) {
401
+ const label = padRight(item.label, maxLabel);
402
+ console.log(` ${ansi.dim}${label}${ansi.reset} ${item.value}`);
403
+ }
404
+ }
405
+
406
+ // ═══════════════════════════════════════════════════════════════════════════════
407
+ // PROGRESS BAR
408
+ // ═══════════════════════════════════════════════════════════════════════════════
409
+
410
+ function renderProgressBar(percent, width = 20) {
411
+ const filled = Math.round((percent / 100) * width);
412
+ const empty = width - filled;
413
+
414
+ let color = ansi.green;
415
+ if (percent < 50) color = ansi.red;
416
+ else if (percent < 80) color = ansi.yellow;
417
+
418
+ return `${color}${"█".repeat(filled)}${ansi.gray}${"░".repeat(empty)}${ansi.reset}`;
419
+ }
420
+
421
+ function renderScore(score, label = "Score") {
422
+ const bar = renderProgressBar(score);
423
+ console.log(` ${ansi.dim}${label}:${ansi.reset} [${bar}] ${score}/100`);
424
+ }
425
+
426
+ // ═══════════════════════════════════════════════════════════════════════════════
427
+ // FOOTER / NEXT STEPS
428
+ // ═══════════════════════════════════════════════════════════════════════════════
429
+
430
+ /**
431
+ * Render footer with next steps and optional upsell
432
+ * @param {object} opts
433
+ * @param {Array<{cmd: string, desc: string}>} [opts.nextSteps]
434
+ * @param {string} [opts.docsUrl]
435
+ * @param {boolean} [opts.showUpsell]
436
+ */
437
+ function renderFooter(opts = {}) {
438
+ const { nextSteps = [], docsUrl, showUpsell = true } = opts;
439
+ const currentTier = getTierFromKey();
440
+
441
+ console.log();
442
+ renderDivider();
443
+
444
+ // Next steps
445
+ if (nextSteps.length > 0) {
446
+ console.log(`\n ${ansi.bold}${sym.arrow} Next steps${ansi.reset}`);
447
+ for (const step of nextSteps) {
448
+ console.log(` ${ansi.cyan}${step.cmd}${ansi.reset} ${ansi.dim}${step.desc}${ansi.reset}`);
449
+ }
450
+ }
451
+
452
+ // Upsell for free tier
453
+ if (showUpsell && currentTier === "free") {
454
+ console.log();
455
+ console.log(` ${ansi.dim}${sym.star}${ansi.reset} ${ansi.cyan}STARTER${ansi.reset}${ansi.dim}: dashboard sync + auto-fix + team features${ansi.reset}`);
456
+ console.log(` ${ansi.dim} Upgrade ${sym.arrow} https://vibecheckai.dev${ansi.reset}`);
457
+ }
458
+
459
+ // Docs link
460
+ if (docsUrl) {
461
+ console.log();
462
+ console.log(` ${ansi.dim}Docs: ${docsUrl}${ansi.reset}`);
463
+ }
464
+
465
+ console.log();
466
+ }
467
+
468
+ // ═══════════════════════════════════════════════════════════════════════════════
469
+ // SPINNER
470
+ // ═══════════════════════════════════════════════════════════════════════════════
471
+
472
+ const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
473
+
474
+ class Spinner {
475
+ constructor(text = "") {
476
+ this.text = text;
477
+ this.timer = null;
478
+ this.frame = 0;
479
+ }
480
+
481
+ start(text) {
482
+ if (text) this.text = text;
483
+ if (!process.stdout.isTTY) {
484
+ console.log(` ${ansi.cyan}${sym.gear}${ansi.reset} ${this.text}...`);
485
+ return this;
486
+ }
487
+
488
+ process.stdout.write("\x1b[?25l"); // Hide cursor
489
+ this.timer = setInterval(() => {
490
+ const f = SPINNER_FRAMES[this.frame % SPINNER_FRAMES.length];
491
+ process.stdout.write(`\r ${ansi.cyan}${f}${ansi.reset} ${this.text}`);
492
+ this.frame++;
493
+ }, 80);
494
+ return this;
495
+ }
496
+
497
+ stop(finalIcon, finalColor, finalText) {
498
+ if (this.timer) {
499
+ clearInterval(this.timer);
500
+ this.timer = null;
501
+ }
502
+
503
+ if (process.stdout.isTTY) {
504
+ process.stdout.write("\r\x1b[2K"); // Clear line
505
+ process.stdout.write("\x1b[?25h"); // Show cursor
506
+ }
507
+
508
+ if (finalText !== null) {
509
+ const icon = finalIcon || sym.check;
510
+ const color = finalColor || ansi.green;
511
+ console.log(` ${color}${icon}${ansi.reset} ${finalText || this.text}`);
512
+ }
513
+ return this;
514
+ }
515
+
516
+ succeed(text) { return this.stop(sym.check, ansi.green, text); }
517
+ fail(text) { return this.stop(sym.cross, ansi.red, text); }
518
+ warn(text) { return this.stop(sym.warning, ansi.yellow, text); }
519
+ info(text) { return this.stop(sym.info, ansi.cyan, text); }
520
+ }
521
+
522
+ // ═══════════════════════════════════════════════════════════════════════════════
523
+ // COMMAND TEMPLATES
524
+ // ═══════════════════════════════════════════════════════════════════════════════
525
+
526
+ /**
527
+ * Standard command wrapper for consistent output
528
+ * @param {object} opts
529
+ * @param {string} opts.command - Command name
530
+ * @param {string} opts.title - Title for header
531
+ * @param {string} [opts.tier] - Required tier
532
+ * @param {boolean} [opts.quiet] - Suppress non-essential output
533
+ * @param {boolean} [opts.json] - JSON output mode
534
+ * @param {Function} opts.run - The command's main logic
535
+ */
536
+ async function runCommand(opts) {
537
+ const { command, title, tier = "free", quiet = false, json = false, run } = opts;
538
+
539
+ if (json) {
540
+ // JSON mode - run silently, output only JSON
541
+ return await run();
542
+ }
543
+
544
+ if (!quiet) {
545
+ renderMinimalHeader(command, tier);
546
+ }
547
+
548
+ const result = await run();
549
+
550
+ return result;
551
+ }
552
+
553
+ // ═══════════════════════════════════════════════════════════════════════════════
554
+ // EXPORTS
555
+ // ═══════════════════════════════════════════════════════════════════════════════
556
+
557
+ module.exports = {
558
+ // Constants
559
+ WIDTH,
560
+ ansi,
561
+ sym,
562
+ TIER,
563
+
564
+ // Utilities
565
+ stripAnsi,
566
+ padCenter,
567
+ padRight,
568
+ truncate,
569
+ formatDuration,
570
+ getTierBadge,
571
+ getTierFromKey,
572
+
573
+ // Headers
574
+ renderHeader,
575
+ renderMinimalHeader,
576
+
577
+ // Dividers
578
+ renderDivider,
579
+ renderSectionHeader,
580
+
581
+ // Status
582
+ renderSuccess,
583
+ renderError,
584
+ renderWarning,
585
+ renderInfo,
586
+ renderBullet,
587
+ renderStep,
588
+
589
+ // Results
590
+ renderVerdict,
591
+ renderFindingsTable,
592
+ renderKeyValue,
593
+ renderProgressBar,
594
+ renderScore,
595
+
596
+ // Footer
597
+ renderFooter,
598
+
599
+ // Components
600
+ Spinner,
601
+
602
+ // Templates
603
+ runCommand,
604
+ };