@llipe.com/dev-tasks 0.6.1

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 (230) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +823 -0
  3. package/bundle-manifest.json +113 -0
  4. package/dist/adapters/cli/extract-all.d.ts +31 -0
  5. package/dist/adapters/cli/extract-all.d.ts.map +1 -0
  6. package/dist/adapters/cli/extract-all.js +374 -0
  7. package/dist/adapters/cli/extract-all.js.map +1 -0
  8. package/dist/adapters/cli/extract-asyncapi.d.ts +26 -0
  9. package/dist/adapters/cli/extract-asyncapi.d.ts.map +1 -0
  10. package/dist/adapters/cli/extract-asyncapi.js +142 -0
  11. package/dist/adapters/cli/extract-asyncapi.js.map +1 -0
  12. package/dist/adapters/cli/extract-component.d.ts +24 -0
  13. package/dist/adapters/cli/extract-component.d.ts.map +1 -0
  14. package/dist/adapters/cli/extract-component.js +198 -0
  15. package/dist/adapters/cli/extract-component.js.map +1 -0
  16. package/dist/adapters/cli/extract-detect.d.ts +19 -0
  17. package/dist/adapters/cli/extract-detect.d.ts.map +1 -0
  18. package/dist/adapters/cli/extract-detect.js +98 -0
  19. package/dist/adapters/cli/extract-detect.js.map +1 -0
  20. package/dist/adapters/cli/extract-openapi.d.ts +29 -0
  21. package/dist/adapters/cli/extract-openapi.d.ts.map +1 -0
  22. package/dist/adapters/cli/extract-openapi.js +111 -0
  23. package/dist/adapters/cli/extract-openapi.js.map +1 -0
  24. package/dist/adapters/cli/extract-schema.d.ts +15 -0
  25. package/dist/adapters/cli/extract-schema.d.ts.map +1 -0
  26. package/dist/adapters/cli/extract-schema.js +39 -0
  27. package/dist/adapters/cli/extract-schema.js.map +1 -0
  28. package/dist/adapters/cli/index.d.ts +6 -0
  29. package/dist/adapters/cli/index.d.ts.map +1 -0
  30. package/dist/adapters/cli/index.js +5 -0
  31. package/dist/adapters/cli/index.js.map +1 -0
  32. package/dist/adapters/cli/parse-args.d.ts +22 -0
  33. package/dist/adapters/cli/parse-args.d.ts.map +1 -0
  34. package/dist/adapters/cli/parse-args.js +63 -0
  35. package/dist/adapters/cli/parse-args.js.map +1 -0
  36. package/dist/adapters/mcp/index.d.ts +5 -0
  37. package/dist/adapters/mcp/index.d.ts.map +1 -0
  38. package/dist/adapters/mcp/index.js +2 -0
  39. package/dist/adapters/mcp/index.js.map +1 -0
  40. package/dist/bin/dev-tasks.d.ts +7 -0
  41. package/dist/bin/dev-tasks.d.ts.map +1 -0
  42. package/dist/bin/dev-tasks.js +275 -0
  43. package/dist/bin/dev-tasks.js.map +1 -0
  44. package/dist/bin/dt.d.ts +7 -0
  45. package/dist/bin/dt.d.ts.map +1 -0
  46. package/dist/bin/dt.js +159 -0
  47. package/dist/bin/dt.js.map +1 -0
  48. package/dist/core/catalog/index.d.ts +5 -0
  49. package/dist/core/catalog/index.d.ts.map +1 -0
  50. package/dist/core/catalog/index.js +2 -0
  51. package/dist/core/catalog/index.js.map +1 -0
  52. package/dist/core/context/index.d.ts +5 -0
  53. package/dist/core/context/index.d.ts.map +1 -0
  54. package/dist/core/context/index.js +2 -0
  55. package/dist/core/context/index.js.map +1 -0
  56. package/dist/core/distribution/backup.d.ts +24 -0
  57. package/dist/core/distribution/backup.d.ts.map +1 -0
  58. package/dist/core/distribution/backup.js +37 -0
  59. package/dist/core/distribution/backup.js.map +1 -0
  60. package/dist/core/distribution/doctor.d.ts +35 -0
  61. package/dist/core/distribution/doctor.d.ts.map +1 -0
  62. package/dist/core/distribution/doctor.js +158 -0
  63. package/dist/core/distribution/doctor.js.map +1 -0
  64. package/dist/core/distribution/hash.d.ts +14 -0
  65. package/dist/core/distribution/hash.d.ts.map +1 -0
  66. package/dist/core/distribution/hash.js +21 -0
  67. package/dist/core/distribution/hash.js.map +1 -0
  68. package/dist/core/distribution/index.d.ts +18 -0
  69. package/dist/core/distribution/index.d.ts.map +1 -0
  70. package/dist/core/distribution/index.js +12 -0
  71. package/dist/core/distribution/index.js.map +1 -0
  72. package/dist/core/distribution/install.d.ts +25 -0
  73. package/dist/core/distribution/install.d.ts.map +1 -0
  74. package/dist/core/distribution/install.js +81 -0
  75. package/dist/core/distribution/install.js.map +1 -0
  76. package/dist/core/distribution/manifest.d.ts +28 -0
  77. package/dist/core/distribution/manifest.d.ts.map +1 -0
  78. package/dist/core/distribution/manifest.js +38 -0
  79. package/dist/core/distribution/manifest.js.map +1 -0
  80. package/dist/core/distribution/migrate.d.ts +54 -0
  81. package/dist/core/distribution/migrate.d.ts.map +1 -0
  82. package/dist/core/distribution/migrate.js +200 -0
  83. package/dist/core/distribution/migrate.js.map +1 -0
  84. package/dist/core/distribution/pin.d.ts +15 -0
  85. package/dist/core/distribution/pin.d.ts.map +1 -0
  86. package/dist/core/distribution/pin.js +37 -0
  87. package/dist/core/distribution/pin.js.map +1 -0
  88. package/dist/core/distribution/status.d.ts +20 -0
  89. package/dist/core/distribution/status.d.ts.map +1 -0
  90. package/dist/core/distribution/status.js +39 -0
  91. package/dist/core/distribution/status.js.map +1 -0
  92. package/dist/core/distribution/update.d.ts +41 -0
  93. package/dist/core/distribution/update.d.ts.map +1 -0
  94. package/dist/core/distribution/update.js +148 -0
  95. package/dist/core/distribution/update.js.map +1 -0
  96. package/dist/core/exit-codes.d.ts +23 -0
  97. package/dist/core/exit-codes.d.ts.map +1 -0
  98. package/dist/core/exit-codes.js +22 -0
  99. package/dist/core/exit-codes.js.map +1 -0
  100. package/dist/core/extract/asyncapi/index.d.ts +11 -0
  101. package/dist/core/extract/asyncapi/index.d.ts.map +1 -0
  102. package/dist/core/extract/asyncapi/index.js +7 -0
  103. package/dist/core/extract/asyncapi/index.js.map +1 -0
  104. package/dist/core/extract/asyncapi/payloads.d.ts +20 -0
  105. package/dist/core/extract/asyncapi/payloads.d.ts.map +1 -0
  106. package/dist/core/extract/asyncapi/payloads.js +421 -0
  107. package/dist/core/extract/asyncapi/payloads.js.map +1 -0
  108. package/dist/core/extract/asyncapi/topics.d.ts +27 -0
  109. package/dist/core/extract/asyncapi/topics.d.ts.map +1 -0
  110. package/dist/core/extract/asyncapi/topics.js +368 -0
  111. package/dist/core/extract/asyncapi/topics.js.map +1 -0
  112. package/dist/core/extract/asyncapi/types.d.ts +129 -0
  113. package/dist/core/extract/asyncapi/types.d.ts.map +1 -0
  114. package/dist/core/extract/asyncapi/types.js +5 -0
  115. package/dist/core/extract/asyncapi/types.js.map +1 -0
  116. package/dist/core/extract/asyncapi/validate.d.ts +29 -0
  117. package/dist/core/extract/asyncapi/validate.d.ts.map +1 -0
  118. package/dist/core/extract/asyncapi/validate.js +156 -0
  119. package/dist/core/extract/asyncapi/validate.js.map +1 -0
  120. package/dist/core/extract/component.d.ts +201 -0
  121. package/dist/core/extract/component.d.ts.map +1 -0
  122. package/dist/core/extract/component.js +258 -0
  123. package/dist/core/extract/component.js.map +1 -0
  124. package/dist/core/extract/detect.d.ts +35 -0
  125. package/dist/core/extract/detect.d.ts.map +1 -0
  126. package/dist/core/extract/detect.js +89 -0
  127. package/dist/core/extract/detect.js.map +1 -0
  128. package/dist/core/extract/index.d.ts +12 -0
  129. package/dist/core/extract/index.d.ts.map +1 -0
  130. package/dist/core/extract/index.js +6 -0
  131. package/dist/core/extract/index.js.map +1 -0
  132. package/dist/core/extract/openapi/index.d.ts +13 -0
  133. package/dist/core/extract/openapi/index.d.ts.map +1 -0
  134. package/dist/core/extract/openapi/index.js +9 -0
  135. package/dist/core/extract/openapi/index.js.map +1 -0
  136. package/dist/core/extract/openapi/llm-descriptions.d.ts +41 -0
  137. package/dist/core/extract/openapi/llm-descriptions.d.ts.map +1 -0
  138. package/dist/core/extract/openapi/llm-descriptions.js +36 -0
  139. package/dist/core/extract/openapi/llm-descriptions.js.map +1 -0
  140. package/dist/core/extract/openapi/route1.d.ts +36 -0
  141. package/dist/core/extract/openapi/route1.d.ts.map +1 -0
  142. package/dist/core/extract/openapi/route1.js +327 -0
  143. package/dist/core/extract/openapi/route1.js.map +1 -0
  144. package/dist/core/extract/openapi/route2.d.ts +46 -0
  145. package/dist/core/extract/openapi/route2.d.ts.map +1 -0
  146. package/dist/core/extract/openapi/route2.js +19 -0
  147. package/dist/core/extract/openapi/route2.js.map +1 -0
  148. package/dist/core/extract/openapi/route3.d.ts +26 -0
  149. package/dist/core/extract/openapi/route3.d.ts.map +1 -0
  150. package/dist/core/extract/openapi/route3.js +737 -0
  151. package/dist/core/extract/openapi/route3.js.map +1 -0
  152. package/dist/core/extract/openapi/types.d.ts +125 -0
  153. package/dist/core/extract/openapi/types.d.ts.map +1 -0
  154. package/dist/core/extract/openapi/types.js +5 -0
  155. package/dist/core/extract/openapi/types.js.map +1 -0
  156. package/dist/core/extract/openapi/validate.d.ts +29 -0
  157. package/dist/core/extract/openapi/validate.d.ts.map +1 -0
  158. package/dist/core/extract/openapi/validate.js +200 -0
  159. package/dist/core/extract/openapi/validate.js.map +1 -0
  160. package/dist/core/extract/orm/drizzle.d.ts +20 -0
  161. package/dist/core/extract/orm/drizzle.d.ts.map +1 -0
  162. package/dist/core/extract/orm/drizzle.js +283 -0
  163. package/dist/core/extract/orm/drizzle.js.map +1 -0
  164. package/dist/core/extract/orm/information-schema.d.ts +26 -0
  165. package/dist/core/extract/orm/information-schema.d.ts.map +1 -0
  166. package/dist/core/extract/orm/information-schema.js +142 -0
  167. package/dist/core/extract/orm/information-schema.js.map +1 -0
  168. package/dist/core/extract/orm/llm-descriptions.d.ts +28 -0
  169. package/dist/core/extract/orm/llm-descriptions.d.ts.map +1 -0
  170. package/dist/core/extract/orm/llm-descriptions.js +64 -0
  171. package/dist/core/extract/orm/llm-descriptions.js.map +1 -0
  172. package/dist/core/extract/orm/migration-inference.d.ts +25 -0
  173. package/dist/core/extract/orm/migration-inference.d.ts.map +1 -0
  174. package/dist/core/extract/orm/migration-inference.js +76 -0
  175. package/dist/core/extract/orm/migration-inference.js.map +1 -0
  176. package/dist/core/extract/orm/prisma.d.ts +23 -0
  177. package/dist/core/extract/orm/prisma.d.ts.map +1 -0
  178. package/dist/core/extract/orm/prisma.js +234 -0
  179. package/dist/core/extract/orm/prisma.js.map +1 -0
  180. package/dist/core/extract/orm/typeorm.d.ts +22 -0
  181. package/dist/core/extract/orm/typeorm.d.ts.map +1 -0
  182. package/dist/core/extract/orm/typeorm.js +269 -0
  183. package/dist/core/extract/orm/typeorm.js.map +1 -0
  184. package/dist/core/extract/orm/types.d.ts +97 -0
  185. package/dist/core/extract/orm/types.d.ts.map +1 -0
  186. package/dist/core/extract/orm/types.js +6 -0
  187. package/dist/core/extract/orm/types.js.map +1 -0
  188. package/dist/core/extract/prompt.d.ts +21 -0
  189. package/dist/core/extract/prompt.d.ts.map +1 -0
  190. package/dist/core/extract/prompt.js +79 -0
  191. package/dist/core/extract/prompt.js.map +1 -0
  192. package/dist/core/extract/provider.d.ts +117 -0
  193. package/dist/core/extract/provider.d.ts.map +1 -0
  194. package/dist/core/extract/provider.js +6 -0
  195. package/dist/core/extract/provider.js.map +1 -0
  196. package/dist/core/extract/providers/node-ts.d.ts +69 -0
  197. package/dist/core/extract/providers/node-ts.d.ts.map +1 -0
  198. package/dist/core/extract/providers/node-ts.js +311 -0
  199. package/dist/core/extract/providers/node-ts.js.map +1 -0
  200. package/dist/core/extract/render/schema-md.d.ts +16 -0
  201. package/dist/core/extract/render/schema-md.d.ts.map +1 -0
  202. package/dist/core/extract/render/schema-md.js +140 -0
  203. package/dist/core/extract/render/schema-md.js.map +1 -0
  204. package/dist/core/extract/report.d.ts +97 -0
  205. package/dist/core/extract/report.d.ts.map +1 -0
  206. package/dist/core/extract/report.js +47 -0
  207. package/dist/core/extract/report.js.map +1 -0
  208. package/dist/core/extract/schema.d.ts +36 -0
  209. package/dist/core/extract/schema.d.ts.map +1 -0
  210. package/dist/core/extract/schema.js +141 -0
  211. package/dist/core/extract/schema.js.map +1 -0
  212. package/dist/core/index.d.ts +15 -0
  213. package/dist/core/index.d.ts.map +1 -0
  214. package/dist/core/index.js +14 -0
  215. package/dist/core/index.js.map +1 -0
  216. package/dist/core/providers/index.d.ts +5 -0
  217. package/dist/core/providers/index.d.ts.map +1 -0
  218. package/dist/core/providers/index.js +2 -0
  219. package/dist/core/providers/index.js.map +1 -0
  220. package/dist/core/reconcile.d.ts +25 -0
  221. package/dist/core/reconcile.d.ts.map +1 -0
  222. package/dist/core/reconcile.js +36 -0
  223. package/dist/core/reconcile.js.map +1 -0
  224. package/dist/core/scope/index.d.ts +5 -0
  225. package/dist/core/scope/index.d.ts.map +1 -0
  226. package/dist/core/scope/index.js +2 -0
  227. package/dist/core/scope/index.js.map +1 -0
  228. package/package.json +77 -0
  229. package/schemas/.gitkeep +0 -0
  230. package/skills/.gitkeep +0 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Detection orchestrator — loads registered providers, runs detect(), returns first match.
3
+ * Spec §8.1 — deterministic stack/framework/ORM/messaging detection.
4
+ */
5
+ import type { Capability, DetectionResult, ExtractionProvider, RepoContext, RequiresHumanEntry } from "./provider.js";
6
+ /**
7
+ * Register an extraction provider.
8
+ * Providers are evaluated in registration order; first match wins.
9
+ */
10
+ export declare function registerProvider(provider: ExtractionProvider): void;
11
+ /**
12
+ * Clear all registered providers (used in testing).
13
+ */
14
+ export declare function clearProviders(): void;
15
+ /**
16
+ * Get the list of registered providers.
17
+ */
18
+ export declare function getProviders(): readonly ExtractionProvider[];
19
+ /**
20
+ * Run detection across all registered providers.
21
+ * Returns the DetectionResult from the first matching provider, or null if none match.
22
+ */
23
+ export declare function runDetection(repo: RepoContext): DetectionResult | null;
24
+ /**
25
+ * Get the matching provider for a repo (the first whose detect() returns non-null).
26
+ */
27
+ export declare function getMatchingProvider(repo: RepoContext): ExtractionProvider | null;
28
+ /**
29
+ * Given a provider and a list of desired capabilities, compute which artifacts
30
+ * cannot be produced and should be recorded in requires_human.
31
+ *
32
+ * This does NOT throw — missing capabilities are informational, not fatal.
33
+ */
34
+ export declare function getRequiresHuman(provider: ExtractionProvider, desiredCapabilities: Capability[]): RequiresHumanEntry[];
35
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../core/extract/detect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAKvB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAEnE;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,kBAAkB,EAAE,CAE5D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAQtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB,GAAG,IAAI,CAQhF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,kBAAkB,EAC5B,mBAAmB,EAAE,UAAU,EAAE,GAChC,kBAAkB,EAAE,CActB"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Detection orchestrator — loads registered providers, runs detect(), returns first match.
3
+ * Spec §8.1 — deterministic stack/framework/ORM/messaging detection.
4
+ */
5
+ /** Registry of extraction providers, ordered by priority. */
6
+ let providers = [];
7
+ /**
8
+ * Register an extraction provider.
9
+ * Providers are evaluated in registration order; first match wins.
10
+ */
11
+ export function registerProvider(provider) {
12
+ providers.push(provider);
13
+ }
14
+ /**
15
+ * Clear all registered providers (used in testing).
16
+ */
17
+ export function clearProviders() {
18
+ providers = [];
19
+ }
20
+ /**
21
+ * Get the list of registered providers.
22
+ */
23
+ export function getProviders() {
24
+ return providers;
25
+ }
26
+ /**
27
+ * Run detection across all registered providers.
28
+ * Returns the DetectionResult from the first matching provider, or null if none match.
29
+ */
30
+ export function runDetection(repo) {
31
+ for (const provider of providers) {
32
+ const result = provider.detect(repo);
33
+ if (result !== null) {
34
+ return result;
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ /**
40
+ * Get the matching provider for a repo (the first whose detect() returns non-null).
41
+ */
42
+ export function getMatchingProvider(repo) {
43
+ for (const provider of providers) {
44
+ const result = provider.detect(repo);
45
+ if (result !== null) {
46
+ return provider;
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+ /**
52
+ * Given a provider and a list of desired capabilities, compute which artifacts
53
+ * cannot be produced and should be recorded in requires_human.
54
+ *
55
+ * This does NOT throw — missing capabilities are informational, not fatal.
56
+ */
57
+ export function getRequiresHuman(provider, desiredCapabilities) {
58
+ const entries = [];
59
+ for (const cap of desiredCapabilities) {
60
+ if (!provider.capabilities.includes(cap)) {
61
+ entries.push({
62
+ artifact: capabilityToArtifact(cap),
63
+ reason: `Provider '${provider.id}' does not declare capability '${cap}'`,
64
+ missing_capability: cap,
65
+ });
66
+ }
67
+ }
68
+ return entries;
69
+ }
70
+ /**
71
+ * Map a capability to the artifact it would produce.
72
+ */
73
+ function capabilityToArtifact(cap) {
74
+ switch (cap) {
75
+ case "openapi_native":
76
+ return "openapi.yaml";
77
+ case "openapi_ast":
78
+ return "openapi.yaml";
79
+ case "db_introspection":
80
+ return "schema.md";
81
+ case "orm_ast":
82
+ return "schema.md";
83
+ case "topic_ast":
84
+ return "asyncapi.yaml";
85
+ case "payload_typed":
86
+ return "asyncapi.yaml";
87
+ }
88
+ }
89
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../core/extract/detect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,6DAA6D;AAC7D,IAAI,SAAS,GAAyB,EAAE,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA4B;IAC3D,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,SAAS,GAAG,EAAE,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAiB;IAC5C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAiB;IACnD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA4B,EAC5B,mBAAiC;IAEjC,MAAM,OAAO,GAAyB,EAAE,CAAC;IAEzC,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC;gBACX,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC;gBACnC,MAAM,EAAE,aAAa,QAAQ,CAAC,EAAE,kCAAkC,GAAG,GAAG;gBACxE,kBAAkB,EAAE,GAAG;aACxB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,GAAe;IAC3C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,gBAAgB;YACnB,OAAO,cAAc,CAAC;QACxB,KAAK,aAAa;YAChB,OAAO,cAAc,CAAC;QACxB,KAAK,kBAAkB;YACrB,OAAO,WAAW,CAAC;QACrB,KAAK,SAAS;YACZ,OAAO,WAAW,CAAC;QACrB,KAAK,WAAW;YACd,OAAO,eAAe,CAAC;QACzB,KAAK,eAAe;YAClB,OAAO,eAAe,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Extract module — component metadata extraction.
3
+ */
4
+ export type { Capability, DetectionEvidence, DetectionResult, ExtractionProvider, HttpDetection, MessagingDetection, OpenApiStrategy, OrmDetection, RepoContext, RequiresHumanEntry, } from "./provider.js";
5
+ export { runDetection, registerProvider, clearProviders, getProviders, getMatchingProvider, getRequiresHuman, } from "./detect.js";
6
+ export { nodeTsProvider } from "./providers/node-ts.js";
7
+ export { deriveComponent, deriveFields, applyInference, applyPrompted, computeFieldHashes, assembleProvenance, reconcileField, reconcileComponent, getMissingRequiredFields, FIELD_CATEGORIES, } from "./component.js";
8
+ export type { ComponentYaml, ProvenanceBlock, FieldProvenance, FieldSource, FieldCategory, Confidence, ExtractionInputs, InferenceResult, PromptedValues, ConfirmationResult, DeriveComponentOptions, } from "./component.js";
9
+ export { isInteractive, promptNonDerivableFields, confirmInference } from "./prompt.js";
10
+ export { buildExtractionReport, serializeReport } from "./report.js";
11
+ export type { ExtractionReport, ReportInputs, StrategyEntry, CoverageMetrics, UnresolvedItem, RequiresHumanItem, ConfidenceCounts, } from "./report.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/extract/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAErE,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { runDetection, registerProvider, clearProviders, getProviders, getMatchingProvider, getRequiresHuman, } from "./detect.js";
2
+ export { nodeTsProvider } from "./providers/node-ts.js";
3
+ export { deriveComponent, deriveFields, applyInference, applyPrompted, computeFieldHashes, assembleProvenance, reconcileField, reconcileComponent, getMissingRequiredFields, FIELD_CATEGORIES, } from "./component.js";
4
+ export { isInteractive, promptNonDerivableFields, confirmInference } from "./prompt.js";
5
+ export { buildExtractionReport, serializeReport } from "./report.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/extract/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * OpenAPI extraction module barrel export.
3
+ */
4
+ export type { ExtractedEndpoint, OpenApiConfidence, OpenApiDocument, OpenApiExtractionResult, OpenApiSource, RequestBodySchema, ResponseSchema, RouteParam, UnresolvedRoute, } from "./types.js";
5
+ export { extractRoute1, detectOnDiskSpec, normalizeSpec, Route1Error } from "./route1.js";
6
+ export { extractRoute3, composePath, extractPathParams } from "./route3.js";
7
+ export { extractRoute2 } from "./route2.js";
8
+ export type { Route2Config, Route2Extractor } from "./route2.js";
9
+ export { validateOpenApi, extractionResultToDocument } from "./validate.js";
10
+ export type { ValidationResult, ValidationError } from "./validate.js";
11
+ export { applyLlmDescriptions } from "./llm-descriptions.js";
12
+ export type { OpenApiLlmProvider } from "./llm-descriptions.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * OpenAPI extraction module barrel export.
3
+ */
4
+ export { extractRoute1, detectOnDiskSpec, normalizeSpec, Route1Error } from "./route1.js";
5
+ export { extractRoute3, composePath, extractPathParams } from "./route3.js";
6
+ export { extractRoute2 } from "./route2.js";
7
+ export { validateOpenApi, extractionResultToDocument } from "./validate.js";
8
+ export { applyLlmDescriptions } from "./llm-descriptions.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * LLM description pass for OpenAPI endpoints.
3
+ * Writes only `summary`, `description`, `tags` per endpoint.
4
+ * Does NOT modify structural information (paths, methods, params, schemas).
5
+ */
6
+ import type { OpenApiExtractionResult } from "./types.js";
7
+ /**
8
+ * LLM provider interface for OpenAPI description generation.
9
+ * Consumers provide an implementation; tests use stubs.
10
+ */
11
+ export interface OpenApiLlmProvider {
12
+ /**
13
+ * Generate summary, description, and tags for a set of endpoints.
14
+ * Must NOT modify structural fields (method, path, parameters, requestBody, responses).
15
+ */
16
+ describeEndpoints(endpoints: EndpointDescriptionInput[]): Promise<EndpointDescriptionOutput[]>;
17
+ }
18
+ /**
19
+ * Input to the LLM for describing an endpoint.
20
+ */
21
+ export interface EndpointDescriptionInput {
22
+ method: string;
23
+ path: string;
24
+ parameters: string[];
25
+ hasBody: boolean;
26
+ responseType: string | null;
27
+ }
28
+ /**
29
+ * LLM output: only descriptive fields.
30
+ */
31
+ export interface EndpointDescriptionOutput {
32
+ summary: string;
33
+ description: string;
34
+ tags: string[];
35
+ }
36
+ /**
37
+ * Apply LLM-generated descriptions to an extraction result.
38
+ * Only writes summary, description, and tags — nothing structural.
39
+ */
40
+ export declare function applyLlmDescriptions(result: OpenApiExtractionResult, llm: OpenApiLlmProvider): Promise<OpenApiExtractionResult>;
41
+ //# sourceMappingURL=llm-descriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-descriptions.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/llm-descriptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAqB,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;CAChG;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,uBAAuB,EAC/B,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,uBAAuB,CAAC,CA2BlC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LLM description pass for OpenAPI endpoints.
3
+ * Writes only `summary`, `description`, `tags` per endpoint.
4
+ * Does NOT modify structural information (paths, methods, params, schemas).
5
+ */
6
+ /**
7
+ * Apply LLM-generated descriptions to an extraction result.
8
+ * Only writes summary, description, and tags — nothing structural.
9
+ */
10
+ export async function applyLlmDescriptions(result, llm) {
11
+ const inputs = result.endpoints.map((ep) => ({
12
+ method: ep.method,
13
+ path: ep.path,
14
+ parameters: ep.parameters.map((p) => `${p.name} (${p.in})`),
15
+ hasBody: !!ep.requestBody,
16
+ responseType: ep.responses[0]?.schema ? "typed" : null,
17
+ }));
18
+ const descriptions = await llm.describeEndpoints(inputs);
19
+ // Apply descriptions to endpoints (do not modify structural fields)
20
+ const updatedEndpoints = result.endpoints.map((ep, i) => {
21
+ const desc = descriptions[i];
22
+ if (!desc)
23
+ return ep;
24
+ return {
25
+ ...ep,
26
+ summary: desc.summary,
27
+ description: desc.description,
28
+ tags: desc.tags,
29
+ };
30
+ });
31
+ return {
32
+ ...result,
33
+ endpoints: updatedEndpoints,
34
+ };
35
+ }
36
+ //# sourceMappingURL=llm-descriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-descriptions.js","sourceRoot":"","sources":["../../../../core/extract/openapi/llm-descriptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA+B,EAC/B,GAAuB;IAEvB,MAAM,MAAM,GAA+B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACvE,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;QAC3D,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW;QACzB,YAAY,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;KACvD,CAAC,CAAC,CAAC;IAEJ,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEzD,oEAAoE;IACpE,MAAM,gBAAgB,GAAwB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QAC3E,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QACrB,OAAO;YACL,GAAG,EAAE;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,MAAM;QACT,SAAS,EAAE,gBAAgB;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * OpenAPI Route 1: On-disk spec detection.
3
+ * Detects an existing openapi.yaml/openapi.json in the repository,
4
+ * copies it, normalizes (resolves $refs within single file, sets openapi: 3.1.x),
5
+ * validates, and attaches source: introspected, confidence: high.
6
+ */
7
+ import type { OpenApiExtractionResult, OpenApiDocument } from "./types.js";
8
+ /**
9
+ * Detect an on-disk OpenAPI specification file.
10
+ * Returns the absolute path if found, null otherwise.
11
+ */
12
+ export declare function detectOnDiskSpec(rootDir: string): string | null;
13
+ /**
14
+ * Parse an OpenAPI file (JSON or YAML-as-JSON for simplicity).
15
+ * For YAML support, we parse basic YAML structure. In production this
16
+ * would use a proper YAML parser, but we keep deps minimal.
17
+ */
18
+ export declare function parseOpenApiFile(filePath: string): OpenApiDocument;
19
+ /**
20
+ * Normalize an OpenAPI document:
21
+ * - Resolve single-file $ref pointers
22
+ * - Set openapi version to 3.1.0 if not already 3.1.x
23
+ */
24
+ export declare function normalizeSpec(doc: OpenApiDocument): OpenApiDocument;
25
+ /**
26
+ * Extract OpenAPI specification using Route 1 strategy.
27
+ * Returns null if no on-disk spec is found.
28
+ */
29
+ export declare function extractRoute1(rootDir: string): OpenApiExtractionResult | null;
30
+ /**
31
+ * Error class for Route 1 failures.
32
+ */
33
+ export declare class Route1Error extends Error {
34
+ constructor(message: string);
35
+ }
36
+ //# sourceMappingURL=route1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route1.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/route1.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkB3E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ/D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAelE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,eAAe,CAUnE;AA8HD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAgC7E;AAmHD;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,327 @@
1
+ /**
2
+ * OpenAPI Route 1: On-disk spec detection.
3
+ * Detects an existing openapi.yaml/openapi.json in the repository,
4
+ * copies it, normalizes (resolves $refs within single file, sets openapi: 3.1.x),
5
+ * validates, and attaches source: introspected, confidence: high.
6
+ */
7
+ import { readFileSync, existsSync } from "node:fs";
8
+ import { resolve } from "node:path";
9
+ /** File names to search for an on-disk OpenAPI spec. */
10
+ const OPENAPI_FILE_CANDIDATES = [
11
+ "openapi.yaml",
12
+ "openapi.yml",
13
+ "openapi.json",
14
+ "swagger.yaml",
15
+ "swagger.yml",
16
+ "swagger.json",
17
+ "api/openapi.yaml",
18
+ "api/openapi.yml",
19
+ "api/openapi.json",
20
+ "docs/openapi.yaml",
21
+ "docs/openapi.yml",
22
+ "docs/openapi.json",
23
+ ];
24
+ /**
25
+ * Detect an on-disk OpenAPI specification file.
26
+ * Returns the absolute path if found, null otherwise.
27
+ */
28
+ export function detectOnDiskSpec(rootDir) {
29
+ for (const candidate of OPENAPI_FILE_CANDIDATES) {
30
+ const fullPath = resolve(rootDir, candidate);
31
+ if (existsSync(fullPath)) {
32
+ return fullPath;
33
+ }
34
+ }
35
+ return null;
36
+ }
37
+ /**
38
+ * Parse an OpenAPI file (JSON or YAML-as-JSON for simplicity).
39
+ * For YAML support, we parse basic YAML structure. In production this
40
+ * would use a proper YAML parser, but we keep deps minimal.
41
+ */
42
+ export function parseOpenApiFile(filePath) {
43
+ const content = readFileSync(filePath, "utf-8");
44
+ const ext = filePath.toLowerCase();
45
+ if (ext.endsWith(".json")) {
46
+ return JSON.parse(content);
47
+ }
48
+ // For YAML files, try JSON parse first (in case it's actually JSON with .yaml ext)
49
+ try {
50
+ return JSON.parse(content);
51
+ }
52
+ catch {
53
+ // Basic YAML parsing for simple OpenAPI specs
54
+ return parseSimpleYaml(content);
55
+ }
56
+ }
57
+ /**
58
+ * Normalize an OpenAPI document:
59
+ * - Resolve single-file $ref pointers
60
+ * - Set openapi version to 3.1.0 if not already 3.1.x
61
+ */
62
+ export function normalizeSpec(doc) {
63
+ // Ensure openapi version is 3.1.x
64
+ const normalized = { ...doc };
65
+ if (!normalized.openapi || !normalized.openapi.startsWith("3.1")) {
66
+ normalized.openapi = "3.1.0";
67
+ }
68
+ // Resolve internal $refs
69
+ const resolved = resolveInternalRefs(normalized);
70
+ return resolved;
71
+ }
72
+ /**
73
+ * Resolve $ref pointers within the same document.
74
+ * Only handles JSON Pointer (#/components/schemas/Foo style) refs.
75
+ */
76
+ function resolveInternalRefs(doc) {
77
+ const docAsAny = doc;
78
+ function resolveValue(value) {
79
+ if (value === null || value === undefined)
80
+ return value;
81
+ if (Array.isArray(value))
82
+ return value.map(resolveValue);
83
+ if (typeof value !== "object")
84
+ return value;
85
+ const obj = value;
86
+ if ("$ref" in obj && typeof obj["$ref"] === "string") {
87
+ const refPath = obj["$ref"];
88
+ if (refPath.startsWith("#/")) {
89
+ const resolved = getByJsonPointer(docAsAny, refPath.slice(2));
90
+ if (resolved !== undefined) {
91
+ return resolveValue(resolved);
92
+ }
93
+ }
94
+ // External refs or unresolvable — leave as-is
95
+ return obj;
96
+ }
97
+ const result = {};
98
+ for (const [key, val] of Object.entries(obj)) {
99
+ result[key] = resolveValue(val);
100
+ }
101
+ return result;
102
+ }
103
+ return resolveValue(doc);
104
+ }
105
+ /**
106
+ * Get a value from a nested object using a JSON Pointer path (without leading #/).
107
+ */
108
+ function getByJsonPointer(obj, pointer) {
109
+ const parts = pointer.split("/");
110
+ let current = obj;
111
+ for (const part of parts) {
112
+ if (current === null || current === undefined || typeof current !== "object") {
113
+ return undefined;
114
+ }
115
+ current = current[part];
116
+ }
117
+ return current;
118
+ }
119
+ /**
120
+ * Simple YAML parser for basic OpenAPI specs.
121
+ * Handles the subset needed: key-value pairs, nested objects, arrays.
122
+ * This is intentionally minimal — a production version would use a YAML lib.
123
+ */
124
+ function parseSimpleYaml(content) {
125
+ // This is a best-effort parser for structured YAML.
126
+ // It handles indented key: value pairs and basic arrays.
127
+ const result = {};
128
+ const lines = content.split("\n");
129
+ const stack = [
130
+ { indent: -1, obj: result },
131
+ ];
132
+ for (const rawLine of lines) {
133
+ const line = rawLine.replace(/\r$/, "");
134
+ if (line.trim() === "" || line.trim().startsWith("#"))
135
+ continue;
136
+ const indent = line.length - line.trimStart().length;
137
+ const trimmed = line.trim();
138
+ // Pop stack until we find the right parent
139
+ while (stack.length > 1 && stack[stack.length - 1].indent >= indent) {
140
+ stack.pop();
141
+ }
142
+ const parent = stack[stack.length - 1].obj;
143
+ // Handle array items
144
+ if (trimmed.startsWith("- ")) {
145
+ const lastKey = Object.keys(parent).pop();
146
+ if (lastKey && Array.isArray(parent[lastKey])) {
147
+ const value = trimmed.slice(2).trim();
148
+ parent[lastKey].push(parseYamlValue(value));
149
+ }
150
+ continue;
151
+ }
152
+ // Handle key: value
153
+ const colonIdx = trimmed.indexOf(":");
154
+ if (colonIdx > 0) {
155
+ const key = trimmed.slice(0, colonIdx).trim();
156
+ const valueStr = trimmed.slice(colonIdx + 1).trim();
157
+ if (valueStr === "" || valueStr === "|" || valueStr === ">") {
158
+ // Nested object or multiline
159
+ const nested = {};
160
+ parent[key] = nested;
161
+ stack.push({ indent, obj: nested });
162
+ }
163
+ else {
164
+ parent[key] = parseYamlValue(valueStr);
165
+ }
166
+ }
167
+ }
168
+ return result;
169
+ }
170
+ function parseYamlValue(value) {
171
+ if (value === "true")
172
+ return true;
173
+ if (value === "false")
174
+ return false;
175
+ if (value === "null")
176
+ return null;
177
+ const num = Number(value);
178
+ if (!isNaN(num) && value !== "")
179
+ return num;
180
+ // Strip quotes
181
+ if ((value.startsWith('"') && value.endsWith('"')) ||
182
+ (value.startsWith("'") && value.endsWith("'"))) {
183
+ return value.slice(1, -1);
184
+ }
185
+ return value;
186
+ }
187
+ /**
188
+ * Extract OpenAPI specification using Route 1 strategy.
189
+ * Returns null if no on-disk spec is found.
190
+ */
191
+ export function extractRoute1(rootDir) {
192
+ const specPath = detectOnDiskSpec(rootDir);
193
+ if (!specPath)
194
+ return null;
195
+ let doc;
196
+ try {
197
+ doc = parseOpenApiFile(specPath);
198
+ }
199
+ catch (error) {
200
+ const message = error instanceof Error ? error.message : String(error);
201
+ throw new Route1Error(`Failed to parse OpenAPI spec at ${specPath}: ${message}`);
202
+ }
203
+ // Validate basic structure
204
+ if (!doc.paths || typeof doc.paths !== "object") {
205
+ throw new Route1Error(`Invalid OpenAPI spec at ${specPath}: missing or invalid 'paths'`);
206
+ }
207
+ // Normalize
208
+ const normalized = normalizeSpec(doc);
209
+ // Convert to extraction result
210
+ const endpoints = pathsToEndpoints(normalized.paths);
211
+ return {
212
+ openapi: normalized.openapi,
213
+ info: normalized.info ?? { title: "API", version: "1.0.0" },
214
+ endpoints,
215
+ unresolved: [],
216
+ source: "introspected",
217
+ confidence: "high",
218
+ strategy: "route1",
219
+ };
220
+ }
221
+ /**
222
+ * Convert OpenAPI paths object to extracted endpoints.
223
+ */
224
+ function pathsToEndpoints(paths) {
225
+ const endpoints = [];
226
+ const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
227
+ for (const [path, pathItem] of Object.entries(paths)) {
228
+ if (!pathItem || typeof pathItem !== "object")
229
+ continue;
230
+ for (const method of methods) {
231
+ const operation = pathItem[method];
232
+ if (!operation || typeof operation !== "object")
233
+ continue;
234
+ const op = operation;
235
+ const params = extractParametersFromOp(op, path);
236
+ endpoints.push({
237
+ method,
238
+ path,
239
+ parameters: params,
240
+ responses: extractResponsesFromOp(op),
241
+ typed: true,
242
+ confidence: "high",
243
+ summary: op.summary,
244
+ description: op.description,
245
+ tags: op.tags,
246
+ });
247
+ }
248
+ }
249
+ return endpoints;
250
+ }
251
+ function extractParametersFromOp(op, path) {
252
+ const params = [];
253
+ // Extract path parameters from the path pattern
254
+ const pathParamMatches = path.matchAll(/\{([^}]+)\}/g);
255
+ for (const match of pathParamMatches) {
256
+ params.push({
257
+ name: match[1],
258
+ in: "path",
259
+ required: true,
260
+ type: "string",
261
+ });
262
+ }
263
+ // Extract from parameters array in the operation
264
+ if (Array.isArray(op.parameters)) {
265
+ for (const param of op.parameters) {
266
+ if (param && typeof param === "object") {
267
+ const p = param;
268
+ // Don't duplicate path params
269
+ if (p.in === "path" && params.some((existing) => existing.name === p.name))
270
+ continue;
271
+ params.push({
272
+ name: p.name ?? "unknown",
273
+ in: p.in ?? "query",
274
+ required: p.required ?? false,
275
+ type: getSchemaType(p.schema),
276
+ });
277
+ }
278
+ }
279
+ }
280
+ return params;
281
+ }
282
+ function extractResponsesFromOp(op) {
283
+ const responses = [];
284
+ if (op.responses && typeof op.responses === "object") {
285
+ for (const [statusCode, response] of Object.entries(op.responses)) {
286
+ if (!response || typeof response !== "object")
287
+ continue;
288
+ const resp = response;
289
+ const content = resp.content;
290
+ if (content && typeof content === "object") {
291
+ for (const [contentType, mediaType] of Object.entries(content)) {
292
+ const mt = mediaType;
293
+ responses.push({
294
+ statusCode,
295
+ contentType,
296
+ schema: mt.schema ?? null,
297
+ description: resp.description ?? "",
298
+ });
299
+ }
300
+ }
301
+ else {
302
+ responses.push({
303
+ statusCode,
304
+ contentType: "application/json",
305
+ schema: null,
306
+ description: resp.description ?? "",
307
+ });
308
+ }
309
+ }
310
+ }
311
+ return responses;
312
+ }
313
+ function getSchemaType(schema) {
314
+ if (!schema)
315
+ return "string";
316
+ return schema.type ?? "string";
317
+ }
318
+ /**
319
+ * Error class for Route 1 failures.
320
+ */
321
+ export class Route1Error extends Error {
322
+ constructor(message) {
323
+ super(message);
324
+ this.name = "Route1Error";
325
+ }
326
+ }
327
+ //# sourceMappingURL=route1.js.map