@mastra/code-sdk 1.0.3-alpha.0 → 1.1.0-alpha.2
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 +49 -0
- package/dist/acp/agent.js +155 -167
- package/dist/acp/agent.js.map +1 -1
- package/dist/acp/event-mapper.js +193 -168
- package/dist/acp/event-mapper.js.map +1 -1
- package/dist/acp/index.js +60 -49
- package/dist/acp/index.js.map +1 -1
- package/dist/acp/server.js +31 -30
- package/dist/acp/server.js.map +1 -1
- package/dist/acp.js +1 -4
- package/dist/agents/credential-resolver.js +40 -29
- package/dist/agents/credential-resolver.js.map +1 -1
- package/dist/agents/custom-provider-source.js +16 -9
- package/dist/agents/custom-provider-source.js.map +1 -1
- package/dist/agents/instructions.js +27 -36
- package/dist/agents/instructions.js.map +1 -1
- package/dist/agents/mastracode-gateway.js +355 -428
- package/dist/agents/mastracode-gateway.js.map +1 -1
- package/dist/agents/memory.js +87 -78
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/model.js +114 -119
- package/dist/agents/model.js.map +1 -1
- package/dist/agents/modes/build.js +12 -13
- package/dist/agents/modes/build.js.map +1 -1
- package/dist/agents/modes/explore.js +14 -13
- package/dist/agents/modes/explore.js.map +1 -1
- package/dist/agents/modes/plan.js +14 -15
- package/dist/agents/modes/plan.js.map +1 -1
- package/dist/agents/prompts/agent-instructions.js +78 -69
- package/dist/agents/prompts/agent-instructions.js.map +1 -1
- package/dist/agents/prompts/build.js +19 -16
- package/dist/agents/prompts/build.js.map +1 -1
- package/dist/agents/prompts/fast.js +8 -4
- package/dist/agents/prompts/fast.js.map +1 -1
- package/dist/agents/prompts/index.js +48 -47
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/prompts/model.js +6 -5
- package/dist/agents/prompts/model.js.map +1 -1
- package/dist/agents/prompts/plan.js +20 -16
- package/dist/agents/prompts/plan.js.map +1 -1
- package/dist/agents/prompts/tool-guidance.js +77 -109
- package/dist/agents/prompts/tool-guidance.js.map +1 -1
- package/dist/agents/sandbox-filesystem.js +245 -259
- package/dist/agents/sandbox-filesystem.js.map +1 -1
- package/dist/agents/sandbox-reattach.js +9 -11
- package/dist/agents/sandbox-reattach.js.map +1 -1
- package/dist/agents/thread-caveman-state.js +92 -81
- package/dist/agents/thread-caveman-state.js.map +1 -1
- package/dist/agents/tool-availability.js +62 -80
- package/dist/agents/tool-availability.js.map +1 -1
- package/dist/agents/tools.js +99 -139
- package/dist/agents/tools.js.map +1 -1
- package/dist/agents/workspace.js +232 -225
- package/dist/agents/workspace.js.map +1 -1
- package/dist/analytics.js +139 -128
- package/dist/analytics.js.map +1 -1
- package/dist/auth/authorization-input.js +39 -25
- package/dist/auth/authorization-input.js.map +1 -1
- package/dist/auth/device-code.js +112 -80
- package/dist/auth/device-code.js.map +1 -1
- package/dist/auth/index.js +2 -9
- package/dist/auth/pkce.js +27 -16
- package/dist/auth/pkce.js.map +1 -1
- package/dist/auth/providers/anthropic.js +107 -93
- package/dist/auth/providers/anthropic.js.map +1 -1
- package/dist/auth/providers/github-copilot.js +304 -293
- package/dist/auth/providers/github-copilot.js.map +1 -1
- package/dist/auth/providers/openai-codex.js +442 -460
- package/dist/auth/providers/openai-codex.js.map +1 -1
- package/dist/auth/providers/xai.js +179 -145
- package/dist/auth/providers/xai.js.map +1 -1
- package/dist/auth/storage.js +182 -175
- package/dist/auth/storage.js.map +1 -1
- package/dist/auth/types.js +1 -1
- package/dist/clipboard/index.js +206 -172
- package/dist/clipboard/index.js.map +1 -1
- package/dist/constants.js +11 -16
- package/dist/constants.js.map +1 -1
- package/dist/error-classification.js +19 -11
- package/dist/error-classification.js.map +1 -1
- package/dist/evals/context-builder.js +145 -104
- package/dist/evals/context-builder.js.map +1 -1
- package/dist/evals/index.js +4 -7
- package/dist/evals/scorers/classify-command.js +62 -41
- package/dist/evals/scorers/classify-command.js.map +1 -1
- package/dist/evals/scorers/efficiency.js +239 -181
- package/dist/evals/scorers/efficiency.js.map +1 -1
- package/dist/evals/scorers/extract-tools.js +51 -47
- package/dist/evals/scorers/extract-tools.js.map +1 -1
- package/dist/evals/scorers/index.js +1 -5
- package/dist/evals/scorers/outcome.js +321 -212
- package/dist/evals/scorers/outcome.js.map +1 -1
- package/dist/goal-manager.js +266 -261
- package/dist/goal-manager.js.map +1 -1
- package/dist/goal-signal.js +14 -13
- package/dist/goal-signal.js.map +1 -1
- package/dist/headless/cli.js +153 -154
- package/dist/headless/cli.js.map +1 -1
- package/dist/headless/flags.js +180 -178
- package/dist/headless/flags.js.map +1 -1
- package/dist/headless/format.js +72 -71
- package/dist/headless/format.js.map +1 -1
- package/dist/headless/index.js +5 -31
- package/dist/headless/policy.js +35 -31
- package/dist/headless/policy.js.map +1 -1
- package/dist/headless/run-mc.js +332 -334
- package/dist/headless/run-mc.js.map +1 -1
- package/dist/headless/types.js +16 -7
- package/dist/headless/types.js.map +1 -1
- package/dist/hooks/config.js +56 -61
- package/dist/hooks/config.js.map +1 -1
- package/dist/hooks/executor.js +118 -116
- package/dist/hooks/executor.js.map +1 -1
- package/dist/hooks/index.js +4 -15
- package/dist/hooks/manager.js +221 -280
- package/dist/hooks/manager.js.map +1 -1
- package/dist/hooks/types.js +5 -4
- package/dist/hooks/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +632 -712
- package/dist/index.js.map +1 -1
- package/dist/ipc/ipc-reporter.js +19 -22
- package/dist/ipc/ipc-reporter.js.map +1 -1
- package/dist/lsp/client.js +248 -306
- package/dist/lsp/client.js.map +1 -1
- package/dist/lsp/index.js +1 -6
- package/dist/lsp/language.js +39 -43
- package/dist/lsp/language.js.map +1 -1
- package/dist/lsp/manager.js +78 -93
- package/dist/lsp/manager.js.map +1 -1
- package/dist/lsp/server.js +151 -120
- package/dist/lsp/server.js.map +1 -1
- package/dist/lsp/workspace.js +50 -47
- package/dist/lsp/workspace.js.map +1 -1
- package/dist/mcp/config.js +210 -199
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.js +2 -9
- package/dist/mcp/manager.js +482 -475
- package/dist/mcp/manager.js.map +1 -1
- package/dist/mcp/types.js +1 -1
- package/dist/onboarding/custom-packs.js +14 -17
- package/dist/onboarding/custom-packs.js.map +1 -1
- package/dist/onboarding/custom-providers.js +22 -20
- package/dist/onboarding/custom-providers.js.map +1 -1
- package/dist/onboarding/index.d.ts +1 -1
- package/dist/onboarding/index.d.ts.map +1 -1
- package/dist/onboarding/index.js +3 -21
- package/dist/onboarding/om-settings.d.ts +5 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -1
- package/dist/onboarding/om-settings.js +41 -20
- package/dist/onboarding/om-settings.js.map +1 -1
- package/dist/onboarding/packs.d.ts +4 -6
- package/dist/onboarding/packs.d.ts.map +1 -1
- package/dist/onboarding/packs.js +154 -105
- package/dist/onboarding/packs.js.map +1 -1
- package/dist/onboarding/settings.js +575 -517
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/permissions.js +112 -99
- package/dist/permissions.js.map +1 -1
- package/dist/plugin.js +21 -23
- package/dist/plugin.js.map +1 -1
- package/dist/plugins/dependencies.js +64 -87
- package/dist/plugins/dependencies.js.map +1 -1
- package/dist/plugins/install.js +159 -169
- package/dist/plugins/install.js.map +1 -1
- package/dist/plugins/loader.js +170 -185
- package/dist/plugins/loader.js.map +1 -1
- package/dist/plugins/manager.js +374 -380
- package/dist/plugins/manager.js.map +1 -1
- package/dist/plugins/manifest.js +38 -63
- package/dist/plugins/manifest.js.map +1 -1
- package/dist/plugins/package-link.js +48 -64
- package/dist/plugins/package-link.js.map +1 -1
- package/dist/plugins/paths.js +18 -19
- package/dist/plugins/paths.js.map +1 -1
- package/dist/plugins/registry.js +97 -81
- package/dist/plugins/registry.js.map +1 -1
- package/dist/plugins/scaffold.js +62 -98
- package/dist/plugins/scaffold.js.map +1 -1
- package/dist/plugins/types.js +1 -1
- package/dist/processors/plan-rejection-abort.js +45 -44
- package/dist/processors/plan-rejection-abort.js.map +1 -1
- package/dist/providers/amazon-bedrock-gateway.js +134 -125
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -1
- package/dist/providers/amazon-bedrock.js +68 -47
- package/dist/providers/amazon-bedrock.js.map +1 -1
- package/dist/providers/claude-max.js +153 -133
- package/dist/providers/claude-max.js.map +1 -1
- package/dist/providers/github-copilot.js +232 -230
- package/dist/providers/github-copilot.js.map +1 -1
- package/dist/providers/openai-codex.js +271 -260
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/xai.js +57 -50
- package/dist/providers/xai.js.map +1 -1
- package/dist/schema.js +91 -89
- package/dist/schema.js.map +1 -1
- package/dist/theme-palette.js +18 -14
- package/dist/theme-palette.js.map +1 -1
- package/dist/tool-names.js +46 -37
- package/dist/tool-names.js.map +1 -1
- package/dist/tools/index.js +2 -8
- package/dist/tools/request-sandbox-access.js +71 -80
- package/dist/tools/request-sandbox-access.js.map +1 -1
- package/dist/tools/utils.js +26 -16
- package/dist/tools/utils.js.map +1 -1
- package/dist/tools/web-search.js +51 -55
- package/dist/tools/web-search.js.map +1 -1
- package/dist/utils/binaries.js +65 -61
- package/dist/utils/binaries.js.map +1 -1
- package/dist/utils/debug-log.js +51 -47
- package/dist/utils/debug-log.js.map +1 -1
- package/dist/utils/errors.js +157 -192
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/gateway-sync.js +49 -37
- package/dist/utils/gateway-sync.js.map +1 -1
- package/dist/utils/path-security.js +7 -6
- package/dist/utils/path-security.js.map +1 -1
- package/dist/utils/plan-diff.js +58 -39
- package/dist/utils/plan-diff.js.map +1 -1
- package/dist/utils/plans.js +92 -74
- package/dist/utils/plans.js.map +1 -1
- package/dist/utils/project.js +318 -256
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/signals-pubsub.js +117 -99
- package/dist/utils/signals-pubsub.js.map +1 -1
- package/dist/utils/slash-command-loader.js +118 -154
- package/dist/utils/slash-command-loader.js.map +1 -1
- package/dist/utils/slash-command-processor.js +92 -83
- package/dist/utils/slash-command-processor.js.map +1 -1
- package/dist/utils/stdin-pipe.js +87 -63
- package/dist/utils/stdin-pipe.js.map +1 -1
- package/dist/utils/storage-factory.js +104 -84
- package/dist/utils/storage-factory.js.map +1 -1
- package/dist/utils/storage-maintenance.js +249 -211
- package/dist/utils/storage-maintenance.js.map +1 -1
- package/dist/utils/thread-lock.js +96 -92
- package/dist/utils/thread-lock.js.map +1 -1
- package/dist/utils/token-estimator.js +12 -12
- package/dist/utils/token-estimator.js.map +1 -1
- package/dist/utils/update-check.d.ts +1 -1
- package/dist/utils/update-check.js +341 -259
- package/dist/utils/update-check.js.map +1 -1
- package/dist/voice/stt-registry.js +131 -113
- package/dist/voice/stt-registry.js.map +1 -1
- package/package.json +11 -11
- package/dist/acp.js.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/evals/index.js.map +0 -1
- package/dist/evals/scorers/index.js.map +0 -1
- package/dist/headless/index.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/lsp/index.js.map +0 -1
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/types.js.map +0 -1
- package/dist/onboarding/index.js.map +0 -1
- package/dist/plugins/types.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
package/dist/lsp/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { LSPClient } from "./client.js";
|
|
2
2
|
import { getServersForFile } from "./server.js";
|
|
3
3
|
import { lspManager } from "./manager.js";
|
|
4
|
-
export {
|
|
5
|
-
LSPClient,
|
|
6
|
-
getServersForFile,
|
|
7
|
-
lspManager
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
export { LSPClient, getServersForFile, lspManager };
|
package/dist/lsp/language.js
CHANGED
|
@@ -1,48 +1,44 @@
|
|
|
1
|
+
//#region src/lsp/language.ts
|
|
2
|
+
/**
|
|
3
|
+
* Maps file extensions to LSP language identifiers
|
|
4
|
+
*/
|
|
1
5
|
const LANGUAGE_EXTENSIONS = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
".yaml": "yaml",
|
|
30
|
-
".yml": "yaml",
|
|
31
|
-
// Markdown
|
|
32
|
-
".md": "markdown",
|
|
33
|
-
// HTML/CSS
|
|
34
|
-
".html": "html",
|
|
35
|
-
".css": "css",
|
|
36
|
-
".scss": "scss",
|
|
37
|
-
".sass": "sass",
|
|
38
|
-
".less": "less"
|
|
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"
|
|
39
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Get LSP language ID for a file path
|
|
36
|
+
*/
|
|
40
37
|
function getLanguageId(filePath) {
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const ext = filePath.substring(filePath.lastIndexOf("."));
|
|
39
|
+
return LANGUAGE_EXTENSIONS[ext];
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { LANGUAGE_EXTENSIONS, getLanguageId };
|
|
43
|
+
|
|
48
44
|
//# sourceMappingURL=language.js.map
|
package/dist/lsp/language.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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":"
|
|
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"}
|
package/dist/lsp/manager.js
CHANGED
|
@@ -1,97 +1,82 @@
|
|
|
1
1
|
import { LSPClient } from "./client.js";
|
|
2
2
|
import { getServersForFile } from "./server.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
getActiveClientCount() {
|
|
78
|
-
return this.clients.size;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Close a document in all active clients
|
|
82
|
-
* This is useful for tests that reuse the same file path
|
|
83
|
-
*/
|
|
84
|
-
closeDocument(filePath) {
|
|
85
|
-
for (const client of this.clients.values()) {
|
|
86
|
-
try {
|
|
87
|
-
client.notifyClose(filePath);
|
|
88
|
-
} catch {
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const lspManager = new LSPManager();
|
|
94
|
-
export {
|
|
95
|
-
lspManager
|
|
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
|
+
}
|
|
96
77
|
};
|
|
78
|
+
const lspManager = new LSPManager();
|
|
79
|
+
//#endregion
|
|
80
|
+
export { lspManager };
|
|
81
|
+
|
|
97
82
|
//# sourceMappingURL=manager.js.map
|
package/dist/lsp/manager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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":"
|
|
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"}
|
package/dist/lsp/server.js
CHANGED
|
@@ -1,128 +1,159 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import path, { join } from "node:path";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
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
|
+
*/
|
|
7
11
|
function findNearestRoot(cwd, markers) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (parent === current) break;
|
|
17
|
-
current = parent;
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
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
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Built-in LSP server definitions
|
|
23
|
+
*/
|
|
21
24
|
const BUILTIN_SERVERS = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
}
|
|
115
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Get all servers that can handle a file
|
|
150
|
+
*/
|
|
116
151
|
function getServersForFile(filePath, cwd) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(server) => server.languageIds.includes(languageId) && server.root(cwd) !== null
|
|
121
|
-
);
|
|
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);
|
|
122
155
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
getServersForFile
|
|
127
|
-
};
|
|
156
|
+
//#endregion
|
|
157
|
+
export { BUILTIN_SERVERS, findNearestRoot, getServersForFile };
|
|
158
|
+
|
|
128
159
|
//# sourceMappingURL=server.js.map
|