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/oracles/api-repo.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { VibecodeError, errorMessage } from "../core/errors.js";
|
|
4
5
|
import { validateJsonSchema, queryJsonPath } from "../core/schema.js";
|
|
5
6
|
import { diffJsonSubset } from "../core/diff.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { collectHeaderSecrets, collectJsonSecrets, collectSecretValue, collectUrlSecrets, hasCrossPlatformPathEscape, isInsideVaultDirectory, isPathWithinDir, isRecordSafe, isSensitiveKeyName, isSensitiveQueryParamName, redactDeepValue, redactSecretSpans, redactSensitiveText, resolveSafeTargetUrl } from "../core/security.js";
|
|
8
|
+
import { scanExportsFromFile } from "../ingestors/api-repo.js";
|
|
9
|
+
import { mergeHeaders } from "../ingestors/trace.js";
|
|
10
|
+
const isObject = isRecordSafe;
|
|
11
|
+
function redactApiText(text, secrets) {
|
|
12
|
+
const raw = String(text ?? "");
|
|
13
|
+
if (!raw)
|
|
14
|
+
return "";
|
|
15
|
+
return redactSensitiveText(secrets.size > 0 ? redactSecretSpans(raw, secrets) : raw);
|
|
9
16
|
}
|
|
10
17
|
async function fetchWithTimeout(url, { method = "GET", headers = {}, body, timeoutMs = 10000 } = {}) {
|
|
11
18
|
const ctrl = new AbortController();
|
|
@@ -32,36 +39,59 @@ async function fetchWithTimeout(url, { method = "GET", headers = {}, body, timeo
|
|
|
32
39
|
clearTimeout(t);
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
|
-
function buildUrl(base, p, query) {
|
|
36
|
-
const baseUrl = /^https?:\/\//i.test(base) ? base : `http://${base}`;
|
|
37
|
-
const url = /^https?:\/\//i.test(p) ? new URL(p) : new URL(p, baseUrl);
|
|
38
|
-
if (isObject(query)) {
|
|
39
|
-
for (const [k, v] of Object.entries(query)) {
|
|
40
|
-
if (v !== undefined && v !== null)
|
|
41
|
-
url.searchParams.set(k, String(v));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return url.toString();
|
|
45
|
-
}
|
|
46
42
|
async function verifyHttp(invariant, ctx, deps) {
|
|
47
43
|
if (!ctx.target)
|
|
48
44
|
throw new VibecodeError("TARGET_MISSING", "Missing --target <base-url> for HTTP verification.");
|
|
49
45
|
const input = invariant.input || {};
|
|
50
46
|
const expected = invariant.expected || {};
|
|
51
|
-
const url = buildUrl(ctx.target, input.path || "/", input.query);
|
|
52
47
|
const method = String(input.method || "GET").toUpperCase();
|
|
53
|
-
const
|
|
48
|
+
const secrets = new Set();
|
|
49
|
+
collectUrlSecrets(secrets, ctx.target);
|
|
50
|
+
if (typeof input.path === "string")
|
|
51
|
+
collectUrlSecrets(secrets, input.path);
|
|
52
|
+
if (isObject(input.query)) {
|
|
53
|
+
for (const [qk, qv] of Object.entries(input.query)) {
|
|
54
|
+
if (qv !== undefined && qv !== null && (isSensitiveQueryParamName(qk) || isSensitiveKeyName(qk))) {
|
|
55
|
+
collectSecretValue(secrets, String(qv));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
collectHeaderSecrets(secrets, isObject(input.headers) ? input.headers : undefined);
|
|
60
|
+
collectHeaderSecrets(secrets, ctx.headers);
|
|
61
|
+
let url;
|
|
62
|
+
try {
|
|
63
|
+
url = resolveSafeTargetUrl(input.path || "/", ctx.target, { query: input.query }).toString();
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
const rawDisplay = typeof input.path === "string" && input.path.trim() ? input.path : ctx.target;
|
|
67
|
+
return {
|
|
68
|
+
status: "fail",
|
|
69
|
+
score: 0,
|
|
70
|
+
failures: [redactApiText(`invalid HTTP URL: ${errorMessage(err)}`, secrets)],
|
|
71
|
+
metrics: { url: redactApiText(rawDisplay, secrets), method: redactApiText(method, secrets) }
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
collectUrlSecrets(secrets, url);
|
|
75
|
+
const safeUrl = redactApiText(url, secrets);
|
|
76
|
+
const headers = mergeHeaders(isObject(input.headers) ? input.headers : undefined, ctx.headers);
|
|
54
77
|
const timeoutMs = input.timeoutMs || 10000;
|
|
55
78
|
const body = input.body ?? null;
|
|
79
|
+
collectJsonSecrets(secrets, body, { maxDepth: 24 });
|
|
56
80
|
let obs;
|
|
57
81
|
const started = Date.now();
|
|
58
82
|
try {
|
|
59
83
|
obs = await (deps.fetchWithTimeout || fetchWithTimeout)(url, { method, headers, body, timeoutMs });
|
|
60
84
|
}
|
|
61
85
|
catch (err) {
|
|
62
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
status: "fail",
|
|
88
|
+
score: 0,
|
|
89
|
+
failures: [redactApiText(`request failed: ${errorMessage(err)}`, secrets)],
|
|
90
|
+
metrics: { url: safeUrl, method: redactApiText(method, secrets) }
|
|
91
|
+
};
|
|
63
92
|
}
|
|
64
93
|
const durationMs = Date.now() - started;
|
|
94
|
+
collectJsonSecrets(secrets, obs.json, { maxDepth: 24 });
|
|
65
95
|
const failures = [];
|
|
66
96
|
const diff = {};
|
|
67
97
|
if (expected.status !== undefined) {
|
|
@@ -150,27 +180,70 @@ async function verifyHttp(invariant, ctx, deps) {
|
|
|
150
180
|
}
|
|
151
181
|
if (jsonPathDiffs.length > 0)
|
|
152
182
|
diff.jsonPaths = jsonPathDiffs;
|
|
183
|
+
const trimmedText = obs.text.trim();
|
|
184
|
+
const candidateOutputHash = trimmedText.length > 0
|
|
185
|
+
? crypto.createHash("sha256").update(trimmedText, "utf8").digest("hex")
|
|
186
|
+
: undefined;
|
|
187
|
+
const scrubbedDiff = Object.keys(diff).length > 0
|
|
188
|
+
? redactDeepValue(diff, {
|
|
189
|
+
maxDepth: 24,
|
|
190
|
+
redactText: (s) => redactApiText(s, secrets),
|
|
191
|
+
sensitiveKeyMode: "value",
|
|
192
|
+
sensitivePathAware: true
|
|
193
|
+
})
|
|
194
|
+
: undefined;
|
|
153
195
|
return {
|
|
154
196
|
status: failures.length ? "fail" : "pass",
|
|
155
197
|
score: failures.length ? 0 : 1,
|
|
156
|
-
failures,
|
|
157
|
-
...(
|
|
158
|
-
metrics: {
|
|
198
|
+
failures: failures.map((f) => redactApiText(f, secrets)),
|
|
199
|
+
...(scrubbedDiff ? { diff: scrubbedDiff } : {}),
|
|
200
|
+
metrics: {
|
|
201
|
+
url: safeUrl,
|
|
202
|
+
method: redactApiText(method, secrets),
|
|
203
|
+
status: obs.status,
|
|
204
|
+
bytes: obs.text.length,
|
|
205
|
+
durationMs,
|
|
206
|
+
...(candidateOutputHash ? { candidateOutputHash } : {})
|
|
207
|
+
}
|
|
159
208
|
};
|
|
160
209
|
}
|
|
210
|
+
function resolveRepoSubpath(repoDir, rawRel) {
|
|
211
|
+
if (!rawRel || hasCrossPlatformPathEscape(rawRel) || path.isAbsolute(rawRel))
|
|
212
|
+
return null;
|
|
213
|
+
const resolved = path.resolve(repoDir, rawRel);
|
|
214
|
+
if (!isPathWithinDir(resolved, repoDir, { allowEqual: false }))
|
|
215
|
+
return null;
|
|
216
|
+
if (isInsideVaultDirectory(resolved))
|
|
217
|
+
return null;
|
|
218
|
+
try {
|
|
219
|
+
if (fs.existsSync(resolved)) {
|
|
220
|
+
const realRepo = fs.realpathSync(repoDir);
|
|
221
|
+
const realTarget = fs.realpathSync(resolved);
|
|
222
|
+
if (!isPathWithinDir(realTarget, realRepo, { allowEqual: false }) || isInsideVaultDirectory(realTarget))
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
return resolved;
|
|
230
|
+
}
|
|
161
231
|
async function verifyRepoExports(invariant, ctx, _deps) {
|
|
162
232
|
if (!ctx.target)
|
|
163
233
|
throw new VibecodeError("TARGET_MISSING", "Missing --target <repo-dir> for repo verification.");
|
|
164
234
|
const repoDir = path.resolve(ctx.cwd || process.cwd(), ctx.target);
|
|
235
|
+
if (isInsideVaultDirectory(repoDir)) {
|
|
236
|
+
throw new VibecodeError("CONFIG_INVALID", "Repo target must not reside inside a holdout vault directory.");
|
|
237
|
+
}
|
|
165
238
|
if (!fs.existsSync(repoDir) || !fs.statSync(repoDir).isDirectory()) {
|
|
166
|
-
throw new VibecodeError("TARGET_MISSING", `Repo target not found: ${ctx.target}`);
|
|
239
|
+
throw new VibecodeError("TARGET_MISSING", `Repo target not found: ${redactSensitiveText(ctx.target)}`);
|
|
167
240
|
}
|
|
168
241
|
const expected = invariant.expected || {};
|
|
169
242
|
const failures = [];
|
|
170
243
|
for (const rel of expected.filesPresent || []) {
|
|
171
|
-
const abs =
|
|
172
|
-
if (!fs.existsSync(abs))
|
|
173
|
-
failures.push(`missing file ${rel}`);
|
|
244
|
+
const abs = resolveRepoSubpath(repoDir, rel);
|
|
245
|
+
if (!abs || !fs.existsSync(abs))
|
|
246
|
+
failures.push(`missing file ${redactSensitiveText(rel)}`);
|
|
174
247
|
}
|
|
175
248
|
const modulePath = invariant.input?.modulePath || (expected.filesPresent || [])[0];
|
|
176
249
|
if (Array.isArray(expected.exports) && expected.exports.length) {
|
|
@@ -178,13 +251,12 @@ async function verifyRepoExports(invariant, ctx, _deps) {
|
|
|
178
251
|
failures.push("no modulePath provided for export verification");
|
|
179
252
|
}
|
|
180
253
|
else {
|
|
181
|
-
const abs =
|
|
182
|
-
if (!fs.existsSync(abs)) {
|
|
183
|
-
failures.push(`module not found: ${modulePath}`);
|
|
254
|
+
const abs = resolveRepoSubpath(repoDir, modulePath);
|
|
255
|
+
if (!abs || !fs.existsSync(abs) || !fs.statSync(abs).isFile()) {
|
|
256
|
+
failures.push(`module not found: ${redactSensitiveText(modulePath)}`);
|
|
184
257
|
}
|
|
185
258
|
else {
|
|
186
|
-
const
|
|
187
|
-
const actual = scanExportsFromText(text);
|
|
259
|
+
const actual = scanExportsFromFile(abs);
|
|
188
260
|
const actualNames = new Set(actual.map((e) => e.name));
|
|
189
261
|
for (const exp of expected.exports) {
|
|
190
262
|
if (!actualNames.has(exp.name))
|
|
@@ -202,7 +274,7 @@ async function verifyRepoExports(invariant, ctx, _deps) {
|
|
|
202
274
|
status: failures.length ? "fail" : "pass",
|
|
203
275
|
score: failures.length ? 0 : 1,
|
|
204
276
|
failures,
|
|
205
|
-
metrics: { repoDir }
|
|
277
|
+
metrics: { repoDir: redactSensitiveText(repoDir) }
|
|
206
278
|
};
|
|
207
279
|
}
|
|
208
280
|
export async function verifyInvariant(invariant, ctx, deps = {}) {
|
package/dist/oracles/cli.js
CHANGED
|
@@ -1,27 +1,63 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
1
3
|
import path from "node:path";
|
|
2
|
-
import { splitCommand
|
|
4
|
+
import { splitCommand } from "../core/exec.js";
|
|
5
|
+
import { DETERMINISTIC_CLI_ENV, diffFsSnapshots, resolveCommandForSandbox, runSandboxedCommand, sha256Text, takeFsSnapshot, verifyFsEffects } from "../core/fs-snapshot.js";
|
|
3
6
|
import { normalizeText, diffLines } from "../core/diff.js";
|
|
4
7
|
import { validateJsonSchema, queryJsonPath } from "../core/schema.js";
|
|
5
8
|
import { VibecodeError, errorMessage } from "../core/errors.js";
|
|
9
|
+
import { isInsideVaultDirectory, redactDeepValue, redactSensitiveText } from "../core/security.js";
|
|
6
10
|
export async function verifyInvariant(invariant, ctx, _deps = {}) {
|
|
7
11
|
if (!ctx.target)
|
|
8
12
|
throw new VibecodeError("TARGET_MISSING", "Missing --target \"<command>\" for CLI verification.");
|
|
9
13
|
const tokens = splitCommand(ctx.target);
|
|
10
14
|
if (tokens.length === 0)
|
|
11
15
|
throw new VibecodeError("TARGET_MISSING", "Invalid --target command");
|
|
12
|
-
const
|
|
16
|
+
const resolvedTokens = resolveCommandForSandbox(tokens, ctx.cwd);
|
|
17
|
+
const [target, ...baseArgs] = resolvedTokens;
|
|
13
18
|
const input = invariant.input || {};
|
|
14
19
|
const expected = invariant.expected || {};
|
|
15
20
|
const modes = Array.isArray(expected.normalize) ? expected.normalize : [];
|
|
16
21
|
const args = [...baseArgs, ...(Array.isArray(input.args) ? input.args : [])];
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const env = {
|
|
23
|
+
...DETERMINISTIC_CLI_ENV,
|
|
24
|
+
...(input.env || {})
|
|
25
|
+
};
|
|
26
|
+
const useFsDiff = input.fsDiff === true || Array.isArray(expected.fsEffects);
|
|
27
|
+
const rawCwdInput = typeof input.cwd === "string" ? input.cwd.trim() : "";
|
|
28
|
+
const cwd = rawCwdInput && rawCwdInput !== "." ? path.resolve(ctx.cwd || process.cwd(), rawCwdInput) : ctx.cwd;
|
|
29
|
+
if ((rawCwdInput && isInsideVaultDirectory(rawCwdInput)) || (cwd && isInsideVaultDirectory(cwd))) {
|
|
30
|
+
throw new VibecodeError("CONFIG_INVALID", "CLI invariant input.cwd must not point inside a holdout vault directory.");
|
|
31
|
+
}
|
|
32
|
+
let run;
|
|
33
|
+
let actualEffects = null;
|
|
34
|
+
if (useFsDiff) {
|
|
35
|
+
const fsSandbox = fs.mkdtempSync(path.join(os.tmpdir(), "vibecode-verify-fs-"));
|
|
36
|
+
try {
|
|
37
|
+
const before = takeFsSnapshot(fsSandbox);
|
|
38
|
+
run = await runSandboxedCommand(target, args, {
|
|
39
|
+
stdin: input.stdin,
|
|
40
|
+
env,
|
|
41
|
+
cwd: fsSandbox,
|
|
42
|
+
timeoutMs: input.timeoutMs || 10000,
|
|
43
|
+
shell: input.shell === true
|
|
44
|
+
});
|
|
45
|
+
const after = takeFsSnapshot(fsSandbox);
|
|
46
|
+
actualEffects = diffFsSnapshots(before, after);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
fs.rmSync(fsSandbox, { recursive: true, force: true, maxRetries: 3, retryDelay: 50 });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
run = await runSandboxedCommand(target, args, {
|
|
54
|
+
stdin: input.stdin,
|
|
55
|
+
env,
|
|
56
|
+
cwd,
|
|
57
|
+
timeoutMs: input.timeoutMs || 10000,
|
|
58
|
+
shell: input.shell === true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
25
61
|
const failures = [];
|
|
26
62
|
const diff = {};
|
|
27
63
|
const stdout = normalizeText(run.stdout, modes);
|
|
@@ -76,7 +112,10 @@ export async function verifyInvariant(invariant, ctx, _deps = {}) {
|
|
|
76
112
|
const golden = normalizeText(expected.goldenStdout, modes);
|
|
77
113
|
const d = diffLines(golden, stdout, { context: 2, maxLines: 60 });
|
|
78
114
|
if (!d.identical) {
|
|
79
|
-
diff.goldenStdout =
|
|
115
|
+
diff.goldenStdout = {
|
|
116
|
+
...d,
|
|
117
|
+
unified: redactSensitiveText(d.unified)
|
|
118
|
+
};
|
|
80
119
|
failures.push(`stdout differs from golden (${d.added} added, ${d.removed} removed)`);
|
|
81
120
|
}
|
|
82
121
|
}
|
|
@@ -101,7 +140,7 @@ export async function verifyInvariant(invariant, ctx, _deps = {}) {
|
|
|
101
140
|
if (schemaErrors.length) {
|
|
102
141
|
for (const e of schemaErrors.slice(0, 10))
|
|
103
142
|
failures.push(`jsonSchema ${e.path}: ${e.message}`);
|
|
104
|
-
diff.jsonSchema = schemaErrors;
|
|
143
|
+
diff.jsonSchema = redactDeepValue(schemaErrors);
|
|
105
144
|
}
|
|
106
145
|
}
|
|
107
146
|
}
|
|
@@ -141,17 +180,26 @@ export async function verifyInvariant(invariant, ctx, _deps = {}) {
|
|
|
141
180
|
}
|
|
142
181
|
}
|
|
143
182
|
if (jsonPathDiffs.length > 0)
|
|
144
|
-
diff.jsonPaths = jsonPathDiffs;
|
|
183
|
+
diff.jsonPaths = redactDeepValue(jsonPathDiffs);
|
|
184
|
+
if (useFsDiff && actualEffects !== null) {
|
|
185
|
+
const fsResult = verifyFsEffects(expected.fsEffects || [], actualEffects);
|
|
186
|
+
failures.push(...fsResult.failures);
|
|
187
|
+
if (fsResult.diffs.length > 0) {
|
|
188
|
+
diff.fsEffects = redactDeepValue(fsResult.diffs);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const safeFailures = failures.map((f) => redactSensitiveText(f));
|
|
145
192
|
return {
|
|
146
|
-
status:
|
|
147
|
-
score:
|
|
148
|
-
failures,
|
|
193
|
+
status: safeFailures.length === 0 ? "pass" : "fail",
|
|
194
|
+
score: safeFailures.length === 0 ? 1 : 0,
|
|
195
|
+
failures: safeFailures,
|
|
149
196
|
...(Object.keys(diff).length ? { diff } : {}),
|
|
150
197
|
metrics: {
|
|
151
198
|
exitCode: run.exitCode,
|
|
152
199
|
durationMs: run.durationMs,
|
|
153
200
|
stdoutBytes: (run.stdout || "").length,
|
|
154
|
-
stderrBytes: (run.stderr || "").length
|
|
201
|
+
stderrBytes: (run.stderr || "").length,
|
|
202
|
+
...(stdout.length > 0 ? { candidateOutputHash: sha256Text(stdout) } : {})
|
|
155
203
|
}
|
|
156
204
|
};
|
|
157
205
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Invariant, JsonPathAssertion, JsonSchema, OracleContext, OracleInvariantOutcome, VerifyDeps } from "../core/types.js";
|
|
2
|
+
export interface HttpWorkflowStepExpected {
|
|
3
|
+
status?: number | number[];
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
bodyExact?: string;
|
|
6
|
+
bodyContains?: string | string[];
|
|
7
|
+
jsonSchema?: JsonSchema;
|
|
8
|
+
jsonSubset?: unknown;
|
|
9
|
+
jsonPaths?: JsonPathAssertion[];
|
|
10
|
+
maxLatencyMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface HttpWorkflowStep {
|
|
13
|
+
id: string;
|
|
14
|
+
method?: string;
|
|
15
|
+
path: string;
|
|
16
|
+
query?: Record<string, string | number | boolean>;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
extract?: Record<string, string>;
|
|
21
|
+
expected?: HttpWorkflowStepExpected;
|
|
22
|
+
}
|
|
23
|
+
export interface HttpWorkflowInput {
|
|
24
|
+
steps: HttpWorkflowStep[];
|
|
25
|
+
finallySteps?: HttpWorkflowStep[];
|
|
26
|
+
vars?: Record<string, string>;
|
|
27
|
+
cookieJar?: boolean;
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface WorkflowStepSummary {
|
|
31
|
+
id: string;
|
|
32
|
+
method: string;
|
|
33
|
+
url: string;
|
|
34
|
+
status?: number;
|
|
35
|
+
durationMs: number;
|
|
36
|
+
passed: boolean;
|
|
37
|
+
phase: "main" | "finally";
|
|
38
|
+
failures: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface WorkflowStepRecord {
|
|
41
|
+
status: number;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
body: unknown;
|
|
44
|
+
text: string;
|
|
45
|
+
extracted: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export interface WorkflowScope {
|
|
48
|
+
steps?: Map<string, WorkflowStepRecord> | Record<string, WorkflowStepRecord>;
|
|
49
|
+
vars?: Map<string, unknown> | Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/** Zero-dependency RFC 6265 cookie jar. */
|
|
52
|
+
export declare class CookieJar {
|
|
53
|
+
private readonly cookies;
|
|
54
|
+
private readonly maxCookies;
|
|
55
|
+
private seq;
|
|
56
|
+
constructor(maxCookies?: number);
|
|
57
|
+
storeFromHeaders(url: string, setCookieHeaders: readonly string[], nowMs?: number): void;
|
|
58
|
+
getCookieHeader(url: string, nowMs?: number): string | undefined;
|
|
59
|
+
clear(): void;
|
|
60
|
+
}
|
|
61
|
+
/** Recursively interpolates `{{...}}` templates safely with prototype-pollution, cycle, and depth guards. */
|
|
62
|
+
export declare function interpolateWorkflowValue(value: unknown, scope: WorkflowScope): {
|
|
63
|
+
value: unknown;
|
|
64
|
+
unresolved: string[];
|
|
65
|
+
};
|
|
66
|
+
/** Verifies a stateful multi-step HTTP workflow with RFC 6265 cookies, extraction, and guaranteed finally cleanup. */
|
|
67
|
+
export declare function verifyHttpWorkflow(invariant: Invariant, ctx: OracleContext, deps?: VerifyDeps): Promise<OracleInvariantOutcome>;
|
|
68
|
+
export declare const verifyInvariant: typeof verifyHttpWorkflow;
|