@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,217 @@
|
|
|
1
|
+
import type { GeneratedOption } from './generate/tools.js';
|
|
2
|
+
import { buildFallbackLiteral, pickExampleLiteral } from './generate/tools.js';
|
|
3
|
+
import { cyanText, dimText, extraDimText } from './terminal.js';
|
|
4
|
+
|
|
5
|
+
export interface SignatureFormatOptions {
|
|
6
|
+
colorize?: boolean;
|
|
7
|
+
defaultReturnType?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FlagUsageExtra {
|
|
11
|
+
text: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function formatFunctionSignature(
|
|
16
|
+
name: string,
|
|
17
|
+
options: GeneratedOption[],
|
|
18
|
+
outputSchema: unknown,
|
|
19
|
+
formatOptions?: SignatureFormatOptions
|
|
20
|
+
): string {
|
|
21
|
+
const colorize = formatOptions?.colorize !== false;
|
|
22
|
+
const keyword = colorize ? extraDimText('function') : 'function';
|
|
23
|
+
const formattedName = colorize ? cyanText(name) : name;
|
|
24
|
+
const paramsText = options.map((option) => formatInlineParameter(option, colorize)).join(', ');
|
|
25
|
+
const returnType = inferReturnTypeName(outputSchema) ?? formatOptions?.defaultReturnType;
|
|
26
|
+
const signature = `${keyword} ${formattedName}(${paramsText})`;
|
|
27
|
+
return returnType ? `${signature}: ${returnType};` : `${signature};`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function formatOptionalSummary(hiddenOptions: GeneratedOption[], options?: { colorize?: boolean }): string {
|
|
31
|
+
const colorize = options?.colorize !== false;
|
|
32
|
+
const maxNames = 5;
|
|
33
|
+
const names = hiddenOptions.map((option) => option.property);
|
|
34
|
+
if (names.length === 0) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
const preview = names.slice(0, maxNames).join(', ');
|
|
38
|
+
const suffix = names.length > maxNames ? ', ...' : '';
|
|
39
|
+
const tint = colorize ? extraDimText : (value: string): string => value;
|
|
40
|
+
return tint(`// optional (${names.length}): ${preview}${suffix}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function formatFlagUsage(
|
|
44
|
+
options: GeneratedOption[],
|
|
45
|
+
extras?: FlagUsageExtra[],
|
|
46
|
+
opts?: { colorize?: boolean }
|
|
47
|
+
): string {
|
|
48
|
+
const colorize = opts?.colorize !== false;
|
|
49
|
+
const entries: Array<{ text: string; required: boolean }> = options.map((option) => ({
|
|
50
|
+
text: formatFlagLabel(option),
|
|
51
|
+
required: option.required,
|
|
52
|
+
}));
|
|
53
|
+
if (extras) {
|
|
54
|
+
entries.push(
|
|
55
|
+
...extras
|
|
56
|
+
.map((extra) => ({
|
|
57
|
+
text: extra.text.trim(),
|
|
58
|
+
required: Boolean(extra.required),
|
|
59
|
+
}))
|
|
60
|
+
.filter((entry) => entry.text.length > 0)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const parts = entries
|
|
64
|
+
.filter((entry) => entry.text.length > 0)
|
|
65
|
+
.map((entry) => (entry.required ? entry.text : `[${entry.text}]`));
|
|
66
|
+
if (parts.length === 0) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
const rendered = parts.join(' ');
|
|
70
|
+
return colorize ? extraDimText(rendered) : rendered;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function formatFlagLabel(option: GeneratedOption): string {
|
|
74
|
+
return `--${option.cliName} ${option.placeholder}`.trim();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function formatCallExpressionExample(
|
|
78
|
+
serverName: string,
|
|
79
|
+
toolName: string,
|
|
80
|
+
options: GeneratedOption[],
|
|
81
|
+
extra?: { callSelector?: string; wrapExpression?: boolean }
|
|
82
|
+
): string | undefined {
|
|
83
|
+
const assignments = options
|
|
84
|
+
.map((option) => ({ option, literal: pickExampleLiteral(option) }))
|
|
85
|
+
.filter(({ option, literal }) => option.required || literal !== undefined)
|
|
86
|
+
.map(({ option, literal }) => {
|
|
87
|
+
const value = literal ?? buildFallbackLiteral(option);
|
|
88
|
+
return `${option.property}: ${value}`;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const args = assignments.join(', ');
|
|
92
|
+
const callSuffix = assignments.length > 0 ? `(${args})` : '()';
|
|
93
|
+
const selector = extra?.callSelector ?? serverName;
|
|
94
|
+
const expression = `${selector}.${toolName}${callSuffix}`;
|
|
95
|
+
const rendered = extra?.wrapExpression ? quoteShellExpression(expression) : expression;
|
|
96
|
+
return `mcporter call ${rendered}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function formatExampleBlock(
|
|
100
|
+
examples: string[],
|
|
101
|
+
options?: { maxExamples?: number; maxLength?: number }
|
|
102
|
+
): string[] {
|
|
103
|
+
const maxExamples = options?.maxExamples ?? 1;
|
|
104
|
+
const maxLength = options?.maxLength ?? 80;
|
|
105
|
+
return Array.from(new Set(examples))
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.slice(0, maxExamples)
|
|
108
|
+
.map((example) => truncateExample(example, maxLength));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function truncateExample(example: string, maxLength: number): string {
|
|
112
|
+
if (example.length <= maxLength) {
|
|
113
|
+
return example;
|
|
114
|
+
}
|
|
115
|
+
const openIndex = example.indexOf('(');
|
|
116
|
+
const closeIndex = example.lastIndexOf(')');
|
|
117
|
+
if (openIndex === -1 || closeIndex === -1 || closeIndex <= openIndex) {
|
|
118
|
+
return `${example.slice(0, Math.max(0, maxLength - 1))}…`;
|
|
119
|
+
}
|
|
120
|
+
const prefix = example.slice(0, openIndex + 1);
|
|
121
|
+
const suffix = example.slice(closeIndex);
|
|
122
|
+
const available = maxLength - prefix.length - suffix.length - 5;
|
|
123
|
+
if (available <= 0) {
|
|
124
|
+
return `${prefix}...${suffix}`;
|
|
125
|
+
}
|
|
126
|
+
const args = example.slice(openIndex + 1, closeIndex).trim();
|
|
127
|
+
const shortened = args
|
|
128
|
+
.slice(0, available)
|
|
129
|
+
.trimEnd()
|
|
130
|
+
.replace(/[\s,]+$/, '');
|
|
131
|
+
const ellipsis = shortened.length > 0 ? `${shortened}, ...` : '...';
|
|
132
|
+
return `${prefix}${ellipsis}${suffix}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function formatInlineParameter(option: GeneratedOption, colorize: boolean): string {
|
|
136
|
+
const typeAnnotation = formatTypeAnnotation(option, colorize);
|
|
137
|
+
const optionalSuffix = option.required ? '' : '?';
|
|
138
|
+
return `${option.property}${optionalSuffix}: ${typeAnnotation}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function quoteShellExpression(expression: string): string {
|
|
142
|
+
if (!expression.includes("'")) {
|
|
143
|
+
return `'${expression}'`;
|
|
144
|
+
}
|
|
145
|
+
const escaped = expression.replace(/(["\\$`])/g, '\\$1');
|
|
146
|
+
return `"${escaped}"`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function inferReturnTypeName(schema: unknown): string | undefined {
|
|
150
|
+
if (!schema || typeof schema !== 'object') {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return inferSchemaDisplayType(schema as Record<string, unknown>);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function inferSchemaDisplayType(descriptor: Record<string, unknown>): string {
|
|
157
|
+
const title = typeof descriptor.title === 'string' ? descriptor.title.trim() : undefined;
|
|
158
|
+
if (title) {
|
|
159
|
+
return title;
|
|
160
|
+
}
|
|
161
|
+
const type = typeof descriptor.type === 'string' ? (descriptor.type as string) : undefined;
|
|
162
|
+
if (!type && typeof descriptor.properties === 'object') {
|
|
163
|
+
return 'object';
|
|
164
|
+
}
|
|
165
|
+
if (!type && descriptor.items && typeof descriptor.items === 'object') {
|
|
166
|
+
return `${inferSchemaDisplayType(descriptor.items as Record<string, unknown>)}[]`;
|
|
167
|
+
}
|
|
168
|
+
if (type === 'array' && descriptor.items && typeof descriptor.items === 'object') {
|
|
169
|
+
return `${inferSchemaDisplayType(descriptor.items as Record<string, unknown>)}[]`;
|
|
170
|
+
}
|
|
171
|
+
if (!type && Array.isArray(descriptor.enum)) {
|
|
172
|
+
const values = (descriptor.enum as unknown[]).filter((entry): entry is string => typeof entry === 'string');
|
|
173
|
+
if (values.length > 0) {
|
|
174
|
+
return values.map((entry) => JSON.stringify(entry)).join(' | ');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return type ?? 'unknown';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function formatTypeAnnotation(option: GeneratedOption, colorize: boolean): string {
|
|
181
|
+
let baseType: string;
|
|
182
|
+
if (option.enumValues && option.enumValues.length > 0) {
|
|
183
|
+
baseType = option.enumValues.map((value) => JSON.stringify(value)).join(' | ');
|
|
184
|
+
} else {
|
|
185
|
+
switch (option.type) {
|
|
186
|
+
case 'number':
|
|
187
|
+
baseType = 'number';
|
|
188
|
+
break;
|
|
189
|
+
case 'boolean':
|
|
190
|
+
baseType = 'boolean';
|
|
191
|
+
break;
|
|
192
|
+
case 'array':
|
|
193
|
+
baseType = 'string[]';
|
|
194
|
+
break;
|
|
195
|
+
case 'string':
|
|
196
|
+
baseType = 'string';
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
baseType = 'unknown';
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const tint = colorize ? dimText : (value: string): string => value;
|
|
204
|
+
const base = tint(baseType);
|
|
205
|
+
if (option.formatHint && option.type === 'string' && (!option.enumValues || option.enumValues.length === 0)) {
|
|
206
|
+
const descriptionText = option.description?.toLowerCase() ?? '';
|
|
207
|
+
const hintLower = option.formatHint.toLowerCase();
|
|
208
|
+
const normalizedDescription = descriptionText.replace(/[\s_-]+/g, '');
|
|
209
|
+
const normalizedHint = hintLower.replace(/[\s_-]+/g, '');
|
|
210
|
+
const hasHintInDescription = descriptionText.includes(hintLower) || normalizedDescription.includes(normalizedHint);
|
|
211
|
+
if (hasHintInDescription) {
|
|
212
|
+
return base;
|
|
213
|
+
}
|
|
214
|
+
return `${base} ${tint(`/* ${option.formatHint} */`)}`;
|
|
215
|
+
}
|
|
216
|
+
return base;
|
|
217
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createPrefixedConsoleLogger, type Logger, type LogLevel, resolveLogLevelFromEnv } from '../logging.js';
|
|
2
|
+
|
|
3
|
+
let activeLogLevel: LogLevel = resolveLogLevelFromEnv();
|
|
4
|
+
let activeLogger: Logger = createPrefixedConsoleLogger('mcporter', activeLogLevel);
|
|
5
|
+
|
|
6
|
+
export function getActiveLogLevel(): LogLevel {
|
|
7
|
+
return activeLogLevel;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getActiveLogger(): Logger {
|
|
11
|
+
return activeLogger;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function setLogLevel(level: LogLevel): void {
|
|
15
|
+
activeLogLevel = level;
|
|
16
|
+
activeLogger = createPrefixedConsoleLogger('mcporter', activeLogLevel);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function setLogger(logger: Logger, level?: LogLevel): void {
|
|
20
|
+
activeLogger = logger;
|
|
21
|
+
if (level) {
|
|
22
|
+
activeLogLevel = level;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function logInfo(message: string): void {
|
|
27
|
+
activeLogger.info(message);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function logWarn(message: string): void {
|
|
31
|
+
activeLogger.warn(message);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function logError(message: string, error?: unknown): void {
|
|
35
|
+
activeLogger.error(message, error);
|
|
36
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { OutputFormat } from './output-utils.js';
|
|
2
|
+
|
|
3
|
+
interface ConsumeOutputOptions {
|
|
4
|
+
defaultFormat?: OutputFormat;
|
|
5
|
+
allowed?: OutputFormat[];
|
|
6
|
+
enableRawShortcut?: boolean;
|
|
7
|
+
jsonShortcutFlag?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function consumeOutputFormat(args: string[], options: ConsumeOutputOptions = {}): OutputFormat {
|
|
11
|
+
const allowed = options.allowed ?? ['auto', 'text', 'markdown', 'json', 'raw'];
|
|
12
|
+
const defaultFormat = options.defaultFormat ?? 'auto';
|
|
13
|
+
const enableRawShortcut = options.enableRawShortcut !== false;
|
|
14
|
+
let format: OutputFormat = defaultFormat;
|
|
15
|
+
|
|
16
|
+
const isAllowed = (value: OutputFormat): boolean => allowed.includes(value);
|
|
17
|
+
|
|
18
|
+
let index = 0;
|
|
19
|
+
while (index < args.length) {
|
|
20
|
+
const token = args[index];
|
|
21
|
+
if (token === '--output') {
|
|
22
|
+
const value = args[index + 1];
|
|
23
|
+
if (!value) {
|
|
24
|
+
throw new Error("Flag '--output' requires a value.");
|
|
25
|
+
}
|
|
26
|
+
if (!isCliOutputFormat(value)) {
|
|
27
|
+
throw new Error('--output format must be one of: auto, text, markdown, json, raw.');
|
|
28
|
+
}
|
|
29
|
+
if (!isAllowed(value)) {
|
|
30
|
+
throw new Error(`--output format '${value}' is not supported for this command.`);
|
|
31
|
+
}
|
|
32
|
+
format = value;
|
|
33
|
+
args.splice(index, 2);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (enableRawShortcut && token === '--raw') {
|
|
37
|
+
if (!isAllowed('raw')) {
|
|
38
|
+
throw new Error('--raw is not supported for this command.');
|
|
39
|
+
}
|
|
40
|
+
format = 'raw';
|
|
41
|
+
args.splice(index, 1);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (options.jsonShortcutFlag && token === options.jsonShortcutFlag) {
|
|
45
|
+
if (!isAllowed('json')) {
|
|
46
|
+
throw new Error(`${options.jsonShortcutFlag} is not supported for this command.`);
|
|
47
|
+
}
|
|
48
|
+
format = 'json';
|
|
49
|
+
args.splice(index, 1);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
index += 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!isAllowed(format)) {
|
|
56
|
+
throw new Error(`Format '${format}' is not supported for this command.`);
|
|
57
|
+
}
|
|
58
|
+
return format;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function isCliOutputFormat(value: string): value is OutputFormat {
|
|
62
|
+
return value === 'auto' || value === 'text' || value === 'markdown' || value === 'json' || value === 'raw';
|
|
63
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { inspect } from 'node:util';
|
|
3
|
+
import type { CallResult } from '../result-utils.js';
|
|
4
|
+
import { logWarn } from './logger-context.js';
|
|
5
|
+
|
|
6
|
+
export type OutputFormat = 'auto' | 'text' | 'markdown' | 'json' | 'raw';
|
|
7
|
+
const RAW_INSPECT_DEPTH = 8;
|
|
8
|
+
|
|
9
|
+
type RenderableKind = 'json' | 'markdown' | 'text' | 'raw';
|
|
10
|
+
|
|
11
|
+
interface RenderableOutput {
|
|
12
|
+
kind: RenderableKind;
|
|
13
|
+
value: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const PREFERRED_OUTPUT_BY_FORMAT: Record<OutputFormat, RenderableKind[]> = {
|
|
17
|
+
auto: ['json', 'markdown', 'text', 'raw'],
|
|
18
|
+
text: ['text', 'markdown', 'json', 'raw'],
|
|
19
|
+
markdown: ['markdown', 'text', 'json', 'raw'],
|
|
20
|
+
json: ['json', 'raw'],
|
|
21
|
+
raw: ['raw'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function printCallOutput<T>(wrapped: CallResult<T>, raw: T, format: OutputFormat): void {
|
|
25
|
+
const preferredKinds = PREFERRED_OUTPUT_BY_FORMAT[format];
|
|
26
|
+
const renderable = resolveRenderableOutput(wrapped, raw, preferredKinds);
|
|
27
|
+
emitRenderableOutput(renderable);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function tailLogIfRequested(result: unknown, enabled: boolean): void {
|
|
31
|
+
// Some transports still encode log paths inside tool results; tail when explicitly asked.
|
|
32
|
+
if (!enabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const candidates: string[] = [];
|
|
36
|
+
if (typeof result === 'string') {
|
|
37
|
+
const idx = result.indexOf(':');
|
|
38
|
+
if (idx !== -1) {
|
|
39
|
+
const candidate = result.slice(idx + 1).trim();
|
|
40
|
+
if (candidate) {
|
|
41
|
+
candidates.push(candidate);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (result && typeof result === 'object') {
|
|
46
|
+
const possibleKeys = ['logPath', 'logFile', 'logfile', 'path'];
|
|
47
|
+
for (const key of possibleKeys) {
|
|
48
|
+
const value = (result as Record<string, unknown>)[key];
|
|
49
|
+
if (typeof value === 'string') {
|
|
50
|
+
candidates.push(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const candidate of candidates) {
|
|
56
|
+
if (!fs.existsSync(candidate)) {
|
|
57
|
+
logWarn(`Log path not found: ${candidate}`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const content = fs.readFileSync(candidate, 'utf8');
|
|
62
|
+
const lines = content.trimEnd().split(/\r?\n/);
|
|
63
|
+
const tail = lines.slice(-20);
|
|
64
|
+
console.log(`--- tail ${candidate} ---`);
|
|
65
|
+
for (const line of tail) {
|
|
66
|
+
console.log(line);
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
logWarn(`Failed to read log file ${candidate}: ${(error as Error).message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function resolveRenderableOutput<T>(
|
|
75
|
+
wrapped: CallResult<T>,
|
|
76
|
+
raw: T,
|
|
77
|
+
preferredKinds: RenderableKind[]
|
|
78
|
+
): RenderableOutput {
|
|
79
|
+
for (const kind of preferredKinds) {
|
|
80
|
+
if (kind === 'json') {
|
|
81
|
+
const jsonValue = wrapped.json();
|
|
82
|
+
if (jsonValue !== null) {
|
|
83
|
+
return { kind, value: jsonValue };
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (kind === 'markdown') {
|
|
88
|
+
const markdown = wrapped.markdown();
|
|
89
|
+
if (typeof markdown === 'string') {
|
|
90
|
+
return { kind, value: markdown };
|
|
91
|
+
}
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (kind === 'text') {
|
|
95
|
+
const text = wrapped.text();
|
|
96
|
+
if (typeof text === 'string') {
|
|
97
|
+
return { kind, value: text };
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (kind === 'raw') {
|
|
102
|
+
return { kind, value: raw };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { kind: 'raw', value: raw };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function emitRenderableOutput(renderable: RenderableOutput): void {
|
|
109
|
+
if (renderable.kind === 'json') {
|
|
110
|
+
if (!attemptPrintJson(renderable.value)) {
|
|
111
|
+
printRaw(renderable.value);
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (renderable.kind === 'markdown' || renderable.kind === 'text') {
|
|
116
|
+
console.log(String(renderable.value));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
printRaw(renderable.value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function attemptPrintJson(value: unknown): boolean {
|
|
123
|
+
if (value === undefined) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
if (value === null) {
|
|
128
|
+
console.log('null');
|
|
129
|
+
} else {
|
|
130
|
+
console.log(JSON.stringify(value, null, 2));
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function printRaw(raw: unknown): void {
|
|
139
|
+
if (typeof raw === 'string') {
|
|
140
|
+
console.log(raw);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (raw === null) {
|
|
144
|
+
console.log('null');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (raw === undefined) {
|
|
148
|
+
console.log('undefined');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (typeof raw === 'bigint') {
|
|
152
|
+
console.log(raw.toString());
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (typeof raw === 'symbol' || typeof raw === 'function') {
|
|
156
|
+
console.log(raw.toString());
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// Keep nested payloads readable without unbounded inspect walks on huge objects.
|
|
160
|
+
console.log(inspect(raw, { depth: RAW_INSPECT_DEPTH, maxStringLength: null, breakLength: 80 }));
|
|
161
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
// formatPathForDisplay rewrites absolute paths into user-friendly display strings.
|
|
5
|
+
export function formatPathForDisplay(filePath: string): string {
|
|
6
|
+
const cwd = process.cwd();
|
|
7
|
+
const relative = path.relative(cwd, filePath);
|
|
8
|
+
const displayPath =
|
|
9
|
+
relative && !relative.startsWith('..') && !path.isAbsolute(relative)
|
|
10
|
+
? relative
|
|
11
|
+
: filePath.replace(os.homedir(), '~');
|
|
12
|
+
return displayPath;
|
|
13
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
import { logInfo, logWarn } from './logger-context.js';
|
|
3
|
+
|
|
4
|
+
export const DEBUG_HANG = process.env.MCPORTER_DEBUG_HANG === '1';
|
|
5
|
+
|
|
6
|
+
type ProcessWithHandles = NodeJS.Process & {
|
|
7
|
+
_getActiveHandles?: () => unknown[];
|
|
8
|
+
_getActiveRequests?: () => unknown[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function describeHandle(handle: unknown): string {
|
|
12
|
+
if (!handle || (typeof handle !== 'object' && typeof handle !== 'function')) {
|
|
13
|
+
return String(handle);
|
|
14
|
+
}
|
|
15
|
+
const ctor = (handle as { constructor?: { name?: string } }).constructor?.name ?? typeof handle;
|
|
16
|
+
if (ctor === 'Socket') {
|
|
17
|
+
try {
|
|
18
|
+
const socket = handle as {
|
|
19
|
+
localAddress?: string;
|
|
20
|
+
localPort?: number;
|
|
21
|
+
remoteAddress?: string;
|
|
22
|
+
remotePort?: number;
|
|
23
|
+
};
|
|
24
|
+
const parts: string[] = ['Socket'];
|
|
25
|
+
if (socket.localAddress) {
|
|
26
|
+
parts.push(`local=${socket.localAddress}:${socket.localPort ?? '?'}`);
|
|
27
|
+
}
|
|
28
|
+
if (socket.remoteAddress) {
|
|
29
|
+
parts.push(`remote=${socket.remoteAddress}:${socket.remotePort ?? '?'}`);
|
|
30
|
+
}
|
|
31
|
+
if (typeof (socket as { address?: () => { address: string; port: number } | null }).address === 'function') {
|
|
32
|
+
const addr = (socket as { address?: () => { address: string; port: number } | null }).address?.();
|
|
33
|
+
if (addr) {
|
|
34
|
+
parts.push(`addr=${addr.address}:${addr.port}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const host = (handle as { _host?: string })._host;
|
|
38
|
+
if (host) {
|
|
39
|
+
parts.push(`host=${host}`);
|
|
40
|
+
}
|
|
41
|
+
const pipeName = (handle as { path?: string }).path;
|
|
42
|
+
if (pipeName) {
|
|
43
|
+
parts.push(`path=${pipeName}`);
|
|
44
|
+
}
|
|
45
|
+
const extraKeys = Reflect.ownKeys(handle as Record<string | symbol, unknown>)
|
|
46
|
+
.filter((key) => typeof key === 'string' && key.startsWith('_') && !['_events', '_eventsCount'].includes(key))
|
|
47
|
+
.slice(0, 4) as string[];
|
|
48
|
+
if (extraKeys.length > 0) {
|
|
49
|
+
parts.push(`keys=${extraKeys.join(',')}`);
|
|
50
|
+
}
|
|
51
|
+
return parts.join(' ');
|
|
52
|
+
} catch {
|
|
53
|
+
return ctor;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (typeof handle === 'object') {
|
|
57
|
+
const pid = (handle as { pid?: number }).pid;
|
|
58
|
+
if (typeof pid === 'number') {
|
|
59
|
+
return `${ctor} (pid=${pid})`;
|
|
60
|
+
}
|
|
61
|
+
const fd = (handle as { fd?: number }).fd;
|
|
62
|
+
if (typeof fd === 'number') {
|
|
63
|
+
return `${ctor} (fd=${fd})`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return ctor;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function dumpActiveHandles(label: string): void {
|
|
70
|
+
if (!DEBUG_HANG) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const proc = process as ProcessWithHandles;
|
|
74
|
+
const activeHandles = proc._getActiveHandles?.() ?? [];
|
|
75
|
+
const activeRequests = proc._getActiveRequests?.() ?? [];
|
|
76
|
+
logInfo(`[debug] ${label}: ${activeHandles.length} active handle(s), ${activeRequests.length} request(s)`);
|
|
77
|
+
for (const handle of activeHandles) {
|
|
78
|
+
logInfo(`[debug] handle => ${describeHandle(handle)}`);
|
|
79
|
+
}
|
|
80
|
+
for (const request of activeRequests) {
|
|
81
|
+
logInfo(`[debug] request => ${describeHandle(request)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function terminateChildProcesses(label: string): void {
|
|
86
|
+
const proc = process as ProcessWithHandles;
|
|
87
|
+
const handles = proc._getActiveHandles?.() ?? [];
|
|
88
|
+
for (const handle of handles) {
|
|
89
|
+
if (!handle || typeof handle !== 'object') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const candidate = handle as ChildProcess;
|
|
93
|
+
const ctor = (handle as { constructor?: { name?: string } }).constructor?.name ?? '';
|
|
94
|
+
if (ctor === 'Socket' && typeof (handle as { destroy?: () => void }).destroy === 'function') {
|
|
95
|
+
try {
|
|
96
|
+
(handle as { destroy?: () => void }).destroy?.();
|
|
97
|
+
if (typeof (handle as { unref?: () => void }).unref === 'function') {
|
|
98
|
+
(handle as { unref?: () => void }).unref?.();
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
// ignore
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (typeof (candidate.stdout as { destroy?: () => void } | undefined)?.destroy === 'function') {
|
|
105
|
+
try {
|
|
106
|
+
(candidate.stdout as { destroy?: () => void }).destroy?.();
|
|
107
|
+
} catch {
|
|
108
|
+
// ignore
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (typeof (candidate.stderr as { destroy?: () => void } | undefined)?.destroy === 'function') {
|
|
112
|
+
try {
|
|
113
|
+
(candidate.stderr as { destroy?: () => void }).destroy?.();
|
|
114
|
+
} catch {
|
|
115
|
+
// ignore
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (typeof (candidate.stdin as { end?: () => void } | undefined)?.end === 'function') {
|
|
119
|
+
try {
|
|
120
|
+
(candidate.stdin as { end?: () => void }).end?.();
|
|
121
|
+
} catch {
|
|
122
|
+
// ignore
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// When DEBUG_HANG is enabled we leave extra breadcrumbs so developers can see
|
|
126
|
+
// which transports required forceful teardown before Node would exit.
|
|
127
|
+
if (DEBUG_HANG) {
|
|
128
|
+
const killed = candidate.kill?.('SIGKILL') ?? false;
|
|
129
|
+
if (candidate.pid) {
|
|
130
|
+
const outcome = killed ? 'killed' : 'kill-failed';
|
|
131
|
+
logWarn(`[debug] forcibly ${outcome} child pid=${candidate.pid} (${label})`);
|
|
132
|
+
}
|
|
133
|
+
} else if (typeof candidate.kill === 'function' && typeof candidate.pid === 'number' && !candidate.killed) {
|
|
134
|
+
try {
|
|
135
|
+
candidate.kill('SIGKILL');
|
|
136
|
+
} catch {
|
|
137
|
+
// ignore
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerDefinition } from '../config.js';
|
|
2
|
+
import { normalizeHttpUrl } from './http-utils.js';
|
|
3
|
+
|
|
4
|
+
export function findServerByHttpUrl(definitions: readonly ServerDefinition[], urlString: string): string | undefined {
|
|
5
|
+
const normalizedTarget = normalizeHttpUrl(urlString);
|
|
6
|
+
if (!normalizedTarget) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
for (const definition of definitions) {
|
|
10
|
+
if (definition.command.kind !== 'http') {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const normalizedDefinitionUrl = normalizeHttpUrl(definition.command.url);
|
|
14
|
+
if (!normalizedDefinitionUrl) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (normalizedDefinitionUrl === normalizedTarget) {
|
|
18
|
+
return definition.name;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const forceColorRaw = process.env.FORCE_COLOR?.toLowerCase();
|
|
2
|
+
const forceDisableColor = forceColorRaw === '0' || forceColorRaw === 'false';
|
|
3
|
+
const forceEnableColor =
|
|
4
|
+
forceColorRaw === '1' || forceColorRaw === 'true' || forceColorRaw === '2' || forceColorRaw === '3';
|
|
5
|
+
const hasNoColor = process.env.NO_COLOR !== undefined;
|
|
6
|
+
const stdoutStream = process.stdout as NodeJS.WriteStream | undefined;
|
|
7
|
+
|
|
8
|
+
export const supportsAnsiColor =
|
|
9
|
+
!hasNoColor && (forceEnableColor || (!forceDisableColor && Boolean(stdoutStream?.isTTY)));
|
|
10
|
+
|
|
11
|
+
// colorize wraps a string in ANSI color codes when output supports them.
|
|
12
|
+
export function colorize(code: number, text: string): string {
|
|
13
|
+
if (!supportsAnsiColor) {
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
return `\u001B[${code}m${text}\u001B[0m`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const dimText = (text: string): string => colorize(90, text);
|
|
20
|
+
export const yellowText = (text: string): string => colorize(33, text);
|
|
21
|
+
export const redText = (text: string): string => colorize(31, text);
|
|
22
|
+
export const extraDimText = (text: string): string => {
|
|
23
|
+
if (!supportsAnsiColor) {
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
return `\u001B[38;5;244m${text}\u001B[0m`;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const cyanText = (text: string): string => colorize(36, text);
|
|
30
|
+
|
|
31
|
+
export const boldText = (text: string): string => {
|
|
32
|
+
if (!supportsAnsiColor) {
|
|
33
|
+
return text;
|
|
34
|
+
}
|
|
35
|
+
return `\u001B[1m${text}\u001B[0m`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const isCI = Boolean(process.env.CI && process.env.CI !== '0' && process.env.CI.toLowerCase() !== 'false');
|
|
39
|
+
const spinnerDisabled = process.env.MCPORTER_NO_SPINNER === '1';
|
|
40
|
+
|
|
41
|
+
export const supportsSpinner = Boolean(stdoutStream?.isTTY && !isCI && !spinnerDisabled);
|