vibecode-anything 0.0.0-stage → 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 (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +407 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +2519 -0
  5. package/dist/core/adapters.d.ts +31 -0
  6. package/dist/core/adapters.js +478 -0
  7. package/dist/core/agent-adapter.d.ts +67 -0
  8. package/dist/core/agent-adapter.js +312 -0
  9. package/dist/core/anti-cheat.d.ts +6 -0
  10. package/dist/core/anti-cheat.js +372 -0
  11. package/dist/core/badge.d.ts +18 -0
  12. package/dist/core/badge.js +360 -0
  13. package/dist/core/cache.d.ts +47 -0
  14. package/dist/core/cache.js +403 -0
  15. package/dist/core/ci-export.d.ts +35 -0
  16. package/dist/core/ci-export.js +796 -0
  17. package/dist/core/ci-formats.d.ts +21 -0
  18. package/dist/core/ci-formats.js +388 -0
  19. package/dist/core/client-codegen.d.ts +36 -0
  20. package/dist/core/client-codegen.js +2538 -0
  21. package/dist/core/compose.d.ts +71 -0
  22. package/dist/core/compose.js +1088 -0
  23. package/dist/core/diff.d.ts +10 -0
  24. package/dist/core/diff.js +207 -0
  25. package/dist/core/docs-export.d.ts +37 -0
  26. package/dist/core/docs-export.js +2706 -0
  27. package/dist/core/doctor.d.ts +70 -0
  28. package/dist/core/doctor.js +525 -0
  29. package/dist/core/errors.d.ts +32 -0
  30. package/dist/core/errors.js +81 -0
  31. package/dist/core/exec.d.ts +38 -0
  32. package/dist/core/exec.js +336 -0
  33. package/dist/core/fixtures.d.ts +153 -0
  34. package/dist/core/fixtures.js +2245 -0
  35. package/dist/core/format.d.ts +77 -0
  36. package/dist/core/format.js +632 -0
  37. package/dist/core/fs-snapshot.d.ts +37 -0
  38. package/dist/core/fs-snapshot.js +216 -0
  39. package/dist/core/graphql-export.d.ts +34 -0
  40. package/dist/core/graphql-export.js +2482 -0
  41. package/dist/core/har-export.d.ts +29 -0
  42. package/dist/core/har-export.js +988 -0
  43. package/dist/core/html-report.d.ts +27 -0
  44. package/dist/core/html-report.js +1535 -0
  45. package/dist/core/http-export.d.ts +31 -0
  46. package/dist/core/http-export.js +726 -0
  47. package/dist/core/impact.d.ts +80 -0
  48. package/dist/core/impact.js +1412 -0
  49. package/dist/core/lint.d.ts +38 -0
  50. package/dist/core/lint.js +1111 -0
  51. package/dist/core/load-export.d.ts +37 -0
  52. package/dist/core/load-export.js +1813 -0
  53. package/dist/core/mcp-export.d.ts +35 -0
  54. package/dist/core/mcp-export.js +1736 -0
  55. package/dist/core/mock-server.d.ts +47 -0
  56. package/dist/core/mock-server.js +1722 -0
  57. package/dist/core/openapi-export.d.ts +44 -0
  58. package/dist/core/openapi-export.js +1074 -0
  59. package/dist/core/parity.d.ts +14 -0
  60. package/dist/core/parity.js +173 -0
  61. package/dist/core/playwright-exporter.d.ts +23 -0
  62. package/dist/core/playwright-exporter.js +1343 -0
  63. package/dist/core/png.d.ts +7 -0
  64. package/dist/core/png.js +339 -0
  65. package/dist/core/regression.d.ts +54 -0
  66. package/dist/core/regression.js +529 -0
  67. package/dist/core/responsive.d.ts +86 -0
  68. package/dist/core/responsive.js +606 -0
  69. package/dist/core/run.d.ts +74 -0
  70. package/dist/core/run.js +696 -0
  71. package/dist/core/scheduler.d.ts +24 -0
  72. package/dist/core/scheduler.js +162 -0
  73. package/dist/core/schema-export.d.ts +29 -0
  74. package/dist/core/schema-export.js +2215 -0
  75. package/dist/core/schema.d.ts +18 -0
  76. package/dist/core/schema.js +1057 -0
  77. package/dist/core/security.d.ts +233 -0
  78. package/dist/core/security.js +1839 -0
  79. package/dist/core/server-export.d.ts +38 -0
  80. package/dist/core/server-export.js +3198 -0
  81. package/dist/core/slices.d.ts +24 -0
  82. package/dist/core/slices.js +294 -0
  83. package/dist/core/spec-writer.d.ts +9 -0
  84. package/dist/core/spec-writer.js +1202 -0
  85. package/dist/core/store.d.ts +26 -0
  86. package/dist/core/store.js +217 -0
  87. package/dist/core/target-map.d.ts +34 -0
  88. package/dist/core/target-map.js +262 -0
  89. package/dist/core/test-exporter.d.ts +25 -0
  90. package/dist/core/test-exporter.js +1918 -0
  91. package/dist/core/types.d.ts +919 -0
  92. package/dist/core/types.js +4 -0
  93. package/dist/core/visual-semantic.d.ts +67 -0
  94. package/dist/core/visual-semantic.js +673 -0
  95. package/dist/core/visual.d.ts +34 -0
  96. package/dist/core/visual.js +508 -0
  97. package/dist/core/watch.d.ts +78 -0
  98. package/dist/core/watch.js +495 -0
  99. package/dist/core/yaml.d.ts +5 -0
  100. package/dist/core/yaml.js +1009 -0
  101. package/dist/diagnostics/diagnose.d.ts +53 -0
  102. package/dist/diagnostics/diagnose.js +1083 -0
  103. package/dist/diagnostics/flake.d.ts +71 -0
  104. package/dist/diagnostics/flake.js +608 -0
  105. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  106. package/dist/diagnostics/mutation-audit.js +769 -0
  107. package/dist/diagnostics/spatial.d.ts +42 -0
  108. package/dist/diagnostics/spatial.js +346 -0
  109. package/dist/diagnostics/trends.d.ts +122 -0
  110. package/dist/diagnostics/trends.js +1190 -0
  111. package/dist/discovery/discover.d.ts +111 -0
  112. package/dist/discovery/discover.js +2017 -0
  113. package/dist/discovery/lock.d.ts +116 -0
  114. package/dist/discovery/lock.js +1505 -0
  115. package/dist/discovery/routes.d.ts +36 -0
  116. package/dist/discovery/routes.js +1494 -0
  117. package/dist/discovery/test-importer.d.ts +92 -0
  118. package/dist/discovery/test-importer.js +4952 -0
  119. package/dist/index.d.ts +123 -0
  120. package/dist/index.js +99 -0
  121. package/dist/ingestors/api-collections.d.ts +28 -0
  122. package/dist/ingestors/api-collections.js +2335 -0
  123. package/dist/ingestors/api-repo.d.ts +6 -0
  124. package/dist/ingestors/api-repo.js +1120 -0
  125. package/dist/ingestors/asyncapi.d.ts +26 -0
  126. package/dist/ingestors/asyncapi.js +2105 -0
  127. package/dist/ingestors/bridges.d.ts +5 -0
  128. package/dist/ingestors/bridges.js +1264 -0
  129. package/dist/ingestors/cli.d.ts +10 -0
  130. package/dist/ingestors/cli.js +454 -0
  131. package/dist/ingestors/curl.d.ts +14 -0
  132. package/dist/ingestors/curl.js +1024 -0
  133. package/dist/ingestors/graphql.d.ts +56 -0
  134. package/dist/ingestors/graphql.js +1852 -0
  135. package/dist/ingestors/http-file.d.ts +20 -0
  136. package/dist/ingestors/http-file.js +923 -0
  137. package/dist/ingestors/image.d.ts +2 -0
  138. package/dist/ingestors/image.js +147 -0
  139. package/dist/ingestors/index.d.ts +5 -0
  140. package/dist/ingestors/index.js +577 -0
  141. package/dist/ingestors/openrpc.d.ts +29 -0
  142. package/dist/ingestors/openrpc.js +1807 -0
  143. package/dist/ingestors/proto.d.ts +47 -0
  144. package/dist/ingestors/proto.js +2690 -0
  145. package/dist/ingestors/trace.d.ts +10 -0
  146. package/dist/ingestors/trace.js +599 -0
  147. package/dist/ingestors/video.d.ts +50 -0
  148. package/dist/ingestors/video.js +655 -0
  149. package/dist/ingestors/web.d.ts +40 -0
  150. package/dist/ingestors/web.js +839 -0
  151. package/dist/mcp/server.d.ts +2 -0
  152. package/dist/mcp/server.js +3969 -0
  153. package/dist/oracles/api-repo.d.ts +2 -0
  154. package/dist/oracles/api-repo.js +286 -0
  155. package/dist/oracles/cli.d.ts +2 -0
  156. package/dist/oracles/cli.js +205 -0
  157. package/dist/oracles/http-workflow.d.ts +68 -0
  158. package/dist/oracles/http-workflow.js +828 -0
  159. package/dist/oracles/image.d.ts +2 -0
  160. package/dist/oracles/image.js +429 -0
  161. package/dist/oracles/index.d.ts +6 -0
  162. package/dist/oracles/index.js +320 -0
  163. package/dist/oracles/perf-budget.d.ts +90 -0
  164. package/dist/oracles/perf-budget.js +1329 -0
  165. package/dist/oracles/stream.d.ts +94 -0
  166. package/dist/oracles/stream.js +1268 -0
  167. package/dist/oracles/ui-states.d.ts +49 -0
  168. package/dist/oracles/ui-states.js +894 -0
  169. package/dist/oracles/video.d.ts +21 -0
  170. package/dist/oracles/video.js +627 -0
  171. package/dist/oracles/web.d.ts +2 -0
  172. package/dist/oracles/web.js +871 -0
  173. package/dist/plugins/builtins.d.ts +12 -0
  174. package/dist/plugins/builtins.js +1052 -0
  175. package/dist/plugins/registry.d.ts +86 -0
  176. package/dist/plugins/registry.js +554 -0
  177. package/dist/setup/index.d.ts +7 -0
  178. package/dist/setup/index.js +298 -0
  179. package/package.json +54 -4
  180. package/skills/vibecode-anything/SKILL.md +75 -0
@@ -0,0 +1,577 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { VibecodeError } from "../core/errors.js";
4
+ import { ingest as ingestCli } from "./cli.js";
5
+ import { isPostmanCollectionDoc } from "./bridges.js";
6
+ import { isCurlCommandText } from "./curl.js";
7
+ import { isGraphqlIntrospectionDoc, isGraphqlSchemaText } from "./graphql.js";
8
+ import { isHttpFileText } from "./http-file.js";
9
+ import { isBrunoCollectionDir, isBrunoFileText, isInsomniaExportDoc } from "./api-collections.js";
10
+ import { isAsyncApiDoc, isAsyncApiText } from "./asyncapi.js";
11
+ import { isOpenRpcDoc, isOpenRpcText } from "./openrpc.js";
12
+ import { isProtoSchemaText } from "./proto.js";
13
+ const INGESTORS = {
14
+ cli: ingestCli,
15
+ script: ingestCli
16
+ };
17
+ const IMAGE_EXTS_EXT = new Set([".png", ".jpg", ".jpeg", ".webp"]);
18
+ const VIDEO_EXTS_EXT = new Set([".mp4", ".mov", ".webm", ".mkv", ".gif", ".avi", ".m4v"]);
19
+ // Sidecar files that legitimately accompany an ordered keyframe directory.
20
+ const FRAMES_SIDECAR_EXTS = new Set([".srt", ".vtt"]);
21
+ const OPENAPI_YAML_HEAD_BYTES = 65_536;
22
+ const OPENAPI_YAML_HEADER_RE = /^\s*(?:openapi|swagger)\s*:/m;
23
+ const OPENAPI_YAML_PATHS_RE = /^\s*paths\s*:/m;
24
+ const INSOMNIA_YAML_TYPE_RE = /^\s*_type\s*:\s*['"]?export['"]?\s*$/m;
25
+ const INSOMNIA_YAML_FORMAT_RE = /^\s*__export_format\s*:\s*4\b/m;
26
+ function stripBomText(text) {
27
+ return text.startsWith("\uFEFF") ? text.slice(1) : text;
28
+ }
29
+ function readFileHeadUtf8(filePath, maxBytes) {
30
+ const fd = fs.openSync(filePath, "r");
31
+ try {
32
+ const buf = Buffer.allocUnsafe(maxBytes);
33
+ const bytesRead = fs.readSync(fd, buf, 0, maxBytes, 0);
34
+ return buf.subarray(0, bytesRead).toString("utf8");
35
+ }
36
+ finally {
37
+ fs.closeSync(fd);
38
+ }
39
+ }
40
+ // Lazy-loaded registries for milestone modules (M2-M4/M3 bridges).
41
+ const LAZY = {
42
+ image: async () => (await import("./image.js")).ingest,
43
+ web: async () => (await import("./web.js")).ingest,
44
+ url: async () => (await import("./web.js")).ingest,
45
+ api: async () => (await import("./api-repo.js")).ingestApi,
46
+ repo: async () => (await import("./api-repo.js")).ingestRepo,
47
+ video: async () => (await import("./video.js")).ingest,
48
+ rea: async () => {
49
+ const mod = await import("./bridges.js");
50
+ return (options = {}) => mod.importRea(options.source || "", options);
51
+ },
52
+ "cli-anything": async () => {
53
+ const mod = await import("./bridges.js");
54
+ return (options = {}) => mod.importCliAnything(options.source || "", options);
55
+ },
56
+ postman: async () => {
57
+ const mod = await import("./bridges.js");
58
+ return (options = {}) => mod.importPostmanCollection(options.source || "", options);
59
+ },
60
+ curl: async () => (await import("./curl.js")).ingestCurl,
61
+ graphql: async () => (await import("./graphql.js")).ingestGraphql,
62
+ "http-file": async () => (await import("./http-file.js")).ingestHttpFile,
63
+ insomnia: async () => {
64
+ const mod = await import("./api-collections.js");
65
+ return (options = {}, deps = {}) => mod.importInsomniaExport(options.source || "", options, deps);
66
+ },
67
+ bruno: async () => {
68
+ const mod = await import("./api-collections.js");
69
+ return (options = {}, deps = {}) => mod.ingestBrunoCollection(options.source || "", options, deps);
70
+ },
71
+ asyncapi: async () => (await import("./asyncapi.js")).ingestAsyncApi,
72
+ openrpc: async () => (await import("./openrpc.js")).ingestOpenRpc,
73
+ proto: async () => (await import("./proto.js")).ingestProto
74
+ };
75
+ export function listDomains() {
76
+ return [...new Set([...Object.keys(INGESTORS), ...Object.keys(LAZY)])];
77
+ }
78
+ export function detectDomain(source) {
79
+ if (typeof source !== "string")
80
+ return "cli";
81
+ const s = source.trim();
82
+ if (/^https?:\/\//i.test(s))
83
+ return "web";
84
+ if (fs.existsSync(s)) {
85
+ const st = fs.statSync(s);
86
+ if (st.isDirectory()) {
87
+ // A directory of ordered keyframes (plus optional .srt/.vtt sidecars) is a video
88
+ // reference; anything else is a repo.
89
+ try {
90
+ const entries = fs
91
+ .readdirSync(s)
92
+ .filter((f) => !f.startsWith(".") && !FRAMES_SIDECAR_EXTS.has(path.extname(f).toLowerCase()));
93
+ const images = entries.filter((f) => IMAGE_EXTS_EXT.has(path.extname(f).toLowerCase()));
94
+ if (images.length > 0 && images.length === entries.length)
95
+ return "video";
96
+ }
97
+ catch {
98
+ // fall through to bruno / repo
99
+ }
100
+ if (isBrunoCollectionDir(s))
101
+ return "api";
102
+ return "repo";
103
+ }
104
+ const ext = path.extname(s).toLowerCase();
105
+ if ([".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp"].includes(ext))
106
+ return "image";
107
+ if (VIDEO_EXTS_EXT.has(ext))
108
+ return "video";
109
+ if (ext === ".har")
110
+ return "api";
111
+ if (ext === ".curl")
112
+ return "api";
113
+ if (ext === ".bru")
114
+ return "api";
115
+ if (ext === ".http" || ext === ".rest")
116
+ return "api";
117
+ if (ext === ".graphql" || ext === ".gql")
118
+ return "api";
119
+ if (ext === ".proto")
120
+ return "api";
121
+ if (ext === ".sh" || ext === ".txt") {
122
+ try {
123
+ const head = readFileHeadUtf8(s, OPENAPI_YAML_HEAD_BYTES);
124
+ if (isCurlCommandText(head))
125
+ return "api";
126
+ if (isHttpFileText(head))
127
+ return "api";
128
+ if (isGraphqlSchemaText(head))
129
+ return "api";
130
+ if (isBrunoFileText(head))
131
+ return "api";
132
+ if (isProtoSchemaText(head))
133
+ return "api";
134
+ }
135
+ catch {
136
+ // fall through
137
+ }
138
+ }
139
+ if (ext === ".yaml" || ext === ".yml") {
140
+ try {
141
+ const head = stripBomText(readFileHeadUtf8(s, OPENAPI_YAML_HEAD_BYTES));
142
+ if (isOpenRpcText(head))
143
+ return "api";
144
+ if (isAsyncApiText(head))
145
+ return "api";
146
+ if (OPENAPI_YAML_HEADER_RE.test(head) && OPENAPI_YAML_PATHS_RE.test(head))
147
+ return "api";
148
+ if (INSOMNIA_YAML_TYPE_RE.test(head) && INSOMNIA_YAML_FORMAT_RE.test(head))
149
+ return "api";
150
+ }
151
+ catch {
152
+ // fall through
153
+ }
154
+ }
155
+ if (ext === ".json") {
156
+ try {
157
+ const doc = JSON.parse(stripBomText(fs.readFileSync(s, "utf8")));
158
+ if (doc && typeof doc === "object" && !Array.isArray(doc)) {
159
+ const rec = doc;
160
+ if (isOpenRpcDoc(doc))
161
+ return "api";
162
+ if (isAsyncApiDoc(doc))
163
+ return "api";
164
+ if ((rec.openapi || rec.swagger) && rec.paths)
165
+ return "api";
166
+ if (isPostmanCollectionDoc(doc))
167
+ return "api";
168
+ if (isInsomniaExportDoc(doc))
169
+ return "api";
170
+ if (isGraphqlIntrospectionDoc(doc))
171
+ return "api";
172
+ }
173
+ }
174
+ catch {
175
+ // fall through
176
+ }
177
+ }
178
+ }
179
+ if (isCurlCommandText(s))
180
+ return "api";
181
+ if (isHttpFileText(s))
182
+ return "api";
183
+ if (isBrunoFileText(s))
184
+ return "api";
185
+ if (isGraphqlSchemaText(s))
186
+ return "api";
187
+ if (isOpenRpcText(s))
188
+ return "api";
189
+ if (isAsyncApiText(s))
190
+ return "api";
191
+ if (isProtoSchemaText(s))
192
+ return "api";
193
+ if (s.startsWith("{")) {
194
+ try {
195
+ const parsed = JSON.parse(s);
196
+ if (isOpenRpcDoc(parsed))
197
+ return "api";
198
+ if (isAsyncApiDoc(parsed))
199
+ return "api";
200
+ if (isInsomniaExportDoc(parsed))
201
+ return "api";
202
+ }
203
+ catch {
204
+ // ignore
205
+ }
206
+ }
207
+ else if (INSOMNIA_YAML_TYPE_RE.test(s) && INSOMNIA_YAML_FORMAT_RE.test(s)) {
208
+ return "api";
209
+ }
210
+ return "cli";
211
+ }
212
+ export async function getIngestor(domain) {
213
+ if (INGESTORS[domain])
214
+ return INGESTORS[domain];
215
+ if (LAZY[domain]) {
216
+ return LAZY[domain]();
217
+ }
218
+ throw new VibecodeError("UNSUPPORTED_FORMAT", `Unknown ingest domain: ${domain}`);
219
+ }
220
+ export async function ingest(options = {}, deps = {}) {
221
+ const hasFromCommands = typeof options.fromCommands === "string" && options.fromCommands.trim().length > 0;
222
+ const hasFromHar = typeof options.fromHar === "string" && options.fromHar.trim().length > 0;
223
+ if (hasFromCommands && hasFromHar) {
224
+ throw new VibecodeError("CONTRACT_INVALID", "Cannot combine --from-commands and --from-har in a single ingest.");
225
+ }
226
+ let domain;
227
+ let result;
228
+ const resolvedSourceHar = !hasFromHar &&
229
+ !hasFromCommands &&
230
+ typeof options.source === "string" &&
231
+ options.source.trim().length > 0 &&
232
+ (!options.domain || options.domain === "api")
233
+ ? (() => {
234
+ const candidate = path.resolve(options.cwd || process.cwd(), options.source.trim());
235
+ if (path.extname(candidate).toLowerCase() !== ".har")
236
+ return null;
237
+ try {
238
+ return fs.existsSync(candidate) && fs.statSync(candidate).isFile() ? candidate : null;
239
+ }
240
+ catch {
241
+ return null;
242
+ }
243
+ })()
244
+ : null;
245
+ if (hasFromCommands) {
246
+ domain = "cli";
247
+ const { ingestFromCommands } = await import("./trace.js");
248
+ result = await ingestFromCommands(options, deps);
249
+ }
250
+ else if (hasFromHar) {
251
+ domain = "api";
252
+ const { ingestFromHar } = await import("./trace.js");
253
+ result = await ingestFromHar(options, deps);
254
+ }
255
+ else if (resolvedSourceHar) {
256
+ domain = "api";
257
+ const { ingestFromHar } = await import("./trace.js");
258
+ result = await ingestFromHar({ ...options, fromHar: resolvedSourceHar }, deps);
259
+ }
260
+ else {
261
+ let postmanSource = null;
262
+ let insomniaSource = null;
263
+ let asyncapiSource = null;
264
+ let openrpcSource = null;
265
+ if (typeof options.source === "string" &&
266
+ options.source.trim().length > 0 &&
267
+ (!options.domain || options.domain === "api")) {
268
+ const trimmed = options.source.trim();
269
+ const hasNewline = /[\r\n]/.test(trimmed);
270
+ if (trimmed.startsWith("{")) {
271
+ try {
272
+ const parsed = JSON.parse(stripBomText(trimmed));
273
+ if (isOpenRpcDoc(parsed)) {
274
+ openrpcSource = trimmed;
275
+ }
276
+ else if (isAsyncApiDoc(parsed)) {
277
+ asyncapiSource = trimmed;
278
+ }
279
+ else if (isPostmanCollectionDoc(parsed)) {
280
+ postmanSource = trimmed;
281
+ }
282
+ else if (isInsomniaExportDoc(parsed)) {
283
+ insomniaSource = trimmed;
284
+ }
285
+ }
286
+ catch {
287
+ // fall through
288
+ }
289
+ }
290
+ else if (!hasNewline) {
291
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
292
+ const ext = path.extname(candidate).toLowerCase();
293
+ if (ext === ".json") {
294
+ try {
295
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
296
+ const parsed = JSON.parse(stripBomText(fs.readFileSync(candidate, "utf8")));
297
+ if (isOpenRpcDoc(parsed)) {
298
+ openrpcSource = candidate;
299
+ }
300
+ else if (isAsyncApiDoc(parsed)) {
301
+ asyncapiSource = candidate;
302
+ }
303
+ else if (isPostmanCollectionDoc(parsed)) {
304
+ postmanSource = candidate;
305
+ }
306
+ else if (isInsomniaExportDoc(parsed)) {
307
+ insomniaSource = candidate;
308
+ }
309
+ }
310
+ }
311
+ catch {
312
+ // ignore malformed JSON here and let downstream ingestor report structured error
313
+ }
314
+ }
315
+ else if (ext === ".yaml" || ext === ".yml") {
316
+ try {
317
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
318
+ const head = stripBomText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES));
319
+ if (isOpenRpcText(head)) {
320
+ openrpcSource = candidate;
321
+ }
322
+ else if (isAsyncApiText(head)) {
323
+ asyncapiSource = candidate;
324
+ }
325
+ else if (INSOMNIA_YAML_TYPE_RE.test(head) && INSOMNIA_YAML_FORMAT_RE.test(head)) {
326
+ insomniaSource = candidate;
327
+ }
328
+ }
329
+ }
330
+ catch {
331
+ // ignore read errors here
332
+ }
333
+ }
334
+ }
335
+ else if (isOpenRpcText(trimmed)) {
336
+ openrpcSource = trimmed;
337
+ }
338
+ else if (isAsyncApiText(trimmed)) {
339
+ asyncapiSource = trimmed;
340
+ }
341
+ else if (INSOMNIA_YAML_TYPE_RE.test(trimmed) && INSOMNIA_YAML_FORMAT_RE.test(trimmed)) {
342
+ insomniaSource = trimmed;
343
+ }
344
+ }
345
+ if (openrpcSource) {
346
+ domain = "api";
347
+ const { ingestOpenRpc } = await import("./openrpc.js");
348
+ result = await ingestOpenRpc(options, deps);
349
+ }
350
+ else if (asyncapiSource) {
351
+ domain = "api";
352
+ const { ingestAsyncApi } = await import("./asyncapi.js");
353
+ result = await ingestAsyncApi(options, deps);
354
+ }
355
+ else if (postmanSource) {
356
+ domain = "api";
357
+ const { importPostmanCollection } = await import("./bridges.js");
358
+ result = await importPostmanCollection(postmanSource, options);
359
+ }
360
+ else if (insomniaSource) {
361
+ domain = "api";
362
+ const { importInsomniaExport } = await import("./api-collections.js");
363
+ result = await importInsomniaExport(insomniaSource, options, deps);
364
+ }
365
+ else {
366
+ let routeCurl = false;
367
+ if (typeof options.source === "string" &&
368
+ options.source.trim().length > 0 &&
369
+ (!options.domain || options.domain === "api")) {
370
+ const trimmed = options.source.trim();
371
+ if (isCurlCommandText(trimmed)) {
372
+ routeCurl = true;
373
+ }
374
+ else if (!/[\r\n]/.test(trimmed)) {
375
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
376
+ const ext = path.extname(candidate).toLowerCase();
377
+ if (ext === ".curl" || ext === ".sh" || ext === ".txt") {
378
+ try {
379
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
380
+ if (ext === ".curl" || isCurlCommandText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES))) {
381
+ routeCurl = true;
382
+ }
383
+ }
384
+ }
385
+ catch {
386
+ // fall through
387
+ }
388
+ }
389
+ }
390
+ }
391
+ if (routeCurl) {
392
+ domain = "api";
393
+ const { ingestCurl } = await import("./curl.js");
394
+ result = await ingestCurl(options, deps);
395
+ }
396
+ else {
397
+ let routeGraphql = false;
398
+ if (typeof options.source === "string" &&
399
+ options.source.trim().length > 0 &&
400
+ (!options.domain || options.domain === "api")) {
401
+ const trimmed = options.source.trim();
402
+ if (isGraphqlSchemaText(trimmed)) {
403
+ routeGraphql = true;
404
+ }
405
+ else if (!/[\r\n]/.test(trimmed)) {
406
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
407
+ const ext = path.extname(candidate).toLowerCase();
408
+ if (ext === ".graphql" || ext === ".gql") {
409
+ routeGraphql = true;
410
+ }
411
+ else if (ext === ".json") {
412
+ try {
413
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
414
+ const parsed = JSON.parse(fs.readFileSync(candidate, "utf8"));
415
+ if (isGraphqlIntrospectionDoc(parsed)) {
416
+ routeGraphql = true;
417
+ }
418
+ }
419
+ }
420
+ catch {
421
+ // fall through
422
+ }
423
+ }
424
+ else if (ext === ".txt") {
425
+ try {
426
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
427
+ if (isGraphqlSchemaText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES))) {
428
+ routeGraphql = true;
429
+ }
430
+ }
431
+ }
432
+ catch {
433
+ // fall through
434
+ }
435
+ }
436
+ }
437
+ else if (trimmed.startsWith("{")) {
438
+ try {
439
+ const parsed = JSON.parse(trimmed);
440
+ if (isGraphqlIntrospectionDoc(parsed)) {
441
+ routeGraphql = true;
442
+ }
443
+ }
444
+ catch {
445
+ // fall through
446
+ }
447
+ }
448
+ }
449
+ if (routeGraphql) {
450
+ domain = "api";
451
+ const { ingestGraphql } = await import("./graphql.js");
452
+ result = await ingestGraphql(options, deps);
453
+ }
454
+ else {
455
+ let routeHttpFile = false;
456
+ if (typeof options.source === "string" &&
457
+ options.source.trim().length > 0 &&
458
+ (!options.domain || options.domain === "api")) {
459
+ const trimmed = options.source.trim();
460
+ if (isHttpFileText(trimmed)) {
461
+ routeHttpFile = true;
462
+ }
463
+ else if (!/[\r\n]/.test(trimmed)) {
464
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
465
+ const ext = path.extname(candidate).toLowerCase();
466
+ if (ext === ".http" || ext === ".rest") {
467
+ routeHttpFile = true;
468
+ }
469
+ else if (ext === ".txt") {
470
+ try {
471
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
472
+ if (isHttpFileText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES))) {
473
+ routeHttpFile = true;
474
+ }
475
+ }
476
+ }
477
+ catch {
478
+ // fall through
479
+ }
480
+ }
481
+ }
482
+ }
483
+ if (routeHttpFile) {
484
+ domain = "api";
485
+ const { ingestHttpFile } = await import("./http-file.js");
486
+ result = await ingestHttpFile(options, deps);
487
+ }
488
+ else {
489
+ let routeBruno = false;
490
+ if (typeof options.source === "string" &&
491
+ options.source.trim().length > 0 &&
492
+ (!options.domain || options.domain === "api")) {
493
+ const trimmed = options.source.trim();
494
+ if (isBrunoFileText(trimmed)) {
495
+ routeBruno = true;
496
+ }
497
+ else if (!/[\r\n]/.test(trimmed)) {
498
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
499
+ const ext = path.extname(candidate).toLowerCase();
500
+ if (ext === ".bru") {
501
+ routeBruno = true;
502
+ }
503
+ else if (isBrunoCollectionDir(candidate)) {
504
+ routeBruno = true;
505
+ }
506
+ else if (ext === ".txt") {
507
+ try {
508
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
509
+ if (isBrunoFileText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES))) {
510
+ routeBruno = true;
511
+ }
512
+ }
513
+ }
514
+ catch {
515
+ // fall through
516
+ }
517
+ }
518
+ }
519
+ }
520
+ if (routeBruno) {
521
+ domain = "api";
522
+ const { ingestBrunoCollection } = await import("./api-collections.js");
523
+ result = await ingestBrunoCollection(options.source || "", options, deps);
524
+ }
525
+ else {
526
+ let routeProto = false;
527
+ if (typeof options.source === "string" &&
528
+ options.source.trim().length > 0 &&
529
+ (!options.domain || options.domain === "api")) {
530
+ const trimmed = options.source.trim();
531
+ if (isProtoSchemaText(trimmed)) {
532
+ routeProto = true;
533
+ }
534
+ else if (!/[\r\n]/.test(trimmed)) {
535
+ const candidate = path.resolve(options.cwd || process.cwd(), trimmed);
536
+ const ext = path.extname(candidate).toLowerCase();
537
+ if (ext === ".proto") {
538
+ routeProto = true;
539
+ }
540
+ else if (ext === ".txt") {
541
+ try {
542
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
543
+ if (isProtoSchemaText(readFileHeadUtf8(candidate, OPENAPI_YAML_HEAD_BYTES))) {
544
+ routeProto = true;
545
+ }
546
+ }
547
+ }
548
+ catch {
549
+ // fall through
550
+ }
551
+ }
552
+ }
553
+ }
554
+ if (routeProto) {
555
+ domain = "api";
556
+ const { ingestProto } = await import("./proto.js");
557
+ result = await ingestProto(options, deps);
558
+ }
559
+ else {
560
+ domain = options.domain || detectDomain(options.source);
561
+ const fn = await getIngestor(domain);
562
+ result = await fn(options, deps);
563
+ }
564
+ }
565
+ }
566
+ }
567
+ }
568
+ }
569
+ }
570
+ return {
571
+ domain: result.domain || domain,
572
+ sources: result.sources || [],
573
+ artifacts: result.artifacts || { root: ".vibecode/artifacts", files: {} },
574
+ invariants: result.invariants || [],
575
+ warnings: result.warnings || []
576
+ };
577
+ }
@@ -0,0 +1,29 @@
1
+ import type { IngestDeps, IngestOptions, IngestResult, JsonSchema } from "../core/types.js";
2
+ export interface ParsedOpenRpcParam {
3
+ name: string;
4
+ required: boolean;
5
+ schema?: JsonSchema;
6
+ description?: string;
7
+ }
8
+ export interface ParsedOpenRpcMethod {
9
+ id: string;
10
+ name: string;
11
+ summary?: string;
12
+ paramStructure: "either" | "by-name" | "by-position";
13
+ params: ParsedOpenRpcParam[];
14
+ sampleParams: unknown;
15
+ resultSchema?: JsonSchema;
16
+ errorCodes: number[];
17
+ }
18
+ export interface ParsedOpenRpcSpec {
19
+ openrpc: string;
20
+ title: string;
21
+ baseUrl?: string;
22
+ endpointPath: string;
23
+ methods: ParsedOpenRpcMethod[];
24
+ warnings: string[];
25
+ }
26
+ export declare function isOpenRpcDoc(value: unknown): boolean;
27
+ export declare function isOpenRpcText(rawText: string): boolean;
28
+ export declare function parseOpenRpcSpec(rawText: string): ParsedOpenRpcSpec;
29
+ export declare function ingestOpenRpc(options?: IngestOptions, _deps?: IngestDeps): Promise<IngestResult>;