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.
- package/README.md +239 -67
- package/dist/cli.js +2140 -73
- package/dist/core/adapters.d.ts +26 -3
- package/dist/core/adapters.js +411 -25
- package/dist/core/agent-adapter.d.ts +67 -0
- package/dist/core/agent-adapter.js +312 -0
- package/dist/core/anti-cheat.d.ts +6 -0
- package/dist/core/anti-cheat.js +372 -0
- package/dist/core/badge.d.ts +18 -0
- package/dist/core/badge.js +360 -0
- package/dist/core/cache.d.ts +47 -0
- package/dist/core/cache.js +403 -0
- package/dist/core/ci-export.d.ts +35 -0
- package/dist/core/ci-export.js +796 -0
- package/dist/core/ci-formats.d.ts +21 -0
- package/dist/core/ci-formats.js +388 -0
- package/dist/core/client-codegen.d.ts +36 -0
- package/dist/core/client-codegen.js +2538 -0
- package/dist/core/compose.d.ts +71 -0
- package/dist/core/compose.js +1088 -0
- package/dist/core/docs-export.d.ts +37 -0
- package/dist/core/docs-export.js +2706 -0
- package/dist/core/doctor.d.ts +21 -1
- package/dist/core/doctor.js +234 -21
- package/dist/core/exec.d.ts +26 -2
- package/dist/core/exec.js +235 -8
- package/dist/core/fixtures.d.ts +153 -0
- package/dist/core/fixtures.js +2245 -0
- package/dist/core/format.d.ts +77 -0
- package/dist/core/format.js +632 -0
- package/dist/core/fs-snapshot.d.ts +37 -0
- package/dist/core/fs-snapshot.js +216 -0
- package/dist/core/graphql-export.d.ts +34 -0
- package/dist/core/graphql-export.js +2482 -0
- package/dist/core/har-export.d.ts +29 -0
- package/dist/core/har-export.js +988 -0
- package/dist/core/html-report.d.ts +27 -0
- package/dist/core/html-report.js +1535 -0
- package/dist/core/http-export.d.ts +31 -0
- package/dist/core/http-export.js +726 -0
- package/dist/core/impact.d.ts +80 -0
- package/dist/core/impact.js +1412 -0
- package/dist/core/lint.d.ts +38 -0
- package/dist/core/lint.js +1111 -0
- package/dist/core/load-export.d.ts +37 -0
- package/dist/core/load-export.js +1813 -0
- package/dist/core/mcp-export.d.ts +35 -0
- package/dist/core/mcp-export.js +1736 -0
- package/dist/core/mock-server.d.ts +47 -0
- package/dist/core/mock-server.js +1722 -0
- package/dist/core/openapi-export.d.ts +44 -0
- package/dist/core/openapi-export.js +1074 -0
- package/dist/core/parity.d.ts +6 -1
- package/dist/core/parity.js +36 -1
- package/dist/core/playwright-exporter.d.ts +23 -0
- package/dist/core/playwright-exporter.js +1343 -0
- package/dist/core/png.js +45 -9
- package/dist/core/regression.d.ts +54 -0
- package/dist/core/regression.js +529 -0
- package/dist/core/responsive.d.ts +86 -0
- package/dist/core/responsive.js +606 -0
- package/dist/core/run.d.ts +74 -0
- package/dist/core/run.js +696 -0
- package/dist/core/scheduler.d.ts +24 -0
- package/dist/core/scheduler.js +162 -0
- package/dist/core/schema-export.d.ts +29 -0
- package/dist/core/schema-export.js +2215 -0
- package/dist/core/schema.d.ts +3 -2
- package/dist/core/schema.js +460 -17
- package/dist/core/security.d.ts +233 -0
- package/dist/core/security.js +1839 -0
- package/dist/core/server-export.d.ts +38 -0
- package/dist/core/server-export.js +3198 -0
- package/dist/core/spec-writer.d.ts +9 -0
- package/dist/core/spec-writer.js +1202 -0
- package/dist/core/store.d.ts +11 -2
- package/dist/core/store.js +128 -8
- package/dist/core/target-map.d.ts +34 -0
- package/dist/core/target-map.js +262 -0
- package/dist/core/test-exporter.d.ts +25 -0
- package/dist/core/test-exporter.js +1918 -0
- package/dist/core/types.d.ts +182 -14
- package/dist/core/visual-semantic.d.ts +67 -0
- package/dist/core/visual-semantic.js +673 -0
- package/dist/core/visual.js +65 -16
- package/dist/core/watch.d.ts +28 -3
- package/dist/core/watch.js +222 -12
- package/dist/core/yaml.d.ts +5 -0
- package/dist/core/yaml.js +1009 -0
- package/dist/diagnostics/diagnose.d.ts +53 -0
- package/dist/diagnostics/diagnose.js +1083 -0
- package/dist/diagnostics/flake.d.ts +71 -0
- package/dist/diagnostics/flake.js +608 -0
- package/dist/diagnostics/mutation-audit.d.ts +69 -0
- package/dist/diagnostics/mutation-audit.js +769 -0
- package/dist/diagnostics/spatial.d.ts +42 -0
- package/dist/diagnostics/spatial.js +346 -0
- package/dist/diagnostics/trends.d.ts +122 -0
- package/dist/diagnostics/trends.js +1190 -0
- package/dist/discovery/discover.d.ts +111 -0
- package/dist/discovery/discover.js +2017 -0
- package/dist/discovery/lock.d.ts +116 -0
- package/dist/discovery/lock.js +1505 -0
- package/dist/discovery/routes.d.ts +36 -0
- package/dist/discovery/routes.js +1494 -0
- package/dist/discovery/test-importer.d.ts +92 -0
- package/dist/discovery/test-importer.js +4952 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +99 -0
- package/dist/ingestors/api-collections.d.ts +28 -0
- package/dist/ingestors/api-collections.js +2335 -0
- package/dist/ingestors/api-repo.d.ts +2 -1
- package/dist/ingestors/api-repo.js +483 -85
- package/dist/ingestors/asyncapi.d.ts +26 -0
- package/dist/ingestors/asyncapi.js +2105 -0
- package/dist/ingestors/bridges.d.ts +2 -0
- package/dist/ingestors/bridges.js +702 -0
- package/dist/ingestors/cli.d.ts +2 -1
- package/dist/ingestors/cli.js +234 -46
- package/dist/ingestors/curl.d.ts +14 -0
- package/dist/ingestors/curl.js +1024 -0
- package/dist/ingestors/graphql.d.ts +56 -0
- package/dist/ingestors/graphql.js +1852 -0
- package/dist/ingestors/http-file.d.ts +20 -0
- package/dist/ingestors/http-file.js +923 -0
- package/dist/ingestors/index.js +486 -6
- package/dist/ingestors/openrpc.d.ts +29 -0
- package/dist/ingestors/openrpc.js +1807 -0
- package/dist/ingestors/proto.d.ts +47 -0
- package/dist/ingestors/proto.js +2690 -0
- package/dist/ingestors/trace.d.ts +10 -0
- package/dist/ingestors/trace.js +599 -0
- package/dist/ingestors/video.d.ts +4 -1
- package/dist/ingestors/video.js +86 -36
- package/dist/ingestors/web.d.ts +16 -1
- package/dist/ingestors/web.js +474 -32
- package/dist/mcp/server.js +3532 -67
- package/dist/oracles/api-repo.js +102 -30
- package/dist/oracles/cli.js +65 -17
- package/dist/oracles/http-workflow.d.ts +68 -0
- package/dist/oracles/http-workflow.js +828 -0
- package/dist/oracles/image.js +178 -28
- package/dist/oracles/index.d.ts +3 -1
- package/dist/oracles/index.js +243 -14
- package/dist/oracles/perf-budget.d.ts +90 -0
- package/dist/oracles/perf-budget.js +1329 -0
- package/dist/oracles/stream.d.ts +94 -0
- package/dist/oracles/stream.js +1268 -0
- package/dist/oracles/ui-states.d.ts +49 -0
- package/dist/oracles/ui-states.js +894 -0
- package/dist/oracles/video.d.ts +1 -1
- package/dist/oracles/video.js +232 -16
- package/dist/oracles/web.js +464 -73
- package/dist/plugins/builtins.d.ts +12 -0
- package/dist/plugins/builtins.js +1052 -0
- package/dist/plugins/registry.d.ts +86 -0
- package/dist/plugins/registry.js +554 -0
- package/dist/setup/index.js +145 -33
- package/package.json +56 -47
- package/skills/vibecode-anything/SKILL.md +75 -52
package/dist/core/exec.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
const DEFAULT_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
2
3
|
/**
|
|
3
4
|
* Cross-platform quote-aware command tokenizer.
|
|
4
5
|
* Handles "double quotes", 'single quotes', and Windows paths with spaces.
|
|
@@ -55,24 +56,47 @@ export function splitCommand(cmdString) {
|
|
|
55
56
|
args.push(cur);
|
|
56
57
|
return args;
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
-
return /\.(cmd|bat)$/i.test(target);
|
|
59
|
+
export function isWindowsCmdShim(target, platform = process.platform) {
|
|
60
|
+
return platform === "win32" && /\.(cmd|bat)$/i.test(target);
|
|
61
|
+
}
|
|
62
|
+
export function quoteWindowsCmdArg(arg) {
|
|
63
|
+
if (arg.length === 0)
|
|
64
|
+
return '""';
|
|
65
|
+
if (!/[\s"&|<>^(),;=%!]/.test(arg))
|
|
66
|
+
return arg;
|
|
67
|
+
const escaped = arg.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/, "$1$1");
|
|
68
|
+
return `"${escaped}"`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build a shell-free cmd.exe invocation for Windows .cmd/.bat shims so Node 24+
|
|
72
|
+
* does not emit [DEP0190] (passing args with shell: true).
|
|
73
|
+
*/
|
|
74
|
+
export function buildWindowsCmdSpawn(target, args, comSpec = process.env.ComSpec || "cmd.exe") {
|
|
75
|
+
const cmdLine = [quoteWindowsCmdArg(target), ...args.map(quoteWindowsCmdArg)].join(" ");
|
|
76
|
+
return {
|
|
77
|
+
command: comSpec,
|
|
78
|
+
args: ["/d", "/s", "/c", `"${cmdLine}"`],
|
|
79
|
+
windowsVerbatimArguments: true
|
|
80
|
+
};
|
|
60
81
|
}
|
|
61
82
|
/**
|
|
62
83
|
* Safe command execution wrapper.
|
|
63
84
|
* Spawns directly (shell: false) by default to preserve exact arg boundaries
|
|
64
|
-
* and prevent injection; on Windows,
|
|
65
|
-
*
|
|
85
|
+
* and prevent injection; on Windows, invokes .cmd/.bat shims via cmd.exe /d /s /c
|
|
86
|
+
* with windowsVerbatimArguments: true to avoid Node 24+ [DEP0190] warnings.
|
|
66
87
|
*/
|
|
67
88
|
export function runCommand(target, args = [], options = {}) {
|
|
68
89
|
const { stdin, env, cwd, timeoutMs = 10000, shell = false } = options;
|
|
69
90
|
const started = Date.now();
|
|
70
|
-
const
|
|
91
|
+
const strArgs = args.map(String);
|
|
92
|
+
const winCmd = !shell && isWindowsCmdShim(target);
|
|
71
93
|
const spawnOpts = {
|
|
72
94
|
cwd,
|
|
73
95
|
encoding: "utf8",
|
|
74
96
|
timeout: timeoutMs,
|
|
75
|
-
shell
|
|
97
|
+
shell,
|
|
98
|
+
windowsHide: true,
|
|
99
|
+
...(winCmd ? { windowsVerbatimArguments: true } : {}),
|
|
76
100
|
env: env ? { ...process.env, ...env } : process.env,
|
|
77
101
|
maxBuffer: 10 * 1024 * 1024
|
|
78
102
|
};
|
|
@@ -81,7 +105,13 @@ export function runCommand(target, args = [], options = {}) {
|
|
|
81
105
|
}
|
|
82
106
|
let res;
|
|
83
107
|
try {
|
|
84
|
-
|
|
108
|
+
if (winCmd) {
|
|
109
|
+
const spec = buildWindowsCmdSpawn(target, strArgs);
|
|
110
|
+
res = spawnSync(spec.command, spec.args, spawnOpts);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
res = spawnSync(target, strArgs, spawnOpts);
|
|
114
|
+
}
|
|
85
115
|
}
|
|
86
116
|
catch (err) {
|
|
87
117
|
const errObj = err instanceof Error ? err : new Error(String(err));
|
|
@@ -107,3 +137,200 @@ export function runCommand(target, args = [], options = {}) {
|
|
|
107
137
|
error: res.error || null
|
|
108
138
|
};
|
|
109
139
|
}
|
|
140
|
+
function appendBoundedChunk(chunks, currentBytes, chunk, maxBytes) {
|
|
141
|
+
if (currentBytes >= maxBytes)
|
|
142
|
+
return currentBytes;
|
|
143
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
144
|
+
const remaining = maxBytes - currentBytes;
|
|
145
|
+
if (buf.length <= remaining) {
|
|
146
|
+
chunks.push(buf);
|
|
147
|
+
return currentBytes + buf.length;
|
|
148
|
+
}
|
|
149
|
+
chunks.push(buf.subarray(0, remaining));
|
|
150
|
+
return maxBytes;
|
|
151
|
+
}
|
|
152
|
+
/** Terminates a spawned child and its process group/tree across POSIX and Windows. */
|
|
153
|
+
export function killProcessTree(child) {
|
|
154
|
+
if (child.pid) {
|
|
155
|
+
if (process.platform === "win32") {
|
|
156
|
+
try {
|
|
157
|
+
spawnSync("taskkill", ["/PID", String(child.pid), "/T", "/F"], {
|
|
158
|
+
windowsHide: true,
|
|
159
|
+
timeout: 5000,
|
|
160
|
+
stdio: "ignore"
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Fallback to direct child kill below.
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
child.kill("SIGKILL");
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Ignore if already exited.
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
process.kill(-child.pid, "SIGKILL");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
try {
|
|
180
|
+
child.kill("SIGKILL");
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// Ignore if already exited.
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
child.kill("SIGKILL");
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// Ignore if already exited.
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Executes an async command with deterministic stdio handling, bounded output buffering,
|
|
197
|
+
* and full process-tree termination on timeout.
|
|
198
|
+
*/
|
|
199
|
+
export async function spawnBoundedCommand(target, args = [], options = {}) {
|
|
200
|
+
const timeoutMs = options.timeoutMs ?? 10_000;
|
|
201
|
+
const maxBufferBytes = typeof options.maxBufferBytes === "number" && Number.isFinite(options.maxBufferBytes) && options.maxBufferBytes >= 0
|
|
202
|
+
? Math.floor(options.maxBufferBytes)
|
|
203
|
+
: DEFAULT_MAX_BUFFER_BYTES;
|
|
204
|
+
const strArgs = args.map(String);
|
|
205
|
+
const useShell = Boolean(options.shell);
|
|
206
|
+
const winCmd = !useShell && isWindowsCmdShim(target);
|
|
207
|
+
const env = options.env ? { ...process.env, ...options.env } : process.env;
|
|
208
|
+
const started = Date.now();
|
|
209
|
+
let child;
|
|
210
|
+
try {
|
|
211
|
+
if (winCmd) {
|
|
212
|
+
const winArgs = options.flattenWindowsCmdNewlines
|
|
213
|
+
? strArgs.map((arg) => arg.replace(/[\r\n]+/g, " "))
|
|
214
|
+
: strArgs;
|
|
215
|
+
const spec = buildWindowsCmdSpawn(target, winArgs);
|
|
216
|
+
child = spawn(spec.command, spec.args, {
|
|
217
|
+
cwd: options.cwd,
|
|
218
|
+
env,
|
|
219
|
+
shell: false,
|
|
220
|
+
windowsVerbatimArguments: spec.windowsVerbatimArguments,
|
|
221
|
+
windowsHide: true,
|
|
222
|
+
detached: false,
|
|
223
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
child = spawn(target, strArgs, {
|
|
228
|
+
cwd: options.cwd,
|
|
229
|
+
env,
|
|
230
|
+
shell: useShell,
|
|
231
|
+
windowsHide: true,
|
|
232
|
+
detached: process.platform !== "win32",
|
|
233
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
const errObj = err instanceof Error ? err : new Error(String(err));
|
|
239
|
+
return {
|
|
240
|
+
exitCode: null,
|
|
241
|
+
signal: null,
|
|
242
|
+
stdout: "",
|
|
243
|
+
stderr: errObj.message,
|
|
244
|
+
timedOut: false,
|
|
245
|
+
durationMs: Date.now() - started,
|
|
246
|
+
error: errObj
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return new Promise((resolve) => {
|
|
250
|
+
const stdoutChunks = [];
|
|
251
|
+
const stderrChunks = [];
|
|
252
|
+
let stdoutBytes = 0;
|
|
253
|
+
let stderrBytes = 0;
|
|
254
|
+
let settled = false;
|
|
255
|
+
let timedOut = false;
|
|
256
|
+
let spawnErr = null;
|
|
257
|
+
let exitCode = null;
|
|
258
|
+
let exitSignal = null;
|
|
259
|
+
let timeoutTimer = null;
|
|
260
|
+
let postKillTimer = null;
|
|
261
|
+
const finish = (code, signal, err) => {
|
|
262
|
+
if (settled)
|
|
263
|
+
return;
|
|
264
|
+
settled = true;
|
|
265
|
+
if (timeoutTimer) {
|
|
266
|
+
clearTimeout(timeoutTimer);
|
|
267
|
+
timeoutTimer = null;
|
|
268
|
+
}
|
|
269
|
+
if (postKillTimer) {
|
|
270
|
+
clearTimeout(postKillTimer);
|
|
271
|
+
postKillTimer = null;
|
|
272
|
+
}
|
|
273
|
+
if (timedOut) {
|
|
274
|
+
child.stdin?.destroy();
|
|
275
|
+
child.stdout?.destroy();
|
|
276
|
+
child.stderr?.destroy();
|
|
277
|
+
}
|
|
278
|
+
resolve({
|
|
279
|
+
exitCode: timedOut ? null : code,
|
|
280
|
+
signal: signal || (timedOut ? "SIGKILL" : null),
|
|
281
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
282
|
+
stderr: Buffer.concat(stderrChunks).toString("utf8"),
|
|
283
|
+
timedOut,
|
|
284
|
+
durationMs: Date.now() - started,
|
|
285
|
+
error: err
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
child.stdout?.on("error", () => { });
|
|
289
|
+
child.stderr?.on("error", () => { });
|
|
290
|
+
child.stdout?.on("data", (chunk) => {
|
|
291
|
+
stdoutBytes = appendBoundedChunk(stdoutChunks, stdoutBytes, chunk, maxBufferBytes);
|
|
292
|
+
});
|
|
293
|
+
child.stderr?.on("data", (chunk) => {
|
|
294
|
+
stderrBytes = appendBoundedChunk(stderrChunks, stderrBytes, chunk, maxBufferBytes);
|
|
295
|
+
});
|
|
296
|
+
child.stdin?.on("error", () => { });
|
|
297
|
+
if (options.stdin !== undefined && options.stdin !== null) {
|
|
298
|
+
child.stdin?.end(String(options.stdin));
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
child.stdin?.end();
|
|
302
|
+
}
|
|
303
|
+
if (timeoutMs > 0) {
|
|
304
|
+
timeoutTimer = setTimeout(() => {
|
|
305
|
+
if (settled)
|
|
306
|
+
return;
|
|
307
|
+
timedOut = true;
|
|
308
|
+
killProcessTree(child);
|
|
309
|
+
postKillTimer = setTimeout(() => {
|
|
310
|
+
finish(null, "SIGKILL", spawnErr);
|
|
311
|
+
}, 500);
|
|
312
|
+
postKillTimer.unref?.();
|
|
313
|
+
}, timeoutMs);
|
|
314
|
+
timeoutTimer.unref?.();
|
|
315
|
+
}
|
|
316
|
+
child.on("error", (err) => {
|
|
317
|
+
spawnErr = err;
|
|
318
|
+
finish(null, null, err);
|
|
319
|
+
});
|
|
320
|
+
child.on("exit", (code, signal) => {
|
|
321
|
+
exitCode = code;
|
|
322
|
+
exitSignal = signal;
|
|
323
|
+
if (timedOut && !settled) {
|
|
324
|
+
if (postKillTimer)
|
|
325
|
+
clearTimeout(postKillTimer);
|
|
326
|
+
postKillTimer = setTimeout(() => {
|
|
327
|
+
finish(null, signal ?? "SIGKILL", spawnErr);
|
|
328
|
+
}, 150);
|
|
329
|
+
postKillTimer.unref?.();
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
child.on("close", (code, signal) => {
|
|
333
|
+
finish(code ?? exitCode, signal ?? exitSignal, spawnErr);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency declarative stateful fixture & guaranteed rollback engine.
|
|
3
|
+
*
|
|
4
|
+
* Supports workspace file seeding (UTF-8 / base64), recursive workspace snapshots
|
|
5
|
+
* with anti-symlink-swap rollback, relative-origin HTTP setup/teardown hooks
|
|
6
|
+
* (with runtime `{{vars.NAME}}` interpolation, manual redirects, and timeouts),
|
|
7
|
+
* and opt-in shell-free command setup/teardown hooks.
|
|
8
|
+
*/
|
|
9
|
+
import { isSensitiveHeaderName } from "./security.js";
|
|
10
|
+
import { type TargetMap } from "./target-map.js";
|
|
11
|
+
export { isSensitiveHeaderName };
|
|
12
|
+
export declare const MAX_FIXTURE_SEED_FILES = 50;
|
|
13
|
+
export declare const MAX_FIXTURE_SEED_BYTES: number;
|
|
14
|
+
export declare const MAX_FIXTURE_SNAPSHOT_PATHS = 50;
|
|
15
|
+
export declare const MAX_FIXTURE_SNAPSHOT_FILES = 200;
|
|
16
|
+
export declare const MAX_FIXTURE_SNAPSHOT_TOTAL_BYTES: number;
|
|
17
|
+
export declare const MAX_FIXTURE_HOOKS = 20;
|
|
18
|
+
export declare const DEFAULT_FIXTURE_HOOK_TIMEOUT_MS = 10000;
|
|
19
|
+
export declare const MAX_FIXTURE_HOOK_TIMEOUT_MS = 30000;
|
|
20
|
+
export interface FixtureSeedFile {
|
|
21
|
+
path: string;
|
|
22
|
+
content: string;
|
|
23
|
+
encoding?: "utf8" | "base64";
|
|
24
|
+
}
|
|
25
|
+
export interface FixtureHttpHook {
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
body?: unknown;
|
|
30
|
+
expectStatus?: number | number[];
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
targetDomain?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface FixtureCommandHook {
|
|
35
|
+
command: string;
|
|
36
|
+
args?: string[];
|
|
37
|
+
env?: Record<string, string>;
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
expectExitCode?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ContractFixtures {
|
|
42
|
+
seedFiles?: FixtureSeedFile[];
|
|
43
|
+
snapshotPaths?: string[];
|
|
44
|
+
httpSetup?: FixtureHttpHook[];
|
|
45
|
+
httpTeardown?: FixtureHttpHook[];
|
|
46
|
+
commandSetup?: FixtureCommandHook[];
|
|
47
|
+
commandTeardown?: FixtureCommandHook[];
|
|
48
|
+
}
|
|
49
|
+
export type FixturePhaseKind = "seed" | "snapshot" | "http_setup" | "http_teardown" | "command_setup" | "command_teardown" | "rollback";
|
|
50
|
+
export interface FixturePhaseRecord {
|
|
51
|
+
kind: FixturePhaseKind;
|
|
52
|
+
target: string;
|
|
53
|
+
ok: boolean;
|
|
54
|
+
status?: number;
|
|
55
|
+
durationMs: number;
|
|
56
|
+
detail?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface FixtureRunSummary {
|
|
59
|
+
applied: boolean;
|
|
60
|
+
rolledBack: boolean;
|
|
61
|
+
seededFiles: number;
|
|
62
|
+
restoredPaths: number;
|
|
63
|
+
removedNewPaths: number;
|
|
64
|
+
httpSetupCount: number;
|
|
65
|
+
httpTeardownCount: number;
|
|
66
|
+
commandSetupCount: number;
|
|
67
|
+
commandTeardownCount: number;
|
|
68
|
+
failedHooks: number;
|
|
69
|
+
warnings: string[];
|
|
70
|
+
records: FixturePhaseRecord[];
|
|
71
|
+
totalDurationMs: number;
|
|
72
|
+
}
|
|
73
|
+
export interface FixtureExecutionOptions {
|
|
74
|
+
cwd: string;
|
|
75
|
+
target?: string;
|
|
76
|
+
targets?: TargetMap;
|
|
77
|
+
vars?: Record<string, string>;
|
|
78
|
+
headers?: Record<string, string>;
|
|
79
|
+
allowCommandHooks?: boolean;
|
|
80
|
+
skipFixtures?: boolean;
|
|
81
|
+
fetchImpl?: typeof fetch;
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface FixtureValidationResult {
|
|
85
|
+
valid: boolean;
|
|
86
|
+
errors: string[];
|
|
87
|
+
warnings: string[];
|
|
88
|
+
normalized?: ContractFixtures;
|
|
89
|
+
}
|
|
90
|
+
export interface WorkspaceSnapshotFileEntry {
|
|
91
|
+
relPath: string;
|
|
92
|
+
content: Buffer;
|
|
93
|
+
mode?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface WorkspaceSnapshotDirEntry {
|
|
96
|
+
relPath: string;
|
|
97
|
+
mode?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface WorkspaceSnapshotEntry {
|
|
100
|
+
relPath: string;
|
|
101
|
+
existed: boolean;
|
|
102
|
+
kind: "missing" | "file" | "directory";
|
|
103
|
+
content?: Buffer;
|
|
104
|
+
mode?: number;
|
|
105
|
+
files?: WorkspaceSnapshotFileEntry[];
|
|
106
|
+
directories?: WorkspaceSnapshotDirEntry[];
|
|
107
|
+
/** Shallowest ancestor that did not exist at capture time (for empty-dir cleanup on rollback). */
|
|
108
|
+
firstMissingAncestor?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface WorkspaceSnapshot {
|
|
111
|
+
rootDir: string;
|
|
112
|
+
capturedAt: string;
|
|
113
|
+
entries: WorkspaceSnapshotEntry[];
|
|
114
|
+
totalFiles: number;
|
|
115
|
+
totalBytes: number;
|
|
116
|
+
}
|
|
117
|
+
export interface RestoreWorkspaceSnapshotsResult {
|
|
118
|
+
restoredPaths: number;
|
|
119
|
+
removedNewPaths: number;
|
|
120
|
+
errors: string[];
|
|
121
|
+
}
|
|
122
|
+
export interface FormatPrettyFixtureSummaryOptions {
|
|
123
|
+
color?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Validates and normalizes a declarative `ContractFixtures` configuration.
|
|
127
|
+
* Uses descriptor-only plain-object inspection (immune to hostile Proxies/getters
|
|
128
|
+
* and prototype pollution) and enforces strict path, size, and SSRF invariants.
|
|
129
|
+
*/
|
|
130
|
+
export declare function validateContractFixtures(raw: unknown): FixtureValidationResult;
|
|
131
|
+
/**
|
|
132
|
+
* Captures an in-memory byte-exact snapshot of workspace files, directories, and absent paths.
|
|
133
|
+
* Rejects any symlink, special file, vault/secret path, or escape outside `cwd`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function captureWorkspaceSnapshots(cwd: string, paths: readonly string[]): WorkspaceSnapshot;
|
|
136
|
+
/**
|
|
137
|
+
* Restores a captured `WorkspaceSnapshot` back to exact pre-run state.
|
|
138
|
+
* Enforces anti-symlink-swap verification via `lstatSync` on every path component
|
|
139
|
+
* before every mkdir, write, or unlink — never writes or deletes outside `snapshot.rootDir`.
|
|
140
|
+
*/
|
|
141
|
+
export declare function restoreWorkspaceSnapshots(snapshot: WorkspaceSnapshot): RestoreWorkspaceSnapshotsResult;
|
|
142
|
+
/**
|
|
143
|
+
* Executes `runFn()` wrapped in declarative fixture setup and GUARANTEED `finally`
|
|
144
|
+
* teardown + workspace snapshot rollback.
|
|
145
|
+
*/
|
|
146
|
+
export declare function runWithFixtures<T>(fixtures: ContractFixtures | undefined, options: FixtureExecutionOptions, runFn: () => Promise<T>): Promise<{
|
|
147
|
+
result: T;
|
|
148
|
+
fixtureSummary: FixtureRunSummary;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Formats a concise, sanitized terminal summary for a `FixtureRunSummary`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function formatPrettyFixtureSummary(summary: FixtureRunSummary, options?: FormatPrettyFixtureSummaryOptions): string;
|