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,18 @@
1
+ /**
2
+ * Zero-dependency GitHub parity SVG badge and PR/CI Markdown summary generators.
3
+ */
4
+ import type { ParityReport, SliceSummary } from "./types.js";
5
+ export interface BadgeOptions {
6
+ label?: string;
7
+ }
8
+ export interface PrSummaryOptions {
9
+ contractName?: string;
10
+ target?: string;
11
+ slices?: SliceSummary;
12
+ reportHtmlPath?: string;
13
+ holdoutCount?: number;
14
+ }
15
+ export declare function renderParityBadgeSvg(report: ParityReport, options?: BadgeOptions): string;
16
+ export declare function writeParityBadgeSvg(outPath: string, report: ParityReport, options?: BadgeOptions): string;
17
+ export declare function renderPrCommentMarkdown(report: ParityReport, options?: PrSummaryOptions): string;
18
+ export declare function writePrCommentMarkdown(outPath: string, report: ParityReport, options?: PrSummaryOptions): string;
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Zero-dependency GitHub parity SVG badge and PR/CI Markdown summary generators.
3
+ */
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { redactSensitiveText as redactCoreSensitiveText } from "./security.js";
7
+ import { ensureDir } from "./store.js";
8
+ const DEFAULT_BADGE_LABEL = "vibecode parity";
9
+ const BADGE_HEIGHT = 20;
10
+ const BADGE_LABEL_BG = "#555555";
11
+ const MAX_VISIBLE_ISSUES = 15;
12
+ const MAX_HOLDOUT_ISSUES = 15;
13
+ const STATUS_STYLE = {
14
+ pass: {
15
+ color: "#16a34a",
16
+ shortLabel: "PASS",
17
+ icon: "โœ…",
18
+ banner: "PASS"
19
+ },
20
+ pass_with_warnings: {
21
+ color: "#d97706",
22
+ shortLabel: "WARN",
23
+ icon: "โš ๏ธ",
24
+ banner: "PASS WITH WARNINGS"
25
+ },
26
+ fail: {
27
+ color: "#dc2626",
28
+ shortLabel: "FAIL",
29
+ icon: "โŒ",
30
+ banner: "FAIL"
31
+ },
32
+ incomplete: {
33
+ color: "#64748b",
34
+ shortLabel: "INCOMPLETE",
35
+ icon: "โšช",
36
+ banner: "INCOMPLETE"
37
+ }
38
+ };
39
+ function clamp01(value) {
40
+ if (typeof value !== "number" || !Number.isFinite(value))
41
+ return 0;
42
+ return Math.max(0, Math.min(1, value));
43
+ }
44
+ function formatPercent(ratio) {
45
+ return `${(clamp01(ratio) * 100).toFixed(1)}%`;
46
+ }
47
+ function resolveGateStyle(status) {
48
+ if (status === "pass" || status === "pass_with_warnings" || status === "fail" || status === "incomplete") {
49
+ return STATUS_STYLE[status];
50
+ }
51
+ return STATUS_STYLE.fail;
52
+ }
53
+ function normalizeSingleLine(text) {
54
+ return String(text)
55
+ .replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "")
56
+ .replace(/\r?\n/g, " ")
57
+ .replace(/\s+/g, " ")
58
+ .trim();
59
+ }
60
+ function escapeXml(value) {
61
+ return String(value)
62
+ .replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "")
63
+ .replace(/&/g, "&")
64
+ .replace(/</g, "&lt;")
65
+ .replace(/>/g, "&gt;")
66
+ .replace(/"/g, "&quot;")
67
+ .replace(/'/g, "&apos;");
68
+ }
69
+ function estimateCharWidth(ch, bold) {
70
+ const factor = bold ? 1.06 : 1.0;
71
+ if ("ilI1.,:;!|'`".includes(ch))
72
+ return 4.2 * factor;
73
+ if ("fjrt()-/\\[]".includes(ch))
74
+ return 4.8 * factor;
75
+ if (ch === " ")
76
+ return 4.0 * factor;
77
+ if ("mwMW%@".includes(ch))
78
+ return 9.4 * factor;
79
+ if (ch >= "A" && ch <= "Z")
80
+ return 7.6 * factor;
81
+ if (ch.charCodeAt(0) > 127)
82
+ return 8.8 * factor;
83
+ return 6.5 * factor;
84
+ }
85
+ function computeSegmentWidth(text, bold) {
86
+ let width = 0;
87
+ for (const ch of text) {
88
+ width += estimateCharWidth(ch, bold);
89
+ }
90
+ const padded = Math.ceil(width) + 14;
91
+ return Math.max(36, padded);
92
+ }
93
+ function formatCoord(value) {
94
+ return Number.isInteger(value) ? String(value) : value.toFixed(1).replace(/\.0$/, "");
95
+ }
96
+ function redactSensitiveText(input) {
97
+ return redactCoreSensitiveText(input).replace(/\[REDACTED_VAULT\]/g, "[REDACTED_VAULT_PATH]");
98
+ }
99
+ function escapeTableCell(value) {
100
+ return normalizeSingleLine(redactSensitiveText(value)).replace(/\|/g, "\\|");
101
+ }
102
+ function formatCodeSpan(value) {
103
+ const clean = normalizeSingleLine(redactSensitiveText(value));
104
+ const longestBackticks = (clean.match(/`+/g) ?? []).reduce((max, s) => Math.max(max, s.length), 0);
105
+ const fence = "`".repeat(longestBackticks + 1);
106
+ const needsSpace = clean.startsWith("`") || clean.endsWith("`");
107
+ return needsSpace ? `${fence} ${clean} ${fence}` : `${fence}${clean}${fence}`;
108
+ }
109
+ function formatCodeBlock(value, lang = "sh") {
110
+ const clean = redactSensitiveText(value).replace(/\r\n?/g, "\n").trim();
111
+ const longestBackticks = (clean.match(/`+/g) ?? []).reduce((max, s) => Math.max(max, s.length), 0);
112
+ const fence = "`".repeat(Math.max(3, longestBackticks + 1));
113
+ return `${fence}${lang}\n${clean}\n${fence}`;
114
+ }
115
+ function isHoldoutResult(item) {
116
+ const raw = item;
117
+ return (item.metrics?.redacted === true ||
118
+ item.metrics?.holdout === true ||
119
+ raw.holdout === true);
120
+ }
121
+ function getSafeHoldoutHint(item) {
122
+ const raw = item;
123
+ if (typeof raw.holdoutHint === "string" && raw.holdoutHint.trim().length > 0) {
124
+ const hint = normalizeSingleLine(redactSensitiveText(raw.holdoutHint));
125
+ if (hint && !/\[REDACTED_VAULT_PATH\]/.test(hint)) {
126
+ return hint;
127
+ }
128
+ }
129
+ if (item.metrics?.redacted === true &&
130
+ Array.isArray(item.failures) &&
131
+ typeof item.failures[0] === "string" &&
132
+ item.failures[0].trim().length > 0 &&
133
+ !/\.vibecode-vault|holdouts?(?:-[a-f0-9]+)?\.json/i.test(item.failures[0])) {
134
+ const candidate = normalizeSingleLine(redactSensitiveText(item.failures[0]));
135
+ if (candidate && !candidate.includes("[REDACTED_VAULT_PATH]")) {
136
+ return candidate;
137
+ }
138
+ }
139
+ return "Holdout invariant failed (expected details redacted)";
140
+ }
141
+ function summarizeVisibleIssue(item) {
142
+ const raw = (Array.isArray(item.failures) && typeof item.failures[0] === "string" && item.failures[0].trim()) ||
143
+ (typeof item.reason === "string" && item.reason.trim()) ||
144
+ (typeof item.diagnostic?.message === "string" && item.diagnostic.message.trim()) ||
145
+ `status=${item.status}`;
146
+ return normalizeSingleLine(redactSensitiveText(raw));
147
+ }
148
+ function formatSliceStatus(status) {
149
+ switch (status) {
150
+ case "passed":
151
+ return "โœ… passed";
152
+ case "failed":
153
+ return "โŒ failed";
154
+ case "in_progress":
155
+ return "๐Ÿ”„ in_progress";
156
+ case "skipped":
157
+ return "โญ๏ธ skipped";
158
+ case "pending":
159
+ default:
160
+ return "โณ pending";
161
+ }
162
+ }
163
+ function issueRank(item) {
164
+ const statusRank = item.status === "fail" || item.status === "error" ? 0 : 1;
165
+ const sevRank = item.severity === "hard" ? 0 : 1;
166
+ return statusRank * 2 + sevRank;
167
+ }
168
+ function writeFileAtomically(outPath, content) {
169
+ const resolved = path.resolve(outPath);
170
+ ensureDir(path.dirname(resolved));
171
+ const tmpPath = `${resolved}.tmp`;
172
+ fs.writeFileSync(tmpPath, content, "utf8");
173
+ fs.renameSync(tmpPath, resolved);
174
+ return resolved;
175
+ }
176
+ export function renderParityBadgeSvg(report, options = {}) {
177
+ const rawLabel = normalizeSingleLine(redactSensitiveText(options.label ?? "")) || DEFAULT_BADGE_LABEL;
178
+ const status = report.gate?.status ?? "fail";
179
+ const style = resolveGateStyle(status);
180
+ const pct = Math.round(clamp01(report.compositeScore) * 100);
181
+ const rawMessage = status === "incomplete" ? style.shortLabel : `${pct}% ${style.shortLabel}`;
182
+ const leftWidth = computeSegmentWidth(rawLabel, false);
183
+ const rightWidth = computeSegmentWidth(rawMessage, true);
184
+ const totalWidth = leftWidth + rightWidth;
185
+ const leftTextX = formatCoord(leftWidth / 2);
186
+ const rightTextX = formatCoord(leftWidth + rightWidth / 2);
187
+ const escapedLabel = escapeXml(rawLabel);
188
+ const escapedMessage = escapeXml(rawMessage);
189
+ const escapedTitle = escapeXml(`${rawLabel}: ${rawMessage}`);
190
+ return [
191
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${totalWidth}" height="${BADGE_HEIGHT}" role="img" aria-label="${escapedTitle}">`,
192
+ ` <title>${escapedTitle}</title>`,
193
+ ` <g shape-rendering="crispEdges">`,
194
+ ` <rect width="${leftWidth}" height="${BADGE_HEIGHT}" fill="${BADGE_LABEL_BG}"/>`,
195
+ ` <rect x="${leftWidth}" width="${rightWidth}" height="${BADGE_HEIGHT}" fill="${style.color}"/>`,
196
+ ` </g>`,
197
+ ` <g fill="#ffffff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,system-ui,-apple-system,sans-serif" text-rendering="geometricPrecision" font-size="11">`,
198
+ ` <text x="${leftTextX}" y="14" fill="#ffffff">${escapedLabel}</text>`,
199
+ ` <text x="${rightTextX}" y="14" fill="#ffffff" font-weight="600">${escapedMessage}</text>`,
200
+ ` </g>`,
201
+ `</svg>`,
202
+ ""
203
+ ].join("\n");
204
+ }
205
+ export function writeParityBadgeSvg(outPath, report, options = {}) {
206
+ const svg = renderParityBadgeSvg(report, options);
207
+ return writeFileAtomically(outPath, svg);
208
+ }
209
+ export function renderPrCommentMarkdown(report, options = {}) {
210
+ const status = report.gate?.status ?? "fail";
211
+ const style = resolveGateStyle(status);
212
+ const lines = [];
213
+ const contractSuffix = options.contractName?.trim()
214
+ ? ` โ€” ${formatCodeSpan(options.contractName)}`
215
+ : "";
216
+ lines.push(`## ${style.icon} Vibecode Parity: ${style.banner}${contractSuffix}`);
217
+ lines.push("");
218
+ const metaParts = [];
219
+ if (options.target?.trim()) {
220
+ metaParts.push(`**Target:** ${formatCodeSpan(options.target)}`);
221
+ }
222
+ if (typeof options.holdoutCount === "number" && Number.isFinite(options.holdoutCount) && options.holdoutCount > 0) {
223
+ metaParts.push(`**Holdouts:** ${Math.floor(options.holdoutCount)} hidden`);
224
+ }
225
+ if (options.reportHtmlPath?.trim()) {
226
+ metaParts.push(`**HTML Report:** ${formatCodeSpan(options.reportHtmlPath)}`);
227
+ }
228
+ if (metaParts.length > 0) {
229
+ lines.push(metaParts.join(" ยท "));
230
+ lines.push("");
231
+ }
232
+ // Metrics summary table
233
+ const hard = report.hard ?? { passed: 0, failed: 0, skipped: 0, evaluated: 0, total: 0, parity: 0 };
234
+ const soft = report.soft ?? { passed: 0, warned: 0, failed: 0, skipped: 0, evaluated: 0, total: 0, meanScore: 0, parity: 0 };
235
+ const hardDetailParts = [`${hard.passed}/${hard.evaluated} passed`];
236
+ if (hard.failed > 0)
237
+ hardDetailParts.push(`${hard.failed} failed`);
238
+ if (hard.skipped > 0)
239
+ hardDetailParts.push(`${hard.skipped} skipped`);
240
+ const hardCell = hard.total > 0
241
+ ? `${formatPercent(hard.parity)} (${hardDetailParts.join(", ")})`
242
+ : "N/A (0 hard)";
243
+ let softCell = "N/A (0 soft)";
244
+ if (soft.total > 0) {
245
+ const softDetailParts = [`${soft.passed}/${soft.evaluated} passed`];
246
+ if (soft.warned > 0)
247
+ softDetailParts.push(`${soft.warned} warned`);
248
+ if (soft.failed > 0)
249
+ softDetailParts.push(`${soft.failed} failed`);
250
+ if (soft.skipped > 0)
251
+ softDetailParts.push(`${soft.skipped} skipped`);
252
+ softCell = `${formatPercent(soft.meanScore)} (${softDetailParts.join(", ")})`;
253
+ }
254
+ const compositeCell = `${formatPercent(report.compositeScore)} (${report.passed}/${report.total} passed)`;
255
+ let antiCheatCell = "N/A";
256
+ if (report.antiCheat) {
257
+ if (report.antiCheat.status === "clean") {
258
+ antiCheatCell = "โœ… Clean";
259
+ }
260
+ else {
261
+ const reasons = (report.antiCheat.reasons ?? [])
262
+ .map((r) => escapeTableCell(r))
263
+ .filter((r) => r.length > 0);
264
+ antiCheatCell = reasons.length > 0
265
+ ? `๐Ÿšจ Suspected โ€” ${reasons.join("; ")}`
266
+ : "๐Ÿšจ Suspected";
267
+ }
268
+ }
269
+ const exitCode = typeof report.gate?.exitCode === "number" ? report.gate.exitCode : status === "fail" ? 1 : status === "incomplete" ? 2 : 0;
270
+ const gateExitCell = `\`${exitCode}\` (${style.banner})`;
271
+ lines.push("| Metric | Value |");
272
+ lines.push("| --- | --- |");
273
+ lines.push(`| Hard Parity | ${escapeTableCell(hardCell)} |`);
274
+ lines.push(`| Soft Perceptual | ${escapeTableCell(softCell)} |`);
275
+ lines.push(`| Composite Score | ${escapeTableCell(compositeCell)} |`);
276
+ lines.push(`| Anti-Cheat | ${antiCheatCell} |`);
277
+ lines.push(`| Gate Exit Code | ${gateExitCell} |`);
278
+ lines.push("");
279
+ if (Array.isArray(report.gate?.reasons) && report.gate.reasons.length > 0) {
280
+ lines.push("**Gate Reasons:**");
281
+ for (const reason of report.gate.reasons) {
282
+ const clean = normalizeSingleLine(redactSensitiveText(reason));
283
+ if (clean)
284
+ lines.push(`- ${clean}`);
285
+ }
286
+ lines.push("");
287
+ }
288
+ if (report.nextAction && report.nextAction !== "none") {
289
+ lines.push(`**Next Action:** ${formatCodeSpan(report.nextAction)}`);
290
+ lines.push("");
291
+ }
292
+ // Optional Slices progress table
293
+ if (options.slices && options.slices.total > 0) {
294
+ const s = options.slices;
295
+ const nextPart = s.nextSlice ? ` ยท Next: ${formatCodeSpan(s.nextSlice)}` : "";
296
+ lines.push(`### Slices Progress (${s.passed}/${s.total} passed โ€” ${formatPercent(s.completionRatio)})${nextPart}`);
297
+ lines.push("");
298
+ if (Array.isArray(s.slices) && s.slices.length > 0) {
299
+ lines.push("| Slice | Title | Status | Invariants | Score |");
300
+ lines.push("| --- | --- | --- | ---: | ---: |");
301
+ for (const slice of s.slices) {
302
+ const scoreCell = typeof slice.lastScore === "number" && Number.isFinite(slice.lastScore)
303
+ ? formatPercent(slice.lastScore)
304
+ : "โ€”";
305
+ lines.push(`| ${formatCodeSpan(slice.id)} | ${escapeTableCell(slice.title)} | ${formatSliceStatus(slice.status)} | ${slice.invariantCount} | ${scoreCell} |`);
306
+ }
307
+ lines.push("");
308
+ }
309
+ }
310
+ // Failing / warned invariants (visible vs redacted holdouts)
311
+ const issues = (report.results ?? [])
312
+ .filter((r) => r.status === "fail" || r.status === "error" || r.status === "warn")
313
+ .sort((a, b) => issueRank(a) - issueRank(b));
314
+ const visibleIssues = issues.filter((r) => !isHoldoutResult(r));
315
+ const holdoutIssues = issues.filter((r) => isHoldoutResult(r));
316
+ if (visibleIssues.length > 0) {
317
+ lines.push(`### Failing & Warned Invariants (${visibleIssues.length})`);
318
+ lines.push("");
319
+ const shown = visibleIssues.slice(0, MAX_VISIBLE_ISSUES);
320
+ for (const item of shown) {
321
+ const badge = item.status === "warn" ? "โš ๏ธ WARN" : item.status === "error" ? "โŒ ERROR" : "โŒ FAIL";
322
+ const summary = summarizeVisibleIssue(item);
323
+ lines.push(`- **${badge}** ${formatCodeSpan(item.id)} (${item.severity}, ${escapeTableCell(String(item.type))}): ${summary}`);
324
+ if (typeof item.repro === "string" && item.repro.trim().length > 0) {
325
+ lines.push("");
326
+ lines.push(" Repro:");
327
+ const block = formatCodeBlock(item.repro, "sh")
328
+ .split("\n")
329
+ .map((l) => ` ${l}`)
330
+ .join("\n");
331
+ lines.push(block);
332
+ }
333
+ }
334
+ if (visibleIssues.length > MAX_VISIBLE_ISSUES) {
335
+ lines.push("");
336
+ lines.push(`_... and ${visibleIssues.length - MAX_VISIBLE_ISSUES} more visible failing/warned invariant(s)._`);
337
+ }
338
+ lines.push("");
339
+ }
340
+ if (holdoutIssues.length > 0) {
341
+ lines.push(`### Holdout Failures (${holdoutIssues.length} redacted)`);
342
+ lines.push("");
343
+ const shownHoldouts = holdoutIssues.slice(0, MAX_HOLDOUT_ISSUES);
344
+ for (const item of shownHoldouts) {
345
+ const badge = item.status === "warn" ? "โš ๏ธ WARN" : "โŒ FAIL";
346
+ const hint = getSafeHoldoutHint(item);
347
+ lines.push(`- **${badge}** ${formatCodeSpan(item.id)} (${item.severity}) _[holdout redacted]_: ${hint}`);
348
+ }
349
+ if (holdoutIssues.length > MAX_HOLDOUT_ISSUES) {
350
+ lines.push("");
351
+ lines.push(`_... and ${holdoutIssues.length - MAX_HOLDOUT_ISSUES} more redacted holdout failure(s)._`);
352
+ }
353
+ lines.push("");
354
+ }
355
+ return lines.join("\n").trimEnd() + "\n";
356
+ }
357
+ export function writePrCommentMarkdown(outPath, report, options = {}) {
358
+ const markdown = renderPrCommentMarkdown(report, options);
359
+ return writeFileAtomically(outPath, markdown);
360
+ }
@@ -0,0 +1,47 @@
1
+ import type { Invariant, InvariantResult, OracleContext } from "./types.js";
2
+ export declare const REPLAY_CACHE_SCHEMA_VERSION = "1";
3
+ export declare const REPLAY_CACHE_FILENAME = "replay.json";
4
+ export interface ReplayCacheEntry {
5
+ key: string;
6
+ invariantId: string;
7
+ targetFingerprint: string;
8
+ result: InvariantResult;
9
+ cachedAt: string;
10
+ lastUsedAt: string;
11
+ }
12
+ export interface ReplayCacheStore {
13
+ schemaVersion: string;
14
+ entries: Record<string, ReplayCacheEntry>;
15
+ }
16
+ /**
17
+ * Deterministic SHA-256 hex digest over canonical key-sorted JSON.
18
+ */
19
+ export declare function stableHash(value: unknown): string;
20
+ /**
21
+ * Computes a deterministic SHA-256 fingerprint for a local target and context.
22
+ * Returns `null` for live HTTP/HTTPS URLs so remote targets are never cached.
23
+ */
24
+ export declare function computeTargetFingerprint(target: string, cwd?: string, ctx?: Pick<OracleContext, "headers" | "storageState" | "strict">): string | null;
25
+ /**
26
+ * Computes a deterministic SHA-256 cache key for an invariant + target fingerprint.
27
+ */
28
+ export declare function computeInvariantCacheKey(invariant: Invariant, targetFingerprint: string, strict: boolean): string;
29
+ /**
30
+ * Loads `.vibecode/cache/replay.json`. Recovers gracefully with an empty store
31
+ * if the file is missing, unreadable, malformed, or has an incompatible schema.
32
+ */
33
+ export declare function loadReplayCache(workspaceDir: string): ReplayCacheStore;
34
+ /**
35
+ * Evicts oldest `lastUsedAt` entries above `maxEntries` and atomically writes
36
+ * `.vibecode/cache/replay.json` via `.tmp` + rename.
37
+ */
38
+ export declare function saveReplayCache(workspaceDir: string, store: ReplayCacheStore, maxEntries?: number): string;
39
+ /**
40
+ * Looks up a cached passing result for `invariant` under `ctx`.
41
+ * Never returns cached hits for holdout invariants, non-passing results, or live URLs.
42
+ */
43
+ export declare function lookupCachedResult(store: ReplayCacheStore, invariant: Invariant, ctx: OracleContext): InvariantResult | null;
44
+ /**
45
+ * Stores a passing non-holdout result for a cacheable local target.
46
+ */
47
+ export declare function storeCachedResult(store: ReplayCacheStore, invariant: Invariant, ctx: OracleContext, result: InvariantResult): boolean;