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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +452 -0
  5. package/dist/core/adapters.d.ts +8 -0
  6. package/dist/core/adapters.js +92 -0
  7. package/dist/core/diff.d.ts +10 -0
  8. package/dist/core/diff.js +207 -0
  9. package/dist/core/doctor.d.ts +50 -0
  10. package/dist/core/doctor.js +312 -0
  11. package/dist/core/errors.d.ts +32 -0
  12. package/dist/core/errors.js +81 -0
  13. package/dist/core/exec.d.ts +14 -0
  14. package/dist/core/exec.js +109 -0
  15. package/dist/core/parity.d.ts +9 -0
  16. package/dist/core/parity.js +138 -0
  17. package/dist/core/png.d.ts +7 -0
  18. package/dist/core/png.js +303 -0
  19. package/dist/core/schema.d.ts +17 -0
  20. package/dist/core/schema.js +614 -0
  21. package/dist/core/slices.d.ts +24 -0
  22. package/dist/core/slices.js +294 -0
  23. package/dist/core/store.d.ts +17 -0
  24. package/dist/core/store.js +97 -0
  25. package/dist/core/types.d.ts +751 -0
  26. package/dist/core/types.js +4 -0
  27. package/dist/core/visual.d.ts +34 -0
  28. package/dist/core/visual.js +459 -0
  29. package/dist/core/watch.d.ts +53 -0
  30. package/dist/core/watch.js +285 -0
  31. package/dist/ingestors/api-repo.d.ts +5 -0
  32. package/dist/ingestors/api-repo.js +722 -0
  33. package/dist/ingestors/bridges.d.ts +3 -0
  34. package/dist/ingestors/bridges.js +562 -0
  35. package/dist/ingestors/cli.d.ts +9 -0
  36. package/dist/ingestors/cli.js +266 -0
  37. package/dist/ingestors/image.d.ts +2 -0
  38. package/dist/ingestors/image.js +147 -0
  39. package/dist/ingestors/index.d.ts +5 -0
  40. package/dist/ingestors/index.js +97 -0
  41. package/dist/ingestors/video.d.ts +47 -0
  42. package/dist/ingestors/video.js +605 -0
  43. package/dist/ingestors/web.d.ts +25 -0
  44. package/dist/ingestors/web.js +397 -0
  45. package/dist/mcp/server.d.ts +2 -0
  46. package/dist/mcp/server.js +504 -0
  47. package/dist/oracles/api-repo.d.ts +2 -0
  48. package/dist/oracles/api-repo.js +214 -0
  49. package/dist/oracles/cli.d.ts +2 -0
  50. package/dist/oracles/cli.js +157 -0
  51. package/dist/oracles/image.d.ts +2 -0
  52. package/dist/oracles/image.js +279 -0
  53. package/dist/oracles/index.d.ts +4 -0
  54. package/dist/oracles/index.js +91 -0
  55. package/dist/oracles/video.d.ts +21 -0
  56. package/dist/oracles/video.js +411 -0
  57. package/dist/oracles/web.d.ts +2 -0
  58. package/dist/oracles/web.js +480 -0
  59. package/dist/setup/index.d.ts +7 -0
  60. package/dist/setup/index.js +186 -0
  61. package/package.json +47 -6
  62. package/skills/vibecode-anything/SKILL.md +52 -0
@@ -0,0 +1,285 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { VibecodeError, errorMessage, errorCode } from "./errors.js";
4
+ import { readContract, writeContract, writeLastReport, resolveWorkspace } from "./store.js";
5
+ import { verifyContract as defaultVerifyContract } from "../oracles/index.js";
6
+ import { resolveSliceInvariants, updateSliceProgress, summarizeSlices } from "./slices.js";
7
+ const DEFAULT_IGNORE = [".git", ".vibecode", "node_modules"];
8
+ function normalizedSegments(filePath, rootDir) {
9
+ const normalized = filePath.replace(/\\/g, "/");
10
+ const rel = path.relative(rootDir, filePath).replace(/\\/g, "/");
11
+ const base = rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? rel : normalized.replace(/^[A-Za-z]:\//, "");
12
+ return base.split("/").filter(Boolean);
13
+ }
14
+ function isIgnored(filePath, ignore, rootDir) {
15
+ const ignored = new Set(ignore.map((entry) => entry.replace(/\\/g, "/").replace(/^\.\//, "")));
16
+ return normalizedSegments(filePath, rootDir).some((segment) => ignored.has(segment));
17
+ }
18
+ function normalizeWatchError(error) {
19
+ if (error instanceof VibecodeError)
20
+ return error;
21
+ return new VibecodeError("INTERNAL_ERROR", errorMessage(error), { details: error });
22
+ }
23
+ /** Start a zero-dependency continuous verification watcher. */
24
+ export async function startWatch(options, deps = {}) {
25
+ if (typeof options.target !== "string" || !options.target.trim()) {
26
+ throw new VibecodeError("TARGET_MISSING", "A non-empty verification target is required");
27
+ }
28
+ const rootDir = resolveWorkspace(options.cwd ?? process.cwd()).rootDir;
29
+ const read = deps.readContract ?? readContract;
30
+ const verify = deps.verifyContract ?? defaultVerifyContract;
31
+ const writeLast = deps.writeLastReport ?? writeLastReport;
32
+ const write = deps.writeContract ?? writeContract;
33
+ const watcherFn = deps.fsWatch ??
34
+ ((filename, opts, listener) => fs.watch(filename, opts, listener));
35
+ let contract = read(rootDir);
36
+ const sliceIds = options.sliceIds ?? [];
37
+ let sliceInvariantIds = [];
38
+ if (sliceIds.length > 0) {
39
+ sliceInvariantIds = resolveSliceInvariants(contract, sliceIds).invariantIds;
40
+ }
41
+ const evaluationIds = [];
42
+ const seenEvaluationIds = new Set();
43
+ for (const id of [...(options.invariantIds ?? []), ...sliceInvariantIds]) {
44
+ if (!seenEvaluationIds.has(id)) {
45
+ seenEvaluationIds.add(id);
46
+ evaluationIds.push(id);
47
+ }
48
+ }
49
+ const updateSlices = options.updateSlices ?? Boolean(sliceIds.length > 0 || (contract.slices && contract.slices.length > 0));
50
+ const ignore = options.ignore ?? DEFAULT_IGNORE;
51
+ const debounceMs = options.debounceMs ?? 300;
52
+ const watchPaths = (options.watchPaths && options.watchPaths.length > 0 ? options.watchPaths : [rootDir]).map((entry) => path.resolve(rootDir, entry));
53
+ let doneResolve = () => { };
54
+ const done = new Promise((resolve) => {
55
+ doneResolve = resolve;
56
+ });
57
+ let finished = false;
58
+ const finish = () => {
59
+ if (finished)
60
+ return;
61
+ finished = true;
62
+ doneResolve();
63
+ };
64
+ const watchers = [];
65
+ let timer = null;
66
+ let running = false;
67
+ let pendingRun = false;
68
+ let pendingAllowEmpty = false;
69
+ const pendingFiles = new Set();
70
+ let closed = false;
71
+ let runIndex = 0;
72
+ let activeRun = null;
73
+ let previousStatuses = new Map();
74
+ const onAbort = () => {
75
+ void close();
76
+ };
77
+ const teardown = () => {
78
+ if (closed)
79
+ return;
80
+ closed = true;
81
+ if (timer) {
82
+ clearTimeout(timer);
83
+ timer = null;
84
+ }
85
+ for (const watcher of watchers) {
86
+ try {
87
+ watcher.close();
88
+ }
89
+ catch {
90
+ // A watcher that is already closed needs no further cleanup.
91
+ }
92
+ }
93
+ watchers.length = 0;
94
+ if (options.signal)
95
+ options.signal.removeEventListener("abort", onAbort);
96
+ };
97
+ const reportError = (error) => {
98
+ options.onError?.(normalizeWatchError(error));
99
+ };
100
+ const close = async () => {
101
+ teardown();
102
+ if (activeRun)
103
+ await activeRun.catch(() => { });
104
+ finish();
105
+ };
106
+ const scheduleRun = (reason, immediate = false) => {
107
+ if (closed)
108
+ return;
109
+ if (timer) {
110
+ clearTimeout(timer);
111
+ timer = null;
112
+ }
113
+ const launch = () => {
114
+ timer = null;
115
+ const changedFiles = [...pendingFiles];
116
+ const allowEmpty = pendingAllowEmpty;
117
+ pendingFiles.clear();
118
+ pendingAllowEmpty = false;
119
+ if (changedFiles.length > 0 || allowEmpty)
120
+ void launchRun(reason, changedFiles);
121
+ };
122
+ if (immediate || debounceMs <= 0) {
123
+ launch();
124
+ return;
125
+ }
126
+ timer = setTimeout(launch, debounceMs);
127
+ timer.unref?.();
128
+ };
129
+ const executeRun = async (reason, files) => {
130
+ if (closed)
131
+ return;
132
+ const started = Date.now();
133
+ running = true;
134
+ runIndex += 1;
135
+ try {
136
+ const ctx = {
137
+ target: options.target,
138
+ cwd: rootDir,
139
+ contract,
140
+ strict: options.strict === true,
141
+ ...(evaluationIds.length > 0 ? { invariantIds: evaluationIds } : {})
142
+ };
143
+ const report = await verify(contract, ctx, {});
144
+ if (closed)
145
+ return;
146
+ const newlyFixed = [];
147
+ const newlyBroken = [];
148
+ const fixedSet = new Set();
149
+ const brokenSet = new Set();
150
+ const nextStatuses = new Map();
151
+ for (const result of report.results || []) {
152
+ nextStatuses.set(result.id, result.status);
153
+ const previous = previousStatuses.get(result.id);
154
+ if (previous === undefined)
155
+ continue;
156
+ if (previous !== "pass" && result.status === "pass" && !fixedSet.has(result.id)) {
157
+ fixedSet.add(result.id);
158
+ newlyFixed.push(result.id);
159
+ }
160
+ else if (previous === "pass" && result.status !== "pass" && !brokenSet.has(result.id)) {
161
+ brokenSet.add(result.id);
162
+ newlyBroken.push(result.id);
163
+ }
164
+ }
165
+ previousStatuses = nextStatuses;
166
+ writeLast(report, rootDir);
167
+ let slices;
168
+ if (updateSlices) {
169
+ contract = updateSliceProgress(contract, report, { sliceIds, timestamp: report.timestamp });
170
+ write(contract, rootDir, { force: true });
171
+ slices = summarizeSlices(contract);
172
+ }
173
+ else if (contract.slices && contract.slices.length > 0) {
174
+ slices = summarizeSlices(contract);
175
+ }
176
+ const event = {
177
+ runIndex,
178
+ reason,
179
+ changedFiles: [...new Set(files)],
180
+ timestamp: report.timestamp || new Date().toISOString(),
181
+ durationMs: Date.now() - started,
182
+ report,
183
+ ...(slices ? { slices } : {}),
184
+ newlyFixed,
185
+ newlyBroken
186
+ };
187
+ options.onRun?.(event);
188
+ if (options.maxRuns !== undefined && runIndex >= options.maxRuns) {
189
+ teardown();
190
+ finish();
191
+ }
192
+ }
193
+ catch (error) {
194
+ reportError(normalizeWatchError(error));
195
+ }
196
+ finally {
197
+ running = false;
198
+ if (!closed && pendingRun) {
199
+ pendingRun = false;
200
+ scheduleRun("change");
201
+ }
202
+ }
203
+ };
204
+ const launchRun = (reason, files) => {
205
+ if (closed)
206
+ return;
207
+ const active = executeRun(reason, files);
208
+ activeRun = active;
209
+ void active.finally(() => {
210
+ if (activeRun === active)
211
+ activeRun = null;
212
+ });
213
+ };
214
+ const enqueue = (files, reason, allowEmpty) => {
215
+ if (closed)
216
+ return;
217
+ for (const file of files) {
218
+ if (!isIgnored(file, ignore, rootDir))
219
+ pendingFiles.add(file);
220
+ }
221
+ if (running) {
222
+ if (allowEmpty)
223
+ pendingAllowEmpty = true;
224
+ pendingRun = true;
225
+ return;
226
+ }
227
+ if (pendingFiles.size === 0 && !allowEmpty)
228
+ return;
229
+ if (allowEmpty)
230
+ pendingAllowEmpty = true;
231
+ scheduleRun(reason);
232
+ };
233
+ const trigger = (changedFiles = []) => {
234
+ enqueue(changedFiles, "manual", true);
235
+ };
236
+ try {
237
+ for (const watchPath of watchPaths) {
238
+ const listener = (_eventType, filename) => {
239
+ if (filename === null || filename === undefined)
240
+ return;
241
+ const raw = String(filename);
242
+ const absolute = path.isAbsolute(raw) ? raw : path.resolve(watchPath, raw);
243
+ enqueue([absolute], "change", false);
244
+ };
245
+ let watcher;
246
+ try {
247
+ watcher = watcherFn(watchPath, { recursive: true }, listener);
248
+ }
249
+ catch (error) {
250
+ const code = errorCode(error);
251
+ if (code !== "ERR_FEATURE_UNAVAILABLE_ON_PLATFORM" && code !== "EINVAL")
252
+ throw error;
253
+ watcher = watcherFn(watchPath, { recursive: false }, listener);
254
+ }
255
+ watchers.push(watcher);
256
+ }
257
+ }
258
+ catch (error) {
259
+ teardown();
260
+ finish();
261
+ throw error;
262
+ }
263
+ if (options.signal) {
264
+ if (options.signal.aborted) {
265
+ teardown();
266
+ finish();
267
+ }
268
+ else {
269
+ options.signal.addEventListener("abort", onAbort, { once: true });
270
+ }
271
+ }
272
+ if (!closed && options.runOnStart !== false) {
273
+ await executeRun("initial", []);
274
+ }
275
+ return { close, trigger, done, runCount: () => runIndex };
276
+ }
277
+ /** Concise one-line summary of a watch run, with follow-up details when relevant. */
278
+ export function formatWatchEvent(event) {
279
+ const fixed = event.newlyFixed.length > 0 ? event.newlyFixed.join(", ") : "none";
280
+ const broken = event.newlyBroken.length > 0 ? event.newlyBroken.join(", ") : "none";
281
+ const next = event.slices?.nextSlice ?? "none";
282
+ const files = event.changedFiles.length > 0 ? String(event.changedFiles.length) : "0";
283
+ const score = Number.isFinite(event.report.compositeScore) ? event.report.compositeScore.toFixed(3) : "0.000";
284
+ return `run #${event.runIndex} [${event.reason}] gate=${event.report.gate.status} score=${score} files=${files} newlyFixed=${fixed} newlyBroken=${broken} nextSlice=${next}`;
285
+ }
@@ -0,0 +1,5 @@
1
+ import type { IngestDeps, IngestOptions, IngestResult, RepoExportEntry } from "../core/types.js";
2
+ declare function scanExportsFromText(text: string): RepoExportEntry[];
3
+ export declare function ingestRepo(options?: IngestOptions, _deps?: IngestDeps): Promise<IngestResult>;
4
+ export { scanExportsFromText };
5
+ export declare function ingestApi(options?: IngestOptions, deps?: IngestDeps): Promise<IngestResult>;