vibecode-anything 0.3.0 → 0.4.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 (160) hide show
  1. package/README.md +239 -67
  2. package/dist/cli.js +2140 -73
  3. package/dist/core/adapters.d.ts +26 -3
  4. package/dist/core/adapters.js +411 -25
  5. package/dist/core/agent-adapter.d.ts +67 -0
  6. package/dist/core/agent-adapter.js +312 -0
  7. package/dist/core/anti-cheat.d.ts +6 -0
  8. package/dist/core/anti-cheat.js +372 -0
  9. package/dist/core/badge.d.ts +18 -0
  10. package/dist/core/badge.js +360 -0
  11. package/dist/core/cache.d.ts +47 -0
  12. package/dist/core/cache.js +403 -0
  13. package/dist/core/ci-export.d.ts +35 -0
  14. package/dist/core/ci-export.js +796 -0
  15. package/dist/core/ci-formats.d.ts +21 -0
  16. package/dist/core/ci-formats.js +388 -0
  17. package/dist/core/client-codegen.d.ts +36 -0
  18. package/dist/core/client-codegen.js +2538 -0
  19. package/dist/core/compose.d.ts +71 -0
  20. package/dist/core/compose.js +1088 -0
  21. package/dist/core/docs-export.d.ts +37 -0
  22. package/dist/core/docs-export.js +2706 -0
  23. package/dist/core/doctor.d.ts +21 -1
  24. package/dist/core/doctor.js +234 -21
  25. package/dist/core/exec.d.ts +26 -2
  26. package/dist/core/exec.js +235 -8
  27. package/dist/core/fixtures.d.ts +153 -0
  28. package/dist/core/fixtures.js +2245 -0
  29. package/dist/core/format.d.ts +77 -0
  30. package/dist/core/format.js +632 -0
  31. package/dist/core/fs-snapshot.d.ts +37 -0
  32. package/dist/core/fs-snapshot.js +216 -0
  33. package/dist/core/graphql-export.d.ts +34 -0
  34. package/dist/core/graphql-export.js +2482 -0
  35. package/dist/core/har-export.d.ts +29 -0
  36. package/dist/core/har-export.js +988 -0
  37. package/dist/core/html-report.d.ts +27 -0
  38. package/dist/core/html-report.js +1535 -0
  39. package/dist/core/http-export.d.ts +31 -0
  40. package/dist/core/http-export.js +726 -0
  41. package/dist/core/impact.d.ts +80 -0
  42. package/dist/core/impact.js +1412 -0
  43. package/dist/core/lint.d.ts +38 -0
  44. package/dist/core/lint.js +1111 -0
  45. package/dist/core/load-export.d.ts +37 -0
  46. package/dist/core/load-export.js +1813 -0
  47. package/dist/core/mcp-export.d.ts +35 -0
  48. package/dist/core/mcp-export.js +1736 -0
  49. package/dist/core/mock-server.d.ts +47 -0
  50. package/dist/core/mock-server.js +1722 -0
  51. package/dist/core/openapi-export.d.ts +44 -0
  52. package/dist/core/openapi-export.js +1074 -0
  53. package/dist/core/parity.d.ts +6 -1
  54. package/dist/core/parity.js +36 -1
  55. package/dist/core/playwright-exporter.d.ts +23 -0
  56. package/dist/core/playwright-exporter.js +1343 -0
  57. package/dist/core/png.js +45 -9
  58. package/dist/core/regression.d.ts +54 -0
  59. package/dist/core/regression.js +529 -0
  60. package/dist/core/responsive.d.ts +86 -0
  61. package/dist/core/responsive.js +606 -0
  62. package/dist/core/run.d.ts +74 -0
  63. package/dist/core/run.js +696 -0
  64. package/dist/core/scheduler.d.ts +24 -0
  65. package/dist/core/scheduler.js +162 -0
  66. package/dist/core/schema-export.d.ts +29 -0
  67. package/dist/core/schema-export.js +2215 -0
  68. package/dist/core/schema.d.ts +3 -2
  69. package/dist/core/schema.js +460 -17
  70. package/dist/core/security.d.ts +233 -0
  71. package/dist/core/security.js +1839 -0
  72. package/dist/core/server-export.d.ts +38 -0
  73. package/dist/core/server-export.js +3198 -0
  74. package/dist/core/spec-writer.d.ts +9 -0
  75. package/dist/core/spec-writer.js +1202 -0
  76. package/dist/core/store.d.ts +11 -2
  77. package/dist/core/store.js +128 -8
  78. package/dist/core/target-map.d.ts +34 -0
  79. package/dist/core/target-map.js +262 -0
  80. package/dist/core/test-exporter.d.ts +25 -0
  81. package/dist/core/test-exporter.js +1918 -0
  82. package/dist/core/types.d.ts +182 -14
  83. package/dist/core/visual-semantic.d.ts +67 -0
  84. package/dist/core/visual-semantic.js +673 -0
  85. package/dist/core/visual.js +65 -16
  86. package/dist/core/watch.d.ts +28 -3
  87. package/dist/core/watch.js +222 -12
  88. package/dist/core/yaml.d.ts +5 -0
  89. package/dist/core/yaml.js +1009 -0
  90. package/dist/diagnostics/diagnose.d.ts +53 -0
  91. package/dist/diagnostics/diagnose.js +1083 -0
  92. package/dist/diagnostics/flake.d.ts +71 -0
  93. package/dist/diagnostics/flake.js +608 -0
  94. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  95. package/dist/diagnostics/mutation-audit.js +769 -0
  96. package/dist/diagnostics/spatial.d.ts +42 -0
  97. package/dist/diagnostics/spatial.js +346 -0
  98. package/dist/diagnostics/trends.d.ts +122 -0
  99. package/dist/diagnostics/trends.js +1190 -0
  100. package/dist/discovery/discover.d.ts +111 -0
  101. package/dist/discovery/discover.js +2017 -0
  102. package/dist/discovery/lock.d.ts +116 -0
  103. package/dist/discovery/lock.js +1505 -0
  104. package/dist/discovery/routes.d.ts +36 -0
  105. package/dist/discovery/routes.js +1494 -0
  106. package/dist/discovery/test-importer.d.ts +92 -0
  107. package/dist/discovery/test-importer.js +4952 -0
  108. package/dist/index.d.ts +123 -0
  109. package/dist/index.js +99 -0
  110. package/dist/ingestors/api-collections.d.ts +28 -0
  111. package/dist/ingestors/api-collections.js +2335 -0
  112. package/dist/ingestors/api-repo.d.ts +2 -1
  113. package/dist/ingestors/api-repo.js +483 -85
  114. package/dist/ingestors/asyncapi.d.ts +26 -0
  115. package/dist/ingestors/asyncapi.js +2105 -0
  116. package/dist/ingestors/bridges.d.ts +2 -0
  117. package/dist/ingestors/bridges.js +702 -0
  118. package/dist/ingestors/cli.d.ts +2 -1
  119. package/dist/ingestors/cli.js +234 -46
  120. package/dist/ingestors/curl.d.ts +14 -0
  121. package/dist/ingestors/curl.js +1024 -0
  122. package/dist/ingestors/graphql.d.ts +56 -0
  123. package/dist/ingestors/graphql.js +1852 -0
  124. package/dist/ingestors/http-file.d.ts +20 -0
  125. package/dist/ingestors/http-file.js +923 -0
  126. package/dist/ingestors/index.js +486 -6
  127. package/dist/ingestors/openrpc.d.ts +29 -0
  128. package/dist/ingestors/openrpc.js +1807 -0
  129. package/dist/ingestors/proto.d.ts +47 -0
  130. package/dist/ingestors/proto.js +2690 -0
  131. package/dist/ingestors/trace.d.ts +10 -0
  132. package/dist/ingestors/trace.js +599 -0
  133. package/dist/ingestors/video.d.ts +4 -1
  134. package/dist/ingestors/video.js +86 -36
  135. package/dist/ingestors/web.d.ts +16 -1
  136. package/dist/ingestors/web.js +474 -32
  137. package/dist/mcp/server.js +3532 -67
  138. package/dist/oracles/api-repo.js +102 -30
  139. package/dist/oracles/cli.js +65 -17
  140. package/dist/oracles/http-workflow.d.ts +68 -0
  141. package/dist/oracles/http-workflow.js +828 -0
  142. package/dist/oracles/image.js +178 -28
  143. package/dist/oracles/index.d.ts +3 -1
  144. package/dist/oracles/index.js +243 -14
  145. package/dist/oracles/perf-budget.d.ts +90 -0
  146. package/dist/oracles/perf-budget.js +1329 -0
  147. package/dist/oracles/stream.d.ts +94 -0
  148. package/dist/oracles/stream.js +1268 -0
  149. package/dist/oracles/ui-states.d.ts +49 -0
  150. package/dist/oracles/ui-states.js +894 -0
  151. package/dist/oracles/video.d.ts +1 -1
  152. package/dist/oracles/video.js +232 -16
  153. package/dist/oracles/web.js +464 -73
  154. package/dist/plugins/builtins.d.ts +12 -0
  155. package/dist/plugins/builtins.js +1052 -0
  156. package/dist/plugins/registry.d.ts +86 -0
  157. package/dist/plugins/registry.js +554 -0
  158. package/dist/setup/index.js +145 -33
  159. package/package.json +56 -47
  160. package/skills/vibecode-anything/SKILL.md +75 -52
@@ -0,0 +1,632 @@
1
+ /**
2
+ * Zero-dependency terminal summary formatter for `--pretty` CLI output.
3
+ */
4
+ const ANSI = {
5
+ reset: "\x1b[0m",
6
+ bold: "\x1b[1m",
7
+ dim: "\x1b[2m",
8
+ red: "\x1b[31m",
9
+ green: "\x1b[32m",
10
+ yellow: "\x1b[33m",
11
+ cyan: "\x1b[36m"
12
+ };
13
+ const MAX_LISTED_INVARIANTS = 10;
14
+ const MAX_DIFF_LINES = 40;
15
+ const MAX_DIFF_ITEMS = 15;
16
+ const MAX_JSON_DIFF_LINES = 24;
17
+ const BAR_WIDTH = 10;
18
+ // Patterns for defense-in-depth sanitization of visible repro/failure/diff lines.
19
+ const VAULT_DIR_RE = /[^\s"'`<>()[\]{}]*\.vibecode-vault[^\s"'`<>()[\]{}]*/gi;
20
+ const VAULT_PATH_RE = /(?:[A-Za-z]:\\|\/|\.?\.?[\\/])[^\s"'`<>()[\]{}]*holdouts?(?:-[a-f0-9]+)?\.json/gi;
21
+ const URL_CREDENTIALS_RE = /(https?:\/\/)([^:@\s"'`<>\/]+:[^@\s"'`<>\/]+)(@)/gi;
22
+ const SENSITIVE_QUERY_PARAM_RE = /([?&](?:access_token|id_token|refresh_token|token|api[_-]?key|apikey|secret|password|passwd|auth|jwt|session[_-]?id|sig|signature)=)([^&#\s"'`<>]+)/gi;
23
+ const SENSITIVE_COOKIE_RE = /(["']?\b(?:set-cookie|cookie)\b["']?\s*[:=]\s*["']?)([^\r\n"'`}]+)/gi;
24
+ const SENSITIVE_JSON_FIELD_RE = /(["']\b(?:authorization|proxy-authorization|x-api-key|x-auth-token|api[_-]?key|apikey|secret|client[_-]?secret|token|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token|password|passwd|private[_-]?key|session[_-]?id)\b["']\s*[:=]\s*["'])([^"'\r\n]+)(["'])/gi;
25
+ const SENSITIVE_HEADER_VALUE_RE = /(\b(?:authorization|proxy-authorization|x-api-key|x-auth-token|api[_-]?key|apikey)\b\s*[:=]\s*)(?:"[^"]*"|'[^']*'|(?:(?:bearer|basic|token|digest|apikey)\s+)?[^\s'",;})&#]+)/gi;
26
+ const BEARER_TOKEN_RE = /(\bBearer\s+)([A-Za-z0-9._~+/=-]{6,})/gi;
27
+ const SENSITIVE_KEY_RE = /^(?:authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token|api[-_]?key|apikey|secret|client[-_]?secret|password|passwd|token|jwt|access[-_]?token|refresh[-_]?token|id[-_]?token|private[-_]?key|session[-_]?id)$/i;
28
+ function style(text, codes, useColor) {
29
+ return useColor ? `${codes}${text}${ANSI.reset}` : text;
30
+ }
31
+ function clamp01(value) {
32
+ if (!Number.isFinite(value))
33
+ return 0;
34
+ return Math.max(0, Math.min(1, value));
35
+ }
36
+ function formatPercent(ratio) {
37
+ return `${(clamp01(ratio) * 100).toFixed(1)}%`;
38
+ }
39
+ function renderProgressBar(ratio, useColor) {
40
+ const clamped = clamp01(ratio);
41
+ const filled = Math.round(clamped * BAR_WIDTH);
42
+ const bar = `[${"#".repeat(filled)}${".".repeat(BAR_WIDTH - filled)}]`;
43
+ if (!useColor)
44
+ return bar;
45
+ const tone = clamped >= 1 ? ANSI.green : clamped >= 0.7 ? ANSI.yellow : ANSI.red;
46
+ return style(bar, tone, true);
47
+ }
48
+ function gateBannerText(status) {
49
+ switch (status) {
50
+ case "pass":
51
+ return "PASS";
52
+ case "pass_with_warnings":
53
+ return "PASS WITH WARNINGS";
54
+ case "fail":
55
+ return "FAIL";
56
+ case "incomplete":
57
+ return "INCOMPLETE";
58
+ }
59
+ }
60
+ function gateBannerColor(status) {
61
+ switch (status) {
62
+ case "pass":
63
+ return `${ANSI.bold}${ANSI.green}`;
64
+ case "pass_with_warnings":
65
+ return `${ANSI.bold}${ANSI.yellow}`;
66
+ case "fail":
67
+ return `${ANSI.bold}${ANSI.red}`;
68
+ case "incomplete":
69
+ return `${ANSI.bold}${ANSI.yellow}`;
70
+ }
71
+ }
72
+ function sanitizeText(text) {
73
+ return text
74
+ .replace(VAULT_DIR_RE, "[REDACTED_VAULT]")
75
+ .replace(VAULT_PATH_RE, "[REDACTED_VAULT]")
76
+ .replace(URL_CREDENTIALS_RE, "$1[REDACTED]$3")
77
+ .replace(SENSITIVE_QUERY_PARAM_RE, "$1[REDACTED]")
78
+ .replace(SENSITIVE_COOKIE_RE, "$1[REDACTED]")
79
+ .replace(SENSITIVE_JSON_FIELD_RE, "$1[REDACTED]$3")
80
+ .replace(SENSITIVE_HEADER_VALUE_RE, "$1[REDACTED]")
81
+ .replace(BEARER_TOKEN_RE, "$1[REDACTED]");
82
+ }
83
+ function sanitizeLine(text) {
84
+ return sanitizeText(text)
85
+ .replace(/\r?\n/g, " ")
86
+ .trim();
87
+ }
88
+ function isRecord(value) {
89
+ return value !== null && typeof value === "object" && !Array.isArray(value);
90
+ }
91
+ function sanitizeDiffValue(value, depth = 0) {
92
+ if (depth > 6)
93
+ return "[TRUNCATED]";
94
+ if (typeof value === "string")
95
+ return sanitizeText(value);
96
+ if (value === null || typeof value !== "object")
97
+ return value;
98
+ if (Array.isArray(value)) {
99
+ return value.map((entry) => sanitizeDiffValue(entry, depth + 1));
100
+ }
101
+ const out = {};
102
+ for (const [key, entry] of Object.entries(value)) {
103
+ if (entry === undefined)
104
+ continue;
105
+ if (SENSITIVE_KEY_RE.test(key)) {
106
+ out[key] = "[REDACTED]";
107
+ continue;
108
+ }
109
+ out[key] = sanitizeDiffValue(entry, depth + 1);
110
+ }
111
+ return out;
112
+ }
113
+ function isRedactedHoldout(item) {
114
+ return item.metrics?.redacted === true;
115
+ }
116
+ function summarizeInvariantIssue(item) {
117
+ if (isRedactedHoldout(item)) {
118
+ const raw = item.failures?.[0] || "Holdout invariant failed (expected details redacted)";
119
+ return sanitizeLine(raw);
120
+ }
121
+ const raw = item.failures?.[0] || item.reason || item.diagnostic?.message || `status=${item.status}`;
122
+ return sanitizeLine(raw);
123
+ }
124
+ function formatInvariantLine(item, useColor) {
125
+ const tagRaw = item.status === "warn" ? "WARN" : item.status === "error" ? "ERR " : "FAIL";
126
+ const tagColor = item.status === "warn" ? ANSI.yellow : ANSI.red;
127
+ const tag = style(tagRaw, `${ANSI.bold}${tagColor}`, useColor);
128
+ const sev = style(`(${item.severity})`, ANSI.dim, useColor);
129
+ const redacted = isRedactedHoldout(item);
130
+ const suffix = redacted ? ` ${style("[holdout redacted]", ANSI.dim, useColor)}` : "";
131
+ const summary = summarizeInvariantIssue(item);
132
+ const lines = [` - ${tag} ${item.id} ${sev}${suffix}: ${summary}`];
133
+ if (!redacted && typeof item.repro === "string" && item.repro.trim().length > 0) {
134
+ const reproClean = sanitizeLine(item.repro);
135
+ lines.push(` ${style("repro:", ANSI.dim, useColor)} ${reproClean}`);
136
+ }
137
+ return lines;
138
+ }
139
+ export function formatPrettyReport(report, options = {}) {
140
+ const useColor = options.color === true;
141
+ const lines = [];
142
+ const banner = style(`[${gateBannerText(report.gate.status)}]`, gateBannerColor(report.gate.status), useColor);
143
+ const titleParts = [banner];
144
+ if (options.contractName)
145
+ titleParts.push(style(options.contractName, ANSI.bold, useColor));
146
+ if (options.target)
147
+ titleParts.push(style(`-> ${options.target}`, ANSI.cyan, useColor));
148
+ lines.push(titleParts.join(" "));
149
+ const hardSkippedPart = report.hard.skipped > 0 ? `, ${report.hard.skipped} skipped` : "";
150
+ lines.push(`Hard Parity: ${renderProgressBar(report.hard.parity, useColor)} ${formatPercent(report.hard.parity)} (${report.hard.passed}/${report.hard.evaluated} passed${hardSkippedPart})`);
151
+ lines.push(`Composite Score: ${renderProgressBar(report.compositeScore, useColor)} ${formatPercent(report.compositeScore)}`);
152
+ if (report.soft.total > 0) {
153
+ const softDetails = [`${report.soft.passed}/${report.soft.evaluated} passed`, `mean ${formatPercent(report.soft.meanScore)}`];
154
+ if (report.soft.warned > 0)
155
+ softDetails.push(`${report.soft.warned} warned`);
156
+ if (report.soft.failed > 0)
157
+ softDetails.push(`${report.soft.failed} failed`);
158
+ if (report.soft.skipped > 0)
159
+ softDetails.push(`${report.soft.skipped} skipped`);
160
+ lines.push(`Soft Parity: ${renderProgressBar(report.soft.meanScore, useColor)} ${formatPercent(report.soft.meanScore)} (${softDetails.join(", ")})`);
161
+ }
162
+ if (report.antiCheat) {
163
+ const verdict = report.antiCheat.status === "clean"
164
+ ? style("CLEAN", ANSI.green, useColor)
165
+ : style("SUSPECTED", `${ANSI.bold}${ANSI.red}`, useColor);
166
+ const reasonText = report.antiCheat.status === "suspected" && report.antiCheat.reasons.length > 0
167
+ ? ` — ${report.antiCheat.reasons.map(sanitizeLine).join("; ")}`
168
+ : "";
169
+ lines.push(`Anti-Cheat: ${verdict}${reasonText}`);
170
+ }
171
+ if (options.slices && options.slices.total > 0) {
172
+ const s = options.slices;
173
+ const parts = [`${s.passed}/${s.total} passed (${formatPercent(s.completionRatio)})`];
174
+ if (s.failed > 0)
175
+ parts.push(`${s.failed} failed`);
176
+ if (s.inProgress > 0)
177
+ parts.push(`${s.inProgress} in-progress`);
178
+ if (s.pending > 0)
179
+ parts.push(`${s.pending} pending`);
180
+ if (s.nextSlice)
181
+ parts.push(`next: ${s.nextSlice}`);
182
+ lines.push(`Slices: ${parts.join(", ")}`);
183
+ }
184
+ if (report.gate.reasons && report.gate.reasons.length > 0) {
185
+ lines.push(`Reasons: ${report.gate.reasons.map(sanitizeLine).join("; ")}`);
186
+ }
187
+ if (report.nextAction && report.nextAction !== "none") {
188
+ lines.push(`Next Action: ${report.nextAction}`);
189
+ }
190
+ const issues = (report.results || [])
191
+ .filter((r) => r.status === "fail" || r.status === "error" || r.status === "warn")
192
+ .sort((a, b) => {
193
+ const rank = (s) => (s === "fail" || s === "error" ? 0 : 1);
194
+ return rank(a.status) - rank(b.status);
195
+ });
196
+ if (issues.length > 0) {
197
+ lines.push(`Issues (${issues.length}):`);
198
+ const visible = issues.slice(0, MAX_LISTED_INVARIANTS);
199
+ for (const item of visible) {
200
+ lines.push(...formatInvariantLine(item, useColor));
201
+ }
202
+ if (issues.length > MAX_LISTED_INVARIANTS) {
203
+ lines.push(` ... and ${issues.length - MAX_LISTED_INVARIANTS} more`);
204
+ }
205
+ }
206
+ if (options.reportHtmlPath && options.reportHtmlPath.trim().length > 0) {
207
+ lines.push(`HTML Report: ${options.reportHtmlPath.trim()}`);
208
+ }
209
+ return lines.join("\n");
210
+ }
211
+ export function formatPrettyRun(result, options = {}) {
212
+ const useColor = options.color === true;
213
+ const lines = [];
214
+ const statusLabel = result.dryRun ? "DRY RUN" : result.ok ? "RUN PASS" : "RUN STOPPED";
215
+ const statusColor = result.dryRun
216
+ ? `${ANSI.bold}${ANSI.cyan}`
217
+ : result.ok
218
+ ? `${ANSI.bold}${ANSI.green}`
219
+ : `${ANSI.bold}${ANSI.red}`;
220
+ lines.push(`${style(`[${statusLabel}]`, statusColor, useColor)} agent=${result.agent} reason=${result.stoppedReason}`);
221
+ const metaParts = [`iterations=${result.iterations.length}`];
222
+ if (result.plannedSlices.length > 0) {
223
+ metaParts.push(`plannedSlices=${result.plannedSlices.length}`);
224
+ }
225
+ if (result.iterations.length > 0) {
226
+ const totalMs = result.iterations.reduce((acc, it) => acc + (Number.isFinite(it.durationMs) ? it.durationMs : 0), 0);
227
+ metaParts.push(`duration=${(totalMs / 1000).toFixed(1)}s`);
228
+ }
229
+ lines.push(`Summary: ${metaParts.join(", ")}`);
230
+ if (result.iterations.length > 0) {
231
+ lines.push("Iterations:");
232
+ const shown = result.iterations.slice(-MAX_LISTED_INVARIANTS);
233
+ if (result.iterations.length > MAX_LISTED_INVARIANTS) {
234
+ lines.push(` ... (${result.iterations.length - MAX_LISTED_INVARIANTS} earlier iteration(s) omitted)`);
235
+ }
236
+ for (const it of shown) {
237
+ const sliceTag = it.sliceId ? ` [${it.sliceId}]` : "";
238
+ lines.push(` #${it.iteration}${sliceTag} hard=${it.hardPassed}/${it.hardTotal} (${formatPercent(it.parity)}) composite=${formatPercent(it.compositeScore)} gate=${it.gateStatus}`);
239
+ }
240
+ }
241
+ if (result.tamperedFiles && result.tamperedFiles.length > 0) {
242
+ lines.push(`${style("Tampered Files:", `${ANSI.bold}${ANSI.red}`, useColor)} ${result.tamperedFiles.map(sanitizeLine).join(", ")}`);
243
+ }
244
+ if (result.diagnostic) {
245
+ lines.push(`Diagnostic: [${result.diagnostic.code}] ${sanitizeLine(result.diagnostic.message)}`);
246
+ if (result.diagnostic.installHint) {
247
+ lines.push(`Install Hint: ${sanitizeLine(result.diagnostic.installHint)}`);
248
+ }
249
+ }
250
+ if (result.specPath) {
251
+ lines.push(`Spec: ${result.specPath}`);
252
+ }
253
+ if (result.historyPath) {
254
+ lines.push(`History: ${result.historyPath}`);
255
+ }
256
+ if (result.finalReport) {
257
+ lines.push("");
258
+ lines.push(formatPrettyReport(result.finalReport, {
259
+ ...(options.reportHtmlPath ? { reportHtmlPath: options.reportHtmlPath } : {}),
260
+ color: useColor
261
+ }));
262
+ }
263
+ else if (options.reportHtmlPath && options.reportHtmlPath.trim().length > 0) {
264
+ lines.push(`HTML Report: ${options.reportHtmlPath.trim()}`);
265
+ }
266
+ return lines.join("\n");
267
+ }
268
+ export function formatPrettyStatus(status, options = {}) {
269
+ const useColor = options.color === true;
270
+ const lines = [];
271
+ if (status.contract.exists) {
272
+ const c = status.contract;
273
+ const headerParts = [
274
+ style("[CONTRACT]", `${ANSI.bold}${ANSI.cyan}`, useColor),
275
+ style(sanitizeLine(c.name), ANSI.bold, useColor)
276
+ ];
277
+ if (c.schemaVersion) {
278
+ headerParts.push(style(`(v${sanitizeLine(c.schemaVersion)})`, ANSI.dim, useColor));
279
+ }
280
+ lines.push(headerParts.join(" "));
281
+ if (c.domains && c.domains.length > 0) {
282
+ lines.push(`Domains: ${c.domains.map(sanitizeLine).join(", ")}`);
283
+ }
284
+ const total = typeof c.invariants === "number"
285
+ ? c.invariants
286
+ : (c.hard ?? 0) + (c.soft ?? 0);
287
+ const breakdown = [];
288
+ if (typeof c.hard === "number")
289
+ breakdown.push(`${c.hard} hard`);
290
+ if (typeof c.soft === "number")
291
+ breakdown.push(`${c.soft} soft`);
292
+ if (typeof c.holdouts === "number") {
293
+ breakdown.push(`${c.holdouts} ${c.holdouts === 1 ? "holdout" : "holdouts"}`);
294
+ }
295
+ const suffix = breakdown.length > 0 ? ` (${breakdown.join(", ")})` : "";
296
+ lines.push(`Invariants: ${total} total${suffix}`);
297
+ if (c.slices && c.slices.total > 0) {
298
+ const s = c.slices;
299
+ const ratio = Number.isFinite(s.completionRatio)
300
+ ? s.completionRatio
301
+ : s.total > 0
302
+ ? s.passed / s.total
303
+ : 0;
304
+ const sliceParts = [`${s.passed}/${s.total} passed`];
305
+ if (s.failed > 0)
306
+ sliceParts.push(`${s.failed} failed`);
307
+ if (s.inProgress > 0)
308
+ sliceParts.push(`${s.inProgress} in-progress`);
309
+ if (s.pending > 0)
310
+ sliceParts.push(`${s.pending} pending`);
311
+ if (s.nextSlice)
312
+ sliceParts.push(`next: ${sanitizeLine(s.nextSlice)}`);
313
+ lines.push(`Slices: ${renderProgressBar(ratio, useColor)} ${formatPercent(ratio)} (${sliceParts.join(", ")})`);
314
+ }
315
+ }
316
+ else {
317
+ lines.push(`${style("[NO CONTRACT]", `${ANSI.bold}${ANSI.yellow}`, useColor)} No .vibecode/contract.json found`);
318
+ }
319
+ if (status.adapters) {
320
+ const adapterKeys = ["playwright", "ffmpeg", "ffprobe", "sharp"];
321
+ const adapterParts = [];
322
+ for (const key of adapterKeys) {
323
+ const entry = status.adapters[key];
324
+ if (!entry)
325
+ continue;
326
+ const badge = entry.available
327
+ ? style("ok", ANSI.green, useColor)
328
+ : style("missing", ANSI.yellow, useColor);
329
+ adapterParts.push(`${key} (${badge})`);
330
+ }
331
+ if (adapterParts.length > 0) {
332
+ lines.push(`Adapters: ${adapterParts.join(", ")}`);
333
+ }
334
+ }
335
+ if (status.lastReport) {
336
+ const lr = status.lastReport;
337
+ const gateBadge = style(`[${gateBannerText(lr.gate.status)}]`, gateBannerColor(lr.gate.status), useColor);
338
+ const tsPart = lr.timestamp ? ` ${style(sanitizeLine(lr.timestamp), ANSI.dim, useColor)}` : "";
339
+ lines.push(`Last Report: ${gateBadge}${tsPart}`);
340
+ if (lr.hard) {
341
+ const denom = lr.hard.evaluated ?? lr.hard.total;
342
+ const hardSkipped = lr.hard.skipped && lr.hard.skipped > 0 ? `, ${lr.hard.skipped} skipped` : "";
343
+ lines.push(`Hard Parity: ${renderProgressBar(lr.hard.parity, useColor)} ${formatPercent(lr.hard.parity)} (${lr.hard.passed}/${denom} passed${hardSkipped})`);
344
+ }
345
+ if (lr.soft && lr.soft.total > 0) {
346
+ const softRatio = typeof lr.soft.meanScore === "number"
347
+ ? lr.soft.meanScore
348
+ : typeof lr.soft.parity === "number"
349
+ ? lr.soft.parity
350
+ : typeof lr.soft.passed === "number" && lr.soft.total > 0
351
+ ? lr.soft.passed / lr.soft.total
352
+ : 0;
353
+ const softDenom = lr.soft.evaluated ?? lr.soft.total;
354
+ const softDetails = [];
355
+ if (typeof lr.soft.passed === "number") {
356
+ softDetails.push(`${lr.soft.passed}/${softDenom} passed`);
357
+ }
358
+ else {
359
+ softDetails.push(`${lr.soft.total} total`);
360
+ }
361
+ if (typeof lr.soft.warned === "number" && lr.soft.warned > 0) {
362
+ softDetails.push(`${lr.soft.warned} warned`);
363
+ }
364
+ if (typeof lr.soft.failed === "number" && lr.soft.failed > 0) {
365
+ softDetails.push(`${lr.soft.failed} failed`);
366
+ }
367
+ if (typeof lr.soft.skipped === "number" && lr.soft.skipped > 0) {
368
+ softDetails.push(`${lr.soft.skipped} skipped`);
369
+ }
370
+ lines.push(`Soft Parity: ${renderProgressBar(softRatio, useColor)} ${formatPercent(softRatio)} (${softDetails.join(", ")})`);
371
+ }
372
+ if (typeof lr.compositeScore === "number" && Number.isFinite(lr.compositeScore)) {
373
+ lines.push(`Composite Score: ${renderProgressBar(lr.compositeScore, useColor)} ${formatPercent(lr.compositeScore)}`);
374
+ }
375
+ else if (typeof lr.parity === "number" && Number.isFinite(lr.parity)) {
376
+ lines.push(`Parity: ${renderProgressBar(lr.parity, useColor)} ${formatPercent(lr.parity)}`);
377
+ }
378
+ else if (typeof lr.parity === "string" && lr.parity.trim().length > 0) {
379
+ lines.push(`Parity: ${sanitizeLine(lr.parity)}`);
380
+ }
381
+ if (typeof lr.nextAction === "string" && lr.nextAction.trim().length > 0 && lr.nextAction !== "none") {
382
+ lines.push(`Next Action: ${sanitizeLine(lr.nextAction)}`);
383
+ }
384
+ }
385
+ else {
386
+ lines.push(`Last Report: ${style("No parity report yet", ANSI.dim, useColor)}`);
387
+ }
388
+ return lines.join("\n");
389
+ }
390
+ function invariantStatusBadge(status, useColor) {
391
+ switch (status) {
392
+ case "pass":
393
+ return style("[PASS]", `${ANSI.bold}${ANSI.green}`, useColor);
394
+ case "warn":
395
+ return style("[WARN]", `${ANSI.bold}${ANSI.yellow}`, useColor);
396
+ case "skipped":
397
+ return style("[SKIP]", `${ANSI.bold}${ANSI.dim}`, useColor);
398
+ case "error":
399
+ return style("[FAIL]", `${ANSI.bold}${ANSI.red}`, useColor);
400
+ case "fail":
401
+ return style("[FAIL]", `${ANSI.bold}${ANSI.red}`, useColor);
402
+ }
403
+ }
404
+ function formatCompactJson(value) {
405
+ if (value === undefined)
406
+ return "undefined";
407
+ try {
408
+ const raw = JSON.stringify(sanitizeDiffValue(value));
409
+ if (raw === undefined)
410
+ return "undefined";
411
+ return raw.length > 120 ? `${raw.slice(0, 117)}...` : raw;
412
+ }
413
+ catch {
414
+ return sanitizeLine(String(value));
415
+ }
416
+ }
417
+ function extractUnifiedDiff(diff) {
418
+ const candidates = [
419
+ ["unified", diff.unified],
420
+ ["goldenStdout", isRecord(diff.goldenStdout) ? diff.goldenStdout.unified : undefined],
421
+ ["stdout", isRecord(diff.stdout) ? diff.stdout.unified : undefined],
422
+ ["body", isRecord(diff.body) ? diff.body.unified : undefined]
423
+ ];
424
+ for (const [sourceKey, candidate] of candidates) {
425
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
426
+ return { text: candidate, sourceKey };
427
+ }
428
+ }
429
+ return null;
430
+ }
431
+ function formatUnifiedDiffLines(unified, useColor, maxLines) {
432
+ const rawLines = unified.replace(/\r\n/g, "\n").split("\n");
433
+ // Drop a single trailing empty line caused by trailing newline
434
+ if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "") {
435
+ rawLines.pop();
436
+ }
437
+ const shown = rawLines.slice(0, maxLines);
438
+ const out = [];
439
+ for (const raw of shown) {
440
+ let formatted;
441
+ if (raw.startsWith("@@")) {
442
+ formatted = style(sanitizeText(raw), ANSI.cyan, useColor);
443
+ }
444
+ else if (raw.startsWith("+++ ")) {
445
+ formatted = style(`+++ ${sanitizeText(raw.slice(4))}`, ANSI.bold, useColor);
446
+ }
447
+ else if (raw.startsWith("--- ")) {
448
+ formatted = style(`--- ${sanitizeText(raw.slice(4))}`, ANSI.bold, useColor);
449
+ }
450
+ else if (raw.startsWith("+")) {
451
+ formatted = style(`+${sanitizeText(raw.slice(1))}`, ANSI.green, useColor);
452
+ }
453
+ else if (raw.startsWith("-")) {
454
+ formatted = style(`-${sanitizeText(raw.slice(1))}`, ANSI.red, useColor);
455
+ }
456
+ else if (raw.startsWith(" ")) {
457
+ formatted = ` ${sanitizeText(raw.slice(1))}`;
458
+ }
459
+ else {
460
+ formatted = sanitizeText(raw);
461
+ }
462
+ out.push(` ${formatted}`);
463
+ }
464
+ if (rawLines.length > maxLines) {
465
+ out.push(` ${style(`... (${rawLines.length - maxLines} more diff line(s) truncated)`, ANSI.dim, useColor)}`);
466
+ }
467
+ return out;
468
+ }
469
+ function formatJsonDiffEntries(label, entries, useColor) {
470
+ const out = [` ${style(label, ANSI.bold, useColor)}`];
471
+ const shown = entries.slice(0, MAX_DIFF_ITEMS);
472
+ for (const entry of shown) {
473
+ if (isRecord(entry)) {
474
+ const entryPath = sanitizeLine(String(entry.path ?? "$"));
475
+ if (typeof entry.message === "string") {
476
+ out.push(` - ${entryPath}: ${sanitizeLine(entry.message)}`);
477
+ }
478
+ else {
479
+ const expectedVal = Object.prototype.hasOwnProperty.call(entry, "expected")
480
+ ? entry.expected
481
+ : entry.matches;
482
+ const expStr = formatCompactJson(expectedVal);
483
+ const actStr = formatCompactJson(entry.actual);
484
+ out.push(` - ${entryPath}: expected ${expStr}, got ${actStr}`);
485
+ }
486
+ }
487
+ else {
488
+ out.push(` - ${formatCompactJson(entry)}`);
489
+ }
490
+ }
491
+ if (entries.length > MAX_DIFF_ITEMS) {
492
+ out.push(` ${style(`... and ${entries.length - MAX_DIFF_ITEMS} more`, ANSI.dim, useColor)}`);
493
+ }
494
+ return out;
495
+ }
496
+ function formatSingleInvariantDiff(item, useColor, maxDiffLines) {
497
+ const lines = [];
498
+ const redacted = isRedactedHoldout(item);
499
+ const badge = invariantStatusBadge(item.status, useColor);
500
+ const meta = style(`(${item.type}, ${item.severity})`, ANSI.dim, useColor);
501
+ const redactedTag = redacted ? ` ${style("[holdout redacted]", ANSI.dim, useColor)}` : "";
502
+ lines.push(`${badge} ${sanitizeLine(item.id)} ${meta}${redactedTag}`);
503
+ if (redacted) {
504
+ if (item.failures && item.failures.length > 0) {
505
+ for (const f of item.failures.slice(0, MAX_DIFF_ITEMS)) {
506
+ lines.push(` - ${sanitizeLine(f)}`);
507
+ }
508
+ }
509
+ else if (item.status === "fail" || item.status === "error") {
510
+ lines.push(" - Holdout invariant failed (expected details redacted)");
511
+ }
512
+ else if (item.status === "pass") {
513
+ lines.push(" No differences.");
514
+ }
515
+ return lines;
516
+ }
517
+ let hasDetails = false;
518
+ if (item.failures && item.failures.length > 0) {
519
+ hasDetails = true;
520
+ const shownFailures = item.failures.slice(0, MAX_DIFF_ITEMS);
521
+ for (const f of shownFailures) {
522
+ lines.push(` - ${sanitizeLine(f)}`);
523
+ }
524
+ if (item.failures.length > MAX_DIFF_ITEMS) {
525
+ lines.push(` ${style(`... and ${item.failures.length - MAX_DIFF_ITEMS} more failure(s)`, ANSI.dim, useColor)}`);
526
+ }
527
+ }
528
+ else if (item.reason) {
529
+ hasDetails = true;
530
+ lines.push(` - ${sanitizeLine(item.reason)}`);
531
+ }
532
+ else if (item.diagnostic?.message) {
533
+ hasDetails = true;
534
+ lines.push(` - [${sanitizeLine(item.diagnostic.code)}] ${sanitizeLine(item.diagnostic.message)}`);
535
+ }
536
+ if (typeof item.repro === "string" && item.repro.trim().length > 0) {
537
+ hasDetails = true;
538
+ lines.push(` ${style("repro:", ANSI.dim, useColor)} ${sanitizeLine(item.repro)}`);
539
+ }
540
+ if (isRecord(item.diff)) {
541
+ const unified = extractUnifiedDiff(item.diff);
542
+ const handledKeys = new Set(["diffPng", "diffPath", "diffPngPath", "candidatePath", "referencePath"]);
543
+ if (Array.isArray(item.diff.jsonPaths) && item.diff.jsonPaths.length > 0) {
544
+ hasDetails = true;
545
+ handledKeys.add("jsonPaths");
546
+ lines.push(...formatJsonDiffEntries("JSON Path Diff:", item.diff.jsonPaths, useColor));
547
+ }
548
+ if (Array.isArray(item.diff.jsonSubset) && item.diff.jsonSubset.length > 0) {
549
+ hasDetails = true;
550
+ handledKeys.add("jsonSubset");
551
+ lines.push(...formatJsonDiffEntries("JSON Subset Diff:", item.diff.jsonSubset, useColor));
552
+ }
553
+ if (Array.isArray(item.diff.jsonSchema) && item.diff.jsonSchema.length > 0) {
554
+ hasDetails = true;
555
+ handledKeys.add("jsonSchema");
556
+ lines.push(...formatJsonDiffEntries("JSON Schema Diff:", item.diff.jsonSchema, useColor));
557
+ }
558
+ if (unified) {
559
+ hasDetails = true;
560
+ handledKeys.add(unified.sourceKey);
561
+ lines.push(` ${style("Unified Diff:", ANSI.bold, useColor)}`);
562
+ lines.push(...formatUnifiedDiffLines(unified.text, useColor, maxDiffLines));
563
+ }
564
+ const rest = {};
565
+ for (const [key, val] of Object.entries(item.diff)) {
566
+ if (handledKeys.has(key) || val === undefined)
567
+ continue;
568
+ if (SENSITIVE_KEY_RE.test(key)) {
569
+ rest[key] = "[REDACTED]";
570
+ }
571
+ else {
572
+ rest[key] = sanitizeDiffValue(val);
573
+ }
574
+ }
575
+ if (Object.keys(rest).length > 0) {
576
+ hasDetails = true;
577
+ const serialized = JSON.stringify(rest, null, 2);
578
+ if (serialized && serialized !== "{}") {
579
+ const jsonLines = serialized.split("\n");
580
+ lines.push(` ${style("Diff:", ANSI.bold, useColor)}`);
581
+ for (const jl of jsonLines.slice(0, MAX_JSON_DIFF_LINES)) {
582
+ lines.push(` ${sanitizeText(jl)}`);
583
+ }
584
+ if (jsonLines.length > MAX_JSON_DIFF_LINES) {
585
+ lines.push(` ${style(`... (${jsonLines.length - MAX_JSON_DIFF_LINES} more JSON line(s) truncated)`, ANSI.dim, useColor)}`);
586
+ }
587
+ }
588
+ }
589
+ }
590
+ if (!hasDetails && item.status === "pass") {
591
+ lines.push(" No differences.");
592
+ }
593
+ return lines;
594
+ }
595
+ function isParityReport(target) {
596
+ return "results" in target && Array.isArray(target.results);
597
+ }
598
+ export function formatPrettyDiff(target, options = {}) {
599
+ const useColor = options.color === true;
600
+ const maxDiffLines = typeof options.maxDiffLines === "number" && Number.isFinite(options.maxDiffLines) && options.maxDiffLines > 0
601
+ ? Math.floor(options.maxDiffLines)
602
+ : MAX_DIFF_LINES;
603
+ if (isParityReport(target)) {
604
+ const report = target;
605
+ const lines = [];
606
+ const banner = style(`[${gateBannerText(report.gate.status)}]`, gateBannerColor(report.gate.status), useColor);
607
+ lines.push(`${banner} Parity Diff (${report.hard.passed}/${report.hard.evaluated} hard passed, ${formatPercent(report.hard.parity)})`);
608
+ lines.push(`Hard Parity: ${renderProgressBar(report.hard.parity, useColor)} ${formatPercent(report.hard.parity)} (${report.hard.passed}/${report.hard.evaluated} passed)`);
609
+ const issues = report.results
610
+ .filter((r) => r.status === "fail" || r.status === "error" || r.status === "warn")
611
+ .sort((a, b) => {
612
+ const rank = (s) => (s === "fail" || s === "error" ? 0 : 1);
613
+ return rank(a.status) - rank(b.status);
614
+ });
615
+ if (issues.length === 0) {
616
+ lines.push("No failing or warning invariants.");
617
+ return lines.join("\n");
618
+ }
619
+ lines.push(`Issues (${issues.length}):`);
620
+ const shown = issues.slice(0, MAX_LISTED_INVARIANTS);
621
+ for (const item of shown) {
622
+ lines.push("");
623
+ lines.push(...formatSingleInvariantDiff(item, useColor, maxDiffLines));
624
+ }
625
+ if (issues.length > MAX_LISTED_INVARIANTS) {
626
+ lines.push("");
627
+ lines.push(`... and ${issues.length - MAX_LISTED_INVARIANTS} more invariant(s) omitted`);
628
+ }
629
+ return lines.join("\n");
630
+ }
631
+ return formatSingleInvariantDiff(target, useColor, maxDiffLines).join("\n");
632
+ }
@@ -0,0 +1,37 @@
1
+ import type { CommandExecOptions, CommandExecResult, FsEffectEntry } from "./types.js";
2
+ export declare const DETERMINISTIC_CLI_ENV: Readonly<Record<string, string>>;
3
+ export declare const MAX_SNAPSHOT_FILE_BYTES: number;
4
+ export declare const MAX_SNAPSHOT_PREVIEW_CHARS = 4096;
5
+ export declare const IGNORED_DIRS: Set<string>;
6
+ export interface FsSnapshotFile {
7
+ size: number;
8
+ sha256?: string;
9
+ preview?: string;
10
+ }
11
+ export type FsSnapshot = Map<string, FsSnapshotFile>;
12
+ export declare function sha256Text(text: string): string;
13
+ /**
14
+ * Recursively snapshot regular files under rootDir, keyed by sorted POSIX relative paths.
15
+ */
16
+ export declare function takeFsSnapshot(rootDir: string): FsSnapshot;
17
+ /**
18
+ * Compute sorted filesystem side effects between two directory snapshots.
19
+ */
20
+ export declare function diffFsSnapshots(before: FsSnapshot, after: FsSnapshot): FsEffectEntry[];
21
+ /**
22
+ * Verify actual filesystem side effects against expected effects from a contract invariant.
23
+ */
24
+ export declare function verifyFsEffects(expected: readonly FsEffectEntry[], actual: readonly FsEffectEntry[]): {
25
+ failures: string[];
26
+ diffs: Array<Record<string, unknown>>;
27
+ };
28
+ /**
29
+ * Resolve relative executable and script/fixture path tokens against workspaceCwd
30
+ * before running the command inside an isolated temp directory.
31
+ */
32
+ export declare function resolveCommandForSandbox(tokens: readonly string[], workspaceCwd?: string): string[];
33
+ /**
34
+ * Execute a CLI command with deterministic stdio handling, bounded output buffering,
35
+ * and full process-tree termination on timeout.
36
+ */
37
+ export declare function runSandboxedCommand(target: string, args?: readonly (string | number | boolean)[], options?: CommandExecOptions): Promise<CommandExecResult>;