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
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { spawnSync } from "node:child_process";
4
4
  import { VibecodeError } from "../core/errors.js";
5
+ import { buildWindowsCmdSpawn, isWindowsCmdShim } from "../core/exec.js";
5
6
  import { findFfmpeg } from "../core/adapters.js";
6
7
  import { decodeImage, computeSSIM, computeDHash, hammingDistanceHex, computePixelDiff, extractPalette, extractLayoutRegions } from "../core/visual.js";
7
8
  import { ensureDir, saveArtifact, resolveWorkspace } from "../core/store.js";
@@ -86,14 +87,6 @@ export function cueAt(cues, timestampMs) {
86
87
  /* ------------------------------------------------------------------ *
87
88
  * ffmpeg adapter (optional, injectable for tests)
88
89
  * ------------------------------------------------------------------ */
89
- function quoteWindowsCmdArg(arg) {
90
- if (arg.length === 0)
91
- return '""';
92
- if (!/[\s"&|<>^(),;=%!]/.test(arg))
93
- return arg;
94
- const escaped = arg.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/, "$1$1");
95
- return `"${escaped}"`;
96
- }
97
90
  function tailDiagnostic(text, maxLen = 600) {
98
91
  if (text == null)
99
92
  return "";
@@ -118,12 +111,18 @@ function spawnCapture(cmd, args) {
118
111
  encoding: "utf8",
119
112
  timeout: 120000,
120
113
  maxBuffer: 16 * 1024 * 1024,
121
- windowsHide: true
114
+ windowsHide: true,
115
+ shell: false
122
116
  };
123
- const isWinCmd = process.platform === "win32" && /\.(cmd|bat)$/i.test(cmd);
124
- const res = isWinCmd
125
- ? spawnSync(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", `"${[quoteWindowsCmdArg(cmd), ...args.map(quoteWindowsCmdArg)].join(" ")}"`], { ...opts, windowsVerbatimArguments: true })
126
- : spawnSync(cmd, args, { ...opts, shell: false });
117
+ const res = isWindowsCmdShim(cmd)
118
+ ? (() => {
119
+ const spec = buildWindowsCmdSpawn(cmd, args);
120
+ return spawnSync(spec.command, spec.args, {
121
+ ...opts,
122
+ windowsVerbatimArguments: spec.windowsVerbatimArguments
123
+ });
124
+ })()
125
+ : spawnSync(cmd, args, opts);
127
126
  if (res.error) {
128
127
  const errCode = res.error.code;
129
128
  const stderr = tailDiagnostic(res.stderr);
@@ -216,6 +215,34 @@ function periodicTimestamps(durationMs, maxFrames) {
216
215
  const raw = Array.from({ length: count }, (_, i) => (i === count - 1 ? Math.round(endMs) : Math.round(i * step)));
217
216
  return [...new Set(raw)].sort((a, b) => a - b);
218
217
  }
218
+ const INVALID_CROP_MESSAGE = "Invalid --crop value; expected w:h:x:y with positive width/height and non-negative offsets.";
219
+ /** Validate and normalize an ffmpeg `w:h:x:y` crop specification. */
220
+ export function parseCropFilter(crop) {
221
+ if (crop === undefined || crop === null || crop === "")
222
+ return undefined;
223
+ if (typeof crop !== "string") {
224
+ throw new VibecodeError("CONTRACT_INVALID", INVALID_CROP_MESSAGE);
225
+ }
226
+ const match = crop.match(/^\s*(\d+):(\d+):(\d+):(\d+)\s*$/);
227
+ if (!match) {
228
+ throw new VibecodeError("CONTRACT_INVALID", INVALID_CROP_MESSAGE);
229
+ }
230
+ const w = Number(match[1]);
231
+ const h = Number(match[2]);
232
+ const x = Number(match[3]);
233
+ const y = Number(match[4]);
234
+ if (!Number.isSafeInteger(w) ||
235
+ !Number.isSafeInteger(h) ||
236
+ !Number.isSafeInteger(x) ||
237
+ !Number.isSafeInteger(y) ||
238
+ w <= 0 ||
239
+ h <= 0 ||
240
+ x < 0 ||
241
+ y < 0) {
242
+ throw new VibecodeError("CONTRACT_INVALID", INVALID_CROP_MESSAGE);
243
+ }
244
+ return `${w}:${h}:${x}:${y}`;
245
+ }
219
246
  /**
220
247
  * Resolve the ffmpeg adapter.
221
248
  * - `deps.ffmpegAdapter` explicitly set (object or `null`) wins — `null` models "absent" in tests.
@@ -241,10 +268,14 @@ export function resolveFfmpegAdapter(deps = {}) {
241
268
  ]);
242
269
  return res.status === 0 ? parseFfprobeDurationMs(res.stdout) : null;
243
270
  },
244
- probeScenes: (src, sceneThreshold, maxFrames) => {
271
+ probeScenes: (src, sceneThreshold, maxFrames, options) => {
272
+ const crop = parseCropFilter(options?.crop);
273
+ const vf = crop
274
+ ? `crop=${crop},select='gt(scene\\,${sceneThreshold})',showinfo`
275
+ : `select='gt(scene\\,${sceneThreshold})',showinfo`;
245
276
  const res = spawnCapture(ffmpegBin, [
246
277
  "-hide_banner", "-i", src,
247
- "-vf", `select='gt(scene\\,${sceneThreshold})',showinfo`,
278
+ "-vf", vf,
248
279
  "-f", "null", "-"
249
280
  ]);
250
281
  const times = parseSceneTimestamps(`${res.stderr || ""}\n${res.stdout || ""}`);
@@ -263,7 +294,9 @@ export function resolveFfmpegAdapter(deps = {}) {
263
294
  }
264
295
  return times.length ? times.slice(0, maxFrames) : null;
265
296
  },
266
- extractFrames: (src, timestampsMs, outDir) => {
297
+ extractFrames: (src, timestampsMs, outDir, options) => {
298
+ const crop = parseCropFilter(options?.crop);
299
+ const cropArgs = crop ? ["-vf", `crop=${crop}`] : [];
267
300
  cleanStaleFrames(outDir);
268
301
  const out = [];
269
302
  let lastExitCode = null;
@@ -274,7 +307,7 @@ export function resolveFfmpegAdapter(deps = {}) {
274
307
  const res = spawnCapture(ffmpegBin, [
275
308
  "-hide_banner", "-loglevel", "error", "-y",
276
309
  "-ss", String(tsMs / 1000),
277
- "-i", src, "-frames:v", "1", file
310
+ "-i", src, ...cropArgs, "-frames:v", "1", file
278
311
  ]);
279
312
  if (res.status !== 0) {
280
313
  lastExitCode = res.status;
@@ -288,7 +321,7 @@ export function resolveFfmpegAdapter(deps = {}) {
288
321
  const retryRes = spawnCapture(ffmpegBin, [
289
322
  "-hide_banner", "-loglevel", "error", "-y",
290
323
  "-ss", String(retryMs / 1000),
291
- "-i", src, "-frames:v", "1", file
324
+ "-i", src, ...cropArgs, "-frames:v", "1", file
292
325
  ]);
293
326
  if (retryRes.status !== 0) {
294
327
  lastExitCode = retryRes.status;
@@ -329,30 +362,45 @@ export function ffmpegMissingError() {
329
362
  });
330
363
  }
331
364
  /** Extract ordered keyframe files + duration from a video file via the adapter. */
332
- export function extractVideoFrames(absSource, { cwd, sceneThreshold = 0.18, maxFrames = 12, cacheKey = "ingest" }, adapter) {
365
+ export function extractVideoFrames(absSource, { cwd, sceneThreshold = 0.18, maxFrames = 12, cacheKey = "ingest", crop }, adapter) {
366
+ const normalizedCrop = parseCropFilter(crop);
333
367
  if (!adapter)
334
368
  throw ffmpegMissingError();
369
+ const effectiveMaxFrames = Math.max(1, Math.floor(maxFrames));
335
370
  const rawDuration = adapter.probeDuration(absSource);
336
371
  const durationMs = typeof rawDuration === "number" && Number.isFinite(rawDuration) && rawDuration > 0 ? rawDuration : 0;
337
- let timestamps = adapter.probeScenes(absSource, sceneThreshold, maxFrames);
338
- if (!Array.isArray(timestamps) || timestamps.length === 0) {
339
- timestamps = periodicTimestamps(durationMs, Math.min(maxFrames, 4));
340
- }
341
- if (!timestamps.includes(0))
342
- timestamps = [0, ...timestamps];
343
372
  const maxTs = durationMs > 20 ? Math.max(0, durationMs - 20) : null;
344
- timestamps = [
345
- ...new Set(timestamps.map((t) => {
346
- const nonNeg = Number.isFinite(t) ? Math.max(0, Math.round(t)) : 0;
347
- return maxTs !== null ? Math.min(maxTs, nonNeg) : nonNeg;
348
- }))
349
- ]
350
- .sort((a, b) => a - b)
351
- .slice(0, maxFrames);
373
+ const normalizeTs = (t) => {
374
+ const nonNeg = Number.isFinite(t) ? Math.max(0, Math.round(t)) : 0;
375
+ return maxTs !== null ? Math.min(maxTs, nonNeg) : nonNeg;
376
+ };
377
+ const rawScenes = adapter.probeScenes(absSource, sceneThreshold, effectiveMaxFrames, { crop: normalizedCrop });
378
+ const sceneTs = Array.isArray(rawScenes) ? rawScenes : [];
379
+ const normalizedSceneTs = [
380
+ ...new Set((sceneTs.length > 0 ? [0, ...sceneTs] : []).map(normalizeTs))
381
+ ].sort((a, b) => a - b);
382
+ let timestamps;
383
+ if (sceneTs.length === 0 || normalizedSceneTs.length < effectiveMaxFrames) {
384
+ const uniform = periodicTimestamps(durationMs, effectiveMaxFrames);
385
+ const minGapMs = Math.min(100, Math.max(10, Math.floor((durationMs || effectiveMaxFrames * 1000) / (effectiveMaxFrames * 4))));
386
+ const kept = normalizedSceneTs.length > 0 ? [...normalizedSceneTs] : [normalizeTs(0)];
387
+ for (const u of uniform) {
388
+ if (kept.length >= effectiveMaxFrames)
389
+ break;
390
+ const nu = normalizeTs(u);
391
+ if (kept.some((k) => Math.abs(k - nu) <= minGapMs))
392
+ continue;
393
+ kept.push(nu);
394
+ }
395
+ timestamps = kept.sort((a, b) => a - b).slice(0, effectiveMaxFrames);
396
+ }
397
+ else {
398
+ timestamps = normalizedSceneTs.slice(0, effectiveMaxFrames);
399
+ }
352
400
  const { cacheDir } = resolveWorkspace(cwd);
353
401
  const outDir = path.join(cacheDir, "video-frames", String(cacheKey).replace(/[^A-Za-z0-9_.-]+/g, "-"));
354
402
  cleanStaleFrames(outDir);
355
- const frames = adapter.extractFrames(absSource, timestamps, outDir) || [];
403
+ const frames = adapter.extractFrames(absSource, timestamps, outDir, { crop: normalizedCrop }) || [];
356
404
  if (frames.length === 0) {
357
405
  throw new VibecodeError("EXEC_ERROR", "ffmpeg did not produce any keyframe images.", {
358
406
  adapter: "ffmpeg",
@@ -463,6 +511,7 @@ export async function ingest(options = {}, deps = {}) {
463
511
  if (!fs.existsSync(absSource)) {
464
512
  throw new VibecodeError("TARGET_MISSING", `Video source not found: ${source}`);
465
513
  }
514
+ const crop = parseCropFilter(options.crop);
466
515
  const sceneThreshold = typeof options.sceneThreshold === "number" ? options.sceneThreshold : 0.18;
467
516
  const maxFrames = typeof options.maxFrames === "number" && Number.isFinite(options.maxFrames) && options.maxFrames > 0
468
517
  ? Math.floor(options.maxFrames)
@@ -501,7 +550,7 @@ export async function ingest(options = {}, deps = {}) {
501
550
  const adapter = resolveFfmpegAdapter(deps);
502
551
  if (!adapter)
503
552
  throw ffmpegMissingError();
504
- const extracted = extractVideoFrames(absSource, { cwd, sceneThreshold, maxFrames }, adapter);
553
+ const extracted = extractVideoFrames(absSource, { cwd, sceneThreshold, maxFrames, crop }, adapter);
505
554
  frames = extracted.frames;
506
555
  durationMs = extracted.durationMs;
507
556
  const sidecar = findSidecarSubtitles(absSource);
@@ -594,7 +643,8 @@ export async function ingest(options = {}, deps = {}) {
594
643
  frameCount: frames.length,
595
644
  stateCount: publicStates.length,
596
645
  durationMs,
597
- hasSubtitles: cues.length > 0
646
+ hasSubtitles: cues.length > 0,
647
+ ...(crop ? { crop } : {})
598
648
  }
599
649
  }
600
650
  ],
@@ -1,4 +1,5 @@
1
- import type { IngestDeps, IngestOptions, IngestResult, JsonSchema, WebLandmark, WebNetworkExpectation, WebRouteOption } from "../core/types.js";
1
+ import type { IngestDeps, IngestOptions, IngestResult, JsonSchema, PlaywrightBrowserLike, PlaywrightPageLike, PlaywrightResponseLike, Viewport, WebInteractiveLandmark, WebLandmark, WebNetworkExpectation, WebRouteOption } from "../core/types.js";
2
+ export declare const INTERACTIVE_LANDMARK_SELECTOR = "button, a[href], input, select, textarea, [role=\"button\"], [role=\"link\"], [role=\"navigation\"], [role=\"main\"], [role=\"dialog\"], [role=\"tablist\"]";
2
3
  type WebRouteInput = WebRouteOption & {
3
4
  timeoutMs?: number;
4
5
  };
@@ -13,6 +14,20 @@ declare function extractAllLandmarks(html: string): Array<{
13
14
  text: string;
14
15
  }>;
15
16
  declare function extractLandmarks(html: string): WebLandmark[];
17
+ export declare function normalizeSameOriginHref(href: string, baseUrl: string): string | null;
18
+ export declare function extractHtmlHrefs(html: string): string[];
19
+ export interface OpenBrowserPageOptions {
20
+ viewport?: Viewport;
21
+ headers?: Record<string, string>;
22
+ storageState?: string;
23
+ }
24
+ export interface OpenedBrowserPage {
25
+ page: PlaywrightPageLike;
26
+ close(): Promise<void>;
27
+ }
28
+ export declare function openBrowserPage(browser: PlaywrightBrowserLike, options?: OpenBrowserPageOptions): Promise<OpenedBrowserPage>;
29
+ export declare function gotoWithSpaFallback(page: PlaywrightPageLike, url: string, waitUntil: string, timeoutMs: number): Promise<PlaywrightResponseLike | null>;
30
+ export declare function extractInteractiveLandmarks(page: PlaywrightPageLike): Promise<WebInteractiveLandmark[]>;
16
31
  declare function normalizeNetworkEntry(entry: {
17
32
  method?: string;
18
33
  pathPattern?: string;