vibecode-anything 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +235 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +452 -0
- package/dist/core/adapters.d.ts +8 -0
- package/dist/core/adapters.js +92 -0
- package/dist/core/diff.d.ts +10 -0
- package/dist/core/diff.js +207 -0
- package/dist/core/doctor.d.ts +50 -0
- package/dist/core/doctor.js +312 -0
- package/dist/core/errors.d.ts +32 -0
- package/dist/core/errors.js +81 -0
- package/dist/core/exec.d.ts +14 -0
- package/dist/core/exec.js +109 -0
- package/dist/core/parity.d.ts +9 -0
- package/dist/core/parity.js +138 -0
- package/dist/core/png.d.ts +7 -0
- package/dist/core/png.js +303 -0
- package/dist/core/schema.d.ts +17 -0
- package/dist/core/schema.js +614 -0
- package/dist/core/slices.d.ts +24 -0
- package/dist/core/slices.js +294 -0
- package/dist/core/store.d.ts +17 -0
- package/dist/core/store.js +97 -0
- package/dist/core/types.d.ts +751 -0
- package/dist/core/types.js +4 -0
- package/dist/core/visual.d.ts +34 -0
- package/dist/core/visual.js +459 -0
- package/dist/core/watch.d.ts +53 -0
- package/dist/core/watch.js +285 -0
- package/dist/ingestors/api-repo.d.ts +5 -0
- package/dist/ingestors/api-repo.js +722 -0
- package/dist/ingestors/bridges.d.ts +3 -0
- package/dist/ingestors/bridges.js +562 -0
- package/dist/ingestors/cli.d.ts +9 -0
- package/dist/ingestors/cli.js +266 -0
- package/dist/ingestors/image.d.ts +2 -0
- package/dist/ingestors/image.js +147 -0
- package/dist/ingestors/index.d.ts +5 -0
- package/dist/ingestors/index.js +97 -0
- package/dist/ingestors/video.d.ts +47 -0
- package/dist/ingestors/video.js +605 -0
- package/dist/ingestors/web.d.ts +25 -0
- package/dist/ingestors/web.js +397 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.js +504 -0
- package/dist/oracles/api-repo.d.ts +2 -0
- package/dist/oracles/api-repo.js +214 -0
- package/dist/oracles/cli.d.ts +2 -0
- package/dist/oracles/cli.js +157 -0
- package/dist/oracles/image.d.ts +2 -0
- package/dist/oracles/image.js +279 -0
- package/dist/oracles/index.d.ts +4 -0
- package/dist/oracles/index.js +91 -0
- package/dist/oracles/video.d.ts +21 -0
- package/dist/oracles/video.js +411 -0
- package/dist/oracles/web.d.ts +2 -0
- package/dist/oracles/web.js +480 -0
- package/dist/setup/index.d.ts +7 -0
- package/dist/setup/index.js +186 -0
- package/package.json +47 -6
- package/skills/vibecode-anything/SKILL.md +52 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { readContract, writeContract, writeLastReport, readLastReport, resolveWorkspace } from "./core/store.js";
|
|
5
|
+
import { detectDomain, ingest } from "./ingestors/index.js";
|
|
6
|
+
import { verifyContract } from "./oracles/index.js";
|
|
7
|
+
import { probeAdapters } from "./core/adapters.js";
|
|
8
|
+
import { resolveSliceInvariants, summarizeSlices, updateSliceProgress } from "./core/slices.js";
|
|
9
|
+
import { startWatch, formatWatchEvent } from "./core/watch.js";
|
|
10
|
+
import { runDoctor } from "./core/doctor.js";
|
|
11
|
+
import { VibecodeError, errorCode, toDiagnostic } from "./core/errors.js";
|
|
12
|
+
import { makeDefaultContract, VALID_DOMAINS } from "./core/schema.js";
|
|
13
|
+
const VERSION = "0.3.0";
|
|
14
|
+
const CONTRACT_DIR = ".vibecode";
|
|
15
|
+
const CONTRACT_FILE = path.join(CONTRACT_DIR, "contract.json");
|
|
16
|
+
const VALUE_FLAGS = new Set([
|
|
17
|
+
"domain",
|
|
18
|
+
"source",
|
|
19
|
+
"name",
|
|
20
|
+
"target",
|
|
21
|
+
"probe",
|
|
22
|
+
"probes",
|
|
23
|
+
"route",
|
|
24
|
+
"flow",
|
|
25
|
+
"endpoints",
|
|
26
|
+
"base-url",
|
|
27
|
+
"scene-threshold",
|
|
28
|
+
"max-frames",
|
|
29
|
+
"invariant",
|
|
30
|
+
"slice",
|
|
31
|
+
"debounce",
|
|
32
|
+
"watch-path",
|
|
33
|
+
"id",
|
|
34
|
+
"clients",
|
|
35
|
+
"scope",
|
|
36
|
+
"antigravity-dir"
|
|
37
|
+
]);
|
|
38
|
+
const BOOL_FLAGS = new Set(["force", "strict", "dry-run", "local", "help", "h"]);
|
|
39
|
+
function parseArgs(argv) {
|
|
40
|
+
const [command = "help", ...rest] = argv;
|
|
41
|
+
const flags = {};
|
|
42
|
+
const positionals = [];
|
|
43
|
+
for (let i = 0; i < rest.length; i++) {
|
|
44
|
+
const token = rest[i];
|
|
45
|
+
if (token.startsWith("--")) {
|
|
46
|
+
let key = token.slice(2);
|
|
47
|
+
let value;
|
|
48
|
+
const eq = key.indexOf("=");
|
|
49
|
+
if (eq >= 0) {
|
|
50
|
+
value = key.slice(eq + 1);
|
|
51
|
+
key = key.slice(0, eq);
|
|
52
|
+
}
|
|
53
|
+
else if (BOOL_FLAGS.has(key)) {
|
|
54
|
+
value = true;
|
|
55
|
+
}
|
|
56
|
+
else if (VALUE_FLAGS.has(key)) {
|
|
57
|
+
if (i + 1 < rest.length) {
|
|
58
|
+
value = rest[++i];
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
value = true;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const next = rest[i + 1];
|
|
65
|
+
if (next !== undefined && !next.startsWith("--")) {
|
|
66
|
+
value = next;
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
value = true;
|
|
71
|
+
}
|
|
72
|
+
if (Object.prototype.hasOwnProperty.call(flags, key)) {
|
|
73
|
+
const existing = flags[key];
|
|
74
|
+
if (Array.isArray(existing))
|
|
75
|
+
existing.push(value);
|
|
76
|
+
else
|
|
77
|
+
flags[key] = [existing, value];
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
flags[key] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
positionals.push(token);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { command, flags, positionals };
|
|
88
|
+
}
|
|
89
|
+
function flagList(flags, key) {
|
|
90
|
+
const v = flags[key];
|
|
91
|
+
if (v === undefined)
|
|
92
|
+
return [];
|
|
93
|
+
return Array.isArray(v) ? v : [v];
|
|
94
|
+
}
|
|
95
|
+
function splitCsvFlags(values) {
|
|
96
|
+
const out = [];
|
|
97
|
+
for (const value of values) {
|
|
98
|
+
if (typeof value !== "string")
|
|
99
|
+
continue;
|
|
100
|
+
for (const piece of value.split(",")) {
|
|
101
|
+
const trimmed = piece.trim();
|
|
102
|
+
if (trimmed)
|
|
103
|
+
out.push(trimmed);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
function emit(obj) {
|
|
109
|
+
process.stdout.write(JSON.stringify(obj, null, 2) + "\n");
|
|
110
|
+
}
|
|
111
|
+
function fail(err, fallbackCode = 1) {
|
|
112
|
+
const diag = toDiagnostic(err);
|
|
113
|
+
const code = diag.code === "TARGET_MISSING" ||
|
|
114
|
+
diag.code === "CONTRACT_INVALID" ||
|
|
115
|
+
diag.code === "CONTRACT_NOT_FOUND" ||
|
|
116
|
+
diag.code === "ADAPTER_MISSING" ||
|
|
117
|
+
diag.code === "NOT_FOUND"
|
|
118
|
+
? 2
|
|
119
|
+
: fallbackCode;
|
|
120
|
+
process.stderr.write(JSON.stringify({ error: diag }, null, 2) + "\n");
|
|
121
|
+
process.exitCode = code;
|
|
122
|
+
}
|
|
123
|
+
function cmdInit(flags) {
|
|
124
|
+
const domain = typeof flags.domain === "string" ? flags.domain : "cli";
|
|
125
|
+
const source = typeof flags.source === "string" ? flags.source : "unknown";
|
|
126
|
+
const name = typeof flags.name === "string" ? flags.name : path.basename(process.cwd());
|
|
127
|
+
const contractPath = path.join(process.cwd(), CONTRACT_FILE);
|
|
128
|
+
if (fs.existsSync(contractPath) && !flags.force) {
|
|
129
|
+
process.stderr.write(`Contract already exists at ${CONTRACT_FILE}. Use --force to overwrite.\n`);
|
|
130
|
+
process.exitCode = 1;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
fs.mkdirSync(path.join(process.cwd(), CONTRACT_DIR), { recursive: true });
|
|
134
|
+
const contract = {
|
|
135
|
+
version: "0.1.0",
|
|
136
|
+
target: { name, domain, source },
|
|
137
|
+
invariants: [
|
|
138
|
+
{
|
|
139
|
+
id: "inv-help",
|
|
140
|
+
type: "command",
|
|
141
|
+
description: "Target responds cleanly to --help",
|
|
142
|
+
args: ["--help"],
|
|
143
|
+
expected: { exitCode: 0, stdoutContains: [] }
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
thresholds: { behavioralParity: 1.0 }
|
|
147
|
+
};
|
|
148
|
+
fs.writeFileSync(contractPath, JSON.stringify(contract, null, 2) + "\n", "utf8");
|
|
149
|
+
process.stdout.write(`Initialized ${CONTRACT_FILE} (domain=${domain}, source=${source})\n`);
|
|
150
|
+
}
|
|
151
|
+
async function cmdIngest(flags) {
|
|
152
|
+
const source = flags.source;
|
|
153
|
+
if (typeof source !== "string" || !source) {
|
|
154
|
+
throw new VibecodeError("TARGET_MISSING", "ingest requires --source <reference>");
|
|
155
|
+
}
|
|
156
|
+
const domain = typeof flags.domain === "string" ? flags.domain : detectDomain(source);
|
|
157
|
+
const probes = flagList(flags, "probe").filter((p) => typeof p === "string");
|
|
158
|
+
if (typeof flags.probes === "string") {
|
|
159
|
+
const file = path.resolve(process.cwd(), flags.probes);
|
|
160
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
161
|
+
if (!Array.isArray(parsed))
|
|
162
|
+
throw new VibecodeError("CONTRACT_INVALID", "--probes file must contain a JSON array");
|
|
163
|
+
for (const p of parsed)
|
|
164
|
+
probes.push(p);
|
|
165
|
+
}
|
|
166
|
+
const routes = flagList(flags, "route").filter((r) => typeof r === "string");
|
|
167
|
+
let flow = null;
|
|
168
|
+
if (typeof flags.flow === "string") {
|
|
169
|
+
flow = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), flags.flow), "utf8"));
|
|
170
|
+
}
|
|
171
|
+
let endpoints = null;
|
|
172
|
+
if (typeof flags.endpoints === "string") {
|
|
173
|
+
const parsed = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), flags.endpoints), "utf8"));
|
|
174
|
+
const parsedObj = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
175
|
+
endpoints = Array.isArray(parsed)
|
|
176
|
+
? parsed
|
|
177
|
+
: (parsedObj && Array.isArray(parsedObj.endpoints) ? parsedObj.endpoints : []);
|
|
178
|
+
}
|
|
179
|
+
const contractName = typeof flags.name === "string" && flags.name.trim() ? flags.name.trim() : path.basename(process.cwd());
|
|
180
|
+
const result = await ingest({
|
|
181
|
+
domain,
|
|
182
|
+
source,
|
|
183
|
+
name: contractName,
|
|
184
|
+
probes,
|
|
185
|
+
routes,
|
|
186
|
+
flow,
|
|
187
|
+
endpoints,
|
|
188
|
+
baseUrl: typeof flags["base-url"] === "string" ? flags["base-url"] : undefined,
|
|
189
|
+
sceneThreshold: flags["scene-threshold"] !== undefined ? Number(flags["scene-threshold"]) : undefined,
|
|
190
|
+
maxFrames: flags["max-frames"] !== undefined ? Number(flags["max-frames"]) : undefined,
|
|
191
|
+
cwd: process.cwd()
|
|
192
|
+
}, {});
|
|
193
|
+
const contract = makeDefaultContract({ name: contractName, domain: result.domain, source });
|
|
194
|
+
const invDomains = (result.invariants || []).map((i) => i.domain).filter((d) => VALID_DOMAINS.has(d));
|
|
195
|
+
contract.target.domains = [...new Set([result.domain, ...invDomains].filter((d) => VALID_DOMAINS.has(d)))];
|
|
196
|
+
contract.target.sources = result.sources;
|
|
197
|
+
contract.artifacts = result.artifacts;
|
|
198
|
+
contract.invariants = result.invariants;
|
|
199
|
+
const contractPath = writeContract(contract, process.cwd(), { force: Boolean(flags.force) });
|
|
200
|
+
emit({
|
|
201
|
+
ok: true,
|
|
202
|
+
command: "ingest",
|
|
203
|
+
domain: result.domain,
|
|
204
|
+
contractPath,
|
|
205
|
+
invariants: result.invariants.length,
|
|
206
|
+
warnings: result.warnings
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
async function cmdVerify(flags) {
|
|
210
|
+
const contract = readContract(process.cwd());
|
|
211
|
+
const target = flags.target;
|
|
212
|
+
if (typeof target !== "string" || !target) {
|
|
213
|
+
throw new VibecodeError("TARGET_MISSING", "Missing --target \"<command-or-url>\" for verification.");
|
|
214
|
+
}
|
|
215
|
+
const { artifactsDir, cacheDir } = resolveWorkspace(process.cwd());
|
|
216
|
+
const sliceArgs = splitCsvFlags(flagList(flags, "slice"));
|
|
217
|
+
const explicitIds = flagList(flags, "invariant").filter((x) => typeof x === "string");
|
|
218
|
+
let resolvedSliceIds = [];
|
|
219
|
+
const invariantIds = [];
|
|
220
|
+
const seenIds = new Set();
|
|
221
|
+
if (sliceArgs.length > 0) {
|
|
222
|
+
const resolved = resolveSliceInvariants(contract, sliceArgs);
|
|
223
|
+
resolvedSliceIds = resolved.slices.map((s) => s.id);
|
|
224
|
+
for (const id of resolved.invariantIds) {
|
|
225
|
+
if (!seenIds.has(id)) {
|
|
226
|
+
seenIds.add(id);
|
|
227
|
+
invariantIds.push(id);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
for (const id of explicitIds) {
|
|
232
|
+
if (!seenIds.has(id)) {
|
|
233
|
+
seenIds.add(id);
|
|
234
|
+
invariantIds.push(id);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const ctx = {
|
|
238
|
+
target,
|
|
239
|
+
cwd: process.cwd(),
|
|
240
|
+
contract,
|
|
241
|
+
artifactsDir,
|
|
242
|
+
cacheDir,
|
|
243
|
+
strict: flags.strict === true,
|
|
244
|
+
invariantIds,
|
|
245
|
+
runtimeCache: {}
|
|
246
|
+
};
|
|
247
|
+
const report = await verifyContract(contract, ctx, {});
|
|
248
|
+
writeLastReport(report, process.cwd());
|
|
249
|
+
if (resolvedSliceIds.length > 0 || (Array.isArray(contract.slices) && contract.slices.length > 0)) {
|
|
250
|
+
const updated = updateSliceProgress(contract, report, resolvedSliceIds.length > 0 ? { sliceIds: resolvedSliceIds } : {});
|
|
251
|
+
writeContract(updated, process.cwd(), { force: true });
|
|
252
|
+
emit({ ...report, slices: summarizeSlices(updated) });
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
emit(report);
|
|
256
|
+
}
|
|
257
|
+
process.exitCode = report.gate.exitCode;
|
|
258
|
+
}
|
|
259
|
+
async function cmdWatch(flags) {
|
|
260
|
+
const target = flags.target;
|
|
261
|
+
if (typeof target !== "string" || !target.trim()) {
|
|
262
|
+
throw new VibecodeError("TARGET_MISSING", "Missing --target \"<command-or-url>\" for watch.");
|
|
263
|
+
}
|
|
264
|
+
let debounceMs;
|
|
265
|
+
if (flags.debounce !== undefined) {
|
|
266
|
+
if (typeof flags.debounce !== "string" || !flags.debounce.trim()) {
|
|
267
|
+
throw new VibecodeError("CONTRACT_INVALID", "--debounce requires a non-negative number in milliseconds.");
|
|
268
|
+
}
|
|
269
|
+
debounceMs = Number(flags.debounce);
|
|
270
|
+
if (!Number.isFinite(debounceMs) || debounceMs < 0) {
|
|
271
|
+
throw new VibecodeError("CONTRACT_INVALID", `--debounce must be a non-negative number (got "${flags.debounce}").`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const sliceIds = splitCsvFlags(flagList(flags, "slice"));
|
|
275
|
+
const invariantIds = flagList(flags, "invariant").filter((x) => typeof x === "string");
|
|
276
|
+
const watchPaths = flagList(flags, "watch-path").filter((x) => typeof x === "string");
|
|
277
|
+
const controller = new AbortController();
|
|
278
|
+
const stop = () => controller.abort();
|
|
279
|
+
process.on("SIGINT", stop);
|
|
280
|
+
process.on("SIGTERM", stop);
|
|
281
|
+
try {
|
|
282
|
+
const handle = await startWatch({
|
|
283
|
+
target,
|
|
284
|
+
cwd: process.cwd(),
|
|
285
|
+
...(watchPaths.length > 0 ? { watchPaths } : {}),
|
|
286
|
+
...(debounceMs !== undefined ? { debounceMs } : {}),
|
|
287
|
+
strict: flags.strict === true,
|
|
288
|
+
...(sliceIds.length > 0 ? { sliceIds } : {}),
|
|
289
|
+
...(invariantIds.length > 0 ? { invariantIds } : {}),
|
|
290
|
+
signal: controller.signal,
|
|
291
|
+
onRun: (event) => {
|
|
292
|
+
process.stdout.write(formatWatchEvent(event) + "\n");
|
|
293
|
+
process.exitCode = event.report.gate.exitCode;
|
|
294
|
+
},
|
|
295
|
+
onError: (err) => {
|
|
296
|
+
fail(err);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
await handle.done;
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
process.removeListener("SIGINT", stop);
|
|
303
|
+
process.removeListener("SIGTERM", stop);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async function cmdDoctor(flags) {
|
|
307
|
+
const scope = typeof flags.scope === "string" ? flags.scope : "project";
|
|
308
|
+
const antigravityDir = typeof flags["antigravity-dir"] === "string" ? flags["antigravity-dir"] : undefined;
|
|
309
|
+
const strict = flags.strict === true;
|
|
310
|
+
const report = await runDoctor({
|
|
311
|
+
cwd: process.cwd(),
|
|
312
|
+
scope,
|
|
313
|
+
...(antigravityDir ? { antigravityDir } : {}),
|
|
314
|
+
strict
|
|
315
|
+
});
|
|
316
|
+
emit(report);
|
|
317
|
+
process.exitCode = report.exitCode;
|
|
318
|
+
}
|
|
319
|
+
async function cmdStatus() {
|
|
320
|
+
let contract = null;
|
|
321
|
+
try {
|
|
322
|
+
contract = readContract(process.cwd());
|
|
323
|
+
}
|
|
324
|
+
catch (err) {
|
|
325
|
+
if (errorCode(err) !== "CONTRACT_NOT_FOUND")
|
|
326
|
+
throw err;
|
|
327
|
+
}
|
|
328
|
+
const adapters = await probeAdapters();
|
|
329
|
+
const last = readLastReport(process.cwd());
|
|
330
|
+
const hard = contract ? contract.invariants.filter((i) => i.severity === "hard").length : 0;
|
|
331
|
+
const soft = contract ? contract.invariants.filter((i) => i.severity === "soft").length : 0;
|
|
332
|
+
emit({
|
|
333
|
+
ok: true,
|
|
334
|
+
command: "status",
|
|
335
|
+
contract: contract
|
|
336
|
+
? {
|
|
337
|
+
exists: true,
|
|
338
|
+
schemaVersion: contract.schemaVersion,
|
|
339
|
+
name: contract.target.name,
|
|
340
|
+
domains: contract.target.domains,
|
|
341
|
+
sources: contract.target.sources,
|
|
342
|
+
invariants: contract.invariants.length,
|
|
343
|
+
hard,
|
|
344
|
+
soft,
|
|
345
|
+
thresholds: contract.thresholds,
|
|
346
|
+
slices: summarizeSlices(contract)
|
|
347
|
+
}
|
|
348
|
+
: { exists: false },
|
|
349
|
+
adapters,
|
|
350
|
+
lastReport: last
|
|
351
|
+
? {
|
|
352
|
+
timestamp: last.timestamp,
|
|
353
|
+
gate: last.gate,
|
|
354
|
+
hard: last.hard,
|
|
355
|
+
soft: last.soft,
|
|
356
|
+
compositeScore: last.compositeScore,
|
|
357
|
+
parity: last.parity,
|
|
358
|
+
nextAction: last.nextAction
|
|
359
|
+
}
|
|
360
|
+
: null
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function cmdDiff(flags) {
|
|
364
|
+
const last = readLastReport(process.cwd());
|
|
365
|
+
if (!last) {
|
|
366
|
+
throw new VibecodeError("CONTRACT_NOT_FOUND", "No .vibecode/last-report.json yet. Run 'vibecode-anything verify' first.");
|
|
367
|
+
}
|
|
368
|
+
const id = flags.invariant || flags.id;
|
|
369
|
+
if (!id || id === true) {
|
|
370
|
+
emit(last);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const result = (last.results || []).find((r) => r.id === id);
|
|
374
|
+
if (!result) {
|
|
375
|
+
process.stderr.write(JSON.stringify({ error: { code: "NOT_FOUND", message: `No result for invariant ${String(id)}` } }, null, 2) + "\n");
|
|
376
|
+
process.exitCode = 2;
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
emit(result);
|
|
380
|
+
}
|
|
381
|
+
function cmdHelp() {
|
|
382
|
+
process.stdout.write(`vibecode-anything v${VERSION}
|
|
383
|
+
|
|
384
|
+
Commands:
|
|
385
|
+
init --domain <cli|web|api> --source <ref> Create .vibecode/contract.json (v0.1 compatible)
|
|
386
|
+
ingest --domain <cli|web|image|video|api|repo|rea|cli-anything> --source <ref>
|
|
387
|
+
Probe a reference and write a v0.2 contract
|
|
388
|
+
verify --target "<command-or-url>" [--strict] [--invariant <id>] [--slice <id>]
|
|
389
|
+
Run the differential oracle & parity gate
|
|
390
|
+
watch --target "<command-or-url>" [--slice <id>] [--watch-path <dir>] [--debounce <ms>] [--strict]
|
|
391
|
+
Re-run verification automatically on file changes
|
|
392
|
+
status Show contract metadata, adapters, slices, and last report
|
|
393
|
+
diff --invariant <id> Show the last result/diff for one invariant
|
|
394
|
+
doctor [--scope project|global] [--strict] [--antigravity-dir <dir>]
|
|
395
|
+
Check Node, adapters, optional CLIs, and MCP registration
|
|
396
|
+
mcp Start the stdio MCP server
|
|
397
|
+
setup [--clients ...] [--scope project|global] [--dry-run]
|
|
398
|
+
Register MCP + SKILL.md for coding agents
|
|
399
|
+
help Show this help
|
|
400
|
+
`);
|
|
401
|
+
}
|
|
402
|
+
async function main() {
|
|
403
|
+
const { command, flags, positionals } = parseArgs(process.argv.slice(2));
|
|
404
|
+
try {
|
|
405
|
+
// `--help` after any subcommand must print help, never execute (e.g. `setup --help`).
|
|
406
|
+
if (flags.help === true || flags.h === true || command === "help" || command === "--help" || command === "-h" || positionals.includes("-h")) {
|
|
407
|
+
cmdHelp();
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (command === "init")
|
|
411
|
+
cmdInit(flags);
|
|
412
|
+
else if (command === "ingest")
|
|
413
|
+
await cmdIngest(flags);
|
|
414
|
+
else if (command === "verify")
|
|
415
|
+
await cmdVerify(flags);
|
|
416
|
+
else if (command === "watch")
|
|
417
|
+
await cmdWatch(flags);
|
|
418
|
+
else if (command === "status")
|
|
419
|
+
await cmdStatus();
|
|
420
|
+
else if (command === "diff")
|
|
421
|
+
cmdDiff(flags);
|
|
422
|
+
else if (command === "doctor")
|
|
423
|
+
await cmdDoctor(flags);
|
|
424
|
+
else if (command === "mcp") {
|
|
425
|
+
const { createMcpServer } = await import("./mcp/server.js");
|
|
426
|
+
const server = createMcpServer({ cwd: process.cwd() });
|
|
427
|
+
server.start();
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
else if (command === "setup") {
|
|
431
|
+
const { runSetup } = await import("./setup/index.js");
|
|
432
|
+
const report = await runSetup({
|
|
433
|
+
clients: flagList(flags, "clients").filter((c) => typeof c === "string"),
|
|
434
|
+
scope: typeof flags.scope === "string" ? flags.scope : "project",
|
|
435
|
+
local: flags.local === true,
|
|
436
|
+
dryRun: flags["dry-run"] === true,
|
|
437
|
+
antigravityDir: typeof flags["antigravity-dir"] === "string" ? flags["antigravity-dir"] : undefined,
|
|
438
|
+
cwd: process.cwd()
|
|
439
|
+
});
|
|
440
|
+
emit(report);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
process.stderr.write(`Unknown command: ${command}\n\n`);
|
|
444
|
+
cmdHelp();
|
|
445
|
+
process.exitCode = 2;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (err) {
|
|
449
|
+
fail(err);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
main();
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
4
|
+
export declare function loadSharp(_deps?: unknown): Promise<SharpLike | null>;
|
|
5
|
+
export declare function findFfmpeg(_deps?: unknown): {
|
|
6
|
+
ffmpeg: string | null;
|
|
7
|
+
ffprobe: string | null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
function spawnOk(cmd, args) {
|
|
3
|
+
try {
|
|
4
|
+
const useShell = process.platform === "win32" && /\.(cmd|bat)$/i.test(cmd);
|
|
5
|
+
const res = spawnSync(cmd, args, { encoding: "utf8", timeout: 5000, shell: useShell });
|
|
6
|
+
return !res.error && res.status === 0;
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
async function tryImport(spec) {
|
|
13
|
+
try {
|
|
14
|
+
const mod = (await import(spec));
|
|
15
|
+
return mod;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function readSharpVersion(mod) {
|
|
22
|
+
try {
|
|
23
|
+
const def = mod.default;
|
|
24
|
+
const top = mod.versions;
|
|
25
|
+
const ver = def?.versions?.sharp ?? top?.sharp;
|
|
26
|
+
return typeof ver === "string" && ver ? ver : "unknown";
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return "unknown";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function probeAdapters(_deps = {}) {
|
|
33
|
+
const results = {
|
|
34
|
+
playwright: { available: false, installHint: "npm install -D playwright && npx playwright install chromium" },
|
|
35
|
+
ffmpeg: { available: false, installHint: "Install ffmpeg and ensure it is on PATH (or set VIBECODE_FFMPEG_PATH)." },
|
|
36
|
+
ffprobe: { available: false, installHint: "Install ffprobe (part of ffmpeg) and ensure it is on PATH (or set VIBECODE_FFPROBE_PATH)." },
|
|
37
|
+
sharp: { available: false, installHint: "npm install sharp (optional accelerator; native PNG parsing still works)." }
|
|
38
|
+
};
|
|
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";
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const pwc = await tryImport("playwright-core");
|
|
47
|
+
if (pwc) {
|
|
48
|
+
results.playwright.available = true;
|
|
49
|
+
results.playwright.version = typeof pwc.version === "string" ? pwc.version : "unknown";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// ffmpeg / ffprobe
|
|
53
|
+
const ffmpegBin = process.env.VIBECODE_FFMPEG_PATH || "ffmpeg";
|
|
54
|
+
const ffprobeBin = process.env.VIBECODE_FFPROBE_PATH || "ffprobe";
|
|
55
|
+
if (spawnOk(ffmpegBin, ["-version"])) {
|
|
56
|
+
results.ffmpeg.available = true;
|
|
57
|
+
results.ffmpeg.path = ffmpegBin;
|
|
58
|
+
}
|
|
59
|
+
if (spawnOk(ffprobeBin, ["-version"])) {
|
|
60
|
+
results.ffprobe.available = true;
|
|
61
|
+
results.ffprobe.path = ffprobeBin;
|
|
62
|
+
}
|
|
63
|
+
// sharp
|
|
64
|
+
const sharpMod = await tryImport("sharp");
|
|
65
|
+
if (sharpMod) {
|
|
66
|
+
results.sharp.available = true;
|
|
67
|
+
results.sharp.version = readSharpVersion(sharpMod);
|
|
68
|
+
}
|
|
69
|
+
return results;
|
|
70
|
+
}
|
|
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;
|
|
79
|
+
}
|
|
80
|
+
export async function loadSharp(_deps = {}) {
|
|
81
|
+
const mod = await tryImport("sharp");
|
|
82
|
+
if (!mod)
|
|
83
|
+
return null;
|
|
84
|
+
return (mod.default || mod);
|
|
85
|
+
}
|
|
86
|
+
export function findFfmpeg(_deps = {}) {
|
|
87
|
+
const ffmpeg = process.env.VIBECODE_FFMPEG_PATH || "ffmpeg";
|
|
88
|
+
const ffprobe = process.env.VIBECODE_FFPROBE_PATH || "ffprobe";
|
|
89
|
+
const okFfmpeg = spawnOk(ffmpeg, ["-version"]) ? ffmpeg : null;
|
|
90
|
+
const okFfprobe = spawnOk(ffprobe, ["-version"]) ? ffprobe : null;
|
|
91
|
+
return { ffmpeg: okFfmpeg, ffprobe: okFfprobe };
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DiffLinesOptions, DiffLinesResult, JsonSubsetDiff } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Output normalizers and diff utilities.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeText(text: unknown, modes?: readonly string[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* Simple LCS-based unified diff.
|
|
8
|
+
*/
|
|
9
|
+
export declare function diffLines(expected: unknown, actual: unknown, { context, maxLines }?: DiffLinesOptions): DiffLinesResult;
|
|
10
|
+
export declare function diffJsonSubset(expectedSubset: unknown, actual: unknown, path?: string): JsonSubsetDiff[];
|