@mastra/code-sdk 0.0.0-esbuild-bundle-worker-20260807173433
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1349 -0
- package/LICENSE.md +30 -0
- package/README.md +70 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +161 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +214 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +65 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +2 -0
- package/dist/agents/credential-resolver.d.ts +51 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -0
- package/dist/agents/credential-resolver.js +52 -0
- package/dist/agents/credential-resolver.js.map +1 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.d.ts.map +1 -0
- package/dist/agents/custom-provider-source.js +25 -0
- package/dist/agents/custom-provider-source.js.map +1 -0
- package/dist/agents/instructions.d.ts +6 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +32 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +74 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +400 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +13 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +116 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +59 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +132 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +44 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +39 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +37 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +61 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +201 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +76 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +26 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +19 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +65 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +23 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +111 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +13 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +149 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +99 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +328 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/sandbox-reattach.d.ts +19 -0
- package/dist/agents/sandbox-reattach.d.ts.map +1 -0
- package/dist/agents/sandbox-reattach.js +15 -0
- package/dist/agents/sandbox-reattach.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +107 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +87 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +19 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +105 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workspace.d.ts +32 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +251 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +163 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.d.ts.map +1 -0
- package/dist/auth/authorization-input.js +42 -0
- package/dist/auth/authorization-input.js.map +1 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.d.ts.map +1 -0
- package/dist/auth/device-code.js +129 -0
- package/dist/auth/device-code.js.map +1 -0
- package/dist/auth/index.d.ts +10 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +32 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +126 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +340 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +139 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +519 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.d.ts.map +1 -0
- package/dist/auth/providers/xai.js +205 -0
- package/dist/auth/providers/xai.js.map +1 -0
- package/dist/auth/storage.d.ts +91 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +197 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +89 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +226 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +22 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +161 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +73 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +259 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +60 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +347 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/goal-manager.d.ts +78 -0
- package/dist/goal-manager.d.ts.map +1 -0
- package/dist/goal-manager.js +273 -0
- package/dist/goal-manager.js.map +1 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.d.ts.map +1 -0
- package/dist/goal-signal.js +17 -0
- package/dist/goal-signal.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +195 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +190 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +89 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +42 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +346 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +158 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +18 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +73 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +128 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +47 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +225 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +152 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +8 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +258 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +740 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +21 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +251 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +44 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +82 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +159 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +55 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +54 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +240 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +98 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +612 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/state.d.ts +33 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/state.js +88 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/types.d.ts +120 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +30 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +25 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +47 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +46 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +160 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +338 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +673 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +132 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +81 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +28 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +88 -0
- package/dist/plugins/dependencies.js.map +1 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +190 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +15 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +206 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +64 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +384 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +50 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +61 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +25 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +112 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +116 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/types.d.ts +45 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +54 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +152 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +83 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +52 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +171 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +265 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +72 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +302 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +70 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/schema.d.ts +192 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +98 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +21 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +52 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +79 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +32 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +35 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +61 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +78 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +59 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +172 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +61 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +10 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +62 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +56 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +117 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +364 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +122 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +141 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +105 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +96 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +121 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/storage-maintenance.d.ts +103 -0
- package/dist/utils/storage-maintenance.d.ts.map +1 -0
- package/dist/utils/storage-maintenance.js +274 -0
- package/dist/utils/storage-maintenance.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +112 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +101 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +383 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/lsp/language.ts
|
|
2
|
+
/**
|
|
3
|
+
* Maps file extensions to LSP language identifiers
|
|
4
|
+
*/
|
|
5
|
+
const LANGUAGE_EXTENSIONS = {
|
|
6
|
+
".ts": "typescript",
|
|
7
|
+
".tsx": "typescriptreact",
|
|
8
|
+
".js": "javascript",
|
|
9
|
+
".jsx": "javascriptreact",
|
|
10
|
+
".mjs": "javascript",
|
|
11
|
+
".cjs": "javascript",
|
|
12
|
+
".py": "python",
|
|
13
|
+
".pyi": "python",
|
|
14
|
+
".go": "go",
|
|
15
|
+
".rs": "rust",
|
|
16
|
+
".c": "c",
|
|
17
|
+
".cpp": "cpp",
|
|
18
|
+
".cc": "cpp",
|
|
19
|
+
".cxx": "cpp",
|
|
20
|
+
".h": "c",
|
|
21
|
+
".hpp": "cpp",
|
|
22
|
+
".java": "java",
|
|
23
|
+
".json": "json",
|
|
24
|
+
".jsonc": "jsonc",
|
|
25
|
+
".yaml": "yaml",
|
|
26
|
+
".yml": "yaml",
|
|
27
|
+
".md": "markdown",
|
|
28
|
+
".html": "html",
|
|
29
|
+
".css": "css",
|
|
30
|
+
".scss": "scss",
|
|
31
|
+
".sass": "sass",
|
|
32
|
+
".less": "less"
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Get LSP language ID for a file path
|
|
36
|
+
*/
|
|
37
|
+
function getLanguageId(filePath) {
|
|
38
|
+
const ext = filePath.substring(filePath.lastIndexOf("."));
|
|
39
|
+
return LANGUAGE_EXTENSIONS[ext];
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { LANGUAGE_EXTENSIONS, getLanguageId };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.js","names":[],"sources":["../../src/lsp/language.ts"],"sourcesContent":["/**\n * Maps file extensions to LSP language identifiers\n */\nexport const LANGUAGE_EXTENSIONS: Record<string, string> = {\n // TypeScript/JavaScript\n '.ts': 'typescript',\n '.tsx': 'typescriptreact',\n '.js': 'javascript',\n '.jsx': 'javascriptreact',\n '.mjs': 'javascript',\n '.cjs': 'javascript',\n\n // Python\n '.py': 'python',\n '.pyi': 'python',\n\n // Go\n '.go': 'go',\n\n // Rust\n '.rs': 'rust',\n\n // C/C++\n '.c': 'c',\n '.cpp': 'cpp',\n '.cc': 'cpp',\n '.cxx': 'cpp',\n '.h': 'c',\n '.hpp': 'cpp',\n\n // Java\n '.java': 'java',\n\n // JSON\n '.json': 'json',\n '.jsonc': 'jsonc',\n\n // YAML\n '.yaml': 'yaml',\n '.yml': 'yaml',\n\n // Markdown\n '.md': 'markdown',\n\n // HTML/CSS\n '.html': 'html',\n '.css': 'css',\n '.scss': 'scss',\n '.sass': 'sass',\n '.less': 'less',\n};\n\n/**\n * Get LSP language ID for a file path\n */\nexport function getLanguageId(filePath: string): string | undefined {\n const ext = filePath.substring(filePath.lastIndexOf('.'));\n return LANGUAGE_EXTENSIONS[ext];\n}\n"],"mappings":";;;;AAGA,MAAa,sBAA8C;CAEzD,OAAO;CACP,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CAGR,OAAO;CACP,QAAQ;CAGR,OAAO;CAGP,OAAO;CAGP,MAAM;CACN,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CAGR,SAAS;CAGT,SAAS;CACT,UAAU;CAGV,SAAS;CACT,QAAQ;CAGR,OAAO;CAGP,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;AACX;;;;AAKA,SAAgB,cAAc,UAAsC;CAClE,MAAM,MAAM,SAAS,UAAU,SAAS,YAAY,GAAG,CAAC;CACxD,OAAO,oBAAoB;AAC7B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LSPClient } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Singleton LSP client manager that keeps clients alive and reuses them
|
|
4
|
+
* across tool calls for better performance and accuracy
|
|
5
|
+
*/
|
|
6
|
+
declare class LSPManager {
|
|
7
|
+
private clients;
|
|
8
|
+
private initializationPromises;
|
|
9
|
+
/**
|
|
10
|
+
* Get or create an LSP client for a file
|
|
11
|
+
* Returns null if no LSP server is available for the file
|
|
12
|
+
*/
|
|
13
|
+
getClient(filePath: string, workspaceRoot: string): Promise<LSPClient | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Shutdown a specific client
|
|
16
|
+
*/
|
|
17
|
+
shutdownClient(workspaceRoot: string, serverName?: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Shutdown all clients
|
|
20
|
+
*/
|
|
21
|
+
shutdownAll(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the number of active clients
|
|
24
|
+
*/
|
|
25
|
+
getActiveClientCount(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Close a document in all active clients
|
|
28
|
+
* This is useful for tests that reuse the same file path
|
|
29
|
+
*/
|
|
30
|
+
closeDocument(filePath: string): void;
|
|
31
|
+
}
|
|
32
|
+
export declare const lspManager: LSPManager;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/lsp/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,sBAAsB,CAAyC;IAEvE;;;OAGG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA2DnF;;OAEG;IACG,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/E;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAI9B;;;OAGG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAStC;AAGD,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LSPClient } from "./client.js";
|
|
2
|
+
import { getServersForFile } from "./server.js";
|
|
3
|
+
//#region src/lsp/manager.ts
|
|
4
|
+
/**
|
|
5
|
+
* Singleton LSP client manager that keeps clients alive and reuses them
|
|
6
|
+
* across tool calls for better performance and accuracy
|
|
7
|
+
*/
|
|
8
|
+
var LSPManager = class {
|
|
9
|
+
clients = /* @__PURE__ */ new Map();
|
|
10
|
+
initializationPromises = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Get or create an LSP client for a file
|
|
13
|
+
* Returns null if no LSP server is available for the file
|
|
14
|
+
*/
|
|
15
|
+
async getClient(filePath, workspaceRoot) {
|
|
16
|
+
const servers = getServersForFile(filePath, workspaceRoot);
|
|
17
|
+
if (servers.length === 0) return null;
|
|
18
|
+
const serverInfo = servers.find((s) => s.languageIds.includes("typescript") || s.languageIds.includes("javascript") || s.languageIds.includes("python") || s.languageIds.includes("go")) || servers[0];
|
|
19
|
+
if (!serverInfo) return null;
|
|
20
|
+
const key = `${serverInfo.name}:${workspaceRoot}`;
|
|
21
|
+
if (this.clients.has(key)) return this.clients.get(key);
|
|
22
|
+
if (this.initializationPromises.has(key)) {
|
|
23
|
+
await this.initializationPromises.get(key);
|
|
24
|
+
return this.clients.get(key) || null;
|
|
25
|
+
}
|
|
26
|
+
const initPromise = (async () => {
|
|
27
|
+
const client = new LSPClient(serverInfo, workspaceRoot);
|
|
28
|
+
await client.initialize();
|
|
29
|
+
this.clients.set(key, client);
|
|
30
|
+
})();
|
|
31
|
+
this.initializationPromises.set(key, initPromise);
|
|
32
|
+
try {
|
|
33
|
+
await Promise.race([initPromise, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("LSP client initialization timed out")), 15e3))]);
|
|
34
|
+
return this.clients.get(key) || null;
|
|
35
|
+
} catch {
|
|
36
|
+
this.clients.delete(key);
|
|
37
|
+
return null;
|
|
38
|
+
} finally {
|
|
39
|
+
this.initializationPromises.delete(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Shutdown a specific client
|
|
44
|
+
*/
|
|
45
|
+
async shutdownClient(workspaceRoot, serverName) {
|
|
46
|
+
const keysToRemove = [];
|
|
47
|
+
for (const [key, client] of this.clients.entries()) if (key.includes(workspaceRoot) && (!serverName || key.startsWith(serverName))) {
|
|
48
|
+
await client.shutdown();
|
|
49
|
+
keysToRemove.push(key);
|
|
50
|
+
}
|
|
51
|
+
for (const key of keysToRemove) this.clients.delete(key);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Shutdown all clients
|
|
55
|
+
*/
|
|
56
|
+
async shutdownAll() {
|
|
57
|
+
const shutdownPromises = Array.from(this.clients.values()).map((client) => client.shutdown());
|
|
58
|
+
await Promise.all(shutdownPromises);
|
|
59
|
+
this.clients.clear();
|
|
60
|
+
this.initializationPromises.clear();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the number of active clients
|
|
64
|
+
*/
|
|
65
|
+
getActiveClientCount() {
|
|
66
|
+
return this.clients.size;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Close a document in all active clients
|
|
70
|
+
* This is useful for tests that reuse the same file path
|
|
71
|
+
*/
|
|
72
|
+
closeDocument(filePath) {
|
|
73
|
+
for (const client of this.clients.values()) try {
|
|
74
|
+
client.notifyClose(filePath);
|
|
75
|
+
} catch {}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const lspManager = new LSPManager();
|
|
79
|
+
//#endregion
|
|
80
|
+
export { lspManager };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","names":[],"sources":["../../src/lsp/manager.ts"],"sourcesContent":["import { LSPClient } from './client.js';\nimport { getServersForFile } from './server.js';\n\n/**\n * Singleton LSP client manager that keeps clients alive and reuses them\n * across tool calls for better performance and accuracy\n */\nclass LSPManager {\n private clients: Map<string, LSPClient> = new Map();\n private initializationPromises: Map<string, Promise<void>> = new Map();\n\n /**\n * Get or create an LSP client for a file\n * Returns null if no LSP server is available for the file\n */\n async getClient(filePath: string, workspaceRoot: string): Promise<LSPClient | null> {\n const servers = getServersForFile(filePath, workspaceRoot);\n if (servers.length === 0) {\n return null;\n }\n\n // Use the first matching server (prioritize TypeScript/JavaScript)\n const serverInfo =\n servers.find(\n s =>\n s.languageIds.includes('typescript') ||\n s.languageIds.includes('javascript') ||\n s.languageIds.includes('python') ||\n s.languageIds.includes('go'),\n ) || servers[0];\n // Create a unique key for this server + workspace combination\n if (!serverInfo) {\n return null;\n }\n const key = `${serverInfo.name}:${workspaceRoot}`;\n\n // Return existing client if available\n if (this.clients.has(key)) {\n return this.clients.get(key)!;\n }\n\n // If initialization is in progress, wait for it\n if (this.initializationPromises.has(key)) {\n await this.initializationPromises.get(key);\n return this.clients.get(key) || null;\n }\n\n // Create and initialize new client with a timeout to prevent indefinite hangs\n // (e.g., npx resolution issues in pnpm-linked projects)\n const initPromise = (async () => {\n const client = new LSPClient(serverInfo, workspaceRoot);\n await client.initialize();\n this.clients.set(key, client);\n })();\n\n this.initializationPromises.set(key, initPromise);\n\n try {\n await Promise.race([\n initPromise,\n new Promise<void>((_, reject) =>\n setTimeout(() => reject(new Error('LSP client initialization timed out')), 15000),\n ),\n ]);\n return this.clients.get(key) || null;\n } catch {\n // If initialization timed out or failed, clean up\n this.clients.delete(key);\n return null;\n } finally {\n this.initializationPromises.delete(key);\n }\n }\n\n /**\n * Shutdown a specific client\n */\n async shutdownClient(workspaceRoot: string, serverName?: string): Promise<void> {\n const keysToRemove: string[] = [];\n\n for (const [key, client] of this.clients.entries()) {\n if (key.includes(workspaceRoot) && (!serverName || key.startsWith(serverName))) {\n await client.shutdown();\n keysToRemove.push(key);\n }\n }\n\n for (const key of keysToRemove) {\n this.clients.delete(key);\n }\n }\n\n /**\n * Shutdown all clients\n */\n async shutdownAll(): Promise<void> {\n const shutdownPromises = Array.from(this.clients.values()).map(client => client.shutdown());\n await Promise.all(shutdownPromises);\n this.clients.clear();\n this.initializationPromises.clear();\n }\n\n /**\n * Get the number of active clients\n */\n getActiveClientCount(): number {\n return this.clients.size;\n }\n\n /**\n * Close a document in all active clients\n * This is useful for tests that reuse the same file path\n */\n closeDocument(filePath: string): void {\n for (const client of this.clients.values()) {\n try {\n client.notifyClose(filePath);\n } catch {\n // Ignore errors if document wasn't open\n }\n }\n }\n}\n\n// Export singleton instance\nexport const lspManager = new LSPManager();\n"],"mappings":";;;;;;;AAOA,IAAM,aAAN,MAAiB;CACf,0BAA0C,IAAI,IAAI;CAClD,yCAA6D,IAAI,IAAI;;;;;CAMrE,MAAM,UAAU,UAAkB,eAAkD;EAClF,MAAM,UAAU,kBAAkB,UAAU,aAAa;EACzD,IAAI,QAAQ,WAAW,GACrB,OAAO;EAIT,MAAM,aACJ,QAAQ,MACN,MACE,EAAE,YAAY,SAAS,YAAY,KACnC,EAAE,YAAY,SAAS,YAAY,KACnC,EAAE,YAAY,SAAS,QAAQ,KAC/B,EAAE,YAAY,SAAS,IAAI,CAC/B,KAAK,QAAQ;EAEf,IAAI,CAAC,YACH,OAAO;EAET,MAAM,MAAM,GAAG,WAAW,KAAK,GAAG;EAGlC,IAAI,KAAK,QAAQ,IAAI,GAAG,GACtB,OAAO,KAAK,QAAQ,IAAI,GAAG;EAI7B,IAAI,KAAK,uBAAuB,IAAI,GAAG,GAAG;GACxC,MAAM,KAAK,uBAAuB,IAAI,GAAG;GACzC,OAAO,KAAK,QAAQ,IAAI,GAAG,KAAK;EAClC;EAIA,MAAM,eAAe,YAAY;GAC/B,MAAM,SAAS,IAAI,UAAU,YAAY,aAAa;GACtD,MAAM,OAAO,WAAW;GACxB,KAAK,QAAQ,IAAI,KAAK,MAAM;EAC9B,EAAA,CAAG;EAEH,KAAK,uBAAuB,IAAI,KAAK,WAAW;EAEhD,IAAI;GACF,MAAM,QAAQ,KAAK,CACjB,aACA,IAAI,SAAe,GAAG,WACpB,iBAAiB,uBAAO,IAAI,MAAM,qCAAqC,CAAC,GAAG,IAAK,CAClF,CACF,CAAC;GACD,OAAO,KAAK,QAAQ,IAAI,GAAG,KAAK;EAClC,QAAQ;GAEN,KAAK,QAAQ,OAAO,GAAG;GACvB,OAAO;EACT,UAAU;GACR,KAAK,uBAAuB,OAAO,GAAG;EACxC;CACF;;;;CAKA,MAAM,eAAe,eAAuB,YAAoC;EAC9E,MAAM,eAAyB,CAAC;EAEhC,KAAK,MAAM,CAAC,KAAK,WAAW,KAAK,QAAQ,QAAQ,GAC/C,IAAI,IAAI,SAAS,aAAa,MAAM,CAAC,cAAc,IAAI,WAAW,UAAU,IAAI;GAC9E,MAAM,OAAO,SAAS;GACtB,aAAa,KAAK,GAAG;EACvB;EAGF,KAAK,MAAM,OAAO,cAChB,KAAK,QAAQ,OAAO,GAAG;CAE3B;;;;CAKA,MAAM,cAA6B;EACjC,MAAM,mBAAmB,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,CAAC,CAAC,KAAI,WAAU,OAAO,SAAS,CAAC;EAC1F,MAAM,QAAQ,IAAI,gBAAgB;EAClC,KAAK,QAAQ,MAAM;EACnB,KAAK,uBAAuB,MAAM;CACpC;;;;CAKA,uBAA+B;EAC7B,OAAO,KAAK,QAAQ;CACtB;;;;;CAMA,cAAc,UAAwB;EACpC,KAAK,MAAM,UAAU,KAAK,QAAQ,OAAO,GACvC,IAAI;GACF,OAAO,YAAY,QAAQ;EAC7B,QAAQ,CAER;CAEJ;AACF;AAGA,MAAa,aAAa,IAAI,WAAW"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
/**
|
|
3
|
+
* LSP Server definition and spawning logic
|
|
4
|
+
*/
|
|
5
|
+
export interface LSPServerInfo {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
languageIds: string[];
|
|
9
|
+
root: (cwd: string) => string | null;
|
|
10
|
+
spawn: (root: string) => ChildProcess | Promise<{
|
|
11
|
+
process: ChildProcess;
|
|
12
|
+
initialization?: any;
|
|
13
|
+
} | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Find the nearest project root directory
|
|
17
|
+
*/
|
|
18
|
+
export declare function findNearestRoot(cwd: string, markers: string[]): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Built-in LSP server definitions
|
|
21
|
+
*/
|
|
22
|
+
export declare const BUILTIN_SERVERS: Record<string, LSPServerInfo>;
|
|
23
|
+
/**
|
|
24
|
+
* Get all servers that can handle a file
|
|
25
|
+
*/
|
|
26
|
+
export declare function getServersForFile(filePath: string, cwd: string): LSPServerInfo[];
|
|
27
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/lsp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQvD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACrC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,cAAc,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;CAC9G;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAgB7E;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CA4GzD,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CAOhF"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { getLanguageId } from "./language.js";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import path, { join } from "path";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import { pathToFileURL } from "url";
|
|
7
|
+
//#region src/lsp/server.ts
|
|
8
|
+
/**
|
|
9
|
+
* Find the nearest project root directory
|
|
10
|
+
*/
|
|
11
|
+
function findNearestRoot(cwd, markers) {
|
|
12
|
+
let current = cwd;
|
|
13
|
+
while (current !== "/") {
|
|
14
|
+
for (const marker of markers) if (existsSync(join(current, marker))) return current;
|
|
15
|
+
const parent = join(current, "..");
|
|
16
|
+
if (parent === current) break;
|
|
17
|
+
current = parent;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Built-in LSP server definitions
|
|
23
|
+
*/
|
|
24
|
+
const BUILTIN_SERVERS = {
|
|
25
|
+
typescript: {
|
|
26
|
+
id: "typescript",
|
|
27
|
+
name: "TypeScript Language Server",
|
|
28
|
+
languageIds: [
|
|
29
|
+
"typescript",
|
|
30
|
+
"typescriptreact",
|
|
31
|
+
"javascript",
|
|
32
|
+
"javascriptreact"
|
|
33
|
+
],
|
|
34
|
+
root: (cwd) => findNearestRoot(cwd, ["tsconfig.json", "package.json"]),
|
|
35
|
+
spawn: async (root) => {
|
|
36
|
+
const requireFromRoot = createRequire(pathToFileURL(path.join(root, "package.json")));
|
|
37
|
+
let tsserver;
|
|
38
|
+
try {
|
|
39
|
+
tsserver = requireFromRoot.resolve("typescript/lib/tsserver.js");
|
|
40
|
+
} catch {
|
|
41
|
+
tsserver = void 0;
|
|
42
|
+
}
|
|
43
|
+
if (!tsserver) return;
|
|
44
|
+
const localBin = join(root, "node_modules", ".bin", "typescript-language-server");
|
|
45
|
+
const cwdBin = join(process.cwd(), "node_modules", ".bin", "typescript-language-server");
|
|
46
|
+
let tslsBinary;
|
|
47
|
+
if (existsSync(localBin)) tslsBinary = localBin;
|
|
48
|
+
else if (existsSync(cwdBin)) tslsBinary = cwdBin;
|
|
49
|
+
else tslsBinary = "npx";
|
|
50
|
+
return {
|
|
51
|
+
process: spawn(tslsBinary, tslsBinary === "npx" ? ["typescript-language-server", "--stdio"] : ["--stdio"], {
|
|
52
|
+
cwd: root,
|
|
53
|
+
stdio: [
|
|
54
|
+
"pipe",
|
|
55
|
+
"pipe",
|
|
56
|
+
"pipe"
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
initialization: { tsserver: {
|
|
60
|
+
path: tsserver,
|
|
61
|
+
logVerbosity: "off"
|
|
62
|
+
} }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
eslint: {
|
|
67
|
+
id: "eslint",
|
|
68
|
+
name: "ESLint Language Server",
|
|
69
|
+
languageIds: [
|
|
70
|
+
"typescript",
|
|
71
|
+
"typescriptreact",
|
|
72
|
+
"javascript",
|
|
73
|
+
"javascriptreact"
|
|
74
|
+
],
|
|
75
|
+
root: (cwd) => findNearestRoot(cwd, [
|
|
76
|
+
"package.json",
|
|
77
|
+
".eslintrc.js",
|
|
78
|
+
".eslintrc.json",
|
|
79
|
+
".eslintrc.yml",
|
|
80
|
+
".eslintrc.yaml"
|
|
81
|
+
]),
|
|
82
|
+
spawn: (root) => {
|
|
83
|
+
return spawn(join(process.cwd(), "node_modules", ".bin", "eslint-lsp"), ["--stdio"], {
|
|
84
|
+
cwd: root,
|
|
85
|
+
stdio: [
|
|
86
|
+
"pipe",
|
|
87
|
+
"pipe",
|
|
88
|
+
"pipe"
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
python: {
|
|
94
|
+
id: "python",
|
|
95
|
+
name: "Python Language Server (Pyright)",
|
|
96
|
+
languageIds: ["python"],
|
|
97
|
+
root: (cwd) => findNearestRoot(cwd, [
|
|
98
|
+
"pyproject.toml",
|
|
99
|
+
"setup.py",
|
|
100
|
+
"requirements.txt",
|
|
101
|
+
".git"
|
|
102
|
+
]),
|
|
103
|
+
spawn: (root) => {
|
|
104
|
+
const localPath = join(process.cwd(), "node_modules", ".bin", "pyright-langserver");
|
|
105
|
+
return spawn(existsSync(localPath) ? localPath : "pyright-langserver", ["--stdio"], {
|
|
106
|
+
cwd: root,
|
|
107
|
+
stdio: [
|
|
108
|
+
"pipe",
|
|
109
|
+
"pipe",
|
|
110
|
+
"pipe"
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
go: {
|
|
116
|
+
id: "go",
|
|
117
|
+
name: "Go Language Server (gopls)",
|
|
118
|
+
languageIds: ["go"],
|
|
119
|
+
root: (cwd) => findNearestRoot(cwd, ["go.mod", ".git"]),
|
|
120
|
+
spawn: (root) => {
|
|
121
|
+
return spawn("gopls", ["serve"], {
|
|
122
|
+
cwd: root,
|
|
123
|
+
stdio: [
|
|
124
|
+
"pipe",
|
|
125
|
+
"pipe",
|
|
126
|
+
"pipe"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
rust: {
|
|
132
|
+
id: "rust",
|
|
133
|
+
name: "Rust Language Server (rust-analyzer)",
|
|
134
|
+
languageIds: ["rust"],
|
|
135
|
+
root: (cwd) => findNearestRoot(cwd, ["Cargo.toml", ".git"]),
|
|
136
|
+
spawn: (root) => {
|
|
137
|
+
return spawn("rust-analyzer", ["--stdio"], {
|
|
138
|
+
cwd: root,
|
|
139
|
+
stdio: [
|
|
140
|
+
"pipe",
|
|
141
|
+
"pipe",
|
|
142
|
+
"pipe"
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Get all servers that can handle a file
|
|
150
|
+
*/
|
|
151
|
+
function getServersForFile(filePath, cwd) {
|
|
152
|
+
const languageId = getLanguageId(filePath);
|
|
153
|
+
if (!languageId) return [];
|
|
154
|
+
return Object.values(BUILTIN_SERVERS).filter((server) => server.languageIds.includes(languageId) && server.root(cwd) !== null);
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { BUILTIN_SERVERS, findNearestRoot, getServersForFile };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../src/lsp/server.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path, { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { getLanguageId } from './language.js';\n\n/**\n * LSP Server definition and spawning logic\n */\nexport interface LSPServerInfo {\n id: string;\n name: string;\n languageIds: string[];\n root: (cwd: string) => string | null;\n spawn: (root: string) => ChildProcess | Promise<{ process: ChildProcess; initialization?: any } | undefined>;\n}\n\n/**\n * Find the nearest project root directory\n */\nexport function findNearestRoot(cwd: string, markers: string[]): string | null {\n let current = cwd;\n\n while (current !== '/') {\n for (const marker of markers) {\n if (existsSync(join(current, marker))) {\n return current;\n }\n }\n\n const parent = join(current, '..');\n if (parent === current) break;\n current = parent;\n }\n\n return null;\n}\n\n/**\n * Built-in LSP server definitions\n */\nexport const BUILTIN_SERVERS: Record<string, LSPServerInfo> = {\n typescript: {\n id: 'typescript',\n name: 'TypeScript Language Server',\n languageIds: ['typescript', 'typescriptreact', 'javascript', 'javascriptreact'],\n root: (cwd: string) => findNearestRoot(cwd, ['tsconfig.json', 'package.json']),\n spawn: async (root: string) => {\n // Try to resolve TypeScript from the project directory\n const requireFromRoot = createRequire(pathToFileURL(path.join(root, 'package.json')));\n let tsserver: string | undefined;\n try {\n tsserver = requireFromRoot.resolve('typescript/lib/tsserver.js');\n } catch {\n tsserver = undefined;\n }\n if (!tsserver) {\n return undefined;\n }\n\n // Resolve typescript-language-server binary directly to avoid npx hangs\n // (npx can hang indefinitely in projects with pnpm links)\n const localBin = join(root, 'node_modules', '.bin', 'typescript-language-server');\n const cwdBin = join(process.cwd(), 'node_modules', '.bin', 'typescript-language-server');\n let tslsBinary: string;\n if (existsSync(localBin)) {\n tslsBinary = localBin;\n } else if (existsSync(cwdBin)) {\n tslsBinary = cwdBin;\n } else {\n // Fall back to npx as last resort, but this may hang with pnpm links\n tslsBinary = 'npx';\n }\n\n const args = tslsBinary === 'npx' ? ['typescript-language-server', '--stdio'] : ['--stdio'];\n\n const proc = spawn(tslsBinary, args, {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n return {\n process: proc,\n initialization: {\n tsserver: {\n path: tsserver,\n logVerbosity: 'off',\n },\n },\n };\n },\n },\n\n eslint: {\n id: 'eslint',\n name: 'ESLint Language Server',\n languageIds: ['typescript', 'typescriptreact', 'javascript', 'javascriptreact'],\n root: (cwd: string) =>\n findNearestRoot(cwd, ['package.json', '.eslintrc.js', '.eslintrc.json', '.eslintrc.yml', '.eslintrc.yaml']),\n spawn: (root: string) => {\n const binaryPath = join(process.cwd(), 'node_modules', '.bin', 'eslint-lsp');\n return spawn(binaryPath, ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n python: {\n id: 'python',\n name: 'Python Language Server (Pyright)',\n languageIds: ['python'],\n root: (cwd: string) => findNearestRoot(cwd, ['pyproject.toml', 'setup.py', 'requirements.txt', '.git']),\n spawn: (root: string) => {\n // Try node_modules first, then fall back to system PATH\n const localPath = join(process.cwd(), 'node_modules', '.bin', 'pyright-langserver');\n const binaryPath = existsSync(localPath) ? localPath : 'pyright-langserver';\n return spawn(binaryPath, ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n go: {\n id: 'go',\n name: 'Go Language Server (gopls)',\n languageIds: ['go'],\n root: (cwd: string) => findNearestRoot(cwd, ['go.mod', '.git']),\n spawn: (root: string) => {\n return spawn('gopls', ['serve'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n rust: {\n id: 'rust',\n name: 'Rust Language Server (rust-analyzer)',\n languageIds: ['rust'],\n root: (cwd: string) => findNearestRoot(cwd, ['Cargo.toml', '.git']),\n spawn: (root: string) => {\n return spawn('rust-analyzer', ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n};\n\n/**\n * Get all servers that can handle a file\n */\nexport function getServersForFile(filePath: string, cwd: string): LSPServerInfo[] {\n const languageId = getLanguageId(filePath);\n if (!languageId) return [];\n\n return Object.values(BUILTIN_SERVERS).filter(\n server => server.languageIds.includes(languageId) && server.root(cwd) !== null,\n );\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,gBAAgB,KAAa,SAAkC;CAC7E,IAAI,UAAU;CAEd,OAAO,YAAY,KAAK;EACtB,KAAK,MAAM,UAAU,SACnB,IAAI,WAAW,KAAK,SAAS,MAAM,CAAC,GAClC,OAAO;EAIX,MAAM,SAAS,KAAK,SAAS,IAAI;EACjC,IAAI,WAAW,SAAS;EACxB,UAAU;CACZ;CAEA,OAAO;AACT;;;;AAKA,MAAa,kBAAiD;CAC5D,YAAY;EACV,IAAI;EACJ,MAAM;EACN,aAAa;GAAC;GAAc;GAAmB;GAAc;EAAiB;EAC9E,OAAO,QAAgB,gBAAgB,KAAK,CAAC,iBAAiB,cAAc,CAAC;EAC7E,OAAO,OAAO,SAAiB;GAE7B,MAAM,kBAAkB,cAAc,cAAc,KAAK,KAAK,MAAM,cAAc,CAAC,CAAC;GACpF,IAAI;GACJ,IAAI;IACF,WAAW,gBAAgB,QAAQ,4BAA4B;GACjE,QAAQ;IACN,WAAW,KAAA;GACb;GACA,IAAI,CAAC,UACH;GAKF,MAAM,WAAW,KAAK,MAAM,gBAAgB,QAAQ,4BAA4B;GAChF,MAAM,SAAS,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,4BAA4B;GACvF,IAAI;GACJ,IAAI,WAAW,QAAQ,GACrB,aAAa;QACR,IAAI,WAAW,MAAM,GAC1B,aAAa;QAGb,aAAa;GAUf,OAAO;IACL,SANW,MAAM,YAFN,eAAe,QAAQ,CAAC,8BAA8B,SAAS,IAAI,CAAC,SAAS,GAErD;KACnC,KAAK;KACL,OAAO;MAAC;MAAQ;MAAQ;KAAM;IAChC,CAGc;IACZ,gBAAgB,EACd,UAAU;KACR,MAAM;KACN,cAAc;IAChB,EACF;GACF;EACF;CACF;CAEA,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,aAAa;GAAC;GAAc;GAAmB;GAAc;EAAiB;EAC9E,OAAO,QACL,gBAAgB,KAAK;GAAC;GAAgB;GAAgB;GAAkB;GAAiB;EAAgB,CAAC;EAC5G,QAAQ,SAAiB;GAEvB,OAAO,MADY,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,YACzC,GAAG,CAAC,SAAS,GAAG;IACpC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,QAAQ;EACtB,OAAO,QAAgB,gBAAgB,KAAK;GAAC;GAAkB;GAAY;GAAoB;EAAM,CAAC;EACtG,QAAQ,SAAiB;GAEvB,MAAM,YAAY,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,oBAAoB;GAElF,OAAO,MADY,WAAW,SAAS,IAAI,YAAY,sBAC9B,CAAC,SAAS,GAAG;IACpC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,IAAI;EACF,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,IAAI;EAClB,OAAO,QAAgB,gBAAgB,KAAK,CAAC,UAAU,MAAM,CAAC;EAC9D,QAAQ,SAAiB;GACvB,OAAO,MAAM,SAAS,CAAC,OAAO,GAAG;IAC/B,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,MAAM;EACJ,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,MAAM;EACpB,OAAO,QAAgB,gBAAgB,KAAK,CAAC,cAAc,MAAM,CAAC;EAClE,QAAQ,SAAiB;GACvB,OAAO,MAAM,iBAAiB,CAAC,SAAS,GAAG;IACzC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;AACF;;;;AAKA,SAAgB,kBAAkB,UAAkB,KAA8B;CAChF,MAAM,aAAa,cAAc,QAAQ;CACzC,IAAI,CAAC,YAAY,OAAO,CAAC;CAEzB,OAAO,OAAO,OAAO,eAAe,CAAC,CAAC,QACpC,WAAU,OAAO,YAAY,SAAS,UAAU,KAAK,OAAO,KAAK,GAAG,MAAM,IAC5E;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the workspace root by walking up from the file path
|
|
3
|
+
* looking for common workspace markers.
|
|
4
|
+
*
|
|
5
|
+
* For monorepos, this prioritizes the closest package/project root
|
|
6
|
+
* (e.g., packages/core) over the monorepo root.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findWorkspaceRoot(filePath: string): string;
|
|
9
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/lsp/workspace.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiD1D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as fs$1 from "fs";
|
|
2
|
+
import * as path$1 from "path";
|
|
3
|
+
//#region src/lsp/workspace.ts
|
|
4
|
+
/**
|
|
5
|
+
* Workspace markers that indicate the root of a project
|
|
6
|
+
*/
|
|
7
|
+
const WORKSPACE_MARKERS = [
|
|
8
|
+
"package.json",
|
|
9
|
+
"tsconfig.json",
|
|
10
|
+
"pyproject.toml",
|
|
11
|
+
"go.mod",
|
|
12
|
+
".git",
|
|
13
|
+
"Cargo.toml",
|
|
14
|
+
"composer.json"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Find the workspace root by walking up from the file path
|
|
18
|
+
* looking for common workspace markers.
|
|
19
|
+
*
|
|
20
|
+
* For monorepos, this prioritizes the closest package/project root
|
|
21
|
+
* (e.g., packages/core) over the monorepo root.
|
|
22
|
+
*/
|
|
23
|
+
function findWorkspaceRoot(filePath) {
|
|
24
|
+
let currentDir = path$1.dirname(path$1.resolve(filePath));
|
|
25
|
+
const root = path$1.parse(currentDir).root;
|
|
26
|
+
let closestProjectRoot = null;
|
|
27
|
+
let searchDir = currentDir;
|
|
28
|
+
while (searchDir !== root) {
|
|
29
|
+
const hasTsConfig = fs$1.existsSync(path$1.join(searchDir, "tsconfig.json"));
|
|
30
|
+
const hasPackageJson = fs$1.existsSync(path$1.join(searchDir, "package.json"));
|
|
31
|
+
if (hasTsConfig || hasPackageJson) {
|
|
32
|
+
closestProjectRoot = searchDir;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
const parentDir = path$1.dirname(searchDir);
|
|
36
|
+
if (parentDir === searchDir) break;
|
|
37
|
+
searchDir = parentDir;
|
|
38
|
+
}
|
|
39
|
+
if (closestProjectRoot) return closestProjectRoot;
|
|
40
|
+
currentDir = path$1.dirname(path$1.resolve(filePath));
|
|
41
|
+
while (currentDir !== root) {
|
|
42
|
+
for (const marker of WORKSPACE_MARKERS) {
|
|
43
|
+
const markerPath = path$1.join(currentDir, marker);
|
|
44
|
+
if (fs$1.existsSync(markerPath)) return currentDir;
|
|
45
|
+
}
|
|
46
|
+
const parentDir = path$1.dirname(currentDir);
|
|
47
|
+
if (parentDir === currentDir) break;
|
|
48
|
+
currentDir = parentDir;
|
|
49
|
+
}
|
|
50
|
+
return path$1.dirname(path$1.resolve(filePath));
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { findWorkspaceRoot };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","names":["path","fs"],"sources":["../../src/lsp/workspace.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\n/**\n * Workspace markers that indicate the root of a project\n */\nconst WORKSPACE_MARKERS = [\n 'package.json',\n 'tsconfig.json',\n 'pyproject.toml',\n 'go.mod',\n '.git',\n 'Cargo.toml',\n 'composer.json',\n];\n\n/**\n * Find the workspace root by walking up from the file path\n * looking for common workspace markers.\n *\n * For monorepos, this prioritizes the closest package/project root\n * (e.g., packages/core) over the monorepo root.\n */\nexport function findWorkspaceRoot(filePath: string): string {\n let currentDir = path.dirname(path.resolve(filePath));\n const root = path.parse(currentDir).root;\n\n // First, find the closest tsconfig.json or package.json\n // This handles monorepos where the actual project is in a subdirectory\n let closestProjectRoot: string | null = null;\n let searchDir = currentDir;\n\n while (searchDir !== root) {\n const hasTsConfig = fs.existsSync(path.join(searchDir, 'tsconfig.json'));\n const hasPackageJson = fs.existsSync(path.join(searchDir, 'package.json'));\n\n if (hasTsConfig || hasPackageJson) {\n closestProjectRoot = searchDir;\n break;\n }\n\n const parentDir = path.dirname(searchDir);\n if (parentDir === searchDir) {\n break;\n }\n searchDir = parentDir;\n }\n\n // If we found a project root, return it\n if (closestProjectRoot) {\n return closestProjectRoot;\n }\n\n // Otherwise, fall back to looking for any workspace marker\n currentDir = path.dirname(path.resolve(filePath));\n while (currentDir !== root) {\n for (const marker of WORKSPACE_MARKERS) {\n const markerPath = path.join(currentDir, marker);\n if (fs.existsSync(markerPath)) {\n return currentDir;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n // Fallback to the directory containing the file\n return path.dirname(path.resolve(filePath));\n}\n"],"mappings":";;;;;;AAMA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,kBAAkB,UAA0B;CAC1D,IAAI,aAAaA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;CACpD,MAAM,OAAOA,OAAK,MAAM,UAAU,CAAC,CAAC;CAIpC,IAAI,qBAAoC;CACxC,IAAI,YAAY;CAEhB,OAAO,cAAc,MAAM;EACzB,MAAM,cAAcC,KAAG,WAAWD,OAAK,KAAK,WAAW,eAAe,CAAC;EACvE,MAAM,iBAAiBC,KAAG,WAAWD,OAAK,KAAK,WAAW,cAAc,CAAC;EAEzE,IAAI,eAAe,gBAAgB;GACjC,qBAAqB;GACrB;EACF;EAEA,MAAM,YAAYA,OAAK,QAAQ,SAAS;EACxC,IAAI,cAAc,WAChB;EAEF,YAAY;CACd;CAGA,IAAI,oBACF,OAAO;CAIT,aAAaA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;CAChD,OAAO,eAAe,MAAM;EAC1B,KAAK,MAAM,UAAU,mBAAmB;GACtC,MAAM,aAAaA,OAAK,KAAK,YAAY,MAAM;GAC/C,IAAIC,KAAG,WAAW,UAAU,GAC1B,OAAO;EAEX;EAEA,MAAM,YAAYD,OAAK,QAAQ,UAAU;EACzC,IAAI,cAAc,YAChB;EAEF,aAAa;CACf;CAGA,OAAOA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;AAC5C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server configuration loading from filesystem.
|
|
3
|
+
* Loads from:
|
|
4
|
+
* 1. .claude/settings.local.json (Claude Code compat — lowest priority)
|
|
5
|
+
* 2. ~/.mastracode/mcp.json (global)
|
|
6
|
+
* 3. .mcp.json (project root — Claude Code compatible)
|
|
7
|
+
* 4. .mastracode/mcp.json (project — highest priority)
|
|
8
|
+
*
|
|
9
|
+
* Higher-priority configs override lower ones by server name. The project root
|
|
10
|
+
* `.mcp.json` is read so a project that already keeps MCP servers there for
|
|
11
|
+
* Claude Code does not need to duplicate them under `.mastracode/`.
|
|
12
|
+
*/
|
|
13
|
+
import type { McpConfig, McpHttpOAuthConfig } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Default OAuth redirect URL for servers that do not configure one.
|
|
16
|
+
* Port 1458 is stable across sessions so persisted tokens keep the same
|
|
17
|
+
* storage fingerprint; it sits clear of the ports the Codex login flow
|
|
18
|
+
* reserves (1455/1457). When 1458 is busy the callback server falls back
|
|
19
|
+
* to the next sequential port, which stays covered by the client
|
|
20
|
+
* registration (see `@mastra/mcp`'s `getCallbackUrlCandidates`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_OAUTH_REDIRECT_URL = "http://127.0.0.1:1458/oauth/callback";
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the effective OAuth redirect URL for a server config.
|
|
25
|
+
*
|
|
26
|
+
* `callbackPort` (the Claude Code / Codex convention) takes precedence and
|
|
27
|
+
* synthesizes `http://localhost:<port>/callback`. Config-file entries are
|
|
28
|
+
* normalized by `parseOAuthConfig` (which also enforces that `callbackPort`
|
|
29
|
+
* and `redirectUrl` are mutually exclusive), but programmatically registered
|
|
30
|
+
* servers bypass the parser, so every consumer of the redirect URL must
|
|
31
|
+
* resolve it through this helper rather than reading `redirectUrl` directly.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveOAuthRedirectUrl(oauth: McpHttpOAuthConfig | undefined): string;
|
|
34
|
+
export declare function loadMcpConfig(projectDir: string, configDirName?: string): McpConfig;
|
|
35
|
+
export declare function getProjectMcpPath(projectDir: string, configDirName?: string): string;
|
|
36
|
+
export declare function getRootMcpPath(projectDir: string): string;
|
|
37
|
+
export declare function getGlobalMcpPath(configDirName?: string): string;
|
|
38
|
+
export declare function getClaudeSettingsPath(projectDir: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Expand `${VAR}` and `${VAR:-default}` references in a string from the
|
|
41
|
+
* environment, matching how Claude Code resolves values in `.mcp.json`.
|
|
42
|
+
* A referenced variable that is unset or empty falls back to its default,
|
|
43
|
+
* or to an empty string when no default is given.
|
|
44
|
+
*/
|
|
45
|
+
export declare function expandEnvVars(value: string, env?: NodeJS.ProcessEnv): string;
|
|
46
|
+
/**
|
|
47
|
+
* Classify a raw server entry as stdio, http, or skip (with reason).
|
|
48
|
+
*/
|
|
49
|
+
export declare function classifyServerEntry(raw: unknown): {
|
|
50
|
+
kind: 'stdio' | 'http' | 'skip';
|
|
51
|
+
reason?: string;
|
|
52
|
+
};
|
|
53
|
+
export declare function validateConfig(raw: unknown): McpConfig;
|
|
54
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,yCAAyC,CAAC;AAYjF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAKrF;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,SAAS,CAO/F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,MAAM,CAEhG;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,gBAAgB,CAAC,aAAa,SAAqB,GAAG,MAAM,CAE3E;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhE;AA4BD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAUzF;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CA2BtG;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAiDtD"}
|