pybao-cli 1.3.82 → 1.3.84

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.
Files changed (163) hide show
  1. package/dist/REPL-FGFUX54P.js +47 -0
  2. package/dist/{acp-O3XFSFPJ.js → acp-2L5UIDYK.js} +37 -36
  3. package/dist/{acp-O3XFSFPJ.js.map → acp-2L5UIDYK.js.map} +1 -1
  4. package/dist/{agentsValidate-34WM2XCM.js → agentsValidate-G5UPCE23.js} +7 -7
  5. package/dist/{ask-MYUN4IVZ.js → ask-NC5FHXVG.js} +32 -27
  6. package/dist/{ask-MYUN4IVZ.js.map → ask-NC5FHXVG.js.map} +1 -1
  7. package/dist/{autoUpdater-PEQ44H3V.js → autoUpdater-4RF2CRK5.js} +3 -3
  8. package/dist/blockParser-QPLEX5NJ.js +9 -0
  9. package/dist/chunk-42L6OJOC.js +1832 -0
  10. package/dist/chunk-42L6OJOC.js.map +7 -0
  11. package/dist/{chunk-QYMK62S3.js → chunk-46KUA6OA.js} +5 -5
  12. package/dist/{chunk-65GO3IGH.js → chunk-6WOCAHEK.js} +1 -1
  13. package/dist/{chunk-KEI65OPI.js → chunk-7HP3UEMN.js} +1 -1
  14. package/dist/{chunk-JHJUWFQV.js → chunk-7TIDBKNN.js} +3 -3
  15. package/dist/{chunk-BYPTXBFZ.js → chunk-7WMAUFRG.js} +1 -1
  16. package/dist/{chunk-NJGMLEE2.js → chunk-7YPF7IZE.js} +7 -5
  17. package/dist/chunk-7YPF7IZE.js.map +7 -0
  18. package/dist/{chunk-FFI3DPKT.js → chunk-C3HV2RX2.js} +3 -3
  19. package/dist/{chunk-MMW5IKPM.js → chunk-CSRNWBXQ.js} +2 -2
  20. package/dist/{chunk-W7DRY544.js → chunk-FJRJWV7O.js} +7 -7
  21. package/dist/{chunk-7LIFTANO.js → chunk-FKAYIROZ.js} +2 -2
  22. package/dist/{chunk-5OLRA5FW.js → chunk-GFKRGL22.js} +1 -1
  23. package/dist/{chunk-7NJOIESD.js → chunk-JJEJMLIT.js} +1123 -1297
  24. package/dist/chunk-JJEJMLIT.js.map +7 -0
  25. package/dist/{chunk-FXWOPSGI.js → chunk-KDKEJCIA.js} +2 -2
  26. package/dist/{chunk-ICZU7ZHE.js → chunk-KHMW5FJP.js} +1 -1
  27. package/dist/{chunk-JJS6YNOY.js → chunk-LZHKCLLB.js} +3 -3
  28. package/dist/{chunk-M4X6YU4Q.js → chunk-MN5A3I5G.js} +1 -1
  29. package/dist/{chunk-NDMC57FY.js → chunk-MUQI2KCA.js} +2 -2
  30. package/dist/chunk-NEG6NKKM.js +1834 -0
  31. package/dist/chunk-NEG6NKKM.js.map +7 -0
  32. package/dist/{chunk-IAKEZC2M.js → chunk-OVROGAUW.js} +2 -2
  33. package/dist/{chunk-X6ZT2CKW.js → chunk-PC33U2HP.js} +1 -1
  34. package/dist/{chunk-X6ZT2CKW.js.map → chunk-PC33U2HP.js.map} +1 -1
  35. package/dist/{chunk-WKHZANGM.js → chunk-PPIHT4XC.js} +5 -5
  36. package/dist/{blockParser-CFQE5IAN.js → chunk-QWIBSCDN.js} +1 -1
  37. package/dist/{blockParser-CFQE5IAN.js.map → chunk-QWIBSCDN.js.map} +1 -1
  38. package/dist/chunk-SB5WQNSQ.js +478 -0
  39. package/dist/chunk-SB5WQNSQ.js.map +7 -0
  40. package/dist/{chunk-IDDNK666.js → chunk-SOGXQEV2.js} +7 -7
  41. package/dist/{chunk-4W5GGXUO.js → chunk-TACMGUAN.js} +168 -1295
  42. package/dist/chunk-TACMGUAN.js.map +7 -0
  43. package/dist/{chunk-GDLXHK4H.js → chunk-UQHYTY5X.js} +3 -3
  44. package/dist/chunk-W2SGOL2K.js +364 -0
  45. package/dist/chunk-W2SGOL2K.js.map +7 -0
  46. package/dist/{chunk-SWH7ADMS.js → chunk-WPA4GCGG.js} +168 -1
  47. package/dist/{chunk-SWH7ADMS.js.map → chunk-WPA4GCGG.js.map} +3 -3
  48. package/dist/chunk-XI4LTVYT.js +17 -0
  49. package/dist/chunk-XI4LTVYT.js.map +7 -0
  50. package/dist/{chunk-ATBEIY6T.js → chunk-YCIGVKJU.js} +4 -4
  51. package/dist/{chunk-6CAWMG27.js → chunk-ZIEALAFY.js} +1 -1
  52. package/dist/{cli-KAPD54G7.js → cli-MWA546KO.js} +206 -91
  53. package/dist/cli-MWA546KO.js.map +7 -0
  54. package/dist/commands-JMPWEXWX.js +51 -0
  55. package/dist/{config-LWIBGRR5.js → config-JOHT6J75.js} +4 -4
  56. package/dist/{context-XYWJTZHD.js → context-CPFQPWH5.js} +5 -5
  57. package/dist/{customCommands-UCCPVYUJ.js → customCommands-K5AGAFXB.js} +4 -4
  58. package/dist/{env-6UKPD47M.js → env-CEU3W5ME.js} +6 -4
  59. package/dist/file-QZ3DYDGR.js +44 -0
  60. package/dist/index.js +3 -3
  61. package/dist/{chunk-ABDRZ5JP.js → llm-RBX2F2S4.js} +68 -32
  62. package/dist/llm-RBX2F2S4.js.map +7 -0
  63. package/dist/{llmLazy-HBGHFP3Q.js → llmLazy-BIN2DEC2.js} +1 -1
  64. package/dist/{loader-Q3P5WFSZ.js → loader-CV7OJ4NZ.js} +4 -4
  65. package/dist/lsp-QFZEUOOA.js +17 -0
  66. package/dist/{lspAnchor-33U3ZTKG.js → lspAnchor-Q2QPAITR.js} +8 -10
  67. package/dist/lspAnchor-Q2QPAITR.js.map +7 -0
  68. package/dist/{mcp-VKADXSQ2.js → mcp-JM5OIHPD.js} +7 -7
  69. package/dist/{mentionProcessor-SWHAC2DJ.js → mentionProcessor-4LMVOVGA.js} +5 -5
  70. package/dist/{messages-LDGXQV4C.js → messages-XW74FZX6.js} +1 -1
  71. package/dist/{model-4DLJMREO.js → model-RJINKACR.js} +5 -5
  72. package/dist/{openai-FLWMSEUZ.js → openai-66PYA2FX.js} +5 -5
  73. package/dist/{outputStyles-JL7UJMUL.js → outputStyles-MV6ZVKVT.js} +4 -4
  74. package/dist/{pluginRuntime-7LY7TK3X.js → pluginRuntime-BCOVUPBE.js} +6 -6
  75. package/dist/{pluginValidation-7TTJ6I5O.js → pluginValidation-3E6ZTNSH.js} +6 -6
  76. package/dist/prompts-CQXW5O3Z.js +53 -0
  77. package/dist/{pybAgentSessionLoad-HAR3FX4I.js → pybAgentSessionLoad-CKCBOT52.js} +4 -4
  78. package/dist/{pybAgentSessionResume-RA5BAD3Q.js → pybAgentSessionResume-LDUO3VEW.js} +4 -4
  79. package/dist/{pybAgentStreamJsonSession-MGHBFT3O.js → pybAgentStreamJsonSession-5XVEA5BE.js} +1 -1
  80. package/dist/{pybHooks-6QPME7U4.js → pybHooks-JTBESPF6.js} +4 -4
  81. package/dist/query-Z3URPE24.js +55 -0
  82. package/dist/registry-2K7ZNIJX.js +47 -0
  83. package/dist/{ripgrep-FXFBKT6W.js → ripgrep-RJWD3Z7N.js} +3 -3
  84. package/dist/{skillMarketplace-P3UJST5T.js → skillMarketplace-ZDWIN663.js} +3 -3
  85. package/dist/{state-6G53IACA.js → state-XOHPGE2O.js} +2 -2
  86. package/dist/{theme-UO6R6URW.js → theme-B672GYQW.js} +5 -5
  87. package/dist/{toolPermissionSettings-5TLUJA2W.js → toolPermissionSettings-IGFHXHH7.js} +6 -6
  88. package/dist/toolPermissionSettings-IGFHXHH7.js.map +7 -0
  89. package/dist/tools-4SXRMJGJ.js +52 -0
  90. package/dist/tools-4SXRMJGJ.js.map +7 -0
  91. package/dist/{userInput-4SHS43CB.js → userInput-6CV2RY5H.js} +34 -29
  92. package/dist/{userInput-4SHS43CB.js.map → userInput-6CV2RY5H.js.map} +1 -1
  93. package/package.json +1 -1
  94. package/dist/REPL-J3CTO7X2.js +0 -42
  95. package/dist/chunk-4PBAKIJH.js +0 -929
  96. package/dist/chunk-4PBAKIJH.js.map +0 -7
  97. package/dist/chunk-4W5GGXUO.js.map +0 -7
  98. package/dist/chunk-64PUI3X4.js +0 -249
  99. package/dist/chunk-64PUI3X4.js.map +0 -7
  100. package/dist/chunk-7NJOIESD.js.map +0 -7
  101. package/dist/chunk-ABDRZ5JP.js.map +0 -7
  102. package/dist/chunk-NJGMLEE2.js.map +0 -7
  103. package/dist/cli-KAPD54G7.js.map +0 -7
  104. package/dist/commands-EJMKWNRT.js +0 -46
  105. package/dist/llm-SAUON7O4.js +0 -80
  106. package/dist/lspAnchor-33U3ZTKG.js.map +0 -7
  107. package/dist/manager-V2FHM2EQ.js +0 -13
  108. package/dist/prompts-7NZHNDRN.js +0 -48
  109. package/dist/query-UZM2IIQL.js +0 -50
  110. package/dist/tools-WFRZC3LT.js +0 -51
  111. /package/dist/{REPL-J3CTO7X2.js.map → REPL-FGFUX54P.js.map} +0 -0
  112. /package/dist/{agentsValidate-34WM2XCM.js.map → agentsValidate-G5UPCE23.js.map} +0 -0
  113. /package/dist/{autoUpdater-PEQ44H3V.js.map → autoUpdater-4RF2CRK5.js.map} +0 -0
  114. /package/dist/{commands-EJMKWNRT.js.map → blockParser-QPLEX5NJ.js.map} +0 -0
  115. /package/dist/{chunk-QYMK62S3.js.map → chunk-46KUA6OA.js.map} +0 -0
  116. /package/dist/{chunk-65GO3IGH.js.map → chunk-6WOCAHEK.js.map} +0 -0
  117. /package/dist/{chunk-KEI65OPI.js.map → chunk-7HP3UEMN.js.map} +0 -0
  118. /package/dist/{chunk-JHJUWFQV.js.map → chunk-7TIDBKNN.js.map} +0 -0
  119. /package/dist/{chunk-BYPTXBFZ.js.map → chunk-7WMAUFRG.js.map} +0 -0
  120. /package/dist/{chunk-FFI3DPKT.js.map → chunk-C3HV2RX2.js.map} +0 -0
  121. /package/dist/{chunk-MMW5IKPM.js.map → chunk-CSRNWBXQ.js.map} +0 -0
  122. /package/dist/{chunk-W7DRY544.js.map → chunk-FJRJWV7O.js.map} +0 -0
  123. /package/dist/{chunk-7LIFTANO.js.map → chunk-FKAYIROZ.js.map} +0 -0
  124. /package/dist/{chunk-5OLRA5FW.js.map → chunk-GFKRGL22.js.map} +0 -0
  125. /package/dist/{chunk-FXWOPSGI.js.map → chunk-KDKEJCIA.js.map} +0 -0
  126. /package/dist/{chunk-ICZU7ZHE.js.map → chunk-KHMW5FJP.js.map} +0 -0
  127. /package/dist/{chunk-JJS6YNOY.js.map → chunk-LZHKCLLB.js.map} +0 -0
  128. /package/dist/{chunk-M4X6YU4Q.js.map → chunk-MN5A3I5G.js.map} +0 -0
  129. /package/dist/{chunk-NDMC57FY.js.map → chunk-MUQI2KCA.js.map} +0 -0
  130. /package/dist/{chunk-IAKEZC2M.js.map → chunk-OVROGAUW.js.map} +0 -0
  131. /package/dist/{chunk-WKHZANGM.js.map → chunk-PPIHT4XC.js.map} +0 -0
  132. /package/dist/{chunk-IDDNK666.js.map → chunk-SOGXQEV2.js.map} +0 -0
  133. /package/dist/{chunk-GDLXHK4H.js.map → chunk-UQHYTY5X.js.map} +0 -0
  134. /package/dist/{chunk-ATBEIY6T.js.map → chunk-YCIGVKJU.js.map} +0 -0
  135. /package/dist/{chunk-6CAWMG27.js.map → chunk-ZIEALAFY.js.map} +0 -0
  136. /package/dist/{config-LWIBGRR5.js.map → commands-JMPWEXWX.js.map} +0 -0
  137. /package/dist/{context-XYWJTZHD.js.map → config-JOHT6J75.js.map} +0 -0
  138. /package/dist/{customCommands-UCCPVYUJ.js.map → context-CPFQPWH5.js.map} +0 -0
  139. /package/dist/{env-6UKPD47M.js.map → customCommands-K5AGAFXB.js.map} +0 -0
  140. /package/dist/{llm-SAUON7O4.js.map → env-CEU3W5ME.js.map} +0 -0
  141. /package/dist/{llmLazy-HBGHFP3Q.js.map → file-QZ3DYDGR.js.map} +0 -0
  142. /package/dist/{loader-Q3P5WFSZ.js.map → llmLazy-BIN2DEC2.js.map} +0 -0
  143. /package/dist/{manager-V2FHM2EQ.js.map → loader-CV7OJ4NZ.js.map} +0 -0
  144. /package/dist/{mcp-VKADXSQ2.js.map → lsp-QFZEUOOA.js.map} +0 -0
  145. /package/dist/{messages-LDGXQV4C.js.map → mcp-JM5OIHPD.js.map} +0 -0
  146. /package/dist/{mentionProcessor-SWHAC2DJ.js.map → mentionProcessor-4LMVOVGA.js.map} +0 -0
  147. /package/dist/{model-4DLJMREO.js.map → messages-XW74FZX6.js.map} +0 -0
  148. /package/dist/{openai-FLWMSEUZ.js.map → model-RJINKACR.js.map} +0 -0
  149. /package/dist/{outputStyles-JL7UJMUL.js.map → openai-66PYA2FX.js.map} +0 -0
  150. /package/dist/{pluginValidation-7TTJ6I5O.js.map → outputStyles-MV6ZVKVT.js.map} +0 -0
  151. /package/dist/{pluginRuntime-7LY7TK3X.js.map → pluginRuntime-BCOVUPBE.js.map} +0 -0
  152. /package/dist/{prompts-7NZHNDRN.js.map → pluginValidation-3E6ZTNSH.js.map} +0 -0
  153. /package/dist/{pybAgentSessionLoad-HAR3FX4I.js.map → prompts-CQXW5O3Z.js.map} +0 -0
  154. /package/dist/{pybAgentSessionResume-RA5BAD3Q.js.map → pybAgentSessionLoad-CKCBOT52.js.map} +0 -0
  155. /package/dist/{pybHooks-6QPME7U4.js.map → pybAgentSessionResume-LDUO3VEW.js.map} +0 -0
  156. /package/dist/{pybAgentStreamJsonSession-MGHBFT3O.js.map → pybAgentStreamJsonSession-5XVEA5BE.js.map} +0 -0
  157. /package/dist/{query-UZM2IIQL.js.map → pybHooks-JTBESPF6.js.map} +0 -0
  158. /package/dist/{ripgrep-FXFBKT6W.js.map → query-Z3URPE24.js.map} +0 -0
  159. /package/dist/{skillMarketplace-P3UJST5T.js.map → registry-2K7ZNIJX.js.map} +0 -0
  160. /package/dist/{state-6G53IACA.js.map → ripgrep-RJWD3Z7N.js.map} +0 -0
  161. /package/dist/{theme-UO6R6URW.js.map → skillMarketplace-ZDWIN663.js.map} +0 -0
  162. /package/dist/{toolPermissionSettings-5TLUJA2W.js.map → state-XOHPGE2O.js.map} +0 -0
  163. /package/dist/{tools-WFRZC3LT.js.map → theme-B672GYQW.js.map} +0 -0
@@ -1,929 +0,0 @@
1
- import { createRequire as __pybCreateRequire } from "node:module";
2
- const require = __pybCreateRequire(import.meta.url);
3
- import {
4
- levenshtein
5
- } from "./chunk-UZ34JEUK.js";
6
- import {
7
- debug
8
- } from "./chunk-M4X6YU4Q.js";
9
- import {
10
- getCwd
11
- } from "./chunk-SWH7ADMS.js";
12
- import {
13
- __require
14
- } from "./chunk-I3J4JYES.js";
15
-
16
- // src/tools/search/LspTool/client/generic.ts
17
- import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
18
- import { spawn } from "child_process";
19
- import { pathToFileURL, fileURLToPath } from "url";
20
- import { EventEmitter } from "events";
21
- var GenericLspClient = class {
22
- constructor(serverCommand, serverArgs, cwd, rootPath) {
23
- this.rootPath = rootPath;
24
- const env = {
25
- ...process.env,
26
- // Remove potentially conflicting variables
27
- NODE_OPTIONS: void 0,
28
- TS_NODE_PROJECT: void 0,
29
- ELECTRON_RUN_AS_NODE: void 0
30
- };
31
- const options = {
32
- cwd,
33
- stdio: "pipe",
34
- env,
35
- shell: false
36
- };
37
- this.process = spawn(serverCommand, serverArgs, options);
38
- this.process.stderr.on("data", (data) => {
39
- console.error(`[LSP Stderr] ${data}`);
40
- });
41
- this.connection = createMessageConnection(
42
- new StreamMessageReader(this.process.stdout),
43
- new StreamMessageWriter(this.process.stdin)
44
- );
45
- this.connection.onNotification((method, params) => {
46
- if (method === "window/logMessage" || method === "$/progress") {
47
- console.log(`[LSP Notification] ${method}:`, JSON.stringify(params));
48
- }
49
- if (method === "textDocument/publishDiagnostics") {
50
- try {
51
- const uri = params.uri;
52
- let filePath = uri;
53
- if (uri.startsWith("file://")) {
54
- filePath = fileURLToPath(uri);
55
- }
56
- const normalizedUri = this.normalizeUri(filePath);
57
- this.diagnosticsMap.set(normalizedUri, params.diagnostics);
58
- this.diagnosticEvents.emit("diagnostics", { uri, filePath, diagnostics: params.diagnostics });
59
- } catch (e) {
60
- console.error("[LSP] Error processing diagnostics:", e);
61
- }
62
- }
63
- });
64
- this.connection.onRequest((method, params) => {
65
- if (method === "workspace/configuration") {
66
- return Array.isArray(params.items) ? params.items.map(() => ({})) : [];
67
- }
68
- if (method === "client/registerCapability") {
69
- return null;
70
- }
71
- return null;
72
- });
73
- this.connection.listen();
74
- }
75
- connection;
76
- process;
77
- capabilities;
78
- diagnosticEvents = new EventEmitter();
79
- diagnosticsMap = /* @__PURE__ */ new Map();
80
- normalizeUri(filePath) {
81
- let uri = pathToFileURL(filePath).href;
82
- if (process.platform === "win32") {
83
- uri = uri.replace(/^file:\/\/\/([a-zA-Z]):\//, (match, drive) => {
84
- return `file:///${drive.toLowerCase()}%3A/`;
85
- });
86
- }
87
- return uri;
88
- }
89
- async initialize() {
90
- const rootUri = this.normalizeUri(this.rootPath);
91
- console.log("[GenericLspClient] Initializing with normalized rootUri:", rootUri);
92
- const params = {
93
- processId: process.pid,
94
- rootUri,
95
- capabilities: {
96
- textDocument: {
97
- synchronization: {
98
- didOpen: true,
99
- didChange: true,
100
- willSave: false,
101
- willSaveWaitUntil: false,
102
- didSave: true
103
- },
104
- hover: {
105
- contentFormat: ["markdown", "plaintext"]
106
- },
107
- definition: {},
108
- references: {}
109
- },
110
- workspace: {
111
- workspaceFolders: true
112
- }
113
- },
114
- workspaceFolders: [
115
- {
116
- name: "workspace",
117
- uri: this.normalizeUri(this.rootPath)
118
- }
119
- ]
120
- };
121
- const result = await this.connection.sendRequest("initialize", params);
122
- await this.connection.sendNotification("initialized", {});
123
- await this.connection.sendNotification("workspace/didChangeConfiguration", { settings: {} });
124
- await new Promise((resolve) => setTimeout(resolve, 100));
125
- this.capabilities = result.capabilities;
126
- return result;
127
- }
128
- async shutdown() {
129
- try {
130
- await this.connection.sendRequest("shutdown");
131
- await this.connection.sendNotification("exit");
132
- } catch (error) {
133
- }
134
- this.connection.dispose();
135
- this.process.kill();
136
- }
137
- async goToDefinition(filePath, line, character) {
138
- const params = {
139
- textDocument: { uri: this.normalizeUri(filePath) },
140
- position: { line: line - 1, character: character - 1 }
141
- };
142
- return this.connection.sendRequest("textDocument/definition", params);
143
- }
144
- async findReferences(filePath, line, character) {
145
- const params = {
146
- textDocument: { uri: this.normalizeUri(filePath) },
147
- position: { line: line - 1, character: character - 1 },
148
- context: { includeDeclaration: true }
149
- };
150
- return this.connection.sendRequest("textDocument/references", params);
151
- }
152
- async hover(filePath, line, character) {
153
- const params = {
154
- textDocument: { uri: this.normalizeUri(filePath) },
155
- position: { line: line - 1, character: character - 1 }
156
- };
157
- return this.connection.sendRequest("textDocument/hover", params);
158
- }
159
- async documentSymbol(filePath) {
160
- const params = {
161
- textDocument: { uri: this.normalizeUri(filePath) }
162
- };
163
- return this.connection.sendRequest("textDocument/documentSymbol", params);
164
- }
165
- async workspaceSymbol(query) {
166
- const params = {
167
- query
168
- };
169
- return this.connection.sendRequest("workspace/symbol", params);
170
- }
171
- async goToImplementation(filePath, line, character) {
172
- const params = {
173
- textDocument: { uri: this.normalizeUri(filePath) },
174
- position: { line: line - 1, character: character - 1 }
175
- };
176
- return this.connection.sendRequest("textDocument/implementation", params);
177
- }
178
- async didOpen(filePath, content, languageId) {
179
- const params = {
180
- textDocument: {
181
- uri: this.normalizeUri(filePath),
182
- languageId,
183
- version: 1,
184
- text: content
185
- }
186
- };
187
- await this.connection.sendNotification("textDocument/didOpen", params);
188
- }
189
- async didChange(filePath, content, version) {
190
- const params = {
191
- textDocument: {
192
- uri: this.normalizeUri(filePath),
193
- version
194
- },
195
- contentChanges: [{ text: content }]
196
- };
197
- await this.connection.sendNotification("textDocument/didChange", params);
198
- }
199
- async didClose(filePath) {
200
- const params = {
201
- textDocument: {
202
- uri: this.normalizeUri(filePath)
203
- }
204
- };
205
- await this.connection.sendNotification("textDocument/didClose", params);
206
- }
207
- async waitForReadiness(filePath, timeoutMs = 3e3) {
208
- const normalizedUri = this.normalizeUri(filePath);
209
- return new Promise((resolve) => {
210
- let debounceTimer;
211
- let timeoutTimer;
212
- const cleanup = () => {
213
- if (debounceTimer) clearTimeout(debounceTimer);
214
- clearTimeout(timeoutTimer);
215
- this.diagnosticEvents.off("diagnostics", handler);
216
- };
217
- const handler = (event) => {
218
- if (event.uri === normalizedUri || event.uri.toLowerCase() === normalizedUri.toLowerCase() || decodeURIComponent(event.uri) === decodeURIComponent(normalizedUri)) {
219
- if (debounceTimer) clearTimeout(debounceTimer);
220
- debounceTimer = setTimeout(() => {
221
- cleanup();
222
- resolve();
223
- }, 150);
224
- }
225
- };
226
- this.diagnosticEvents.on("diagnostics", handler);
227
- timeoutTimer = setTimeout(() => {
228
- cleanup();
229
- resolve();
230
- }, timeoutMs);
231
- });
232
- }
233
- getDiagnostics(filePath) {
234
- return this.diagnosticsMap.get(this.normalizeUri(filePath)) || [];
235
- }
236
- };
237
-
238
- // src/tools/search/LspTool/client/manager.ts
239
- import { extname, join as join2, dirname as dirname2 } from "path";
240
-
241
- // src/tools/search/LspTool/registry.ts
242
- import { join, dirname } from "path";
243
- import { fileURLToPath as fileURLToPath2 } from "url";
244
- import { existsSync } from "fs";
245
- import { spawnSync } from "child_process";
246
- var __filename = fileURLToPath2(import.meta.url);
247
- var __dirname = dirname(__filename);
248
- var BaseLspServer = class {
249
- isInPath(cmd) {
250
- try {
251
- const where = process.platform === "win32" ? "where" : "which";
252
- const result = spawnSync(where, [cmd], { encoding: "utf8" });
253
- return result.status === 0;
254
- } catch {
255
- return false;
256
- }
257
- }
258
- getLocalBinPath(binName, npmPackageName) {
259
- const exts = process.platform === "win32" ? [".cmd", ".exe", ".ps1", ""] : [""];
260
- const localNodeModulesBin = join(process.cwd(), "node_modules", ".bin");
261
- for (const ext of exts) {
262
- const localBinPath = join(localNodeModulesBin, `${binName}${ext}`);
263
- if (existsSync(localBinPath)) {
264
- return localBinPath;
265
- }
266
- }
267
- try {
268
- const pkgName = npmPackageName || binName;
269
- const pkgEntry = __require.resolve(pkgName, { paths: [process.cwd(), __dirname] });
270
- let current = pkgEntry;
271
- let pkgRoot = "";
272
- for (let i = 0; i < 5; i++) {
273
- current = join(current, "..");
274
- if (existsSync(join(current, "package.json"))) {
275
- pkgRoot = current;
276
- break;
277
- }
278
- }
279
- if (pkgRoot) {
280
- const nodeModulesRoot = join(pkgRoot, "..");
281
- for (const ext of exts) {
282
- const potentialBin = join(nodeModulesRoot, ".bin", `${binName}${ext}`);
283
- if (existsSync(potentialBin)) {
284
- return potentialBin;
285
- }
286
- }
287
- }
288
- } catch (e) {
289
- }
290
- return "";
291
- }
292
- };
293
- var GenericNpmServer = class extends BaseLspServer {
294
- id;
295
- extensions;
296
- rootMarkers;
297
- npmPackage;
298
- binName;
299
- args;
300
- constructor(id, extensions, rootMarkers, npmPackage, binName, args) {
301
- super();
302
- this.id = id;
303
- this.extensions = extensions;
304
- this.rootMarkers = rootMarkers;
305
- this.npmPackage = npmPackage;
306
- this.binName = binName;
307
- this.args = args;
308
- }
309
- async prepare() {
310
- if (this.isInPath(this.binName)) {
311
- return true;
312
- }
313
- const localBin = this.getLocalBinPath(this.binName, this.npmPackage);
314
- if (existsSync(localBin)) {
315
- return true;
316
- }
317
- return false;
318
- }
319
- async getCommand(rootPath) {
320
- if (process.platform === "win32") {
321
- try {
322
- const pkgJsonPath = __require.resolve(`${this.npmPackage}/package.json`, { paths: [process.cwd(), __dirname] });
323
- const pkgJson = __require(pkgJsonPath);
324
- let binScript = "";
325
- if (typeof pkgJson.bin === "string") {
326
- binScript = pkgJson.bin;
327
- } else if (typeof pkgJson.bin === "object" && pkgJson.bin[this.binName]) {
328
- binScript = pkgJson.bin[this.binName];
329
- }
330
- if (binScript) {
331
- if (this.npmPackage === "pyright" && binScript.endsWith("langserver.index.js")) {
332
- const distScript = join(dirname(pkgJsonPath), "dist", "pyright-langserver.js");
333
- if (existsSync(distScript)) {
334
- return { command: process.execPath, args: [distScript, ...this.args] };
335
- }
336
- }
337
- const scriptPath = join(dirname(pkgJsonPath), binScript);
338
- if (existsSync(scriptPath)) {
339
- return { command: process.execPath, args: [scriptPath, ...this.args] };
340
- }
341
- }
342
- } catch (e) {
343
- }
344
- }
345
- if (this.isInPath(this.binName)) {
346
- return { command: this.binName, args: this.args };
347
- }
348
- const localBin = this.getLocalBinPath(this.binName, this.npmPackage);
349
- if (existsSync(localBin)) {
350
- return { command: localBin, args: this.args };
351
- }
352
- return null;
353
- }
354
- };
355
- var GenericBinaryServer = class extends BaseLspServer {
356
- id;
357
- extensions;
358
- rootMarkers;
359
- binNames;
360
- args;
361
- constructor(id, extensions, rootMarkers, binNames, args) {
362
- super();
363
- this.id = id;
364
- this.extensions = extensions;
365
- this.rootMarkers = rootMarkers;
366
- this.binNames = Array.isArray(binNames) ? binNames : [binNames];
367
- this.args = args;
368
- }
369
- async prepare() {
370
- return this.binNames.some((bin) => this.isInPath(bin));
371
- }
372
- async getCommand(rootPath) {
373
- for (const bin of this.binNames) {
374
- if (this.isInPath(bin)) {
375
- return { command: bin, args: this.args };
376
- }
377
- }
378
- return null;
379
- }
380
- };
381
- var GoplsServer = class extends BaseLspServer {
382
- id = "gopls";
383
- extensions = [".go", ".mod"];
384
- rootMarkers = ["go.mod", "go.work", ".git"];
385
- async prepare() {
386
- if (this.isInPath("gopls")) {
387
- return true;
388
- }
389
- if (!this.isInPath("go")) {
390
- debug.error("LSP_MISSING_DEP", { server: this.id, error: "go command not found" });
391
- return false;
392
- }
393
- return this.installGo();
394
- }
395
- async getCommand(rootPath) {
396
- if (this.isInPath("gopls")) {
397
- return { command: "gopls", args: ["serve"] };
398
- }
399
- return null;
400
- }
401
- async installGo() {
402
- try {
403
- debug.info("LSP_INSTALL", { server: this.id, action: "start" });
404
- const result = spawnSync("go", ["install", "golang.org/x/tools/gopls@latest"], {
405
- encoding: "utf8"
406
- });
407
- if (result.status !== 0) {
408
- debug.error("LSP_INSTALL_FAILED", { server: this.id, error: result.stderr });
409
- return false;
410
- }
411
- if (!this.isInPath("gopls")) {
412
- 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." });
413
- }
414
- debug.info("LSP_INSTALL", { server: this.id, action: "success" });
415
- return true;
416
- } catch (e) {
417
- debug.error("LSP_INSTALL_ERROR", { server: this.id, error: String(e) });
418
- return false;
419
- }
420
- }
421
- };
422
- var RustAnalyzerServer = class extends BaseLspServer {
423
- id = "rust-analyzer";
424
- extensions = [".rs"];
425
- rootMarkers = ["Cargo.toml", "rust-project.json", ".git"];
426
- async prepare() {
427
- if (this.isInPath("rust-analyzer")) {
428
- return true;
429
- }
430
- if (this.isInPath("rustup")) {
431
- return this.installRustup();
432
- }
433
- debug.warn("LSP_MISSING_DEP", { server: this.id, message: "rust-analyzer not found and rustup not available. Please install rust-analyzer manually." });
434
- return false;
435
- }
436
- async getCommand(rootPath) {
437
- if (this.isInPath("rust-analyzer")) {
438
- return { command: "rust-analyzer", args: [] };
439
- }
440
- return null;
441
- }
442
- async installRustup() {
443
- try {
444
- debug.info("LSP_INSTALL", { server: this.id, action: "start" });
445
- const result = spawnSync("rustup", ["component", "add", "rust-analyzer"], {
446
- encoding: "utf8"
447
- });
448
- if (result.status !== 0) {
449
- debug.error("LSP_INSTALL_FAILED", { server: this.id, error: result.stderr });
450
- return false;
451
- }
452
- debug.info("LSP_INSTALL", { server: this.id, action: "success" });
453
- return true;
454
- } catch (e) {
455
- debug.error("LSP_INSTALL_ERROR", { server: this.id, error: String(e) });
456
- return false;
457
- }
458
- }
459
- };
460
- var LspServerRegistry = class _LspServerRegistry {
461
- static instance;
462
- servers = [];
463
- constructor() {
464
- this.register(new GenericNpmServer(
465
- "pyright",
466
- [".py", ".pyi"],
467
- ["pyrightconfig.json", "pyproject.toml", "setup.py", "requirements.txt", "Pipfile"],
468
- "pyright",
469
- "pyright-langserver",
470
- ["--stdio"]
471
- ));
472
- this.register(new GoplsServer());
473
- this.register(new RustAnalyzerServer());
474
- this.register(new GenericNpmServer(
475
- "bash-language-server",
476
- [".sh", ".bash", ".zsh"],
477
- [".git"],
478
- "bash-language-server",
479
- "bash-language-server",
480
- ["start"]
481
- ));
482
- this.register(new GenericNpmServer(
483
- "typescript-language-server",
484
- [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"],
485
- ["tsconfig.json", "package.json", "jsconfig.json"],
486
- "typescript-language-server",
487
- "typescript-language-server",
488
- ["--stdio"]
489
- ));
490
- this.register(new GenericNpmServer(
491
- "yaml-language-server",
492
- [".yaml", ".yml"],
493
- [],
494
- "yaml-language-server",
495
- "yaml-language-server",
496
- ["--stdio"]
497
- ));
498
- this.register(new GenericNpmServer(
499
- "dockerfile-language-server",
500
- ["Dockerfile", ".dockerfile"],
501
- [],
502
- "dockerfile-language-server-nodejs",
503
- "docker-langserver",
504
- ["--stdio"]
505
- ));
506
- this.register(new GenericNpmServer(
507
- "vue-language-server",
508
- [".vue"],
509
- ["package.json"],
510
- "@vue/language-server",
511
- "vue-language-server",
512
- ["--stdio"]
513
- ));
514
- this.register(new GenericNpmServer(
515
- "html-language-server",
516
- [".html", ".htm"],
517
- [],
518
- "vscode-langservers-extracted",
519
- "vscode-html-language-server",
520
- ["--stdio"]
521
- ));
522
- this.register(new GenericNpmServer(
523
- "css-language-server",
524
- [".css", ".scss", ".less"],
525
- [],
526
- "vscode-langservers-extracted",
527
- "vscode-css-language-server",
528
- ["--stdio"]
529
- ));
530
- this.register(new GenericNpmServer(
531
- "json-language-server",
532
- [".json", ".jsonc"],
533
- [],
534
- "vscode-langservers-extracted",
535
- "vscode-json-language-server",
536
- ["--stdio"]
537
- ));
538
- this.register(new GenericNpmServer(
539
- "intelephense",
540
- [".php"],
541
- ["composer.json"],
542
- "intelephense",
543
- "intelephense",
544
- ["--stdio"]
545
- ));
546
- this.register(new GenericNpmServer(
547
- "svelte-language-server",
548
- [".svelte"],
549
- ["package.json"],
550
- "svelte-language-server",
551
- "svelte-language-server",
552
- ["--stdio"]
553
- ));
554
- this.register(new GenericNpmServer(
555
- "astro-ls",
556
- [".astro"],
557
- ["package.json"],
558
- "@astrojs/language-server",
559
- "astro-ls",
560
- ["--stdio"]
561
- ));
562
- this.register(new GenericNpmServer(
563
- "prisma-language-server",
564
- [".prisma"],
565
- ["schema.prisma"],
566
- "@prisma/language-server",
567
- "prisma-language-server",
568
- ["--stdio"]
569
- ));
570
- this.register(new GenericNpmServer(
571
- "graphql-lsp",
572
- [".graphql", ".gql"],
573
- [".graphqlrc", "graphql.config.js"],
574
- "graphql-language-service-cli",
575
- "graphql-lsp",
576
- ["server", "-m", "stream"]
577
- ));
578
- this.register(new GenericBinaryServer(
579
- "jdtls",
580
- [".java"],
581
- ["pom.xml", "build.gradle"],
582
- "jdtls",
583
- []
584
- ));
585
- this.register(new GenericBinaryServer(
586
- "clangd",
587
- [".c", ".cpp", ".h", ".hpp", ".cc"],
588
- ["compile_commands.json", ".clang-format"],
589
- "clangd",
590
- ["--stdio"]
591
- ));
592
- this.register(new GenericBinaryServer(
593
- "ruby-lsp",
594
- [".rb", ".rake"],
595
- ["Gemfile", ".ruby-version"],
596
- "ruby-lsp",
597
- ["--stdio"]
598
- ));
599
- this.register(new GenericBinaryServer(
600
- "lua-language-server",
601
- [".lua"],
602
- [".luarc.json"],
603
- ["lua-ls", "lua-language-server"],
604
- []
605
- ));
606
- this.register(new GenericBinaryServer(
607
- "terraform-ls",
608
- [".tf", ".tfvars"],
609
- [],
610
- "terraform-ls",
611
- ["serve"]
612
- ));
613
- this.register(new GenericBinaryServer(
614
- "kotlin-language-server",
615
- [".kt", ".kts"],
616
- ["build.gradle.kts"],
617
- ["kotlin-ls", "kotlin-language-server"],
618
- []
619
- ));
620
- this.register(new GenericBinaryServer(
621
- "elixir-ls",
622
- [".ex", ".exs"],
623
- ["mix.exs"],
624
- ["elixir-ls", "language_server.sh"],
625
- []
626
- ));
627
- this.register(new GenericBinaryServer(
628
- "zls",
629
- [".zig"],
630
- ["build.zig"],
631
- "zls",
632
- []
633
- ));
634
- this.register(new GenericBinaryServer(
635
- "csharp-ls",
636
- [".cs"],
637
- [".csproj", ".sln"],
638
- "csharp-ls",
639
- []
640
- ));
641
- this.register(new GenericBinaryServer(
642
- "fsautocomplete",
643
- [".fs", ".fsi", ".fsx"],
644
- [".fsproj", ".sln"],
645
- "fsautocomplete",
646
- ["--background-service-enabled"]
647
- ));
648
- this.register(new GenericBinaryServer(
649
- "sourcekit-lsp",
650
- [".swift"],
651
- ["Package.swift"],
652
- "sourcekit-lsp",
653
- []
654
- ));
655
- this.register(new GenericBinaryServer(
656
- "dart",
657
- [".dart"],
658
- ["pubspec.yaml"],
659
- "dart",
660
- ["language-server"]
661
- ));
662
- this.register(new GenericBinaryServer(
663
- "ocamllsp",
664
- [".ml", ".mli"],
665
- ["dune-project"],
666
- ["ocaml-lsp", "ocamllsp"],
667
- []
668
- ));
669
- this.register(new GenericBinaryServer(
670
- "gleam",
671
- [".gleam"],
672
- ["gleam.toml"],
673
- "gleam",
674
- ["lsp"]
675
- ));
676
- this.register(new GenericBinaryServer(
677
- "clojure-lsp",
678
- [".clj", ".cljs", ".cljc", ".edn"],
679
- ["deps.edn", "project.clj"],
680
- "clojure-lsp",
681
- []
682
- ));
683
- this.register(new GenericBinaryServer(
684
- "nixd",
685
- [".nix"],
686
- ["flake.nix"],
687
- "nixd",
688
- []
689
- ));
690
- this.register(new GenericBinaryServer(
691
- "tinymist",
692
- [".typ"],
693
- [],
694
- "tinymist",
695
- []
696
- ));
697
- this.register(new GenericBinaryServer(
698
- "metals",
699
- [".scala", ".sbt", ".sc"],
700
- ["build.sbt"],
701
- "metals",
702
- []
703
- ));
704
- this.register(new GenericBinaryServer(
705
- "haskell-language-server",
706
- [".hs", ".lhs"],
707
- ["stack.yaml", "cabal.project", "*.cabal"],
708
- "haskell-language-server-wrapper",
709
- ["--lsp"]
710
- ));
711
- this.register(new GenericBinaryServer(
712
- "texlab",
713
- [".tex", ".bib"],
714
- [],
715
- "texlab",
716
- []
717
- ));
718
- }
719
- static getInstance() {
720
- if (!_LspServerRegistry.instance) {
721
- _LspServerRegistry.instance = new _LspServerRegistry();
722
- }
723
- return _LspServerRegistry.instance;
724
- }
725
- register(server) {
726
- this.servers.push(server);
727
- }
728
- getServerForExtension(ext) {
729
- return this.servers.find((s) => s.extensions.includes(ext)) || null;
730
- }
731
- };
732
-
733
- // src/tools/search/LspTool/client/manager.ts
734
- import { readdir, readFile } from "fs/promises";
735
- import { existsSync as existsSync2 } from "fs";
736
- var LspClientManager = class _LspClientManager {
737
- static instance;
738
- clients = /* @__PURE__ */ new Map();
739
- constructor() {
740
- }
741
- static getInstance() {
742
- if (!_LspClientManager.instance) {
743
- _LspClientManager.instance = new _LspClientManager();
744
- }
745
- return _LspClientManager.instance;
746
- }
747
- getLanguageId(ext) {
748
- const map = {
749
- ".ts": "typescript",
750
- ".tsx": "typescriptreact",
751
- ".js": "javascript",
752
- ".jsx": "javascriptreact",
753
- ".py": "python",
754
- ".java": "java",
755
- ".cs": "csharp",
756
- ".cpp": "cpp",
757
- ".c": "c",
758
- ".rs": "rust",
759
- ".go": "go"
760
- };
761
- return map[ext] || "plaintext";
762
- }
763
- async ensureWorkspaceClients(rootPath) {
764
- try {
765
- const files = await readdir(rootPath, { withFileTypes: true });
766
- const extensionMap = /* @__PURE__ */ new Map();
767
- const fileNames = new Set(files.map((f) => f.name));
768
- if (fileNames.has("tsconfig.json") || fileNames.has("package.json")) {
769
- if (!files.some((f) => f.isFile() && /\.(ts|tsx|js|jsx)$/.test(f.name))) {
770
- try {
771
- const srcFiles = await readdir(join2(rootPath, "src"), { withFileTypes: true });
772
- const triggerFile = srcFiles.find((f) => f.isFile() && /\.(ts|tsx|js|jsx)$/.test(f.name));
773
- if (triggerFile) {
774
- extensionMap.set(extname(triggerFile.name), join2(rootPath, "src", triggerFile.name));
775
- }
776
- } catch (e) {
777
- }
778
- }
779
- }
780
- if (fileNames.has("go.mod")) {
781
- extensionMap.set(".go", join2(rootPath, "go.mod"));
782
- if (fileNames.has("main.go")) extensionMap.set(".go", join2(rootPath, "main.go"));
783
- }
784
- if (fileNames.has("Cargo.toml")) {
785
- try {
786
- if (existsSync2(join2(rootPath, "src", "main.rs"))) extensionMap.set(".rs", join2(rootPath, "src", "main.rs"));
787
- else if (existsSync2(join2(rootPath, "src", "lib.rs"))) extensionMap.set(".rs", join2(rootPath, "src", "lib.rs"));
788
- } catch (e) {
789
- }
790
- }
791
- for (const file of files) {
792
- if (file.isFile()) {
793
- const ext = extname(file.name);
794
- if (ext && !extensionMap.has(ext)) {
795
- extensionMap.set(ext, join2(rootPath, file.name));
796
- }
797
- }
798
- }
799
- for (const [ext, realPath] of extensionMap) {
800
- const client = await this.getClient(realPath, rootPath);
801
- if (client) {
802
- try {
803
- const content = await readFile(realPath, "utf-8");
804
- await client.didOpen(realPath, content, this.getLanguageId(ext));
805
- await client.waitForReadiness(realPath, 2e3);
806
- } catch (e) {
807
- }
808
- } else {
809
- }
810
- }
811
- } catch (e) {
812
- }
813
- }
814
- async getClientForFile(filePath) {
815
- const rootPath = this.findProjectRoot(filePath);
816
- return this.getClient(filePath, rootPath);
817
- }
818
- findProjectRoot(filePath) {
819
- const cwd = getCwd();
820
- if (filePath.startsWith(cwd)) {
821
- return cwd;
822
- }
823
- return dirname2(filePath);
824
- }
825
- async getClient(filePath, rootPath = getCwd()) {
826
- const ext = extname(filePath);
827
- const serverInfo = LspServerRegistry.getInstance().getServerForExtension(ext);
828
- if (!serverInfo) {
829
- return null;
830
- }
831
- try {
832
- const ready = await serverInfo.prepare();
833
- if (!ready) {
834
- return null;
835
- }
836
- } catch (e) {
837
- return null;
838
- }
839
- const cmd = await serverInfo.getCommand(rootPath);
840
- if (!cmd) {
841
- return null;
842
- }
843
- const key = `${rootPath}:${serverInfo.id}`;
844
- let client = this.clients.get(key);
845
- if (!client) {
846
- client = new GenericLspClient(cmd.command, cmd.args, rootPath, rootPath);
847
- try {
848
- await client.initialize();
849
- this.clients.set(key, client);
850
- } catch (error) {
851
- return null;
852
- }
853
- }
854
- return client;
855
- }
856
- async shutdownAll() {
857
- for (const client of this.clients.values()) {
858
- await client.shutdown();
859
- }
860
- this.clients.clear();
861
- }
862
- async workspaceSymbol(query, rootPath = getCwd()) {
863
- if (this.clients.size === 0) {
864
- await this.ensureWorkspaceClients(rootPath);
865
- }
866
- const results = [];
867
- for (const client of this.clients.values()) {
868
- try {
869
- const symbols = await client.workspaceSymbol(query);
870
- if (symbols && Array.isArray(symbols)) {
871
- results.push(...symbols);
872
- }
873
- } catch (e) {
874
- }
875
- }
876
- if (results.length === 0 && query.length > 0) {
877
- for (const client of this.clients.values()) {
878
- try {
879
- const broadSymbols = await client.workspaceSymbol("");
880
- if (broadSymbols && Array.isArray(broadSymbols)) {
881
- for (const sym of broadSymbols) {
882
- const dist = levenshtein(query, sym.name);
883
- if (dist <= 2 || dist <= query.length * 0.3) {
884
- results.push(sym);
885
- }
886
- }
887
- }
888
- } catch (e) {
889
- }
890
- }
891
- }
892
- return results;
893
- }
894
- async documentSymbol(filePath, rootPath = getCwd()) {
895
- const client = await this.getClient(filePath, rootPath);
896
- if (!client) {
897
- return null;
898
- }
899
- try {
900
- const content = await readFile(filePath, "utf-8");
901
- const languageId = this.getLanguageId(extname(filePath));
902
- await client.didOpen(filePath, content, languageId);
903
- await client.waitForReadiness(filePath, 2e3);
904
- const symbols = await client.documentSymbol(filePath);
905
- return symbols || [];
906
- } catch (e) {
907
- console.error(`Failed to get document symbols for ${filePath}:`, e);
908
- return null;
909
- }
910
- }
911
- async getDiagnostics(filePath, rootPath = getCwd()) {
912
- const client = await this.getClient(filePath, rootPath);
913
- if (!client) {
914
- return [];
915
- }
916
- return client.getDiagnostics(filePath);
917
- }
918
- // New helper to expose waitForReadiness to clients who only have a manager
919
- async waitForReadiness(filePath, rootPath = getCwd(), timeoutMs = 2e3) {
920
- const client = await this.getClientForFile(filePath);
921
- if (client) {
922
- await client.waitForReadiness(filePath, timeoutMs);
923
- }
924
- }
925
- };
926
-
927
- export {
928
- LspClientManager
929
- };