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,6 +1,29 @@
1
- import type { AdapterProbeResults, PlaywrightLike, SharpLike } from "./types.js";
2
- export declare function probeAdapters(_deps?: unknown): Promise<AdapterProbeResults>;
3
- export declare function loadPlaywright(_deps?: unknown): Promise<PlaywrightLike | null>;
1
+ import type { AdapterProbeResults, IngestDeps, PlaywrightBrowserLike, PlaywrightLaunchOptions, PlaywrightLike, SharpLike, VerifyDeps } from "./types.js";
2
+ export interface SystemBrowserInfo {
3
+ path: string;
4
+ name: string;
5
+ }
6
+ export interface FindSystemBrowserDeps {
7
+ env?: NodeJS.ProcessEnv;
8
+ platform?: NodeJS.Platform;
9
+ existsSync?: (p: string) => boolean;
10
+ }
11
+ export interface AdapterProbeDeps {
12
+ cwd?: string;
13
+ env?: NodeJS.ProcessEnv;
14
+ globalRoot?: string | null;
15
+ findSystemBrowser?: typeof findSystemBrowser;
16
+ }
17
+ export interface LaunchBrowserOptions extends PlaywrightLaunchOptions {
18
+ source?: "playwright" | "playwright-core";
19
+ featureName?: string;
20
+ env?: NodeJS.ProcessEnv;
21
+ findSystemBrowser?: typeof findSystemBrowser;
22
+ }
23
+ export declare function findSystemBrowser(deps?: FindSystemBrowserDeps): SystemBrowserInfo | null;
24
+ export declare function probeAdapters(deps?: AdapterProbeDeps): Promise<AdapterProbeResults>;
25
+ export declare function loadPlaywright(deps?: AdapterProbeDeps | IngestDeps | VerifyDeps): Promise<PlaywrightLike | null>;
26
+ export declare function launchBrowser(pw: PlaywrightLike, options?: LaunchBrowserOptions): Promise<PlaywrightBrowserLike>;
4
27
  export declare function loadSharp(_deps?: unknown): Promise<SharpLike | null>;
5
28
  export declare function findFfmpeg(_deps?: unknown): {
6
29
  ffmpeg: string | null;
@@ -1,8 +1,37 @@
1
1
  import { spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+ import { VibecodeError, errorMessage } from "./errors.js";
7
+ import { buildWindowsCmdSpawn, isWindowsCmdShim } from "./exec.js";
8
+ const PLAYWRIGHT_INSTALL_HINT = "npm install -D playwright && npx playwright install chromium";
9
+ const PLAYWRIGHT_CORE_BROWSER_HINT = "playwright-core was found, but no system Chrome/Edge/Chromium browser was detected. Install Google Chrome or Microsoft Edge, set VIBECODE_CHROME_PATH to a browser executable, or run: npm install -D playwright && npx playwright install chromium";
10
+ const MISSING_EXECUTABLE_RE = /executable doesn't exist|failed to launch|not found|enoent/i;
11
+ const playwrightMeta = new WeakMap();
12
+ let cachedGlobalRoot;
13
+ function safeExists(existsFn, targetPath) {
14
+ try {
15
+ return existsFn(targetPath);
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
2
21
  function spawnOk(cmd, args) {
3
22
  try {
4
- const useShell = process.platform === "win32" && /\.(cmd|bat)$/i.test(cmd);
5
- const res = spawnSync(cmd, args, { encoding: "utf8", timeout: 5000, shell: useShell });
23
+ const res = isWindowsCmdShim(cmd)
24
+ ? (() => {
25
+ const spec = buildWindowsCmdSpawn(cmd, args);
26
+ return spawnSync(spec.command, spec.args, {
27
+ encoding: "utf8",
28
+ timeout: 5000,
29
+ shell: false,
30
+ windowsVerbatimArguments: spec.windowsVerbatimArguments,
31
+ windowsHide: true
32
+ });
33
+ })()
34
+ : spawnSync(cmd, args, { encoding: "utf8", timeout: 5000, shell: false, windowsHide: true });
6
35
  return !res.error && res.status === 0;
7
36
  }
8
37
  catch {
@@ -18,6 +47,293 @@ async function tryImport(spec) {
18
47
  return null;
19
48
  }
20
49
  }
50
+ export function findSystemBrowser(deps = {}) {
51
+ const env = deps.env ?? process.env;
52
+ const platform = deps.platform ?? process.platform;
53
+ const exists = deps.existsSync ?? fs.existsSync;
54
+ const customPath = env.VIBECODE_CHROME_PATH?.trim();
55
+ if (customPath && safeExists(exists, customPath)) {
56
+ return { path: customPath, name: "VIBECODE_CHROME_PATH" };
57
+ }
58
+ const candidates = [];
59
+ if (platform === "win32") {
60
+ const programFiles = env.ProgramFiles || "C:\\Program Files";
61
+ const programFilesX86 = env["ProgramFiles(x86)"] || "C:\\Program Files (x86)";
62
+ candidates.push({ path: path.win32.join(programFiles, "Google\\Chrome\\Application\\chrome.exe"), name: "Google Chrome" }, { path: path.win32.join(programFilesX86, "Google\\Chrome\\Application\\chrome.exe"), name: "Google Chrome" });
63
+ if (env.LOCALAPPDATA) {
64
+ candidates.push({
65
+ path: path.win32.join(env.LOCALAPPDATA, "Google\\Chrome\\Application\\chrome.exe"),
66
+ name: "Google Chrome"
67
+ });
68
+ }
69
+ candidates.push({ path: path.win32.join(programFiles, "Microsoft\\Edge\\Application\\msedge.exe"), name: "Microsoft Edge" }, { path: path.win32.join(programFilesX86, "Microsoft\\Edge\\Application\\msedge.exe"), name: "Microsoft Edge" });
70
+ }
71
+ else if (platform === "darwin") {
72
+ candidates.push({ path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", name: "Google Chrome" }, { path: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", name: "Microsoft Edge" }, { path: "/Applications/Chromium.app/Contents/MacOS/Chromium", name: "Chromium" });
73
+ }
74
+ else {
75
+ candidates.push({ path: "/usr/bin/google-chrome", name: "Google Chrome" }, { path: "/usr/bin/google-chrome-stable", name: "Google Chrome" }, { path: "/usr/bin/chromium", name: "Chromium" }, { path: "/usr/bin/chromium-browser", name: "Chromium" }, { path: "/usr/bin/microsoft-edge", name: "Microsoft Edge" });
76
+ }
77
+ for (const candidate of candidates) {
78
+ if (safeExists(exists, candidate.path)) {
79
+ return candidate;
80
+ }
81
+ }
82
+ return null;
83
+ }
84
+ function resolveGlobalNpmRoot(deps) {
85
+ if (deps.globalRoot !== undefined) {
86
+ const trimmed = deps.globalRoot?.trim();
87
+ return trimmed ? trimmed : null;
88
+ }
89
+ if (cachedGlobalRoot !== undefined)
90
+ return cachedGlobalRoot;
91
+ try {
92
+ const isWin = process.platform === "win32";
93
+ const res = isWin
94
+ ? spawnSync(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", "npm.cmd", "root", "-g"], {
95
+ encoding: "utf8",
96
+ timeout: 3000,
97
+ windowsHide: true
98
+ })
99
+ : spawnSync("npm", ["root", "-g"], {
100
+ encoding: "utf8",
101
+ timeout: 3000,
102
+ windowsHide: true
103
+ });
104
+ const out = !res.error && res.status === 0 ? String(res.stdout ?? "").trim() : "";
105
+ cachedGlobalRoot = out || null;
106
+ }
107
+ catch {
108
+ cachedGlobalRoot = null;
109
+ }
110
+ return cachedGlobalRoot;
111
+ }
112
+ function extractExportTarget(entry) {
113
+ if (typeof entry === "string")
114
+ return entry;
115
+ if (!entry || typeof entry !== "object")
116
+ return null;
117
+ const rec = entry;
118
+ for (const key of ["import", "node", "default"]) {
119
+ const nested = extractExportTarget(rec[key]);
120
+ if (nested)
121
+ return nested;
122
+ }
123
+ return null;
124
+ }
125
+ function resolveDirectPackageEntry(pkgDir, probeBaseDir) {
126
+ try {
127
+ return createRequire(path.join(probeBaseDir, "_probe_.js")).resolve(pkgDir);
128
+ }
129
+ catch {
130
+ // Fall back to reading package.json for pure-ESM packages without a require condition.
131
+ }
132
+ const pkgJsonPath = path.join(pkgDir, "package.json");
133
+ if (!safeExists(fs.existsSync, pkgJsonPath))
134
+ return null;
135
+ try {
136
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
137
+ const candidates = [];
138
+ if (pkg.exports && typeof pkg.exports === "object" && !Array.isArray(pkg.exports)) {
139
+ const exportsObj = pkg.exports;
140
+ candidates.push(extractExportTarget(exportsObj["."]), extractExportTarget(pkg.exports));
141
+ }
142
+ else {
143
+ candidates.push(extractExportTarget(pkg.exports));
144
+ }
145
+ if (typeof pkg.module === "string")
146
+ candidates.push(pkg.module);
147
+ if (typeof pkg.main === "string")
148
+ candidates.push(pkg.main);
149
+ candidates.push("index.mjs", "index.js");
150
+ for (const rel of candidates) {
151
+ if (!rel)
152
+ continue;
153
+ const abs = path.resolve(pkgDir, rel);
154
+ if (safeExists(fs.existsSync, abs) && fs.statSync(abs).isFile()) {
155
+ return abs;
156
+ }
157
+ }
158
+ }
159
+ catch {
160
+ return null;
161
+ }
162
+ return null;
163
+ }
164
+ function resolveSpecInDir(dir, spec, preferDirect) {
165
+ const resolvedDir = path.resolve(dir);
166
+ if (preferDirect) {
167
+ const directPkgDir = path.join(resolvedDir, spec);
168
+ if (safeExists(fs.existsSync, path.join(directPkgDir, "package.json"))) {
169
+ const directEntry = resolveDirectPackageEntry(directPkgDir, resolvedDir);
170
+ if (directEntry)
171
+ return directEntry;
172
+ }
173
+ try {
174
+ return createRequire(path.join(resolvedDir, "_probe_.js")).resolve(spec);
175
+ }
176
+ catch {
177
+ return null;
178
+ }
179
+ }
180
+ try {
181
+ return createRequire(path.join(resolvedDir, "package.json")).resolve(spec);
182
+ }
183
+ catch {
184
+ const nodeModulesPkgDir = path.join(resolvedDir, "node_modules", spec);
185
+ if (safeExists(fs.existsSync, path.join(nodeModulesPkgDir, "package.json"))) {
186
+ return resolveDirectPackageEntry(nodeModulesPkgDir, resolvedDir);
187
+ }
188
+ return null;
189
+ }
190
+ }
191
+ function resolveOwnPackagePath(spec) {
192
+ try {
193
+ const resolved = import.meta.resolve(spec);
194
+ if (resolved.startsWith("file:")) {
195
+ return fileURLToPath(resolved);
196
+ }
197
+ return resolved;
198
+ }
199
+ catch {
200
+ try {
201
+ return createRequire(import.meta.url).resolve(spec);
202
+ }
203
+ catch {
204
+ return undefined;
205
+ }
206
+ }
207
+ }
208
+ function extractPlaywright(mod) {
209
+ const direct = mod;
210
+ if (direct.chromium && typeof direct.chromium.launch === "function") {
211
+ return direct;
212
+ }
213
+ const def = mod.default;
214
+ if (def && typeof def === "object" && def.chromium && typeof def.chromium.launch === "function") {
215
+ return def;
216
+ }
217
+ return null;
218
+ }
219
+ function readVersionValue(candidate) {
220
+ if (typeof candidate === "string" && candidate.trim())
221
+ return candidate.trim();
222
+ if (typeof candidate === "function") {
223
+ try {
224
+ const out = candidate();
225
+ if (typeof out === "string" && out.trim())
226
+ return out.trim();
227
+ }
228
+ catch {
229
+ return null;
230
+ }
231
+ }
232
+ return null;
233
+ }
234
+ function readVersionFromPackageJson(packagePath, spec) {
235
+ if (!packagePath)
236
+ return null;
237
+ let dir = path.dirname(packagePath);
238
+ let fallbackVersion = null;
239
+ for (let depth = 0; depth < 6; depth++) {
240
+ const pkgJson = path.join(dir, "package.json");
241
+ if (safeExists(fs.existsSync, pkgJson)) {
242
+ try {
243
+ const parsed = JSON.parse(fs.readFileSync(pkgJson, "utf8"));
244
+ if (typeof parsed.version === "string" && parsed.version.trim()) {
245
+ if (parsed.name === spec)
246
+ return parsed.version.trim();
247
+ if (!fallbackVersion)
248
+ fallbackVersion = parsed.version.trim();
249
+ }
250
+ }
251
+ catch {
252
+ // Ignore unreadable package.json files and keep walking up.
253
+ }
254
+ }
255
+ const parent = path.dirname(dir);
256
+ if (parent === dir)
257
+ break;
258
+ dir = parent;
259
+ }
260
+ return fallbackVersion;
261
+ }
262
+ function readPlaywrightVersion(mod, packagePath, spec) {
263
+ const def = mod.default;
264
+ const direct = readVersionValue(mod.version) ?? (def && typeof def === "object" ? readVersionValue(def.version) : null);
265
+ if (direct)
266
+ return direct;
267
+ return readVersionFromPackageJson(packagePath, spec) ?? "unknown";
268
+ }
269
+ function recordPlaywrightMeta(mod, pw, meta) {
270
+ playwrightMeta.set(mod, meta);
271
+ playwrightMeta.set(pw, meta);
272
+ if (mod.default && typeof mod.default === "object") {
273
+ playwrightMeta.set(mod.default, meta);
274
+ }
275
+ }
276
+ async function resolvePackage(spec, deps) {
277
+ const candidates = [];
278
+ const ownMod = await tryImport(spec);
279
+ if (ownMod) {
280
+ candidates.push({ mod: ownMod, packagePath: resolveOwnPackagePath(spec) });
281
+ }
282
+ if (candidates.length === 0) {
283
+ const cwd = deps.cwd ?? process.cwd();
284
+ const cwdEntry = resolveSpecInDir(cwd, spec, false);
285
+ if (cwdEntry) {
286
+ const mod = await tryImport(pathToFileURL(cwdEntry).href);
287
+ if (mod)
288
+ candidates.push({ mod, packagePath: cwdEntry });
289
+ }
290
+ }
291
+ if (candidates.length === 0) {
292
+ const env = deps.env ?? process.env;
293
+ const nodePathDirs = (env.NODE_PATH ?? "")
294
+ .split(path.delimiter)
295
+ .map((entry) => entry.trim())
296
+ .filter(Boolean);
297
+ for (const dir of nodePathDirs) {
298
+ const entry = resolveSpecInDir(dir, spec, true);
299
+ if (!entry)
300
+ continue;
301
+ const mod = await tryImport(pathToFileURL(entry).href);
302
+ if (mod) {
303
+ candidates.push({ mod, packagePath: entry });
304
+ break;
305
+ }
306
+ }
307
+ }
308
+ if (candidates.length === 0) {
309
+ const globalRoot = resolveGlobalNpmRoot(deps);
310
+ if (globalRoot) {
311
+ const entry = resolveSpecInDir(globalRoot, spec, true);
312
+ if (entry) {
313
+ const mod = await tryImport(pathToFileURL(entry).href);
314
+ if (mod)
315
+ candidates.push({ mod, packagePath: entry });
316
+ }
317
+ }
318
+ }
319
+ for (const candidate of candidates) {
320
+ const pw = extractPlaywright(candidate.mod);
321
+ if (!pw)
322
+ continue;
323
+ const meta = {
324
+ source: spec,
325
+ ...(candidate.packagePath ? { packagePath: candidate.packagePath } : {})
326
+ };
327
+ recordPlaywrightMeta(candidate.mod, pw, meta);
328
+ return {
329
+ source: spec,
330
+ pw,
331
+ ...(candidate.packagePath ? { packagePath: candidate.packagePath } : {}),
332
+ version: readPlaywrightVersion(candidate.mod, candidate.packagePath, spec)
333
+ };
334
+ }
335
+ return null;
336
+ }
21
337
  function readSharpVersion(mod) {
22
338
  try {
23
339
  const def = mod.default;
@@ -29,29 +345,50 @@ function readSharpVersion(mod) {
29
345
  return "unknown";
30
346
  }
31
347
  }
32
- export async function probeAdapters(_deps = {}) {
348
+ function toProbeDeps(deps) {
349
+ const record = deps;
350
+ return {
351
+ ...(typeof record.cwd === "string" ? { cwd: record.cwd } : {}),
352
+ ...(record.env && typeof record.env === "object" ? { env: record.env } : {}),
353
+ ...(record.globalRoot === null || typeof record.globalRoot === "string"
354
+ ? { globalRoot: record.globalRoot }
355
+ : {}),
356
+ ...(typeof record.findSystemBrowser === "function"
357
+ ? { findSystemBrowser: record.findSystemBrowser }
358
+ : {})
359
+ };
360
+ }
361
+ export async function probeAdapters(deps = {}) {
362
+ const env = deps.env ?? process.env;
363
+ const discoverBrowser = deps.findSystemBrowser ?? findSystemBrowser;
364
+ const browser = discoverBrowser({ env });
33
365
  const results = {
34
- playwright: { available: false, installHint: "npm install -D playwright && npx playwright install chromium" },
366
+ playwright: { available: false, installHint: PLAYWRIGHT_INSTALL_HINT },
35
367
  ffmpeg: { available: false, installHint: "Install ffmpeg and ensure it is on PATH (or set VIBECODE_FFMPEG_PATH)." },
36
368
  ffprobe: { available: false, installHint: "Install ffprobe (part of ffmpeg) and ensure it is on PATH (or set VIBECODE_FFPROBE_PATH)." },
37
369
  sharp: { available: false, installHint: "npm install sharp (optional accelerator; native PNG parsing still works)." }
38
370
  };
39
- // playwright
40
- const pw = await tryImport("playwright");
41
- if (pw) {
42
- results.playwright.available = true;
43
- results.playwright.version = typeof pw.version === "string" ? pw.version : "unknown";
371
+ if (browser) {
372
+ results.playwright.browserPath = browser.path;
373
+ results.playwright.browserName = browser.name;
44
374
  }
45
- else {
46
- const pwc = await tryImport("playwright-core");
47
- if (pwc) {
375
+ const resolvedPw = (await resolvePackage("playwright", deps)) ?? (await resolvePackage("playwright-core", deps));
376
+ if (resolvedPw) {
377
+ results.playwright.source = resolvedPw.source;
378
+ results.playwright.version = resolvedPw.version;
379
+ if (resolvedPw.packagePath) {
380
+ results.playwright.packagePath = resolvedPw.packagePath;
381
+ }
382
+ if (resolvedPw.source === "playwright-core" && !browser) {
383
+ results.playwright.available = false;
384
+ results.playwright.installHint = PLAYWRIGHT_CORE_BROWSER_HINT;
385
+ }
386
+ else {
48
387
  results.playwright.available = true;
49
- results.playwright.version = typeof pwc.version === "string" ? pwc.version : "unknown";
50
388
  }
51
389
  }
52
- // ffmpeg / ffprobe
53
- const ffmpegBin = process.env.VIBECODE_FFMPEG_PATH || "ffmpeg";
54
- const ffprobeBin = process.env.VIBECODE_FFPROBE_PATH || "ffprobe";
390
+ const ffmpegBin = env.VIBECODE_FFMPEG_PATH || "ffmpeg";
391
+ const ffprobeBin = env.VIBECODE_FFPROBE_PATH || "ffprobe";
55
392
  if (spawnOk(ffmpegBin, ["-version"])) {
56
393
  results.ffmpeg.available = true;
57
394
  results.ffmpeg.path = ffmpegBin;
@@ -60,7 +397,6 @@ export async function probeAdapters(_deps = {}) {
60
397
  results.ffprobe.available = true;
61
398
  results.ffprobe.path = ffprobeBin;
62
399
  }
63
- // sharp
64
400
  const sharpMod = await tryImport("sharp");
65
401
  if (sharpMod) {
66
402
  results.sharp.available = true;
@@ -68,14 +404,64 @@ export async function probeAdapters(_deps = {}) {
68
404
  }
69
405
  return results;
70
406
  }
71
- export async function loadPlaywright(_deps = {}) {
72
- const pw = await tryImport("playwright");
73
- if (pw)
74
- return pw;
75
- const pwc = await tryImport("playwright-core");
76
- if (pwc)
77
- return pwc;
78
- return null;
407
+ export async function loadPlaywright(deps = {}) {
408
+ const probeDeps = toProbeDeps(deps);
409
+ const resolved = (await resolvePackage("playwright", probeDeps)) ?? (await resolvePackage("playwright-core", probeDeps));
410
+ return resolved ? resolved.pw : null;
411
+ }
412
+ export async function launchBrowser(pw, options) {
413
+ const env = options?.env ?? process.env;
414
+ const featureName = options?.featureName || "Browser automation";
415
+ const discoverBrowser = options?.findSystemBrowser ?? findSystemBrowser;
416
+ const normalizedPw = extractPlaywright(pw) ?? pw;
417
+ const meta = playwrightMeta.get(pw) ?? playwrightMeta.get(normalizedPw);
418
+ const isCore = options?.source === "playwright-core" || (options?.source === undefined && meta?.source === "playwright-core");
419
+ const envChrome = env.VIBECODE_CHROME_PATH?.trim();
420
+ const exe = options?.executablePath ||
421
+ (envChrome && safeExists(fs.existsSync, envChrome) ? envChrome : undefined);
422
+ const baseOpts = {
423
+ headless: options?.headless ?? true,
424
+ ...(options?.args ? { args: options.args } : {})
425
+ };
426
+ const hint = isCore ? PLAYWRIGHT_CORE_BROWSER_HINT : PLAYWRIGHT_INSTALL_HINT;
427
+ if (exe) {
428
+ try {
429
+ return await normalizedPw.chromium.launch({ ...baseOpts, executablePath: exe });
430
+ }
431
+ catch (err) {
432
+ throw new VibecodeError("ADAPTER_MISSING", `${featureName} requires Playwright Chromium (${errorMessage(err)})`, { adapter: "playwright", installHint: hint });
433
+ }
434
+ }
435
+ if (isCore) {
436
+ const browser = discoverBrowser({ env });
437
+ if (!browser) {
438
+ throw new VibecodeError("ADAPTER_MISSING", `${featureName} requires Playwright Chromium (playwright-core found, but no system browser binary was detected)`, { adapter: "playwright", installHint: PLAYWRIGHT_CORE_BROWSER_HINT });
439
+ }
440
+ try {
441
+ return await normalizedPw.chromium.launch({ ...baseOpts, executablePath: browser.path });
442
+ }
443
+ catch (err) {
444
+ throw new VibecodeError("ADAPTER_MISSING", `${featureName} requires Playwright Chromium (${errorMessage(err)})`, { adapter: "playwright", installHint: PLAYWRIGHT_CORE_BROWSER_HINT });
445
+ }
446
+ }
447
+ try {
448
+ return await normalizedPw.chromium.launch(baseOpts);
449
+ }
450
+ catch (err) {
451
+ const msg = errorMessage(err);
452
+ if (MISSING_EXECUTABLE_RE.test(msg)) {
453
+ const browser = discoverBrowser({ env });
454
+ if (browser) {
455
+ try {
456
+ return await normalizedPw.chromium.launch({ ...baseOpts, executablePath: browser.path });
457
+ }
458
+ catch (retryErr) {
459
+ throw new VibecodeError("ADAPTER_MISSING", `${featureName} requires Playwright Chromium (${errorMessage(retryErr)})`, { adapter: "playwright", installHint: PLAYWRIGHT_INSTALL_HINT });
460
+ }
461
+ }
462
+ }
463
+ throw new VibecodeError("ADAPTER_MISSING", `${featureName} requires Playwright Chromium (${msg})`, { adapter: "playwright", installHint: PLAYWRIGHT_INSTALL_HINT });
464
+ }
79
465
  }
80
466
  export async function loadSharp(_deps = {}) {
81
467
  const mod = await tryImport("sharp");
@@ -0,0 +1,67 @@
1
+ import type { TargetMap } from "./target-map.js";
2
+ import type { CommandExecResult } from "./types.js";
3
+ export type AgentKind = "auto" | "claude" | "codex" | "agy" | "opencode" | "mock";
4
+ export type CliAgentKind = Exclude<AgentKind, "auto" | "mock">;
5
+ export interface ParsedAgentSpec {
6
+ kind: AgentKind;
7
+ mockScript?: string;
8
+ }
9
+ export interface AgentFailingSummaryItem {
10
+ id: string;
11
+ severity: string;
12
+ status: string;
13
+ failures: string[];
14
+ repro?: string;
15
+ diffSummary?: string;
16
+ }
17
+ export interface AgentInvokeContext {
18
+ workspaceDir: string;
19
+ specPath: string;
20
+ target: string;
21
+ targets?: TargetMap;
22
+ sliceId?: string;
23
+ iteration: number;
24
+ maxIterations: number;
25
+ failingSummary: AgentFailingSummaryItem[];
26
+ diagnosisBrief?: string;
27
+ }
28
+ export interface AgentInvokeResult {
29
+ ok: boolean;
30
+ agent: string;
31
+ exitCode: number | null;
32
+ stdout: string;
33
+ stderr: string;
34
+ durationMs: number;
35
+ timedOut: boolean;
36
+ quotaExceeded: boolean;
37
+ }
38
+ export interface AgentCommandRunInput {
39
+ command: string;
40
+ args: string[];
41
+ cwd: string;
42
+ stdin?: string;
43
+ env?: Record<string, string | undefined>;
44
+ timeoutMs: number;
45
+ }
46
+ export type AgentCommandRunner = (input: AgentCommandRunInput) => Promise<CommandExecResult>;
47
+ export interface DetectAgentOptions {
48
+ env?: NodeJS.ProcessEnv;
49
+ platform?: NodeJS.Platform;
50
+ probeCommand?: (cmd: string) => boolean;
51
+ }
52
+ export interface InvokeAgentOptions {
53
+ timeoutMs?: number;
54
+ commandRunner?: AgentCommandRunner;
55
+ detectAgent?: (preferred?: AgentKind) => AgentKind | null;
56
+ env?: NodeJS.ProcessEnv;
57
+ platform?: NodeJS.Platform;
58
+ }
59
+ export declare const CLI_AGENT_ORDER: readonly CliAgentKind[];
60
+ export declare const QUOTA_EXCEEDED_RE: RegExp;
61
+ export declare function findExecutableInPath(name: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string | null;
62
+ export declare function parseAgentSpec(spec?: string): ParsedAgentSpec;
63
+ export declare function detectAvailableAgent(preferred?: AgentKind, options?: DetectAgentOptions): AgentKind | null;
64
+ export declare function buildGoldfishPrompt(ctx: AgentInvokeContext): string;
65
+ export declare function buildAgentCliArgs(agent: CliAgentKind, prompt: string): string[];
66
+ export declare function defaultAgentCommandRunner(input: AgentCommandRunInput): Promise<CommandExecResult>;
67
+ export declare function invokeAgent(spec: ParsedAgentSpec, ctx: AgentInvokeContext, options?: InvokeAgentOptions): Promise<AgentInvokeResult>;