raiton 6.8.9-beta.25 → 6.11.0-beta.29
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.
- package/CHANGELOG.md +67 -0
- package/README.md +65 -1
- package/benchmarks/README.md +31 -0
- package/benchmarks/ai-debug.json +145 -0
- package/benchmarks/ai-debug.md +64 -0
- package/benchmarks/latest.json +172 -0
- package/benchmarks/latest.md +66 -0
- package/build/bin/index.mjs +37621 -21866
- package/build/types/bin/bootstrapper.d.ts +2 -0
- package/build/types/bin/cli-output.d.ts +46 -0
- package/build/types/bin/cli-tools.d.ts +13 -0
- package/build/types/bin/cli.d.ts +3 -0
- package/build/types/bin/commands.registry.d.ts +4 -0
- package/build/types/bin/constants.d.ts +3 -0
- package/build/types/bin/file-utils.d.ts +21 -0
- package/build/types/bin/index.d.ts +2 -0
- package/build/types/bin/name-utils.d.ts +4 -0
- package/build/types/bin/project-utils.d.ts +12 -0
- package/build/types/commands/artifact.command.d.ts +7 -0
- package/build/types/commands/build.command.d.ts +8 -0
- package/build/types/commands/call.command.d.ts +10 -0
- package/build/types/commands/client.command.d.ts +7 -0
- package/build/types/commands/contract.command.d.ts +8 -0
- package/build/types/commands/debug.shared.d.ts +16 -0
- package/build/types/commands/develop.command.d.ts +9 -0
- package/build/types/commands/docs.command.d.ts +8 -0
- package/build/types/commands/doctor.command.d.ts +9 -0
- package/build/types/commands/explain.command.d.ts +8 -0
- package/build/types/commands/generate.command.d.ts +7 -0
- package/build/types/commands/inspect.command.d.ts +7 -0
- package/build/types/commands/mcp.command.d.ts +12 -0
- package/build/types/commands/new.command.d.ts +7 -0
- package/build/types/commands/openapi.command.d.ts +7 -0
- package/build/types/commands/requests.command.d.ts +8 -0
- package/build/types/commands/routes.command.d.ts +7 -0
- package/build/types/commands/start.command.d.ts +9 -0
- package/build/types/commands/verify.command.d.ts +8 -0
- package/build/types/commands/why.command.d.ts +7 -0
- package/build/types/contracts/decorators.d.ts +59 -0
- package/build/types/contracts/errors.d.ts +68 -0
- package/build/types/contracts/index.d.ts +4 -0
- package/build/types/contracts/schema.d.ts +83 -0
- package/build/types/contracts/typebox.d.ts +81 -0
- package/build/types/core/application.d.ts +45 -0
- package/build/types/core/artifacts/artifact.d.ts +3 -0
- package/build/types/core/artifacts/index.d.ts +1 -0
- package/build/types/core/artifacts/runner.d.ts +1 -0
- package/build/types/core/builder.d.ts +42 -0
- package/build/types/core/bytes.util.d.ts +3 -0
- package/build/types/core/command.d.ts +13 -0
- package/build/types/core/commands.d.ts +10 -0
- package/build/types/core/config/config.d.ts +27 -0
- package/build/types/core/config/define.d.ts +8 -0
- package/build/types/core/config/index.d.ts +3 -0
- package/build/types/core/config/schema.d.ts +24 -0
- package/build/types/core/context.d.ts +11 -0
- package/build/types/core/controller/builder.d.ts +26 -0
- package/build/types/core/controller/compiler.d.ts +2 -0
- package/build/types/core/controller/index.d.ts +4 -0
- package/build/types/core/controller/metadata.d.ts +3 -0
- package/build/types/core/controller/tracker.d.ts +9 -0
- package/build/types/core/directories.d.ts +10 -0
- package/build/types/core/guards.d.ts +11 -0
- package/build/types/core/helpers/index.d.ts +1 -0
- package/build/types/core/helpers/raiton.d.ts +1 -0
- package/build/types/core/hooks.d.ts +14 -0
- package/build/types/core/index.d.ts +17 -0
- package/build/types/core/injection/index.d.ts +1 -0
- package/build/types/core/injection/injection.d.ts +37 -0
- package/build/types/core/mcp/builder.d.ts +2 -0
- package/build/types/core/mcp/index.d.ts +3 -0
- package/build/types/core/mcp/metadata.d.ts +9 -0
- package/build/types/core/mcp/tracker.d.ts +9 -0
- package/build/types/core/middleware/compose.d.ts +8 -0
- package/build/types/core/middleware/index.d.ts +2 -0
- package/build/types/core/middleware/pipeline.d.ts +12 -0
- package/build/types/core/plugins/index.d.ts +2 -0
- package/build/types/core/plugins/plugin.d.ts +2 -0
- package/build/types/core/plugins/scope.d.ts +15 -0
- package/build/types/core/process.util.d.ts +1 -0
- package/build/types/core/raiton.d.ts +15 -0
- package/build/types/core/router/handler.d.ts +2 -0
- package/build/types/core/router/handler.utils.d.ts +37 -0
- package/build/types/core/router/index.d.ts +4 -0
- package/build/types/core/router/matcher.d.ts +50 -0
- package/build/types/core/router/route.d.ts +52 -0
- package/build/types/core/router/router.d.ts +23 -0
- package/build/types/core/scheduler/builder.d.ts +2 -0
- package/build/types/core/scheduler/cron.d.ts +32 -0
- package/build/types/core/scheduler/duration.d.ts +7 -0
- package/build/types/core/scheduler/index.d.ts +6 -0
- package/build/types/core/scheduler/manager.d.ts +47 -0
- package/build/types/core/scheduler/metadata.d.ts +8 -0
- package/build/types/core/scheduler/queue/backend.d.ts +42 -0
- package/build/types/core/scheduler/queue/index.d.ts +3 -0
- package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
- package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
- package/build/types/core/server.d.ts +9 -0
- package/build/types/core/socket/builder.d.ts +1 -0
- package/build/types/core/socket/index.d.ts +2 -0
- package/build/types/core/socket/metadata.d.ts +14 -0
- package/build/types/core/thread.d.ts +21 -0
- package/build/types/debug/cli.d.ts +33 -0
- package/build/types/debug/collector.d.ts +41 -0
- package/build/types/debug/collector.internal.d.ts +27 -0
- package/build/types/debug/config.d.ts +19 -0
- package/build/types/debug/examples.d.ts +43 -0
- package/build/types/debug/explain.d.ts +9 -0
- package/build/types/debug/index.d.ts +15 -0
- package/build/types/debug/invocation.d.ts +53 -0
- package/build/types/debug/journal.d.ts +49 -0
- package/build/types/debug/mcp-http.d.ts +17 -0
- package/build/types/debug/mcp.d.ts +14 -0
- package/build/types/debug/redaction.d.ts +48 -0
- package/build/types/debug/requests.d.ts +37 -0
- package/build/types/debug/runtime.d.ts +52 -0
- package/build/types/debug/session.d.ts +21 -0
- package/build/types/debug/source.d.ts +17 -0
- package/build/types/debug/surface.d.ts +10 -0
- package/build/types/debug/types.d.ts +271 -0
- package/build/types/debug/verify.d.ts +23 -0
- package/build/types/framework/artifacts.d.ts +20 -0
- package/build/types/framework/cache/cache.d.ts +84 -0
- package/build/types/framework/cache/cache.decorator.d.ts +21 -0
- package/build/types/framework/cache/etag.d.ts +62 -0
- package/build/types/framework/cache/index.d.ts +4 -0
- package/build/types/framework/cache/types.d.ts +89 -0
- package/build/types/framework/constants/decorators.constant.d.ts +28 -0
- package/build/types/framework/constants/index.d.ts +2 -0
- package/build/types/framework/constants/microservices.constant.d.ts +3 -0
- package/build/types/framework/controllers.d.ts +2 -0
- package/build/types/framework/data-transfer-object.d.ts +5 -0
- package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
- package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
- package/build/types/framework/decorators/api.decorator.d.ts +160 -0
- package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
- package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
- package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
- package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
- package/build/types/framework/decorators/index.d.ts +15 -0
- package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
- package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
- package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
- package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
- package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
- package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
- package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
- package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
- package/build/types/framework/encryption.d.ts +25 -0
- package/build/types/framework/enums/csrf.enum.d.ts +4 -0
- package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
- package/build/types/framework/enums/event.message.enum.d.ts +4 -0
- package/build/types/framework/enums/http-method.enum.d.ts +10 -0
- package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
- package/build/types/framework/enums/http-status.enum.d.ts +64 -0
- package/build/types/framework/enums/index.d.ts +9 -0
- package/build/types/framework/enums/runtime.enum.d.ts +5 -0
- package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
- package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
- package/build/types/framework/env.d.ts +3 -0
- package/build/types/framework/errors/catalog.d.ts +57 -0
- package/build/types/framework/exceptions/http-exception.d.ts +18 -0
- package/build/types/framework/exceptions/index.d.ts +2 -0
- package/build/types/framework/exceptions/throwable.d.ts +76 -0
- package/build/types/framework/health-check.d.ts +42 -0
- package/build/types/framework/index.d.ts +20 -0
- package/build/types/framework/mcp/audit.d.ts +12 -0
- package/build/types/framework/mcp/conformance.d.ts +31 -0
- package/build/types/framework/mcp/handler.d.ts +11 -0
- package/build/types/framework/mcp/index.d.ts +5 -0
- package/build/types/framework/mcp/protocol.d.ts +17 -0
- package/build/types/framework/mcp/rate-limit.d.ts +10 -0
- package/build/types/framework/mcp/stdio.d.ts +40 -0
- package/build/types/framework/mcp/streamable-http.d.ts +17 -0
- package/build/types/framework/observability/index.d.ts +6 -0
- package/build/types/framework/observability/metrics.d.ts +23 -0
- package/build/types/framework/observability/plugin.d.ts +20 -0
- package/build/types/framework/observability/readiness.d.ts +9 -0
- package/build/types/framework/observability/request.d.ts +7 -0
- package/build/types/framework/observability/shutdown.d.ts +21 -0
- package/build/types/framework/observability/trace.d.ts +96 -0
- package/build/types/framework/parameter-bag.d.ts +14 -0
- package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
- package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
- package/build/types/framework/plugins/index.d.ts +5 -0
- package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
- package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
- package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
- package/build/types/framework/plugins/security/cors.d.ts +10 -0
- package/build/types/framework/plugins/security/csrf.d.ts +2 -0
- package/build/types/framework/plugins/security/headers.d.ts +1 -0
- package/build/types/framework/plugins/security/index.d.ts +13 -0
- package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
- package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
- package/build/types/framework/repositories.d.ts +5 -0
- package/build/types/framework/responses/error.d.ts +13 -0
- package/build/types/framework/responses/helpers.d.ts +7 -0
- package/build/types/framework/responses/http-throwable.d.ts +14 -0
- package/build/types/framework/responses/http.d.ts +13 -0
- package/build/types/framework/responses/index.d.ts +4 -0
- package/build/types/framework/runtime/bun/server.d.ts +2 -0
- package/build/types/framework/runtime/deno/server.d.ts +2 -0
- package/build/types/framework/runtime/index.d.ts +17 -0
- package/build/types/framework/runtime/node/reply.d.ts +12 -0
- package/build/types/framework/runtime/node/request.d.ts +33 -0
- package/build/types/framework/runtime/node/server.d.ts +2 -0
- package/build/types/framework/runtime/web/server.d.ts +1 -0
- package/build/types/framework/services.d.ts +5 -0
- package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
- package/build/types/framework/utilities/artifact.util.d.ts +7 -0
- package/build/types/framework/utilities/callable.util.d.ts +1 -0
- package/build/types/framework/utilities/cookie.util.d.ts +1 -0
- package/build/types/framework/utilities/csrf.util.d.ts +26 -0
- package/build/types/framework/utilities/https.util.d.ts +49 -0
- package/build/types/framework/utilities/index.d.ts +12 -0
- package/build/types/framework/utilities/ip.util.d.ts +15 -0
- package/build/types/framework/utilities/json.util.d.ts +10 -0
- package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
- package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
- package/build/types/framework/utilities/path.util.d.ts +3 -0
- package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
- package/build/types/framework/utilities/url.util.d.ts +1 -0
- package/build/types/framework/utilities/utilities.util.d.ts +3 -0
- package/build/types/framework/utilities/validation.util.d.ts +8 -0
- package/build/types/framework/view-model.d.ts +4 -0
- package/build/types/generators/artifact.templates.d.ts +7 -0
- package/build/types/generators/index.d.ts +2 -0
- package/build/types/generators/project.templates.d.ts +21 -0
- package/build/types/manifest/client.d.ts +12 -0
- package/build/types/manifest/contract.d.ts +25 -0
- package/build/types/manifest/index.d.ts +5 -0
- package/build/types/manifest/introspect.d.ts +18 -0
- package/build/types/manifest/manifest.d.ts +18 -0
- package/build/types/manifest/schema.d.ts +241 -0
- package/build/types/requirements.d.ts +1 -0
- package/build/types/types/access-guards.d.ts +4 -0
- package/build/types/types/application.d.ts +32 -0
- package/build/types/types/artifact.d.ts +8 -0
- package/build/types/types/builder.d.ts +37 -0
- package/build/types/types/config.d.ts +112 -0
- package/build/types/types/controller.d.ts +27 -0
- package/build/types/types/contruct.d.ts +1 -0
- package/build/types/types/core.d.ts +11 -0
- package/build/types/types/csrf.d.ts +33 -0
- package/build/types/types/directory.d.ts +6 -0
- package/build/types/types/encryption.d.ts +14 -0
- package/build/types/types/generic.d.ts +2 -0
- package/build/types/types/guard.d.ts +9 -0
- package/build/types/types/http-responses.d.ts +7 -0
- package/build/types/types/index.d.ts +27 -0
- package/build/types/types/injection.d.ts +11 -0
- package/build/types/types/lifecycle.d.ts +9 -0
- package/build/types/types/mcp.d.ts +148 -0
- package/build/types/types/middleware.d.ts +12 -0
- package/build/types/types/parseable.d.ts +3 -0
- package/build/types/types/plugin.d.ts +6 -0
- package/build/types/types/raiton.d.ts +13 -0
- package/build/types/types/responses.d.ts +20 -0
- package/build/types/types/router.d.ts +13 -0
- package/build/types/types/runtime.d.ts +48 -0
- package/build/types/types/scheduler.d.ts +140 -0
- package/build/types/types/scheme.d.ts +125 -0
- package/build/types/types/server.d.ts +10 -0
- package/build/types/types/socket.d.ts +11 -0
- package/build/types/types/thread.d.ts +25 -0
- package/build/types/types/utilities.d.ts +4 -0
- package/build/types/types/values.d.ts +2 -0
- package/docs/AGENTS.md +55 -0
- package/docs/CLAUDE.md +55 -0
- package/docs/README.md +5 -0
- package/docs/contributors/cli/README.md +17 -3
- package/docs/contributors/cli/commands.md +28 -17
- package/docs/contributors/framework/plugins/openapi.md +12 -3
- package/docs/generated/cli/commands.md +31 -0
- package/docs/generated/config-schema.json +243 -0
- package/docs/generated/manifest-schema.json +312 -0
- package/docs/generated/manifest.json +118 -0
- package/docs/llms-full.txt +1450 -0
- package/docs/llms.txt +51 -0
- package/docs/user-guide/README.md +19 -12
- package/docs/user-guide/cli.md +26 -0
- package/docs/user-guide/config.md +32 -0
- package/docs/user-guide/contracts.md +67 -0
- package/docs/user-guide/debug.md +130 -0
- package/docs/user-guide/en/README.md +83 -0
- package/docs/user-guide/getting-started.md +13 -1
- package/docs/user-guide/mcp.md +45 -2
- package/docs/user-guide/observability.md +74 -0
- package/docs/user-guide/openapi/plugin.md +10 -0
- package/docs/user-guide/recipes/README.md +32 -0
- package/docs/user-guide/recipes/contracts.md +52 -0
- package/docs/user-guide/recipes/doctor.md +16 -0
- package/docs/user-guide/recipes/generate.md +28 -0
- package/docs/user-guide/recipes/manifest.md +17 -0
- package/docs/user-guide/recipes/mcp-stdio.md +35 -0
- package/docs/user-guide/recipes/new-project.md +34 -0
- package/docs/user-guide/recipes/observability.md +17 -0
- package/package.json +42 -7
- package/scripts/bench-ai-debug.ts +572 -0
- package/scripts/bench.ts +586 -0
- package/scripts/postinstall.mjs +15 -0
- package/source/bin/cli-output.ts +139 -0
- package/source/bin/commands.registry.ts +31 -3
- package/source/bin/file-utils.ts +95 -0
- package/source/bin/name-utils.ts +26 -0
- package/source/bin/project-utils.ts +78 -0
- package/source/commands/artifact.command.ts +30 -15
- package/source/commands/call.command.ts +247 -0
- package/source/commands/client.command.ts +64 -0
- package/source/commands/contract.command.ts +104 -0
- package/source/commands/debug.shared.ts +90 -0
- package/source/commands/docs.command.ts +269 -0
- package/source/commands/doctor.command.ts +226 -0
- package/source/commands/explain.command.ts +119 -0
- package/source/commands/generate.command.ts +58 -0
- package/source/commands/inspect.command.ts +108 -0
- package/source/commands/mcp.command.ts +322 -0
- package/source/commands/new.command.ts +135 -0
- package/source/commands/openapi.command.ts +95 -0
- package/source/commands/requests.command.ts +137 -0
- package/source/commands/routes.command.ts +39 -0
- package/source/commands/verify.command.ts +173 -0
- package/source/commands/why.command.ts +61 -0
- package/source/contracts/decorators.ts +216 -0
- package/source/contracts/errors.ts +135 -0
- package/source/contracts/index.ts +4 -0
- package/source/contracts/schema.ts +438 -0
- package/source/contracts/typebox.ts +193 -0
- package/source/core/application.ts +322 -72
- package/source/core/builder.ts +10 -2
- package/source/core/config/config.ts +155 -26
- package/source/core/config/define.ts +35 -8
- package/source/core/config/index.ts +2 -1
- package/source/core/config/schema.ts +406 -0
- package/source/core/controller/builder.ts +38 -13
- package/source/core/controller/compiler.ts +14 -7
- package/source/core/controller/metadata.ts +1 -1
- package/source/core/hooks.ts +13 -1
- package/source/core/injection/injection.ts +47 -9
- package/source/core/mcp/builder.ts +13 -2
- package/source/core/mcp/metadata.ts +2 -1
- package/source/core/middleware/compose.ts +48 -0
- package/source/core/middleware/pipeline.ts +69 -46
- package/source/core/raiton.ts +8 -0
- package/source/core/router/handler.ts +246 -37
- package/source/core/router/handler.utils.ts +107 -51
- package/source/core/router/matcher.ts +195 -24
- package/source/core/router/route.ts +100 -31
- package/source/core/router/router.ts +27 -2
- package/source/core/scheduler/metadata.ts +1 -1
- package/source/core/socket/metadata.ts +1 -1
- package/source/core/thread.ts +37 -2
- package/source/debug/cli.ts +206 -0
- package/source/debug/collector.internal.ts +27 -0
- package/source/debug/collector.ts +294 -0
- package/source/debug/config.ts +142 -0
- package/source/debug/examples.ts +188 -0
- package/source/debug/explain.ts +187 -0
- package/source/debug/index.ts +15 -0
- package/source/debug/invocation.ts +695 -0
- package/source/debug/journal.ts +249 -0
- package/source/debug/mcp-http.ts +145 -0
- package/source/debug/mcp.ts +410 -0
- package/source/debug/redaction.ts +225 -0
- package/source/debug/requests.ts +136 -0
- package/source/debug/runtime.ts +181 -0
- package/source/debug/session.ts +107 -0
- package/source/debug/source.ts +95 -0
- package/source/debug/surface.ts +375 -0
- package/source/debug/types.ts +311 -0
- package/source/debug/verify.ts +186 -0
- package/source/framework/artifacts.ts +47 -15
- package/source/framework/cache/cache.ts +48 -3
- package/source/framework/constants/decorators.constant.ts +5 -0
- package/source/framework/data-transfer-object.ts +4 -3
- package/source/framework/decorators/controllable.decorator.ts +3 -3
- package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
- package/source/framework/decorators/csrf-token.decorator.ts +1 -1
- package/source/framework/decorators/guard.decorator.ts +3 -2
- package/source/framework/decorators/health-check.decorator.ts +1 -1
- package/source/framework/decorators/mcp.decorator.ts +38 -7
- package/source/framework/decorators/middleware.decorator.ts +2 -2
- package/source/framework/decorators/parametrable.decorator.ts +2 -1
- package/source/framework/decorators/routable.decorator.ts +3 -3
- package/source/framework/decorators/route-interaction.decorator.ts +2 -2
- package/source/framework/decorators/scheduler.decorator.ts +3 -3
- package/source/framework/decorators/socket.decorator.ts +3 -3
- package/source/framework/encryption.ts +46 -7
- package/source/framework/errors/catalog.ts +205 -0
- package/source/framework/exceptions/http-exception.ts +1 -1
- package/source/framework/health-check.ts +18 -0
- package/source/framework/index.ts +2 -0
- package/source/framework/mcp/audit.ts +57 -0
- package/source/framework/mcp/conformance.ts +195 -0
- package/source/framework/mcp/handler.ts +139 -9
- package/source/framework/mcp/index.ts +6 -1
- package/source/framework/mcp/protocol.ts +6 -0
- package/source/framework/mcp/rate-limit.ts +33 -0
- package/source/framework/mcp/stdio.ts +150 -0
- package/source/framework/mcp/streamable-http.ts +36 -5
- package/source/framework/observability/index.ts +6 -0
- package/source/framework/observability/metrics.ts +162 -0
- package/source/framework/observability/plugin.ts +151 -0
- package/source/framework/observability/readiness.ts +22 -0
- package/source/framework/observability/request.ts +31 -0
- package/source/framework/observability/shutdown.ts +68 -0
- package/source/framework/observability/trace.ts +241 -0
- package/source/framework/plugins/body-parser.plugin.ts +88 -85
- package/source/framework/plugins/dev.plugin.ts +227 -0
- package/source/framework/plugins/index.ts +2 -1
- package/source/framework/plugins/mcp.plugin.ts +14 -3
- package/source/framework/plugins/openapi.plugin.ts +56 -13
- package/source/framework/responses/helpers.ts +4 -4
- package/source/framework/responses/http-throwable.ts +1 -1
- package/source/framework/runtime/bun/server.ts +2 -1
- package/source/framework/runtime/deno/server.ts +2 -1
- package/source/framework/runtime/index.ts +45 -13
- package/source/framework/runtime/node/request.ts +59 -13
- package/source/framework/utilities/index.ts +3 -1
- package/source/framework/utilities/openapi.utils.impl.ts +733 -0
- package/source/framework/utilities/openapi.utils.ts +6 -636
- package/source/framework/utilities/route-suggestion.util.ts +59 -0
- package/source/framework/utilities/validation.util.ts +20 -0
- package/source/generators/artifact.templates.ts +230 -0
- package/source/generators/index.ts +2 -0
- package/source/generators/project.templates.ts +392 -0
- package/source/manifest/client.ts +299 -0
- package/source/manifest/contract.ts +138 -0
- package/source/manifest/index.ts +5 -0
- package/source/manifest/introspect.ts +57 -0
- package/source/manifest/manifest.ts +364 -0
- package/source/manifest/schema.ts +200 -0
- package/source/types/builder.ts +5 -0
- package/source/types/config.ts +120 -2
- package/source/types/mcp.ts +63 -1
- package/tsconfig.build.json +13 -0
- package/source/commands/grafts.command.ts +0 -27
- package/tests/artifact-resolution.test.ts +0 -60
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import {RaitonCommand} from "../core/command.ts";
|
|
2
|
+
import {CLI_JSON_SCHEMA_VERSION, CliError, ExitCode, fail, print} from "../bin/cli-output.ts";
|
|
3
|
+
import {loadProject} from "../bin/project-utils.ts";
|
|
4
|
+
import {getMcpServer, getMcpServerRegistry} from "../core/mcp/metadata.ts";
|
|
5
|
+
import {RaitonConfig} from "../core/config/config.ts";
|
|
6
|
+
import {handleMcpRequest} from "../framework/mcp/handler.ts";
|
|
7
|
+
import {runAllConformance} from "../framework/mcp/conformance.ts";
|
|
8
|
+
import {serveMcpStdio} from "../framework/mcp/stdio.ts";
|
|
9
|
+
import type {McpInvocationContext} from "../types/index.ts";
|
|
10
|
+
import {createDebugMcpEntry} from "../debug/mcp.ts";
|
|
11
|
+
import {enableCliDebug} from "../debug/cli.ts";
|
|
12
|
+
import {serveDebugMcpHttp} from "../debug/mcp-http.ts";
|
|
13
|
+
|
|
14
|
+
interface ListOptions {
|
|
15
|
+
json?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface InspectOptions {
|
|
19
|
+
json?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TestOptions {
|
|
23
|
+
args?: string;
|
|
24
|
+
scopes?: string;
|
|
25
|
+
json?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ServeOptions {
|
|
29
|
+
stdio?: boolean;
|
|
30
|
+
json?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ConformanceOptions {
|
|
34
|
+
json?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface DebugOptions {
|
|
38
|
+
stdio?: boolean;
|
|
39
|
+
http?: boolean;
|
|
40
|
+
port?: string;
|
|
41
|
+
hostname?: string;
|
|
42
|
+
token?: string;
|
|
43
|
+
json?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseArgs(value?: string): Record<string, any> {
|
|
47
|
+
if (!value) return {};
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(value);
|
|
50
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
51
|
+
throw new Error("arguments must be a JSON object");
|
|
52
|
+
}
|
|
53
|
+
return parsed;
|
|
54
|
+
} catch (error: any) {
|
|
55
|
+
throw new CliError(`Invalid --args JSON: ${error.message}`, {
|
|
56
|
+
code: "INVALID_ARGUMENTS",
|
|
57
|
+
hint: "Pass a JSON object, for example --args '{\"a\":1,\"b\":2}'.",
|
|
58
|
+
exitCode: ExitCode.USAGE,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default class McpCommand extends RaitonCommand {
|
|
64
|
+
public readonly name = "mcp";
|
|
65
|
+
public readonly description = "Inspect, test and serve MCP servers";
|
|
66
|
+
|
|
67
|
+
public register(): void {
|
|
68
|
+
const command = this.cli
|
|
69
|
+
.command("mcp")
|
|
70
|
+
.description(this.description);
|
|
71
|
+
|
|
72
|
+
command
|
|
73
|
+
.command("list")
|
|
74
|
+
.description("List MCP servers and their tools")
|
|
75
|
+
.option("--json", "Emit JSON on stdout")
|
|
76
|
+
.action((options: ListOptions) => this.list(options).catch(error => fail(error, options.json)));
|
|
77
|
+
|
|
78
|
+
command
|
|
79
|
+
.command("inspect <server>")
|
|
80
|
+
.description("Show the schemas and safety annotations of an MCP server")
|
|
81
|
+
.option("--json", "Emit JSON on stdout")
|
|
82
|
+
.action((server: string, options: InspectOptions) => this.inspect(server, options).catch(error => fail(error, options.json)));
|
|
83
|
+
|
|
84
|
+
command
|
|
85
|
+
.command("test <target>")
|
|
86
|
+
.description("Call a tool; target is <server>.<tool> or <tool>")
|
|
87
|
+
.option("--args <json>", "JSON object of tool arguments", "{}")
|
|
88
|
+
.option("--scopes <scopes>", "Comma-separated scopes for the call", "")
|
|
89
|
+
.option("--json", "Emit JSON on stdout")
|
|
90
|
+
.action((target: string, options: TestOptions) => this.test(target, options).catch(error => fail(error, options.json)));
|
|
91
|
+
|
|
92
|
+
command
|
|
93
|
+
.command("serve [server]")
|
|
94
|
+
.description("Serve an MCP server over stdin/stdout")
|
|
95
|
+
.option("--stdio", "Use the stdio transport (default)", true)
|
|
96
|
+
.option("--json", "Emit JSON (not compatible with a long-running server)")
|
|
97
|
+
.action((server: string | undefined, options: ServeOptions) => this.serve(server, options).catch(error => fail(error, options.json)));
|
|
98
|
+
|
|
99
|
+
command
|
|
100
|
+
.command("conformance [server]")
|
|
101
|
+
.description("Run the shared HTTP and stdio MCP conformance suite")
|
|
102
|
+
.option("--json", "Emit JSON on stdout")
|
|
103
|
+
.action((server: string | undefined, options: ConformanceOptions) => this.conformance(server, options).catch(error => fail(error, options.json)));
|
|
104
|
+
|
|
105
|
+
command
|
|
106
|
+
.command("debug")
|
|
107
|
+
.description("Serve the AI-assisted debug MCP server (stdio or HTTP)")
|
|
108
|
+
.option("--stdio", "Serve newline-delimited JSON-RPC over stdin/stdout")
|
|
109
|
+
.option("--http", "Serve streamable HTTP on a local port")
|
|
110
|
+
.option("--port <port>", "HTTP port", "5711")
|
|
111
|
+
.option("--hostname <host>", "HTTP host", "127.0.0.1")
|
|
112
|
+
.option("--token <token>", "Token required by the HTTP transport")
|
|
113
|
+
.option("--json", "Emit JSON (not compatible with a long-running server)")
|
|
114
|
+
.action((options: DebugOptions) => this.debug(options).catch(error => fail(error, options.json)));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private async list(options: ListOptions): Promise<void> {
|
|
118
|
+
const {manifest} = await loadProject(this.workdir, options.json);
|
|
119
|
+
if (options.json) {
|
|
120
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, servers: manifest.mcp}, true);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!manifest.mcp.length) {
|
|
124
|
+
print("No MCP server registered.");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
for (const server of manifest.mcp) {
|
|
128
|
+
print(`${server.server} ${server.path} (${server.tools.length} tool(s))`);
|
|
129
|
+
for (const tool of server.tools) {
|
|
130
|
+
print(` - ${tool.name}${tool.exposed ? "" : " [hidden: destructive]"}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private async inspect(name: string, options: InspectOptions): Promise<void> {
|
|
136
|
+
await loadProject(this.workdir, options.json);
|
|
137
|
+
const entry = getMcpServer(name);
|
|
138
|
+
if (!entry) {
|
|
139
|
+
throw new CliError(`MCP server not found: ${name}`, {
|
|
140
|
+
code: "MCP_SERVER_NOT_FOUND",
|
|
141
|
+
hint: `Available servers: ${[...getMcpServerRegistry().keys()].join(", ") || "none"}.`,
|
|
142
|
+
exitCode: ExitCode.USAGE,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const payload = {
|
|
147
|
+
server: entry.name,
|
|
148
|
+
path: entry.path,
|
|
149
|
+
version: entry.version,
|
|
150
|
+
description: entry.description,
|
|
151
|
+
exposeDestructive: entry.metadata.exposeDestructive,
|
|
152
|
+
tools: entry.metadata.tools.map(tool => ({
|
|
153
|
+
name: tool.name,
|
|
154
|
+
description: tool.description,
|
|
155
|
+
inputSchema: tool.inputSchema,
|
|
156
|
+
outputSchema: tool.outputSchema,
|
|
157
|
+
annotations: tool.annotations,
|
|
158
|
+
scopes: tool.scopes,
|
|
159
|
+
exposed: !(tool.annotations?.destructiveHint === true || tool.destructive === true)
|
|
160
|
+
|| entry.metadata.exposeDestructive === true
|
|
161
|
+
|| RaitonConfig.get("mcp")?.exposeDestructive === true,
|
|
162
|
+
})),
|
|
163
|
+
prompts: entry.metadata.prompts,
|
|
164
|
+
resources: entry.metadata.resources,
|
|
165
|
+
resourceTemplates: entry.metadata.resourceTemplates,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (options.json) {
|
|
169
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, ...payload}, true);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
print(`${payload.server} ${payload.path} (${payload.version})`);
|
|
174
|
+
for (const tool of payload.tools) {
|
|
175
|
+
print(` - ${tool.name}${tool.exposed ? "" : " [hidden]"}: ${tool.description ?? ""}`);
|
|
176
|
+
if (tool.inputSchema) print(` input: ${JSON.stringify(tool.inputSchema)}`);
|
|
177
|
+
if (tool.outputSchema) print(` output: ${JSON.stringify(tool.outputSchema)}`);
|
|
178
|
+
if (tool.annotations) print(` annotations: ${JSON.stringify(tool.annotations)}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private async test(target: string, options: TestOptions): Promise<void> {
|
|
183
|
+
await loadProject(this.workdir, options.json);
|
|
184
|
+
const [serverName, toolName] = target.includes(".")
|
|
185
|
+
? target.split(".", 2)
|
|
186
|
+
: [[...getMcpServerRegistry().keys()][0], target];
|
|
187
|
+
|
|
188
|
+
const entry = getMcpServer(serverName);
|
|
189
|
+
if (!entry) {
|
|
190
|
+
throw new CliError(`MCP server not found: ${serverName}`, {
|
|
191
|
+
code: "MCP_SERVER_NOT_FOUND",
|
|
192
|
+
hint: `Available servers: ${[...getMcpServerRegistry().keys()].join(", ") || "none"}.`,
|
|
193
|
+
exitCode: ExitCode.USAGE,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const context: McpInvocationContext = {
|
|
198
|
+
actor: "raiton-cli",
|
|
199
|
+
transport: "streamable-http",
|
|
200
|
+
scopes: (options.scopes ?? "").split(",").map(scope => scope.trim()).filter(Boolean),
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const handled = await handleMcpRequest(entry, {
|
|
204
|
+
jsonrpc: "2.0",
|
|
205
|
+
id: 1,
|
|
206
|
+
method: "tools/call",
|
|
207
|
+
params: {name: toolName, arguments: parseArgs(options.args)},
|
|
208
|
+
}, context);
|
|
209
|
+
|
|
210
|
+
const message: any = Array.isArray(handled.message) ? handled.message[0] : handled.message;
|
|
211
|
+
if (message?.error) {
|
|
212
|
+
throw new CliError(message.error.message, {
|
|
213
|
+
code: "MCP_CALL_FAILED",
|
|
214
|
+
hint: `Run \`raiton mcp inspect ${entry.name}\` to check the tool name and input schema.`,
|
|
215
|
+
exitCode: ExitCode.USAGE,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const result = message?.result;
|
|
220
|
+
if (options.json) {
|
|
221
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, server: entry.name, tool: toolName, ok: !result?.isError, result}, true);
|
|
222
|
+
} else {
|
|
223
|
+
print(JSON.stringify(result, null, 2));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (result?.isError) process.exitCode = ExitCode.USAGE;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private async serve(name: string | undefined, options: ServeOptions): Promise<void> {
|
|
230
|
+
if (options.json) {
|
|
231
|
+
throw new CliError("`mcp serve` is a long-running server and cannot emit a single JSON document", {
|
|
232
|
+
code: "INVALID_OPTION",
|
|
233
|
+
hint: "Omit --json when serving over stdio.",
|
|
234
|
+
exitCode: ExitCode.USAGE,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// stdout is the stdio protocol channel: silence every incidental log
|
|
239
|
+
// while booting the project.
|
|
240
|
+
await loadProject(this.workdir, true);
|
|
241
|
+
const entry = name ? getMcpServer(name) : [...getMcpServerRegistry().values()][0];
|
|
242
|
+
if (!entry) {
|
|
243
|
+
throw new CliError(name ? `MCP server not found: ${name}` : "No MCP server registered", {
|
|
244
|
+
code: "MCP_SERVER_NOT_FOUND",
|
|
245
|
+
hint: "Add a `@McpServer` class in a `*.mcp.ts` file.",
|
|
246
|
+
exitCode: ExitCode.PREREQUISITE_MISSING,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
process.stderr.write(`[raiton:mcp] serving ${entry.name} over stdio\n`);
|
|
251
|
+
await serveMcpStdio(entry);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private async conformance(name: string | undefined, options: ConformanceOptions): Promise<void> {
|
|
255
|
+
await loadProject(this.workdir, options.json);
|
|
256
|
+
const entry = name ? getMcpServer(name) : [...getMcpServerRegistry().values()][0];
|
|
257
|
+
if (!entry) {
|
|
258
|
+
throw new CliError("No MCP server registered", {
|
|
259
|
+
code: "MCP_SERVER_NOT_FOUND",
|
|
260
|
+
hint: "Add a `@McpServer` class in a `*.mcp.ts` file.",
|
|
261
|
+
exitCode: ExitCode.PREREQUISITE_MISSING,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const results = await runAllConformance(entry);
|
|
266
|
+
const passed = results.every(result => result.passed);
|
|
267
|
+
|
|
268
|
+
if (options.json) {
|
|
269
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, passed, results}, true);
|
|
270
|
+
} else {
|
|
271
|
+
for (const result of results) {
|
|
272
|
+
print(`${result.passed ? "PASS" : "FAIL"} ${result.transport}`);
|
|
273
|
+
for (const check of result.checks) {
|
|
274
|
+
print(` ${check.passed ? "ok" : "fail"} ${check.name}${check.detail ? ` (${check.detail})` : ""}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (!passed) process.exitCode = ExitCode.DIAGNOSTIC_FAILED;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private async debug(options: DebugOptions): Promise<void> {
|
|
283
|
+
if (options.json) {
|
|
284
|
+
throw new CliError("`mcp debug` is a long-running server and cannot emit a single JSON document", {
|
|
285
|
+
code: "INVALID_OPTION",
|
|
286
|
+
hint: "Omit --json when serving the debug MCP server.",
|
|
287
|
+
exitCode: ExitCode.USAGE,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const {application} = await loadProject(this.workdir, true);
|
|
292
|
+
const runtime = enableCliDebug(application, this.workdir);
|
|
293
|
+
const entry = createDebugMcpEntry(runtime.config.mcp.path);
|
|
294
|
+
const scopes = ["debug:read", "debug:call", "debug:replay", "debug:admin"];
|
|
295
|
+
const context: McpInvocationContext = {
|
|
296
|
+
actor: "raiton-debug-cli",
|
|
297
|
+
transport: "stdio",
|
|
298
|
+
scopes,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
if (options.http) {
|
|
302
|
+
const port = Number(options.port ?? 5711);
|
|
303
|
+
const server = await serveDebugMcpHttp(entry, {
|
|
304
|
+
hostname: options.hostname,
|
|
305
|
+
port,
|
|
306
|
+
token: options.token,
|
|
307
|
+
scopes,
|
|
308
|
+
});
|
|
309
|
+
process.stderr.write(`[raiton:debug] MCP HTTP listening on ${server.url}\n`);
|
|
310
|
+
await new Promise<void>(resolve => {
|
|
311
|
+
const stop = () => resolve();
|
|
312
|
+
process.once("SIGINT", stop);
|
|
313
|
+
process.once("SIGTERM", stop);
|
|
314
|
+
});
|
|
315
|
+
await server.close();
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
process.stderr.write("[raiton:debug] serving debug MCP over stdio\n");
|
|
320
|
+
await serveMcpStdio(entry, {context});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import {spawnSync} from "node:child_process";
|
|
4
|
+
import {RaitonCommand} from "../core/command.ts";
|
|
5
|
+
import {CLI_JSON_SCHEMA_VERSION, CliError, ExitCode, fail, print} from "../bin/cli-output.ts";
|
|
6
|
+
import {writeFiles} from "../bin/file-utils.ts";
|
|
7
|
+
import {
|
|
8
|
+
assertRuntime,
|
|
9
|
+
assertTemplate,
|
|
10
|
+
projectFiles,
|
|
11
|
+
type ProjectRuntime,
|
|
12
|
+
type ProjectTemplate,
|
|
13
|
+
} from "../generators/project.templates.ts";
|
|
14
|
+
import {isBunUsed, isDenoUsed} from "../bin/constants.ts";
|
|
15
|
+
import {kebab} from "../bin/name-utils.ts";
|
|
16
|
+
|
|
17
|
+
interface NewOptions {
|
|
18
|
+
template?: string;
|
|
19
|
+
runtime?: string;
|
|
20
|
+
dir?: string;
|
|
21
|
+
yes?: boolean;
|
|
22
|
+
offline?: boolean;
|
|
23
|
+
install?: boolean;
|
|
24
|
+
force?: boolean;
|
|
25
|
+
dryRun?: boolean;
|
|
26
|
+
json?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function detectRuntime(): ProjectRuntime {
|
|
30
|
+
if (isBunUsed) return "bun";
|
|
31
|
+
if (isDenoUsed) return "deno";
|
|
32
|
+
return "node";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function install(target: string, runtime: ProjectRuntime, json: boolean): {ran: boolean; command: string; status: number} {
|
|
36
|
+
if (runtime === "deno") return {ran: false, command: "deno (imports resolved at runtime)", status: 0};
|
|
37
|
+
|
|
38
|
+
const command = runtime === "bun" ? "bun" : "npm";
|
|
39
|
+
const result = spawnSync(command, ["install"], {
|
|
40
|
+
cwd: target,
|
|
41
|
+
stdio: json ? ["ignore", "ignore", "inherit"] : "inherit",
|
|
42
|
+
env: process.env,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return {ran: true, command: `${command} install`, status: result.status ?? 1};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default class NewCommand extends RaitonCommand {
|
|
49
|
+
public readonly name = "new";
|
|
50
|
+
public readonly description = "Create a new Raiton project";
|
|
51
|
+
|
|
52
|
+
public register(): void {
|
|
53
|
+
this.cli
|
|
54
|
+
.command("new <name>")
|
|
55
|
+
.description(this.description)
|
|
56
|
+
.option("--template <template>", "Project template: api, minimal, mcp-agent", "api")
|
|
57
|
+
.option("--runtime <runtime>", "Target runtime: bun, node, deno")
|
|
58
|
+
.option("--dir <directory>", "Target directory (defaults to ./<name>)")
|
|
59
|
+
.option("--yes", "Non-interactive mode; never prompt")
|
|
60
|
+
.option("--offline", "Do not access the network; skip dependency installation")
|
|
61
|
+
.option("--no-install", "Do not install dependencies")
|
|
62
|
+
.option("--force", "Overwrite existing files explicitly")
|
|
63
|
+
.option("--dry-run", "Print the file plan without writing anything")
|
|
64
|
+
.option("--json", "Emit a machine-readable result on stdout")
|
|
65
|
+
.action((name: string, options: NewOptions) => this.run(name, options).catch(error => fail(error, options.json)));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private async run(name: string, options: NewOptions): Promise<void> {
|
|
69
|
+
const template: ProjectTemplate = assertTemplate(options.template ?? "api");
|
|
70
|
+
const runtime: ProjectRuntime = assertRuntime(options.runtime ?? detectRuntime());
|
|
71
|
+
const target = options.dir
|
|
72
|
+
? path.resolve(this.workdir, options.dir)
|
|
73
|
+
: path.resolve(this.workdir, name);
|
|
74
|
+
|
|
75
|
+
if (fs.existsSync(target) && !fs.statSync(target).isDirectory()) {
|
|
76
|
+
throw new CliError(`Target exists and is not a directory: ${target}`, {
|
|
77
|
+
code: "INVALID_TARGET",
|
|
78
|
+
hint: "Choose another directory or remove the file.",
|
|
79
|
+
location: target,
|
|
80
|
+
exitCode: ExitCode.FILE_CONFLICT,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const files = projectFiles({name: kebab(name), template, runtime});
|
|
85
|
+
const result = writeFiles(target, files, {
|
|
86
|
+
force: options.force,
|
|
87
|
+
dryRun: options.dryRun,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
let installation: {ran: boolean; command: string; status: number} = {
|
|
91
|
+
ran: false,
|
|
92
|
+
command: "",
|
|
93
|
+
status: 0,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if (!options.dryRun && options.offline !== true && options.install !== false) {
|
|
97
|
+
installation = install(target, runtime, Boolean(options.json));
|
|
98
|
+
if (installation.ran && installation.status !== 0) {
|
|
99
|
+
throw new CliError(`Dependency installation failed (${installation.command})`, {
|
|
100
|
+
code: "INSTALL_FAILED",
|
|
101
|
+
hint: "Run the install command manually, or use --offline / --no-install.",
|
|
102
|
+
location: target,
|
|
103
|
+
exitCode: ExitCode.PREREQUISITE_MISSING,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const payload = {
|
|
109
|
+
schemaVersion: CLI_JSON_SCHEMA_VERSION,
|
|
110
|
+
status: options.dryRun ? "planned" : "created",
|
|
111
|
+
project: kebab(name),
|
|
112
|
+
template,
|
|
113
|
+
runtime,
|
|
114
|
+
target,
|
|
115
|
+
files: result.files,
|
|
116
|
+
installed: installation.ran && installation.status === 0,
|
|
117
|
+
installCommand: installation.command || undefined,
|
|
118
|
+
offline: Boolean(options.offline),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
if (options.json) {
|
|
122
|
+
print(payload, true);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (options.dryRun) {
|
|
127
|
+
print(`Would create ${payload.files.length} file(s) in ${target}:`);
|
|
128
|
+
for (const file of payload.files) print(` - ${file}`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
print(`Created ${payload.project} (${template}, ${runtime}) in ${target}`);
|
|
133
|
+
print(`Next: cd ${path.relative(process.cwd(), target) || "."} && ${runtime === "node" ? "npx raiton dev" : runtime === "deno" ? "deno task dev" : "bun raiton dev"}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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} from "../bin/cli-output.ts";
|
|
5
|
+
import {loadProject} from "../bin/project-utils.ts";
|
|
6
|
+
import {generateOpenApiSpec} from "../framework/utilities/openapi.utils.ts";
|
|
7
|
+
|
|
8
|
+
interface OpenApiExportOptions {
|
|
9
|
+
out?: string;
|
|
10
|
+
json?: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
dryRun?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default class OpenApiCommand extends RaitonCommand {
|
|
19
|
+
public readonly name = "openapi";
|
|
20
|
+
public readonly description = "Manage the generated OpenAPI document";
|
|
21
|
+
|
|
22
|
+
public register(): void {
|
|
23
|
+
const command = this.cli
|
|
24
|
+
.command("openapi")
|
|
25
|
+
.description(this.description);
|
|
26
|
+
|
|
27
|
+
command
|
|
28
|
+
.command("export")
|
|
29
|
+
.description("Export the OpenAPI document generated from the live routes")
|
|
30
|
+
.option("--out <file>", "Write the document to a file")
|
|
31
|
+
.option("--title <title>", "API title", "API")
|
|
32
|
+
.option("--version <version>", "API version", "1.0.0")
|
|
33
|
+
.option("--description <description>", "API description", "")
|
|
34
|
+
.option("--force", "Overwrite an existing output file")
|
|
35
|
+
.option("--dry-run", "Print the output plan without writing")
|
|
36
|
+
.option("--json", "Emit the document on stdout")
|
|
37
|
+
.action((options: OpenApiExportOptions) => this.run(options).catch(error => fail(error, options.json)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private async run(options: OpenApiExportOptions): Promise<void> {
|
|
41
|
+
const {application} = await loadProject(this.workdir, options.json);
|
|
42
|
+
const rootScope = (application as any).root;
|
|
43
|
+
if (!rootScope) {
|
|
44
|
+
throw new CliError("Application root scope is unavailable", {
|
|
45
|
+
code: "INTROSPECTION_FAILED",
|
|
46
|
+
hint: "Ensure the bootstrapper creates a standard Raiton Application.",
|
|
47
|
+
exitCode: ExitCode.PREREQUISITE_MISSING,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const spec = await generateOpenApiSpec(rootScope, {
|
|
52
|
+
title: options.title ?? "API",
|
|
53
|
+
version: options.version ?? "1.0.0",
|
|
54
|
+
description: options.description ?? "",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (options.out) {
|
|
58
|
+
const filename = path.resolve(this.workdir, options.out);
|
|
59
|
+
if (fs.existsSync(filename) && !options.force) {
|
|
60
|
+
throw new CliError(`Refusing to overwrite existing file: ${path.relative(this.workdir, filename)}`, {
|
|
61
|
+
code: "FILE_CONFLICT",
|
|
62
|
+
hint: "Pass --force to overwrite the OpenAPI document explicitly.",
|
|
63
|
+
location: filename,
|
|
64
|
+
exitCode: ExitCode.FILE_CONFLICT,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (options.dryRun) {
|
|
68
|
+
if (options.json) {
|
|
69
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "planned", file: path.relative(this.workdir, filename)}, true);
|
|
70
|
+
} else {
|
|
71
|
+
print(`Would write OpenAPI document to ${path.relative(process.cwd(), filename)}`);
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
fs.mkdirSync(path.dirname(filename), {recursive: true});
|
|
76
|
+
fs.writeFileSync(filename, JSON.stringify(spec, null, 2) + "\n", "utf-8");
|
|
77
|
+
if (options.json) {
|
|
78
|
+
print({schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "exported", file: path.relative(this.workdir, filename), paths: Object.keys(spec.paths ?? {}).length}, true);
|
|
79
|
+
} else {
|
|
80
|
+
print(`OpenAPI document written to ${path.relative(process.cwd(), filename)}`);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (options.json) {
|
|
86
|
+
print(spec, true);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
print(`OpenAPI ${spec.openapi} — ${Object.keys(spec.paths ?? {}).length} path(s)`);
|
|
91
|
+
for (const [route, item] of Object.entries(spec.paths ?? {})) {
|
|
92
|
+
print(` ${Object.keys(item as any).join(",").toUpperCase().padEnd(8)} ${route}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|