@nimrobo/mcporter-remote 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +7 -0
- package/.gitattributes +2 -0
- package/.github/workflows/ci.yml +26 -0
- package/AGENTS.md +109 -0
- package/CHANGELOG.md +361 -0
- package/LICENSE +21 -0
- package/README.md +449 -0
- package/bin/git +180 -0
- package/biome.json +43 -0
- package/config/mcporter.json +134 -0
- package/dist/cli/adhoc-server.d.ts +21 -0
- package/dist/cli/adhoc-server.d.ts.map +1 -0
- package/dist/cli/adhoc-server.js +228 -0
- package/dist/cli/adhoc-server.js.map +1 -0
- package/dist/cli/auth-command.d.ts +6 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +257 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/call-argument-expression.d.ts +5 -0
- package/dist/cli/call-argument-expression.d.ts.map +1 -0
- package/dist/cli/call-argument-expression.js +57 -0
- package/dist/cli/call-argument-expression.js.map +1 -0
- package/dist/cli/call-argument-values.d.ts +10 -0
- package/dist/cli/call-argument-values.d.ts.map +1 -0
- package/dist/cli/call-argument-values.js +83 -0
- package/dist/cli/call-argument-values.js.map +1 -0
- package/dist/cli/call-arguments.d.ts +17 -0
- package/dist/cli/call-arguments.d.ts.map +1 -0
- package/dist/cli/call-arguments.js +183 -0
- package/dist/cli/call-arguments.js.map +1 -0
- package/dist/cli/call-command.d.ts +5 -0
- package/dist/cli/call-command.d.ts.map +1 -0
- package/dist/cli/call-command.js +371 -0
- package/dist/cli/call-command.js.map +1 -0
- package/dist/cli/call-expression-parser.d.ts +9 -0
- package/dist/cli/call-expression-parser.d.ts.map +1 -0
- package/dist/cli/call-expression-parser.js +177 -0
- package/dist/cli/call-expression-parser.js.map +1 -0
- package/dist/cli/cli-factory.d.ts +16 -0
- package/dist/cli/cli-factory.d.ts.map +1 -0
- package/dist/cli/cli-factory.js +37 -0
- package/dist/cli/cli-factory.js.map +1 -0
- package/dist/cli/command-inference.d.ts +12 -0
- package/dist/cli/command-inference.d.ts.map +1 -0
- package/dist/cli/command-inference.js +75 -0
- package/dist/cli/command-inference.js.map +1 -0
- package/dist/cli/config/add.d.ts +23 -0
- package/dist/cli/config/add.d.ts.map +1 -0
- package/dist/cli/config/add.js +267 -0
- package/dist/cli/config/add.js.map +1 -0
- package/dist/cli/config/auth.d.ts +4 -0
- package/dist/cli/config/auth.d.ts.map +1 -0
- package/dist/cli/config/auth.js +21 -0
- package/dist/cli/config/auth.js.map +1 -0
- package/dist/cli/config/doctor.d.ts +3 -0
- package/dist/cli/config/doctor.d.ts.map +1 -0
- package/dist/cli/config/doctor.js +26 -0
- package/dist/cli/config/doctor.js.map +1 -0
- package/dist/cli/config/get.d.ts +3 -0
- package/dist/cli/config/get.d.ts.map +1 -0
- package/dist/cli/config/get.js +45 -0
- package/dist/cli/config/get.js.map +1 -0
- package/dist/cli/config/help.d.ts +18 -0
- package/dist/cli/config/help.d.ts.map +1 -0
- package/dist/cli/config/help.js +193 -0
- package/dist/cli/config/help.js.map +1 -0
- package/dist/cli/config/import.d.ts +9 -0
- package/dist/cli/config/import.d.ts.map +1 -0
- package/dist/cli/config/import.js +88 -0
- package/dist/cli/config/import.js.map +1 -0
- package/dist/cli/config/index.d.ts +2 -0
- package/dist/cli/config/index.d.ts.map +1 -0
- package/dist/cli/config/index.js +2 -0
- package/dist/cli/config/index.js.map +1 -0
- package/dist/cli/config/list.d.ts +7 -0
- package/dist/cli/config/list.d.ts.map +1 -0
- package/dist/cli/config/list.js +71 -0
- package/dist/cli/config/list.js.map +1 -0
- package/dist/cli/config/remove.d.ts +3 -0
- package/dist/cli/config/remove.d.ts.map +1 -0
- package/dist/cli/config/remove.js +19 -0
- package/dist/cli/config/remove.js.map +1 -0
- package/dist/cli/config/render.d.ts +26 -0
- package/dist/cli/config/render.d.ts.map +1 -0
- package/dist/cli/config/render.js +99 -0
- package/dist/cli/config/render.js.map +1 -0
- package/dist/cli/config/shared.d.ts +21 -0
- package/dist/cli/config/shared.d.ts.map +1 -0
- package/dist/cli/config/shared.js +130 -0
- package/dist/cli/config/shared.js.map +1 -0
- package/dist/cli/config/types.d.ts +7 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +2 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/config-command.d.ts +7 -0
- package/dist/cli/config-command.d.ts.map +1 -0
- package/dist/cli/config-command.js +67 -0
- package/dist/cli/config-command.js.map +1 -0
- package/dist/cli/daemon-command.d.ts +8 -0
- package/dist/cli/daemon-command.d.ts.map +1 -0
- package/dist/cli/daemon-command.js +219 -0
- package/dist/cli/daemon-command.js.map +1 -0
- package/dist/cli/emit-ts-command.d.ts +31 -0
- package/dist/cli/emit-ts-command.d.ts.map +1 -0
- package/dist/cli/emit-ts-command.js +217 -0
- package/dist/cli/emit-ts-command.js.map +1 -0
- package/dist/cli/emit-ts-templates.d.ts +23 -0
- package/dist/cli/emit-ts-templates.d.ts.map +1 -0
- package/dist/cli/emit-ts-templates.js +130 -0
- package/dist/cli/emit-ts-templates.js.map +1 -0
- package/dist/cli/ephemeral-flags.d.ts +7 -0
- package/dist/cli/ephemeral-flags.d.ts.map +1 -0
- package/dist/cli/ephemeral-flags.js +108 -0
- package/dist/cli/ephemeral-flags.js.map +1 -0
- package/dist/cli/ephemeral-target.d.ts +16 -0
- package/dist/cli/ephemeral-target.d.ts.map +1 -0
- package/dist/cli/ephemeral-target.js +105 -0
- package/dist/cli/ephemeral-target.js.map +1 -0
- package/dist/cli/errors.d.ts +4 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +7 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/flag-utils.d.ts +4 -0
- package/dist/cli/flag-utils.d.ts.map +1 -0
- package/dist/cli/flag-utils.js +27 -0
- package/dist/cli/flag-utils.js.map +1 -0
- package/dist/cli/generate/artifacts.d.ts +15 -0
- package/dist/cli/generate/artifacts.d.ts.map +1 -0
- package/dist/cli/generate/artifacts.js +247 -0
- package/dist/cli/generate/artifacts.js.map +1 -0
- package/dist/cli/generate/definition.d.ts +22 -0
- package/dist/cli/generate/definition.d.ts.map +1 -0
- package/dist/cli/generate/definition.js +265 -0
- package/dist/cli/generate/definition.js.map +1 -0
- package/dist/cli/generate/flag-parser.d.ts +11 -0
- package/dist/cli/generate/flag-parser.d.ts.map +1 -0
- package/dist/cli/generate/flag-parser.js +41 -0
- package/dist/cli/generate/flag-parser.js.map +1 -0
- package/dist/cli/generate/flags.d.ts +20 -0
- package/dist/cli/generate/flags.d.ts.map +1 -0
- package/dist/cli/generate/flags.js +220 -0
- package/dist/cli/generate/flags.js.map +1 -0
- package/dist/cli/generate/fs-helpers.d.ts +3 -0
- package/dist/cli/generate/fs-helpers.d.ts.map +1 -0
- package/dist/cli/generate/fs-helpers.js +34 -0
- package/dist/cli/generate/fs-helpers.js.map +1 -0
- package/dist/cli/generate/name-utils.d.ts +5 -0
- package/dist/cli/generate/name-utils.d.ts.map +1 -0
- package/dist/cli/generate/name-utils.js +170 -0
- package/dist/cli/generate/name-utils.js.map +1 -0
- package/dist/cli/generate/output.d.ts +5 -0
- package/dist/cli/generate/output.d.ts.map +1 -0
- package/dist/cli/generate/output.js +24 -0
- package/dist/cli/generate/output.js.map +1 -0
- package/dist/cli/generate/runtime.d.ts +3 -0
- package/dist/cli/generate/runtime.d.ts.map +1 -0
- package/dist/cli/generate/runtime.js +34 -0
- package/dist/cli/generate/runtime.js.map +1 -0
- package/dist/cli/generate/server-utils.d.ts +3 -0
- package/dist/cli/generate/server-utils.d.ts.map +1 -0
- package/dist/cli/generate/server-utils.js +33 -0
- package/dist/cli/generate/server-utils.js.map +1 -0
- package/dist/cli/generate/template-data.d.ts +25 -0
- package/dist/cli/generate/template-data.d.ts.map +1 -0
- package/dist/cli/generate/template-data.js +90 -0
- package/dist/cli/generate/template-data.js.map +1 -0
- package/dist/cli/generate/template-help.d.ts +2 -0
- package/dist/cli/generate/template-help.d.ts.map +1 -0
- package/dist/cli/generate/template-help.js +113 -0
- package/dist/cli/generate/template-help.js.map +1 -0
- package/dist/cli/generate/template.d.ts +30 -0
- package/dist/cli/generate/template.d.ts.map +1 -0
- package/dist/cli/generate/template.js +366 -0
- package/dist/cli/generate/template.js.map +1 -0
- package/dist/cli/generate/tools.d.ts +46 -0
- package/dist/cli/generate/tools.d.ts.map +1 -0
- package/dist/cli/generate/tools.js +304 -0
- package/dist/cli/generate/tools.js.map +1 -0
- package/dist/cli/generate/types.d.ts +5 -0
- package/dist/cli/generate/types.d.ts.map +1 -0
- package/dist/cli/generate/types.js +2 -0
- package/dist/cli/generate/types.js.map +1 -0
- package/dist/cli/generate-cli-runner.d.ts +3 -0
- package/dist/cli/generate-cli-runner.d.ts.map +1 -0
- package/dist/cli/generate-cli-runner.js +72 -0
- package/dist/cli/generate-cli-runner.js.map +1 -0
- package/dist/cli/help-output.d.ts +6 -0
- package/dist/cli/help-output.d.ts.map +1 -0
- package/dist/cli/help-output.js +186 -0
- package/dist/cli/help-output.js.map +1 -0
- package/dist/cli/http-utils.d.ts +9 -0
- package/dist/cli/http-utils.d.ts.map +1 -0
- package/dist/cli/http-utils.js +88 -0
- package/dist/cli/http-utils.js.map +1 -0
- package/dist/cli/identifier-helpers.d.ts +20 -0
- package/dist/cli/identifier-helpers.d.ts.map +1 -0
- package/dist/cli/identifier-helpers.js +84 -0
- package/dist/cli/identifier-helpers.js.map +1 -0
- package/dist/cli/image-output.d.ts +3 -0
- package/dist/cli/image-output.d.ts.map +1 -0
- package/dist/cli/image-output.js +57 -0
- package/dist/cli/image-output.js.map +1 -0
- package/dist/cli/inspect-cli-command.d.ts +11 -0
- package/dist/cli/inspect-cli-command.d.ts.map +1 -0
- package/dist/cli/inspect-cli-command.js +78 -0
- package/dist/cli/inspect-cli-command.js.map +1 -0
- package/dist/cli/json-output.d.ts +23 -0
- package/dist/cli/json-output.d.ts.map +1 -0
- package/dist/cli/json-output.js +38 -0
- package/dist/cli/json-output.js.map +1 -0
- package/dist/cli/list-command.d.ts +15 -0
- package/dist/cli/list-command.d.ts.map +1 -0
- package/dist/cli/list-command.js +372 -0
- package/dist/cli/list-command.js.map +1 -0
- package/dist/cli/list-detail-helpers.d.ts +41 -0
- package/dist/cli/list-detail-helpers.d.ts.map +1 -0
- package/dist/cli/list-detail-helpers.js +99 -0
- package/dist/cli/list-detail-helpers.js.map +1 -0
- package/dist/cli/list-doc-comments.d.ts +6 -0
- package/dist/cli/list-doc-comments.d.ts.map +1 -0
- package/dist/cli/list-doc-comments.js +114 -0
- package/dist/cli/list-doc-comments.js.map +1 -0
- package/dist/cli/list-format.d.ts +38 -0
- package/dist/cli/list-format.d.ts.map +1 -0
- package/dist/cli/list-format.js +98 -0
- package/dist/cli/list-format.js.map +1 -0
- package/dist/cli/list-output.d.ts +39 -0
- package/dist/cli/list-output.d.ts.map +1 -0
- package/dist/cli/list-output.js +159 -0
- package/dist/cli/list-output.js.map +1 -0
- package/dist/cli/list-signature.d.ts +26 -0
- package/dist/cli/list-signature.d.ts.map +1 -0
- package/dist/cli/list-signature.js +176 -0
- package/dist/cli/list-signature.js.map +1 -0
- package/dist/cli/logger-context.d.ts +9 -0
- package/dist/cli/logger-context.d.ts.map +1 -0
- package/dist/cli/logger-context.js +29 -0
- package/dist/cli/logger-context.js.map +1 -0
- package/dist/cli/output-format.d.ts +11 -0
- package/dist/cli/output-format.d.ts.map +1 -0
- package/dist/cli/output-format.js +51 -0
- package/dist/cli/output-format.js.map +1 -0
- package/dist/cli/output-utils.d.ts +5 -0
- package/dist/cli/output-utils.d.ts.map +1 -0
- package/dist/cli/output-utils.js +143 -0
- package/dist/cli/output-utils.js.map +1 -0
- package/dist/cli/path-utils.d.ts +2 -0
- package/dist/cli/path-utils.d.ts.map +1 -0
- package/dist/cli/path-utils.js +12 -0
- package/dist/cli/path-utils.js.map +1 -0
- package/dist/cli/runtime-debug.d.ts +4 -0
- package/dist/cli/runtime-debug.d.ts.map +1 -0
- package/dist/cli/runtime-debug.js +134 -0
- package/dist/cli/runtime-debug.js.map +1 -0
- package/dist/cli/server-lookup.d.ts +3 -0
- package/dist/cli/server-lookup.d.ts.map +1 -0
- package/dist/cli/server-lookup.js +21 -0
- package/dist/cli/server-lookup.js.map +1 -0
- package/dist/cli/terminal.d.ts +10 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +33 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/timeouts.d.ts +9 -0
- package/dist/cli/timeouts.d.ts.map +1 -0
- package/dist/cli/timeouts.js +55 -0
- package/dist/cli/timeouts.js.map +1 -0
- package/dist/cli/tool-cache.d.ts +9 -0
- package/dist/cli/tool-cache.d.ts.map +1 -0
- package/dist/cli/tool-cache.js +31 -0
- package/dist/cli/tool-cache.js.map +1 -0
- package/dist/cli/transport-utils.d.ts +3 -0
- package/dist/cli/transport-utils.d.ts.map +1 -0
- package/dist/cli/transport-utils.js +9 -0
- package/dist/cli/transport-utils.js.map +1 -0
- package/dist/cli-metadata.d.ts +57 -0
- package/dist/cli-metadata.d.ts.map +1 -0
- package/dist/cli-metadata.js +92 -0
- package/dist/cli-metadata.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +217 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/imports/external.d.ts +8 -0
- package/dist/config/imports/external.d.ts.map +1 -0
- package/dist/config/imports/external.js +231 -0
- package/dist/config/imports/external.js.map +1 -0
- package/dist/config/imports/paths-utils.d.ts +3 -0
- package/dist/config/imports/paths-utils.d.ts.map +1 -0
- package/dist/config/imports/paths-utils.js +27 -0
- package/dist/config/imports/paths-utils.js.map +1 -0
- package/dist/config/imports/paths.d.ts +3 -0
- package/dist/config/imports/paths.d.ts.map +1 -0
- package/dist/config/imports/paths.js +135 -0
- package/dist/config/imports/paths.js.map +1 -0
- package/dist/config/imports/shared.d.ts +4 -0
- package/dist/config/imports/shared.d.ts.map +1 -0
- package/dist/config/imports/shared.js +25 -0
- package/dist/config/imports/shared.js.map +1 -0
- package/dist/config/path-discovery.d.ts +11 -0
- package/dist/config/path-discovery.d.ts.map +1 -0
- package/dist/config/path-discovery.js +65 -0
- package/dist/config/path-discovery.js.map +1 -0
- package/dist/config/read-config.d.ts +9 -0
- package/dist/config/read-config.d.ts.map +1 -0
- package/dist/config/read-config.js +74 -0
- package/dist/config/read-config.js.map +1 -0
- package/dist/config-imports.d.ts +7 -0
- package/dist/config-imports.d.ts.map +1 -0
- package/dist/config-imports.js +8 -0
- package/dist/config-imports.js.map +1 -0
- package/dist/config-normalize.d.ts +8 -0
- package/dist/config-normalize.d.ts.map +1 -0
- package/dist/config-normalize.js +184 -0
- package/dist/config-normalize.js.map +1 -0
- package/dist/config-schema.d.ts +164 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +103 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +91 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon/client.d.ts +34 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +291 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/config-layers.d.ts +7 -0
- package/dist/daemon/config-layers.d.ts.map +1 -0
- package/dist/daemon/config-layers.js +20 -0
- package/dist/daemon/config-layers.js.map +1 -0
- package/dist/daemon/host.d.ts +32 -0
- package/dist/daemon/host.d.ts.map +1 -0
- package/dist/daemon/host.js +345 -0
- package/dist/daemon/host.js.map +1 -0
- package/dist/daemon/launch.d.ts +10 -0
- package/dist/daemon/launch.d.ts.map +1 -0
- package/dist/daemon/launch.js +35 -0
- package/dist/daemon/launch.js.map +1 -0
- package/dist/daemon/log-context.d.ts +18 -0
- package/dist/daemon/log-context.d.ts.map +1 -0
- package/dist/daemon/log-context.js +64 -0
- package/dist/daemon/log-context.js.map +1 -0
- package/dist/daemon/paths.d.ts +5 -0
- package/dist/daemon/paths.d.ts.map +1 -0
- package/dist/daemon/paths.js +30 -0
- package/dist/daemon/paths.js.map +1 -0
- package/dist/daemon/protocol.d.ts +51 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +2 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/request-utils.d.ts +12 -0
- package/dist/daemon/request-utils.d.ts.map +1 -0
- package/dist/daemon/request-utils.js +52 -0
- package/dist/daemon/request-utils.js.map +1 -0
- package/dist/daemon/runtime-wrapper.d.ts +9 -0
- package/dist/daemon/runtime-wrapper.d.ts.map +1 -0
- package/dist/daemon/runtime-wrapper.js +110 -0
- package/dist/daemon/runtime-wrapper.js.map +1 -0
- package/dist/env.d.ts +5 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +93 -0
- package/dist/env.js.map +1 -0
- package/dist/error-classifier.d.ts +11 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +141 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/fs-json.d.ts +3 -0
- package/dist/fs-json.d.ts.map +1 -0
- package/dist/fs-json.js +21 -0
- package/dist/fs-json.js.map +1 -0
- package/dist/generate-cli.d.ts +32 -0
- package/dist/generate-cli.d.ts.map +1 -0
- package/dist/generate-cli.js +155 -0
- package/dist/generate-cli.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +8 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +106 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logging.d.ts +19 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +76 -0
- package/dist/logging.js.map +1 -0
- package/dist/oauth-manual.d.ts +9 -0
- package/dist/oauth-manual.d.ts.map +1 -0
- package/dist/oauth-manual.js +84 -0
- package/dist/oauth-manual.js.map +1 -0
- package/dist/oauth-persistence.d.ts +20 -0
- package/dist/oauth-persistence.d.ts.map +1 -0
- package/dist/oauth-persistence.js +254 -0
- package/dist/oauth-persistence.js.map +1 -0
- package/dist/oauth-vault.d.ts +19 -0
- package/dist/oauth-vault.d.ts.map +1 -0
- package/dist/oauth-vault.js +100 -0
- package/dist/oauth-vault.js.map +1 -0
- package/dist/oauth.d.ts +31 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +414 -0
- package/dist/oauth.js.map +1 -0
- package/dist/result-utils.d.ts +22 -0
- package/dist/result-utils.d.ts.map +1 -0
- package/dist/result-utils.js +229 -0
- package/dist/result-utils.js.map +1 -0
- package/dist/runtime/errors.d.ts +2 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +16 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/http-transport.d.ts +15 -0
- package/dist/runtime/http-transport.d.ts.map +1 -0
- package/dist/runtime/http-transport.js +91 -0
- package/dist/runtime/http-transport.js.map +1 -0
- package/dist/runtime/manual-oauth.d.ts +8 -0
- package/dist/runtime/manual-oauth.d.ts.map +1 -0
- package/dist/runtime/manual-oauth.js +81 -0
- package/dist/runtime/manual-oauth.js.map +1 -0
- package/dist/runtime/oauth.d.ts +22 -0
- package/dist/runtime/oauth.d.ts.map +1 -0
- package/dist/runtime/oauth.js +83 -0
- package/dist/runtime/oauth.js.map +1 -0
- package/dist/runtime/transport.d.ts +24 -0
- package/dist/runtime/transport.d.ts.map +1 -0
- package/dist/runtime/transport.js +165 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/utils.d.ts +5 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/utils.js +47 -0
- package/dist/runtime/utils.js.map +1 -0
- package/dist/runtime-header-utils.d.ts +2 -0
- package/dist/runtime-header-utils.d.ts.map +1 -0
- package/dist/runtime-header-utils.js +19 -0
- package/dist/runtime-header-utils.js.map +1 -0
- package/dist/runtime-oauth-support.d.ts +5 -0
- package/dist/runtime-oauth-support.d.ts.map +1 -0
- package/dist/runtime-oauth-support.js +21 -0
- package/dist/runtime-oauth-support.js.map +1 -0
- package/dist/runtime-process-utils.d.ts +11 -0
- package/dist/runtime-process-utils.d.ts.map +1 -0
- package/dist/runtime-process-utils.js +299 -0
- package/dist/runtime-process-utils.js.map +1 -0
- package/dist/runtime.d.ts +55 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +245 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema-cache.d.ts +10 -0
- package/dist/schema-cache.d.ts.map +1 -0
- package/dist/schema-cache.js +40 -0
- package/dist/schema-cache.js.map +1 -0
- package/dist/sdk-patches.d.ts +5 -0
- package/dist/sdk-patches.d.ts.map +1 -0
- package/dist/sdk-patches.js +399 -0
- package/dist/sdk-patches.js.map +1 -0
- package/dist/server-proxy.d.ts +17 -0
- package/dist/server-proxy.d.ts.map +1 -0
- package/dist/server-proxy.js +342 -0
- package/dist/server-proxy.js.map +1 -0
- package/docs/RELEASE.md +96 -0
- package/docs/adhoc.md +76 -0
- package/docs/call-heuristic.md +31 -0
- package/docs/call-syntax.md +75 -0
- package/docs/cli-generator.md +116 -0
- package/docs/cli-reference.md +76 -0
- package/docs/config.md +208 -0
- package/docs/daemon.md +95 -0
- package/docs/emit-ts.md +98 -0
- package/docs/hang-debug.md +88 -0
- package/docs/import.md +59 -0
- package/docs/known-issues.md +33 -0
- package/docs/livetests.md +31 -0
- package/docs/local.md +73 -0
- package/docs/logging.md +67 -0
- package/docs/manual-testing.md +78 -0
- package/docs/mcp.md +44 -0
- package/docs/migration.md +77 -0
- package/docs/pnpm-mcp-migration.md +15 -0
- package/docs/refactor.md +76 -0
- package/docs/shortcuts.md +31 -0
- package/docs/spec.md +86 -0
- package/docs/subagent.md +39 -0
- package/docs/supabase-auth-issue.md +53 -0
- package/docs/tmux.md +30 -0
- package/docs/tool-calling.md +73 -0
- package/docs/windows.md +25 -0
- package/examples/context7-headlines.ts +72 -0
- package/git +3 -0
- package/mcporter.png +0 -0
- package/mcporter.schema.json +263 -0
- package/package.json +105 -0
- package/pnpm-workspace.yaml +2 -0
- package/runner +13 -0
- package/scripts/agent-send.ts +179 -0
- package/scripts/build-bun.ts +125 -0
- package/scripts/committer +53 -0
- package/scripts/docs-list.ts +132 -0
- package/scripts/generate-json-schema.ts +50 -0
- package/scripts/git-policy.ts +165 -0
- package/scripts/mcp_signoz_retry_patch.cjs +9 -0
- package/scripts/release.sh +86 -0
- package/scripts/runner.ts +1556 -0
- package/scripts/test-runner.js +39 -0
- package/src/cli/adhoc-server.ts +263 -0
- package/src/cli/auth-command.ts +290 -0
- package/src/cli/call-argument-expression.ts +61 -0
- package/src/cli/call-argument-values.ts +95 -0
- package/src/cli/call-arguments.ts +246 -0
- package/src/cli/call-command.ts +478 -0
- package/src/cli/call-expression-parser.ts +210 -0
- package/src/cli/cli-factory.ts +51 -0
- package/src/cli/command-inference.ts +99 -0
- package/src/cli/config/add.ts +308 -0
- package/src/cli/config/auth.ts +23 -0
- package/src/cli/config/doctor.ts +27 -0
- package/src/cli/config/get.ts +47 -0
- package/src/cli/config/help.ts +213 -0
- package/src/cli/config/import.ts +97 -0
- package/src/cli/config/index.ts +1 -0
- package/src/cli/config/list.ts +81 -0
- package/src/cli/config/remove.ts +20 -0
- package/src/cli/config/render.ts +119 -0
- package/src/cli/config/shared.ts +159 -0
- package/src/cli/config/types.ts +8 -0
- package/src/cli/config-command.ts +72 -0
- package/src/cli/daemon-command.ts +260 -0
- package/src/cli/emit-ts-command.ts +260 -0
- package/src/cli/emit-ts-templates.ts +161 -0
- package/src/cli/ephemeral-flags.ts +128 -0
- package/src/cli/ephemeral-target.ts +134 -0
- package/src/cli/errors.ts +6 -0
- package/src/cli/flag-utils.ts +29 -0
- package/src/cli/generate/artifacts.ts +308 -0
- package/src/cli/generate/definition.ts +325 -0
- package/src/cli/generate/flag-parser.ts +50 -0
- package/src/cli/generate/flags.ts +248 -0
- package/src/cli/generate/fs-helpers.ts +34 -0
- package/src/cli/generate/name-utils.ts +176 -0
- package/src/cli/generate/output.ts +27 -0
- package/src/cli/generate/runtime.ts +38 -0
- package/src/cli/generate/server-utils.ts +38 -0
- package/src/cli/generate/template-data.ts +126 -0
- package/src/cli/generate/template-help.ts +112 -0
- package/src/cli/generate/template.ts +407 -0
- package/src/cli/generate/tools.ts +354 -0
- package/src/cli/generate/types.ts +1 -0
- package/src/cli/generate-cli-runner.ts +82 -0
- package/src/cli/help-output.ts +207 -0
- package/src/cli/http-utils.ts +89 -0
- package/src/cli/identifier-helpers.ts +107 -0
- package/src/cli/image-output.ts +62 -0
- package/src/cli/inspect-cli-command.ts +89 -0
- package/src/cli/json-output.ts +60 -0
- package/src/cli/list-command.ts +432 -0
- package/src/cli/list-detail-helpers.ts +179 -0
- package/src/cli/list-doc-comments.ts +129 -0
- package/src/cli/list-format.ts +150 -0
- package/src/cli/list-output.ts +224 -0
- package/src/cli/list-signature.ts +217 -0
- package/src/cli/logger-context.ts +36 -0
- package/src/cli/output-format.ts +63 -0
- package/src/cli/output-utils.ts +161 -0
- package/src/cli/path-utils.ts +13 -0
- package/src/cli/runtime-debug.ts +141 -0
- package/src/cli/server-lookup.ts +22 -0
- package/src/cli/terminal.ts +41 -0
- package/src/cli/timeouts.ts +67 -0
- package/src/cli/tool-cache.ts +43 -0
- package/src/cli/transport-utils.ts +10 -0
- package/src/cli-metadata.ts +164 -0
- package/src/cli.ts +234 -0
- package/src/config/imports/external.ts +284 -0
- package/src/config/imports/paths-utils.ts +29 -0
- package/src/config/imports/paths.ts +145 -0
- package/src/config/imports/shared.ts +27 -0
- package/src/config/path-discovery.ts +79 -0
- package/src/config/read-config.ts +91 -0
- package/src/config-imports.ts +12 -0
- package/src/config-normalize.ts +220 -0
- package/src/config-schema.ts +175 -0
- package/src/config.ts +136 -0
- package/src/daemon/client.ts +350 -0
- package/src/daemon/config-layers.ts +23 -0
- package/src/daemon/host.ts +455 -0
- package/src/daemon/launch.ts +45 -0
- package/src/daemon/log-context.ts +78 -0
- package/src/daemon/paths.ts +35 -0
- package/src/daemon/protocol.ts +57 -0
- package/src/daemon/request-utils.ts +67 -0
- package/src/daemon/runtime-wrapper.ts +135 -0
- package/src/env.ts +107 -0
- package/src/error-classifier.ts +158 -0
- package/src/fs-json.ts +21 -0
- package/src/generate-cli.ts +211 -0
- package/src/index.ts +14 -0
- package/src/lifecycle.ts +138 -0
- package/src/logging.ts +93 -0
- package/src/oauth-manual.ts +103 -0
- package/src/oauth-persistence.ts +316 -0
- package/src/oauth-vault.ts +128 -0
- package/src/oauth.ts +494 -0
- package/src/result-utils.ts +278 -0
- package/src/runtime/errors.ts +17 -0
- package/src/runtime/oauth.ts +112 -0
- package/src/runtime/transport.ts +198 -0
- package/src/runtime/utils.ts +54 -0
- package/src/runtime-header-utils.ts +23 -0
- package/src/runtime-oauth-support.ts +24 -0
- package/src/runtime-process-utils.ts +324 -0
- package/src/runtime.ts +321 -0
- package/src/schema-cache.ts +49 -0
- package/src/sdk-patches.ts +498 -0
- package/src/server-proxy.ts +407 -0
- package/tests/adhoc-server.test.ts +49 -0
- package/tests/call-arguments.test.ts +111 -0
- package/tests/cli-auth-help.test.ts +43 -0
- package/tests/cli-auth-retry.test.ts +41 -0
- package/tests/cli-auth.test.ts +96 -0
- package/tests/cli-call-args.test.ts +69 -0
- package/tests/cli-call-errors.test.ts +27 -0
- package/tests/cli-call-execution.test.ts +279 -0
- package/tests/cli-call-help.test.ts +43 -0
- package/tests/cli-command-inference.test.ts +73 -0
- package/tests/cli-config-command.test.ts +371 -0
- package/tests/cli-config-fallback.test.ts +259 -0
- package/tests/cli-config-routing.test.ts +20 -0
- package/tests/cli-ephemeral-flags.test.ts +54 -0
- package/tests/cli-flag-utils.test.ts +17 -0
- package/tests/cli-generate-artifacts.test.ts +52 -0
- package/tests/cli-generate-cli.integration.test.ts +675 -0
- package/tests/cli-generate-runner.test.ts +156 -0
- package/tests/cli-global-flags.test.ts +61 -0
- package/tests/cli-help-shortcuts.test.ts +42 -0
- package/tests/cli-image-output.test.ts +65 -0
- package/tests/cli-inspect-command.test.ts +15 -0
- package/tests/cli-list-classification.test.ts +291 -0
- package/tests/cli-list-flags.test.ts +83 -0
- package/tests/cli-list-formatting.test.ts +358 -0
- package/tests/cli-list-help.test.ts +43 -0
- package/tests/cli-list-json.test.ts +55 -0
- package/tests/cli-list-stdio-logs.test.ts +108 -0
- package/tests/cli-list-verbose-e2e.test.ts +83 -0
- package/tests/cli-oauth-timeout-flag.test.ts +94 -0
- package/tests/cli-output-utils.test.ts +129 -0
- package/tests/cli-regenerate.test.ts +261 -0
- package/tests/cli-version.test.ts +24 -0
- package/tests/config-add-dry-run.test.ts +45 -0
- package/tests/config-add-flags.test.ts +61 -0
- package/tests/config-add-imports.test.ts +28 -0
- package/tests/config-add-persist.test.ts +27 -0
- package/tests/config-add-scope-behavior.test.ts +46 -0
- package/tests/config-add-scope.test.ts +101 -0
- package/tests/config-add-sse.test.ts +23 -0
- package/tests/config-command-string.test.ts +96 -0
- package/tests/config-doctor.test.ts +45 -0
- package/tests/config-get-json.test.ts +24 -0
- package/tests/config-import-dedupe.test.ts +27 -0
- package/tests/config-import-paths.test.ts +49 -0
- package/tests/config-import.test.ts +64 -0
- package/tests/config-imports-unit.test.ts +337 -0
- package/tests/config-imports.test.ts +417 -0
- package/tests/config-layered.test.ts +178 -0
- package/tests/config-list-text-footer.test.ts +33 -0
- package/tests/config-list.test.ts +62 -0
- package/tests/config-missing.test.ts +140 -0
- package/tests/config-normalize.test.ts +71 -0
- package/tests/config-remove.test.ts +44 -0
- package/tests/config-render.test.ts +61 -0
- package/tests/config-resolution.test.ts +94 -0
- package/tests/config-schema-file.test.ts +29 -0
- package/tests/config-shared.test.ts +41 -0
- package/tests/config-sources.test.ts +58 -0
- package/tests/daemon-cli-command.test.ts +112 -0
- package/tests/daemon-client-config-stale.test.ts +222 -0
- package/tests/daemon-client-timeout.test.ts +114 -0
- package/tests/daemon-client.test.ts +61 -0
- package/tests/daemon-host.test.ts +33 -0
- package/tests/daemon.integration.test.ts +175 -0
- package/tests/emit-ts.test.ts +125 -0
- package/tests/ephemeral-target.test.ts +26 -0
- package/tests/error-classifier.test.ts +46 -0
- package/tests/fixtures/ansi.ts +18 -0
- package/tests/fixtures/cli-list-fixtures.ts +43 -0
- package/tests/fixtures/config-fixture.ts +29 -0
- package/tests/fixtures/imports/.claude/mcp.json +8 -0
- package/tests/fixtures/imports/.claude/settings.json +10 -0
- package/tests/fixtures/imports/.claude/settings.local.json +10 -0
- package/tests/fixtures/imports/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/.codex/config.toml +7 -0
- package/tests/fixtures/imports/.config/opencode/opencode.jsonc +10 -0
- package/tests/fixtures/imports/.cursor/mcp.json +14 -0
- package/tests/fixtures/imports/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/config/mcporter.json +11 -0
- package/tests/fixtures/imports/home/.claude/settings.json +7 -0
- package/tests/fixtures/imports/home/.codeium/windsurf/mcp_config.json +14 -0
- package/tests/fixtures/imports/home/.codex/config.toml +7 -0
- package/tests/fixtures/imports/home/Library/Application Support/Code/User/mcp.json +11 -0
- package/tests/fixtures/imports/opencode.jsonc +11 -0
- package/tests/fixtures/mcporter.json +64 -0
- package/tests/fixtures/stdio-filesystem-server.mjs +63 -0
- package/tests/fixtures/stdio-memory-server.mjs +58 -0
- package/tests/fixtures/test-helpers.ts +24 -0
- package/tests/fixtures/tool-fixtures.ts +35 -0
- package/tests/fs-json.test.ts +35 -0
- package/tests/generate-cli-helpers.test.ts +162 -0
- package/tests/generate-cli.test.ts +595 -0
- package/tests/generate-definition.test.ts +25 -0
- package/tests/generator-flag-parser.test.ts +19 -0
- package/tests/index-api.test.ts +136 -0
- package/tests/keep-alive-runtime.test.ts +152 -0
- package/tests/lifecycle.test.ts +29 -0
- package/tests/list-detail-helpers.test.ts +204 -0
- package/tests/list-format.test.ts +40 -0
- package/tests/list-inline-stdio.test.ts +71 -0
- package/tests/list-output.test.ts +138 -0
- package/tests/live/deepwiki-live.test.ts +53 -0
- package/tests/oauth-callback.test.ts +108 -0
- package/tests/oauth-open-external.test.ts +29 -0
- package/tests/oauth-persistence.test.ts +146 -0
- package/tests/oauth-session.test.ts +216 -0
- package/tests/result-utils.test.ts +254 -0
- package/tests/runtime-call-timeout.test.ts +75 -0
- package/tests/runtime-compose.test.ts +298 -0
- package/tests/runtime-error-reset.test.ts +65 -0
- package/tests/runtime-header-utils.test.ts +36 -0
- package/tests/runtime-integration.test.ts +113 -0
- package/tests/runtime-oauth-connect.test.ts +72 -0
- package/tests/runtime-oauth-detection.test.ts +72 -0
- package/tests/runtime-oauth-timeout.test.ts +60 -0
- package/tests/runtime-oauth-utils.test.ts +14 -0
- package/tests/runtime-process-utils.test.ts +53 -0
- package/tests/runtime-transport.test.ts +69 -0
- package/tests/runtime-utils.test.ts +31 -0
- package/tests/runtime.test.ts +94 -0
- package/tests/sdk-patches.test.ts +24 -0
- package/tests/server-proxy.test.ts +336 -0
- package/tests/stdio-servers.integration.test.ts +139 -0
- package/tests/tool-cache.test.ts +42 -0
- package/tests/version-consistency.test.ts +11 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +18 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type FlagMap = Partial<Record<string, string>>;
|
|
2
|
+
|
|
3
|
+
// extractFlags snacks out targeted flags (and their values) from argv in place.
|
|
4
|
+
export function extractFlags(args: string[], keys: readonly string[]): FlagMap {
|
|
5
|
+
const flags: FlagMap = {};
|
|
6
|
+
let index = 0;
|
|
7
|
+
while (index < args.length) {
|
|
8
|
+
const token = args[index];
|
|
9
|
+
if (token === undefined || !keys.includes(token)) {
|
|
10
|
+
index += 1;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const value = args[index + 1];
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
throw new Error(`Flag '${token}' requires a value.`);
|
|
16
|
+
}
|
|
17
|
+
flags[token] = value;
|
|
18
|
+
args.splice(index, 2);
|
|
19
|
+
}
|
|
20
|
+
return flags;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// expectValue asserts that a flag is followed by a value.
|
|
24
|
+
export function expectValue(flag: string, value: string | undefined): string {
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
throw new Error(`Flag '${flag}' requires a value.`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import fsSync from 'node:fs';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import type { RolldownPlugin } from 'rolldown';
|
|
8
|
+
import { markExecutable, safeCopyFile } from './fs-helpers.js';
|
|
9
|
+
import { verifyBunAvailable } from './runtime.js';
|
|
10
|
+
|
|
11
|
+
const localRequire = createRequire(import.meta.url);
|
|
12
|
+
const packageRoot = fileURLToPath(new URL('../../..', import.meta.url));
|
|
13
|
+
// Generated CLIs import commander/mcporter, but end-users run mcporter from directories
|
|
14
|
+
// that often lack node_modules. Pre-resolve those deps to this package so bundling works
|
|
15
|
+
// even in empty temp dirs (fixes #1).
|
|
16
|
+
const BUNDLED_DEPENDENCIES = ['commander', '@nimrobo/mcporter-remote', 'jsonc-parser'] as const;
|
|
17
|
+
const dependencyAliasPlugin = createLocalDependencyAliasPlugin([...BUNDLED_DEPENDENCIES]);
|
|
18
|
+
|
|
19
|
+
export async function bundleOutput({
|
|
20
|
+
sourcePath,
|
|
21
|
+
targetPath,
|
|
22
|
+
runtimeKind,
|
|
23
|
+
minify,
|
|
24
|
+
bundler,
|
|
25
|
+
}: {
|
|
26
|
+
sourcePath: string;
|
|
27
|
+
targetPath: string;
|
|
28
|
+
runtimeKind: 'node' | 'bun';
|
|
29
|
+
minify: boolean;
|
|
30
|
+
bundler: 'rolldown' | 'bun';
|
|
31
|
+
}): Promise<string> {
|
|
32
|
+
if (bundler === 'bun') {
|
|
33
|
+
return await bundleWithBun({ sourcePath, targetPath, runtimeKind, minify });
|
|
34
|
+
}
|
|
35
|
+
return await bundleWithRolldown({ sourcePath, targetPath, runtimeKind, minify });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function bundleWithRolldown({
|
|
39
|
+
sourcePath,
|
|
40
|
+
targetPath,
|
|
41
|
+
runtimeKind,
|
|
42
|
+
minify,
|
|
43
|
+
}: {
|
|
44
|
+
sourcePath: string;
|
|
45
|
+
targetPath: string;
|
|
46
|
+
runtimeKind: 'node' | 'bun';
|
|
47
|
+
minify: boolean;
|
|
48
|
+
}): Promise<string> {
|
|
49
|
+
let rolldownImpl: typeof import('rolldown')['rolldown'];
|
|
50
|
+
try {
|
|
51
|
+
({ rolldown: rolldownImpl } = await import('rolldown'));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const message =
|
|
54
|
+
'Rolldown bundling is unavailable in this build of mcporter; rerun with --bundler bun or install mcporter via npm (Node.js) to use the Rolldown bundler.';
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
error.message = `${message}\n\n${error.message}`;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
throw new Error(message);
|
|
60
|
+
}
|
|
61
|
+
const absTarget = path.resolve(targetPath);
|
|
62
|
+
await fs.mkdir(path.dirname(absTarget), { recursive: true });
|
|
63
|
+
const plugins = dependencyAliasPlugin ? [dependencyAliasPlugin] : undefined;
|
|
64
|
+
const bundle = await rolldownImpl({
|
|
65
|
+
input: sourcePath,
|
|
66
|
+
treeshake: false,
|
|
67
|
+
plugins,
|
|
68
|
+
onLog(level, log, handler) {
|
|
69
|
+
if (typeof (log as { code?: string }).code === 'string' && (log as { code?: string }).code === 'EVAL') {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
handler(level, log);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
await bundle.write({
|
|
76
|
+
file: absTarget,
|
|
77
|
+
format: runtimeKind === 'bun' ? 'esm' : 'cjs',
|
|
78
|
+
sourcemap: false,
|
|
79
|
+
minify,
|
|
80
|
+
});
|
|
81
|
+
await markExecutable(absTarget);
|
|
82
|
+
return absTarget;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function bundleWithBun({
|
|
86
|
+
sourcePath,
|
|
87
|
+
targetPath,
|
|
88
|
+
runtimeKind,
|
|
89
|
+
minify,
|
|
90
|
+
}: {
|
|
91
|
+
sourcePath: string;
|
|
92
|
+
targetPath: string;
|
|
93
|
+
runtimeKind: 'node' | 'bun';
|
|
94
|
+
minify: boolean;
|
|
95
|
+
}): Promise<string> {
|
|
96
|
+
const absTarget = path.resolve(targetPath);
|
|
97
|
+
await fs.mkdir(path.dirname(absTarget), { recursive: true });
|
|
98
|
+
const bunBin = await verifyBunAvailable();
|
|
99
|
+
const tmpRoot = path.join(packageRoot, 'tmp');
|
|
100
|
+
await fs.mkdir(tmpRoot, { recursive: true });
|
|
101
|
+
const stagingDir = await fs.mkdtemp(path.join(tmpRoot, 'bundle-'));
|
|
102
|
+
const stagingEntry = path.join(stagingDir, path.basename(sourcePath));
|
|
103
|
+
// Copy the template into the package tree so Bun sees our node_modules deps even when the
|
|
104
|
+
// CLI runs from an empty working directory.
|
|
105
|
+
await safeCopyFile(sourcePath, stagingEntry);
|
|
106
|
+
await ensureBundlerDeps(stagingDir);
|
|
107
|
+
try {
|
|
108
|
+
const args = ['build', stagingEntry, '--outfile', absTarget, '--target', runtimeKind === 'bun' ? 'bun' : 'node'];
|
|
109
|
+
if (minify) {
|
|
110
|
+
args.push('--minify');
|
|
111
|
+
}
|
|
112
|
+
await new Promise<void>((resolve, reject) => {
|
|
113
|
+
execFile(bunBin, args, { cwd: packageRoot, env: process.env }, (error) => {
|
|
114
|
+
if (error) {
|
|
115
|
+
reject(error);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
resolve();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
} finally {
|
|
122
|
+
await fs.rm(stagingDir, { recursive: true, force: true }).catch(() => {});
|
|
123
|
+
}
|
|
124
|
+
await markExecutable(absTarget);
|
|
125
|
+
return absTarget;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function compileBundleWithBun(bundlePath: string, outputPath: string): Promise<void> {
|
|
129
|
+
const bunBin = await verifyBunAvailable();
|
|
130
|
+
await new Promise<void>((resolve, reject) => {
|
|
131
|
+
execFile(
|
|
132
|
+
bunBin,
|
|
133
|
+
['build', bundlePath, '--compile', '--outfile', outputPath],
|
|
134
|
+
{ cwd: process.cwd(), env: process.env },
|
|
135
|
+
(error) => {
|
|
136
|
+
if (error) {
|
|
137
|
+
reject(error);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
resolve();
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await markExecutable(outputPath);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function resolveBundleTarget({
|
|
149
|
+
bundle,
|
|
150
|
+
compile,
|
|
151
|
+
outputPath,
|
|
152
|
+
}: {
|
|
153
|
+
bundle?: boolean | string;
|
|
154
|
+
compile?: boolean | string;
|
|
155
|
+
outputPath: string;
|
|
156
|
+
}): string {
|
|
157
|
+
if (typeof bundle === 'string') {
|
|
158
|
+
return bundle;
|
|
159
|
+
}
|
|
160
|
+
if (bundle) {
|
|
161
|
+
throw new Error('--bundle requires an explicit output path when used with --compile.');
|
|
162
|
+
}
|
|
163
|
+
if (typeof compile === 'string') {
|
|
164
|
+
const ext = path.extname(compile);
|
|
165
|
+
const base = ext ? path.join(path.dirname(compile), path.basename(compile, ext)) : compile;
|
|
166
|
+
return `${base}.js`;
|
|
167
|
+
}
|
|
168
|
+
if (compile) {
|
|
169
|
+
const tmpDir = path.join(process.cwd(), 'tmp', 'mcporter-cli-bundles');
|
|
170
|
+
const baseName = path.basename(outputPath, path.extname(outputPath)) || 'bundle';
|
|
171
|
+
return path.join(tmpDir, `${baseName}-${Date.now()}.bundle.js`);
|
|
172
|
+
}
|
|
173
|
+
throw new Error('--compile requires an explicit bundle target.');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function computeCompileTarget(
|
|
177
|
+
compileOption: boolean | string | undefined,
|
|
178
|
+
_bundlePath: string,
|
|
179
|
+
serverName: string
|
|
180
|
+
): string {
|
|
181
|
+
if (typeof compileOption === 'string') {
|
|
182
|
+
return compileOption;
|
|
183
|
+
}
|
|
184
|
+
const baseName = sanitizeFileName(serverName) || 'mcporter-cli';
|
|
185
|
+
return resolveUniquePath(process.cwd(), baseName);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function createLocalDependencyAliasPlugin(specifiers: string[]): RolldownPlugin | undefined {
|
|
189
|
+
const resolvedEntries = specifiers
|
|
190
|
+
.map((specifier) => ({ specifier, path: resolveLocalDependency(specifier) }))
|
|
191
|
+
.filter((entry): entry is { specifier: string; path: string } => Boolean(entry.path));
|
|
192
|
+
if (resolvedEntries.length === 0) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
name: 'mcporter-local-deps',
|
|
197
|
+
resolveId(source) {
|
|
198
|
+
const match = resolvedEntries.find((entry) => entry.specifier === source);
|
|
199
|
+
if (match) {
|
|
200
|
+
return match.path;
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function resolveLocalDependency(specifier: string): string | undefined {
|
|
208
|
+
try {
|
|
209
|
+
if (specifier === 'jsonc-parser') {
|
|
210
|
+
const pkgJsonPath = localRequire.resolve('jsonc-parser/package.json');
|
|
211
|
+
const pkgDir = path.dirname(pkgJsonPath);
|
|
212
|
+
try {
|
|
213
|
+
const pkg = JSON.parse(fsSync.readFileSync(pkgJsonPath, 'utf8')) as { module?: string };
|
|
214
|
+
if (pkg.module) {
|
|
215
|
+
const esmEntry = path.join(pkgDir, pkg.module);
|
|
216
|
+
if (fsSync.existsSync(esmEntry)) {
|
|
217
|
+
return esmEntry;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch {
|
|
221
|
+
// Fall back to Node's resolution below if we can't parse or locate the module entry.
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return localRequire.resolve(specifier);
|
|
225
|
+
} catch {
|
|
226
|
+
if (specifier === '@nimrobo/mcporter-remote') {
|
|
227
|
+
// During development or unpublished builds there may not be an installed entry,
|
|
228
|
+
// so fall back to the files inside the repo that represent the published surface.
|
|
229
|
+
const fallbacks = [
|
|
230
|
+
path.join(packageRoot, 'dist', 'index.js'),
|
|
231
|
+
path.join(packageRoot, 'dist', 'index.mjs'),
|
|
232
|
+
path.join(packageRoot, 'src', 'index.ts'),
|
|
233
|
+
path.join(packageRoot, 'src', 'index.js'),
|
|
234
|
+
];
|
|
235
|
+
for (const candidate of fallbacks) {
|
|
236
|
+
if (fsSync.existsSync(candidate)) {
|
|
237
|
+
return candidate;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async function ensureBundlerDeps(stagingDir: string): Promise<void> {
|
|
246
|
+
const nodeModulesDir = path.join(stagingDir, 'node_modules');
|
|
247
|
+
await fs.mkdir(nodeModulesDir, { recursive: true });
|
|
248
|
+
await Promise.all(
|
|
249
|
+
BUNDLED_DEPENDENCIES.map(async (specifier) => {
|
|
250
|
+
const sourceDir = resolveDependencyDirectory(specifier);
|
|
251
|
+
if (!sourceDir) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const target = path.join(nodeModulesDir, specifier);
|
|
255
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
256
|
+
await linkOrCopyDependency(sourceDir, target);
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function resolveDependencyDirectory(specifier: (typeof BUNDLED_DEPENDENCIES)[number]): string | undefined {
|
|
262
|
+
try {
|
|
263
|
+
if (specifier === '@nimrobo/mcporter-remote') {
|
|
264
|
+
return packageRoot;
|
|
265
|
+
}
|
|
266
|
+
const pkgPath = localRequire.resolve(path.join(specifier, 'package.json'));
|
|
267
|
+
return path.dirname(pkgPath);
|
|
268
|
+
} catch {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function linkOrCopyDependency(sourceDir: string, targetDir: string): Promise<void> {
|
|
274
|
+
try {
|
|
275
|
+
await fs.symlink(sourceDir, targetDir, 'dir');
|
|
276
|
+
} catch (error) {
|
|
277
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
278
|
+
if (code === 'EEXIST') {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (code === 'ENOENT') {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (code === 'EPERM' || code === 'EACCES') {
|
|
285
|
+
await fs.cp(sourceDir, targetDir, { recursive: true });
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function sanitizeFileName(input: string): string {
|
|
293
|
+
const slug = input
|
|
294
|
+
.trim()
|
|
295
|
+
.toLowerCase()
|
|
296
|
+
.replace(/[^a-z0-9]+/g, '-');
|
|
297
|
+
return slug.replace(/^-+|-+$/g, '');
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function resolveUniquePath(directory: string, baseName: string): string {
|
|
301
|
+
let attempt = path.join(directory, baseName);
|
|
302
|
+
let suffix = 1;
|
|
303
|
+
while (fsSync.existsSync(attempt)) {
|
|
304
|
+
attempt = path.join(directory, `${baseName}-${suffix}`);
|
|
305
|
+
suffix += 1;
|
|
306
|
+
}
|
|
307
|
+
return attempt;
|
|
308
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { CliArtifactMetadata } from '../../cli-metadata.js';
|
|
4
|
+
import { type HttpCommand, loadServerDefinitions, type ServerDefinition, type StdioCommand } from '../../config.js';
|
|
5
|
+
import type { Runtime, ServerToolInfo } from '../../runtime.js';
|
|
6
|
+
import { createRuntime } from '../../runtime.js';
|
|
7
|
+
import { extractHttpServerTarget, normalizeHttpUrl } from '../http-utils.js';
|
|
8
|
+
|
|
9
|
+
export interface ResolvedServer {
|
|
10
|
+
definition: ServerDefinition;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type DefinitionInput =
|
|
15
|
+
| ServerDefinition
|
|
16
|
+
| (Record<string, unknown> & {
|
|
17
|
+
name: string;
|
|
18
|
+
command?: unknown;
|
|
19
|
+
args?: unknown;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export async function fileExists(filePath: string): Promise<boolean> {
|
|
23
|
+
try {
|
|
24
|
+
await fs.access(filePath);
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ensureInvocationDefaults(
|
|
32
|
+
invocation: CliArtifactMetadata['invocation'],
|
|
33
|
+
definition: ServerDefinition
|
|
34
|
+
): CliArtifactMetadata['invocation'] {
|
|
35
|
+
const serverRef = invocation.serverRef ?? definition.name;
|
|
36
|
+
const configPath =
|
|
37
|
+
invocation.configPath ??
|
|
38
|
+
(definition.source && definition.source.kind === 'local' ? definition.source.path : undefined);
|
|
39
|
+
return {
|
|
40
|
+
...invocation,
|
|
41
|
+
serverRef,
|
|
42
|
+
configPath,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function resolveServerDefinition(
|
|
47
|
+
serverRef: string,
|
|
48
|
+
configPath?: string,
|
|
49
|
+
rootDir?: string
|
|
50
|
+
): Promise<ResolvedServer> {
|
|
51
|
+
const trimmed = serverRef.trim();
|
|
52
|
+
|
|
53
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
54
|
+
// Allow callers to inline a JSON server definition (used by tests + CLI).
|
|
55
|
+
const parsed = JSON.parse(trimmed) as ServerDefinition & { name: string };
|
|
56
|
+
if (!parsed.name) {
|
|
57
|
+
throw new Error("Inline server definition must include a 'name' field.");
|
|
58
|
+
}
|
|
59
|
+
return { definition: normalizeDefinition(parsed), name: parsed.name };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const possiblePath = path.resolve(trimmed);
|
|
63
|
+
try {
|
|
64
|
+
const buffer = await fs.readFile(possiblePath, 'utf8');
|
|
65
|
+
const parsed = JSON.parse(buffer) as {
|
|
66
|
+
mcpServers?: Record<string, unknown>;
|
|
67
|
+
};
|
|
68
|
+
if (!parsed.mcpServers || typeof parsed.mcpServers !== 'object') {
|
|
69
|
+
throw new Error(`Config file ${possiblePath} does not contain mcpServers.`);
|
|
70
|
+
}
|
|
71
|
+
const entries = Object.entries(parsed.mcpServers);
|
|
72
|
+
if (entries.length === 0) {
|
|
73
|
+
throw new Error(`Config file ${possiblePath} does not define any servers.`);
|
|
74
|
+
}
|
|
75
|
+
const first = entries[0];
|
|
76
|
+
if (!first) {
|
|
77
|
+
throw new Error(`Config file ${possiblePath} does not define any servers.`);
|
|
78
|
+
}
|
|
79
|
+
const [name, value] = first;
|
|
80
|
+
return {
|
|
81
|
+
definition: normalizeDefinition({
|
|
82
|
+
name,
|
|
83
|
+
...(value as Record<string, unknown>),
|
|
84
|
+
}),
|
|
85
|
+
name,
|
|
86
|
+
};
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const definitions = await loadServerDefinitions({
|
|
94
|
+
configPath,
|
|
95
|
+
rootDir,
|
|
96
|
+
});
|
|
97
|
+
const matchByName = definitions.find((def) => def.name === trimmed);
|
|
98
|
+
if (matchByName) {
|
|
99
|
+
return { definition: matchByName, name: matchByName.name };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const httpTarget = extractHttpServerTarget(trimmed);
|
|
103
|
+
if (httpTarget) {
|
|
104
|
+
const normalizedTarget = normalizeHttpUrl(httpTarget);
|
|
105
|
+
if (normalizedTarget) {
|
|
106
|
+
const matchByUrl = definitions.find((def) => {
|
|
107
|
+
if (def.command.kind !== 'http') {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const normalizedDefinitionUrl = normalizeHttpUrl(def.command.url);
|
|
111
|
+
return normalizedDefinitionUrl === normalizedTarget;
|
|
112
|
+
});
|
|
113
|
+
if (matchByUrl) {
|
|
114
|
+
return { definition: matchByUrl, name: matchByUrl.name };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Unknown MCP server '${trimmed}'. Provide a name from config, a JSON file, inline JSON, or an HTTP URL that matches a configured server.`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function fetchTools(
|
|
125
|
+
definition: ServerDefinition,
|
|
126
|
+
serverName: string,
|
|
127
|
+
configPath?: string,
|
|
128
|
+
rootDir?: string
|
|
129
|
+
): Promise<{ tools: ServerToolInfo[]; derivedDescription?: string }> {
|
|
130
|
+
// Reuse the runtime helper so bundle builds and CLI generation share the same discovery path.
|
|
131
|
+
const runtime = await createRuntime({
|
|
132
|
+
configPath,
|
|
133
|
+
rootDir,
|
|
134
|
+
servers: configPath ? undefined : [definition],
|
|
135
|
+
});
|
|
136
|
+
try {
|
|
137
|
+
const tools = await runtime.listTools(serverName, { includeSchema: true });
|
|
138
|
+
const derivedDescription = definition.description
|
|
139
|
+
? undefined
|
|
140
|
+
: await deriveDefinitionDescription(runtime, serverName);
|
|
141
|
+
return { tools, derivedDescription };
|
|
142
|
+
} finally {
|
|
143
|
+
await runtime.close(serverName).catch(() => {});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function deriveDefinitionDescription(runtime: Runtime, serverName: string): Promise<string | undefined> {
|
|
148
|
+
try {
|
|
149
|
+
const context = await runtime.connect(serverName);
|
|
150
|
+
const instructions =
|
|
151
|
+
typeof context.client.getInstructions === 'function' ? context.client.getInstructions() : undefined;
|
|
152
|
+
const serverInfo =
|
|
153
|
+
typeof context.client.getServerVersion === 'function' ? context.client.getServerVersion() : undefined;
|
|
154
|
+
const derived = pickDescription(instructions, serverInfo);
|
|
155
|
+
return derived;
|
|
156
|
+
} catch {
|
|
157
|
+
// Ignore metadata lookup failures; fallback description will be used instead.
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function pickDescription(
|
|
163
|
+
instructions: unknown,
|
|
164
|
+
serverInfo: { title?: unknown; name?: unknown } | undefined
|
|
165
|
+
): string | undefined {
|
|
166
|
+
const ordered = [instructions, serverInfo?.title, serverInfo?.name];
|
|
167
|
+
for (const candidate of ordered) {
|
|
168
|
+
if (typeof candidate === 'string') {
|
|
169
|
+
const trimmed = candidate.trim();
|
|
170
|
+
if (trimmed.length > 0) {
|
|
171
|
+
return trimmed;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function normalizeDefinition(def: DefinitionInput): ServerDefinition {
|
|
179
|
+
if (isServerDefinition(def)) {
|
|
180
|
+
return def;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const name = def.name;
|
|
184
|
+
if (typeof name !== 'string' || name.trim().length === 0) {
|
|
185
|
+
throw new Error('Server definition must include a name.');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const description = typeof def.description === 'string' ? def.description : undefined;
|
|
189
|
+
const env = toStringRecord(def.env);
|
|
190
|
+
const auth = typeof def.auth === 'string' ? def.auth : undefined;
|
|
191
|
+
const tokenCacheDir = typeof def.tokenCacheDir === 'string' ? def.tokenCacheDir : undefined;
|
|
192
|
+
const clientName = typeof def.clientName === 'string' ? def.clientName : undefined;
|
|
193
|
+
const headers = toStringRecord((def as Record<string, unknown>).headers);
|
|
194
|
+
|
|
195
|
+
const commandValue = def.command;
|
|
196
|
+
if (isCommandSpec(commandValue)) {
|
|
197
|
+
return {
|
|
198
|
+
name,
|
|
199
|
+
description,
|
|
200
|
+
command: normalizeCommand(commandValue, headers),
|
|
201
|
+
env,
|
|
202
|
+
auth,
|
|
203
|
+
tokenCacheDir,
|
|
204
|
+
clientName,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
if (typeof commandValue === 'string' && commandValue.trim().length > 0) {
|
|
208
|
+
return {
|
|
209
|
+
name,
|
|
210
|
+
description,
|
|
211
|
+
command: toCommandSpec(commandValue, getStringArray(def.args), headers ? { headers } : undefined),
|
|
212
|
+
env,
|
|
213
|
+
auth,
|
|
214
|
+
tokenCacheDir,
|
|
215
|
+
clientName,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
if (Array.isArray(commandValue) && commandValue.length > 0) {
|
|
219
|
+
const [first, ...rest] = commandValue;
|
|
220
|
+
if (typeof first !== 'string' || !rest.every((entry) => typeof entry === 'string')) {
|
|
221
|
+
throw new Error('Command array must contain only strings.');
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
name,
|
|
225
|
+
description,
|
|
226
|
+
command: toCommandSpec(first, rest as string[], headers ? { headers } : undefined),
|
|
227
|
+
env,
|
|
228
|
+
auth,
|
|
229
|
+
tokenCacheDir,
|
|
230
|
+
clientName,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
throw new Error('Server definition must include command information.');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function isServerDefinition(value: unknown): value is ServerDefinition {
|
|
237
|
+
if (typeof value !== 'object' || value === null) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
const record = value as Record<string, unknown>;
|
|
241
|
+
if (typeof record.name !== 'string') {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return isCommandSpec(record.command);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function isCommandSpec(value: unknown): value is ServerDefinition['command'] {
|
|
248
|
+
if (typeof value !== 'object' || value === null) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const candidate = value as { kind?: unknown };
|
|
252
|
+
if (candidate.kind === 'http') {
|
|
253
|
+
return 'url' in candidate;
|
|
254
|
+
}
|
|
255
|
+
if (candidate.kind === 'stdio') {
|
|
256
|
+
return 'command' in candidate;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function normalizeCommand(
|
|
262
|
+
command: ServerDefinition['command'],
|
|
263
|
+
headers?: Record<string, string>
|
|
264
|
+
): ServerDefinition['command'] {
|
|
265
|
+
if (command.kind === 'http') {
|
|
266
|
+
const urlValue = command.url;
|
|
267
|
+
const url = urlValue instanceof URL ? urlValue : new URL(String(urlValue));
|
|
268
|
+
const mergedHeaders = command.headers ? (headers ? { ...command.headers, ...headers } : command.headers) : headers;
|
|
269
|
+
const normalized: HttpCommand = {
|
|
270
|
+
kind: 'http',
|
|
271
|
+
url,
|
|
272
|
+
...(mergedHeaders ? { headers: mergedHeaders } : {}),
|
|
273
|
+
};
|
|
274
|
+
return normalized;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
kind: 'stdio',
|
|
278
|
+
command: command.command,
|
|
279
|
+
args: [...command.args],
|
|
280
|
+
cwd: command.cwd ?? process.cwd(),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function toCommandSpec(
|
|
285
|
+
command: string,
|
|
286
|
+
args?: string[],
|
|
287
|
+
extra?: { headers?: Record<string, string> }
|
|
288
|
+
): ServerDefinition['command'] {
|
|
289
|
+
if (command.startsWith('http://') || command.startsWith('https://')) {
|
|
290
|
+
const httpCommand: HttpCommand = {
|
|
291
|
+
kind: 'http',
|
|
292
|
+
url: new URL(command),
|
|
293
|
+
...(extra?.headers ? { headers: extra.headers } : {}),
|
|
294
|
+
};
|
|
295
|
+
return httpCommand;
|
|
296
|
+
}
|
|
297
|
+
const stdio: StdioCommand = {
|
|
298
|
+
kind: 'stdio',
|
|
299
|
+
command,
|
|
300
|
+
args: args ?? [],
|
|
301
|
+
cwd: process.cwd(),
|
|
302
|
+
};
|
|
303
|
+
return stdio;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function getStringArray(value: unknown): string[] | undefined {
|
|
307
|
+
if (!Array.isArray(value)) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
const entries = value.filter((item): item is string => typeof item === 'string');
|
|
311
|
+
return entries.length > 0 ? entries : undefined;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function toStringRecord(value: unknown): Record<string, string> | undefined {
|
|
315
|
+
if (typeof value !== 'object' || value === null) {
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
const result: Record<string, string> = {};
|
|
319
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
320
|
+
if (typeof entry === 'string') {
|
|
321
|
+
result[key] = entry;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
325
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface GeneratorCommonFlags {
|
|
2
|
+
runtime?: 'node' | 'bun';
|
|
3
|
+
timeout?: number;
|
|
4
|
+
includeOptional?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface ExtractOptions {
|
|
8
|
+
allowIncludeOptional?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function extractGeneratorFlags(args: string[], options: ExtractOptions = {}): GeneratorCommonFlags {
|
|
12
|
+
const result: GeneratorCommonFlags = {};
|
|
13
|
+
let index = 0;
|
|
14
|
+
while (index < args.length) {
|
|
15
|
+
const token = args[index];
|
|
16
|
+
if (!token) {
|
|
17
|
+
index += 1;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (token === '--runtime') {
|
|
21
|
+
const value = args[index + 1];
|
|
22
|
+
if (value !== 'node' && value !== 'bun') {
|
|
23
|
+
throw new Error("--runtime must be 'node' or 'bun'.");
|
|
24
|
+
}
|
|
25
|
+
result.runtime = value;
|
|
26
|
+
args.splice(index, 2);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (token === '--timeout') {
|
|
30
|
+
const raw = args[index + 1];
|
|
31
|
+
if (!raw) {
|
|
32
|
+
throw new Error("Flag '--timeout' requires a value.");
|
|
33
|
+
}
|
|
34
|
+
const parsed = Number.parseInt(raw, 10);
|
|
35
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
36
|
+
throw new Error('--timeout must be a positive integer.');
|
|
37
|
+
}
|
|
38
|
+
result.timeout = parsed;
|
|
39
|
+
args.splice(index, 2);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (options.allowIncludeOptional && (token === '--include-optional' || token === '--all-parameters')) {
|
|
43
|
+
result.includeOptional = true;
|
|
44
|
+
args.splice(index, 1);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
index += 1;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|