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
@@ -4,7 +4,7 @@ interface AlignmentEntry {
4
4
  candidateIndex: number;
5
5
  similarity: number;
6
6
  }
7
- /** Load ordered candidate frames from a frame directory or a video file. */
7
+ /** Load ordered candidate frames from a frame directory, video file, or HTTP/HTTPS URL. */
8
8
  export declare function loadCandidateFrames(target: string, ctx: OracleContext, deps?: VerifyDeps): Promise<FfmpegFrame[]>;
9
9
  /**
10
10
  * Strictly monotone (j_0 < j_1 < ... < j_{K-1}) maximum-score alignment.
@@ -1,8 +1,10 @@
1
1
  import crypto from "node:crypto";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
- import { VibecodeError } from "../core/errors.js";
5
- import { artifactPath } from "../core/store.js";
4
+ import { VibecodeError, errorMessage } from "../core/errors.js";
5
+ import { STRICT_CONTROL_CHARS_RE, isForbiddenObjectKey, isInsideVaultDirectory, isPathWithinDir, parseSafeHttpBaseUrl, redactSensitiveText } from "../core/security.js";
6
+ import { loadPlaywright, launchBrowser } from "../core/adapters.js";
7
+ import { artifactPath, ensureDir, resolveWorkspace } from "../core/store.js";
6
8
  import { readImageDimensions } from "../core/png.js";
7
9
  import { decodeImage, computeSSIM, computeDHash, hammingDistanceHex, comparePalettes, bboxIoU } from "../core/visual.js";
8
10
  import { VIDEO_EXTS, IMAGE_EXTS, listFrameFiles, resolveFfmpegAdapter, extractVideoFrames, ffmpegMissingError, extractStates, changedRegionBetween } from "../ingestors/video.js";
@@ -62,17 +64,168 @@ function assertValidDecodedImage(img, filePath) {
62
64
  function listCandidateFrames(dir) {
63
65
  return listFrameFiles(dir).map((p, i) => ({ path: p, timestampMs: i * 1000 }));
64
66
  }
65
- /** Load ordered candidate frames from a frame directory or a video file. */
67
+ const PLAYWRIGHT_INSTALL_HINT = "npm install -D playwright && npx playwright install chromium";
68
+ const VIDEO_URL_FALLBACK_HINT = "Pass a video file or directory of PNG keyframes with --target ./frames/";
69
+ function resolvePlaywright(candidate) {
70
+ if (!candidate || typeof candidate !== "object")
71
+ return null;
72
+ const mod = candidate;
73
+ if (mod.chromium && typeof mod.chromium.launch === "function") {
74
+ return mod;
75
+ }
76
+ if (mod.default?.chromium && typeof mod.default.chromium.launch === "function") {
77
+ return mod.default;
78
+ }
79
+ return null;
80
+ }
81
+ async function launchVideoBrowser(pw) {
82
+ try {
83
+ return await launchBrowser(pw, {
84
+ headless: true,
85
+ featureName: "Verifying a video contract against an HTTP/HTTPS URL"
86
+ });
87
+ }
88
+ catch (err) {
89
+ if (err instanceof VibecodeError && err.code === "ADAPTER_MISSING")
90
+ throw err;
91
+ throw new VibecodeError("ADAPTER_MISSING", `Verifying a video contract against an HTTP/HTTPS URL requires Playwright Chromium (${err instanceof Error ? err.message : String(err)}).`, {
92
+ adapter: "playwright",
93
+ installHint: PLAYWRIGHT_INSTALL_HINT,
94
+ fallbackHint: VIDEO_URL_FALLBACK_HINT
95
+ });
96
+ }
97
+ }
98
+ async function captureUrlCandidateFrames(targetUrl, ctx, deps) {
99
+ const hasExplicitPw = Object.prototype.hasOwnProperty.call(deps, "playwright");
100
+ const rawPw = hasExplicitPw ? deps.playwright : await loadPlaywright({ cwd: ctx.cwd });
101
+ const pw = resolvePlaywright(rawPw);
102
+ if (!pw) {
103
+ throw new VibecodeError("ADAPTER_MISSING", "Verifying a video contract against an HTTP/HTTPS URL requires Playwright.", {
104
+ adapter: "playwright",
105
+ installHint: PLAYWRIGHT_INSTALL_HINT,
106
+ fallbackHint: VIDEO_URL_FALLBACK_HINT
107
+ });
108
+ }
109
+ const invariants = ctx.contract?.invariants || [];
110
+ const matchedInv = ctx.currentInvariantId
111
+ ? invariants.find((inv) => inv.id === ctx.currentInvariantId)
112
+ : undefined;
113
+ const stateCount = matchedInv?.expected?.states?.length ??
114
+ invariants.find((inv) => Array.isArray(inv.expected?.states) && inv.expected.states.length > 0)?.expected?.states?.length ??
115
+ 0;
116
+ const captureCount = Math.max(stateCount, 8);
117
+ const cacheDir = ctx.cacheDir || resolveWorkspace(ctx.cwd).cacheDir;
118
+ const outDir = path.join(cacheDir, "video-url-frames", shortHash(targetUrl));
119
+ ensureDir(outDir);
120
+ for (const entry of fs.readdirSync(outDir)) {
121
+ if (/^frame-\d+\.png$/i.test(entry)) {
122
+ fs.rmSync(path.join(outDir, entry), { force: true });
123
+ }
124
+ }
125
+ const viewport = { width: 1440, height: 900 };
126
+ const browser = await launchVideoBrowser(pw);
127
+ let page = null;
128
+ try {
129
+ page = await browser.newPage({ viewport });
130
+ try {
131
+ await page.goto(targetUrl, { waitUntil: "networkidle", timeout: 15000 });
132
+ }
133
+ catch {
134
+ try {
135
+ await page.goto(targetUrl, { waitUntil: "load", timeout: 15000 });
136
+ }
137
+ catch {
138
+ // Bounded fallback: proceed if DOM is already rendered
139
+ }
140
+ }
141
+ const rawMetrics = await page.evaluate(() => ({
142
+ scrollHeight: typeof document !== "undefined"
143
+ ? document.documentElement?.scrollHeight ||
144
+ document.body?.scrollHeight ||
145
+ (typeof window !== "undefined" ? window.innerHeight : 900) ||
146
+ 900
147
+ : 900,
148
+ innerHeight: typeof window !== "undefined" ? window.innerHeight || 900 : 900
149
+ }));
150
+ const innerHeight = typeof rawMetrics?.innerHeight === "number" && Number.isFinite(rawMetrics.innerHeight) && rawMetrics.innerHeight > 0
151
+ ? rawMetrics.innerHeight
152
+ : viewport.height;
153
+ const scrollHeight = typeof rawMetrics?.scrollHeight === "number" && Number.isFinite(rawMetrics.scrollHeight) && rawMetrics.scrollHeight > 0
154
+ ? rawMetrics.scrollHeight
155
+ : innerHeight;
156
+ const maxScroll = scrollHeight - innerHeight;
157
+ const scrollable = maxScroll > 10;
158
+ const evalWithArg = page;
159
+ const frames = [];
160
+ for (let i = 0; i < captureCount; i++) {
161
+ if (scrollable) {
162
+ const frac = captureCount > 1 ? i / (captureCount - 1) : 0;
163
+ const scrollY = Math.round(frac * maxScroll);
164
+ await evalWithArg.evaluate((y) => {
165
+ if (typeof window !== "undefined" && typeof window.scrollTo === "function") {
166
+ window.scrollTo(0, y);
167
+ }
168
+ }, scrollY);
169
+ await page.waitForTimeout?.(100);
170
+ }
171
+ else if (i > 0) {
172
+ await page.waitForTimeout?.(150);
173
+ }
174
+ const framePath = path.join(outDir, `frame-${String(i).padStart(3, "0")}.png`);
175
+ const buf = await page.screenshot({ path: framePath });
176
+ if (!fs.existsSync(framePath) && buf instanceof Uint8Array) {
177
+ fs.writeFileSync(framePath, buf);
178
+ }
179
+ frames.push({ path: framePath, timestampMs: i * (scrollable ? 100 : 150) });
180
+ }
181
+ return frames;
182
+ }
183
+ finally {
184
+ try {
185
+ await page?.close?.();
186
+ }
187
+ catch { /* ignore */ }
188
+ try {
189
+ await browser.close();
190
+ }
191
+ catch { /* ignore */ }
192
+ }
193
+ }
194
+ /** Load ordered candidate frames from a frame directory, video file, or HTTP/HTTPS URL. */
66
195
  export async function loadCandidateFrames(target, ctx, deps = {}) {
67
196
  if (!target)
68
197
  throw new VibecodeError("TARGET_MISSING", "Missing --target <frames-dir-or-video> for video verification.");
69
- const abs = path.resolve(ctx.cwd || process.cwd(), target);
198
+ const trimmed = target.trim();
199
+ const looksLikeUriScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmed) && !/^[a-z]:[\\/]/i.test(trimmed);
200
+ if (/^https?:\/\//i.test(trimmed) || looksLikeUriScheme || trimmed.startsWith("//")) {
201
+ let targetUrl;
202
+ try {
203
+ const baseUrl = parseSafeHttpBaseUrl(trimmed);
204
+ targetUrl = /^https?:\/\//i.test(trimmed) ? trimmed : baseUrl.toString();
205
+ }
206
+ catch (err) {
207
+ throw new VibecodeError("CONFIG_INVALID", redactSensitiveText(`Invalid video target URL: ${errorMessage(err)}`));
208
+ }
209
+ return captureUrlCandidateFrames(targetUrl, ctx, deps);
210
+ }
211
+ if (STRICT_CONTROL_CHARS_RE.test(trimmed)) {
212
+ throw new VibecodeError("CONFIG_INVALID", "Video target path contains control characters.");
213
+ }
214
+ const abs = path.resolve(ctx.cwd || process.cwd(), trimmed);
215
+ if (isInsideVaultDirectory(trimmed) || isInsideVaultDirectory(abs)) {
216
+ throw new VibecodeError("CONFIG_INVALID", "Target video path must not point inside a holdout vault directory.");
217
+ }
70
218
  if (!fs.existsSync(abs))
71
- throw new VibecodeError("TARGET_MISSING", `Target not found: ${target}`);
219
+ throw new VibecodeError("TARGET_MISSING", `Target not found: ${redactSensitiveText(target)}`);
72
220
  if (fs.statSync(abs).isDirectory()) {
73
221
  const files = listFrameFiles(abs);
74
222
  if (files.length === 0)
75
- throw new VibecodeError("UNSUPPORTED_FORMAT", `No frames found in directory: ${target}`);
223
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `No frames found in directory: ${redactSensitiveText(target)}`);
224
+ for (const f of files) {
225
+ if (isInsideVaultDirectory(f)) {
226
+ throw new VibecodeError("CONFIG_INVALID", "Target video frame path must not point inside a holdout vault directory.");
227
+ }
228
+ }
76
229
  return listCandidateFrames(abs);
77
230
  }
78
231
  const ext = path.extname(abs).toLowerCase();
@@ -87,15 +240,20 @@ export async function loadCandidateFrames(target, ctx, deps = {}) {
87
240
  maxFrames: 48,
88
241
  cacheKey: `verify-${ctx.currentInvariantId || "video"}-${shortHash(abs)}`
89
242
  }, adapter);
243
+ for (const frame of frames) {
244
+ if (frame?.path && isInsideVaultDirectory(frame.path)) {
245
+ throw new VibecodeError("CONFIG_INVALID", "Extracted video frame path must not point inside a holdout vault directory.");
246
+ }
247
+ }
90
248
  return frames;
91
249
  }
92
250
  catch (err) {
93
251
  if (err instanceof VibecodeError)
94
252
  throw err;
95
- throw new VibecodeError("EXEC_ERROR", `Failed to extract candidate frames from ${path.basename(abs)}: ${err instanceof Error ? err.message : String(err)}`, {
253
+ throw new VibecodeError("EXEC_ERROR", redactSensitiveText(`Failed to extract candidate frames from ${path.basename(abs)}: ${err instanceof Error ? err.message : String(err)}`), {
96
254
  adapter: "ffmpeg",
97
255
  fallbackHint: "Pass a directory of PNG keyframes with --target ./frames/",
98
- details: { source: abs }
256
+ details: { source: redactSensitiveText(abs) }
99
257
  });
100
258
  }
101
259
  }
@@ -114,17 +272,39 @@ function assertValidPngHeaderIfPng(filePath) {
114
272
  }
115
273
  }
116
274
  function resolveReferenceState(state, ctx) {
117
- if (!state || !state.keyframeArtifact) {
275
+ if (!state || !state.keyframeArtifact || typeof state.keyframeArtifact !== "string" || isForbiddenObjectKey(state.keyframeArtifact)) {
118
276
  throw new VibecodeError("CONTRACT_INVALID", "Video state missing keyframeArtifact");
119
277
  }
120
278
  const files = ctx.contract?.artifacts?.files || {};
121
- const rel = files[state.keyframeArtifact];
122
- if (!rel) {
279
+ const rel = Object.prototype.hasOwnProperty.call(files, state.keyframeArtifact) ? files[state.keyframeArtifact] : undefined;
280
+ if (!rel || typeof rel !== "string") {
123
281
  throw new VibecodeError("CONTRACT_INVALID", `Keyframe artifact ${state.keyframeArtifact} not found in contract.artifacts.files`);
124
282
  }
283
+ if (STRICT_CONTROL_CHARS_RE.test(rel) ||
284
+ path.isAbsolute(rel) ||
285
+ /^[A-Za-z]:/.test(rel) ||
286
+ isInsideVaultDirectory(rel)) {
287
+ throw new VibecodeError("CONFIG_INVALID", "Keyframe artifact path must remain inside .vibecode/artifacts and outside vault directories.");
288
+ }
289
+ const { artifactsDir } = resolveWorkspace(ctx.cwd);
125
290
  const abs = artifactPath(rel, ctx.cwd);
291
+ if (!isPathWithinDir(abs, artifactsDir, { allowEqual: false }) || isInsideVaultDirectory(abs)) {
292
+ throw new VibecodeError("CONFIG_INVALID", "Keyframe artifact path must remain inside .vibecode/artifacts and outside vault directories.");
293
+ }
126
294
  if (!fs.existsSync(abs) || !fs.statSync(abs).isFile()) {
127
- throw new VibecodeError("CONTRACT_NOT_FOUND", `Keyframe artifact missing on disk: ${rel}`);
295
+ throw new VibecodeError("CONTRACT_NOT_FOUND", `Keyframe artifact missing on disk: ${redactSensitiveText(rel)}`);
296
+ }
297
+ try {
298
+ const realArtifacts = fs.realpathSync(artifactsDir);
299
+ const realAbs = fs.realpathSync(abs);
300
+ if (!isPathWithinDir(realAbs, realArtifacts, { allowEqual: false }) || isInsideVaultDirectory(realAbs)) {
301
+ throw new VibecodeError("CONFIG_INVALID", "Keyframe artifact symlink must remain inside .vibecode/artifacts and outside vault directories.");
302
+ }
303
+ }
304
+ catch (err) {
305
+ if (err instanceof VibecodeError)
306
+ throw err;
307
+ throw new VibecodeError("CONFIG_INVALID", "Keyframe artifact path could not be verified safely.");
128
308
  }
129
309
  return abs;
130
310
  }
@@ -272,8 +452,38 @@ async function verifyTimeline(invariant, ctx, deps) {
272
452
  throw new VibecodeError("CONTRACT_INVALID", `Invariant ${invariant.id} has no expected.states`);
273
453
  }
274
454
  let candStates;
275
- const absTarget = ctx.target ? path.resolve(ctx.cwd || process.cwd(), ctx.target) : null;
276
- const cacheKey = absTarget ? `video:${targetCacheToken(absTarget)}:${depsCacheToken(deps)}` : null;
455
+ const trimmedTarget = ctx.target ? ctx.target.trim() : "";
456
+ const looksLikeUriScheme = /^[a-z][a-z0-9+.-]*:/i.test(trimmedTarget) && !/^[a-z]:[\\/]/i.test(trimmedTarget);
457
+ const targetIsUri = Boolean(trimmedTarget && (/^https?:\/\//i.test(trimmedTarget) || looksLikeUriScheme || trimmedTarget.startsWith("//")));
458
+ let targetIsUrl = false;
459
+ let normalizedTarget = null;
460
+ if (trimmedTarget) {
461
+ if (targetIsUri) {
462
+ try {
463
+ const baseUrl = parseSafeHttpBaseUrl(trimmedTarget);
464
+ targetIsUrl = true;
465
+ normalizedTarget = /^https?:\/\//i.test(trimmedTarget) ? trimmedTarget : baseUrl.toString();
466
+ }
467
+ catch (err) {
468
+ throw new VibecodeError("CONFIG_INVALID", redactSensitiveText(`Invalid video target URL: ${errorMessage(err)}`));
469
+ }
470
+ }
471
+ else {
472
+ if (STRICT_CONTROL_CHARS_RE.test(trimmedTarget)) {
473
+ throw new VibecodeError("CONFIG_INVALID", "Video target path contains control characters.");
474
+ }
475
+ normalizedTarget = path.resolve(ctx.cwd || process.cwd(), trimmedTarget);
476
+ if (isInsideVaultDirectory(trimmedTarget) || isInsideVaultDirectory(normalizedTarget)) {
477
+ throw new VibecodeError("CONFIG_INVALID", "Target video path must not point inside a holdout vault directory.");
478
+ }
479
+ }
480
+ }
481
+ const cacheToken = !normalizedTarget
482
+ ? null
483
+ : targetIsUrl
484
+ ? `url:${normalizedTarget}`
485
+ : targetCacheToken(normalizedTarget);
486
+ const cacheKey = cacheToken ? `video:${cacheToken}:${depsCacheToken(deps)}` : null;
277
487
  if (ctx.runtimeCache && cacheKey && Array.isArray(ctx.runtimeCache[cacheKey])) {
278
488
  candStates = ctx.runtimeCache[cacheKey];
279
489
  }
@@ -282,11 +492,17 @@ async function verifyTimeline(invariant, ctx, deps) {
282
492
  for (const f of frames) {
283
493
  if (!f || typeof f.path !== "string" || !fs.existsSync(f.path)) {
284
494
  throw new VibecodeError("EXEC_ERROR", `Extracted candidate frame missing on disk: ${f?.path ? path.basename(f.path) : "(unknown)"}`, {
285
- adapter: "ffmpeg",
495
+ adapter: targetIsUrl ? "playwright" : "ffmpeg",
286
496
  fallbackHint: "Pass a directory of PNG keyframes with --target ./frames/",
287
- details: { source: absTarget, framePath: f?.path ?? null }
497
+ details: {
498
+ source: normalizedTarget ? redactSensitiveText(normalizedTarget) : null,
499
+ framePath: f?.path ? redactSensitiveText(f.path) : null
500
+ }
288
501
  });
289
502
  }
503
+ if (isInsideVaultDirectory(f.path)) {
504
+ throw new VibecodeError("CONFIG_INVALID", "Extracted video frame path must not point inside a holdout vault directory.");
505
+ }
290
506
  assertValidPngHeaderIfPng(f.path);
291
507
  }
292
508
  const extracted = await extractStates(frames, { deps });