pybao-cli 1.3.62 → 1.3.64
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/dist/REPL-G5ROIO54.js +42 -0
- package/dist/{acp-E4ORUUG6.js → acp-5GSH6EXS.js} +35 -33
- package/dist/{acp-E4ORUUG6.js.map → acp-5GSH6EXS.js.map} +1 -1
- package/dist/{agentsValidate-XGPIMBWY.js → agentsValidate-VG3EFPJY.js} +7 -7
- package/dist/{ask-2XSGPUFY.js → ask-NXWU4WXV.js} +29 -29
- package/dist/{autoUpdater-EA3SMTGS.js → autoUpdater-CS37G7JH.js} +3 -3
- package/dist/blockParser-CFQE5IAN.js +54 -0
- package/dist/blockParser-CFQE5IAN.js.map +7 -0
- package/dist/{chunk-U5LLDWEZ.js → chunk-44LIZIG4.js} +1 -1
- package/dist/{chunk-E3F3GF24.js → chunk-564FCO3O.js} +7 -7
- package/dist/{chunk-QZQWZEE4.js → chunk-62BPTM22.js} +1 -1
- package/dist/{chunk-5F7W4RBR.js → chunk-AWF22TQA.js} +1 -1
- package/dist/{chunk-E6J3J4NP.js → chunk-BEYXNT3B.js} +1 -1
- package/dist/{chunk-7T5HJASI.js → chunk-DE45OGV2.js} +3 -3
- package/dist/{chunk-EBT7XQ6S.js → chunk-E7DJCNPH.js} +3 -3
- package/dist/{chunk-HZVVMIKU.js → chunk-F7YUCKEG.js} +3 -3
- package/dist/{chunk-MHYAFWIN.js → chunk-HFVO3U7D.js} +1 -1
- package/dist/{chunk-46POHLME.js → chunk-JKZNJH4H.js} +546 -776
- package/dist/chunk-JKZNJH4H.js.map +7 -0
- package/dist/chunk-K4F43CEG.js +727 -0
- package/dist/chunk-K4F43CEG.js.map +7 -0
- package/dist/{chunk-2MUYWG5A.js → chunk-KGPZOVSK.js} +1 -1
- package/dist/{chunk-2MUYWG5A.js.map → chunk-KGPZOVSK.js.map} +1 -1
- package/dist/{chunk-C5CUCBJ4.js → chunk-L6E3GWAN.js} +2 -2
- package/dist/{chunk-H7QQQG7D.js → chunk-L7SSQIS4.js} +1 -1
- package/dist/{chunk-CAMPL4AN.js → chunk-L7XD2SDM.js} +1 -1
- package/dist/{chunk-755RLUNM.js → chunk-LATRINJL.js} +1 -1
- package/dist/{chunk-AQ2HCXCW.js → chunk-MFIUM74N.js} +1 -1
- package/dist/{chunk-UVD6OLKV.js → chunk-OOOIM522.js} +3 -3
- package/dist/{chunk-DKIGBYKF.js → chunk-PA7H4OQC.js} +2 -2
- package/dist/{chunk-DCROD4XG.js → chunk-QCC7OITN.js} +2 -2
- package/dist/chunk-QONPUH55.js +323 -0
- package/dist/chunk-QONPUH55.js.map +7 -0
- package/dist/{chunk-H6AUMJOJ.js → chunk-RQAITTSX.js} +179 -745
- package/dist/chunk-RQAITTSX.js.map +7 -0
- package/dist/{chunk-M7KNDY5P.js → chunk-T262SVHZ.js} +5 -5
- package/dist/{chunk-NTCRKERM.js → chunk-TQL2DUII.js} +3 -3
- package/dist/{chunk-63M6WU3A.js → chunk-VUS6CHKJ.js} +2 -2
- package/dist/{chunk-THCNHWHQ.js → chunk-WN2XXHNB.js} +2 -2
- package/dist/{chunk-AEWQCACK.js → chunk-XO2GLVQX.js} +4 -4
- package/dist/{chunk-NYK4S5HS.js → chunk-ZD45HTW4.js} +6 -6
- package/dist/{chunk-HZV2KUZV.js → chunk-ZZWMWREU.js} +3 -3
- package/dist/{cli-KPXNIY4B.js → cli-LTMUDVSO.js} +90 -88
- package/dist/{cli-KPXNIY4B.js.map → cli-LTMUDVSO.js.map} +1 -1
- package/dist/commands-OXAWOLWC.js +46 -0
- package/dist/{config-MF6CHCR2.js → config-LPIWUZDG.js} +4 -4
- package/dist/{context-RDXY7XES.js → context-FDY7KASK.js} +5 -5
- package/dist/{customCommands-Y6RHVSCF.js → customCommands-HL4L5XKU.js} +4 -4
- package/dist/{env-FZLSAOGM.js → env-KT3C4PNM.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{llm-5CCL32VY.js → llm-GFTKKVTZ.js} +36 -36
- package/dist/{llmLazy-FGXF7GIC.js → llmLazy-V5UDMJXT.js} +1 -1
- package/dist/{loader-ZSTIZJIW.js → loader-7ZC2BNNC.js} +4 -4
- package/dist/lspAnchor-XFCCXSQI.js +77 -0
- package/dist/lspAnchor-XFCCXSQI.js.map +7 -0
- package/dist/manager-4UOP4R3A.js +12 -0
- package/dist/{mcp-YFO3QPJ6.js → mcp-L2JIKEWZ.js} +7 -7
- package/dist/{mentionProcessor-EMFPDQOH.js → mentionProcessor-OQ2CKQEI.js} +5 -5
- package/dist/{messages-HCJ6555M.js → messages-XGI3SVGF.js} +1 -1
- package/dist/{model-4LKKMVPC.js → model-X64ICC6T.js} +5 -5
- package/dist/{openai-JZNJGZNU.js → openai-CRIRHSVF.js} +5 -5
- package/dist/{outputStyles-U6B4LWVO.js → outputStyles-6S5IPYOE.js} +4 -4
- package/dist/{pluginRuntime-A2AWM3Q6.js → pluginRuntime-E25X4DF2.js} +6 -6
- package/dist/{pluginValidation-XB3PWUM5.js → pluginValidation-SSVRKP4T.js} +6 -6
- package/dist/prompts-SWS7INIG.js +48 -0
- package/dist/{pybAgentSessionLoad-ZKFVCJPW.js → pybAgentSessionLoad-USXXUZ4J.js} +4 -4
- package/dist/{pybAgentSessionResume-DE4JLCCC.js → pybAgentSessionResume-S7WYGRX4.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-5IYZ5RHL.js → pybAgentStreamJsonSession-4LVBFH43.js} +1 -1
- package/dist/{pybHooks-Z2SZ736X.js → pybHooks-UNH6GUNG.js} +4 -4
- package/dist/query-BM2KFEDF.js +50 -0
- package/dist/{ripgrep-VP646M4W.js → ripgrep-3RK2NAQE.js} +3 -3
- package/dist/{skillMarketplace-WCGQOTNM.js → skillMarketplace-YZZMAWE3.js} +3 -3
- package/dist/smart-edit-J5J4S2TS.js +54 -0
- package/dist/smart-edit-J5J4S2TS.js.map +7 -0
- package/dist/{state-HXU5E4JD.js → state-5VXARPH2.js} +2 -2
- package/dist/{theme-MQCZHWJ2.js → theme-N7F6FII5.js} +5 -5
- package/dist/{toolPermissionSettings-XCDVYB3P.js → toolPermissionSettings-H5276GYI.js} +6 -6
- package/dist/tools-Q5R2XLVA.js +49 -0
- package/dist/tools-Q5R2XLVA.js.map +7 -0
- package/dist/{userInput-JX2UGSWD.js → userInput-VQX2KYRL.js} +32 -32
- package/package.json +1 -1
- package/dist/REPL-I2MV4CLO.js +0 -42
- package/dist/chunk-46POHLME.js.map +0 -7
- package/dist/chunk-H6AUMJOJ.js.map +0 -7
- package/dist/commands-JXQA3F7B.js +0 -46
- package/dist/prompts-SYOCBLKQ.js +0 -48
- package/dist/query-XS3ZVIZL.js +0 -50
- package/dist/tools-BLPOCGYT.js +0 -47
- /package/dist/{REPL-I2MV4CLO.js.map → REPL-G5ROIO54.js.map} +0 -0
- /package/dist/{agentsValidate-XGPIMBWY.js.map → agentsValidate-VG3EFPJY.js.map} +0 -0
- /package/dist/{ask-2XSGPUFY.js.map → ask-NXWU4WXV.js.map} +0 -0
- /package/dist/{autoUpdater-EA3SMTGS.js.map → autoUpdater-CS37G7JH.js.map} +0 -0
- /package/dist/{chunk-U5LLDWEZ.js.map → chunk-44LIZIG4.js.map} +0 -0
- /package/dist/{chunk-E3F3GF24.js.map → chunk-564FCO3O.js.map} +0 -0
- /package/dist/{chunk-QZQWZEE4.js.map → chunk-62BPTM22.js.map} +0 -0
- /package/dist/{chunk-5F7W4RBR.js.map → chunk-AWF22TQA.js.map} +0 -0
- /package/dist/{chunk-E6J3J4NP.js.map → chunk-BEYXNT3B.js.map} +0 -0
- /package/dist/{chunk-7T5HJASI.js.map → chunk-DE45OGV2.js.map} +0 -0
- /package/dist/{chunk-EBT7XQ6S.js.map → chunk-E7DJCNPH.js.map} +0 -0
- /package/dist/{chunk-HZVVMIKU.js.map → chunk-F7YUCKEG.js.map} +0 -0
- /package/dist/{chunk-MHYAFWIN.js.map → chunk-HFVO3U7D.js.map} +0 -0
- /package/dist/{chunk-C5CUCBJ4.js.map → chunk-L6E3GWAN.js.map} +0 -0
- /package/dist/{chunk-H7QQQG7D.js.map → chunk-L7SSQIS4.js.map} +0 -0
- /package/dist/{chunk-CAMPL4AN.js.map → chunk-L7XD2SDM.js.map} +0 -0
- /package/dist/{chunk-755RLUNM.js.map → chunk-LATRINJL.js.map} +0 -0
- /package/dist/{chunk-AQ2HCXCW.js.map → chunk-MFIUM74N.js.map} +0 -0
- /package/dist/{chunk-UVD6OLKV.js.map → chunk-OOOIM522.js.map} +0 -0
- /package/dist/{chunk-DKIGBYKF.js.map → chunk-PA7H4OQC.js.map} +0 -0
- /package/dist/{chunk-DCROD4XG.js.map → chunk-QCC7OITN.js.map} +0 -0
- /package/dist/{chunk-M7KNDY5P.js.map → chunk-T262SVHZ.js.map} +0 -0
- /package/dist/{chunk-NTCRKERM.js.map → chunk-TQL2DUII.js.map} +0 -0
- /package/dist/{chunk-63M6WU3A.js.map → chunk-VUS6CHKJ.js.map} +0 -0
- /package/dist/{chunk-THCNHWHQ.js.map → chunk-WN2XXHNB.js.map} +0 -0
- /package/dist/{chunk-AEWQCACK.js.map → chunk-XO2GLVQX.js.map} +0 -0
- /package/dist/{chunk-NYK4S5HS.js.map → chunk-ZD45HTW4.js.map} +0 -0
- /package/dist/{chunk-HZV2KUZV.js.map → chunk-ZZWMWREU.js.map} +0 -0
- /package/dist/{commands-JXQA3F7B.js.map → commands-OXAWOLWC.js.map} +0 -0
- /package/dist/{config-MF6CHCR2.js.map → config-LPIWUZDG.js.map} +0 -0
- /package/dist/{context-RDXY7XES.js.map → context-FDY7KASK.js.map} +0 -0
- /package/dist/{customCommands-Y6RHVSCF.js.map → customCommands-HL4L5XKU.js.map} +0 -0
- /package/dist/{env-FZLSAOGM.js.map → env-KT3C4PNM.js.map} +0 -0
- /package/dist/{llm-5CCL32VY.js.map → llm-GFTKKVTZ.js.map} +0 -0
- /package/dist/{llmLazy-FGXF7GIC.js.map → llmLazy-V5UDMJXT.js.map} +0 -0
- /package/dist/{loader-ZSTIZJIW.js.map → loader-7ZC2BNNC.js.map} +0 -0
- /package/dist/{mcp-YFO3QPJ6.js.map → manager-4UOP4R3A.js.map} +0 -0
- /package/dist/{messages-HCJ6555M.js.map → mcp-L2JIKEWZ.js.map} +0 -0
- /package/dist/{mentionProcessor-EMFPDQOH.js.map → mentionProcessor-OQ2CKQEI.js.map} +0 -0
- /package/dist/{model-4LKKMVPC.js.map → messages-XGI3SVGF.js.map} +0 -0
- /package/dist/{openai-JZNJGZNU.js.map → model-X64ICC6T.js.map} +0 -0
- /package/dist/{outputStyles-U6B4LWVO.js.map → openai-CRIRHSVF.js.map} +0 -0
- /package/dist/{pluginValidation-XB3PWUM5.js.map → outputStyles-6S5IPYOE.js.map} +0 -0
- /package/dist/{pluginRuntime-A2AWM3Q6.js.map → pluginRuntime-E25X4DF2.js.map} +0 -0
- /package/dist/{prompts-SYOCBLKQ.js.map → pluginValidation-SSVRKP4T.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-ZKFVCJPW.js.map → prompts-SWS7INIG.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-DE4JLCCC.js.map → pybAgentSessionLoad-USXXUZ4J.js.map} +0 -0
- /package/dist/{pybHooks-Z2SZ736X.js.map → pybAgentSessionResume-S7WYGRX4.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-5IYZ5RHL.js.map → pybAgentStreamJsonSession-4LVBFH43.js.map} +0 -0
- /package/dist/{query-XS3ZVIZL.js.map → pybHooks-UNH6GUNG.js.map} +0 -0
- /package/dist/{ripgrep-VP646M4W.js.map → query-BM2KFEDF.js.map} +0 -0
- /package/dist/{skillMarketplace-WCGQOTNM.js.map → ripgrep-3RK2NAQE.js.map} +0 -0
- /package/dist/{state-HXU5E4JD.js.map → skillMarketplace-YZZMAWE3.js.map} +0 -0
- /package/dist/{theme-MQCZHWJ2.js.map → state-5VXARPH2.js.map} +0 -0
- /package/dist/{toolPermissionSettings-XCDVYB3P.js.map → theme-N7F6FII5.js.map} +0 -0
- /package/dist/{tools-BLPOCGYT.js.map → toolPermissionSettings-H5276GYI.js.map} +0 -0
- /package/dist/{userInput-JX2UGSWD.js.map → userInput-VQX2KYRL.js.map} +0 -0
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import { createRequire as __pybCreateRequire } from "node:module";
|
|
2
|
+
const require = __pybCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
debug
|
|
5
|
+
} from "./chunk-BEYXNT3B.js";
|
|
6
|
+
import {
|
|
7
|
+
__require
|
|
8
|
+
} from "./chunk-I3J4JYES.js";
|
|
9
|
+
|
|
10
|
+
// src/tools/search/LspTool/client/generic.ts
|
|
11
|
+
import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
|
|
12
|
+
import { spawn } from "child_process";
|
|
13
|
+
import { pathToFileURL } from "url";
|
|
14
|
+
var GenericLspClient = class {
|
|
15
|
+
constructor(serverCommand, serverArgs, cwd, rootPath) {
|
|
16
|
+
this.rootPath = rootPath;
|
|
17
|
+
const env = {
|
|
18
|
+
...process.env,
|
|
19
|
+
// Remove potentially conflicting variables
|
|
20
|
+
NODE_OPTIONS: void 0,
|
|
21
|
+
TS_NODE_PROJECT: void 0,
|
|
22
|
+
ELECTRON_RUN_AS_NODE: void 0
|
|
23
|
+
};
|
|
24
|
+
const options = {
|
|
25
|
+
cwd,
|
|
26
|
+
stdio: "pipe",
|
|
27
|
+
env,
|
|
28
|
+
shell: false
|
|
29
|
+
};
|
|
30
|
+
this.process = spawn(serverCommand, serverArgs, options);
|
|
31
|
+
this.process.stderr.on("data", (data) => {
|
|
32
|
+
console.error(`[LSP Stderr] ${data}`);
|
|
33
|
+
});
|
|
34
|
+
this.connection = createMessageConnection(
|
|
35
|
+
new StreamMessageReader(this.process.stdout),
|
|
36
|
+
new StreamMessageWriter(this.process.stdin)
|
|
37
|
+
);
|
|
38
|
+
this.connection.onNotification((method, params) => {
|
|
39
|
+
if (method === "window/logMessage" || method === "$/progress") {
|
|
40
|
+
console.log(`[LSP Notification] ${method}:`, JSON.stringify(params));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.connection.onRequest((method, params) => {
|
|
44
|
+
if (method === "workspace/configuration") {
|
|
45
|
+
return Array.isArray(params.items) ? params.items.map(() => ({})) : [];
|
|
46
|
+
}
|
|
47
|
+
if (method === "client/registerCapability") {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
});
|
|
52
|
+
this.connection.listen();
|
|
53
|
+
}
|
|
54
|
+
connection;
|
|
55
|
+
process;
|
|
56
|
+
capabilities;
|
|
57
|
+
normalizeUri(filePath) {
|
|
58
|
+
let uri = pathToFileURL(filePath).href;
|
|
59
|
+
if (process.platform === "win32") {
|
|
60
|
+
uri = uri.replace(/^file:\/\/\/([a-zA-Z]):\//, (match, drive) => {
|
|
61
|
+
return `file:///${drive.toLowerCase()}%3A/`;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return uri;
|
|
65
|
+
}
|
|
66
|
+
async initialize() {
|
|
67
|
+
const rootUri = this.normalizeUri(this.rootPath);
|
|
68
|
+
console.log("[GenericLspClient] Initializing with normalized rootUri:", rootUri);
|
|
69
|
+
const params = {
|
|
70
|
+
processId: process.pid,
|
|
71
|
+
rootUri,
|
|
72
|
+
capabilities: {
|
|
73
|
+
textDocument: {
|
|
74
|
+
synchronization: {
|
|
75
|
+
didOpen: true,
|
|
76
|
+
didChange: true,
|
|
77
|
+
willSave: false,
|
|
78
|
+
willSaveWaitUntil: false,
|
|
79
|
+
didSave: true
|
|
80
|
+
},
|
|
81
|
+
hover: {
|
|
82
|
+
contentFormat: ["markdown", "plaintext"]
|
|
83
|
+
},
|
|
84
|
+
definition: {},
|
|
85
|
+
references: {}
|
|
86
|
+
},
|
|
87
|
+
workspace: {
|
|
88
|
+
workspaceFolders: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
workspaceFolders: [
|
|
92
|
+
{
|
|
93
|
+
name: "workspace",
|
|
94
|
+
uri: this.normalizeUri(this.rootPath)
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
};
|
|
98
|
+
const result = await this.connection.sendRequest("initialize", params);
|
|
99
|
+
await this.connection.sendNotification("initialized", {});
|
|
100
|
+
await this.connection.sendNotification("workspace/didChangeConfiguration", { settings: {} });
|
|
101
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
102
|
+
this.capabilities = result.capabilities;
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async shutdown() {
|
|
106
|
+
try {
|
|
107
|
+
await this.connection.sendRequest("shutdown");
|
|
108
|
+
await this.connection.sendNotification("exit");
|
|
109
|
+
} catch (error) {
|
|
110
|
+
}
|
|
111
|
+
this.connection.dispose();
|
|
112
|
+
this.process.kill();
|
|
113
|
+
}
|
|
114
|
+
async goToDefinition(filePath, line, character) {
|
|
115
|
+
const params = {
|
|
116
|
+
textDocument: { uri: this.normalizeUri(filePath) },
|
|
117
|
+
position: { line: line - 1, character: character - 1 }
|
|
118
|
+
};
|
|
119
|
+
return this.connection.sendRequest("textDocument/definition", params);
|
|
120
|
+
}
|
|
121
|
+
async findReferences(filePath, line, character) {
|
|
122
|
+
const params = {
|
|
123
|
+
textDocument: { uri: this.normalizeUri(filePath) },
|
|
124
|
+
position: { line: line - 1, character: character - 1 },
|
|
125
|
+
context: { includeDeclaration: true }
|
|
126
|
+
};
|
|
127
|
+
return this.connection.sendRequest("textDocument/references", params);
|
|
128
|
+
}
|
|
129
|
+
async hover(filePath, line, character) {
|
|
130
|
+
const params = {
|
|
131
|
+
textDocument: { uri: this.normalizeUri(filePath) },
|
|
132
|
+
position: { line: line - 1, character: character - 1 }
|
|
133
|
+
};
|
|
134
|
+
return this.connection.sendRequest("textDocument/hover", params);
|
|
135
|
+
}
|
|
136
|
+
async documentSymbol(filePath) {
|
|
137
|
+
const params = {
|
|
138
|
+
textDocument: { uri: this.normalizeUri(filePath) }
|
|
139
|
+
};
|
|
140
|
+
return this.connection.sendRequest("textDocument/documentSymbol", params);
|
|
141
|
+
}
|
|
142
|
+
async workspaceSymbol(query) {
|
|
143
|
+
const params = {
|
|
144
|
+
query
|
|
145
|
+
};
|
|
146
|
+
return this.connection.sendRequest("workspace/symbol", params);
|
|
147
|
+
}
|
|
148
|
+
async goToImplementation(filePath, line, character) {
|
|
149
|
+
const params = {
|
|
150
|
+
textDocument: { uri: this.normalizeUri(filePath) },
|
|
151
|
+
position: { line: line - 1, character: character - 1 }
|
|
152
|
+
};
|
|
153
|
+
return this.connection.sendRequest("textDocument/implementation", params);
|
|
154
|
+
}
|
|
155
|
+
async didOpen(filePath, content, languageId) {
|
|
156
|
+
const params = {
|
|
157
|
+
textDocument: {
|
|
158
|
+
uri: this.normalizeUri(filePath),
|
|
159
|
+
languageId,
|
|
160
|
+
version: 1,
|
|
161
|
+
text: content
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
await this.connection.sendNotification("textDocument/didOpen", params);
|
|
165
|
+
}
|
|
166
|
+
async didChange(filePath, content, version) {
|
|
167
|
+
const params = {
|
|
168
|
+
textDocument: {
|
|
169
|
+
uri: this.normalizeUri(filePath),
|
|
170
|
+
version
|
|
171
|
+
},
|
|
172
|
+
contentChanges: [{ text: content }]
|
|
173
|
+
};
|
|
174
|
+
await this.connection.sendNotification("textDocument/didChange", params);
|
|
175
|
+
}
|
|
176
|
+
getDiagnostics(filePath) {
|
|
177
|
+
return this.diagnostics.get(this.normalizeUri(filePath)) || [];
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/tools/search/LspTool/client/manager.ts
|
|
182
|
+
import { extname } from "path";
|
|
183
|
+
|
|
184
|
+
// src/tools/search/LspTool/registry.ts
|
|
185
|
+
import { join, dirname } from "path";
|
|
186
|
+
import { existsSync } from "fs";
|
|
187
|
+
import { spawnSync } from "child_process";
|
|
188
|
+
var BaseLspServer = class {
|
|
189
|
+
isInPath(cmd) {
|
|
190
|
+
try {
|
|
191
|
+
const where = process.platform === "win32" ? "where" : "which";
|
|
192
|
+
const result = spawnSync(where, [cmd], { encoding: "utf8" });
|
|
193
|
+
return result.status === 0;
|
|
194
|
+
} catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
getLocalBinPath(binName, npmPackageName) {
|
|
199
|
+
const ext = process.platform === "win32" ? ".cmd" : "";
|
|
200
|
+
const localNodeModulesBin = join(process.cwd(), "node_modules", ".bin");
|
|
201
|
+
let localBinPath = join(localNodeModulesBin, `${binName}${ext}`);
|
|
202
|
+
if (existsSync(localBinPath)) {
|
|
203
|
+
return localBinPath;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const pkgName = npmPackageName || binName;
|
|
207
|
+
const pkgEntry = __require.resolve(pkgName, { paths: [process.cwd(), __dirname] });
|
|
208
|
+
let current = pkgEntry;
|
|
209
|
+
let pkgRoot = "";
|
|
210
|
+
for (let i = 0; i < 5; i++) {
|
|
211
|
+
current = join(current, "..");
|
|
212
|
+
if (existsSync(join(current, "package.json"))) {
|
|
213
|
+
pkgRoot = current;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (pkgRoot) {
|
|
218
|
+
const nodeModulesRoot = join(pkgRoot, "..");
|
|
219
|
+
const potentialBin = join(nodeModulesRoot, ".bin", `${binName}${ext}`);
|
|
220
|
+
if (existsSync(potentialBin)) {
|
|
221
|
+
return potentialBin;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch (e) {
|
|
225
|
+
}
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var GenericNpmServer = class extends BaseLspServer {
|
|
230
|
+
id;
|
|
231
|
+
extensions;
|
|
232
|
+
rootMarkers;
|
|
233
|
+
npmPackage;
|
|
234
|
+
binName;
|
|
235
|
+
args;
|
|
236
|
+
constructor(id, extensions, rootMarkers, npmPackage, binName, args) {
|
|
237
|
+
super();
|
|
238
|
+
this.id = id;
|
|
239
|
+
this.extensions = extensions;
|
|
240
|
+
this.rootMarkers = rootMarkers;
|
|
241
|
+
this.npmPackage = npmPackage;
|
|
242
|
+
this.binName = binName;
|
|
243
|
+
this.args = args;
|
|
244
|
+
}
|
|
245
|
+
async prepare() {
|
|
246
|
+
if (this.isInPath(this.binName)) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
const localBin = this.getLocalBinPath(this.binName, this.npmPackage);
|
|
250
|
+
if (existsSync(localBin)) {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
async getCommand(rootPath) {
|
|
256
|
+
if (process.platform === "win32") {
|
|
257
|
+
try {
|
|
258
|
+
const pkgJsonPath = __require.resolve(`${this.npmPackage}/package.json`, { paths: [process.cwd(), __dirname] });
|
|
259
|
+
const pkgJson = __require(pkgJsonPath);
|
|
260
|
+
let binScript = "";
|
|
261
|
+
if (typeof pkgJson.bin === "string") {
|
|
262
|
+
binScript = pkgJson.bin;
|
|
263
|
+
} else if (typeof pkgJson.bin === "object" && pkgJson.bin[this.binName]) {
|
|
264
|
+
binScript = pkgJson.bin[this.binName];
|
|
265
|
+
}
|
|
266
|
+
if (binScript) {
|
|
267
|
+
if (this.npmPackage === "pyright" && binScript.endsWith("langserver.index.js")) {
|
|
268
|
+
const distScript = join(dirname(pkgJsonPath), "dist", "pyright-langserver.js");
|
|
269
|
+
if (existsSync(distScript)) {
|
|
270
|
+
return { command: process.execPath, args: [distScript, ...this.args] };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const scriptPath = join(dirname(pkgJsonPath), binScript);
|
|
274
|
+
if (existsSync(scriptPath)) {
|
|
275
|
+
return { command: process.execPath, args: [scriptPath, ...this.args] };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch (e) {
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (this.isInPath(this.binName)) {
|
|
282
|
+
return { command: this.binName, args: this.args };
|
|
283
|
+
}
|
|
284
|
+
const localBin = this.getLocalBinPath(this.binName, this.npmPackage);
|
|
285
|
+
if (existsSync(localBin)) {
|
|
286
|
+
return { command: localBin, args: this.args };
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var GenericBinaryServer = class extends BaseLspServer {
|
|
292
|
+
id;
|
|
293
|
+
extensions;
|
|
294
|
+
rootMarkers;
|
|
295
|
+
binNames;
|
|
296
|
+
args;
|
|
297
|
+
constructor(id, extensions, rootMarkers, binNames, args) {
|
|
298
|
+
super();
|
|
299
|
+
this.id = id;
|
|
300
|
+
this.extensions = extensions;
|
|
301
|
+
this.rootMarkers = rootMarkers;
|
|
302
|
+
this.binNames = Array.isArray(binNames) ? binNames : [binNames];
|
|
303
|
+
this.args = args;
|
|
304
|
+
}
|
|
305
|
+
async prepare() {
|
|
306
|
+
return this.binNames.some((bin) => this.isInPath(bin));
|
|
307
|
+
}
|
|
308
|
+
async getCommand(rootPath) {
|
|
309
|
+
for (const bin of this.binNames) {
|
|
310
|
+
if (this.isInPath(bin)) {
|
|
311
|
+
return { command: bin, args: this.args };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
var GoplsServer = class extends BaseLspServer {
|
|
318
|
+
id = "gopls";
|
|
319
|
+
extensions = [".go", ".mod"];
|
|
320
|
+
rootMarkers = ["go.mod", "go.work", ".git"];
|
|
321
|
+
async prepare() {
|
|
322
|
+
if (this.isInPath("gopls")) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
if (!this.isInPath("go")) {
|
|
326
|
+
debug.error("LSP_MISSING_DEP", { server: this.id, error: "go command not found" });
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
return this.installGo();
|
|
330
|
+
}
|
|
331
|
+
async getCommand(rootPath) {
|
|
332
|
+
if (this.isInPath("gopls")) {
|
|
333
|
+
return { command: "gopls", args: ["serve"] };
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
async installGo() {
|
|
338
|
+
try {
|
|
339
|
+
debug.info("LSP_INSTALL", { server: this.id, action: "start" });
|
|
340
|
+
const result = spawnSync("go", ["install", "golang.org/x/tools/gopls@latest"], {
|
|
341
|
+
encoding: "utf8"
|
|
342
|
+
});
|
|
343
|
+
if (result.status !== 0) {
|
|
344
|
+
debug.error("LSP_INSTALL_FAILED", { server: this.id, error: result.stderr });
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
if (!this.isInPath("gopls")) {
|
|
348
|
+
debug.warn("LSP_INSTALL_WARNING", { server: this.id, message: "gopls installed but not found in PATH. Make sure $(go env GOPATH)/bin is in your PATH." });
|
|
349
|
+
}
|
|
350
|
+
debug.info("LSP_INSTALL", { server: this.id, action: "success" });
|
|
351
|
+
return true;
|
|
352
|
+
} catch (e) {
|
|
353
|
+
debug.error("LSP_INSTALL_ERROR", { server: this.id, error: String(e) });
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var RustAnalyzerServer = class extends BaseLspServer {
|
|
359
|
+
id = "rust-analyzer";
|
|
360
|
+
extensions = [".rs"];
|
|
361
|
+
rootMarkers = ["Cargo.toml", "rust-project.json", ".git"];
|
|
362
|
+
async prepare() {
|
|
363
|
+
if (this.isInPath("rust-analyzer")) {
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
if (this.isInPath("rustup")) {
|
|
367
|
+
return this.installRustup();
|
|
368
|
+
}
|
|
369
|
+
debug.warn("LSP_MISSING_DEP", { server: this.id, message: "rust-analyzer not found and rustup not available. Please install rust-analyzer manually." });
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
async getCommand(rootPath) {
|
|
373
|
+
if (this.isInPath("rust-analyzer")) {
|
|
374
|
+
return { command: "rust-analyzer", args: [] };
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
async installRustup() {
|
|
379
|
+
try {
|
|
380
|
+
debug.info("LSP_INSTALL", { server: this.id, action: "start" });
|
|
381
|
+
const result = spawnSync("rustup", ["component", "add", "rust-analyzer"], {
|
|
382
|
+
encoding: "utf8"
|
|
383
|
+
});
|
|
384
|
+
if (result.status !== 0) {
|
|
385
|
+
debug.error("LSP_INSTALL_FAILED", { server: this.id, error: result.stderr });
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
debug.info("LSP_INSTALL", { server: this.id, action: "success" });
|
|
389
|
+
return true;
|
|
390
|
+
} catch (e) {
|
|
391
|
+
debug.error("LSP_INSTALL_ERROR", { server: this.id, error: String(e) });
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var LspServerRegistry = class _LspServerRegistry {
|
|
397
|
+
static instance;
|
|
398
|
+
servers = [];
|
|
399
|
+
constructor() {
|
|
400
|
+
this.register(new GenericNpmServer(
|
|
401
|
+
"pyright",
|
|
402
|
+
[".py", ".pyi"],
|
|
403
|
+
["pyrightconfig.json", "pyproject.toml", "setup.py", "requirements.txt", "Pipfile"],
|
|
404
|
+
"pyright",
|
|
405
|
+
"pyright-langserver",
|
|
406
|
+
["--stdio"]
|
|
407
|
+
));
|
|
408
|
+
this.register(new GoplsServer());
|
|
409
|
+
this.register(new RustAnalyzerServer());
|
|
410
|
+
this.register(new GenericNpmServer(
|
|
411
|
+
"bash-language-server",
|
|
412
|
+
[".sh", ".bash", ".zsh"],
|
|
413
|
+
[".git"],
|
|
414
|
+
"bash-language-server",
|
|
415
|
+
"bash-language-server",
|
|
416
|
+
["start"]
|
|
417
|
+
));
|
|
418
|
+
this.register(new GenericNpmServer(
|
|
419
|
+
"yaml-language-server",
|
|
420
|
+
[".yaml", ".yml"],
|
|
421
|
+
[],
|
|
422
|
+
"yaml-language-server",
|
|
423
|
+
"yaml-language-server",
|
|
424
|
+
["--stdio"]
|
|
425
|
+
));
|
|
426
|
+
this.register(new GenericNpmServer(
|
|
427
|
+
"dockerfile-language-server",
|
|
428
|
+
["Dockerfile", ".dockerfile"],
|
|
429
|
+
[],
|
|
430
|
+
"dockerfile-language-server-nodejs",
|
|
431
|
+
"docker-langserver",
|
|
432
|
+
["--stdio"]
|
|
433
|
+
));
|
|
434
|
+
this.register(new GenericNpmServer(
|
|
435
|
+
"vue-language-server",
|
|
436
|
+
[".vue"],
|
|
437
|
+
["package.json"],
|
|
438
|
+
"@vue/language-server",
|
|
439
|
+
"vue-language-server",
|
|
440
|
+
["--stdio"]
|
|
441
|
+
));
|
|
442
|
+
this.register(new GenericNpmServer(
|
|
443
|
+
"html-language-server",
|
|
444
|
+
[".html", ".htm"],
|
|
445
|
+
[],
|
|
446
|
+
"vscode-langservers-extracted",
|
|
447
|
+
"vscode-html-language-server",
|
|
448
|
+
["--stdio"]
|
|
449
|
+
));
|
|
450
|
+
this.register(new GenericNpmServer(
|
|
451
|
+
"css-language-server",
|
|
452
|
+
[".css", ".scss", ".less"],
|
|
453
|
+
[],
|
|
454
|
+
"vscode-langservers-extracted",
|
|
455
|
+
"vscode-css-language-server",
|
|
456
|
+
["--stdio"]
|
|
457
|
+
));
|
|
458
|
+
this.register(new GenericNpmServer(
|
|
459
|
+
"json-language-server",
|
|
460
|
+
[".json", ".jsonc"],
|
|
461
|
+
[],
|
|
462
|
+
"vscode-langservers-extracted",
|
|
463
|
+
"vscode-json-language-server",
|
|
464
|
+
["--stdio"]
|
|
465
|
+
));
|
|
466
|
+
this.register(new GenericNpmServer(
|
|
467
|
+
"intelephense",
|
|
468
|
+
[".php"],
|
|
469
|
+
["composer.json"],
|
|
470
|
+
"intelephense",
|
|
471
|
+
"intelephense",
|
|
472
|
+
["--stdio"]
|
|
473
|
+
));
|
|
474
|
+
this.register(new GenericNpmServer(
|
|
475
|
+
"svelte-language-server",
|
|
476
|
+
[".svelte"],
|
|
477
|
+
["package.json"],
|
|
478
|
+
"svelte-language-server",
|
|
479
|
+
"svelte-language-server",
|
|
480
|
+
["--stdio"]
|
|
481
|
+
));
|
|
482
|
+
this.register(new GenericNpmServer(
|
|
483
|
+
"astro-ls",
|
|
484
|
+
[".astro"],
|
|
485
|
+
["package.json"],
|
|
486
|
+
"@astrojs/language-server",
|
|
487
|
+
"astro-ls",
|
|
488
|
+
["--stdio"]
|
|
489
|
+
));
|
|
490
|
+
this.register(new GenericNpmServer(
|
|
491
|
+
"prisma-language-server",
|
|
492
|
+
[".prisma"],
|
|
493
|
+
["schema.prisma"],
|
|
494
|
+
"@prisma/language-server",
|
|
495
|
+
"prisma-language-server",
|
|
496
|
+
["--stdio"]
|
|
497
|
+
));
|
|
498
|
+
this.register(new GenericNpmServer(
|
|
499
|
+
"graphql-lsp",
|
|
500
|
+
[".graphql", ".gql"],
|
|
501
|
+
[".graphqlrc", "graphql.config.js"],
|
|
502
|
+
"graphql-language-service-cli",
|
|
503
|
+
"graphql-lsp",
|
|
504
|
+
["server", "-m", "stream"]
|
|
505
|
+
));
|
|
506
|
+
this.register(new GenericBinaryServer(
|
|
507
|
+
"jdtls",
|
|
508
|
+
[".java"],
|
|
509
|
+
["pom.xml", "build.gradle"],
|
|
510
|
+
"jdtls",
|
|
511
|
+
[]
|
|
512
|
+
));
|
|
513
|
+
this.register(new GenericBinaryServer(
|
|
514
|
+
"clangd",
|
|
515
|
+
[".c", ".cpp", ".h", ".hpp", ".cc"],
|
|
516
|
+
["compile_commands.json", ".clang-format"],
|
|
517
|
+
"clangd",
|
|
518
|
+
["--stdio"]
|
|
519
|
+
));
|
|
520
|
+
this.register(new GenericBinaryServer(
|
|
521
|
+
"ruby-lsp",
|
|
522
|
+
[".rb", ".rake"],
|
|
523
|
+
["Gemfile", ".ruby-version"],
|
|
524
|
+
"ruby-lsp",
|
|
525
|
+
["--stdio"]
|
|
526
|
+
));
|
|
527
|
+
this.register(new GenericBinaryServer(
|
|
528
|
+
"lua-language-server",
|
|
529
|
+
[".lua"],
|
|
530
|
+
[".luarc.json"],
|
|
531
|
+
["lua-ls", "lua-language-server"],
|
|
532
|
+
[]
|
|
533
|
+
));
|
|
534
|
+
this.register(new GenericBinaryServer(
|
|
535
|
+
"terraform-ls",
|
|
536
|
+
[".tf", ".tfvars"],
|
|
537
|
+
[],
|
|
538
|
+
"terraform-ls",
|
|
539
|
+
["serve"]
|
|
540
|
+
));
|
|
541
|
+
this.register(new GenericBinaryServer(
|
|
542
|
+
"kotlin-language-server",
|
|
543
|
+
[".kt", ".kts"],
|
|
544
|
+
["build.gradle.kts"],
|
|
545
|
+
["kotlin-ls", "kotlin-language-server"],
|
|
546
|
+
[]
|
|
547
|
+
));
|
|
548
|
+
this.register(new GenericBinaryServer(
|
|
549
|
+
"elixir-ls",
|
|
550
|
+
[".ex", ".exs"],
|
|
551
|
+
["mix.exs"],
|
|
552
|
+
["elixir-ls", "language_server.sh"],
|
|
553
|
+
[]
|
|
554
|
+
));
|
|
555
|
+
this.register(new GenericBinaryServer(
|
|
556
|
+
"zls",
|
|
557
|
+
[".zig"],
|
|
558
|
+
["build.zig"],
|
|
559
|
+
"zls",
|
|
560
|
+
[]
|
|
561
|
+
));
|
|
562
|
+
this.register(new GenericBinaryServer(
|
|
563
|
+
"csharp-ls",
|
|
564
|
+
[".cs"],
|
|
565
|
+
[".csproj", ".sln"],
|
|
566
|
+
"csharp-ls",
|
|
567
|
+
[]
|
|
568
|
+
));
|
|
569
|
+
this.register(new GenericBinaryServer(
|
|
570
|
+
"fsautocomplete",
|
|
571
|
+
[".fs", ".fsi", ".fsx"],
|
|
572
|
+
[".fsproj", ".sln"],
|
|
573
|
+
"fsautocomplete",
|
|
574
|
+
["--background-service-enabled"]
|
|
575
|
+
));
|
|
576
|
+
this.register(new GenericBinaryServer(
|
|
577
|
+
"sourcekit-lsp",
|
|
578
|
+
[".swift"],
|
|
579
|
+
["Package.swift"],
|
|
580
|
+
"sourcekit-lsp",
|
|
581
|
+
[]
|
|
582
|
+
));
|
|
583
|
+
this.register(new GenericBinaryServer(
|
|
584
|
+
"dart",
|
|
585
|
+
[".dart"],
|
|
586
|
+
["pubspec.yaml"],
|
|
587
|
+
"dart",
|
|
588
|
+
["language-server"]
|
|
589
|
+
));
|
|
590
|
+
this.register(new GenericBinaryServer(
|
|
591
|
+
"ocamllsp",
|
|
592
|
+
[".ml", ".mli"],
|
|
593
|
+
["dune-project"],
|
|
594
|
+
["ocaml-lsp", "ocamllsp"],
|
|
595
|
+
[]
|
|
596
|
+
));
|
|
597
|
+
this.register(new GenericBinaryServer(
|
|
598
|
+
"gleam",
|
|
599
|
+
[".gleam"],
|
|
600
|
+
["gleam.toml"],
|
|
601
|
+
"gleam",
|
|
602
|
+
["lsp"]
|
|
603
|
+
));
|
|
604
|
+
this.register(new GenericBinaryServer(
|
|
605
|
+
"clojure-lsp",
|
|
606
|
+
[".clj", ".cljs", ".cljc", ".edn"],
|
|
607
|
+
["deps.edn", "project.clj"],
|
|
608
|
+
"clojure-lsp",
|
|
609
|
+
[]
|
|
610
|
+
));
|
|
611
|
+
this.register(new GenericBinaryServer(
|
|
612
|
+
"nixd",
|
|
613
|
+
[".nix"],
|
|
614
|
+
["flake.nix"],
|
|
615
|
+
"nixd",
|
|
616
|
+
[]
|
|
617
|
+
));
|
|
618
|
+
this.register(new GenericBinaryServer(
|
|
619
|
+
"tinymist",
|
|
620
|
+
[".typ"],
|
|
621
|
+
[],
|
|
622
|
+
"tinymist",
|
|
623
|
+
[]
|
|
624
|
+
));
|
|
625
|
+
this.register(new GenericBinaryServer(
|
|
626
|
+
"metals",
|
|
627
|
+
[".scala", ".sbt", ".sc"],
|
|
628
|
+
["build.sbt"],
|
|
629
|
+
"metals",
|
|
630
|
+
[]
|
|
631
|
+
));
|
|
632
|
+
this.register(new GenericBinaryServer(
|
|
633
|
+
"haskell-language-server",
|
|
634
|
+
[".hs", ".lhs"],
|
|
635
|
+
["stack.yaml", "cabal.project", "*.cabal"],
|
|
636
|
+
"haskell-language-server-wrapper",
|
|
637
|
+
["--lsp"]
|
|
638
|
+
));
|
|
639
|
+
this.register(new GenericBinaryServer(
|
|
640
|
+
"texlab",
|
|
641
|
+
[".tex", ".bib"],
|
|
642
|
+
[],
|
|
643
|
+
"texlab",
|
|
644
|
+
[]
|
|
645
|
+
));
|
|
646
|
+
}
|
|
647
|
+
static getInstance() {
|
|
648
|
+
if (!_LspServerRegistry.instance) {
|
|
649
|
+
_LspServerRegistry.instance = new _LspServerRegistry();
|
|
650
|
+
}
|
|
651
|
+
return _LspServerRegistry.instance;
|
|
652
|
+
}
|
|
653
|
+
register(server) {
|
|
654
|
+
this.servers.push(server);
|
|
655
|
+
}
|
|
656
|
+
getServerForExtension(ext) {
|
|
657
|
+
return this.servers.find((s) => s.extensions.includes(ext)) || null;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
// src/tools/search/LspTool/client/manager.ts
|
|
662
|
+
var LspClientManager = class _LspClientManager {
|
|
663
|
+
static instance;
|
|
664
|
+
clients = /* @__PURE__ */ new Map();
|
|
665
|
+
constructor() {
|
|
666
|
+
}
|
|
667
|
+
static getInstance() {
|
|
668
|
+
if (!_LspClientManager.instance) {
|
|
669
|
+
_LspClientManager.instance = new _LspClientManager();
|
|
670
|
+
}
|
|
671
|
+
return _LspClientManager.instance;
|
|
672
|
+
}
|
|
673
|
+
async getClient(filePath, rootPath) {
|
|
674
|
+
const ext = extname(filePath);
|
|
675
|
+
const serverInfo = LspServerRegistry.getInstance().getServerForExtension(ext);
|
|
676
|
+
if (!serverInfo) {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
try {
|
|
680
|
+
const ready = await serverInfo.prepare();
|
|
681
|
+
if (!ready) {
|
|
682
|
+
return null;
|
|
683
|
+
}
|
|
684
|
+
} catch (e) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
const cmd = await serverInfo.getCommand(rootPath);
|
|
688
|
+
if (!cmd) {
|
|
689
|
+
return null;
|
|
690
|
+
}
|
|
691
|
+
const key = `${rootPath}:${serverInfo.id}`;
|
|
692
|
+
let client = this.clients.get(key);
|
|
693
|
+
if (!client) {
|
|
694
|
+
client = new GenericLspClient(cmd.command, cmd.args, rootPath, rootPath);
|
|
695
|
+
try {
|
|
696
|
+
await client.initialize();
|
|
697
|
+
this.clients.set(key, client);
|
|
698
|
+
} catch (error) {
|
|
699
|
+
return null;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return client;
|
|
703
|
+
}
|
|
704
|
+
async shutdownAll() {
|
|
705
|
+
for (const client of this.clients.values()) {
|
|
706
|
+
await client.shutdown();
|
|
707
|
+
}
|
|
708
|
+
this.clients.clear();
|
|
709
|
+
}
|
|
710
|
+
async workspaceSymbol(query) {
|
|
711
|
+
const results = [];
|
|
712
|
+
for (const client of this.clients.values()) {
|
|
713
|
+
try {
|
|
714
|
+
const symbols = await client.workspaceSymbol(query);
|
|
715
|
+
if (symbols && Array.isArray(symbols)) {
|
|
716
|
+
results.push(...symbols);
|
|
717
|
+
}
|
|
718
|
+
} catch (e) {
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return results;
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
export {
|
|
726
|
+
LspClientManager
|
|
727
|
+
};
|