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.
Files changed (160) hide show
  1. package/README.md +239 -67
  2. package/dist/cli.js +2140 -73
  3. package/dist/core/adapters.d.ts +26 -3
  4. package/dist/core/adapters.js +411 -25
  5. package/dist/core/agent-adapter.d.ts +67 -0
  6. package/dist/core/agent-adapter.js +312 -0
  7. package/dist/core/anti-cheat.d.ts +6 -0
  8. package/dist/core/anti-cheat.js +372 -0
  9. package/dist/core/badge.d.ts +18 -0
  10. package/dist/core/badge.js +360 -0
  11. package/dist/core/cache.d.ts +47 -0
  12. package/dist/core/cache.js +403 -0
  13. package/dist/core/ci-export.d.ts +35 -0
  14. package/dist/core/ci-export.js +796 -0
  15. package/dist/core/ci-formats.d.ts +21 -0
  16. package/dist/core/ci-formats.js +388 -0
  17. package/dist/core/client-codegen.d.ts +36 -0
  18. package/dist/core/client-codegen.js +2538 -0
  19. package/dist/core/compose.d.ts +71 -0
  20. package/dist/core/compose.js +1088 -0
  21. package/dist/core/docs-export.d.ts +37 -0
  22. package/dist/core/docs-export.js +2706 -0
  23. package/dist/core/doctor.d.ts +21 -1
  24. package/dist/core/doctor.js +234 -21
  25. package/dist/core/exec.d.ts +26 -2
  26. package/dist/core/exec.js +235 -8
  27. package/dist/core/fixtures.d.ts +153 -0
  28. package/dist/core/fixtures.js +2245 -0
  29. package/dist/core/format.d.ts +77 -0
  30. package/dist/core/format.js +632 -0
  31. package/dist/core/fs-snapshot.d.ts +37 -0
  32. package/dist/core/fs-snapshot.js +216 -0
  33. package/dist/core/graphql-export.d.ts +34 -0
  34. package/dist/core/graphql-export.js +2482 -0
  35. package/dist/core/har-export.d.ts +29 -0
  36. package/dist/core/har-export.js +988 -0
  37. package/dist/core/html-report.d.ts +27 -0
  38. package/dist/core/html-report.js +1535 -0
  39. package/dist/core/http-export.d.ts +31 -0
  40. package/dist/core/http-export.js +726 -0
  41. package/dist/core/impact.d.ts +80 -0
  42. package/dist/core/impact.js +1412 -0
  43. package/dist/core/lint.d.ts +38 -0
  44. package/dist/core/lint.js +1111 -0
  45. package/dist/core/load-export.d.ts +37 -0
  46. package/dist/core/load-export.js +1813 -0
  47. package/dist/core/mcp-export.d.ts +35 -0
  48. package/dist/core/mcp-export.js +1736 -0
  49. package/dist/core/mock-server.d.ts +47 -0
  50. package/dist/core/mock-server.js +1722 -0
  51. package/dist/core/openapi-export.d.ts +44 -0
  52. package/dist/core/openapi-export.js +1074 -0
  53. package/dist/core/parity.d.ts +6 -1
  54. package/dist/core/parity.js +36 -1
  55. package/dist/core/playwright-exporter.d.ts +23 -0
  56. package/dist/core/playwright-exporter.js +1343 -0
  57. package/dist/core/png.js +45 -9
  58. package/dist/core/regression.d.ts +54 -0
  59. package/dist/core/regression.js +529 -0
  60. package/dist/core/responsive.d.ts +86 -0
  61. package/dist/core/responsive.js +606 -0
  62. package/dist/core/run.d.ts +74 -0
  63. package/dist/core/run.js +696 -0
  64. package/dist/core/scheduler.d.ts +24 -0
  65. package/dist/core/scheduler.js +162 -0
  66. package/dist/core/schema-export.d.ts +29 -0
  67. package/dist/core/schema-export.js +2215 -0
  68. package/dist/core/schema.d.ts +3 -2
  69. package/dist/core/schema.js +460 -17
  70. package/dist/core/security.d.ts +233 -0
  71. package/dist/core/security.js +1839 -0
  72. package/dist/core/server-export.d.ts +38 -0
  73. package/dist/core/server-export.js +3198 -0
  74. package/dist/core/spec-writer.d.ts +9 -0
  75. package/dist/core/spec-writer.js +1202 -0
  76. package/dist/core/store.d.ts +11 -2
  77. package/dist/core/store.js +128 -8
  78. package/dist/core/target-map.d.ts +34 -0
  79. package/dist/core/target-map.js +262 -0
  80. package/dist/core/test-exporter.d.ts +25 -0
  81. package/dist/core/test-exporter.js +1918 -0
  82. package/dist/core/types.d.ts +182 -14
  83. package/dist/core/visual-semantic.d.ts +67 -0
  84. package/dist/core/visual-semantic.js +673 -0
  85. package/dist/core/visual.js +65 -16
  86. package/dist/core/watch.d.ts +28 -3
  87. package/dist/core/watch.js +222 -12
  88. package/dist/core/yaml.d.ts +5 -0
  89. package/dist/core/yaml.js +1009 -0
  90. package/dist/diagnostics/diagnose.d.ts +53 -0
  91. package/dist/diagnostics/diagnose.js +1083 -0
  92. package/dist/diagnostics/flake.d.ts +71 -0
  93. package/dist/diagnostics/flake.js +608 -0
  94. package/dist/diagnostics/mutation-audit.d.ts +69 -0
  95. package/dist/diagnostics/mutation-audit.js +769 -0
  96. package/dist/diagnostics/spatial.d.ts +42 -0
  97. package/dist/diagnostics/spatial.js +346 -0
  98. package/dist/diagnostics/trends.d.ts +122 -0
  99. package/dist/diagnostics/trends.js +1190 -0
  100. package/dist/discovery/discover.d.ts +111 -0
  101. package/dist/discovery/discover.js +2017 -0
  102. package/dist/discovery/lock.d.ts +116 -0
  103. package/dist/discovery/lock.js +1505 -0
  104. package/dist/discovery/routes.d.ts +36 -0
  105. package/dist/discovery/routes.js +1494 -0
  106. package/dist/discovery/test-importer.d.ts +92 -0
  107. package/dist/discovery/test-importer.js +4952 -0
  108. package/dist/index.d.ts +123 -0
  109. package/dist/index.js +99 -0
  110. package/dist/ingestors/api-collections.d.ts +28 -0
  111. package/dist/ingestors/api-collections.js +2335 -0
  112. package/dist/ingestors/api-repo.d.ts +2 -1
  113. package/dist/ingestors/api-repo.js +483 -85
  114. package/dist/ingestors/asyncapi.d.ts +26 -0
  115. package/dist/ingestors/asyncapi.js +2105 -0
  116. package/dist/ingestors/bridges.d.ts +2 -0
  117. package/dist/ingestors/bridges.js +702 -0
  118. package/dist/ingestors/cli.d.ts +2 -1
  119. package/dist/ingestors/cli.js +234 -46
  120. package/dist/ingestors/curl.d.ts +14 -0
  121. package/dist/ingestors/curl.js +1024 -0
  122. package/dist/ingestors/graphql.d.ts +56 -0
  123. package/dist/ingestors/graphql.js +1852 -0
  124. package/dist/ingestors/http-file.d.ts +20 -0
  125. package/dist/ingestors/http-file.js +923 -0
  126. package/dist/ingestors/index.js +486 -6
  127. package/dist/ingestors/openrpc.d.ts +29 -0
  128. package/dist/ingestors/openrpc.js +1807 -0
  129. package/dist/ingestors/proto.d.ts +47 -0
  130. package/dist/ingestors/proto.js +2690 -0
  131. package/dist/ingestors/trace.d.ts +10 -0
  132. package/dist/ingestors/trace.js +599 -0
  133. package/dist/ingestors/video.d.ts +4 -1
  134. package/dist/ingestors/video.js +86 -36
  135. package/dist/ingestors/web.d.ts +16 -1
  136. package/dist/ingestors/web.js +474 -32
  137. package/dist/mcp/server.js +3532 -67
  138. package/dist/oracles/api-repo.js +102 -30
  139. package/dist/oracles/cli.js +65 -17
  140. package/dist/oracles/http-workflow.d.ts +68 -0
  141. package/dist/oracles/http-workflow.js +828 -0
  142. package/dist/oracles/image.js +178 -28
  143. package/dist/oracles/index.d.ts +3 -1
  144. package/dist/oracles/index.js +243 -14
  145. package/dist/oracles/perf-budget.d.ts +90 -0
  146. package/dist/oracles/perf-budget.js +1329 -0
  147. package/dist/oracles/stream.d.ts +94 -0
  148. package/dist/oracles/stream.js +1268 -0
  149. package/dist/oracles/ui-states.d.ts +49 -0
  150. package/dist/oracles/ui-states.js +894 -0
  151. package/dist/oracles/video.d.ts +1 -1
  152. package/dist/oracles/video.js +232 -16
  153. package/dist/oracles/web.js +464 -73
  154. package/dist/plugins/builtins.d.ts +12 -0
  155. package/dist/plugins/builtins.js +1052 -0
  156. package/dist/plugins/registry.d.ts +86 -0
  157. package/dist/plugins/registry.js +554 -0
  158. package/dist/setup/index.js +145 -33
  159. package/package.json +56 -47
  160. package/skills/vibecode-anything/SKILL.md +75 -52
@@ -2,6 +2,14 @@ import path from "node:path";
2
2
  import fs from "node:fs";
3
3
  import { VibecodeError } from "../core/errors.js";
4
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";
5
13
  const INGESTORS = {
6
14
  cli: ingestCli,
7
15
  script: ingestCli
@@ -10,6 +18,25 @@ const IMAGE_EXTS_EXT = new Set([".png", ".jpg", ".jpeg", ".webp"]);
10
18
  const VIDEO_EXTS_EXT = new Set([".mp4", ".mov", ".webm", ".mkv", ".gif", ".avi", ".m4v"]);
11
19
  // Sidecar files that legitimately accompany an ordered keyframe directory.
12
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
+ }
13
40
  // Lazy-loaded registries for milestone modules (M2-M4/M3 bridges).
14
41
  const LAZY = {
15
42
  image: async () => (await import("./image.js")).ingest,
@@ -25,7 +52,25 @@ const LAZY = {
25
52
  "cli-anything": async () => {
26
53
  const mod = await import("./bridges.js");
27
54
  return (options = {}) => mod.importCliAnything(options.source || "", options);
28
- }
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
29
74
  };
30
75
  export function listDomains() {
31
76
  return [...new Set([...Object.keys(INGESTORS), ...Object.keys(LAZY)])];
@@ -50,8 +95,10 @@ export function detectDomain(source) {
50
95
  return "video";
51
96
  }
52
97
  catch {
53
- // fall through to repo
98
+ // fall through to bruno / repo
54
99
  }
100
+ if (isBrunoCollectionDir(s))
101
+ return "api";
55
102
  return "repo";
56
103
  }
57
104
  const ext = path.extname(s).toLowerCase();
@@ -59,13 +106,69 @@ export function detectDomain(source) {
59
106
  return "image";
60
107
  if (VIDEO_EXTS_EXT.has(ext))
61
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
+ }
62
155
  if (ext === ".json") {
63
156
  try {
64
- const doc = JSON.parse(fs.readFileSync(s, "utf8"));
157
+ const doc = JSON.parse(stripBomText(fs.readFileSync(s, "utf8")));
65
158
  if (doc && typeof doc === "object" && !Array.isArray(doc)) {
66
159
  const rec = doc;
160
+ if (isOpenRpcDoc(doc))
161
+ return "api";
162
+ if (isAsyncApiDoc(doc))
163
+ return "api";
67
164
  if ((rec.openapi || rec.swagger) && rec.paths)
68
165
  return "api";
166
+ if (isPostmanCollectionDoc(doc))
167
+ return "api";
168
+ if (isInsomniaExportDoc(doc))
169
+ return "api";
170
+ if (isGraphqlIntrospectionDoc(doc))
171
+ return "api";
69
172
  }
70
173
  }
71
174
  catch {
@@ -73,6 +176,37 @@ export function detectDomain(source) {
73
176
  }
74
177
  }
75
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
+ }
76
210
  return "cli";
77
211
  }
78
212
  export async function getIngestor(domain) {
@@ -84,9 +218,355 @@ export async function getIngestor(domain) {
84
218
  throw new VibecodeError("UNSUPPORTED_FORMAT", `Unknown ingest domain: ${domain}`);
85
219
  }
86
220
  export async function ingest(options = {}, deps = {}) {
87
- const domain = options.domain || detectDomain(options.source);
88
- const fn = await getIngestor(domain);
89
- const result = await fn(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
+ }
90
570
  return {
91
571
  domain: result.domain || domain,
92
572
  sources: result.sources || [],
@@ -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>;