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,59 @@
1
+ export interface SuggestableRoute {
2
+ method: string;
3
+ path: string;
4
+ version?: string;
5
+ }
6
+
7
+ function fullPath(route: SuggestableRoute): string {
8
+ return route.version ? `/${route.version}${route.path}` : route.path;
9
+ }
10
+
11
+ function distance(left: string, right: string): number {
12
+ const a = left.split("/").filter(Boolean);
13
+ const b = right.split("/").filter(Boolean);
14
+ const rows = a.length + 1;
15
+ const cols = b.length + 1;
16
+ const matrix: number[][] = Array.from({length: rows}, () => new Array(cols).fill(0));
17
+
18
+ for (let row = 0; row < rows; row++) matrix[row][0] = row;
19
+ for (let col = 0; col < cols; col++) matrix[0][col] = col;
20
+
21
+ for (let row = 1; row < rows; row++) {
22
+ for (let col = 1; col < cols; col++) {
23
+ const cost = a[row - 1] === b[col - 1] ? 0 : 1;
24
+ matrix[row][col] = Math.min(
25
+ matrix[row - 1][col] + 1,
26
+ matrix[row][col - 1] + 1,
27
+ matrix[row - 1][col - 1] + cost,
28
+ );
29
+ }
30
+ }
31
+
32
+ return matrix[rows - 1][cols - 1];
33
+ }
34
+
35
+ /**
36
+ * Suggest the closest known route for a 404 response in development. Only
37
+ * routes whose shape is reasonably close are returned.
38
+ */
39
+ export function suggestRoute(
40
+ routes: SuggestableRoute[],
41
+ method: string,
42
+ pathname: string,
43
+ ): string | undefined {
44
+ const requested = pathname.replace(/\/+$/, "") || "/";
45
+ let best: {route: SuggestableRoute; score: number} | null = null;
46
+
47
+ for (const route of routes) {
48
+ const candidate = fullPath(route).replace(/\/+$/, "") || "/";
49
+ const segments = distance(requested, candidate);
50
+ const methodPenalty = route.method.toUpperCase() === method.toUpperCase() ? 0 : 1;
51
+ const score = segments + methodPenalty;
52
+ if (!best || score < best.score) best = {route, score};
53
+ }
54
+
55
+ if (!best) return undefined;
56
+ const maxSegments = Math.max(requested.split("/").length, fullPath(best.route).split("/").length);
57
+ if (best.score > Math.max(2, Math.ceil(maxSegments / 2))) return undefined;
58
+ return `${best.route.method.toUpperCase()} ${fullPath(best.route)}`;
59
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Chargement paresseux de `class-validator`.
3
+ *
4
+ * Le paquet est optionnel à l'exécution : une application qui n'utilise ni DTO
5
+ * ni validation de réponse ne doit pas le charger au démarrage.
6
+ */
7
+ export type ClassValidatorModule = typeof import("class-validator")
8
+
9
+ let classValidatorPromise: Promise<ClassValidatorModule> | undefined
10
+
11
+ export function loadClassValidator(): Promise<ClassValidatorModule> {
12
+ return (classValidatorPromise ??= import("class-validator").catch((error: any) => {
13
+ classValidatorPromise = undefined
14
+ throw new Error(
15
+ 'class-validator is required for DTO/response validation. ' +
16
+ 'Install it with `bun add class-validator` or `npm install class-validator`. ' +
17
+ `Original error: ${error?.message ?? error}`
18
+ )
19
+ }))
20
+ }
@@ -0,0 +1,230 @@
1
+ import {camel, kebab, pascal, plural} from "../bin/name-utils.ts";
2
+ import {Raiton} from "../core/raiton.ts";
3
+
4
+ export type ArtifactType = "controller" | "service" | "repository" | "dto" | "mcp-tool" | "test" | "resource";
5
+
6
+ export interface ArtifactFile {
7
+ path: string;
8
+ content: string;
9
+ }
10
+
11
+ function controllerFile(name: string, withService = false): ArtifactFile {
12
+ const className = `${pascal(name)}Controller`;
13
+ const route = `/${kebab(plural(name))}`;
14
+ const serviceImport = withService
15
+ ? `import {Create${pascal(name)}} from "../dtos/${kebab(name)}.dto"\nimport {${pascal(name)}Service} from "../services/${kebab(name)}.service"\n`
16
+ : "";
17
+ const constructor = withService
18
+ ? ` constructor(private readonly service: ${pascal(name)}Service) {}\n\n`
19
+ : "";
20
+ const listBody = withService
21
+ ? "return this.service.list()"
22
+ : "return []";
23
+ const createRoute = withService
24
+ ? `
25
+ @Post("/")
26
+ @Input(Create${pascal(name)})
27
+ create(@Body() input: Create${pascal(name)}) {
28
+ return this.service.create(input)
29
+ }
30
+ `
31
+ : "";
32
+
33
+ return {
34
+ path: `source/controllers/${kebab(name)}.controller.ts`,
35
+ content: `import {${withService ? "Body, " : ""}Controllable, Get, Post} from "${Raiton.identifier}/framework"
36
+ ${withService ? `import {Input} from "${Raiton.identifier}/contracts"\n` : ""}${serviceImport}
37
+ @Controllable("${route}")
38
+ export class ${className} {
39
+ ${constructor} @Get("/")
40
+ list() {
41
+ ${listBody}
42
+ }
43
+ ${createRoute}}
44
+ `,
45
+ };
46
+ }
47
+
48
+ function serviceFile(name: string, withRepository = false): ArtifactFile {
49
+ const className = `${pascal(name)}Service`;
50
+ const repositoryImport = withRepository
51
+ ? `import type {Create${pascal(name)}} from "../dtos/${kebab(name)}.dto"\nimport {${pascal(name)}Repository} from "../repositories/${kebab(name)}.repository"\n`
52
+ : "";
53
+ const constructor = withRepository
54
+ ? ` constructor(private readonly repository: ${pascal(name)}Repository) {}\n\n`
55
+ : "";
56
+ const methods = withRepository
57
+ ? ` list() {
58
+ return this.repository.list()
59
+ }
60
+
61
+ create(input: Create${pascal(name)}) {
62
+ return this.repository.save({id: crypto.randomUUID(), name: input.name})
63
+ }
64
+ `
65
+ : ` private readonly items: string[] = []
66
+
67
+ list(): string[] {
68
+ return [...this.items]
69
+ }
70
+
71
+ add(value: string): string {
72
+ this.items.push(value)
73
+ return value
74
+ }
75
+ `;
76
+
77
+ return {
78
+ path: `source/services/${kebab(name)}.service.ts`,
79
+ content: `import {Injectable} from "${Raiton.identifier}/framework"
80
+ ${repositoryImport}
81
+ @Injectable()
82
+ export class ${className} {
83
+ ${constructor}${methods}}
84
+ `,
85
+ };
86
+ }
87
+
88
+ function repositoryFile(name: string): ArtifactFile {
89
+ return {
90
+ path: `source/repositories/${kebab(name)}.repository.ts`,
91
+ content: `import {Injectable} from "${Raiton.identifier}/framework"
92
+
93
+ export interface ${pascal(name)}Record {
94
+ id: string
95
+ name: string
96
+ }
97
+
98
+ @Injectable()
99
+ export class ${pascal(name)}Repository {
100
+ private readonly items = new Map<string, ${pascal(name)}Record>()
101
+
102
+ list(): ${pascal(name)}Record[] {
103
+ return [...this.items.values()]
104
+ }
105
+
106
+ find(id: string): ${pascal(name)}Record | undefined {
107
+ return this.items.get(id)
108
+ }
109
+
110
+ save(record: ${pascal(name)}Record): ${pascal(name)}Record {
111
+ this.items.set(record.id, record)
112
+ return record
113
+ }
114
+ }
115
+ `,
116
+ };
117
+ }
118
+
119
+ function dtoFile(name: string): ArtifactFile {
120
+ const typeName = pascal(name).startsWith("Create") ? pascal(name) : `Create${pascal(name)}`;
121
+ return {
122
+ path: `source/dtos/${kebab(name)}.dto.ts`,
123
+ content: `import {t} from "${Raiton.identifier}/contracts"
124
+
125
+ export const ${typeName} = t.object({
126
+ name: t.string().min(1),
127
+ })
128
+
129
+ export type ${typeName} = t.infer<typeof ${typeName}>
130
+ `,
131
+ };
132
+ }
133
+
134
+ function mcpToolFile(name: string): ArtifactFile {
135
+ const toolName = camel(name);
136
+ const className = `${pascal(name)}McpServer`;
137
+ return {
138
+ path: `source/mcp/${kebab(name)}.mcp.ts`,
139
+ content: `import {McpArg, McpServer, McpTool} from "${Raiton.identifier}/framework"
140
+
141
+ @McpServer({
142
+ name: "${kebab(name)}",
143
+ version: "1.0.0",
144
+ description: "${pascal(name)} tool server",
145
+ path: "/mcp",
146
+ })
147
+ export class ${className} {
148
+ @McpTool({
149
+ name: "${toolName}",
150
+ description: "Generated ${toolName} tool",
151
+ annotations: {readOnlyHint: false, destructiveHint: false},
152
+ })
153
+ ${toolName}(@McpArg("value", "Input value", String) value: string) {
154
+ return {value, ok: true}
155
+ }
156
+ }
157
+ `,
158
+ };
159
+ }
160
+
161
+ function testFile(name: string, withRepository = false): ArtifactFile {
162
+ if (withRepository) {
163
+ return {
164
+ path: `tests/${kebab(name)}.test.ts`,
165
+ content: `import {describe, it} from "node:test"
166
+ import assert from "node:assert/strict"
167
+ import {${pascal(name)}Repository} from "../source/repositories/${kebab(name)}.repository.ts"
168
+ import {${pascal(name)}Service} from "../source/services/${kebab(name)}.service.ts"
169
+
170
+ describe("${pascal(name)}Service", () => {
171
+ it("creates and lists records", () => {
172
+ const service = new ${pascal(name)}Service(new ${pascal(name)}Repository())
173
+ const created = service.create({name: "Raiton"})
174
+ assert.equal(created.name, "Raiton")
175
+ assert.equal(service.list().length, 1)
176
+ })
177
+ })
178
+ `,
179
+ };
180
+ }
181
+
182
+ return {
183
+ path: `tests/${kebab(name)}.test.ts`,
184
+ content: `import {describe, it} from "node:test"
185
+ import assert from "node:assert/strict"
186
+ import {${pascal(name)}Service} from "../source/services/${kebab(name)}.service.ts"
187
+
188
+ describe("${pascal(name)}Service", () => {
189
+ it("stores a value", () => {
190
+ const service = new ${pascal(name)}Service()
191
+ assert.equal(service.add("raiton"), "raiton")
192
+ assert.deepEqual(service.list(), ["raiton"])
193
+ })
194
+ })
195
+ `,
196
+ };
197
+ }
198
+
199
+ export function artifactFiles(type: ArtifactType, name: string): ArtifactFile[] {
200
+ switch (type) {
201
+ case "controller":
202
+ return [controllerFile(name)];
203
+ case "service":
204
+ return [serviceFile(name)];
205
+ case "repository":
206
+ return [repositoryFile(name)];
207
+ case "dto":
208
+ return [dtoFile(name)];
209
+ case "mcp-tool":
210
+ return [mcpToolFile(name)];
211
+ case "test":
212
+ return [testFile(name)];
213
+ case "resource":
214
+ return [
215
+ dtoFile(name),
216
+ repositoryFile(name),
217
+ serviceFile(name, true),
218
+ controllerFile(name, true),
219
+ testFile(name, true),
220
+ ];
221
+ }
222
+ }
223
+
224
+ export function assertArtifactType(value: string): ArtifactType {
225
+ const allowed: ArtifactType[] = ["controller", "service", "repository", "dto", "mcp-tool", "test", "resource"];
226
+ if (!allowed.includes(value as ArtifactType)) {
227
+ throw new Error(`Unknown generator "${value}". Expected ${allowed.join(", ")}.`);
228
+ }
229
+ return value as ArtifactType;
230
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./project.templates.ts";
2
+ export * from "./artifact.templates.ts";
@@ -0,0 +1,392 @@
1
+ import {camel, kebab, pascal, plural} from "../bin/name-utils.ts";
2
+ import {Raiton} from "../core/raiton.ts";
3
+ import pkg from "../../package.json" with {type: "json"};
4
+
5
+ export type ProjectTemplate = "api" | "minimal" | "mcp-agent";
6
+ export type ProjectRuntime = "bun" | "node" | "deno";
7
+
8
+ export interface ProjectTemplateOptions {
9
+ name: string;
10
+ template: ProjectTemplate;
11
+ runtime: ProjectRuntime;
12
+ raitonVersion?: string;
13
+ }
14
+
15
+ export interface ProjectFile {
16
+ path: string;
17
+ content: string;
18
+ }
19
+
20
+ export function projectPackageJson(options: ProjectTemplateOptions): string {
21
+ const scripts: Record<string, string> = {
22
+ test: options.runtime === "deno"
23
+ ? "deno test -A"
24
+ : options.runtime === "node"
25
+ ? "node --test"
26
+ : "bun test",
27
+ };
28
+
29
+ if (options.runtime === "node") {
30
+ scripts.dev = "raiton dev";
31
+ scripts.build = "raiton build";
32
+ scripts.start = "raiton start";
33
+ } else if (options.runtime === "deno") {
34
+ scripts.dev = "deno task dev";
35
+ scripts.build = "deno task build";
36
+ scripts.start = "deno task start";
37
+ } else {
38
+ scripts.dev = "bun raiton dev";
39
+ scripts.build = "bun raiton build";
40
+ scripts.start = "bun raiton start";
41
+ }
42
+
43
+ return JSON.stringify({
44
+ name: kebab(options.name),
45
+ version: "0.1.0",
46
+ private: true,
47
+ type: "module",
48
+ scripts,
49
+ dependencies: {
50
+ [Raiton.identifier]: options.raitonVersion ?? `^${pkg.version}`,
51
+ "reflect-metadata": "^0.2.2",
52
+ },
53
+ devDependencies: {
54
+ ...(options.runtime === "bun"
55
+ ? {"@types/bun": "^1.4.2"}
56
+ : options.runtime === "deno"
57
+ ? {"@types/deno": "^2.5.0"}
58
+ : {"@types/node": "^25.0.3"}),
59
+ typescript: "^5.9.0",
60
+ },
61
+ }, null, 2) + "\n";
62
+ }
63
+
64
+ export function projectTsconfig(runtime: ProjectRuntime): string {
65
+ return JSON.stringify({
66
+ compilerOptions: {
67
+ target: "ES2022",
68
+ module: "NodeNext",
69
+ moduleResolution: "NodeNext",
70
+ strict: true,
71
+ experimentalDecorators: true,
72
+ emitDecoratorMetadata: true,
73
+ esModuleInterop: true,
74
+ allowImportingTsExtensions: true,
75
+ noEmit: true,
76
+ skipLibCheck: true,
77
+ resolveJsonModule: true,
78
+ types: runtime === "bun" ? ["bun"] : runtime === "deno" ? ["deno"] : ["node"],
79
+ baseUrl: "./",
80
+ },
81
+ include: ["source", "tests"],
82
+ exclude: ["node_modules", ".raiton", "build"],
83
+ }, null, 2) + "\n";
84
+ }
85
+
86
+ export function projectConfig(options: ProjectTemplateOptions): ProjectFile {
87
+ const config = {
88
+ rootDir: "./source",
89
+ version: "0.1.0",
90
+ port: 5711,
91
+ hostname: "0.0.0.0",
92
+ prefix: "/api",
93
+ pathname: "/",
94
+ artifacts: {types: ["controller", "service", "repository", "dto", "mcp"]},
95
+ observability: {mode: "off"},
96
+ validation: {responses: "auto"},
97
+ devPage: {enabled: true},
98
+ mcp: {exposeDestructive: false},
99
+ };
100
+
101
+ if (options.runtime === "bun" || options.runtime === "deno") {
102
+ return {
103
+ path: "raiton.config.ts",
104
+ content: `import {defineConfigSync} from "${Raiton.identifier}/core"
105
+
106
+ export default defineConfigSync(${JSON.stringify(config, null, 2)})
107
+ `,
108
+ };
109
+ }
110
+
111
+ return {
112
+ path: "raiton.config.js",
113
+ content: `/** @type {import("${Raiton.identifier}/types").ConfigurableInterface} */
114
+ export default ${JSON.stringify(config, null, 2)}
115
+ `,
116
+ };
117
+ }
118
+
119
+ export function projectMain(options: ProjectTemplateOptions): string {
120
+ const runtime = options.runtime;
121
+ const runtimeType = runtime === "bun" ? "Bun" : runtime === "deno" ? "Deno" : "Node";
122
+ return `import "reflect-metadata"
123
+ import {Application, RaitonConfig} from "${Raiton.identifier}/core"
124
+ import {openApiPlugin, RuntimeType} from "${Raiton.identifier}/framework"
125
+ import type {ThreadInterface} from "${Raiton.identifier}/types"
126
+
127
+ export default async (thread: ThreadInterface) => {
128
+ const project = RaitonConfig.toObject()
129
+ const app = new Application({
130
+ port: project.port ?? Number(process.env.PORT ?? 5711),
131
+ prefix: project.prefix ?? "/api",
132
+ hostname: project.hostname,
133
+ pathname: project.pathname,
134
+ })
135
+
136
+ if (process.env.NODE_ENV !== "production") {
137
+ app.register(openApiPlugin({
138
+ route: "/docs",
139
+ endpoint: "/docs/json",
140
+ title: "${pascal(options.name)} API",
141
+ version: "0.1.0",
142
+ }))
143
+ }
144
+
145
+ return await thread.setup({
146
+ application: app,
147
+ runtime: RuntimeType.${runtimeType},
148
+ }).run()
149
+ }
150
+ `;
151
+ }
152
+
153
+ function exampleController(name: string): ProjectFile {
154
+ const resource = kebab(plural(name));
155
+ const className = `${pascal(name)}Controller`;
156
+ return {
157
+ path: `source/controllers/${kebab(name)}.controller.ts`,
158
+ content: `import {Body, Controllable, Get, Post} from "${Raiton.identifier}/framework"
159
+ import {Input, Output, t} from "${Raiton.identifier}/contracts"
160
+
161
+ export const GreetingInput = t.object({
162
+ name: t.string().min(1),
163
+ })
164
+
165
+ export type GreetingInput = t.infer<typeof GreetingInput>
166
+
167
+ export const GreetingOutput = t.object({
168
+ message: t.string(),
169
+ })
170
+
171
+ export type GreetingOutput = t.infer<typeof GreetingOutput>
172
+
173
+ @Controllable("/${resource}")
174
+ export class ${className} {
175
+ @Get("/")
176
+ @Output(GreetingOutput)
177
+ greet(): GreetingOutput {
178
+ return {message: "Hello from Raiton"}
179
+ }
180
+
181
+ @Post("/")
182
+ @Input(GreetingInput)
183
+ @Output(GreetingOutput)
184
+ create(@Body() input: GreetingInput): GreetingOutput {
185
+ return {message: \`Hello \${input.name}\`}
186
+ }
187
+ }
188
+ `,
189
+ };
190
+ }
191
+
192
+ function exampleService(name: string): ProjectFile {
193
+ return {
194
+ path: `source/services/${kebab(name)}.service.ts`,
195
+ content: `import {Injectable} from "${Raiton.identifier}/framework"
196
+
197
+ @Injectable()
198
+ export class ${pascal(name)}Service {
199
+ private readonly greetings = new Set<string>()
200
+
201
+ greet(name: string): string {
202
+ this.greetings.add(name)
203
+ return \`Hello \${name}\`
204
+ }
205
+
206
+ get count(): number {
207
+ return this.greetings.size
208
+ }
209
+ }
210
+ `,
211
+ };
212
+ }
213
+
214
+ function mcpTest(name: string): ProjectFile {
215
+ return {
216
+ path: `tests/${kebab(name)}.test.ts`,
217
+ content: `import {describe, it} from "node:test"
218
+ import assert from "node:assert/strict"
219
+ import {${pascal(name)}McpServer} from "../source/mcp/${kebab(name)}.mcp.ts"
220
+
221
+ describe("${pascal(name)}McpServer", () => {
222
+ it("adds two numbers", () => {
223
+ assert.deepEqual(new ${pascal(name)}McpServer().add(1, 2), {result: 3})
224
+ })
225
+ })
226
+ `,
227
+ };
228
+ }
229
+
230
+ function exampleTest(name: string): ProjectFile {
231
+ return {
232
+ path: `tests/${kebab(name)}.test.ts`,
233
+ content: `import {describe, it} from "node:test"
234
+ import assert from "node:assert/strict"
235
+ import {${pascal(name)}Service} from "../source/services/${kebab(name)}.service.ts"
236
+
237
+ describe("${pascal(name)}Service", () => {
238
+ it("greets and counts calls", () => {
239
+ const service = new ${pascal(name)}Service()
240
+ assert.equal(service.greet("Raiton"), "Hello Raiton")
241
+ assert.equal(service.count, 1)
242
+ })
243
+ })
244
+ `,
245
+ };
246
+ }
247
+
248
+ function mcpServer(name: string): ProjectFile {
249
+ return {
250
+ path: `source/mcp/${kebab(name)}.mcp.ts`,
251
+ content: `import {McpArg, McpServer, McpTool} from "${Raiton.identifier}/framework"
252
+ import {t} from "${Raiton.identifier}/contracts"
253
+
254
+ export const AddInput = t.object({
255
+ a: t.number(),
256
+ b: t.number(),
257
+ })
258
+
259
+ export type AddInput = t.infer<typeof AddInput>
260
+
261
+ export const AddOutput = t.object({
262
+ result: t.number(),
263
+ })
264
+
265
+ export type AddOutput = t.infer<typeof AddOutput>
266
+
267
+ @McpServer({
268
+ name: "${kebab(name)}",
269
+ version: "1.0.0",
270
+ description: "Example MCP server",
271
+ path: "/mcp",
272
+ })
273
+ export class ${pascal(name)}McpServer {
274
+ @McpTool({
275
+ name: "add",
276
+ description: "Add two numbers",
277
+ inputSchema: AddInput,
278
+ outputSchema: AddOutput,
279
+ annotations: {readOnlyHint: true, destructiveHint: false},
280
+ })
281
+ add(
282
+ @McpArg("a", "First operand", Number) a: number,
283
+ @McpArg("b", "Second operand", Number) b: number,
284
+ ): AddOutput {
285
+ return {result: a + b}
286
+ }
287
+ }
288
+ `,
289
+ };
290
+ }
291
+
292
+ function readme(options: ProjectTemplateOptions): string {
293
+ const resource = kebab(plural(options.name));
294
+ const runtimeCommand = options.runtime === "bun"
295
+ ? "bun raiton dev"
296
+ : options.runtime === "deno"
297
+ ? "deno task dev"
298
+ : "npx raiton dev";
299
+
300
+ return `# ${pascal(options.name)}
301
+
302
+ Generated with **${Raiton.identifier}** (\`${options.template}\` template, ${options.runtime} runtime).
303
+
304
+ ## Start
305
+
306
+ \`\`\`bash
307
+ ${runtimeCommand}
308
+ \`\`\`
309
+
310
+ ${options.template === "api" ? `The example endpoint is available at:\n\n\`\`\`bash\ncurl http://localhost:5711/api/${resource}/\ncurl http://localhost:5711/api/health\n\`\`\`` : "The health endpoint is available at `http://localhost:5711/api/health`."}
311
+
312
+ ## Test
313
+
314
+ \`\`\`bash
315
+ bun test
316
+ \`\`\`
317
+
318
+ ## Inspect
319
+
320
+ \`\`\`bash
321
+ bun raiton inspect --json
322
+ bun raiton routes
323
+ bun raiton doctor
324
+ \`\`\`
325
+
326
+ ${options.template === "mcp-agent" ? `## MCP\n\nStart the server over stdio:\n\n\`\`\`bash\nbun raiton mcp serve ${kebab(options.name)} --stdio\n\`\`\`\n` : ""}
327
+ `;
328
+ }
329
+
330
+ export function projectFiles(options: ProjectTemplateOptions): ProjectFile[] {
331
+ const files: ProjectFile[] = [
332
+ {path: "package.json", content: projectPackageJson(options)},
333
+ {path: "tsconfig.json", content: projectTsconfig(options.runtime)},
334
+ projectConfig(options),
335
+ {path: "source/main.ts", content: projectMain(options)},
336
+ {path: ".env.example", content: "PORT=5711\n"},
337
+ {path: ".gitignore", content: "node_modules\n.raiton\nbuild\n.env\n"},
338
+ {path: "README.md", content: readme(options)},
339
+ ];
340
+
341
+ if (options.runtime === "deno") {
342
+ files.push({
343
+ path: "deno.json",
344
+ content: JSON.stringify({
345
+ tasks: {
346
+ dev: `deno run -A --watch npm:${Raiton.identifier}/cli dev`,
347
+ build: `deno run -A npm:${Raiton.identifier}/cli build`,
348
+ start: `deno run -A npm:${Raiton.identifier}/cli start`,
349
+ test: "deno test -A",
350
+ },
351
+ compilerOptions: {
352
+ experimentalDecorators: true,
353
+ emitDecoratorMetadata: true,
354
+ },
355
+ }, null, 2) + "\n",
356
+ });
357
+ }
358
+
359
+ if (options.template === "api") {
360
+ files.push(exampleController(options.name));
361
+ files.push(exampleService(options.name));
362
+ files.push(exampleTest(options.name));
363
+ }
364
+
365
+ if (options.template === "minimal") {
366
+ files.push(exampleService(options.name));
367
+ files.push(exampleTest(options.name));
368
+ }
369
+
370
+ if (options.template === "mcp-agent") {
371
+ files.push(mcpServer(options.name));
372
+ files.push(mcpTest(options.name));
373
+ }
374
+
375
+ return files;
376
+ }
377
+
378
+ export function assertTemplate(value: string): ProjectTemplate {
379
+ if (!["api", "minimal", "mcp-agent"].includes(value)) {
380
+ throw new Error(`Unknown template "${value}". Expected api, minimal, or mcp-agent.`);
381
+ }
382
+ return value as ProjectTemplate;
383
+ }
384
+
385
+ export function assertRuntime(value: string): ProjectRuntime {
386
+ if (!["bun", "node", "deno"].includes(value)) {
387
+ throw new Error(`Unsupported runtime "${value}". Expected bun, node, or deno.`);
388
+ }
389
+ return value as ProjectRuntime;
390
+ }
391
+
392
+ export {camel, kebab, pascal, plural};