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
@@ -1,13 +1,15 @@
1
1
  import fs from "node:fs";
2
- import { VibecodeError } from "./errors.js";
3
- import { decodePng, readImageDimensions, encodePng } from "./png.js";
2
+ import { VibecodeError, errorMessage } from "./errors.js";
3
+ import { PNG_SIG, decodePng, readImageDimensions, encodePng } from "./png.js";
4
4
  import { loadSharp } from "./adapters.js";
5
5
  const MAX_SSIM_EDGE = 512;
6
6
  export async function decodeImage(filePath, deps = {}) {
7
7
  const buf = fs.readFileSync(filePath);
8
8
  const dims = readImageDimensions(buf);
9
+ const hasPngSig = buf.length >= 8 && buf.subarray(0, 8).equals(PNG_SIG);
10
+ const looksLikePng = dims?.format === "png" || hasPngSig || /\.png$/i.test(filePath);
9
11
  let pngErr = null;
10
- if (dims && dims.format === "png") {
12
+ if (dims?.format === "png" || hasPngSig) {
11
13
  try {
12
14
  const decoded = decodePng(buf);
13
15
  return { ...decoded, format: "png", backend: "png-native" };
@@ -19,18 +21,28 @@ export async function decodeImage(filePath, deps = {}) {
19
21
  const explicitSharp = Object.prototype.hasOwnProperty.call(deps, "sharp") ? deps.sharp : undefined;
20
22
  const sharp = explicitSharp === null ? null : (explicitSharp || (await loadSharp(deps)));
21
23
  if (sharp) {
22
- const { data, info } = await sharp(buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
23
- return {
24
- width: info.width,
25
- height: info.height,
26
- data: new Uint8Array(data),
27
- format: dims?.format || "unknown",
28
- backend: "sharp"
29
- };
24
+ try {
25
+ const { data, info } = await sharp(buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
26
+ return {
27
+ width: info.width,
28
+ height: info.height,
29
+ data: new Uint8Array(data),
30
+ format: dims?.format || "unknown",
31
+ backend: "sharp"
32
+ };
33
+ }
34
+ catch (err) {
35
+ if (err instanceof VibecodeError)
36
+ throw err;
37
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Failed to decode image ${filePath}: ${errorMessage(err)}`);
38
+ }
30
39
  }
31
40
  if (pngErr)
32
41
  throw pngErr;
33
- throw new VibecodeError("ADAPTER_MISSING", `Cannot decode ${dims?.format || "unknown"} image without the optional 'sharp' adapter`, {
42
+ if (!dims) {
43
+ throw new VibecodeError("UNSUPPORTED_FORMAT", looksLikePng ? `Not a valid PNG image: ${filePath}` : `Unrecognized or corrupt image format: ${filePath}`);
44
+ }
45
+ throw new VibecodeError("ADAPTER_MISSING", `Cannot decode ${dims.format} image without the optional 'sharp' adapter`, {
34
46
  adapter: "sharp",
35
47
  installHint: "npm install sharp",
36
48
  fallbackHint: "Convert the image to a non-interlaced 8-bit PNG to use the zero-dependency decoder.",
@@ -312,6 +324,40 @@ function splitByGaps(profile, minSegFrac = 0.06) {
312
324
  segs.push([start, n]);
313
325
  return segs.length > 1 ? segs : [[0, n]];
314
326
  }
327
+ function classifyLayoutRegion(gray, W, H, x0, y0, rw, rh, bbox) {
328
+ const rx0 = Math.max(0, Math.min(W, Math.floor(x0)));
329
+ const ry0 = Math.max(0, Math.min(H, Math.floor(y0)));
330
+ const rx1 = Math.max(rx0, Math.min(W, Math.round(x0 + rw)));
331
+ const ry1 = Math.max(ry0, Math.min(H, Math.round(y0 + rh)));
332
+ let edgeH = 0;
333
+ let edgeV = 0;
334
+ let sum = 0;
335
+ let sumSq = 0;
336
+ let count = 0;
337
+ for (let y = ry0; y < ry1; y++) {
338
+ for (let x = rx0; x < rx1; x++) {
339
+ const val = gray[y * W + x];
340
+ sum += val;
341
+ sumSq += val * val;
342
+ count++;
343
+ if (y + 1 < ry1)
344
+ edgeH += Math.abs(val - gray[(y + 1) * W + x]);
345
+ if (x + 1 < rx1)
346
+ edgeV += Math.abs(val - gray[y * W + x + 1]);
347
+ }
348
+ }
349
+ const mean = count > 0 ? sum / count : 0;
350
+ const variance = count > 0 ? Math.max(0, sumSq / count - mean * mean) : 0;
351
+ const { y, w, h } = bbox;
352
+ const aspect = w / Math.max(h, 1e-4);
353
+ if (((y <= 0.14 || y + h >= 0.86) && h <= 0.18 && w >= 0.4) || (w <= 0.2 && h >= 0.5)) {
354
+ return "ui_chrome";
355
+ }
356
+ if ((aspect >= 2.2 && h <= 0.35) || (variance > 0 && edgeV > 0 && edgeH / edgeV >= 1.25 && h <= 0.4 && w >= 0.25)) {
357
+ return "text_band";
358
+ }
359
+ return "media_block";
360
+ }
315
361
  export function extractLayoutRegions(img, { maxDepth = 3 } = {}) {
316
362
  const maxEdge = 96;
317
363
  const scale = Math.min(1, maxEdge / Math.max(img.width, img.height));
@@ -323,7 +369,8 @@ export function extractLayoutRegions(img, { maxDepth = 3 } = {}) {
323
369
  const push = (x, y, w, h) => {
324
370
  if (regions.length >= 12)
325
371
  return;
326
- regions.push({ bbox: { x: x / W, y: y / H, w: w / W, h: h / H } });
372
+ const bbox = { x: x / W, y: y / H, w: w / W, h: h / H };
373
+ regions.push({ bbox, kind: classifyLayoutRegion(gray, W, H, x, y, w, h, bbox) });
327
374
  };
328
375
  const recurse = (x, y, w, h, depth) => {
329
376
  if (regions.length >= 12)
@@ -348,9 +395,11 @@ export function extractLayoutRegions(img, { maxDepth = 3 } = {}) {
348
395
  push(x, y, w, h);
349
396
  };
350
397
  recurse(0, 0, W, H, 0);
351
- if (regions.length === 0)
352
- regions.push({ bbox: { x: 0, y: 0, w: 1, h: 1 } });
353
- return regions.map((r, i) => ({ id: `r-${i}`, bbox: r.bbox }));
398
+ if (regions.length === 0) {
399
+ const bbox = { x: 0, y: 0, w: 1, h: 1 };
400
+ regions.push({ bbox, kind: classifyLayoutRegion(gray, W, H, 0, 0, W, H, bbox) });
401
+ }
402
+ return regions.map((r, i) => ({ id: `r-${i}`, bbox: r.bbox, kind: r.kind }));
354
403
  }
355
404
  export function compareRegionsIoU(regA, regB) {
356
405
  const a = regA || [];
@@ -1,4 +1,7 @@
1
- import type { ContractV02, OracleContext, ParityReport, SliceSummary, VerifyDeps } from "./types.js";
1
+ import { type ImpactAnalysisReport } from "./impact.js";
2
+ import { type TargetMap } from "./target-map.js";
3
+ import type { PluginRegistry } from "../plugins/registry.js";
4
+ import type { ContractV02, OracleContext, ParityReport, SliceSummary, VerifyDeps, VerifyMode } from "./types.js";
2
5
  export interface WatchFsWatcher {
3
6
  close(): void;
4
7
  }
@@ -10,12 +13,20 @@ export interface WatchRunEvent {
10
13
  timestamp: string;
11
14
  durationMs: number;
12
15
  report: ParityReport;
16
+ impact?: ImpactAnalysisReport;
13
17
  slices?: SliceSummary;
14
18
  newlyFixed: string[];
15
19
  newlyBroken: string[];
16
20
  }
17
21
  export interface WatchOptions {
18
- target: string;
22
+ target?: string;
23
+ targets?: TargetMap;
24
+ vars?: Record<string, string>;
25
+ mode?: VerifyMode;
26
+ concurrency?: number;
27
+ pluginRegistry?: PluginRegistry;
28
+ smart?: boolean;
29
+ impactGraph?: ReadonlyMap<string, ReadonlySet<string>>;
19
30
  cwd?: string;
20
31
  watchPaths?: string[];
21
32
  debounceMs?: number;
@@ -26,6 +37,11 @@ export interface WatchOptions {
26
37
  maxRuns?: number;
27
38
  runOnStart?: boolean;
28
39
  updateSlices?: boolean;
40
+ useCache?: boolean;
41
+ headers?: Record<string, string>;
42
+ storageState?: string;
43
+ skipFixtures?: boolean;
44
+ allowFixtureCommands?: boolean;
29
45
  onRun?: (event: WatchRunEvent) => void;
30
46
  onError?: (error: unknown) => void;
31
47
  signal?: AbortSignal;
@@ -35,6 +51,7 @@ export interface WatchDeps {
35
51
  readContract?: (cwd?: string) => ContractV02;
36
52
  writeContract?: (contract: unknown, cwd?: string, options?: {
37
53
  force?: boolean;
54
+ preserveHoldouts?: boolean;
38
55
  }) => string;
39
56
  writeLastReport?: (report: ParityReport, cwd?: string) => string;
40
57
  fsWatch?: (filename: string, options: {
@@ -50,4 +67,12 @@ export interface WatchHandle {
50
67
  /** Start a zero-dependency continuous verification watcher. */
51
68
  export declare function startWatch(options: WatchOptions, deps?: WatchDeps): Promise<WatchHandle>;
52
69
  /** Concise one-line summary of a watch run, with follow-up details when relevant. */
53
- export declare function formatWatchEvent(event: WatchRunEvent): string;
70
+ export declare function formatWatchEvent(event: WatchRunEvent, options?: {
71
+ vars?: Record<string, string>;
72
+ }): string;
73
+ export interface FormatPrettyWatchOptions {
74
+ color?: boolean;
75
+ vars?: Record<string, string>;
76
+ }
77
+ /** High-signal colorized or plain terminal summary of a watch run. */
78
+ export declare function formatPrettyWatchEvent(event: WatchRunEvent, options?: FormatPrettyWatchOptions): string;
@@ -1,7 +1,11 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { VibecodeError, errorMessage, errorCode } from "./errors.js";
4
+ import { analyzeImpact } from "./impact.js";
5
+ import { scoreReport } from "./parity.js";
6
+ import { sanitizeSingleLine } from "./security.js";
4
7
  import { readContract, writeContract, writeLastReport, resolveWorkspace } from "./store.js";
8
+ import { redactRuntimeVars } from "./target-map.js";
5
9
  import { verifyContract as defaultVerifyContract } from "../oracles/index.js";
6
10
  import { resolveSliceInvariants, updateSliceProgress, summarizeSlices } from "./slices.js";
7
11
  const DEFAULT_IGNORE = [".git", ".vibecode", "node_modules"];
@@ -22,9 +26,15 @@ function normalizeWatchError(error) {
22
26
  }
23
27
  /** Start a zero-dependency continuous verification watcher. */
24
28
  export async function startWatch(options, deps = {}) {
25
- if (typeof options.target !== "string" || !options.target.trim()) {
26
- throw new VibecodeError("TARGET_MISSING", "A non-empty verification target is required");
29
+ const hasTarget = typeof options.target === "string" && options.target.trim().length > 0;
30
+ const hasTargets = Boolean(options.targets &&
31
+ typeof options.targets === "object" &&
32
+ !Array.isArray(options.targets) &&
33
+ Object.keys(options.targets).length > 0);
34
+ if (!hasTarget && !hasTargets) {
35
+ throw new VibecodeError("TARGET_MISSING", "A non-empty verification target (or non-empty targets map) is required");
27
36
  }
37
+ const target = typeof options.target === "string" ? options.target : "";
28
38
  const rootDir = resolveWorkspace(options.cwd ?? process.cwd()).rootDir;
29
39
  const read = deps.readContract ?? readContract;
30
40
  const verify = deps.verifyContract ?? defaultVerifyContract;
@@ -71,6 +81,9 @@ export async function startWatch(options, deps = {}) {
71
81
  let runIndex = 0;
72
82
  let activeRun = null;
73
83
  let previousStatuses = new Map();
84
+ let lastReport = null;
85
+ let lastResultsById = new Map();
86
+ let lastResultOrder = [];
74
87
  const onAbort = () => {
75
88
  void close();
76
89
  };
@@ -124,7 +137,6 @@ export async function startWatch(options, deps = {}) {
124
137
  return;
125
138
  }
126
139
  timer = setTimeout(launch, debounceMs);
127
- timer.unref?.();
128
140
  };
129
141
  const executeRun = async (reason, files) => {
130
142
  if (closed)
@@ -133,16 +145,127 @@ export async function startWatch(options, deps = {}) {
133
145
  running = true;
134
146
  runIndex += 1;
135
147
  try {
148
+ let impact;
149
+ let effectiveInvariantIds = evaluationIds;
150
+ let isPartialSmartRun = false;
151
+ let skipVerify = false;
152
+ if (options.smart === true &&
153
+ (reason === "change" || reason === "manual") &&
154
+ files.length > 0 &&
155
+ lastReport !== null &&
156
+ lastResultsById.size > 0) {
157
+ const previousFailedIds = [...previousStatuses.entries()]
158
+ .filter(([, status]) => status === "fail" || status === "error" || status === "warn")
159
+ .map(([id]) => id);
160
+ impact = analyzeImpact(contract, files, {
161
+ cwd: rootDir,
162
+ ...(options.impactGraph ? { graph: options.impactGraph } : {}),
163
+ previousFailedIds
164
+ });
165
+ const evalSet = evaluationIds.length > 0 ? new Set(evaluationIds) : null;
166
+ const selectedIds = impact.fallbackToFull
167
+ ? evaluationIds
168
+ : evalSet
169
+ ? impact.selectedInvariantIds.filter((id) => evalSet.has(id))
170
+ : impact.selectedInvariantIds;
171
+ const fullEvalCount = evaluationIds.length > 0 ? evaluationIds.length : contract.invariants.length;
172
+ if (!impact.fallbackToFull && selectedIds.length === 0) {
173
+ skipVerify = true;
174
+ }
175
+ else if (!impact.fallbackToFull && selectedIds.length > 0 && selectedIds.length < fullEvalCount) {
176
+ isPartialSmartRun = true;
177
+ effectiveInvariantIds = selectedIds;
178
+ }
179
+ else {
180
+ effectiveInvariantIds = evaluationIds;
181
+ }
182
+ }
183
+ if (skipVerify && lastReport !== null) {
184
+ const reusedReport = {
185
+ ...lastReport,
186
+ timestamp: new Date().toISOString()
187
+ };
188
+ lastReport = reusedReport;
189
+ writeLast(reusedReport, rootDir);
190
+ const slices = contract.slices && contract.slices.length > 0 ? summarizeSlices(contract) : undefined;
191
+ const event = {
192
+ runIndex,
193
+ reason,
194
+ changedFiles: [...new Set(files)],
195
+ timestamp: reusedReport.timestamp,
196
+ durationMs: Date.now() - started,
197
+ report: reusedReport,
198
+ ...(impact ? { impact } : {}),
199
+ ...(slices ? { slices } : {}),
200
+ newlyFixed: [],
201
+ newlyBroken: []
202
+ };
203
+ options.onRun?.(event);
204
+ if (options.maxRuns !== undefined && runIndex >= options.maxRuns) {
205
+ teardown();
206
+ finish();
207
+ }
208
+ return;
209
+ }
136
210
  const ctx = {
137
- target: options.target,
211
+ target,
212
+ ...(hasTargets ? { targets: options.targets } : {}),
213
+ ...(options.vars && Object.keys(options.vars).length > 0 ? { vars: options.vars } : {}),
138
214
  cwd: rootDir,
139
215
  contract,
140
216
  strict: options.strict === true,
141
- ...(evaluationIds.length > 0 ? { invariantIds: evaluationIds } : {})
217
+ ...(options.mode ? { mode: options.mode } : {}),
218
+ ...(options.concurrency !== undefined ? { concurrency: options.concurrency } : {}),
219
+ ...(options.pluginRegistry ? { pluginRegistry: options.pluginRegistry } : {}),
220
+ ...(effectiveInvariantIds.length > 0 ? { invariantIds: effectiveInvariantIds } : {}),
221
+ ...(options.useCache ? { useCache: true } : {}),
222
+ ...(options.headers ? { headers: options.headers } : {}),
223
+ ...(options.storageState ? { storageState: options.storageState } : {}),
224
+ ...(options.skipFixtures ? { skipFixtures: true } : {}),
225
+ ...(options.allowFixtureCommands ? { allowFixtureCommands: true } : {})
142
226
  };
143
- const report = await verify(contract, ctx, {});
227
+ const rawReport = await verify(contract, ctx, {});
144
228
  if (closed)
145
229
  return;
230
+ let report;
231
+ if (isPartialSmartRun) {
232
+ for (const res of rawReport.results || []) {
233
+ lastResultsById.set(res.id, res);
234
+ if (!lastResultOrder.includes(res.id))
235
+ lastResultOrder.push(res.id);
236
+ }
237
+ const mergedResults = [];
238
+ const emittedIds = new Set();
239
+ for (const inv of contract.invariants) {
240
+ const res = lastResultsById.get(inv.id);
241
+ if (res && !emittedIds.has(inv.id)) {
242
+ emittedIds.add(inv.id);
243
+ mergedResults.push(res);
244
+ }
245
+ }
246
+ for (const id of lastResultOrder) {
247
+ const res = lastResultsById.get(id);
248
+ if (res && !emittedIds.has(id)) {
249
+ emittedIds.add(id);
250
+ mergedResults.push(res);
251
+ }
252
+ }
253
+ report = scoreReport(contract, mergedResults, {
254
+ strict: options.strict === true,
255
+ ...(rawReport.antiCheat?.status === "suspected" ? { antiCheat: rawReport.antiCheat } : {})
256
+ });
257
+ }
258
+ else {
259
+ report = rawReport;
260
+ lastResultsById = new Map();
261
+ lastResultOrder = [];
262
+ for (const res of report.results || []) {
263
+ lastResultsById.set(res.id, res);
264
+ if (!lastResultOrder.includes(res.id))
265
+ lastResultOrder.push(res.id);
266
+ }
267
+ }
268
+ lastReport = report;
146
269
  const newlyFixed = [];
147
270
  const newlyBroken = [];
148
271
  const fixedSet = new Set();
@@ -167,7 +290,7 @@ export async function startWatch(options, deps = {}) {
167
290
  let slices;
168
291
  if (updateSlices) {
169
292
  contract = updateSliceProgress(contract, report, { sliceIds, timestamp: report.timestamp });
170
- write(contract, rootDir, { force: true });
293
+ write(contract, rootDir, { force: true, preserveHoldouts: true });
171
294
  slices = summarizeSlices(contract);
172
295
  }
173
296
  else if (contract.slices && contract.slices.length > 0) {
@@ -180,6 +303,7 @@ export async function startWatch(options, deps = {}) {
180
303
  timestamp: report.timestamp || new Date().toISOString(),
181
304
  durationMs: Date.now() - started,
182
305
  report,
306
+ ...(impact ? { impact } : {}),
183
307
  ...(slices ? { slices } : {}),
184
308
  newlyFixed,
185
309
  newlyBroken
@@ -274,12 +398,98 @@ export async function startWatch(options, deps = {}) {
274
398
  }
275
399
  return { close, trigger, done, runCount: () => runIndex };
276
400
  }
401
+ function formatSmartImpactTag(impact) {
402
+ if (impact.fallbackToFull) {
403
+ return `smart=full(${sanitizeSingleLine(impact.fallbackReason)})`;
404
+ }
405
+ if (impact.docsOnly && impact.selectedInvariantIds.length === 0) {
406
+ return "smart=docs-only";
407
+ }
408
+ const selected = Number.isFinite(impact.summary?.selected)
409
+ ? impact.summary.selected
410
+ : impact.selectedInvariantIds.length;
411
+ const total = Number.isFinite(impact.summary?.total)
412
+ ? impact.summary.total
413
+ : selected;
414
+ return `smart=${selected}/${total}`;
415
+ }
277
416
  /** Concise one-line summary of a watch run, with follow-up details when relevant. */
278
- export function formatWatchEvent(event) {
279
- const fixed = event.newlyFixed.length > 0 ? event.newlyFixed.join(", ") : "none";
280
- const broken = event.newlyBroken.length > 0 ? event.newlyBroken.join(", ") : "none";
281
- const next = event.slices?.nextSlice ?? "none";
417
+ export function formatWatchEvent(event, options = {}) {
418
+ const fixed = event.newlyFixed.length > 0 ? event.newlyFixed.map((s) => sanitizeSingleLine(s)).join(", ") : "none";
419
+ const broken = event.newlyBroken.length > 0 ? event.newlyBroken.map((s) => sanitizeSingleLine(s)).join(", ") : "none";
420
+ const next = event.slices?.nextSlice ? sanitizeSingleLine(event.slices.nextSlice) : "none";
282
421
  const files = event.changedFiles.length > 0 ? String(event.changedFiles.length) : "0";
283
422
  const score = Number.isFinite(event.report.compositeScore) ? event.report.compositeScore.toFixed(3) : "0.000";
284
- return `run #${event.runIndex} [${event.reason}] gate=${event.report.gate.status} score=${score} files=${files} newlyFixed=${fixed} newlyBroken=${broken} nextSlice=${next}`;
423
+ const smartSuffix = event.impact ? ` ${formatSmartImpactTag(event.impact)}` : "";
424
+ const line = `run #${event.runIndex} [${sanitizeSingleLine(String(event.reason))}] gate=${sanitizeSingleLine(String(event.report.gate.status))} score=${score} files=${files} newlyFixed=${fixed} newlyBroken=${broken} nextSlice=${next}${smartSuffix}`;
425
+ return options.vars && Object.keys(options.vars).length > 0 ? redactRuntimeVars(line, options.vars) : line;
426
+ }
427
+ const ANSI = {
428
+ reset: "\x1b[0m",
429
+ bold: "\x1b[1m",
430
+ dim: "\x1b[2m",
431
+ red: "\x1b[31m",
432
+ green: "\x1b[32m",
433
+ yellow: "\x1b[33m",
434
+ cyan: "\x1b[36m"
435
+ };
436
+ function style(text, codes, useColor) {
437
+ return useColor ? `${codes}${text}${ANSI.reset}` : text;
438
+ }
439
+ function clamp01(value) {
440
+ if (!Number.isFinite(value))
441
+ return 0;
442
+ return Math.max(0, Math.min(1, value));
443
+ }
444
+ function formatPercent(ratio) {
445
+ return `${(clamp01(ratio) * 100).toFixed(1)}%`;
446
+ }
447
+ function watchGateBadge(status, useColor) {
448
+ switch (status) {
449
+ case "pass":
450
+ return style("[PASS]", `${ANSI.bold}${ANSI.green}`, useColor);
451
+ case "pass_with_warnings":
452
+ return style("[WARN]", `${ANSI.bold}${ANSI.yellow}`, useColor);
453
+ case "fail":
454
+ return style("[FAIL]", `${ANSI.bold}${ANSI.red}`, useColor);
455
+ case "incomplete":
456
+ return style("[INCOMPLETE]", `${ANSI.bold}${ANSI.yellow}`, useColor);
457
+ }
458
+ }
459
+ /** High-signal colorized or plain terminal summary of a watch run. */
460
+ export function formatPrettyWatchEvent(event, options = {}) {
461
+ const useColor = options.color === true;
462
+ const runLabel = style(`#${event.runIndex} [${sanitizeSingleLine(String(event.reason))}]`, `${ANSI.bold}${ANSI.cyan}`, useColor);
463
+ const badge = watchGateBadge(event.report.gate.status, useColor);
464
+ const hardPassed = Number.isFinite(event.report.hard?.passed) ? event.report.hard.passed : 0;
465
+ const hardTotal = Number.isFinite(event.report.hard?.total) ? event.report.hard.total : 0;
466
+ const hardParity = Number.isFinite(event.report.hard?.parity)
467
+ ? event.report.hard.parity
468
+ : hardTotal > 0
469
+ ? hardPassed / hardTotal
470
+ : 0;
471
+ const composite = Number.isFinite(event.report.compositeScore) ? event.report.compositeScore : 0;
472
+ const fileCount = event.changedFiles.length;
473
+ const filesLabel = `${fileCount} ${fileCount === 1 ? "file" : "files"}`;
474
+ const durationMs = Number.isFinite(event.durationMs) && event.durationMs >= 0 ? Math.round(event.durationMs) : 0;
475
+ const sep = style("|", ANSI.dim, useColor);
476
+ const smartSegment = event.impact
477
+ ? ` ${sep} ${style(formatSmartImpactTag(event.impact), event.impact.fallbackToFull ? ANSI.yellow : ANSI.cyan, useColor)}`
478
+ : "";
479
+ const lines = [
480
+ `${runLabel} ${badge} hard ${hardPassed}/${hardTotal} (${formatPercent(hardParity)}) ${sep} score ${formatPercent(composite)} ${sep} ${filesLabel}${smartSegment} ${sep} ${style(`${durationMs}ms`, ANSI.dim, useColor)}`
481
+ ];
482
+ if (event.newlyFixed.length > 0) {
483
+ const fixed = event.newlyFixed.map((s) => sanitizeSingleLine(s)).join(", ");
484
+ lines.push(` ${style(`+newlyFixed: ${fixed}`, ANSI.green, useColor)}`);
485
+ }
486
+ if (event.newlyBroken.length > 0) {
487
+ const broken = event.newlyBroken.map((s) => sanitizeSingleLine(s)).join(", ");
488
+ lines.push(` ${style(`-newlyBroken: ${broken}`, ANSI.red, useColor)}`);
489
+ }
490
+ if (event.slices?.nextSlice) {
491
+ lines.push(` ${style("next slice:", ANSI.dim, useColor)} ${style(sanitizeSingleLine(event.slices.nextSlice), ANSI.cyan, useColor)}`);
492
+ }
493
+ const output = lines.join("\n");
494
+ return options.vars && Object.keys(options.vars).length > 0 ? redactRuntimeVars(output, options.vars) : output;
285
495
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Parse a YAML 1.2 document (OpenAPI 3.x / Swagger 2.0 subset) with zero runtime dependencies.
3
+ * Enforces 4 MB input size limit, max nesting depth of 32, and strict indentation/syntax checks.
4
+ */
5
+ export declare function parseYaml(text: string): unknown;