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,8 +1,9 @@
1
+ import { VALID_DOMAINS } from "./security.js";
1
2
  import type { ContractV02, Domain, JsonPathQueryResult, ValidationError, ValidationResult } from "./types.js";
2
3
  export declare const SCHEMA_VERSION = "0.2.0";
3
4
  export declare const VALID_SLICE_STATUSES: Set<string>;
4
- declare const VALID_DOMAINS: Set<string>;
5
5
  declare const VALID_SEVERITIES: Set<string>;
6
+ declare const VALID_UI_STATE_CHECK_KINDS: Set<string>;
6
7
  declare const VALID_TYPES: Set<string>;
7
8
  export declare function normalizeContract(raw: unknown): ContractV02;
8
9
  export declare function validateContract(contract: unknown): ValidationResult;
@@ -14,4 +15,4 @@ export declare function makeDefaultContract({ name, domain, source }?: {
14
15
  domain?: Domain | string;
15
16
  source?: string;
16
17
  }): ContractV02;
17
- export { VALID_DOMAINS, VALID_SEVERITIES, VALID_TYPES };
18
+ export { VALID_DOMAINS, VALID_SEVERITIES, VALID_TYPES, VALID_TYPES as VALID_INVARIANT_TYPES, VALID_UI_STATE_CHECK_KINDS };
@@ -1,19 +1,43 @@
1
1
  import { VibecodeError } from "./errors.js";
2
+ import { validateContractFixtures } from "./fixtures.js";
3
+ import { VALID_DOMAINS, isForbiddenObjectKey } from "./security.js";
2
4
  export const SCHEMA_VERSION = "0.2.0";
3
5
  export const VALID_SLICE_STATUSES = new Set(["pending", "in_progress", "passed", "failed", "skipped"]);
4
- const VALID_DOMAINS = new Set(["cli", "web", "image", "video", "api", "repo"]);
5
6
  const VALID_SEVERITIES = new Set(["hard", "soft"]);
7
+ const VALID_FS_EFFECT_STATUSES = new Set(["created", "modified", "deleted"]);
8
+ const VALID_STREAM_FORMATS = new Set(["sse", "ndjson", "auto"]);
9
+ const VALID_WS_STEP_ACTIONS = new Set(["send", "expect", "close"]);
10
+ const VALID_UI_STATE_CHECK_KINDS = new Set(["hover", "focus", "keyboard_tab", "disabled", "empty_state", "error_state", "storage"]);
6
11
  const VALID_TYPES = new Set([
7
12
  "command",
8
13
  "web_route",
9
14
  "web_flow",
10
15
  "web_network",
16
+ "web_ui_states",
11
17
  "image_layout",
12
18
  "image_perceptual",
13
19
  "video_timeline",
14
20
  "http",
21
+ "http_workflow",
22
+ "http_stream",
23
+ "ws_protocol",
24
+ "perf_budget",
15
25
  "repo_exports"
16
26
  ]);
27
+ const VALID_PERF_BUDGET_KINDS = new Set(["http", "command"]);
28
+ const PERF_BUDGET_NONNEG_KEYS = [
29
+ "maxP50Ms",
30
+ "maxP95Ms",
31
+ "maxP99Ms",
32
+ "maxMeanMs",
33
+ "maxDurationMs",
34
+ "maxBytes",
35
+ "minBytes"
36
+ ];
37
+ const PLUGIN_INVARIANT_TYPE_RE = /^plugin_[a-z][a-z0-9_-]{0,47}$/;
38
+ function isValidInvariantType(type) {
39
+ return typeof type === "string" && (VALID_TYPES.has(type) || PLUGIN_INVARIANT_TYPE_RE.test(type));
40
+ }
17
41
  function isObject(v) {
18
42
  return v !== null && typeof v === "object" && !Array.isArray(v);
19
43
  }
@@ -87,7 +111,8 @@ function normalizeV01(raw) {
87
111
  defaults: defaultThresholds()
88
112
  },
89
113
  invariants: [],
90
- ...(Array.isArray(raw.slices) ? { slices: normalizeSlices(raw.slices) } : {})
114
+ ...(Array.isArray(raw.slices) ? { slices: normalizeSlices(raw.slices) } : {}),
115
+ ...(raw.fixtures !== undefined ? { fixtures: clone(raw.fixtures) } : {})
91
116
  };
92
117
  // v0.1 thresholds.behavioralParity maps to hardBehavioralParity
93
118
  if (typeof rawThresholds.behavioralParity === "number") {
@@ -115,6 +140,8 @@ function normalizeV01(raw) {
115
140
  description: typeof inv.description === "string" ? inv.description : "",
116
141
  tags: Array.isArray(inv.tags) ? inv.tags.map(String) : [],
117
142
  sourceId: typeof inv.sourceId === "string" && inv.sourceId ? inv.sourceId : "src-1",
143
+ ...(inv.holdout !== undefined ? { holdout: inv.holdout } : {}),
144
+ ...(inv.holdoutHint !== undefined ? { holdoutHint: inv.holdoutHint } : {}),
118
145
  input: isObject(inv.input) ? clone(inv.input) : {},
119
146
  expected: isObject(inv.expected) ? clone(inv.expected) : {},
120
147
  tolerance: isObject(inv.tolerance) ? clone(inv.tolerance) : {}
@@ -215,6 +242,8 @@ export function normalizeContract(raw) {
215
242
  description: typeof n.description === "string" ? n.description : "",
216
243
  tags: Array.isArray(n.tags) ? n.tags.map(String) : [],
217
244
  ...(typeof n.sourceId === "string" && n.sourceId ? { sourceId: n.sourceId } : {}),
245
+ ...(n.holdout !== undefined ? { holdout: n.holdout } : {}),
246
+ ...(n.holdoutHint !== undefined ? { holdoutHint: n.holdoutHint } : {}),
218
247
  input,
219
248
  expected: isObject(n.expected) ? n.expected : {},
220
249
  tolerance: isObject(n.tolerance) ? n.tolerance : {}
@@ -233,7 +262,8 @@ export function normalizeContract(raw) {
233
262
  artifacts,
234
263
  thresholds,
235
264
  invariants,
236
- ...(Array.isArray(c.slices) ? { slices: normalizeSlices(c.slices) } : {})
265
+ ...(Array.isArray(c.slices) ? { slices: normalizeSlices(c.slices) } : {}),
266
+ ...(c.fixtures !== undefined ? { fixtures: c.fixtures } : {})
237
267
  };
238
268
  }
239
269
  export function validateContract(contract) {
@@ -299,16 +329,179 @@ export function validateContract(contract) {
299
329
  if (typeof inv.domain !== "string" || !VALID_DOMAINS.has(inv.domain)) {
300
330
  errors.push({ path: `${p}.domain`, message: `Invalid domain: ${String(inv.domain)}` });
301
331
  }
302
- if (typeof inv.type !== "string" || !VALID_TYPES.has(inv.type)) {
332
+ if (!isValidInvariantType(inv.type)) {
303
333
  errors.push({ path: `${p}.type`, message: `Invalid type: ${String(inv.type)}` });
304
334
  }
305
335
  if (typeof inv.severity !== "string" || !VALID_SEVERITIES.has(inv.severity)) {
306
336
  errors.push({ path: `${p}.severity`, message: `Invalid severity: ${String(inv.severity)}` });
307
337
  }
308
- if (!isObject(inv.input))
338
+ if (!isObject(inv.input)) {
309
339
  errors.push({ path: `${p}.input`, message: "input must be an object" });
310
- if (!isObject(inv.expected))
340
+ }
341
+ else {
342
+ if (inv.type === "http_workflow") {
343
+ if (!Array.isArray(inv.input.steps) || inv.input.steps.length === 0) {
344
+ errors.push({ path: `${p}.input.steps`, message: "http_workflow requires a non-empty steps array" });
345
+ }
346
+ else {
347
+ inv.input.steps.forEach((step, j) => {
348
+ const sp = `${p}.input.steps[${j}]`;
349
+ if (!isObject(step)) {
350
+ errors.push({ path: sp, message: "http_workflow step must be an object" });
351
+ return;
352
+ }
353
+ if (typeof step.id !== "string" || !step.id.trim()) {
354
+ errors.push({ path: `${sp}.id`, message: "http_workflow step.id must be a non-empty string" });
355
+ }
356
+ if (typeof step.path !== "string") {
357
+ errors.push({ path: `${sp}.path`, message: "http_workflow step.path must be a string" });
358
+ }
359
+ });
360
+ }
361
+ if (inv.input.finallySteps !== undefined) {
362
+ if (!Array.isArray(inv.input.finallySteps)) {
363
+ errors.push({ path: `${p}.input.finallySteps`, message: "http_workflow finallySteps must be an array" });
364
+ }
365
+ else {
366
+ inv.input.finallySteps.forEach((step, j) => {
367
+ const sp = `${p}.input.finallySteps[${j}]`;
368
+ if (!isObject(step)) {
369
+ errors.push({ path: sp, message: "http_workflow finallyStep must be an object" });
370
+ return;
371
+ }
372
+ if (typeof step.id !== "string" || !step.id.trim()) {
373
+ errors.push({ path: `${sp}.id`, message: "http_workflow finallyStep.id must be a non-empty string" });
374
+ }
375
+ if (typeof step.path !== "string") {
376
+ errors.push({ path: `${sp}.path`, message: "http_workflow finallyStep.path must be a string" });
377
+ }
378
+ });
379
+ }
380
+ }
381
+ }
382
+ else if (inv.type === "ws_protocol") {
383
+ if (!Array.isArray(inv.input.steps) || inv.input.steps.length === 0) {
384
+ errors.push({ path: `${p}.input.steps`, message: "ws_protocol requires a non-empty steps array" });
385
+ }
386
+ else {
387
+ inv.input.steps.forEach((step, j) => {
388
+ const sp = `${p}.input.steps[${j}]`;
389
+ if (!isObject(step)) {
390
+ errors.push({ path: sp, message: "ws_protocol step must be an object" });
391
+ return;
392
+ }
393
+ if (typeof step.action !== "string" || !VALID_WS_STEP_ACTIONS.has(step.action)) {
394
+ errors.push({ path: `${sp}.action`, message: "ws_protocol step.action must be 'send', 'expect', or 'close'" });
395
+ }
396
+ });
397
+ }
398
+ }
399
+ else if (inv.type === "web_ui_states") {
400
+ if (!Array.isArray(inv.input.checks) || inv.input.checks.length === 0) {
401
+ errors.push({ path: `${p}.input.checks`, message: "web_ui_states requires a non-empty checks array" });
402
+ }
403
+ else {
404
+ inv.input.checks.forEach((check, j) => {
405
+ const cp = `${p}.input.checks[${j}]`;
406
+ if (!isObject(check)) {
407
+ errors.push({ path: cp, message: "web_ui_states check must be an object" });
408
+ }
409
+ else if (typeof check.kind !== "string" || !VALID_UI_STATE_CHECK_KINDS.has(check.kind)) {
410
+ errors.push({ path: `${cp}.kind`, message: `web_ui_states check.kind must be one of ${[...VALID_UI_STATE_CHECK_KINDS].join(", ")}` });
411
+ }
412
+ });
413
+ }
414
+ }
415
+ else if (inv.type === "http_stream" && inv.input.format !== undefined) {
416
+ if (typeof inv.input.format !== "string" || !VALID_STREAM_FORMATS.has(inv.input.format)) {
417
+ errors.push({ path: `${p}.input.format`, message: "http_stream format must be 'sse', 'ndjson', or 'auto'" });
418
+ }
419
+ }
420
+ else if (inv.type === "perf_budget") {
421
+ if (inv.input.kind !== undefined && (typeof inv.input.kind !== "string" || !VALID_PERF_BUDGET_KINDS.has(inv.input.kind))) {
422
+ errors.push({ path: `${p}.input.kind`, message: "perf_budget kind must be 'http' or 'command'" });
423
+ }
424
+ if (inv.input.runs !== undefined &&
425
+ (typeof inv.input.runs !== "number" || !Number.isInteger(inv.input.runs) || inv.input.runs < 1)) {
426
+ errors.push({ path: `${p}.input.runs`, message: "perf_budget runs must be an integer >= 1" });
427
+ }
428
+ if (inv.input.warmupRuns !== undefined &&
429
+ (typeof inv.input.warmupRuns !== "number" || !Number.isInteger(inv.input.warmupRuns) || inv.input.warmupRuns < 0)) {
430
+ errors.push({ path: `${p}.input.warmupRuns`, message: "perf_budget warmupRuns must be an integer >= 0" });
431
+ }
432
+ if (inv.input.timeoutMs !== undefined &&
433
+ (typeof inv.input.timeoutMs !== "number" || !Number.isFinite(inv.input.timeoutMs) || inv.input.timeoutMs <= 0)) {
434
+ errors.push({ path: `${p}.input.timeoutMs`, message: "perf_budget timeoutMs must be a positive finite number" });
435
+ }
436
+ }
437
+ }
438
+ if (!isObject(inv.expected)) {
311
439
  errors.push({ path: `${p}.expected`, message: "expected must be an object" });
440
+ }
441
+ else {
442
+ if (inv.type === "perf_budget") {
443
+ for (const key of PERF_BUDGET_NONNEG_KEYS) {
444
+ const v = inv.expected[key];
445
+ if (v !== undefined && (typeof v !== "number" || !Number.isFinite(v) || v < 0)) {
446
+ errors.push({ path: `${p}.expected.${key}`, message: `perf_budget ${key} must be a finite number >= 0` });
447
+ }
448
+ }
449
+ const minB = inv.expected.minBytes;
450
+ const maxB = inv.expected.maxBytes;
451
+ if (typeof minB === "number" &&
452
+ Number.isFinite(minB) &&
453
+ minB >= 0 &&
454
+ typeof maxB === "number" &&
455
+ Number.isFinite(maxB) &&
456
+ maxB >= 0 &&
457
+ minB > maxB) {
458
+ errors.push({ path: `${p}.expected.minBytes`, message: `perf_budget minBytes (${minB}) cannot exceed maxBytes (${maxB})` });
459
+ }
460
+ if (inv.expected.maxErrorRate !== undefined &&
461
+ (typeof inv.expected.maxErrorRate !== "number" ||
462
+ !Number.isFinite(inv.expected.maxErrorRate) ||
463
+ inv.expected.maxErrorRate < 0 ||
464
+ inv.expected.maxErrorRate > 1)) {
465
+ errors.push({ path: `${p}.expected.maxErrorRate`, message: "perf_budget maxErrorRate must be a finite number in [0, 1]" });
466
+ }
467
+ }
468
+ if (inv.expected.fsEffects !== undefined) {
469
+ if (!Array.isArray(inv.expected.fsEffects)) {
470
+ errors.push({ path: `${p}.expected.fsEffects`, message: "fsEffects must be an array" });
471
+ }
472
+ else {
473
+ inv.expected.fsEffects.forEach((entry, j) => {
474
+ const ep = `${p}.expected.fsEffects[${j}]`;
475
+ if (!isObject(entry)) {
476
+ errors.push({ path: ep, message: "fsEffects entry must be an object" });
477
+ return;
478
+ }
479
+ if (typeof entry.path !== "string" || !entry.path.trim()) {
480
+ errors.push({ path: `${ep}.path`, message: "path must be a non-empty string" });
481
+ }
482
+ if (typeof entry.status !== "string" || !VALID_FS_EFFECT_STATUSES.has(entry.status)) {
483
+ errors.push({ path: `${ep}.status`, message: "status must be 'created', 'modified', or 'deleted'" });
484
+ }
485
+ if (entry.sha256 !== undefined && typeof entry.sha256 !== "string") {
486
+ errors.push({ path: `${ep}.sha256`, message: "sha256 must be a string" });
487
+ }
488
+ if (entry.size !== undefined &&
489
+ (typeof entry.size !== "number" || !Number.isFinite(entry.size) || entry.size < 0)) {
490
+ errors.push({ path: `${ep}.size`, message: "size must be a finite number >= 0" });
491
+ }
492
+ if (entry.preview !== undefined && typeof entry.preview !== "string") {
493
+ errors.push({ path: `${ep}.preview`, message: "preview must be a string" });
494
+ }
495
+ });
496
+ }
497
+ }
498
+ }
499
+ if (inv.holdout !== undefined && typeof inv.holdout !== "boolean") {
500
+ errors.push({ path: `${p}.holdout`, message: "holdout must be a boolean" });
501
+ }
502
+ if (inv.holdoutHint !== undefined && typeof inv.holdoutHint !== "string") {
503
+ errors.push({ path: `${p}.holdoutHint`, message: "holdoutHint must be a string" });
504
+ }
312
505
  });
313
506
  }
314
507
  if (contract.slices !== undefined) {
@@ -436,6 +629,18 @@ export function validateContract(contract) {
436
629
  }
437
630
  }
438
631
  }
632
+ if (contract.fixtures !== undefined) {
633
+ const fixValidation = validateContractFixtures(contract.fixtures);
634
+ if (!fixValidation.valid) {
635
+ for (const rawErr of fixValidation.errors) {
636
+ const match = rawErr.match(/^(fixtures(?:\.[A-Za-z0-9_]+|\[\d+\]|\[[^\]]+\])*):\s*(.*)$/);
637
+ errors.push({
638
+ path: match ? `$.${match[1]}` : "$.fixtures",
639
+ message: match && match[2] ? match[2] : rawErr
640
+ });
641
+ }
642
+ }
643
+ }
439
644
  return { ok: errors.length === 0, errors };
440
645
  }
441
646
  export function assertValidContract(contract) {
@@ -445,20 +650,172 @@ export function assertValidContract(contract) {
445
650
  }
446
651
  return contract;
447
652
  }
653
+ const MAX_SCHEMA_DEPTH = 32;
654
+ const MULTIPLE_OF_EPSILON = 1e-9;
655
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
656
+ const DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
657
+ const DATE_TIME_RE = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/;
658
+ const IPV4_RE = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
659
+ function hasOwn(obj, key) {
660
+ return Object.prototype.hasOwnProperty.call(obj, key);
661
+ }
662
+ function isValidCalendarDate(year, month, day) {
663
+ if (month < 1 || month > 12 || day < 1)
664
+ return false;
665
+ const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
666
+ const daysInMonth = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
667
+ return day <= daysInMonth[month - 1];
668
+ }
669
+ function isValidEmail(value) {
670
+ if (value.length > 254 || /\s/.test(value))
671
+ return false;
672
+ const at = value.indexOf("@");
673
+ if (at <= 0 || at !== value.lastIndexOf("@"))
674
+ return false;
675
+ const local = value.slice(0, at);
676
+ const domain = value.slice(at + 1);
677
+ if (local.length > 64 || domain.length < 3)
678
+ return false;
679
+ if (local.startsWith(".") || local.endsWith(".") || local.includes(".."))
680
+ return false;
681
+ if (!/^[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+$/.test(local))
682
+ return false;
683
+ const labels = domain.split(".");
684
+ if (labels.length < 2)
685
+ return false;
686
+ for (const label of labels) {
687
+ if (label.length === 0 || label.length > 63)
688
+ return false;
689
+ if (label.startsWith("-") || label.endsWith("-"))
690
+ return false;
691
+ if (!/^[A-Za-z0-9-]+$/.test(label))
692
+ return false;
693
+ }
694
+ const tld = labels[labels.length - 1];
695
+ if (tld.length < 2 || /^\d+$/.test(tld))
696
+ return false;
697
+ return true;
698
+ }
699
+ function isValidDate(value) {
700
+ const m = DATE_RE.exec(value);
701
+ if (!m)
702
+ return false;
703
+ return isValidCalendarDate(Number(m[1]), Number(m[2]), Number(m[3]));
704
+ }
705
+ function isValidDateTime(value) {
706
+ const m = DATE_TIME_RE.exec(value);
707
+ if (!m)
708
+ return false;
709
+ if (!isValidCalendarDate(Number(m[1]), Number(m[2]), Number(m[3])))
710
+ return false;
711
+ const hour = Number(m[4]);
712
+ const minute = Number(m[5]);
713
+ const second = Number(m[6]);
714
+ if (hour > 23 || minute > 59 || second > 59)
715
+ return false;
716
+ if (m[7] !== undefined) {
717
+ const tzHour = Number(m[8]);
718
+ const tzMinute = Number(m[9]);
719
+ if (tzHour > 23 || tzMinute > 59)
720
+ return false;
721
+ }
722
+ return true;
723
+ }
724
+ function isValidUri(value) {
725
+ if (!value || /\s/.test(value))
726
+ return false;
727
+ try {
728
+ const parsed = new URL(value);
729
+ return /^[A-Za-z][A-Za-z0-9+.-]*:$/.test(parsed.protocol);
730
+ }
731
+ catch {
732
+ return false;
733
+ }
734
+ }
735
+ function isValidIpv4(value) {
736
+ const m = IPV4_RE.exec(value);
737
+ if (!m)
738
+ return false;
739
+ for (let i = 1; i <= 4; i++) {
740
+ const part = m[i];
741
+ if (part.length > 1 && part.startsWith("0"))
742
+ return false;
743
+ const n = Number(part);
744
+ if (n < 0 || n > 255)
745
+ return false;
746
+ }
747
+ return true;
748
+ }
749
+ function validateStringFormat(value, format) {
750
+ switch (format) {
751
+ case "email": return isValidEmail(value);
752
+ case "uuid": return UUID_RE.test(value);
753
+ case "date": return isValidDate(value);
754
+ case "date-time": return isValidDateTime(value);
755
+ case "uri": return isValidUri(value);
756
+ case "ipv4": return isValidIpv4(value);
757
+ default: return true;
758
+ }
759
+ }
760
+ function canonicalJson(v, seen = new WeakSet()) {
761
+ if (v === null)
762
+ return "null";
763
+ if (typeof v === "boolean" || typeof v === "string")
764
+ return JSON.stringify(v);
765
+ if (typeof v === "number")
766
+ return Number.isFinite(v) ? JSON.stringify(v) : String(v);
767
+ if (typeof v === "undefined")
768
+ return "undefined";
769
+ if (Array.isArray(v)) {
770
+ if (seen.has(v))
771
+ return '"[Circular]"';
772
+ seen.add(v);
773
+ const parts = v.map((item) => (item === undefined ? "null" : canonicalJson(item, seen)));
774
+ seen.delete(v);
775
+ return `[${parts.join(",")}]`;
776
+ }
777
+ if (typeof v === "object") {
778
+ if (seen.has(v))
779
+ return '"[Circular]"';
780
+ seen.add(v);
781
+ const obj = v;
782
+ const keys = Object.keys(obj).sort();
783
+ const parts = [];
784
+ for (const k of keys) {
785
+ if (obj[k] === undefined)
786
+ continue;
787
+ parts.push(`${JSON.stringify(k)}:${canonicalJson(obj[k], seen)}`);
788
+ }
789
+ seen.delete(v);
790
+ return `{${parts.join(",")}}`;
791
+ }
792
+ return JSON.stringify(String(v));
793
+ }
448
794
  export function validateJsonSchema(value, schema, path = "$") {
795
+ return validateJsonSchemaInternal(value, schema, path, 0);
796
+ }
797
+ function validateJsonSchemaInternal(value, schema, path, depth) {
449
798
  const errors = [];
799
+ if (depth > MAX_SCHEMA_DEPTH) {
800
+ errors.push({ path, message: `Maximum schema depth (${MAX_SCHEMA_DEPTH}) exceeded` });
801
+ return errors;
802
+ }
450
803
  if (!isObject(schema))
451
804
  return errors;
452
805
  const s = schema;
453
806
  const p = path;
807
+ if (s.nullable === true && value === null) {
808
+ return errors;
809
+ }
454
810
  if (s.const !== undefined) {
455
- if (JSON.stringify(value) !== JSON.stringify(s.const)) {
811
+ if (canonicalJson(value) !== canonicalJson(s.const)) {
456
812
  errors.push({ path: p, message: `Expected const ${JSON.stringify(s.const)}` });
457
813
  }
458
814
  return errors;
459
815
  }
460
816
  if (Array.isArray(s.enum)) {
461
- const ok = s.enum.some((e) => JSON.stringify(e) === JSON.stringify(value));
817
+ const valCanon = canonicalJson(value);
818
+ const ok = s.enum.some((e) => canonicalJson(e) === valCanon);
462
819
  if (!ok)
463
820
  errors.push({ path: p, message: `Expected one of ${JSON.stringify(s.enum)}` });
464
821
  }
@@ -484,37 +841,117 @@ export function validateJsonSchema(value, schema, path = "$") {
484
841
  errors.push({ path: p, message: `invalid pattern ${s.pattern}` });
485
842
  }
486
843
  }
844
+ if (typeof s.format === "string" && !validateStringFormat(value, s.format)) {
845
+ errors.push({ path: p, message: `Invalid format "${s.format}"` });
846
+ }
487
847
  }
488
848
  if (typeof value === "number") {
489
849
  if (typeof s.minimum === "number" && value < s.minimum)
490
850
  errors.push({ path: p, message: `minimum ${s.minimum}` });
491
851
  if (typeof s.maximum === "number" && value > s.maximum)
492
852
  errors.push({ path: p, message: `maximum ${s.maximum}` });
853
+ if (typeof s.exclusiveMinimum === "number" && value <= s.exclusiveMinimum) {
854
+ errors.push({ path: p, message: `exclusiveMinimum ${s.exclusiveMinimum}` });
855
+ }
856
+ if (typeof s.exclusiveMaximum === "number" && value >= s.exclusiveMaximum) {
857
+ errors.push({ path: p, message: `exclusiveMaximum ${s.exclusiveMaximum}` });
858
+ }
859
+ if (typeof s.multipleOf === "number" && Number.isFinite(s.multipleOf) && s.multipleOf > 0) {
860
+ const quotient = value / s.multipleOf;
861
+ if (!Number.isFinite(quotient) || Math.abs(quotient - Math.round(quotient)) > MULTIPLE_OF_EPSILON) {
862
+ errors.push({ path: p, message: `multipleOf ${s.multipleOf}` });
863
+ }
864
+ }
493
865
  }
494
866
  if (Array.isArray(value)) {
495
867
  if (typeof s.minItems === "number" && value.length < s.minItems)
496
868
  errors.push({ path: p, message: `minItems ${s.minItems}` });
869
+ if (typeof s.maxItems === "number" && value.length > s.maxItems)
870
+ errors.push({ path: p, message: `maxItems ${s.maxItems}` });
871
+ if (s.uniqueItems === true) {
872
+ const seenItems = new Set();
873
+ for (const item of value) {
874
+ const key = canonicalJson(item);
875
+ if (seenItems.has(key)) {
876
+ errors.push({ path: p, message: "Array items must be unique" });
877
+ break;
878
+ }
879
+ seenItems.add(key);
880
+ }
881
+ }
497
882
  if (isObject(s.items)) {
498
883
  const itemSchema = s.items;
499
884
  value.forEach((item, i) => {
500
- errors.push(...validateJsonSchema(item, itemSchema, `${p}[${i}]`));
885
+ errors.push(...validateJsonSchemaInternal(item, itemSchema, `${p}[${i}]`, depth + 1));
501
886
  });
502
887
  }
503
888
  }
504
889
  if (isObject(value)) {
890
+ const keys = Object.keys(value);
891
+ if (typeof s.minProperties === "number" && keys.length < s.minProperties) {
892
+ errors.push({ path: p, message: `minProperties ${s.minProperties}` });
893
+ }
894
+ if (typeof s.maxProperties === "number" && keys.length > s.maxProperties) {
895
+ errors.push({ path: p, message: `maxProperties ${s.maxProperties}` });
896
+ }
505
897
  if (Array.isArray(s.required)) {
506
898
  for (const k of s.required) {
507
- if (!(k in value))
899
+ if (!hasOwn(value, k))
508
900
  errors.push({ path: `${p}.${k}`, message: "required" });
509
901
  }
510
902
  }
511
- if (isObject(s.properties)) {
512
- for (const [k, subSchema] of Object.entries(s.properties)) {
513
- if (k in value)
514
- errors.push(...validateJsonSchema(value[k], subSchema, `${p}.${k}`));
903
+ const declaredProps = isObject(s.properties) ? s.properties : undefined;
904
+ if (declaredProps) {
905
+ for (const [k, subSchema] of Object.entries(declaredProps)) {
906
+ if (hasOwn(value, k)) {
907
+ errors.push(...validateJsonSchemaInternal(value[k], subSchema, `${p}.${k}`, depth + 1));
908
+ }
909
+ }
910
+ }
911
+ if (s.additionalProperties === false) {
912
+ for (const k of keys) {
913
+ if (!declaredProps || !hasOwn(declaredProps, k)) {
914
+ errors.push({ path: `${p}.${k}`, message: `Unexpected additional property "${k}"` });
915
+ }
916
+ }
917
+ }
918
+ else if (isObject(s.additionalProperties)) {
919
+ const additionalSchema = s.additionalProperties;
920
+ for (const k of keys) {
921
+ if (!declaredProps || !hasOwn(declaredProps, k)) {
922
+ errors.push(...validateJsonSchemaInternal(value[k], additionalSchema, `${p}.${k}`, depth + 1));
923
+ }
515
924
  }
516
925
  }
517
926
  }
927
+ if (Array.isArray(s.allOf)) {
928
+ for (const subSchema of s.allOf) {
929
+ errors.push(...validateJsonSchemaInternal(value, subSchema, p, depth + 1));
930
+ }
931
+ }
932
+ if (Array.isArray(s.anyOf) && s.anyOf.length > 0) {
933
+ const anyMatched = s.anyOf.some((subSchema) => validateJsonSchemaInternal(value, subSchema, p, depth + 1).length === 0);
934
+ if (!anyMatched) {
935
+ errors.push({ path: p, message: `Value did not match any schema in anyOf (${s.anyOf.length} candidates)` });
936
+ }
937
+ }
938
+ if (Array.isArray(s.oneOf) && s.oneOf.length > 0) {
939
+ let matchCount = 0;
940
+ for (const subSchema of s.oneOf) {
941
+ if (validateJsonSchemaInternal(value, subSchema, p, depth + 1).length === 0) {
942
+ matchCount++;
943
+ }
944
+ }
945
+ if (matchCount !== 1) {
946
+ errors.push({ path: p, message: `Expected value to match exactly 1 schema in oneOf, matched ${matchCount}` });
947
+ }
948
+ }
949
+ if (isObject(s.not)) {
950
+ const notErrors = validateJsonSchemaInternal(value, s.not, p, depth + 1);
951
+ if (notErrors.length === 0) {
952
+ errors.push({ path: p, message: 'Value must not match "not" schema' });
953
+ }
954
+ }
518
955
  return errors;
519
956
  }
520
957
  function jsType(v) {
@@ -537,14 +974,17 @@ function typeMatches(v, t) {
537
974
  }
538
975
  }
539
976
  export function queryJsonPath(obj, expr) {
540
- if (typeof expr !== "string" || !expr.startsWith("$"))
977
+ if (typeof expr !== "string" || !expr.startsWith("$") || expr.length > 2048) {
541
978
  return { found: false, value: undefined };
979
+ }
542
980
  let cur = obj;
543
981
  // Tokenize: .key, ["key"], [0]
544
982
  const tokens = [];
545
983
  const re = /\.([A-Za-z_$][A-Za-z0-9_$-]*)|\[(\d+)\]|\[(?:"([^"]*)"|'([^']*)')\]/g;
546
984
  let i = 1; // skip $
547
985
  while (i < expr.length) {
986
+ if (tokens.length >= 64)
987
+ return { found: false, value: undefined };
548
988
  re.lastIndex = i;
549
989
  const m = re.exec(expr);
550
990
  if (!m || m.index !== i) {
@@ -570,8 +1010,11 @@ export function queryJsonPath(obj, expr) {
570
1010
  cur = cur[t];
571
1011
  }
572
1012
  else {
573
- if (typeof cur !== "object" || !(t in cur))
1013
+ if (isForbiddenObjectKey(t))
1014
+ return { found: false, value: undefined };
1015
+ if (typeof cur !== "object" || !Object.prototype.hasOwnProperty.call(cur, t)) {
574
1016
  return { found: false, value: undefined };
1017
+ }
575
1018
  cur = cur[t];
576
1019
  }
577
1020
  }
@@ -611,4 +1054,4 @@ export function makeDefaultContract({ name, domain = "cli", source = "unknown" }
611
1054
  ]
612
1055
  };
613
1056
  }
614
- export { VALID_DOMAINS, VALID_SEVERITIES, VALID_TYPES };
1057
+ export { VALID_DOMAINS, VALID_SEVERITIES, VALID_TYPES, VALID_TYPES as VALID_INVARIANT_TYPES, VALID_UI_STATE_CHECK_KINDS };