raiton 6.8.9-beta.25 → 6.10.0-beta.28

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 (387) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +46 -1
  3. package/benchmarks/README.md +16 -0
  4. package/benchmarks/latest.json +172 -0
  5. package/benchmarks/latest.md +66 -0
  6. package/build/bin/index.mjs +33550 -21725
  7. package/build/types/bin/bootstrapper.d.ts +2 -0
  8. package/build/types/bin/cli-output.d.ts +46 -0
  9. package/build/types/bin/cli-tools.d.ts +13 -0
  10. package/build/types/bin/cli.d.ts +3 -0
  11. package/build/types/bin/commands.registry.d.ts +4 -0
  12. package/build/types/bin/constants.d.ts +3 -0
  13. package/build/types/bin/file-utils.d.ts +21 -0
  14. package/build/types/bin/index.d.ts +2 -0
  15. package/build/types/bin/name-utils.d.ts +4 -0
  16. package/build/types/bin/project-utils.d.ts +12 -0
  17. package/build/types/commands/artifact.command.d.ts +7 -0
  18. package/build/types/commands/build.command.d.ts +8 -0
  19. package/build/types/commands/client.command.d.ts +7 -0
  20. package/build/types/commands/contract.command.d.ts +8 -0
  21. package/build/types/commands/develop.command.d.ts +9 -0
  22. package/build/types/commands/docs.command.d.ts +8 -0
  23. package/build/types/commands/doctor.command.d.ts +9 -0
  24. package/build/types/commands/generate.command.d.ts +7 -0
  25. package/build/types/commands/inspect.command.d.ts +7 -0
  26. package/build/types/commands/mcp.command.d.ts +11 -0
  27. package/build/types/commands/new.command.d.ts +7 -0
  28. package/build/types/commands/openapi.command.d.ts +7 -0
  29. package/build/types/commands/routes.command.d.ts +7 -0
  30. package/build/types/commands/start.command.d.ts +9 -0
  31. package/build/types/commands/why.command.d.ts +7 -0
  32. package/build/types/contracts/decorators.d.ts +41 -0
  33. package/build/types/contracts/errors.d.ts +42 -0
  34. package/build/types/contracts/index.d.ts +4 -0
  35. package/build/types/contracts/schema.d.ts +70 -0
  36. package/build/types/contracts/typebox.d.ts +81 -0
  37. package/build/types/core/application.d.ts +37 -0
  38. package/build/types/core/artifacts/artifact.d.ts +3 -0
  39. package/build/types/core/artifacts/index.d.ts +1 -0
  40. package/build/types/core/artifacts/runner.d.ts +1 -0
  41. package/build/types/core/builder.d.ts +42 -0
  42. package/build/types/core/bytes.util.d.ts +3 -0
  43. package/build/types/core/command.d.ts +13 -0
  44. package/build/types/core/commands.d.ts +10 -0
  45. package/build/types/core/config/config.d.ts +27 -0
  46. package/build/types/core/config/define.d.ts +8 -0
  47. package/build/types/core/config/index.d.ts +3 -0
  48. package/build/types/core/config/schema.d.ts +24 -0
  49. package/build/types/core/context.d.ts +11 -0
  50. package/build/types/core/controller/builder.d.ts +26 -0
  51. package/build/types/core/controller/compiler.d.ts +2 -0
  52. package/build/types/core/controller/index.d.ts +4 -0
  53. package/build/types/core/controller/metadata.d.ts +3 -0
  54. package/build/types/core/controller/tracker.d.ts +9 -0
  55. package/build/types/core/directories.d.ts +10 -0
  56. package/build/types/core/guards.d.ts +11 -0
  57. package/build/types/core/helpers/index.d.ts +1 -0
  58. package/build/types/core/helpers/raiton.d.ts +1 -0
  59. package/build/types/core/hooks.d.ts +14 -0
  60. package/build/types/core/index.d.ts +17 -0
  61. package/build/types/core/injection/index.d.ts +1 -0
  62. package/build/types/core/injection/injection.d.ts +37 -0
  63. package/build/types/core/mcp/builder.d.ts +2 -0
  64. package/build/types/core/mcp/index.d.ts +3 -0
  65. package/build/types/core/mcp/metadata.d.ts +9 -0
  66. package/build/types/core/mcp/tracker.d.ts +9 -0
  67. package/build/types/core/middleware/compose.d.ts +8 -0
  68. package/build/types/core/middleware/index.d.ts +2 -0
  69. package/build/types/core/middleware/pipeline.d.ts +12 -0
  70. package/build/types/core/plugins/index.d.ts +2 -0
  71. package/build/types/core/plugins/plugin.d.ts +2 -0
  72. package/build/types/core/plugins/scope.d.ts +15 -0
  73. package/build/types/core/process.util.d.ts +1 -0
  74. package/build/types/core/raiton.d.ts +15 -0
  75. package/build/types/core/router/handler.d.ts +2 -0
  76. package/build/types/core/router/handler.utils.d.ts +37 -0
  77. package/build/types/core/router/index.d.ts +4 -0
  78. package/build/types/core/router/matcher.d.ts +50 -0
  79. package/build/types/core/router/route.d.ts +52 -0
  80. package/build/types/core/router/router.d.ts +23 -0
  81. package/build/types/core/scheduler/builder.d.ts +2 -0
  82. package/build/types/core/scheduler/cron.d.ts +32 -0
  83. package/build/types/core/scheduler/duration.d.ts +7 -0
  84. package/build/types/core/scheduler/index.d.ts +6 -0
  85. package/build/types/core/scheduler/manager.d.ts +47 -0
  86. package/build/types/core/scheduler/metadata.d.ts +8 -0
  87. package/build/types/core/scheduler/queue/backend.d.ts +42 -0
  88. package/build/types/core/scheduler/queue/index.d.ts +3 -0
  89. package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
  90. package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
  91. package/build/types/core/server.d.ts +9 -0
  92. package/build/types/core/socket/builder.d.ts +1 -0
  93. package/build/types/core/socket/index.d.ts +2 -0
  94. package/build/types/core/socket/metadata.d.ts +14 -0
  95. package/build/types/core/thread.d.ts +21 -0
  96. package/build/types/framework/artifacts.d.ts +20 -0
  97. package/build/types/framework/cache/cache.d.ts +84 -0
  98. package/build/types/framework/cache/cache.decorator.d.ts +21 -0
  99. package/build/types/framework/cache/etag.d.ts +62 -0
  100. package/build/types/framework/cache/index.d.ts +4 -0
  101. package/build/types/framework/cache/types.d.ts +89 -0
  102. package/build/types/framework/constants/decorators.constant.d.ts +28 -0
  103. package/build/types/framework/constants/index.d.ts +2 -0
  104. package/build/types/framework/constants/microservices.constant.d.ts +3 -0
  105. package/build/types/framework/controllers.d.ts +2 -0
  106. package/build/types/framework/data-transfer-object.d.ts +5 -0
  107. package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
  108. package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
  109. package/build/types/framework/decorators/api.decorator.d.ts +160 -0
  110. package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
  111. package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
  112. package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
  113. package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
  114. package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
  115. package/build/types/framework/decorators/index.d.ts +15 -0
  116. package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
  117. package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
  118. package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
  119. package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
  120. package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
  121. package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
  122. package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
  123. package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
  124. package/build/types/framework/encryption.d.ts +25 -0
  125. package/build/types/framework/enums/csrf.enum.d.ts +4 -0
  126. package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
  127. package/build/types/framework/enums/event.message.enum.d.ts +4 -0
  128. package/build/types/framework/enums/http-method.enum.d.ts +10 -0
  129. package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
  130. package/build/types/framework/enums/http-status.enum.d.ts +64 -0
  131. package/build/types/framework/enums/index.d.ts +9 -0
  132. package/build/types/framework/enums/runtime.enum.d.ts +5 -0
  133. package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
  134. package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
  135. package/build/types/framework/env.d.ts +3 -0
  136. package/build/types/framework/errors/catalog.d.ts +42 -0
  137. package/build/types/framework/exceptions/http-exception.d.ts +18 -0
  138. package/build/types/framework/exceptions/index.d.ts +2 -0
  139. package/build/types/framework/exceptions/throwable.d.ts +76 -0
  140. package/build/types/framework/health-check.d.ts +42 -0
  141. package/build/types/framework/index.d.ts +20 -0
  142. package/build/types/framework/mcp/audit.d.ts +12 -0
  143. package/build/types/framework/mcp/conformance.d.ts +31 -0
  144. package/build/types/framework/mcp/handler.d.ts +11 -0
  145. package/build/types/framework/mcp/index.d.ts +5 -0
  146. package/build/types/framework/mcp/protocol.d.ts +17 -0
  147. package/build/types/framework/mcp/rate-limit.d.ts +10 -0
  148. package/build/types/framework/mcp/stdio.d.ts +40 -0
  149. package/build/types/framework/mcp/streamable-http.d.ts +17 -0
  150. package/build/types/framework/observability/index.d.ts +6 -0
  151. package/build/types/framework/observability/metrics.d.ts +23 -0
  152. package/build/types/framework/observability/plugin.d.ts +20 -0
  153. package/build/types/framework/observability/readiness.d.ts +9 -0
  154. package/build/types/framework/observability/request.d.ts +7 -0
  155. package/build/types/framework/observability/shutdown.d.ts +21 -0
  156. package/build/types/framework/observability/trace.d.ts +96 -0
  157. package/build/types/framework/parameter-bag.d.ts +14 -0
  158. package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
  159. package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
  160. package/build/types/framework/plugins/index.d.ts +5 -0
  161. package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
  162. package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
  163. package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
  164. package/build/types/framework/plugins/security/cors.d.ts +10 -0
  165. package/build/types/framework/plugins/security/csrf.d.ts +2 -0
  166. package/build/types/framework/plugins/security/headers.d.ts +1 -0
  167. package/build/types/framework/plugins/security/index.d.ts +13 -0
  168. package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
  169. package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
  170. package/build/types/framework/repositories.d.ts +5 -0
  171. package/build/types/framework/responses/error.d.ts +13 -0
  172. package/build/types/framework/responses/helpers.d.ts +7 -0
  173. package/build/types/framework/responses/http-throwable.d.ts +14 -0
  174. package/build/types/framework/responses/http.d.ts +13 -0
  175. package/build/types/framework/responses/index.d.ts +4 -0
  176. package/build/types/framework/runtime/bun/server.d.ts +2 -0
  177. package/build/types/framework/runtime/deno/server.d.ts +2 -0
  178. package/build/types/framework/runtime/index.d.ts +17 -0
  179. package/build/types/framework/runtime/node/reply.d.ts +12 -0
  180. package/build/types/framework/runtime/node/request.d.ts +33 -0
  181. package/build/types/framework/runtime/node/server.d.ts +2 -0
  182. package/build/types/framework/runtime/web/server.d.ts +1 -0
  183. package/build/types/framework/services.d.ts +5 -0
  184. package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
  185. package/build/types/framework/utilities/artifact.util.d.ts +7 -0
  186. package/build/types/framework/utilities/callable.util.d.ts +1 -0
  187. package/build/types/framework/utilities/cookie.util.d.ts +1 -0
  188. package/build/types/framework/utilities/csrf.util.d.ts +26 -0
  189. package/build/types/framework/utilities/https.util.d.ts +49 -0
  190. package/build/types/framework/utilities/index.d.ts +12 -0
  191. package/build/types/framework/utilities/ip.util.d.ts +15 -0
  192. package/build/types/framework/utilities/json.util.d.ts +10 -0
  193. package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
  194. package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
  195. package/build/types/framework/utilities/path.util.d.ts +3 -0
  196. package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
  197. package/build/types/framework/utilities/url.util.d.ts +1 -0
  198. package/build/types/framework/utilities/utilities.util.d.ts +3 -0
  199. package/build/types/framework/utilities/validation.util.d.ts +8 -0
  200. package/build/types/framework/view-model.d.ts +4 -0
  201. package/build/types/generators/artifact.templates.d.ts +7 -0
  202. package/build/types/generators/index.d.ts +2 -0
  203. package/build/types/generators/project.templates.d.ts +21 -0
  204. package/build/types/manifest/client.d.ts +12 -0
  205. package/build/types/manifest/contract.d.ts +25 -0
  206. package/build/types/manifest/index.d.ts +5 -0
  207. package/build/types/manifest/introspect.d.ts +18 -0
  208. package/build/types/manifest/manifest.d.ts +18 -0
  209. package/build/types/manifest/schema.d.ts +177 -0
  210. package/build/types/requirements.d.ts +1 -0
  211. package/build/types/types/access-guards.d.ts +4 -0
  212. package/build/types/types/application.d.ts +32 -0
  213. package/build/types/types/artifact.d.ts +8 -0
  214. package/build/types/types/builder.d.ts +37 -0
  215. package/build/types/types/config.d.ts +62 -0
  216. package/build/types/types/controller.d.ts +27 -0
  217. package/build/types/types/contruct.d.ts +1 -0
  218. package/build/types/types/core.d.ts +11 -0
  219. package/build/types/types/csrf.d.ts +33 -0
  220. package/build/types/types/directory.d.ts +6 -0
  221. package/build/types/types/encryption.d.ts +14 -0
  222. package/build/types/types/generic.d.ts +2 -0
  223. package/build/types/types/guard.d.ts +9 -0
  224. package/build/types/types/http-responses.d.ts +7 -0
  225. package/build/types/types/index.d.ts +27 -0
  226. package/build/types/types/injection.d.ts +11 -0
  227. package/build/types/types/lifecycle.d.ts +9 -0
  228. package/build/types/types/mcp.d.ts +148 -0
  229. package/build/types/types/middleware.d.ts +12 -0
  230. package/build/types/types/parseable.d.ts +3 -0
  231. package/build/types/types/plugin.d.ts +6 -0
  232. package/build/types/types/raiton.d.ts +13 -0
  233. package/build/types/types/responses.d.ts +20 -0
  234. package/build/types/types/router.d.ts +13 -0
  235. package/build/types/types/runtime.d.ts +48 -0
  236. package/build/types/types/scheduler.d.ts +140 -0
  237. package/build/types/types/scheme.d.ts +125 -0
  238. package/build/types/types/server.d.ts +10 -0
  239. package/build/types/types/socket.d.ts +11 -0
  240. package/build/types/types/thread.d.ts +25 -0
  241. package/build/types/types/utilities.d.ts +4 -0
  242. package/build/types/types/values.d.ts +2 -0
  243. package/docs/AGENTS.md +55 -0
  244. package/docs/CLAUDE.md +55 -0
  245. package/docs/README.md +5 -0
  246. package/docs/contributors/cli/README.md +17 -3
  247. package/docs/contributors/cli/commands.md +28 -17
  248. package/docs/contributors/framework/plugins/openapi.md +12 -3
  249. package/docs/generated/cli/commands.md +26 -0
  250. package/docs/generated/config-schema.json +150 -0
  251. package/docs/generated/manifest-schema.json +236 -0
  252. package/docs/generated/manifest.json +101 -0
  253. package/docs/llms-full.txt +1271 -0
  254. package/docs/llms.txt +46 -0
  255. package/docs/user-guide/README.md +18 -12
  256. package/docs/user-guide/cli.md +21 -0
  257. package/docs/user-guide/config.md +14 -0
  258. package/docs/user-guide/contracts.md +67 -0
  259. package/docs/user-guide/en/README.md +83 -0
  260. package/docs/user-guide/getting-started.md +13 -1
  261. package/docs/user-guide/mcp.md +45 -2
  262. package/docs/user-guide/observability.md +74 -0
  263. package/docs/user-guide/openapi/plugin.md +10 -0
  264. package/docs/user-guide/recipes/README.md +32 -0
  265. package/docs/user-guide/recipes/contracts.md +52 -0
  266. package/docs/user-guide/recipes/doctor.md +16 -0
  267. package/docs/user-guide/recipes/generate.md +28 -0
  268. package/docs/user-guide/recipes/manifest.md +17 -0
  269. package/docs/user-guide/recipes/mcp-stdio.md +35 -0
  270. package/docs/user-guide/recipes/new-project.md +34 -0
  271. package/docs/user-guide/recipes/observability.md +17 -0
  272. package/package.json +40 -7
  273. package/scripts/bench.ts +586 -0
  274. package/scripts/postinstall.mjs +15 -0
  275. package/source/bin/cli-output.ts +139 -0
  276. package/source/bin/commands.registry.ts +23 -3
  277. package/source/bin/file-utils.ts +95 -0
  278. package/source/bin/name-utils.ts +26 -0
  279. package/source/bin/project-utils.ts +78 -0
  280. package/source/commands/artifact.command.ts +30 -15
  281. package/source/commands/client.command.ts +64 -0
  282. package/source/commands/contract.command.ts +104 -0
  283. package/source/commands/docs.command.ts +263 -0
  284. package/source/commands/doctor.command.ts +226 -0
  285. package/source/commands/generate.command.ts +58 -0
  286. package/source/commands/inspect.command.ts +108 -0
  287. package/source/commands/mcp.command.ts +258 -0
  288. package/source/commands/new.command.ts +135 -0
  289. package/source/commands/openapi.command.ts +95 -0
  290. package/source/commands/routes.command.ts +39 -0
  291. package/source/commands/why.command.ts +61 -0
  292. package/source/contracts/decorators.ts +151 -0
  293. package/source/contracts/errors.ts +76 -0
  294. package/source/contracts/index.ts +4 -0
  295. package/source/contracts/schema.ts +377 -0
  296. package/source/contracts/typebox.ts +193 -0
  297. package/source/core/application.ts +215 -73
  298. package/source/core/builder.ts +6 -2
  299. package/source/core/config/config.ts +144 -26
  300. package/source/core/config/define.ts +35 -8
  301. package/source/core/config/index.ts +2 -1
  302. package/source/core/config/schema.ts +263 -0
  303. package/source/core/controller/builder.ts +38 -13
  304. package/source/core/controller/compiler.ts +14 -7
  305. package/source/core/controller/metadata.ts +1 -1
  306. package/source/core/hooks.ts +13 -1
  307. package/source/core/injection/injection.ts +47 -9
  308. package/source/core/mcp/builder.ts +13 -2
  309. package/source/core/mcp/metadata.ts +2 -1
  310. package/source/core/middleware/compose.ts +48 -0
  311. package/source/core/middleware/pipeline.ts +69 -46
  312. package/source/core/raiton.ts +8 -0
  313. package/source/core/router/handler.ts +91 -31
  314. package/source/core/router/handler.utils.ts +107 -51
  315. package/source/core/router/matcher.ts +195 -24
  316. package/source/core/router/route.ts +100 -31
  317. package/source/core/router/router.ts +27 -2
  318. package/source/core/scheduler/metadata.ts +1 -1
  319. package/source/core/socket/metadata.ts +1 -1
  320. package/source/core/thread.ts +37 -2
  321. package/source/framework/artifacts.ts +47 -15
  322. package/source/framework/cache/cache.ts +48 -3
  323. package/source/framework/constants/decorators.constant.ts +5 -0
  324. package/source/framework/data-transfer-object.ts +4 -3
  325. package/source/framework/decorators/controllable.decorator.ts +3 -3
  326. package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
  327. package/source/framework/decorators/csrf-token.decorator.ts +1 -1
  328. package/source/framework/decorators/guard.decorator.ts +3 -2
  329. package/source/framework/decorators/health-check.decorator.ts +1 -1
  330. package/source/framework/decorators/mcp.decorator.ts +38 -7
  331. package/source/framework/decorators/middleware.decorator.ts +2 -2
  332. package/source/framework/decorators/parametrable.decorator.ts +2 -1
  333. package/source/framework/decorators/routable.decorator.ts +3 -3
  334. package/source/framework/decorators/route-interaction.decorator.ts +2 -2
  335. package/source/framework/decorators/scheduler.decorator.ts +3 -3
  336. package/source/framework/decorators/socket.decorator.ts +3 -3
  337. package/source/framework/encryption.ts +46 -7
  338. package/source/framework/errors/catalog.ts +159 -0
  339. package/source/framework/exceptions/http-exception.ts +1 -1
  340. package/source/framework/health-check.ts +18 -0
  341. package/source/framework/index.ts +2 -0
  342. package/source/framework/mcp/audit.ts +57 -0
  343. package/source/framework/mcp/conformance.ts +195 -0
  344. package/source/framework/mcp/handler.ts +131 -9
  345. package/source/framework/mcp/index.ts +6 -1
  346. package/source/framework/mcp/protocol.ts +6 -0
  347. package/source/framework/mcp/rate-limit.ts +33 -0
  348. package/source/framework/mcp/stdio.ts +150 -0
  349. package/source/framework/mcp/streamable-http.ts +36 -5
  350. package/source/framework/observability/index.ts +6 -0
  351. package/source/framework/observability/metrics.ts +162 -0
  352. package/source/framework/observability/plugin.ts +151 -0
  353. package/source/framework/observability/readiness.ts +22 -0
  354. package/source/framework/observability/request.ts +31 -0
  355. package/source/framework/observability/shutdown.ts +68 -0
  356. package/source/framework/observability/trace.ts +241 -0
  357. package/source/framework/plugins/body-parser.plugin.ts +88 -85
  358. package/source/framework/plugins/dev.plugin.ts +227 -0
  359. package/source/framework/plugins/index.ts +2 -1
  360. package/source/framework/plugins/mcp.plugin.ts +14 -3
  361. package/source/framework/plugins/openapi.plugin.ts +56 -13
  362. package/source/framework/responses/helpers.ts +4 -4
  363. package/source/framework/responses/http-throwable.ts +1 -1
  364. package/source/framework/runtime/bun/server.ts +2 -1
  365. package/source/framework/runtime/deno/server.ts +2 -1
  366. package/source/framework/runtime/index.ts +45 -13
  367. package/source/framework/runtime/node/request.ts +59 -13
  368. package/source/framework/utilities/index.ts +3 -1
  369. package/source/framework/utilities/openapi.utils.impl.ts +705 -0
  370. package/source/framework/utilities/openapi.utils.ts +6 -636
  371. package/source/framework/utilities/route-suggestion.util.ts +59 -0
  372. package/source/framework/utilities/validation.util.ts +20 -0
  373. package/source/generators/artifact.templates.ts +230 -0
  374. package/source/generators/index.ts +2 -0
  375. package/source/generators/project.templates.ts +392 -0
  376. package/source/manifest/client.ts +299 -0
  377. package/source/manifest/contract.ts +138 -0
  378. package/source/manifest/index.ts +5 -0
  379. package/source/manifest/introspect.ts +52 -0
  380. package/source/manifest/manifest.ts +341 -0
  381. package/source/manifest/schema.ts +149 -0
  382. package/source/types/builder.ts +5 -0
  383. package/source/types/config.ts +64 -2
  384. package/source/types/mcp.ts +63 -1
  385. package/tsconfig.build.json +13 -0
  386. package/source/commands/grafts.command.ts +0 -27
  387. package/tests/artifact-resolution.test.ts +0 -60
@@ -0,0 +1,263 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import {RaitonCommand} from "../core/command.ts";
4
+ import {CLI_JSON_SCHEMA_VERSION, ExitCode, fail, print, silenceStdout} from "../bin/cli-output.ts";
5
+ import {RaitonConfig} from "../core/config/config.ts";
6
+ import {getConfigJsonSchema} from "../core/config/schema.ts";
7
+ import {generateManifest} from "../manifest/manifest.ts";
8
+ import {manifestJsonSchema} from "../manifest/schema.ts";
9
+ import type {ProjectManifest} from "../manifest/schema.ts";
10
+
11
+ interface DocsOptions {
12
+ out?: string;
13
+ check?: boolean;
14
+ json?: boolean;
15
+ }
16
+
17
+ const COMMANDS = [
18
+ ["new <name>", "Create a project from a template"],
19
+ ["generate <type> <name>", "Generate controller, service, repository, dto, mcp-tool, test or resource"],
20
+ ["routes", "List mounted routes"],
21
+ ["inspect", "Emit the versioned project manifest"],
22
+ ["why <method> <path>", "Explain which file registered a route"],
23
+ ["doctor", "Diagnose runtime, configuration and prerequisites"],
24
+ ["openapi export", "Export the OpenAPI document"],
25
+ ["client", "Generate a typed client"],
26
+ ["contract check", "Detect breaking contract changes"],
27
+ ["contract snapshot", "Write a contract baseline"],
28
+ ["mcp list", "List MCP servers"],
29
+ ["mcp inspect <server>", "Inspect MCP schemas and safety annotations"],
30
+ ["mcp test <server>.<tool>", "Call an MCP tool"],
31
+ ["mcp serve [server]", "Serve an MCP server over stdio"],
32
+ ["mcp conformance [server]", "Run the HTTP + stdio conformance suite"],
33
+ ["docs agents", "Generate llms.txt, llms-full.txt, AGENTS.md and CLAUDE.md"],
34
+ ["artifact --dump", "Inspect detected artifacts"],
35
+ ["dev", "Run the application with HMR"],
36
+ ["build", "Build the application"],
37
+ ["start", "Run the application in production"],
38
+ ] as const;
39
+
40
+ const GUIDE_FILES = [
41
+ "user-guide/getting-started.md",
42
+ "user-guide/architecture.md",
43
+ "user-guide/cli.md",
44
+ "user-guide/config.md",
45
+ "user-guide/api/routes.md",
46
+ "user-guide/responses.md",
47
+ "user-guide/injection.md",
48
+ "user-guide/contracts.md",
49
+ "user-guide/mcp.md",
50
+ "user-guide/observability.md",
51
+ "user-guide/decorators/README.md",
52
+ "user-guide/recipes/README.md",
53
+ "user-guide/en/README.md",
54
+ "user-guide/best-practices.md",
55
+ ];
56
+
57
+ function relativeRoutes(manifest: ProjectManifest): string {
58
+ if (!manifest.routes.length) return "No route is currently mounted.";
59
+ return manifest.routes
60
+ .map(route => `- \`${route.method} ${route.path}\` → \`${route.controller}.${route.handler}\` (\`${route.file}${route.line ? `:${route.line}` : ""}\`)`)
61
+ .join("\n");
62
+ }
63
+
64
+ function compactIndex(manifest: ProjectManifest): string {
65
+ return `# Raiton
66
+
67
+ > Modular TypeScript backend framework with dependency injection, plugins, schema-first contracts, MCP (HTTP + stdio), observability and typed CLI tooling.
68
+
69
+ ## Start
70
+
71
+ - [Getting started](user-guide/getting-started.md): create, run and test a project in under five minutes.
72
+ - [Configuration](user-guide/config.md): \`raiton.config.ts\` is typed and validated before the port opens.
73
+ - [Contracts](user-guide/recipes/contracts.md): one schema feeds validation, TypeScript types, OpenAPI and the generated client.
74
+ - [MCP](user-guide/mcp.md): expose tools over HTTP and stdio with safety annotations.
75
+ - [Observability](user-guide/observability.md): correlation ids, Prometheus metrics, OTLP traces and graceful shutdown.
76
+
77
+ ## Commands
78
+
79
+ ${COMMANDS.map(([command, description]) => `- \`raiton ${command}\`: ${description}`).join("\n")}
80
+
81
+ ## Project inventory
82
+
83
+ - Framework: ${manifest.framework.name} ${manifest.framework.version}
84
+ - Runtime: ${manifest.runtime}
85
+ - Manifest schema: ${manifest.schemaVersion}
86
+ - Routes: ${manifest.routes.length}
87
+ - MCP servers: ${manifest.mcp.length}
88
+
89
+ ## Routes
90
+
91
+ ${relativeRoutes(manifest)}
92
+ `;
93
+ }
94
+
95
+ function fullReference(manifest: ProjectManifest, docsDir: string): string {
96
+ const sections: string[] = [compactIndex(manifest)];
97
+ for (const file of GUIDE_FILES) {
98
+ const filename = path.join(docsDir, file);
99
+ if (!fs.existsSync(filename)) continue;
100
+ sections.push(`\n\n<!-- ${file} -->\n\n${fs.readFileSync(filename, "utf-8")}`);
101
+ }
102
+ sections.push(`\n\n## Generated manifest\n\n\`\`\`json\n${JSON.stringify(manifest, null, 2)}\n\`\`\`\n`);
103
+ return sections.join("");
104
+ }
105
+
106
+ function agentsGuide(manifest: ProjectManifest): string {
107
+ return `# AGENTS.md — Raiton conventions
108
+
109
+ This repository uses **Raiton** (${manifest.framework.name} ${manifest.framework.version}).
110
+
111
+ ## Deterministic commands
112
+
113
+ Always prefer the CLI over guessing conventions:
114
+
115
+ \`\`\`bash
116
+ raiton routes --json # mounted routes
117
+ raiton inspect --json # versioned manifest (routes, DI, config, env, MCP)
118
+ raiton why GET /path # source file + decorator for a route
119
+ raiton doctor --json # actionable diagnostics
120
+ raiton mcp list --json # MCP servers and tool exposure
121
+ \`\`\`
122
+
123
+ Machine-readable commands write a single JSON document on stdout and logs on stderr.
124
+ Exit codes: 0 success, 1 usage, 2 prerequisite missing, 3 file conflict, 4 diagnostic failure.
125
+
126
+ ## Project layout
127
+
128
+ - \`source/main.ts\` — default export receives the thread and calls \`thread.setup({application}).run()\`.
129
+ - \`source/**/*.controller.ts\` — controllers using \`@Controllable\` and \`@Get/@Post/...\`.
130
+ - \`source/**/*.service.ts\`, \`.repository.ts\`, \`.dto.ts\` — dependency-injected artifacts.
131
+ - \`source/**/*.mcp.ts\` — MCP servers using \`@McpServer\` / \`@McpTool\`.
132
+ - \`raiton.config.ts\` — typed project configuration, validated before listening.
133
+
134
+ ## Contracts
135
+
136
+ Define each route contract once with TypeBox:
137
+
138
+ \`\`\`ts
139
+ import {t} from "raiton/contracts"
140
+
141
+ export const CreateUser = t.object({email: t.string().email()})
142
+ export type CreateUser = t.infer<typeof CreateUser>
143
+ \`\`\`
144
+
145
+ Use \`@Input(CreateUser)\` and \`@Output(User)\`. Invalid input is rejected before the handler with
146
+ \`{error: true, code: "VALIDATION_ERROR", details: [{path, code, message}]}\`.
147
+
148
+ ## Known traps
149
+
150
+ - Destructive MCP tools are hidden unless \`mcp.exposeDestructive\` or the server option is explicit.
151
+ - Output validation is enabled in development only by default; do not rely on it in production.
152
+ - Do not edit generated files under \`docs/generated\`; run \`raiton docs agents\`.
153
+ - Never overwrite generated files without \`--force\`; use \`--dry-run\` first.
154
+
155
+ ## Routes in this project
156
+
157
+ ${relativeRoutes(manifest)}
158
+
159
+ ## MCP
160
+
161
+ ${manifest.mcp.length
162
+ ? manifest.mcp.map(server => `- \`${server.server}\` at \`${server.path}\`: ${server.tools.map(tool => `\`${tool.name}\`${tool.exposed ? "" : " (hidden)"}`).join(", ")}`).join("\n")
163
+ : "No MCP server registered."}
164
+ `;
165
+ }
166
+
167
+ function cliReference(): string {
168
+ return `# CLI reference\n\nGenerated by \`raiton docs agents\`. Do not edit by hand.\n\n| Command | Description |\n|---|---|\n${
169
+ COMMANDS.map(([command, description]) => `| \`raiton ${command}\` | ${description} |`).join("\n")
170
+ }\n`;
171
+ }
172
+
173
+ export default class DocsCommand extends RaitonCommand {
174
+ public readonly name = "docs";
175
+ public readonly description = "Generate agent-oriented and reference documentation";
176
+
177
+ public register(): void {
178
+ const command = this.cli
179
+ .command("docs")
180
+ .description(this.description);
181
+
182
+ command
183
+ .command("agents")
184
+ .description("Generate llms.txt, llms-full.txt, AGENTS.md, CLAUDE.md and generated references")
185
+ .option("--out <directory>", "Documentation directory", "docs")
186
+ .option("--check", "Fail if generated documentation is stale")
187
+ .option("--json", "Emit a machine-readable result on stdout")
188
+ .action((options: DocsOptions) => this.run(options).catch(error => fail(error, options.json)));
189
+ }
190
+
191
+ private async run(options: DocsOptions): Promise<void> {
192
+ const execute = async () => this.generate(options);
193
+ const result = options.json ? await silenceStdout(execute) : await execute();
194
+
195
+ if (options.json) {
196
+ print(result, true);
197
+ return;
198
+ }
199
+
200
+ if (result.stale.length) {
201
+ print("Generated documentation is stale:");
202
+ for (const file of result.stale) print(` - ${file}`);
203
+ print("Run `raiton docs agents` to regenerate.");
204
+ } else if (options.check) {
205
+ print("Generated documentation is up to date.");
206
+ } else {
207
+ print(`Generated ${result.files.length} documentation file(s) in ${result.output}.`);
208
+ }
209
+
210
+ if (result.stale.length) process.exitCode = ExitCode.DIAGNOSTIC_FAILED;
211
+ }
212
+
213
+ private async generate(options: DocsOptions): Promise<{
214
+ schemaVersion: string;
215
+ output: string;
216
+ files: string[];
217
+ stale: string[];
218
+ }> {
219
+ await RaitonConfig.sync(this.workdir, {force: true});
220
+ let current: ProjectManifest;
221
+ try {
222
+ const {loadProject} = await import("../bin/project-utils.ts");
223
+ current = (await loadProject(this.workdir, true)).manifest;
224
+ } catch {
225
+ // Projects without a bootstrapper can still publish a partial
226
+ // inventory (configuration, env names, detected artifacts).
227
+ current = generateManifest({refresh: true, workdir: this.workdir});
228
+ }
229
+ // Generated docs must be reproducible in CI: timestamps are excluded.
230
+ const manifest: ProjectManifest = {...current, generatedAt: "generated"};
231
+ const docsDir = path.resolve(this.workdir, options.out ?? "docs");
232
+
233
+ const generated: Record<string, string> = {
234
+ "llms.txt": compactIndex(manifest),
235
+ "llms-full.txt": fullReference(manifest, docsDir),
236
+ "AGENTS.md": agentsGuide(manifest),
237
+ "CLAUDE.md": agentsGuide(manifest),
238
+ "generated/manifest-schema.json": JSON.stringify(manifestJsonSchema(), null, 2) + "\n",
239
+ "generated/config-schema.json": JSON.stringify(getConfigJsonSchema(), null, 2) + "\n",
240
+ "generated/cli/commands.md": cliReference(),
241
+ "generated/manifest.json": JSON.stringify(manifest, null, 2) + "\n",
242
+ };
243
+
244
+ const stale: string[] = [];
245
+ if (options.check) {
246
+ for (const [relative, content] of Object.entries(generated)) {
247
+ const filename = path.join(docsDir, relative);
248
+ if (!fs.existsSync(filename) || fs.readFileSync(filename, "utf-8") !== content) {
249
+ stale.push(relative);
250
+ }
251
+ }
252
+ return {schemaVersion: CLI_JSON_SCHEMA_VERSION, output: docsDir, files: Object.keys(generated), stale};
253
+ }
254
+
255
+ for (const [relative, content] of Object.entries(generated)) {
256
+ const filename = path.join(docsDir, relative);
257
+ fs.mkdirSync(path.dirname(filename), {recursive: true});
258
+ fs.writeFileSync(filename, content, "utf-8");
259
+ }
260
+
261
+ return {schemaVersion: CLI_JSON_SCHEMA_VERSION, output: docsDir, files: Object.keys(generated), stale: []};
262
+ }
263
+ }
@@ -0,0 +1,226 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import net from "node:net";
4
+ import {RaitonCommand} from "../core/command.ts";
5
+ import {CLI_JSON_SCHEMA_VERSION, ExitCode, fail, print, silenceStdout} from "../bin/cli-output.ts";
6
+ import {RaitonConfig} from "../core/config/config.ts";
7
+ import {errorDocsUrl} from "../framework/errors/catalog.ts";
8
+ import {loadProject} from "../bin/project-utils.ts";
9
+ import {isBunUsed, isDenoUsed} from "../bin/constants.ts";
10
+
11
+ type Severity = "error" | "warning" | "info";
12
+
13
+ interface DiagnosticIssue {
14
+ code: string;
15
+ severity: Severity;
16
+ message: string;
17
+ action: string;
18
+ docsUrl: string;
19
+ location?: string;
20
+ }
21
+
22
+ interface DoctorOptions {
23
+ json?: boolean;
24
+ fix?: boolean;
25
+ }
26
+
27
+ function runtimeVersion(): {name: string; version: string} {
28
+ const versions = process.versions as any;
29
+ if (isBunUsed) return {name: "bun", version: versions.bun ?? "unknown"};
30
+ if (isDenoUsed) return {name: "deno", version: versions.deno ?? "unknown"};
31
+ return {name: "node", version: versions.node ?? "unknown"};
32
+ }
33
+
34
+ function portAvailable(port: number): Promise<boolean> {
35
+ return new Promise(resolve => {
36
+ const server = net.createServer();
37
+ server.once("error", () => resolve(false));
38
+ server.once("listening", () => server.close(() => resolve(true)));
39
+ server.listen(port, "127.0.0.1");
40
+ });
41
+ }
42
+
43
+ export default class DoctorCommand extends RaitonCommand {
44
+ public readonly name = "doctor";
45
+ public readonly description = "Diagnose the runtime, configuration and project prerequisites";
46
+
47
+ public register(): void {
48
+ this.cli
49
+ .command("doctor")
50
+ .description(this.description)
51
+ .option("--json", "Emit diagnostics as JSON on stdout")
52
+ .option("--fix", "Apply safe, non-destructive fixes")
53
+ .action((options: DoctorOptions) => this.run(options).catch(error => fail(error, options.json)));
54
+ }
55
+
56
+ private async run(options: DoctorOptions): Promise<void> {
57
+ const execute = async () => this.diagnose(options);
58
+ const result = options.json ? await silenceStdout(execute) : await execute();
59
+
60
+ if (options.json) {
61
+ print(result, true);
62
+ } else {
63
+ for (const issue of result.issues) {
64
+ const label = issue.severity.toUpperCase().padEnd(7);
65
+ print(`${label} [${issue.code}] ${issue.message}`);
66
+ print(` action: ${issue.action}`);
67
+ if (issue.location) print(` location: ${issue.location}`);
68
+ }
69
+ if (!result.issues.length) print("No issue detected.");
70
+ else print(`\n${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${result.summary.infos} info.`);
71
+ if (result.fixed.length) print(`Applied fixes: ${result.fixed.join(", ")}`);
72
+ }
73
+
74
+ if (result.summary.errors > 0) process.exitCode = ExitCode.DIAGNOSTIC_FAILED;
75
+ }
76
+
77
+ private async diagnose(options: DoctorOptions): Promise<{
78
+ schemaVersion: string;
79
+ issues: DiagnosticIssue[];
80
+ summary: {errors: number; warnings: number; infos: number};
81
+ fixed: string[];
82
+ runtime: {name: string; version: string};
83
+ }> {
84
+ const issues: DiagnosticIssue[] = [];
85
+ const fixed: string[] = [];
86
+ const add = (
87
+ code: string,
88
+ severity: Severity,
89
+ message: string,
90
+ action: string,
91
+ docsPath = "user-guide/cli.md",
92
+ location?: string,
93
+ ) => issues.push({code, severity, message, action, docsUrl: errorDocsUrl(docsPath), location});
94
+
95
+ const runtime = runtimeVersion();
96
+ add("RUNTIME", "info", `Runtime: ${runtime.name} ${runtime.version}`, "No action required.");
97
+
98
+ const packageFile = path.join(this.workdir, "package.json");
99
+ if (!fs.existsSync(packageFile)) {
100
+ add("PACKAGE_MISSING", "error", "package.json not found", "Run `raiton new` or create a package.json.", "user-guide/getting-started.md", packageFile);
101
+ } else {
102
+ try {
103
+ const pkg = JSON.parse(fs.readFileSync(packageFile, "utf-8"));
104
+ const raitonVersion = pkg.dependencies?.raiton ?? pkg.devDependencies?.raiton;
105
+ if (raitonVersion) {
106
+ add("FRAMEWORK_VERSION", "info", `Raiton dependency: ${raitonVersion}`, "No action required.");
107
+ }
108
+ if (!pkg.dependencies?.raiton && !pkg.devDependencies?.raiton) {
109
+ add("RAITON_MISSING", "error", "The `raiton` dependency is not declared", "Run `bun add raiton` in the project.", "user-guide/getting-started.md", packageFile);
110
+ }
111
+ if (!pkg.dependencies?.["reflect-metadata"] && !pkg.devDependencies?.["reflect-metadata"]) {
112
+ add("REFLECT_METADATA_MISSING", "warning", "`reflect-metadata` is not declared", "Run `bun add reflect-metadata` and import it in main.ts.", "user-guide/getting-started.md", packageFile);
113
+ }
114
+ } catch (error: any) {
115
+ add("PACKAGE_INVALID", "error", `package.json is invalid JSON: ${error.message}`, "Fix package.json syntax.", "user-guide/getting-started.md", packageFile);
116
+ }
117
+ }
118
+
119
+ await RaitonConfig.sync(this.workdir, {force: true});
120
+ if (!RaitonConfig.source) {
121
+ add("CONFIG_MISSING", "warning", "No raiton.config.ts/js/json found", "Run `raiton new` or add a raiton.config.ts file.", "user-guide/config.md", this.workdir);
122
+ }
123
+ for (const configError of RaitonConfig.errors) {
124
+ add("CONFIG_FIELD", "error", `Configuration: ${configError.field} ${configError.message}`, "Fix the field in raiton.config.*.", "user-guide/config.md", RaitonConfig.source ?? undefined);
125
+ }
126
+
127
+ const root = path.resolve(this.workdir, RaitonConfig.get("rootDir") || "./");
128
+ if (!fs.existsSync(root)) {
129
+ add("SOURCE_MISSING", "error", `Source directory not found: ${path.relative(this.workdir, root)}`, "Create the directory or fix rootDir.", "user-guide/config.md", root);
130
+ }
131
+ const entry = path.join(root, "main.ts");
132
+ if (!fs.existsSync(entry)) {
133
+ add("ENTRY_MISSING", "error", "Entry point source/main.ts not found", "Create source/main.ts exporting a default bootstrapper.", "user-guide/getting-started.md", entry);
134
+ }
135
+
136
+ const tsconfig = path.join(this.workdir, "tsconfig.json");
137
+ if (!fs.existsSync(tsconfig)) {
138
+ add("TSCONFIG_MISSING", "warning", "tsconfig.json not found", "Add a tsconfig with experimentalDecorators and emitDecoratorMetadata.", "user-guide/getting-started.md", tsconfig);
139
+ } else {
140
+ const content = fs.readFileSync(tsconfig, "utf-8");
141
+ if (!content.includes("experimentalDecorators")) {
142
+ add("DECORATORS_DISABLED", "warning", "tsconfig.json does not enable experimentalDecorators", "Enable experimentalDecorators for controllers and MCP tools.", "user-guide/getting-started.md", tsconfig);
143
+ }
144
+ if (!content.includes("emitDecoratorMetadata")) {
145
+ add("DECORATOR_METADATA_DISABLED", "warning", "tsconfig.json does not enable emitDecoratorMetadata", "Enable emitDecoratorMetadata so dependency injection can resolve types.", "user-guide/injection.md", tsconfig);
146
+ }
147
+ }
148
+
149
+ const port = RaitonConfig.get("port");
150
+ if (port) {
151
+ if (!(await portAvailable(port))) {
152
+ add("PORT_IN_USE", "error", `Port ${port} is already in use or unavailable`, `Stop the process using port ${port} or change the port in raiton.config.ts.`, "user-guide/config.md");
153
+ } else {
154
+ add("PORT_AVAILABLE", "info", `Port ${port} is available`, "No action required.");
155
+ }
156
+ }
157
+
158
+ // Project-level introspection: decorators, routes, MCP and env coverage.
159
+ try {
160
+ const {manifest} = await loadProject(this.workdir, true);
161
+ const envIssue = await this.fixEnv(manifest.env, options.fix, fixed);
162
+ if (envIssue) add(...envIssue);
163
+
164
+ const applicationRoutes = manifest.routes.filter(route => route.controller !== "Application");
165
+ if (applicationRoutes.length === 0) {
166
+ add("NO_ROUTES", "warning", "No controller route was registered", "Add a `@Controllable` controller in source/.", "user-guide/decorators/controllable.md");
167
+ } else {
168
+ add("ROUTES", "info", `${applicationRoutes.length} controller route(s) registered`, "No action required.");
169
+ }
170
+
171
+ if (manifest.artifacts.length === 0) {
172
+ add("NO_ARTIFACTS", "warning", "No artifact file was detected", "Use the documented filename suffixes (e.g. `.controller.ts`, `.service.ts`).", "user-guide/architecture.md");
173
+ }
174
+
175
+ for (const name of manifest.env) {
176
+ if (process.env[name] === undefined) {
177
+ add("ENV_MISSING", "warning", `Environment variable ${name} is not set`, `Add ${name} to .env or the process environment.`, "user-guide/env.md");
178
+ }
179
+ }
180
+
181
+ for (const server of manifest.mcp) {
182
+ const hidden = server.tools.filter(tool => !tool.exposed);
183
+ if (hidden.length) {
184
+ add("MCP_DESTRUCTIVE_HIDDEN", "info", `${hidden.length} destructive MCP tool(s) hidden in ${server.server}`, "Set mcp.exposeDestructive=true or server exposeDestructive:true to expose them.", "user-guide/mcp.md");
185
+ }
186
+ }
187
+ } catch (error: any) {
188
+ if (error?.code !== "PREREQUISITE_MISSING") {
189
+ add("INTROSPECTION_FAILED", "error", `Could not inspect the project: ${error.message}`, "Fix the bootstrapper, then run `raiton doctor` again.", "user-guide/cli.md");
190
+ }
191
+ }
192
+
193
+ const summary = {
194
+ errors: issues.filter(issue => issue.severity === "error").length,
195
+ warnings: issues.filter(issue => issue.severity === "warning").length,
196
+ infos: issues.filter(issue => issue.severity === "info").length,
197
+ };
198
+
199
+ return {schemaVersion: CLI_JSON_SCHEMA_VERSION, issues, summary, fixed, runtime};
200
+ }
201
+
202
+ private async fixEnv(
203
+ names: string[],
204
+ fix: boolean | undefined,
205
+ fixed: string[],
206
+ ): Promise<[string, Severity, string, string, string, string?] | null> {
207
+ if (!names.length) return null;
208
+ const file = path.join(this.workdir, ".env.example");
209
+ if (fs.existsSync(file)) return null;
210
+
211
+ if (fix) {
212
+ fs.writeFileSync(file, names.map(name => `${name}=`).join("\n") + "\n", "utf-8");
213
+ fixed.push(".env.example");
214
+ return null;
215
+ }
216
+
217
+ return [
218
+ "ENV_EXAMPLE_MISSING",
219
+ "warning",
220
+ `.env.example is missing (${names.length} variable(s) detected)`,
221
+ "Run `raiton doctor --fix` to generate it.",
222
+ "user-guide/env.md",
223
+ file,
224
+ ];
225
+ }
226
+ }
@@ -0,0 +1,58 @@
1
+ import {RaitonCommand} from "../core/command.ts";
2
+ import {CLI_JSON_SCHEMA_VERSION, fail, print} from "../bin/cli-output.ts";
3
+ import {writeFiles} from "../bin/file-utils.ts";
4
+ import {artifactFiles, assertArtifactType} from "../generators/artifact.templates.ts";
5
+
6
+ interface GenerateOptions {
7
+ dryRun?: boolean;
8
+ force?: boolean;
9
+ json?: boolean;
10
+ }
11
+
12
+ export default class GenerateCommand extends RaitonCommand {
13
+ public readonly name = "generate";
14
+ public readonly description = "Generate a framework artifact";
15
+
16
+ public register(): void {
17
+ this.cli
18
+ .command("generate <type> <name>")
19
+ .alias("g")
20
+ .description("Generate an artifact: controller, service, repository, dto, mcp-tool, test, resource")
21
+ .option("--dry-run", "Print the file plan without writing anything")
22
+ .option("--force", "Overwrite existing files explicitly")
23
+ .option("--json", "Emit a machine-readable result on stdout")
24
+ .action((type: string, name: string, options: GenerateOptions) =>
25
+ this.run(type, name, options).catch(error => fail(error, options.json)));
26
+ }
27
+
28
+ private async run(type: string, name: string, options: GenerateOptions): Promise<void> {
29
+ const artifactType = assertArtifactType(type);
30
+ const files = artifactFiles(artifactType, name);
31
+ const result = writeFiles(this.workdir, files, {
32
+ force: options.force,
33
+ dryRun: options.dryRun,
34
+ });
35
+
36
+ const payload = {
37
+ schemaVersion: CLI_JSON_SCHEMA_VERSION,
38
+ status: options.dryRun ? "planned" : "generated",
39
+ type: artifactType,
40
+ name,
41
+ files: result.files,
42
+ };
43
+
44
+ if (options.json) {
45
+ print(payload, true);
46
+ return;
47
+ }
48
+
49
+ if (options.dryRun) {
50
+ print(`Would generate ${payload.files.length} file(s):`);
51
+ for (const file of payload.files) print(` - ${file}`);
52
+ return;
53
+ }
54
+
55
+ print(`Generated ${artifactType} "${name}":`);
56
+ for (const file of payload.files) print(` - ${file}`);
57
+ }
58
+ }
@@ -0,0 +1,108 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import {RaitonCommand} from "../core/command.ts";
4
+ import {CLI_JSON_SCHEMA_VERSION, CliError, ExitCode, fail, print, silenceStdout} from "../bin/cli-output.ts";
5
+ import {loadProject} from "../bin/project-utils.ts";
6
+ import {writeManifest} from "../manifest/manifest.ts";
7
+ import {manifestJsonSchema, validateManifest} from "../manifest/schema.ts";
8
+ import {getConfigJsonSchema} from "../core/config/schema.ts";
9
+ import {RaitonConfig} from "../core/config/config.ts";
10
+
11
+ interface InspectOptions {
12
+ json?: boolean;
13
+ out?: string;
14
+ schema?: boolean;
15
+ configSchema?: boolean;
16
+ check?: boolean;
17
+ force?: boolean;
18
+ }
19
+
20
+ export default class InspectCommand extends RaitonCommand {
21
+ public readonly name = "inspect";
22
+ public readonly description = "Emit the machine-readable project inventory";
23
+
24
+ public register(): void {
25
+ this.cli
26
+ .command("inspect")
27
+ .description(this.description)
28
+ .option("--json", "Emit the manifest as JSON on stdout")
29
+ .option("--out <file>", "Write the manifest to a file")
30
+ .option("--schema", "Print the published manifest JSON Schema")
31
+ .option("--config-schema", "Print the published configuration JSON Schema")
32
+ .option("--check", "Validate the manifest and exit non-zero on schema errors")
33
+ .option("--force", "Overwrite an existing manifest output file")
34
+ .action((options: InspectOptions) => this.run(options).catch(error => fail(error, options.json)));
35
+ }
36
+
37
+ private async run(options: InspectOptions): Promise<void> {
38
+ if (options.schema) {
39
+ print(manifestJsonSchema(), true);
40
+ return;
41
+ }
42
+
43
+ if (options.configSchema) {
44
+ print(await silenceStdout(async () => {
45
+ await RaitonConfig.sync(this.workdir, {force: true});
46
+ return getConfigJsonSchema();
47
+ }), true);
48
+ return;
49
+ }
50
+
51
+ const {manifest} = await loadProject(this.workdir, options.json);
52
+ const validation = validateManifest(manifest);
53
+
54
+ if (!validation.valid) {
55
+ const error = new CliError("Manifest does not match its published schema", {
56
+ code: "INVALID_MANIFEST",
57
+ hint: "This is a framework bug; include the errors in a GitHub issue.",
58
+ details: validation.errors,
59
+ exitCode: ExitCode.DIAGNOSTIC_FAILED,
60
+ } as any);
61
+ if (options.json) {
62
+ print({
63
+ error: true,
64
+ schemaVersion: CLI_JSON_SCHEMA_VERSION,
65
+ code: "INVALID_MANIFEST",
66
+ details: validation.errors,
67
+ docsUrl: error.docsUrl,
68
+ }, true);
69
+ process.exitCode = ExitCode.DIAGNOSTIC_FAILED;
70
+ return;
71
+ }
72
+ throw error;
73
+ }
74
+
75
+ if (options.out) {
76
+ const filename = path.resolve(this.workdir, options.out);
77
+ if (fs.existsSync(filename) && !options.force) {
78
+ throw new CliError(`Refusing to overwrite existing manifest: ${path.relative(this.workdir, filename)}`, {
79
+ code: "FILE_CONFLICT",
80
+ hint: "Pass --force to overwrite the manifest explicitly.",
81
+ location: filename,
82
+ exitCode: ExitCode.FILE_CONFLICT,
83
+ });
84
+ }
85
+ writeManifest(filename, manifest);
86
+ if (!options.json) print(`Manifest written to ${path.relative(process.cwd(), filename)}`);
87
+ }
88
+
89
+ if (options.check) {
90
+ if (options.json) print({valid: true, schemaVersion: manifest.schemaVersion}, true);
91
+ else print(`Manifest valid (schema ${manifest.schemaVersion}, ${manifest.routes.length} route(s)).`);
92
+ return;
93
+ }
94
+
95
+ if (options.json) {
96
+ print(manifest, true);
97
+ } else {
98
+ print(`Manifest ${manifest.schemaVersion} · ${manifest.framework.name} ${manifest.framework.version}`);
99
+ print(`Routes: ${manifest.routes.length} · artifacts: ${manifest.artifacts.length} · MCP servers: ${manifest.mcp.length}`);
100
+ if (manifest.routes.length) {
101
+ for (const route of manifest.routes) {
102
+ print(` ${route.method.padEnd(6)} ${route.path} → ${route.controller}.${route.handler} (${route.file}:${route.line})`);
103
+ }
104
+ }
105
+ print("Use --json for the full machine-readable inventory.");
106
+ }
107
+ }
108
+ }