vibecode-anything 0.0.0-stage → 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 (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +407 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +2519 -0
  5. package/dist/core/adapters.d.ts +31 -0
  6. package/dist/core/adapters.js +478 -0
  7. package/dist/core/agent-adapter.d.ts +67 -0
  8. package/dist/core/agent-adapter.js +312 -0
  9. package/dist/core/anti-cheat.d.ts +6 -0
  10. package/dist/core/anti-cheat.js +372 -0
  11. package/dist/core/badge.d.ts +18 -0
  12. package/dist/core/badge.js +360 -0
  13. package/dist/core/cache.d.ts +47 -0
  14. package/dist/core/cache.js +403 -0
  15. package/dist/core/ci-export.d.ts +35 -0
  16. package/dist/core/ci-export.js +796 -0
  17. package/dist/core/ci-formats.d.ts +21 -0
  18. package/dist/core/ci-formats.js +388 -0
  19. package/dist/core/client-codegen.d.ts +36 -0
  20. package/dist/core/client-codegen.js +2538 -0
  21. package/dist/core/compose.d.ts +71 -0
  22. package/dist/core/compose.js +1088 -0
  23. package/dist/core/diff.d.ts +10 -0
  24. package/dist/core/diff.js +207 -0
  25. package/dist/core/docs-export.d.ts +37 -0
  26. package/dist/core/docs-export.js +2706 -0
  27. package/dist/core/doctor.d.ts +70 -0
  28. package/dist/core/doctor.js +525 -0
  29. package/dist/core/errors.d.ts +32 -0
  30. package/dist/core/errors.js +81 -0
  31. package/dist/core/exec.d.ts +38 -0
  32. package/dist/core/exec.js +336 -0
  33. package/dist/core/fixtures.d.ts +153 -0
  34. package/dist/core/fixtures.js +2245 -0
  35. package/dist/core/format.d.ts +77 -0
  36. package/dist/core/format.js +632 -0
  37. package/dist/core/fs-snapshot.d.ts +37 -0
  38. package/dist/core/fs-snapshot.js +216 -0
  39. package/dist/core/graphql-export.d.ts +34 -0
  40. package/dist/core/graphql-export.js +2482 -0
  41. package/dist/core/har-export.d.ts +29 -0
  42. package/dist/core/har-export.js +988 -0
  43. package/dist/core/html-report.d.ts +27 -0
  44. package/dist/core/html-report.js +1535 -0
  45. package/dist/core/http-export.d.ts +31 -0
  46. package/dist/core/http-export.js +726 -0
  47. package/dist/core/impact.d.ts +80 -0
  48. package/dist/core/impact.js +1412 -0
  49. package/dist/core/lint.d.ts +38 -0
  50. package/dist/core/lint.js +1111 -0
  51. package/dist/core/load-export.d.ts +37 -0
  52. package/dist/core/load-export.js +1813 -0
  53. package/dist/core/mcp-export.d.ts +35 -0
  54. package/dist/core/mcp-export.js +1736 -0
  55. package/dist/core/mock-server.d.ts +47 -0
  56. package/dist/core/mock-server.js +1722 -0
  57. package/dist/core/openapi-export.d.ts +44 -0
  58. package/dist/core/openapi-export.js +1074 -0
  59. package/dist/core/parity.d.ts +14 -0
  60. package/dist/core/parity.js +173 -0
  61. package/dist/core/playwright-exporter.d.ts +23 -0
  62. package/dist/core/playwright-exporter.js +1343 -0
  63. package/dist/core/png.d.ts +7 -0
  64. package/dist/core/png.js +339 -0
  65. package/dist/core/regression.d.ts +54 -0
  66. package/dist/core/regression.js +529 -0
  67. package/dist/core/responsive.d.ts +86 -0
  68. package/dist/core/responsive.js +606 -0
  69. package/dist/core/run.d.ts +74 -0
  70. package/dist/core/run.js +696 -0
  71. package/dist/core/scheduler.d.ts +24 -0
  72. package/dist/core/scheduler.js +162 -0
  73. package/dist/core/schema-export.d.ts +29 -0
  74. package/dist/core/schema-export.js +2215 -0
  75. package/dist/core/schema.d.ts +18 -0
  76. package/dist/core/schema.js +1057 -0
  77. package/dist/core/security.d.ts +233 -0
  78. package/dist/core/security.js +1839 -0
  79. package/dist/core/server-export.d.ts +38 -0
  80. package/dist/core/server-export.js +3198 -0
  81. package/dist/core/slices.d.ts +24 -0
  82. package/dist/core/slices.js +294 -0
  83. package/dist/core/spec-writer.d.ts +9 -0
  84. package/dist/core/spec-writer.js +1202 -0
  85. package/dist/core/store.d.ts +26 -0
  86. package/dist/core/store.js +217 -0
  87. package/dist/core/target-map.d.ts +34 -0
  88. package/dist/core/target-map.js +262 -0
  89. package/dist/core/test-exporter.d.ts +25 -0
  90. package/dist/core/test-exporter.js +1918 -0
  91. package/dist/core/types.d.ts +919 -0
  92. package/dist/core/types.js +4 -0
  93. package/dist/core/visual-semantic.d.ts +67 -0
  94. package/dist/core/visual-semantic.js +673 -0
  95. package/dist/core/visual.d.ts +34 -0
  96. package/dist/core/visual.js +508 -0
  97. package/dist/core/watch.d.ts +78 -0
  98. package/dist/core/watch.js +495 -0
  99. package/dist/core/yaml.d.ts +5 -0
  100. package/dist/core/yaml.js +1009 -0
  101. package/dist/diagnostics/diagnose.d.ts +53 -0
  102. package/dist/diagnostics/diagnose.js +1083 -0
  103. package/dist/diagnostics/flake.d.ts +71 -0
  104. package/dist/diagnostics/flake.js +608 -0
  105. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  106. package/dist/diagnostics/mutation-audit.js +769 -0
  107. package/dist/diagnostics/spatial.d.ts +42 -0
  108. package/dist/diagnostics/spatial.js +346 -0
  109. package/dist/diagnostics/trends.d.ts +122 -0
  110. package/dist/diagnostics/trends.js +1190 -0
  111. package/dist/discovery/discover.d.ts +111 -0
  112. package/dist/discovery/discover.js +2017 -0
  113. package/dist/discovery/lock.d.ts +116 -0
  114. package/dist/discovery/lock.js +1505 -0
  115. package/dist/discovery/routes.d.ts +36 -0
  116. package/dist/discovery/routes.js +1494 -0
  117. package/dist/discovery/test-importer.d.ts +92 -0
  118. package/dist/discovery/test-importer.js +4952 -0
  119. package/dist/index.d.ts +123 -0
  120. package/dist/index.js +99 -0
  121. package/dist/ingestors/api-collections.d.ts +28 -0
  122. package/dist/ingestors/api-collections.js +2335 -0
  123. package/dist/ingestors/api-repo.d.ts +6 -0
  124. package/dist/ingestors/api-repo.js +1120 -0
  125. package/dist/ingestors/asyncapi.d.ts +26 -0
  126. package/dist/ingestors/asyncapi.js +2105 -0
  127. package/dist/ingestors/bridges.d.ts +5 -0
  128. package/dist/ingestors/bridges.js +1264 -0
  129. package/dist/ingestors/cli.d.ts +10 -0
  130. package/dist/ingestors/cli.js +454 -0
  131. package/dist/ingestors/curl.d.ts +14 -0
  132. package/dist/ingestors/curl.js +1024 -0
  133. package/dist/ingestors/graphql.d.ts +56 -0
  134. package/dist/ingestors/graphql.js +1852 -0
  135. package/dist/ingestors/http-file.d.ts +20 -0
  136. package/dist/ingestors/http-file.js +923 -0
  137. package/dist/ingestors/image.d.ts +2 -0
  138. package/dist/ingestors/image.js +147 -0
  139. package/dist/ingestors/index.d.ts +5 -0
  140. package/dist/ingestors/index.js +577 -0
  141. package/dist/ingestors/openrpc.d.ts +29 -0
  142. package/dist/ingestors/openrpc.js +1807 -0
  143. package/dist/ingestors/proto.d.ts +47 -0
  144. package/dist/ingestors/proto.js +2690 -0
  145. package/dist/ingestors/trace.d.ts +10 -0
  146. package/dist/ingestors/trace.js +599 -0
  147. package/dist/ingestors/video.d.ts +50 -0
  148. package/dist/ingestors/video.js +655 -0
  149. package/dist/ingestors/web.d.ts +40 -0
  150. package/dist/ingestors/web.js +839 -0
  151. package/dist/mcp/server.d.ts +2 -0
  152. package/dist/mcp/server.js +3969 -0
  153. package/dist/oracles/api-repo.d.ts +2 -0
  154. package/dist/oracles/api-repo.js +286 -0
  155. package/dist/oracles/cli.d.ts +2 -0
  156. package/dist/oracles/cli.js +205 -0
  157. package/dist/oracles/http-workflow.d.ts +68 -0
  158. package/dist/oracles/http-workflow.js +828 -0
  159. package/dist/oracles/image.d.ts +2 -0
  160. package/dist/oracles/image.js +429 -0
  161. package/dist/oracles/index.d.ts +6 -0
  162. package/dist/oracles/index.js +320 -0
  163. package/dist/oracles/perf-budget.d.ts +90 -0
  164. package/dist/oracles/perf-budget.js +1329 -0
  165. package/dist/oracles/stream.d.ts +94 -0
  166. package/dist/oracles/stream.js +1268 -0
  167. package/dist/oracles/ui-states.d.ts +49 -0
  168. package/dist/oracles/ui-states.js +894 -0
  169. package/dist/oracles/video.d.ts +21 -0
  170. package/dist/oracles/video.js +627 -0
  171. package/dist/oracles/web.d.ts +2 -0
  172. package/dist/oracles/web.js +871 -0
  173. package/dist/plugins/builtins.d.ts +12 -0
  174. package/dist/plugins/builtins.js +1052 -0
  175. package/dist/plugins/registry.d.ts +86 -0
  176. package/dist/plugins/registry.js +554 -0
  177. package/dist/setup/index.d.ts +7 -0
  178. package/dist/setup/index.js +298 -0
  179. package/package.json +54 -4
  180. package/skills/vibecode-anything/SKILL.md +75 -0
@@ -0,0 +1,7 @@
1
+ import type { ImageDimensions, RgbaImage } from "./types.js";
2
+ declare const PNG_SIG: Buffer<ArrayBuffer>;
3
+ declare function crc32(buf: Buffer | Uint8Array): number;
4
+ export declare function decodePng(buffer: Buffer | Uint8Array): RgbaImage;
5
+ export declare function encodePng({ width, height, data }: RgbaImage): Buffer;
6
+ export declare function readImageDimensions(buffer: Buffer | Uint8Array): ImageDimensions | null;
7
+ export { PNG_SIG, crc32 };
@@ -0,0 +1,339 @@
1
+ import zlib from "node:zlib";
2
+ import { VibecodeError, errorMessage } from "./errors.js";
3
+ const PNG_SIG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
4
+ const MAX_PNG_CHUNK_LEN = 0x7fffffff;
5
+ const MAX_PNG_DIMENSION = 32768;
6
+ const MAX_PNG_PIXELS = 64 * 1024 * 1024; // 64 MP cap (~256 MB RGBA) to prevent OOM/decompression bombs
7
+ const CRC_TABLE = (() => {
8
+ const table = new Uint32Array(256);
9
+ for (let n = 0; n < 256; n++) {
10
+ let c = n;
11
+ for (let k = 0; k < 8; k++)
12
+ c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
13
+ table[n] = c >>> 0;
14
+ }
15
+ return table;
16
+ })();
17
+ function toBuffer(input) {
18
+ return Buffer.isBuffer(input) ? input : Buffer.from(input.buffer, input.byteOffset, input.byteLength);
19
+ }
20
+ function crc32(buf) {
21
+ let c = 0xffffffff;
22
+ for (let i = 0; i < buf.length; i++)
23
+ c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
24
+ return (c ^ 0xffffffff) >>> 0;
25
+ }
26
+ function readUInt32(buf, off) {
27
+ return ((buf[off] << 24) | (buf[off + 1] << 16) | (buf[off + 2] << 8) | buf[off + 3]) >>> 0;
28
+ }
29
+ function writeUInt32(buf, off, value) {
30
+ buf[off] = (value >>> 24) & 0xff;
31
+ buf[off + 1] = (value >>> 16) & 0xff;
32
+ buf[off + 2] = (value >>> 8) & 0xff;
33
+ buf[off + 3] = value & 0xff;
34
+ }
35
+ function paeth(a, b, c) {
36
+ const p = a + b - c;
37
+ const pa = Math.abs(p - a);
38
+ const pb = Math.abs(p - b);
39
+ const pc = Math.abs(p - c);
40
+ if (pa <= pb && pa <= pc)
41
+ return a;
42
+ if (pb <= pc)
43
+ return b;
44
+ return c;
45
+ }
46
+ function channelsFor(colorType) {
47
+ switch (colorType) {
48
+ case 0: return 1;
49
+ case 2: return 3;
50
+ case 3: return 1;
51
+ case 4: return 2;
52
+ case 6: return 4;
53
+ default: throw new VibecodeError("UNSUPPORTED_FORMAT", `Unsupported PNG color type ${colorType}`);
54
+ }
55
+ }
56
+ export function decodePng(buffer) {
57
+ const buf = toBuffer(buffer);
58
+ if (buf.length < 8 || !buf.subarray(0, 8).equals(PNG_SIG)) {
59
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "Not a PNG file (bad signature)");
60
+ }
61
+ let off = 8;
62
+ let width = 0, height = 0, bitDepth = 0, colorType = 0, interlace = 0;
63
+ let sawIhdr = false;
64
+ let sawIend = false;
65
+ let palette = null;
66
+ let trns = null;
67
+ const idat = [];
68
+ while (off + 8 <= buf.length) {
69
+ const len = readUInt32(buf, off);
70
+ const type = buf.toString("ascii", off + 4, off + 8);
71
+ const dataStart = off + 8;
72
+ const dataEnd = dataStart + len;
73
+ if (len > MAX_PNG_CHUNK_LEN || dataEnd + 4 > buf.length) {
74
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "Truncated or oversized PNG chunk");
75
+ }
76
+ const expectedCrc = readUInt32(buf, dataEnd);
77
+ const actualCrc = crc32(buf.subarray(off + 4, dataEnd));
78
+ if (actualCrc !== expectedCrc) {
79
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Corrupt PNG chunk CRC in ${type} (expected 0x${expectedCrc.toString(16)}, got 0x${actualCrc.toString(16)})`);
80
+ }
81
+ const data = buf.subarray(dataStart, dataEnd);
82
+ if (type === "IHDR") {
83
+ if (data.length !== 13) {
84
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Invalid PNG IHDR chunk length ${data.length}`);
85
+ }
86
+ sawIhdr = true;
87
+ width = readUInt32(data, 0);
88
+ height = readUInt32(data, 4);
89
+ bitDepth = data[8];
90
+ colorType = data[9];
91
+ const compression = data[10];
92
+ const filterMethod = data[11];
93
+ interlace = data[12];
94
+ if (compression !== 0 || filterMethod !== 0) {
95
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Unsupported PNG compression/filter method (${compression}/${filterMethod})`);
96
+ }
97
+ }
98
+ else if (type === "PLTE") {
99
+ palette = Buffer.from(data);
100
+ }
101
+ else if (type === "tRNS") {
102
+ trns = Buffer.from(data);
103
+ }
104
+ else if (type === "IDAT") {
105
+ idat.push(Buffer.from(data));
106
+ }
107
+ else if (type === "IEND") {
108
+ sawIend = true;
109
+ break;
110
+ }
111
+ off = dataEnd + 4;
112
+ }
113
+ if (!sawIend && off < buf.length) {
114
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "Truncated PNG chunk header");
115
+ }
116
+ if (!sawIhdr || !width || !height) {
117
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "PNG missing IHDR or has zero dimensions");
118
+ }
119
+ if (width > MAX_PNG_DIMENSION || height > MAX_PNG_DIMENSION || width * height > MAX_PNG_PIXELS) {
120
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `PNG dimensions ${width}x${height} exceed maximum supported size`);
121
+ }
122
+ if (bitDepth !== 8)
123
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Unsupported PNG bit depth ${bitDepth} (only 8-bit supported)`);
124
+ if (interlace !== 0)
125
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "Interlaced PNG is not supported; convert to non-interlaced");
126
+ const channels = channelsFor(colorType);
127
+ if (colorType === 3 && !palette)
128
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "Indexed PNG missing PLTE");
129
+ if (idat.length === 0)
130
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "PNG missing IDAT chunk");
131
+ const rowLen = width * channels;
132
+ const expected = (rowLen + 1) * height;
133
+ let raw;
134
+ try {
135
+ raw = zlib.inflateSync(Buffer.concat(idat), { maxOutputLength: expected + 1024 });
136
+ }
137
+ catch (err) {
138
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Failed to inflate PNG data: ${errorMessage(err)}`);
139
+ }
140
+ if (raw.length < expected)
141
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "PNG pixel data is truncated");
142
+ const pixels = new Uint8Array(height * rowLen);
143
+ let srcOff = 0;
144
+ let prev = new Uint8Array(rowLen);
145
+ for (let y = 0; y < height; y++) {
146
+ const filter = raw[srcOff++];
147
+ const rowStart = y * rowLen;
148
+ for (let i = 0; i < rowLen; i++) {
149
+ const rawByte = raw[srcOff + i];
150
+ const left = i >= channels ? pixels[rowStart + i - channels] : 0;
151
+ const up = prev[i];
152
+ const upLeft = i >= channels ? prev[i - channels] : 0;
153
+ let value;
154
+ switch (filter) {
155
+ case 0:
156
+ value = rawByte;
157
+ break;
158
+ case 1:
159
+ value = rawByte + left;
160
+ break;
161
+ case 2:
162
+ value = rawByte + up;
163
+ break;
164
+ case 3:
165
+ value = rawByte + ((left + up) >> 1);
166
+ break;
167
+ case 4:
168
+ value = rawByte + paeth(left, up, upLeft);
169
+ break;
170
+ default: throw new VibecodeError("UNSUPPORTED_FORMAT", `Unsupported PNG filter ${filter}`);
171
+ }
172
+ pixels[rowStart + i] = value & 0xff;
173
+ }
174
+ prev = pixels.subarray(rowStart, rowStart + rowLen);
175
+ srcOff += rowLen;
176
+ }
177
+ // Convert to RGBA
178
+ const data = new Uint8Array(width * height * 4);
179
+ for (let i = 0, p = 0; i < width * height; i++) {
180
+ const s = i * channels;
181
+ if (colorType === 0) {
182
+ const g = pixels[s];
183
+ data[p++] = g;
184
+ data[p++] = g;
185
+ data[p++] = g;
186
+ data[p++] = 255;
187
+ }
188
+ else if (colorType === 2) {
189
+ data[p++] = pixels[s];
190
+ data[p++] = pixels[s + 1];
191
+ data[p++] = pixels[s + 2];
192
+ data[p++] = 255;
193
+ }
194
+ else if (colorType === 3 && palette) {
195
+ const idx = pixels[s];
196
+ const pr = palette[idx * 3] ?? 0;
197
+ const pg = palette[idx * 3 + 1] ?? 0;
198
+ const pb = palette[idx * 3 + 2] ?? 0;
199
+ data[p++] = pr;
200
+ data[p++] = pg;
201
+ data[p++] = pb;
202
+ data[p++] = trns && idx < trns.length ? trns[idx] : 255;
203
+ }
204
+ else if (colorType === 4) {
205
+ const g = pixels[s];
206
+ data[p++] = g;
207
+ data[p++] = g;
208
+ data[p++] = g;
209
+ data[p++] = pixels[s + 1];
210
+ }
211
+ else {
212
+ data[p++] = pixels[s];
213
+ data[p++] = pixels[s + 1];
214
+ data[p++] = pixels[s + 2];
215
+ data[p++] = pixels[s + 3];
216
+ }
217
+ }
218
+ return { width, height, data };
219
+ }
220
+ function buildChunk(type, data) {
221
+ const typeBuf = Buffer.from(type, "ascii");
222
+ const dataBuf = toBuffer(data);
223
+ const out = Buffer.alloc(12 + dataBuf.length);
224
+ writeUInt32(out, 0, dataBuf.length);
225
+ typeBuf.copy(out, 4);
226
+ dataBuf.copy(out, 8);
227
+ const crc = crc32(Buffer.concat([typeBuf, dataBuf]));
228
+ writeUInt32(out, 8 + dataBuf.length, crc);
229
+ return out;
230
+ }
231
+ export function encodePng({ width, height, data }) {
232
+ if (!Number.isInteger(width) || !Number.isInteger(height) || width <= 0 || height <= 0) {
233
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "encodePng requires positive integer width/height");
234
+ }
235
+ if (!data || data.length < width * height * 4) {
236
+ throw new VibecodeError("UNSUPPORTED_FORMAT", "encodePng requires RGBA data of width*height*4 bytes");
237
+ }
238
+ const rowLen = width * 4;
239
+ const raw = Buffer.alloc((rowLen + 1) * height);
240
+ for (let y = 0; y < height; y++) {
241
+ raw[y * (rowLen + 1)] = 0;
242
+ raw.set(data.subarray(y * rowLen, y * rowLen + rowLen), y * (rowLen + 1) + 1);
243
+ }
244
+ const ihdr = Buffer.alloc(13);
245
+ writeUInt32(ihdr, 0, width);
246
+ writeUInt32(ihdr, 4, height);
247
+ ihdr[8] = 8; // bit depth
248
+ ihdr[9] = 6; // RGBA
249
+ ihdr[10] = 0;
250
+ ihdr[11] = 0;
251
+ ihdr[12] = 0;
252
+ const compressed = zlib.deflateSync(raw, { level: 9 });
253
+ return Buffer.concat([
254
+ PNG_SIG,
255
+ buildChunk("IHDR", ihdr),
256
+ buildChunk("IDAT", compressed),
257
+ buildChunk("IEND", Buffer.alloc(0))
258
+ ]);
259
+ }
260
+ export function readImageDimensions(buffer) {
261
+ const buf = toBuffer(buffer);
262
+ if (buf.length >= 8 && buf.subarray(0, 8).equals(PNG_SIG)) {
263
+ if (buf.length < 24)
264
+ return null;
265
+ if (buf.toString("ascii", 12, 16) !== "IHDR" || readUInt32(buf, 8) < 13)
266
+ return null;
267
+ const width = readUInt32(buf, 16);
268
+ const height = readUInt32(buf, 20);
269
+ if (!width || !height)
270
+ return null;
271
+ return { format: "png", width, height };
272
+ }
273
+ // JPEG
274
+ if (buf.length >= 4 && buf[0] === 0xff && buf[1] === 0xd8) {
275
+ let off = 2;
276
+ while (off + 4 <= buf.length) {
277
+ if (buf[off] !== 0xff) {
278
+ off++;
279
+ continue;
280
+ }
281
+ let marker = buf[off + 1];
282
+ while (marker === 0xff && off + 2 < buf.length) {
283
+ off++;
284
+ marker = buf[off + 1];
285
+ }
286
+ if (marker === 0xff)
287
+ break;
288
+ if (marker === 0xd8 || marker === 0xd9) {
289
+ off += 2;
290
+ continue;
291
+ }
292
+ if (marker >= 0xd0 && marker <= 0xd7) {
293
+ off += 2;
294
+ continue;
295
+ }
296
+ if (off + 4 > buf.length)
297
+ break;
298
+ const len = buf.readUInt16BE(off + 2);
299
+ if (len < 2)
300
+ break;
301
+ if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
302
+ if (off + 9 > buf.length)
303
+ break;
304
+ const height = buf.readUInt16BE(off + 5);
305
+ const width = buf.readUInt16BE(off + 7);
306
+ return { format: "jpeg", width, height };
307
+ }
308
+ off += 2 + len;
309
+ }
310
+ return null;
311
+ }
312
+ // WebP
313
+ if (buf.length >= 30 && buf.toString("ascii", 0, 4) === "RIFF" && buf.toString("ascii", 8, 12) === "WEBP") {
314
+ const kind = buf.toString("ascii", 12, 16);
315
+ if (kind === "VP8X") {
316
+ const width = 1 + (buf[24] | (buf[25] << 8) | (buf[26] << 16));
317
+ const height = 1 + (buf[27] | (buf[28] << 8) | (buf[29] << 16));
318
+ return { format: "webp", width, height };
319
+ }
320
+ if (kind === "VP8 ") {
321
+ if (buf[23] !== 0x9d || buf[24] !== 0x01 || buf[25] !== 0x2a)
322
+ return null;
323
+ const width = buf.readUInt16LE(26) & 0x3fff;
324
+ const height = buf.readUInt16LE(28) & 0x3fff;
325
+ return { format: "webp", width, height };
326
+ }
327
+ if (kind === "VP8L") {
328
+ if (buf[20] !== 0x2f)
329
+ return null;
330
+ const bits = buf.readUInt32LE(21);
331
+ const width = (bits & 0x3fff) + 1;
332
+ const height = ((bits >> 14) & 0x3fff) + 1;
333
+ return { format: "webp", width, height };
334
+ }
335
+ return null;
336
+ }
337
+ return null;
338
+ }
339
+ export { PNG_SIG, crc32 };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Zero-dependency ParityReport-to-ParityReport regression comparator,
3
+ * pretty terminal formatter, and PR/CI Markdown renderer.
4
+ */
5
+ import type { GateStatus, ParityReport } from "./types.js";
6
+ export interface RegressionInvariantChange {
7
+ id: string;
8
+ severity: string;
9
+ beforeStatus: string | null;
10
+ afterStatus: string | null;
11
+ beforeScore: number | null;
12
+ afterScore: number | null;
13
+ redacted?: boolean;
14
+ failures?: string[];
15
+ }
16
+ export interface ReportRegressionResult {
17
+ ok: boolean;
18
+ regressed: boolean;
19
+ improved: boolean;
20
+ gateBefore: GateStatus;
21
+ gateAfter: GateStatus;
22
+ gateChanged: boolean;
23
+ hardParityBefore: number;
24
+ hardParityAfter: number;
25
+ hardParityDelta: number;
26
+ compositeScoreBefore: number;
27
+ compositeScoreAfter: number;
28
+ compositeScoreDelta: number;
29
+ newlyBroken: RegressionInvariantChange[];
30
+ newlyFixed: RegressionInvariantChange[];
31
+ stillFailing: RegressionInvariantChange[];
32
+ stillPassing: string[];
33
+ addedInvariants: string[];
34
+ removedInvariants: string[];
35
+ summary: string;
36
+ }
37
+ export interface CompareReportsOptions {
38
+ strict?: boolean;
39
+ }
40
+ export interface FormatPrettyRegressionOptions {
41
+ color?: boolean;
42
+ }
43
+ /**
44
+ * Compare a baseline ParityReport against a current ParityReport to detect regressions and improvements.
45
+ */
46
+ export declare function compareReports(baseline: ParityReport, current: ParityReport, options?: CompareReportsOptions): ReportRegressionResult;
47
+ /**
48
+ * Format a ReportRegressionResult for terminal display (zero ANSI codes unless `options.color === true`).
49
+ */
50
+ export declare function formatPrettyRegression(diff: ReportRegressionResult, options?: FormatPrettyRegressionOptions): string;
51
+ /**
52
+ * Render a self-contained PR/CI Markdown summary section for a ReportRegressionResult.
53
+ */
54
+ export declare function renderRegressionMarkdown(diff: ReportRegressionResult): string;