pybao-cli 1.4.13 → 1.4.14

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 (149) hide show
  1. package/dist/REPL-4WOBYT7I.js +47 -0
  2. package/dist/{acp-AITGGIN7.js → acp-IA5SQSEN.js} +29 -29
  3. package/dist/{agentsValidate-K3GLHEUJ.js → agentsValidate-5XBOR23G.js} +7 -7
  4. package/dist/{ask-XRAJ7ONM.js → ask-64IU5XQT.js} +28 -28
  5. package/dist/{autoUpdater-2YW234FZ.js → autoUpdater-LMRJCWGC.js} +3 -3
  6. package/dist/{chunk-6OP2JTUK.js → chunk-2UTQNPK5.js} +1 -1
  7. package/dist/{chunk-6OP2JTUK.js.map → chunk-2UTQNPK5.js.map} +1 -1
  8. package/dist/{chunk-5WXWY6LV.js → chunk-346SFBDV.js} +3 -3
  9. package/dist/{chunk-CPE4NPQV.js → chunk-4E7Y6UG2.js} +2 -2
  10. package/dist/{chunk-34XEWGUY.js → chunk-5MXVXJLZ.js} +2 -1
  11. package/dist/{chunk-O5PGBSLH.js → chunk-7AYBKYWT.js} +2 -2
  12. package/dist/{chunk-XJZQD7RE.js → chunk-7JULAJHD.js} +26 -19
  13. package/dist/chunk-7JULAJHD.js.map +7 -0
  14. package/dist/{chunk-VFAFA24S.js → chunk-CWWCJY6A.js} +3 -3
  15. package/dist/{chunk-QKB32NDM.js → chunk-ENJBFL7H.js} +2 -2
  16. package/dist/{chunk-TWPWHWJT.js → chunk-EQPERVJD.js} +4 -4
  17. package/dist/{chunk-OX4Q6Z5R.js → chunk-EWJOCRNV.js} +3 -3
  18. package/dist/{chunk-M7QSGOTT.js → chunk-G5MEAIEY.js} +1 -1
  19. package/dist/{chunk-V337ZSSD.js → chunk-HMTBDCO6.js} +92 -59
  20. package/dist/chunk-HMTBDCO6.js.map +7 -0
  21. package/dist/{chunk-2PC7UK66.js → chunk-HPLN5FUH.js} +3 -3
  22. package/dist/{chunk-PHKBTCLT.js → chunk-IN2XQ6AY.js} +2 -2
  23. package/dist/{chunk-Y3UMGUVE.js → chunk-KVPLJHUD.js} +1 -1
  24. package/dist/{chunk-CVJLF2VG.js → chunk-L2W6O75K.js} +188 -52
  25. package/dist/chunk-L2W6O75K.js.map +7 -0
  26. package/dist/{chunk-FT5UM6YL.js → chunk-LN2AL7L2.js} +1 -1
  27. package/dist/{chunk-RHY3RRE6.js → chunk-MQVFTMJM.js} +2 -2
  28. package/dist/{chunk-CXT225X7.js → chunk-NQHZG7FJ.js} +2 -2
  29. package/dist/{chunk-VGDDQSCO.js → chunk-O6YOHBUT.js} +1 -1
  30. package/dist/{chunk-UDNZNXXR.js → chunk-PUHROODW.js} +3 -3
  31. package/dist/{chunk-P7MPKAPW.js → chunk-RNRRWM2A.js} +1 -1
  32. package/dist/{chunk-NG5RU74R.js → chunk-RYSI7Q7Y.js} +4 -4
  33. package/dist/{chunk-S45DDLGG.js → chunk-SLPUUK4Q.js} +3 -3
  34. package/dist/{chunk-OOTTUF6Z.js → chunk-TEOI5N7O.js} +1 -1
  35. package/dist/{chunk-HCN7LMEB.js → chunk-U3AYAKGI.js} +1 -1
  36. package/dist/{chunk-ZOM357PV.js → chunk-UNFP4H42.js} +2 -2
  37. package/dist/{chunk-CFTVDXFH.js → chunk-WTMV7L5U.js} +3 -3
  38. package/dist/{chunk-BTS2TAAW.js → chunk-XTVLEXFN.js} +4 -4
  39. package/dist/{chunk-FMH4U7NO.js → chunk-ZUDXNHIB.js} +1 -1
  40. package/dist/{cli-MXO677IA.js → cli-S5R3QHMU.js} +91 -89
  41. package/dist/{cli-MXO677IA.js.map → cli-S5R3QHMU.js.map} +2 -2
  42. package/dist/commands-3VZ7XRRF.js +51 -0
  43. package/dist/{config-YFZ2WAYP.js → config-BNXGPV5O.js} +4 -4
  44. package/dist/{context-OOIFZD5B.js → context-HBDNJQKR.js} +6 -6
  45. package/dist/{customCommands-C5UREHC4.js → customCommands-GLTGTRUH.js} +4 -4
  46. package/dist/{env-LQJ2XZDO.js → env-ROQ4BDAH.js} +2 -2
  47. package/dist/{file-ZBIAG7X4.js → file-2HXCS5WE.js} +4 -4
  48. package/dist/index.js +3 -3
  49. package/dist/{llm-RCNWJH2C.js → llm-KVE2U2V3.js} +29 -29
  50. package/dist/{llmLazy-KXJFFPMF.js → llmLazy-Q2QJ3VTS.js} +1 -1
  51. package/dist/{loader-ENRLCLHZ.js → loader-QNQFN4LE.js} +4 -4
  52. package/dist/{lsp-VWL3PVQJ.js → lsp-MOZ34TIC.js} +6 -6
  53. package/dist/{lspAnchor-WPJIG2RI.js → lspAnchor-JTT6AJVH.js} +8 -8
  54. package/dist/lspAnchor-JTT6AJVH.js.map +7 -0
  55. package/dist/{mcp-P5T4TUW2.js → mcp-A67BC77T.js} +7 -7
  56. package/dist/{mentionProcessor-4ICD3GVH.js → mentionProcessor-F3MXBMQJ.js} +5 -5
  57. package/dist/{messages-SEOXF7DS.js → messages-7VFLTKJA.js} +1 -1
  58. package/dist/{model-YOPR5KUS.js → model-RGNG5GUY.js} +5 -5
  59. package/dist/{openai-FVFZDXPS.js → openai-R7QDORCI.js} +5 -5
  60. package/dist/{outputStyles-7ZZ2JBOT.js → outputStyles-P7YDT3J6.js} +4 -4
  61. package/dist/{pluginRuntime-LASQNLIR.js → pluginRuntime-K6HWIYCH.js} +6 -6
  62. package/dist/{pluginValidation-4BABNGAC.js → pluginValidation-W3KV47BG.js} +6 -6
  63. package/dist/prompts-K4N5Y7ZD.js +53 -0
  64. package/dist/{pybAgentSessionLoad-O7V7I7CV.js → pybAgentSessionLoad-PJZM2CKJ.js} +4 -4
  65. package/dist/{pybAgentSessionResume-Q7EYAD6H.js → pybAgentSessionResume-VJ46VNTG.js} +4 -4
  66. package/dist/{pybAgentStreamJsonSession-N374RMH5.js → pybAgentStreamJsonSession-CVRLDN56.js} +1 -1
  67. package/dist/{pybHooks-MHFEMZC6.js → pybHooks-WIHUGN5B.js} +4 -4
  68. package/dist/query-ZPNOEH35.js +55 -0
  69. package/dist/{registry-KVMGHJ4N.js → registry-5DE5QZMI.js} +5 -5
  70. package/dist/{ripgrep-XSJJZ3W3.js → ripgrep-AFHAOO36.js} +3 -3
  71. package/dist/{skillMarketplace-FL7XBTHJ.js → skillMarketplace-YJU2NWPK.js} +3 -3
  72. package/dist/{state-5NJOFKYB.js → state-YENYNRDX.js} +2 -2
  73. package/dist/{theme-Z26AKEVC.js → theme-Q54BLJ2L.js} +5 -5
  74. package/dist/{toolPermissionSettings-SPSMAX5P.js → toolPermissionSettings-XEQTLKSE.js} +6 -6
  75. package/dist/tools-YK4JOXTT.js +52 -0
  76. package/dist/{userInput-3TEMRAK7.js → userInput-72LMV7AI.js} +30 -30
  77. package/package.json +1 -1
  78. package/dist/REPL-634DFL57.js +0 -47
  79. package/dist/chunk-CVJLF2VG.js.map +0 -7
  80. package/dist/chunk-V337ZSSD.js.map +0 -7
  81. package/dist/chunk-XJZQD7RE.js.map +0 -7
  82. package/dist/commands-Q5LUFGJ5.js +0 -51
  83. package/dist/lspAnchor-WPJIG2RI.js.map +0 -7
  84. package/dist/prompts-DJNSFFKV.js +0 -53
  85. package/dist/query-LAUPI7JK.js +0 -55
  86. package/dist/tools-Q44D6ZG7.js +0 -52
  87. /package/dist/{REPL-634DFL57.js.map → REPL-4WOBYT7I.js.map} +0 -0
  88. /package/dist/{acp-AITGGIN7.js.map → acp-IA5SQSEN.js.map} +0 -0
  89. /package/dist/{agentsValidate-K3GLHEUJ.js.map → agentsValidate-5XBOR23G.js.map} +0 -0
  90. /package/dist/{ask-XRAJ7ONM.js.map → ask-64IU5XQT.js.map} +0 -0
  91. /package/dist/{autoUpdater-2YW234FZ.js.map → autoUpdater-LMRJCWGC.js.map} +0 -0
  92. /package/dist/{chunk-5WXWY6LV.js.map → chunk-346SFBDV.js.map} +0 -0
  93. /package/dist/{chunk-CPE4NPQV.js.map → chunk-4E7Y6UG2.js.map} +0 -0
  94. /package/dist/{chunk-34XEWGUY.js.map → chunk-5MXVXJLZ.js.map} +0 -0
  95. /package/dist/{chunk-O5PGBSLH.js.map → chunk-7AYBKYWT.js.map} +0 -0
  96. /package/dist/{chunk-VFAFA24S.js.map → chunk-CWWCJY6A.js.map} +0 -0
  97. /package/dist/{chunk-QKB32NDM.js.map → chunk-ENJBFL7H.js.map} +0 -0
  98. /package/dist/{chunk-TWPWHWJT.js.map → chunk-EQPERVJD.js.map} +0 -0
  99. /package/dist/{chunk-OX4Q6Z5R.js.map → chunk-EWJOCRNV.js.map} +0 -0
  100. /package/dist/{chunk-M7QSGOTT.js.map → chunk-G5MEAIEY.js.map} +0 -0
  101. /package/dist/{chunk-2PC7UK66.js.map → chunk-HPLN5FUH.js.map} +0 -0
  102. /package/dist/{chunk-PHKBTCLT.js.map → chunk-IN2XQ6AY.js.map} +0 -0
  103. /package/dist/{chunk-Y3UMGUVE.js.map → chunk-KVPLJHUD.js.map} +0 -0
  104. /package/dist/{chunk-FT5UM6YL.js.map → chunk-LN2AL7L2.js.map} +0 -0
  105. /package/dist/{chunk-RHY3RRE6.js.map → chunk-MQVFTMJM.js.map} +0 -0
  106. /package/dist/{chunk-CXT225X7.js.map → chunk-NQHZG7FJ.js.map} +0 -0
  107. /package/dist/{chunk-VGDDQSCO.js.map → chunk-O6YOHBUT.js.map} +0 -0
  108. /package/dist/{chunk-UDNZNXXR.js.map → chunk-PUHROODW.js.map} +0 -0
  109. /package/dist/{chunk-P7MPKAPW.js.map → chunk-RNRRWM2A.js.map} +0 -0
  110. /package/dist/{chunk-NG5RU74R.js.map → chunk-RYSI7Q7Y.js.map} +0 -0
  111. /package/dist/{chunk-S45DDLGG.js.map → chunk-SLPUUK4Q.js.map} +0 -0
  112. /package/dist/{chunk-OOTTUF6Z.js.map → chunk-TEOI5N7O.js.map} +0 -0
  113. /package/dist/{chunk-HCN7LMEB.js.map → chunk-U3AYAKGI.js.map} +0 -0
  114. /package/dist/{chunk-ZOM357PV.js.map → chunk-UNFP4H42.js.map} +0 -0
  115. /package/dist/{chunk-CFTVDXFH.js.map → chunk-WTMV7L5U.js.map} +0 -0
  116. /package/dist/{chunk-BTS2TAAW.js.map → chunk-XTVLEXFN.js.map} +0 -0
  117. /package/dist/{chunk-FMH4U7NO.js.map → chunk-ZUDXNHIB.js.map} +0 -0
  118. /package/dist/{commands-Q5LUFGJ5.js.map → commands-3VZ7XRRF.js.map} +0 -0
  119. /package/dist/{config-YFZ2WAYP.js.map → config-BNXGPV5O.js.map} +0 -0
  120. /package/dist/{context-OOIFZD5B.js.map → context-HBDNJQKR.js.map} +0 -0
  121. /package/dist/{customCommands-C5UREHC4.js.map → customCommands-GLTGTRUH.js.map} +0 -0
  122. /package/dist/{env-LQJ2XZDO.js.map → env-ROQ4BDAH.js.map} +0 -0
  123. /package/dist/{file-ZBIAG7X4.js.map → file-2HXCS5WE.js.map} +0 -0
  124. /package/dist/{llm-RCNWJH2C.js.map → llm-KVE2U2V3.js.map} +0 -0
  125. /package/dist/{llmLazy-KXJFFPMF.js.map → llmLazy-Q2QJ3VTS.js.map} +0 -0
  126. /package/dist/{loader-ENRLCLHZ.js.map → loader-QNQFN4LE.js.map} +0 -0
  127. /package/dist/{lsp-VWL3PVQJ.js.map → lsp-MOZ34TIC.js.map} +0 -0
  128. /package/dist/{mcp-P5T4TUW2.js.map → mcp-A67BC77T.js.map} +0 -0
  129. /package/dist/{mentionProcessor-4ICD3GVH.js.map → mentionProcessor-F3MXBMQJ.js.map} +0 -0
  130. /package/dist/{messages-SEOXF7DS.js.map → messages-7VFLTKJA.js.map} +0 -0
  131. /package/dist/{model-YOPR5KUS.js.map → model-RGNG5GUY.js.map} +0 -0
  132. /package/dist/{openai-FVFZDXPS.js.map → openai-R7QDORCI.js.map} +0 -0
  133. /package/dist/{outputStyles-7ZZ2JBOT.js.map → outputStyles-P7YDT3J6.js.map} +0 -0
  134. /package/dist/{pluginRuntime-LASQNLIR.js.map → pluginRuntime-K6HWIYCH.js.map} +0 -0
  135. /package/dist/{pluginValidation-4BABNGAC.js.map → pluginValidation-W3KV47BG.js.map} +0 -0
  136. /package/dist/{prompts-DJNSFFKV.js.map → prompts-K4N5Y7ZD.js.map} +0 -0
  137. /package/dist/{pybAgentSessionLoad-O7V7I7CV.js.map → pybAgentSessionLoad-PJZM2CKJ.js.map} +0 -0
  138. /package/dist/{pybAgentSessionResume-Q7EYAD6H.js.map → pybAgentSessionResume-VJ46VNTG.js.map} +0 -0
  139. /package/dist/{pybAgentStreamJsonSession-N374RMH5.js.map → pybAgentStreamJsonSession-CVRLDN56.js.map} +0 -0
  140. /package/dist/{pybHooks-MHFEMZC6.js.map → pybHooks-WIHUGN5B.js.map} +0 -0
  141. /package/dist/{query-LAUPI7JK.js.map → query-ZPNOEH35.js.map} +0 -0
  142. /package/dist/{registry-KVMGHJ4N.js.map → registry-5DE5QZMI.js.map} +0 -0
  143. /package/dist/{ripgrep-XSJJZ3W3.js.map → ripgrep-AFHAOO36.js.map} +0 -0
  144. /package/dist/{skillMarketplace-FL7XBTHJ.js.map → skillMarketplace-YJU2NWPK.js.map} +0 -0
  145. /package/dist/{state-5NJOFKYB.js.map → state-YENYNRDX.js.map} +0 -0
  146. /package/dist/{theme-Z26AKEVC.js.map → theme-Q54BLJ2L.js.map} +0 -0
  147. /package/dist/{toolPermissionSettings-SPSMAX5P.js.map → toolPermissionSettings-XEQTLKSE.js.map} +0 -0
  148. /package/dist/{tools-Q44D6ZG7.js.map → tools-YK4JOXTT.js.map} +0 -0
  149. /package/dist/{userInput-3TEMRAK7.js.map → userInput-72LMV7AI.js.map} +0 -0
@@ -5,13 +5,13 @@ import {
5
5
  } from "./chunk-RQVLBMP7.js";
6
6
  import {
7
7
  debug
8
- } from "./chunk-VGDDQSCO.js";
8
+ } from "./chunk-O6YOHBUT.js";
9
9
  import {
10
10
  getCwd,
11
11
  getGlobalConfigFilePath,
12
12
  getLegacyGlobalConfigFilePath,
13
13
  logError
14
- } from "./chunk-P7MPKAPW.js";
14
+ } from "./chunk-RNRRWM2A.js";
15
15
 
16
16
  // src/core/config/schema.ts
17
17
  function isAutoUpdaterStatus(value) {
@@ -688,7 +688,7 @@ function setModelPointer(pointer, modelName) {
688
688
  }
689
689
  };
690
690
  saveGlobalConfig(updatedConfig);
691
- import("./model-YOPR5KUS.js").then(({ reloadModelManager }) => {
691
+ import("./model-RGNG5GUY.js").then(({ reloadModelManager }) => {
692
692
  reloadModelManager();
693
693
  });
694
694
  }
@@ -6,12 +6,12 @@ import {
6
6
  } from "./chunk-ERMQRV55.js";
7
7
  import {
8
8
  getGlobalConfig
9
- } from "./chunk-2PC7UK66.js";
9
+ } from "./chunk-HPLN5FUH.js";
10
10
  import {
11
11
  debug,
12
12
  getCurrentRequest,
13
13
  logAPIError
14
- } from "./chunk-VGDDQSCO.js";
14
+ } from "./chunk-O6YOHBUT.js";
15
15
 
16
16
  // src/services/ai/openai.ts
17
17
  import { ProxyAgent, fetch } from "undici";
@@ -5,7 +5,7 @@ import {
5
5
  getCwd,
6
6
  resolveXdgCachePath,
7
7
  resolveXdgDataPath
8
- } from "./chunk-P7MPKAPW.js";
8
+ } from "./chunk-RNRRWM2A.js";
9
9
 
10
10
  // src/services/plugins/skillMarketplace.ts
11
11
  import {
@@ -4,16 +4,16 @@ import {
4
4
  LspServerRegistry,
5
5
  findNearestRoot,
6
6
  getInstallNotices
7
- } from "./chunk-5WXWY6LV.js";
7
+ } from "./chunk-346SFBDV.js";
8
8
  import {
9
9
  levenshtein
10
10
  } from "./chunk-UZ34JEUK.js";
11
11
  import {
12
12
  debug
13
- } from "./chunk-VGDDQSCO.js";
13
+ } from "./chunk-O6YOHBUT.js";
14
14
  import {
15
15
  getCwd
16
- } from "./chunk-P7MPKAPW.js";
16
+ } from "./chunk-RNRRWM2A.js";
17
17
 
18
18
  // src/lsp/index.ts
19
19
  import { extname as extname2 } from "path";
@@ -27,6 +27,25 @@ import { createMessageConnection, StreamMessageReader, StreamMessageWriter } fro
27
27
  import { spawn } from "child_process";
28
28
  import { pathToFileURL, fileURLToPath } from "url";
29
29
  import { EventEmitter } from "events";
30
+ function resolveInitTimeoutMs() {
31
+ const override = Number.parseInt(process.env.PYB_LSP_INIT_TIMEOUT_MS ?? "", 10);
32
+ if (Number.isFinite(override) && override > 0) return override;
33
+ return 1e4;
34
+ }
35
+ function withTimeout(promise, timeoutMs, message) {
36
+ return new Promise((resolve, reject) => {
37
+ const timer = setTimeout(() => {
38
+ reject(new Error(message));
39
+ }, timeoutMs);
40
+ promise.then((result) => {
41
+ clearTimeout(timer);
42
+ resolve(result);
43
+ }).catch((error) => {
44
+ clearTimeout(timer);
45
+ reject(error);
46
+ });
47
+ });
48
+ }
30
49
  var DiagnosticsEventBus = class {
31
50
  debounceMs;
32
51
  lastEventAt = /* @__PURE__ */ new Map();
@@ -214,7 +233,12 @@ var GenericLspClient = class {
214
233
  if (this.initializationOptions && Object.keys(this.initializationOptions).length > 0) {
215
234
  params.initializationOptions = this.initializationOptions;
216
235
  }
217
- const result = await this.connection.sendRequest("initialize", params);
236
+ const timeoutMs = resolveInitTimeoutMs();
237
+ const result = await withTimeout(
238
+ this.connection.sendRequest("initialize", params),
239
+ timeoutMs,
240
+ `LSP initialize timeout after ${timeoutMs}ms`
241
+ );
218
242
  await this.connection.sendNotification("initialized", {});
219
243
  await this.connection.sendNotification("workspace/didChangeConfiguration", {
220
244
  settings: { yaml: { schemaStore: { enable: false }, schemas: {} } }
@@ -225,12 +249,20 @@ var GenericLspClient = class {
225
249
  }
226
250
  async shutdown() {
227
251
  try {
228
- await this.connection.sendRequest("shutdown");
229
- await this.connection.sendNotification("exit");
252
+ if (this.connection) {
253
+ await this.connection.sendRequest("shutdown");
254
+ await this.connection.sendNotification("exit");
255
+ }
230
256
  } catch (error) {
231
257
  }
232
- this.connection.dispose();
233
- this.process.kill();
258
+ try {
259
+ this.connection?.dispose();
260
+ } catch {
261
+ }
262
+ try {
263
+ this.process?.kill();
264
+ } catch {
265
+ }
234
266
  }
235
267
  async goToDefinition(filePath, line, character) {
236
268
  const params = {
@@ -288,12 +320,12 @@ var GenericLspClient = class {
288
320
  const params = { item };
289
321
  return this.connection.sendRequest("callHierarchy/outgoingCalls", params);
290
322
  }
291
- async didOpen(filePath, content, languageId) {
323
+ async didOpen(filePath, content, languageId, version = 1) {
292
324
  const params = {
293
325
  textDocument: {
294
326
  uri: this.normalizeUri(filePath),
295
327
  languageId,
296
- version: 1,
328
+ version,
297
329
  text: content
298
330
  }
299
331
  };
@@ -324,11 +356,8 @@ var GenericLspClient = class {
324
356
  done = true;
325
357
  });
326
358
  await this.diagnosticsBus.waitForIdle(normalizedUri, timeoutMs);
327
- if (done) {
328
- unsubscribe();
329
- } else {
330
- unsubscribe();
331
- }
359
+ unsubscribe();
360
+ return done;
332
361
  }
333
362
  on(event, handler) {
334
363
  this.diagnosticEvents.on(event, handler);
@@ -392,6 +421,7 @@ var LspClientManager = class _LspClientManager {
392
421
  requestMetrics = /* @__PURE__ */ new Map();
393
422
  compareSamples = /* @__PURE__ */ new Map();
394
423
  qualitySamples = /* @__PURE__ */ new Map();
424
+ fileVersions = /* @__PURE__ */ new Map();
395
425
  constructor() {
396
426
  }
397
427
  static getInstance() {
@@ -534,7 +564,7 @@ var LspClientManager = class _LspClientManager {
534
564
  const safeCwd = /[^\x00-\x7F]/.test(resolvedRoot) ? process.cwd() : resolvedRoot;
535
565
  let initOpts = serverInfo.initializationOptions;
536
566
  if (serverInfo.id === "pyright" || serverInfo.id === "ty") {
537
- const { detectPythonVenv } = await import("./registry-KVMGHJ4N.js");
567
+ const { detectPythonVenv } = await import("./registry-5DE5QZMI.js");
538
568
  const pythonPath = detectPythonVenv(resolvedRoot);
539
569
  if (pythonPath) {
540
570
  initOpts = { ...initOpts ?? {}, pythonPath };
@@ -572,10 +602,12 @@ var LspClientManager = class _LspClientManager {
572
602
  this.requestMetrics.clear();
573
603
  this.compareSamples.clear();
574
604
  this.qualitySamples.clear();
605
+ this.fileVersions.clear();
575
606
  }
576
607
  async workspaceSymbol(query, rootPath = getCwd(), options) {
608
+ await this.maybeEnsureWorkspaceClients(rootPath);
577
609
  if (this.clients.size === 0) {
578
- await this.maybeEnsureWorkspaceClients(rootPath);
610
+ await this.ensureWorkspaceClients(rootPath);
579
611
  }
580
612
  const results = [];
581
613
  for (const client of this.clients.values()) {
@@ -700,17 +732,18 @@ var LspClientManager = class _LspClientManager {
700
732
  return filtered;
701
733
  }
702
734
  async documentSymbol(filePath, rootPath = getCwd()) {
703
- const client = await this.getClient(filePath, rootPath);
704
- if (!client) {
705
- return null;
706
- }
707
735
  try {
708
- const content = await readFile(filePath, "utf-8");
709
- const ext = extname(filePath);
710
- const serverInfo = LspServerRegistry.getInstance().getServerForExtension(ext);
711
- const languageId = this.getLanguageId(ext, serverInfo ?? void 0);
712
- await client.didOpen(filePath, content, languageId);
713
- await client.waitForReadiness(filePath, 2e3);
736
+ const touched = await this.touchFile(filePath, rootPath, {
737
+ wait: true,
738
+ timeoutMs: 2e3
739
+ });
740
+ if (!touched) {
741
+ return null;
742
+ }
743
+ const client = await this.getClient(filePath, rootPath);
744
+ if (!client) {
745
+ return null;
746
+ }
714
747
  const symbols = await client.documentSymbol(filePath);
715
748
  return Array.isArray(symbols) ? symbols : [];
716
749
  } catch (e) {
@@ -927,9 +960,54 @@ var LspClientManager = class _LspClientManager {
927
960
  async waitForReadiness(filePath, rootPath = getCwd(), timeoutMs = 2e3) {
928
961
  const client = await this.getClientForFile(filePath);
929
962
  if (client) {
930
- await client.waitForReadiness(filePath, timeoutMs);
931
- this.readiness.set(filePath, this.now());
963
+ const ready = await client.waitForReadiness(filePath, timeoutMs);
964
+ if (ready) {
965
+ this.readiness.set(filePath, this.now());
966
+ }
967
+ return ready;
968
+ }
969
+ return false;
970
+ }
971
+ resolveServerInfoForClient(ext, client) {
972
+ const serverId = client.serverId;
973
+ const servers = LspServerRegistry.getInstance().getServersForExtension(ext);
974
+ if (serverId) {
975
+ const match = servers.find((server) => server.id === serverId);
976
+ if (match) return match;
977
+ }
978
+ return LspServerRegistry.getInstance().getServerForExtension(ext) ?? servers[0];
979
+ }
980
+ getVersionKey(filePath, client) {
981
+ const serverKey = client.serverKey ?? client.serverId ?? "unknown";
982
+ return `${serverKey}::${filePath}`;
983
+ }
984
+ async touchFile(filePath, rootPath = getCwd(), options) {
985
+ const client = await this.getClient(filePath, rootPath);
986
+ if (!client) {
987
+ return false;
932
988
  }
989
+ const content = await readFile(filePath, "utf-8");
990
+ const ext = extname(filePath);
991
+ const serverInfo = this.resolveServerInfoForClient(ext, client);
992
+ const languageId = this.getLanguageId(ext, serverInfo ?? void 0);
993
+ const versionKey = this.getVersionKey(filePath, client);
994
+ const currentVersion = this.fileVersions.get(versionKey);
995
+ const waitPromise = options?.wait ? client.waitForReadiness(filePath, options.timeoutMs ?? 2e3) : null;
996
+ if (currentVersion === void 0) {
997
+ await client.didOpen(filePath, content, languageId, 0);
998
+ this.fileVersions.set(versionKey, 0);
999
+ } else {
1000
+ const nextVersion = currentVersion + 1;
1001
+ await client.didChange(filePath, content, nextVersion);
1002
+ this.fileVersions.set(versionKey, nextVersion);
1003
+ }
1004
+ if (waitPromise) {
1005
+ const ready = await waitPromise;
1006
+ if (ready) {
1007
+ this.readiness.set(filePath, this.now());
1008
+ }
1009
+ }
1010
+ return true;
933
1011
  }
934
1012
  matchesServerFilters(filePath, serverInfo) {
935
1013
  const normalizePath = (value) => value.replace(/\\/g, "/");
@@ -2335,9 +2413,6 @@ var ScopeAnalyzer = class {
2335
2413
  };
2336
2414
 
2337
2415
  // src/lsp/index.ts
2338
- function getLanguageId(ext) {
2339
- return LspServerRegistry.getInstance().getLanguageIdForExtension(ext);
2340
- }
2341
2416
  function normalizeUri(filePath) {
2342
2417
  let uri = pathToFileURL2(filePath).href;
2343
2418
  if (process.platform === "win32") {
@@ -2551,6 +2626,10 @@ function resolveDiagnosticsTtlMs() {
2551
2626
  function buildDiagnosticsCacheKey(filePath, rootPath) {
2552
2627
  return `${rootPath}::${filePath}`;
2553
2628
  }
2629
+ function clearDiagnosticsCache(filePath, rootPath) {
2630
+ const key = buildDiagnosticsCacheKey(filePath, rootPath);
2631
+ diagnosticsCache.delete(key);
2632
+ }
2554
2633
  function recordFastPathFailure(filePath, reason, now) {
2555
2634
  let perFile = fastPathFailures.get(filePath);
2556
2635
  if (!perFile) {
@@ -2722,7 +2801,7 @@ function shouldSkipFastPath(filePath, now) {
2722
2801
  }
2723
2802
  return null;
2724
2803
  }
2725
- function withTimeout(promise, timeoutMs) {
2804
+ function withTimeout2(promise, timeoutMs) {
2726
2805
  return new Promise((resolve, reject) => {
2727
2806
  const timer = setTimeout(() => {
2728
2807
  reject(new Error("Tree-sitter timeout"));
@@ -3151,10 +3230,19 @@ var LspAPI = {
3151
3230
  recordAttempt("diagnostics");
3152
3231
  const startedAt = Date.now();
3153
3232
  if (input.waitForDiagnostics) {
3154
- await client.waitForReadiness(
3233
+ const timeoutMs = input.timeoutMs ?? 5e3;
3234
+ const ready = await client.waitForReadiness(
3155
3235
  input.filePath,
3156
- input.timeoutMs ?? 5e3
3236
+ timeoutMs
3157
3237
  );
3238
+ if (!ready) {
3239
+ recordFailure("diagnostics", "timeout");
3240
+ return {
3241
+ formatted: `Diagnostics timeout after ${timeoutMs}ms`,
3242
+ resultCount: 0,
3243
+ fileCount: 0
3244
+ };
3245
+ }
3158
3246
  }
3159
3247
  const diagnostics = client.getDiagnostics(input.filePath);
3160
3248
  recordSuccess("diagnostics", startedAt);
@@ -3331,15 +3419,12 @@ var LspAPI = {
3331
3419
  return Promise.all(inputs.map((input) => this.run(input)));
3332
3420
  },
3333
3421
  async touchFile(filePath, options = {}) {
3334
- const client = await LspClientManager.getInstance().getClientForFile(filePath);
3335
- if (!client) return false;
3336
- const content = await readFile4(filePath, "utf-8");
3337
- const languageId = getLanguageId(extname2(filePath));
3338
- await client.didOpen(filePath, content, languageId);
3339
- if (options.wait) {
3340
- await client.waitForReadiness(filePath, options.timeoutMs ?? 2e3);
3341
- }
3342
- return true;
3422
+ const rootPath = options.rootPath ?? getCwd();
3423
+ clearDiagnosticsCache(filePath, rootPath);
3424
+ return LspClientManager.getInstance().touchFile(filePath, rootPath, {
3425
+ wait: options.wait,
3426
+ timeoutMs: options.timeoutMs
3427
+ });
3343
3428
  },
3344
3429
  async diagnostics(filePath, rootPath) {
3345
3430
  const resolvedRoot = rootPath ?? getCwd();
@@ -3468,7 +3553,7 @@ var LspFacade = {
3468
3553
  }
3469
3554
  try {
3470
3555
  const start = Date.now();
3471
- const symbols = await withTimeout(
3556
+ const symbols = await withTimeout2(
3472
3557
  TreeSitterLspAdapter.getDocumentSymbols(input.filePath),
3473
3558
  getFastPathTimeoutMs(input.filePath, contentLength)
3474
3559
  );
@@ -3542,7 +3627,7 @@ var LspFacade = {
3542
3627
  }
3543
3628
  try {
3544
3629
  const start = Date.now();
3545
- const symbols = await withTimeout(
3630
+ const symbols = await withTimeout2(
3546
3631
  TreeSitterLspAdapter.getDocumentSymbols(input.filePath),
3547
3632
  getFastPathTimeoutMs(input.filePath, contentLength)
3548
3633
  );
@@ -3577,6 +3662,13 @@ var LspFacade = {
3577
3662
  }
3578
3663
  }
3579
3664
  }
3665
+ if (fallbackReason) {
3666
+ return LspAPI.run({
3667
+ operation: "documentSymbol",
3668
+ filePath: input.filePath,
3669
+ rootPath
3670
+ });
3671
+ }
3580
3672
  } else {
3581
3673
  const lang = ParserRegistry.getLanguage(input.filePath);
3582
3674
  const now = Date.now();
@@ -3604,7 +3696,7 @@ var LspFacade = {
3604
3696
  }
3605
3697
  try {
3606
3698
  const start = Date.now();
3607
- const symbols = await withTimeout(
3699
+ const symbols = await withTimeout2(
3608
3700
  TreeSitterLspAdapter.getDocumentSymbols(input.filePath),
3609
3701
  getFastPathTimeoutMs(input.filePath, contentLength)
3610
3702
  );
@@ -3684,11 +3776,49 @@ var LspFacade = {
3684
3776
  }
3685
3777
  }
3686
3778
  if (input.operation !== "workspaceSymbol") {
3687
- await LspAPI.touchFile(input.filePath, {
3688
- wait: input.operation === "diagnostics" && input.waitForDiagnostics,
3689
- timeoutMs: input.timeoutMs,
3690
- rootPath
3691
- });
3779
+ if (input.operation === "diagnostics") {
3780
+ const timeoutMs = input.timeoutMs ?? 5e3;
3781
+ const shouldWait = input.waitForDiagnostics ?? true;
3782
+ const touched = await LspAPI.touchFile(input.filePath, {
3783
+ wait: false,
3784
+ timeoutMs,
3785
+ rootPath
3786
+ });
3787
+ if (!touched) {
3788
+ return {
3789
+ formatted: `No LSP server available for file type: ${extname2(input.filePath)}`,
3790
+ resultCount: 0,
3791
+ fileCount: 0
3792
+ };
3793
+ }
3794
+ if (shouldWait) {
3795
+ const ready = await LspClientManager.getInstance().waitForReadiness(
3796
+ input.filePath,
3797
+ rootPath,
3798
+ timeoutMs
3799
+ );
3800
+ if (!ready) {
3801
+ return {
3802
+ formatted: `Diagnostics timeout after ${timeoutMs}ms`,
3803
+ resultCount: 0,
3804
+ fileCount: 0
3805
+ };
3806
+ }
3807
+ }
3808
+ } else {
3809
+ const touched = await LspAPI.touchFile(input.filePath, {
3810
+ wait: false,
3811
+ timeoutMs: input.timeoutMs,
3812
+ rootPath
3813
+ });
3814
+ if (!touched) {
3815
+ return {
3816
+ formatted: `No LSP server available for file type: ${extname2(input.filePath)}`,
3817
+ resultCount: 0,
3818
+ fileCount: 0
3819
+ };
3820
+ }
3821
+ }
3692
3822
  }
3693
3823
  if (input.operation === "workspaceSymbol") {
3694
3824
  const query = input.query ?? input.filePath;
@@ -3714,6 +3844,12 @@ var LspFacade = {
3714
3844
  async touchFile(filePath, options = {}) {
3715
3845
  return LspAPI.touchFile(filePath, options);
3716
3846
  },
3847
+ async diagnostics(filePath, options) {
3848
+ return LspAPI.diagnostics(filePath, options?.rootPath);
3849
+ },
3850
+ async documentSymbolRaw(filePath, rootPath) {
3851
+ return LspAPI.documentSymbolRaw(filePath, rootPath);
3852
+ },
3717
3853
  async diagnosticsPretty(filePath, options) {
3718
3854
  return LspAPI.diagnosticsPretty(filePath, options);
3719
3855
  },