pi-lens 4.4.6 → 4.4.8

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 (174) hide show
  1. package/CHANGELOG.md +232 -0
  2. package/README.md +17 -3
  3. package/config/markdownlint/run-no-fix.mjs +36 -0
  4. package/dist/{chunk-ZQ6NZZTB.js → chunk-2453RRJ2.js} +44 -6
  5. package/dist/{chunk-GZE7WOI4.js → chunk-2BKUFQKR.js} +696 -330
  6. package/dist/chunk-2TS4GLOJ.js +31 -0
  7. package/dist/{chunk-2DMLM3ZO.js → chunk-2ZE3AUJQ.js} +12 -14
  8. package/dist/{chunk-OJLTLYHB.js → chunk-35WKJWO5.js} +51 -33
  9. package/dist/chunk-3JAHQBSY.js +27 -0
  10. package/dist/{chunk-PO45POGF.js → chunk-3O5EII3W.js} +2 -2
  11. package/dist/chunk-447YZL4S.js +25 -0
  12. package/dist/{chunk-TIYGSODX.js → chunk-4B2YFN4U.js} +28 -22
  13. package/dist/{chunk-OSTKYB55.js → chunk-4BKU7PV3.js} +1 -1
  14. package/dist/{chunk-XQCSWV2G.js → chunk-4LL2VRNY.js} +27 -28
  15. package/dist/{chunk-MA77RSFN.js → chunk-4NBWFYWW.js} +9 -9
  16. package/dist/{chunk-75SY4F24.js → chunk-4QG55RRC.js} +12 -12
  17. package/dist/{chunk-K2YGBXOA.js → chunk-4W52ZKZX.js} +2 -2
  18. package/dist/{chunk-Z2XAOKHK.js → chunk-565VRUP4.js} +2 -2
  19. package/dist/{chunk-CFRQMBGP.js → chunk-57X2CDRX.js} +23 -23
  20. package/dist/{chunk-XAIT2YGS.js → chunk-5F3XF3SX.js} +7 -15
  21. package/dist/{chunk-UHGF5UT5.js → chunk-5RNB4HVK.js} +1 -1
  22. package/dist/{chunk-Q4EMRFNA.js → chunk-5T5A6YAJ.js} +35 -34
  23. package/dist/{chunk-W5LGKNET.js → chunk-6FIRFP6A.js} +12 -12
  24. package/dist/{chunk-KLQVC3XC.js → chunk-6GMGEKQN.js} +36 -9
  25. package/dist/{chunk-UN4TEBWN.js → chunk-6LJOJ6EO.js} +20 -15
  26. package/dist/{chunk-HK6JVFZC.js → chunk-6YUNI7B5.js} +3 -3
  27. package/dist/{chunk-PKES3ISE.js → chunk-7ANZ7XDD.js} +2 -2
  28. package/dist/{chunk-VQH24FIP.js → chunk-7CGIDRIK.js} +16 -15
  29. package/dist/{chunk-SCIUNBPF.js → chunk-7MAD5ZAY.js} +16 -17
  30. package/dist/{chunk-OOU2WZZE.js → chunk-7TNILKGY.js} +1 -1
  31. package/dist/{chunk-LEJOJDXL.js → chunk-A5GRLYPZ.js} +9 -9
  32. package/dist/{chunk-AE37FEGH.js → chunk-AGGUWKRK.js} +1 -1
  33. package/dist/{chunk-BWYQUPOS.js → chunk-BBET6HD6.js} +1 -1
  34. package/dist/{chunk-GAACZY6R.js → chunk-BHWW6FAX.js} +14 -13
  35. package/dist/{chunk-A3YNG5KP.js → chunk-BOPDQ7AZ.js} +23 -21
  36. package/dist/{chunk-MKVZQUEG.js → chunk-BQG2QFVO.js} +215 -134
  37. package/dist/{chunk-EVDGNG4F.js → chunk-BUZIQDFS.js} +3 -3
  38. package/dist/{chunk-2PHMIAKO.js → chunk-CM73PPGD.js} +4 -4
  39. package/dist/{chunk-63RIVFQI.js → chunk-CUDD35TW.js} +10 -9
  40. package/dist/{chunk-BM5GS6ZH.js → chunk-CZL44WFN.js} +2 -2
  41. package/dist/{chunk-QGSTQH4D.js → chunk-DIWK3LBC.js} +12 -15
  42. package/dist/{chunk-JL6CXUMW.js → chunk-DYRZGUMA.js} +2 -2
  43. package/dist/{chunk-NDMCVUYK.js → chunk-FHEV6T4L.js} +22 -18
  44. package/dist/{chunk-4PCQCU47.js → chunk-FRLAUP2B.js} +4 -4
  45. package/dist/{chunk-RZOXUSPC.js → chunk-G5GV2Q7K.js} +2 -2
  46. package/dist/{chunk-2RLWJO5K.js → chunk-G6JKM4O7.js} +7 -7
  47. package/dist/chunk-GGYOZWHW.js +27 -0
  48. package/dist/{chunk-DC4CFXM5.js → chunk-GIRBSBGL.js} +6 -5
  49. package/dist/{chunk-PQJFG24Z.js → chunk-GMROJJRN.js} +1292 -946
  50. package/dist/{chunk-ZUUI3ZSA.js → chunk-HHR7WGCI.js} +3 -3
  51. package/dist/{chunk-TIQJPRDD.js → chunk-HKIL6DCL.js} +3 -2
  52. package/dist/{chunk-VPBIMOAQ.js → chunk-HUAM7QG3.js} +15 -13
  53. package/dist/{chunk-ZYNI26MI.js → chunk-HXFUTMX2.js} +2 -2
  54. package/dist/{chunk-W5R5SABV.js → chunk-I22THIHI.js} +12 -12
  55. package/dist/chunk-IE5D3RA5.js +58 -0
  56. package/dist/{chunk-MT6BVNFW.js → chunk-IYVYZQRL.js} +10 -16
  57. package/dist/{chunk-ARD426WI.js → chunk-JBP7KESM.js} +1 -1
  58. package/dist/{chunk-MN7MHUXQ.js → chunk-JE6HKLC7.js} +2 -2
  59. package/dist/{chunk-3MYEA7QD.js → chunk-JPRDTY5S.js} +85 -3
  60. package/dist/{chunk-CJYKEW2L.js → chunk-JYLOYTZD.js} +17 -1
  61. package/dist/{chunk-5APMQ2IJ.js → chunk-JZRP4DGP.js} +2 -2
  62. package/dist/{chunk-AMXIUN2R.js → chunk-KZ4ALBCH.js} +2 -2
  63. package/dist/{chunk-W2V54OCL.js → chunk-L3CLUGDY.js} +3 -3
  64. package/dist/{chunk-DMSLNKF7.js → chunk-L4NEVZ4T.js} +28 -27
  65. package/dist/chunk-LPYTPNOJ.js +22 -0
  66. package/dist/{chunk-BI5LAQ3Y.js → chunk-LSFXZLPW.js} +2071 -1725
  67. package/dist/{chunk-2DDDCJDL.js → chunk-MC6VB2E5.js} +4 -4
  68. package/dist/{chunk-U2SDMG7C.js → chunk-NM2NWH55.js} +5 -5
  69. package/dist/{chunk-Q4FCYCRE.js → chunk-NSPVR3FN.js} +19 -18
  70. package/dist/{chunk-VG5JS5SW.js → chunk-O2ARHQKF.js} +2 -2
  71. package/dist/{chunk-KSR7RGQY.js → chunk-O4N5BQ3T.js} +10 -10
  72. package/dist/{chunk-5ZR3APIM.js → chunk-OC7VWJBZ.js} +39 -40
  73. package/dist/chunk-OFNMHPBT.js +89 -0
  74. package/dist/{chunk-YSBHPOY6.js → chunk-OWTG6UMO.js} +21 -21
  75. package/dist/{chunk-7RQXA5GG.js → chunk-OY7WZI7Q.js} +13 -12
  76. package/dist/{chunk-5CV5ITZF.js → chunk-OZWXLJMX.js} +2 -2
  77. package/dist/{chunk-F6X3YJWD.js → chunk-PIQQM32Y.js} +2 -2
  78. package/dist/chunk-PKLB2XJL.js +8 -0
  79. package/dist/{chunk-DQXSPYRI.js → chunk-PKSUMEPT.js} +17 -4
  80. package/dist/{chunk-YISME6ON.js → chunk-PPKECBPP.js} +1 -1
  81. package/dist/{chunk-4AVZ3TG7.js → chunk-R2QQC33W.js} +14 -14
  82. package/dist/{chunk-GMTFDAOK.js → chunk-R4QWJQ2H.js} +11 -11
  83. package/dist/{chunk-V63BC55Q.js → chunk-RGGH6M34.js} +1 -1
  84. package/dist/{chunk-SJJYRZB4.js → chunk-RZG472YW.js} +116 -26
  85. package/dist/{chunk-NIU2IPC5.js → chunk-SDFKOLSF.js} +6 -6
  86. package/dist/{chunk-H7HTEQUZ.js → chunk-SFLHSL5R.js} +9 -9
  87. package/dist/{chunk-FA5LDARD.js → chunk-SP4TFY5F.js} +14 -13
  88. package/dist/{chunk-J6JP25XU.js → chunk-SQC7K3SP.js} +4 -3
  89. package/dist/{chunk-T7FTXGS3.js → chunk-T2S3FNNJ.js} +44 -42
  90. package/dist/{chunk-S67UJDGQ.js → chunk-TV6RXRYH.js} +10 -10
  91. package/dist/{chunk-GNSIWBAT.js → chunk-U3AS2FR6.js} +3 -3
  92. package/dist/{chunk-WIZWZR4C.js → chunk-UHHLR2VY.js} +43 -41
  93. package/dist/chunk-UYXV5NIS.js +20 -0
  94. package/dist/{chunk-VSFLRN5Y.js → chunk-VLQ7UKZH.js} +1 -1
  95. package/dist/{chunk-FFL3A2VP.js → chunk-VN3L2JWZ.js} +46 -72
  96. package/dist/{chunk-Z7IGUAXL.js → chunk-VOP4PJKA.js} +12 -8
  97. package/dist/{chunk-F5Z6URKM.js → chunk-VOXTCULR.js} +2 -2
  98. package/dist/{chunk-NNKXDXXS.js → chunk-VPLBLWFO.js} +14 -8
  99. package/dist/chunk-W3BGKBBK.js +27 -0
  100. package/dist/{chunk-ZKXQKGWZ.js → chunk-WC6WRNQT.js} +4 -3
  101. package/dist/{chunk-Q3UZHW6N.js → chunk-WMDUT4KH.js} +1150 -1138
  102. package/dist/{chunk-KXF5R4UN.js → chunk-WQV6BI4Q.js} +1 -1
  103. package/dist/chunk-WXUDRAG6.js +24 -0
  104. package/dist/{chunk-OLAWH5UQ.js → chunk-X35S7HSB.js} +29 -10
  105. package/dist/{chunk-YBSONGSZ.js → chunk-X66YJ2SS.js} +40 -34
  106. package/dist/{chunk-U6OC3QEM.js → chunk-XOMGO63G.js} +22 -21
  107. package/dist/{chunk-WQOIR3QY.js → chunk-XWIME22V.js} +13 -13
  108. package/dist/{chunk-3WEPUD2V.js → chunk-XYLC35E4.js} +202 -103
  109. package/dist/{chunk-UCGQT677.js → chunk-YHGYAEFH.js} +18 -18
  110. package/dist/{chunk-V3APN3DY.js → chunk-ZFORSIED.js} +13 -13
  111. package/dist/{chunk-BHUWL2Y3.js → chunk-ZKLTNLAW.js} +64 -73
  112. package/dist/chunk-ZONZ6YY3.js +74 -0
  113. package/dist/chunk-ZSM35JF4.js +30 -0
  114. package/dist/{chunk-PPIBVH4R.js → chunk-ZZDIOAAJ.js} +15 -6
  115. package/dist/index.js +8817 -6239
  116. package/dist/mcp/analyze-cli.js +10 -10
  117. package/dist/mcp/cli.js +44 -42
  118. package/dist/mcp/server.js +2236 -861
  119. package/dist/mcp/worker.js +62 -61
  120. package/dist/probes/installer.js +20 -19
  121. package/docs/adr/0003-git-guard-latch-writer.md +11 -6
  122. package/docs/agent-tools.md +29 -11
  123. package/docs/alignment-families.md +29 -0
  124. package/docs/ast-grep_rules_catalog.md +6 -4
  125. package/docs/ci-bot-pr-checks.md +126 -0
  126. package/docs/configuration.md +99 -3
  127. package/docs/defect-shapes.md +68 -11
  128. package/docs/dependencies.md +1 -0
  129. package/docs/engineering-principles.md +27 -2
  130. package/docs/environment-variables.md +14 -0
  131. package/docs/features.md +13 -3
  132. package/docs/globalconfig.md +12 -1
  133. package/docs/invariants/git-guard-host.md +38 -0
  134. package/docs/invariants/language-config.md +15 -4
  135. package/docs/invariants/lsp-trust-exec.md +22 -2
  136. package/docs/invariants/paths-os.md +4 -2
  137. package/docs/invariants/session-telemetry.md +42 -2
  138. package/docs/lsp-capability-matrix.md +208 -84
  139. package/docs/lsp-idle-eviction.md +3 -5
  140. package/docs/merge-queue-rollout.md +1 -1
  141. package/docs/pi-lens-fixer.md +31 -17
  142. package/docs/pi-lens-merge-policy.md +27 -15
  143. package/docs/pi-lens-monitor.md +9 -0
  144. package/docs/pi-lens-orchestration.md +4 -1
  145. package/docs/pi-lens-reviewer.md +5 -5
  146. package/docs/pi-lens-subagent.md +13 -7
  147. package/docs/public-api-stability.md +18 -2
  148. package/docs/schema/pi-lens-config-v1.json +33 -0
  149. package/docs/servercapabilities.md +1 -1
  150. package/docs/settings.md +15 -6
  151. package/docs/usage.md +5 -0
  152. package/docs/word-index.md +17 -5
  153. package/package.json +5 -3
  154. package/rules/ast-grep-rules/rule-tests/no-accumulating-spread-js-test.yml +37 -0
  155. package/rules/ast-grep-rules/rule-tests/ts-redundant-filter-map-test.yml +12 -1
  156. package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-js-test.yml +12 -0
  157. package/rules/ast-grep-rules/rule-tests-disabled/filter-then-map-test.yml +25 -0
  158. package/rules/ast-grep-rules/rules/no-accumulating-spread-js.yml +49 -1
  159. package/rules/ast-grep-rules/rules/ts-redundant-filter-map.yml +9 -1
  160. package/rules/ast-grep-rules/rules-disabled/filter-then-map-js.yml +17 -0
  161. package/rules/ast-grep-rules/rules-disabled/filter-then-map.yml +36 -0
  162. package/rules/ast-grep-rules/self-scan-baseline.json +1 -1
  163. package/dist/chunk-2F47TQOA.js +0 -73
  164. package/dist/chunk-2X4VLOCC.js +0 -55
  165. package/dist/chunk-4WX4CTUE.js +0 -57
  166. package/dist/chunk-FJIVKLPH.js +0 -31
  167. package/dist/chunk-G2B7F6ZU.js +0 -88
  168. package/dist/chunk-GTAI2J6U.js +0 -27
  169. package/dist/chunk-IPDG45G5.js +0 -26
  170. package/dist/chunk-P4QNXS6I.js +0 -27
  171. package/dist/chunk-Q6D6VMI4.js +0 -22
  172. package/dist/chunk-SXGD4ANG.js +0 -25
  173. package/dist/chunk-XCUHKYCQ.js +0 -23
  174. package/dist/chunk-YRD4ISED.js +0 -30
@@ -7,7 +7,7 @@ import {
7
7
  normalizeMessage,
8
8
  sanitizeCorrelationId,
9
9
  stableFindingId
10
- } from "./chunk-DC4CFXM5.js";
10
+ } from "./chunk-GIRBSBGL.js";
11
11
  import {
12
12
  mapWithConcurrency
13
13
  } from "./chunk-XIMYZ3JA.js";
@@ -38,24 +38,24 @@ import {
38
38
  resolveLspServerCwd,
39
39
  serverTraits,
40
40
  withLspProjectCodePermission
41
- } from "./chunk-3WEPUD2V.js";
41
+ } from "./chunk-XYLC35E4.js";
42
42
  import {
43
43
  findLocalOpengrepConfig
44
- } from "./chunk-JL6CXUMW.js";
44
+ } from "./chunk-DYRZGUMA.js";
45
45
  import {
46
46
  emitBounded
47
- } from "./chunk-NDMCVUYK.js";
47
+ } from "./chunk-FHEV6T4L.js";
48
48
  import {
49
49
  loadProjectSnapshot,
50
50
  readJsonCache
51
- } from "./chunk-PPIBVH4R.js";
51
+ } from "./chunk-ZZDIOAAJ.js";
52
52
  import {
53
53
  acquireWorkspaceSweepHold,
54
54
  configureLspServiceLifecycle,
55
55
  getOwnedLspService,
56
56
  peekOwnedLspService,
57
57
  resetOwnedLspService
58
- } from "./chunk-F5Z6URKM.js";
58
+ } from "./chunk-VOXTCULR.js";
59
59
  import {
60
60
  collectForwardImportMtimes,
61
61
  exceedsLspSyncLimits,
@@ -69,44 +69,46 @@ import {
69
69
  lineTextAt,
70
70
  pathBirthtimeMs,
71
71
  scanDocumentContent
72
- } from "./chunk-OJLTLYHB.js";
72
+ } from "./chunk-35WKJWO5.js";
73
73
  import {
74
74
  js_yaml_default
75
- } from "./chunk-TIQJPRDD.js";
75
+ } from "./chunk-HKIL6DCL.js";
76
76
  import {
77
77
  EXTENSION_TO_LSP_ID,
78
78
  lspLanguageId,
79
79
  resolveFilenameLanguage
80
- } from "./chunk-YISME6ON.js";
80
+ } from "./chunk-PPKECBPP.js";
81
81
  import {
82
82
  HOOK_WALL_BUDGET_MS
83
83
  } from "./chunk-CKEQFGLT.js";
84
84
  import {
85
85
  bounded,
86
+ untilAborted,
86
87
  withDeadline,
87
88
  withTimeout
88
- } from "./chunk-CJYKEW2L.js";
89
+ } from "./chunk-JYLOYTZD.js";
89
90
  import {
90
91
  diagnosticsIpcPathForCwd,
91
92
  requestWarmCodeActions,
92
93
  requestWarmDiagnostics
93
- } from "./chunk-BM5GS6ZH.js";
94
+ } from "./chunk-CZL44WFN.js";
94
95
  import {
95
96
  CONTENT_HASH_MAX_BYTES,
96
97
  hashContentBytes,
97
- hashFileBytes
98
- } from "./chunk-NNKXDXXS.js";
98
+ hashFileBytes,
99
+ stampContentBytes
100
+ } from "./chunk-VPLBLWFO.js";
99
101
  import {
100
102
  findLocalZizmorConfig,
101
103
  logSessionStart
102
- } from "./chunk-MKVZQUEG.js";
104
+ } from "./chunk-BQG2QFVO.js";
103
105
  import {
104
106
  findLocalBinUpwards,
105
107
  isProjectLocalBinPath
106
- } from "./chunk-Z7IGUAXL.js";
108
+ } from "./chunk-VOP4PJKA.js";
107
109
  import {
108
110
  getLspCapableKinds
109
- } from "./chunk-NIU2IPC5.js";
111
+ } from "./chunk-SDFKOLSF.js";
110
112
  import {
111
113
  createGenerationMap,
112
114
  createGenerationSource,
@@ -123,35 +125,36 @@ import {
123
125
  releaseOwnChildPid,
124
126
  removeLspChild,
125
127
  sampleProcessTreeCpuPercent,
126
- selectLivePeerInstances
127
- } from "./chunk-Q3UZHW6N.js";
128
+ selectLivePeerInstances,
129
+ windowsExe
130
+ } from "./chunk-WMDUT4KH.js";
128
131
  import {
129
132
  createSingleFlight
130
133
  } from "./chunk-AWQWXSW4.js";
131
134
  import {
132
135
  SPECIAL_FILENAMES,
133
136
  getLanguageId
134
- } from "./chunk-RZOXUSPC.js";
137
+ } from "./chunk-G5GV2Q7K.js";
135
138
  import {
136
139
  PathKeyedMap,
137
140
  detectFileRole
138
- } from "./chunk-OLAWH5UQ.js";
141
+ } from "./chunk-X35S7HSB.js";
139
142
  import {
140
143
  assertInstallAllowed,
141
144
  isLspSpawnAllowedByTrust,
142
145
  projectTrustDenialReason,
143
146
  writeFileAtomic
144
- } from "./chunk-MN7MHUXQ.js";
147
+ } from "./chunk-JE6HKLC7.js";
145
148
  import {
146
149
  compareOrdinal,
147
150
  incrementDegradationCount,
148
151
  recordDegradation,
149
152
  recordDegradationOnce,
150
153
  truncateForLedger
151
- } from "./chunk-ZQ6NZZTB.js";
154
+ } from "./chunk-2453RRJ2.js";
152
155
  import {
153
156
  logExtension
154
- } from "./chunk-KXF5R4UN.js";
157
+ } from "./chunk-WQV6BI4Q.js";
155
158
  import {
156
159
  freshnessFromMtime
157
160
  } from "./chunk-S26LC76R.js";
@@ -159,7 +162,7 @@ import {
159
162
  logLatency,
160
163
  phaseFinished,
161
164
  phaseStarted
162
- } from "./chunk-Z2XAOKHK.js";
165
+ } from "./chunk-565VRUP4.js";
163
166
  import {
164
167
  createNdjsonLogger,
165
168
  getGlobalPiLensLogDir,
@@ -167,7 +170,7 @@ import {
167
170
  getProcessSingleton,
168
171
  isTestMode,
169
172
  nextModuleEvaluationOrdinal
170
- } from "./chunk-VSFLRN5Y.js";
173
+ } from "./chunk-VLQ7UKZH.js";
171
174
  import {
172
175
  BoundedFifoMap,
173
176
  BoundedLruCache,
@@ -175,18 +178,22 @@ import {
175
178
  isAtOrAboveHomeDir,
176
179
  isUnderDir,
177
180
  isWindowsPath,
181
+ isWithinForm,
178
182
  kernelPathIdentityAsync,
179
183
  minimatch,
180
184
  normalizeEphemeralMapKey,
181
185
  normalizeFilePath,
182
186
  normalizeMapKey,
183
187
  pathsEqual,
188
+ realpathOrResolve,
184
189
  realpathOrResolveAsync,
190
+ relativeInside,
185
191
  toPosix,
186
192
  toProjectRelativePath,
187
193
  uriToDiskPath,
188
- uriToPath
189
- } from "./chunk-PQJFG24Z.js";
194
+ uriToPath,
195
+ walkUpDirs
196
+ } from "./chunk-GMROJJRN.js";
190
197
  import {
191
198
  __commonJS,
192
199
  __require,
@@ -1409,8 +1416,8 @@ var require_semaphore = __commonJS({
1409
1416
  this._waiting = [];
1410
1417
  }
1411
1418
  lock(thunk) {
1412
- return new Promise((resolve8, reject) => {
1413
- this._waiting.push({ thunk, resolve: resolve8, reject });
1419
+ return new Promise((resolve7, reject) => {
1420
+ this._waiting.push({ thunk, resolve: resolve7, reject });
1414
1421
  this.runNext();
1415
1422
  });
1416
1423
  }
@@ -3036,9 +3043,9 @@ ${JSON.stringify(message, null, 4)}`);
3036
3043
  if (typeof cancellationStrategy.sender.enableCancellation === "function") {
3037
3044
  cancellationStrategy.sender.enableCancellation(requestMessage);
3038
3045
  }
3039
- return new Promise(async (resolve8, reject) => {
3046
+ return new Promise(async (resolve7, reject) => {
3040
3047
  const resolveWithCleanup = (r) => {
3041
- resolve8(r);
3048
+ resolve7(r);
3042
3049
  cancellationStrategy.sender.cleanup(id);
3043
3050
  disposable?.dispose();
3044
3051
  };
@@ -3467,10 +3474,10 @@ var require_ril = __commonJS({
3467
3474
  return api_1.Disposable.create(() => this.stream.off("end", listener));
3468
3475
  }
3469
3476
  write(data, encoding) {
3470
- return new Promise((resolve8, reject) => {
3477
+ return new Promise((resolve7, reject) => {
3471
3478
  const callback = (error) => {
3472
3479
  if (error === void 0 || error === null) {
3473
- resolve8();
3480
+ resolve7();
3474
3481
  } else {
3475
3482
  reject(error);
3476
3483
  }
@@ -3607,7 +3614,7 @@ var require_main = __commonJS({
3607
3614
  var ril_1 = __importDefault(require_ril());
3608
3615
  ril_1.default.install();
3609
3616
  var path18 = __importStar(__require("path"));
3610
- var os2 = __importStar(__require("os"));
3617
+ var os3 = __importStar(__require("os"));
3611
3618
  var fs14 = __importStar(__require("fs"));
3612
3619
  var crypto_1 = __require("crypto");
3613
3620
  var net_1 = __require("net");
@@ -3749,7 +3756,7 @@ var require_main = __commonJS({
3749
3756
  }
3750
3757
  let randomLength = 32;
3751
3758
  const fixedLength = "/lsp-.sock".length;
3752
- const tmpDir = fs14.realpathSync(XDG_RUNTIME_DIR ?? os2.tmpdir());
3759
+ const tmpDir = fs14.realpathSync(XDG_RUNTIME_DIR ?? os3.tmpdir());
3753
3760
  const limit = safeIpcPathLengths.get(process.platform);
3754
3761
  if (limit !== void 0) {
3755
3762
  randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
@@ -3762,10 +3769,10 @@ var require_main = __commonJS({
3762
3769
  }
3763
3770
  function createClientPipeTransport(pipeName, encoding = "utf-8") {
3764
3771
  let connectResolve;
3765
- const connected = new Promise((resolve8, _reject) => {
3766
- connectResolve = resolve8;
3772
+ const connected = new Promise((resolve7, _reject) => {
3773
+ connectResolve = resolve7;
3767
3774
  });
3768
- return new Promise((resolve8, reject) => {
3775
+ return new Promise((resolve7, reject) => {
3769
3776
  const server = (0, net_1.createServer)((socket) => {
3770
3777
  server.close();
3771
3778
  connectResolve([
@@ -3776,7 +3783,7 @@ var require_main = __commonJS({
3776
3783
  server.on("error", reject);
3777
3784
  server.listen(pipeName, () => {
3778
3785
  server.removeListener("error", reject);
3779
- resolve8({
3786
+ resolve7({
3780
3787
  onConnected: () => {
3781
3788
  return connected;
3782
3789
  }
@@ -3793,10 +3800,10 @@ var require_main = __commonJS({
3793
3800
  }
3794
3801
  function createClientSocketTransport(port, encoding = "utf-8") {
3795
3802
  let connectResolve;
3796
- const connected = new Promise((resolve8, _reject) => {
3797
- connectResolve = resolve8;
3803
+ const connected = new Promise((resolve7, _reject) => {
3804
+ connectResolve = resolve7;
3798
3805
  });
3799
- return new Promise((resolve8, reject) => {
3806
+ return new Promise((resolve7, reject) => {
3800
3807
  const server = (0, net_1.createServer)((socket) => {
3801
3808
  server.close();
3802
3809
  connectResolve([
@@ -3813,7 +3820,7 @@ var require_main = __commonJS({
3813
3820
  return;
3814
3821
  }
3815
3822
  const boundPort = address.port;
3816
- resolve8({
3823
+ resolve7({
3817
3824
  port: () => boundPort,
3818
3825
  onConnected: () => {
3819
3826
  return connected;
@@ -3857,9 +3864,84 @@ var CASCADE_DIAGNOSTICS_TTL_MS = 24e4;
3857
3864
  // dist/clients/lsp/index.js
3858
3865
  import * as nodeFs2 from "node:fs";
3859
3866
  import fs13 from "node:fs/promises";
3867
+ import os2 from "node:os";
3860
3868
  import path17 from "node:path";
3861
3869
  import { pathToFileURL as pathToFileURL3, URL as URL3 } from "node:url";
3862
3870
 
3871
+ // dist/clients/lsp/watch-queue.js
3872
+ var WATCH_DEBOUNCE_MS = 100;
3873
+ var FILE_CREATED = 1;
3874
+ var FILE_CHANGED = 2;
3875
+ var FILE_DELETED = 3;
3876
+ var WATCH_BIRTH_MARGIN_MS = 100;
3877
+ function watchedTypeForOpen(birthtimeMs, clientStartedAtMs = Number.POSITIVE_INFINITY) {
3878
+ return birthtimeMs >= clientStartedAtMs - WATCH_BIRTH_MARGIN_MS ? FILE_CREATED : FILE_CHANGED;
3879
+ }
3880
+ var WatchedFilesQueue = class {
3881
+ flushFn;
3882
+ debounceMs;
3883
+ onCreated;
3884
+ // uri → latest FileChangeType. A Map collapses repeated events for the same
3885
+ // URI (last-type-wins, except Created is never downgraded to Changed inside
3886
+ // one window — #4320) while preserving first-seen insertion order.
3887
+ pending = /* @__PURE__ */ new Map();
3888
+ timer = null;
3889
+ constructor(flushFn, debounceMs = WATCH_DEBOUNCE_MS, onCreated) {
3890
+ this.flushFn = flushFn;
3891
+ this.debounceMs = debounceMs;
3892
+ this.onCreated = onCreated;
3893
+ }
3894
+ /** Queue a change; arms the debounce timer if not already pending. */
3895
+ enqueue(uri, type) {
3896
+ const held = this.pending.get(uri);
3897
+ this.pending.set(uri, held === FILE_CREATED && type === FILE_CHANGED ? FILE_CREATED : type);
3898
+ if (this.timer)
3899
+ return;
3900
+ this.timer = setTimeout(() => this.flush(), this.debounceMs);
3901
+ this.timer.unref?.();
3902
+ }
3903
+ /** Emit all queued changes as one notification (no-op when empty). */
3904
+ flush() {
3905
+ if (this.timer) {
3906
+ clearTimeout(this.timer);
3907
+ this.timer = null;
3908
+ }
3909
+ if (this.pending.size === 0)
3910
+ return;
3911
+ const changes = [...this.pending.entries()].map(([uri, type]) => ({ uri, type }));
3912
+ this.pending.clear();
3913
+ this.flushFn(changes);
3914
+ const created = changes.flatMap((change) => change.type === FILE_CREATED ? [change.uri] : []);
3915
+ if (created.length > 0)
3916
+ this.onCreated?.(created);
3917
+ }
3918
+ /**
3919
+ * #4320: send now when a Created is waiting, so a read that follows is
3920
+ * answered by a server that has heard of the new path. Leaves a queue of
3921
+ * edits alone to coalesce as usual.
3922
+ */
3923
+ flushIfCreated() {
3924
+ for (const type of this.pending.values()) {
3925
+ if (type === FILE_CREATED) {
3926
+ this.flush();
3927
+ return;
3928
+ }
3929
+ }
3930
+ }
3931
+ /** Drop the timer + any queued changes without emitting (client teardown). */
3932
+ cancel() {
3933
+ if (this.timer) {
3934
+ clearTimeout(this.timer);
3935
+ this.timer = null;
3936
+ }
3937
+ this.pending.clear();
3938
+ }
3939
+ /** Number of distinct URIs currently queued (for tests/introspection). */
3940
+ get size() {
3941
+ return this.pending.size;
3942
+ }
3943
+ };
3944
+
3863
3945
  // dist/clients/lsp/workspace-diagnostics-session.js
3864
3946
  var _sessionStartedAt = Date.now();
3865
3947
  function resetWorkspaceDiagnosticsCacheSession(startedAt = Date.now()) {
@@ -3887,6 +3969,12 @@ function noteWorkspaceFileCreated(serverId, root, paths, at = Date.now()) {
3887
3969
  }
3888
3970
  }
3889
3971
  }
3972
+ function noteWorkspaceFilesChangedOnDisk(root, paths, at = Date.now()) {
3973
+ noteWorkspaceFileCreated("", root, paths, at);
3974
+ }
3975
+ function noteWorkspaceDependenciesChanged(at = Date.now()) {
3976
+ _allFilesChangedAt = Math.max(_allFilesChangedAt, at);
3977
+ }
3890
3978
  function workspaceFileCreatedAtFor(fromServer, holds, counts = () => true) {
3891
3979
  let latest = _allFilesChangedAt;
3892
3980
  for (const creation of _fileCreations.values()) {
@@ -3954,7 +4042,7 @@ async function importTargetsToAnnounce(cwd, importers, onScope) {
3954
4042
  reason: `resolved the imports of ${CREATED_IMPORT_SCAN_MAX_FILES} of ${importers.length} files in one diagnostics call`
3955
4043
  });
3956
4044
  }
3957
- const { extractForwardImports } = await import("./chunk-A3YNG5KP.js");
4045
+ const { extractForwardImports } = await import("./chunk-BOPDQ7AZ.js");
3958
4046
  const targets = /* @__PURE__ */ new Set();
3959
4047
  const reexports = /* @__PURE__ */ new Map();
3960
4048
  let resolved2 = 0;
@@ -4269,10 +4357,10 @@ function isRuleIgnoredForPath(filePath, root, patterns) {
4269
4357
  if (!patterns || patterns.length === 0)
4270
4358
  return false;
4271
4359
  const pathApi = isWindowsPath(root) || isWindowsPath(filePath) ? path3.win32 : path3.posix;
4272
- const relative3 = pathApi.relative(root, filePath);
4273
- const outsideRoot = relative3 !== "" && (relative3 === ".." || relative3.startsWith(`..${pathApi.sep}`) || pathApi.isAbsolute(relative3));
4274
- const displayPath = toPosix(outsideRoot ? filePath : relative3);
4275
- return patterns.some((pattern) => (!outsideRoot || !pattern.replaceAll("\\", "/").endsWith("/**")) && minimatch(displayPath, pattern, { dot: true }));
4360
+ const relative2 = relativeInside(root, filePath, pathApi);
4361
+ const outsideRoot = relative2 === void 0;
4362
+ const displayPath = toPosix(outsideRoot ? filePath : relative2);
4363
+ return patterns.some((pattern) => (!outsideRoot || !toPosix(pattern).endsWith("/**")) && minimatch(displayPath, pattern, { dot: true }));
4276
4364
  }
4277
4365
  function loadRuleIgnorePatterns(root) {
4278
4366
  const patterns = /* @__PURE__ */ new Map();
@@ -4398,18 +4486,50 @@ var AUXILIARY_LSP_PROFILES = [
4398
4486
  // A misspelling is a documentation/quality defect — not security or
4399
4487
  // correctness. "style" is the closest taxonomy class.
4400
4488
  defectClass: () => "style"
4489
+ },
4490
+ {
4491
+ serverId: "fallow",
4492
+ tool: "fallow",
4493
+ // fallow-lsp tags its LSP diagnostics `source: "fallow"`.
4494
+ sourceMatch: /fallow/i,
4495
+ // #4929: opt-in. Off unless `--lens-fallow` / `fallow.enabled=true` is set;
4496
+ // it overlaps knip, jscpd and madge, which keep running either way.
4497
+ enabledByDefault: false,
4498
+ optInFlag: "lens-fallow",
4499
+ // Advisory in this cut: no `allowBlocking`, so even an ERROR-severity
4500
+ // finding stays a warning. fallow publishes unused-code findings as LSP
4501
+ // HINT (severity 4, the editor's greyed-out tag), which the generic
4502
+ // conversion would render as no semantic at all.
4503
+ semantic: () => "warning",
4504
+ defectClass: (d) => {
4505
+ const code = String(d.code ?? "");
4506
+ if (code.startsWith("unused-"))
4507
+ return "unused-value";
4508
+ if (/^(security-|tainted-sink|dangerous-html|client-server-leak)/.test(code))
4509
+ return "safety";
4510
+ return void 0;
4511
+ }
4401
4512
  }
4402
4513
  ];
4514
+ function isOptInAuxiliaryServerId(serverId) {
4515
+ return AUXILIARY_LSP_PROFILES.some((p) => p.serverId === serverId && !p.enabledByDefault);
4516
+ }
4403
4517
  function enabledAuxiliaryLspServerIds(getFlag) {
4404
4518
  if (shouldDegradeAuxiliaryLsp() || isSubagentSession())
4405
4519
  return [];
4406
4520
  return AUXILIARY_LSP_PROFILES.flatMap((p) => isEnabledByConfiguration(p, getFlag) ? [p.serverId] : []);
4407
4521
  }
4408
4522
  function configDisabledAuxiliaryLspServerIds(getFlag) {
4409
- return new Set(AUXILIARY_LSP_PROFILES.flatMap((p) => isEnabledByConfiguration(p, getFlag) ? [] : [p.serverId]));
4523
+ return new Set(AUXILIARY_LSP_PROFILES.flatMap((p) => p.enabledByDefault && !isEnabledByConfiguration(p, getFlag) ? [p.serverId] : []));
4524
+ }
4525
+ function enabledOptInAuxiliaryLspServerIds(getFlag) {
4526
+ return new Set(AUXILIARY_LSP_PROFILES.flatMap((p) => !p.enabledByDefault && isEnabledByConfiguration(p, getFlag) ? [p.serverId] : []));
4410
4527
  }
4411
4528
  function isEnabledByConfiguration(profile, getFlag) {
4412
- return profile.enabledByDefault && !(profile.killSwitchFlag && getFlag(profile.killSwitchFlag) === true);
4529
+ if (!profile.enabledByDefault) {
4530
+ return profile.optInFlag !== void 0 && getFlag(profile.optInFlag) === true;
4531
+ }
4532
+ return !(profile.killSwitchFlag && getFlag(profile.killSwitchFlag) === true);
4413
4533
  }
4414
4534
  var profileForSourceCache = /* @__PURE__ */ new Map();
4415
4535
  function findAuxiliaryProfileForSource(source) {
@@ -4426,6 +4546,16 @@ function isAuxiliaryDiagnosticSuppressed(d, content) {
4426
4546
  const profile = findAuxiliaryProfileForSource(d.source);
4427
4547
  return Boolean(profile?.isSuppressed?.(d, content));
4428
4548
  }
4549
+ function dropExcludedServers(answer, excludeServerIds) {
4550
+ const kept = (serverId) => !excludeServerIds?.has(serverId ?? "");
4551
+ return {
4552
+ ...answer,
4553
+ diagnostics: answer.diagnostics.filter((d) => kept(d.serverId ?? findAuxiliaryProfileForSource(d.source)?.serverId)),
4554
+ ...answer.unconfirmedServerIds !== void 0 && {
4555
+ unconfirmedServerIds: answer.unconfirmedServerIds.filter(kept)
4556
+ }
4557
+ };
4558
+ }
4429
4559
  function applyAuxiliarySuppressions(diagnostics, content, opts) {
4430
4560
  const { filePath, scanRoot } = opts ?? {};
4431
4561
  const ruleIgnores = filePath && scanRoot ? loadRuleIgnorePatterns(scanRoot) : void 0;
@@ -4719,9 +4849,12 @@ var DocumentDriftTracker = class {
4719
4849
  return SKIPPED;
4720
4850
  }
4721
4851
  }
4722
- return this.flight.run(SWEEP_KEY, () => this.runSweep(deps, now));
4852
+ const full = options.full === true;
4853
+ if (full && this.flight.has(SWEEP_KEY))
4854
+ await this.flight.run(SWEEP_KEY, () => this.runSweep(deps, now));
4855
+ return this.flight.run(SWEEP_KEY, () => this.runSweep(deps, now, full));
4723
4856
  }
4724
- async runSweep(deps, now) {
4857
+ async runSweep(deps, now, full = false) {
4725
4858
  this.lastSweepAt = now();
4726
4859
  const stat3 = deps.stat ?? defaultStat;
4727
4860
  const read = deps.read ?? defaultRead;
@@ -4730,8 +4863,10 @@ var DocumentDriftTracker = class {
4730
4863
  const tracked = keys.length;
4731
4864
  if (this.cursor >= tracked)
4732
4865
  this.cursor = 0;
4866
+ const checkBatch = full ? tracked : DRIFT_CHECK_BATCH;
4867
+ const resyncBatch = full ? Number.POSITIVE_INFINITY : DRIFT_RESYNC_BATCH;
4733
4868
  const window = [];
4734
- for (let i = 0; i < Math.min(DRIFT_CHECK_BATCH, tracked); i++) {
4869
+ for (let i = 0; i < Math.min(checkBatch, tracked); i++) {
4735
4870
  window.push(keys[(this.cursor + i) % tracked]);
4736
4871
  }
4737
4872
  this.cursor = tracked === 0 ? 0 : (this.cursor + window.length) % tracked;
@@ -4812,7 +4947,7 @@ var DocumentDriftTracker = class {
4812
4947
  for (const key of queued) {
4813
4948
  if (!this.pendingResync.has(key))
4814
4949
  continue;
4815
- if (resynced >= DRIFT_RESYNC_BATCH) {
4950
+ if (resynced >= resyncBatch) {
4816
4951
  deferred += 1;
4817
4952
  queuedDispositions.set(key, "deferred");
4818
4953
  deps.onDrift?.({
@@ -4868,7 +5003,7 @@ var DocumentDriftTracker = class {
4868
5003
  if (resyncedKeys.has(key))
4869
5004
  continue;
4870
5005
  const driftAgeMs = Math.max(0, now() - record2.syncedAt);
4871
- if (resynced >= DRIFT_RESYNC_BATCH) {
5006
+ if (resynced >= resyncBatch) {
4872
5007
  deferred += 1;
4873
5008
  deps.onDrift?.({
4874
5009
  filePath: key,
@@ -5450,6 +5585,8 @@ var Scope = class {
5450
5585
  retiredReason;
5451
5586
  /** The scope's store cells, by key (#3612); see {@link scopeCell}. */
5452
5587
  cells = /* @__PURE__ */ new Map();
5588
+ /** The lookup keys {@link bindSessionId} bound to this scope. */
5589
+ boundKeys = /* @__PURE__ */ new Set();
5453
5590
  // The stale-write record keeps its `runtime-session:<subject>` subject.
5454
5591
  life = createGenerationSource("runtime-session");
5455
5592
  branch = createGenerationSource("session-branch");
@@ -5474,6 +5611,7 @@ var Scope = class {
5474
5611
  return;
5475
5612
  this.retiredReason = reason ?? "shutdown";
5476
5613
  this.life.bump();
5614
+ unbindScope(this);
5477
5615
  }
5478
5616
  moveBranch() {
5479
5617
  this.branch.bump();
@@ -5534,6 +5672,34 @@ function logScopeTransition(scope, args) {
5534
5672
  }
5535
5673
  });
5536
5674
  }
5675
+ var SESSION_INDEX_FAMILY = "session-scope.session-index";
5676
+ var SESSION_INDEX_VERSION = 1;
5677
+ function sessionIndex() {
5678
+ return getProcessSingleton(SESSION_INDEX_FAMILY, SESSION_INDEX_VERSION, () => ({ byKey: /* @__PURE__ */ new Map() }));
5679
+ }
5680
+ function unbindScope(scope) {
5681
+ const own = scope;
5682
+ const { byKey } = sessionIndex();
5683
+ for (const key of own.boundKeys)
5684
+ if (byKey.get(key) === own)
5685
+ byKey.delete(key);
5686
+ own.boundKeys.clear();
5687
+ }
5688
+ function scopeOfSession(key) {
5689
+ return sessionIndex().byKey.get(key);
5690
+ }
5691
+ function sessionCell(key, cellKey, init) {
5692
+ const scope = scopeOfSession(key);
5693
+ if (scope)
5694
+ return scopeCell(scope, cellKey, init);
5695
+ if (init)
5696
+ incrementDegradationCount({
5697
+ kind: "session-scope-lookup-missed",
5698
+ subject: cellKey,
5699
+ reason: `a ${cellKey} write named a session with no live scope, so it was dropped instead of held with no owner to retire it`
5700
+ });
5701
+ return void 0;
5702
+ }
5537
5703
  var sessionStores = /* @__PURE__ */ new Map();
5538
5704
  function defineSessionStore(spec) {
5539
5705
  if (sessionStores.has(spec.name))
@@ -6924,6 +7090,15 @@ Re-read the relevant section, then retry the edit using the current line range/c
6924
7090
  moveBranch(this.scope);
6925
7091
  return result;
6926
7092
  }
7093
+ /**
7094
+ * #4942 review F8: drop this guard's own {@link FileTime} bucket, which
7095
+ * lives in a process-global map keyed by session id and outlives the
7096
+ * guard object. Called when the owning session is forgotten. Unlike
7097
+ * {@link retainBranch} it leaves the shared branch epoch alone.
7098
+ */
7099
+ releaseFileTime() {
7100
+ this.fileTime.clear();
7101
+ }
6927
7102
  /** The epoch a deferred writer captures before it awaits (#3521). */
6928
7103
  get currentBranchEpoch() {
6929
7104
  return this.scope.branchEpoch();
@@ -7892,6 +8067,8 @@ function bookkeepLspMutation(context, files2, fileDetails) {
7892
8067
  source: context.source,
7893
8068
  cwd: context.cwd,
7894
8069
  changedRange: detail.range,
8070
+ // #4943: the issuing activation's change-log row.
8071
+ sessionId: context.sessionId,
7895
8072
  onAppendError: (err) => context.dbg?.(`lsp mutation project change append failed for ${filePath}: ${err}`)
7896
8073
  });
7897
8074
  if (sessionLive && context.cacheManager) {
@@ -8104,6 +8281,17 @@ function composeBoundToCurrentDisk(values) {
8104
8281
  }
8105
8282
  return true;
8106
8283
  }
8284
+ function warmAnswerBinding(answer) {
8285
+ const wire = answer.binding;
8286
+ const fields = typeof wire === "object" && wire !== null ? wire : {};
8287
+ const verdict = fields.boundToCurrentDisk;
8288
+ return {
8289
+ ...typeof fields.contentHash === "string" && {
8290
+ contentHash: fields.contentHash
8291
+ },
8292
+ boundToCurrentDisk: verdict === true || verdict === false || verdict === "unknown" ? verdict : false
8293
+ };
8294
+ }
8107
8295
  function bindingStateLabel(value) {
8108
8296
  if (value === true)
8109
8297
  return "bound";
@@ -8111,6 +8299,9 @@ function bindingStateLabel(value) {
8111
8299
  return "mismatch";
8112
8300
  return "unknown";
8113
8301
  }
8302
+ function readBoundToCurrentDisk(rawDiags) {
8303
+ return rawDiags?.binding?.boundToCurrentDisk;
8304
+ }
8114
8305
  var DISK_BINDING_MEMO_MAX = 4096;
8115
8306
  function createDiskBindingCache() {
8116
8307
  const diskHashByPath = new PathKeyedMap(normalizeEphemeralMapKey);
@@ -8143,11 +8334,27 @@ function createDiskBindingCache() {
8143
8334
  };
8144
8335
  }
8145
8336
 
8337
+ // dist/clients/lsp/server-config-files.js
8338
+ import { basename } from "node:path";
8339
+ var CONFIG_FILE_SERVERS = /* @__PURE__ */ new Map([
8340
+ ["pyrightconfig.json", ["python"]],
8341
+ ["pyproject.toml", ["python"]]
8342
+ ]);
8343
+ var SERVER_CONFIG_FILE_NAMES = [
8344
+ ...CONFIG_FILE_SERVERS.keys()
8345
+ ];
8346
+ function serverIdsForConfigFile(filePath) {
8347
+ return CONFIG_FILE_SERVERS.get(basename(filePath));
8348
+ }
8349
+
8146
8350
  // dist/clients/lsp/grouping.js
8351
+ function aggregateServersForFile(filePath) {
8352
+ return getServersForFileWithConfig(filePath).flatMap((s) => isOptInAuxiliaryServerId(s.id) ? [] : [s]);
8353
+ }
8147
8354
  function groupFilesByPrimaryServer(files2) {
8148
8355
  const byServer = /* @__PURE__ */ new Map();
8149
8356
  for (const filePath of files2) {
8150
- const servers = getServersForFileWithConfig(filePath);
8357
+ const servers = aggregateServersForFile(filePath);
8151
8358
  const primary = servers[0]?.id ?? "none";
8152
8359
  const group = byServer.get(primary);
8153
8360
  const fallbackFamilyHeads = /* @__PURE__ */ new Map();
@@ -8316,7 +8523,7 @@ function resyncDocumentOnPastEof(filePath) {
8316
8523
  void (async () => {
8317
8524
  try {
8318
8525
  const [{ getOwnedLspService: getOwnedLspService2 }, content] = await Promise.all([
8319
- import("./chunk-2PHMIAKO.js"),
8526
+ import("./chunk-CM73PPGD.js"),
8320
8527
  fs7.promises.readFile(filePath, "utf-8")
8321
8528
  ]);
8322
8529
  await getOwnedLspService2().openFile(filePath, content, { preserveDiagnostics: false });
@@ -9295,14 +9502,14 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
9295
9502
  const languageCount = promises3.length - auxIndices.size;
9296
9503
  let languageRemaining = languageCount;
9297
9504
  let auxGraceStarted = false;
9298
- return new Promise((resolve8) => {
9505
+ return new Promise((resolve7) => {
9299
9506
  const timeout = setTimeout(() => {
9300
9507
  completed = true;
9301
9508
  if (graceTimer)
9302
9509
  clearTimeout(graceTimer);
9303
9510
  if (auxGraceTimer)
9304
9511
  clearTimeout(auxGraceTimer);
9305
- resolve8(results.filter((r) => r !== void 0));
9512
+ resolve7(results.filter((r) => r !== void 0));
9306
9513
  }, options.timeoutMs);
9307
9514
  const finalize = () => {
9308
9515
  if (completed)
@@ -9313,7 +9520,7 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
9313
9520
  clearTimeout(graceTimer);
9314
9521
  if (auxGraceTimer)
9315
9522
  clearTimeout(auxGraceTimer);
9316
- resolve8(results.filter((r) => r !== void 0));
9523
+ resolve7(results.filter((r) => r !== void 0));
9317
9524
  };
9318
9525
  const startAuxGrace = () => {
9319
9526
  if (auxGraceStarted || completed)
@@ -9373,7 +9580,7 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
9373
9580
 
9374
9581
  // dist/clients/lsp/edits.js
9375
9582
  import fs10 from "node:fs/promises";
9376
- import { readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync8 } from "node:fs";
9583
+ import { readFileSync as readFileSync8, realpathSync, statSync as statSync8 } from "node:fs";
9377
9584
  import path10 from "node:path";
9378
9585
  import { URL as URL2 } from "node:url";
9379
9586
 
@@ -9400,80 +9607,6 @@ function convertCharacterOffset(encoding, lineText, utf16Character) {
9400
9607
  return [...prefix].length;
9401
9608
  }
9402
9609
 
9403
- // dist/clients/lsp/watch-queue.js
9404
- var WATCH_DEBOUNCE_MS = 100;
9405
- var FILE_CREATED = 1;
9406
- var FILE_CHANGED = 2;
9407
- var FILE_DELETED = 3;
9408
- var WATCH_BIRTH_MARGIN_MS = 100;
9409
- function watchedTypeForOpen(birthtimeMs, clientStartedAtMs = Number.POSITIVE_INFINITY) {
9410
- return birthtimeMs >= clientStartedAtMs - WATCH_BIRTH_MARGIN_MS ? FILE_CREATED : FILE_CHANGED;
9411
- }
9412
- var WatchedFilesQueue = class {
9413
- flushFn;
9414
- debounceMs;
9415
- onCreated;
9416
- // uri → latest FileChangeType. A Map collapses repeated events for the same
9417
- // URI (last-type-wins, except Created is never downgraded to Changed inside
9418
- // one window — #4320) while preserving first-seen insertion order.
9419
- pending = /* @__PURE__ */ new Map();
9420
- timer = null;
9421
- constructor(flushFn, debounceMs = WATCH_DEBOUNCE_MS, onCreated) {
9422
- this.flushFn = flushFn;
9423
- this.debounceMs = debounceMs;
9424
- this.onCreated = onCreated;
9425
- }
9426
- /** Queue a change; arms the debounce timer if not already pending. */
9427
- enqueue(uri, type) {
9428
- const held = this.pending.get(uri);
9429
- this.pending.set(uri, held === FILE_CREATED && type === FILE_CHANGED ? FILE_CREATED : type);
9430
- if (this.timer)
9431
- return;
9432
- this.timer = setTimeout(() => this.flush(), this.debounceMs);
9433
- this.timer.unref?.();
9434
- }
9435
- /** Emit all queued changes as one notification (no-op when empty). */
9436
- flush() {
9437
- if (this.timer) {
9438
- clearTimeout(this.timer);
9439
- this.timer = null;
9440
- }
9441
- if (this.pending.size === 0)
9442
- return;
9443
- const changes = [...this.pending.entries()].map(([uri, type]) => ({ uri, type }));
9444
- this.pending.clear();
9445
- this.flushFn(changes);
9446
- const created = changes.flatMap((change) => change.type === FILE_CREATED ? [change.uri] : []);
9447
- if (created.length > 0)
9448
- this.onCreated?.(created);
9449
- }
9450
- /**
9451
- * #4320: send now when a Created is waiting, so a read that follows is
9452
- * answered by a server that has heard of the new path. Leaves a queue of
9453
- * edits alone to coalesce as usual.
9454
- */
9455
- flushIfCreated() {
9456
- for (const type of this.pending.values()) {
9457
- if (type === FILE_CREATED) {
9458
- this.flush();
9459
- return;
9460
- }
9461
- }
9462
- }
9463
- /** Drop the timer + any queued changes without emitting (client teardown). */
9464
- cancel() {
9465
- if (this.timer) {
9466
- clearTimeout(this.timer);
9467
- this.timer = null;
9468
- }
9469
- this.pending.clear();
9470
- }
9471
- /** Number of distinct URIs currently queued (for tests/introspection). */
9472
- get size() {
9473
- return this.pending.size;
9474
- }
9475
- };
9476
-
9477
9610
  // dist/clients/lsp/edits.js
9478
9611
  var StaleWorkspaceEditContentError = class extends Error {
9479
9612
  };
@@ -9866,7 +9999,7 @@ function captureRenameExpectedContent(edit, cwd, requestedAtMs, readTrackedSend,
9866
9999
  let targetRealPath;
9867
10000
  if (target !== void 0) {
9868
10001
  try {
9869
- targetRealPath = realpathSync2.native(target.filePath);
10002
+ targetRealPath = realpathSync.native(target.filePath);
9870
10003
  } catch {
9871
10004
  targetRealPath = void 0;
9872
10005
  }
@@ -9876,7 +10009,7 @@ function captureRenameExpectedContent(edit, cwd, requestedAtMs, readTrackedSend,
9876
10009
  let content;
9877
10010
  let mtimeMs;
9878
10011
  try {
9879
- realPath = realpathSync2.native(diskPath);
10012
+ realPath = realpathSync.native(diskPath);
9880
10013
  content = readFileSync8(realPath, "utf-8");
9881
10014
  mtimeMs = statSync8(realPath).mtimeMs;
9882
10015
  } catch {
@@ -10043,7 +10176,7 @@ function planWorkspaceEdit(edit, trackOrigins = false) {
10043
10176
  }
10044
10177
  function relativeToCwd(filePath, cwd) {
10045
10178
  const rel = path10.relative(cwd, filePath) || path10.basename(filePath);
10046
- return rel.replace(/\\/g, "/");
10179
+ return toPosix(rel);
10047
10180
  }
10048
10181
  var IMPORT_RELEVANT_LINE = /^\s*import\b|^\s*export\s[^;]*\bfrom\s|\bfrom\s+['"]/;
10049
10182
  function importsSignature(text) {
@@ -10094,19 +10227,17 @@ async function isSameFsEntry(a, b) {
10094
10227
  return Boolean(statA && statB && isSameFsIdentity(statA, statB));
10095
10228
  }
10096
10229
  async function assertParentIsUsable(filePath, stateFor) {
10097
- let current = path10.dirname(filePath);
10098
- while (true) {
10230
+ for (const current of walkUpDirs(path10.dirname(filePath), {
10231
+ spelling: true
10232
+ })) {
10099
10233
  const known = await stateFor(current);
10100
10234
  if (known.exists) {
10101
10235
  if (!known.directory)
10102
10236
  throw new Error(`resource parent is not a directory: ${current}`);
10103
10237
  return;
10104
10238
  }
10105
- const parent = path10.dirname(current);
10106
- if (parent === current)
10107
- throw new Error(`resource parent does not exist: ${filePath}`);
10108
- current = parent;
10109
10239
  }
10240
+ throw new Error(`resource parent does not exist: ${filePath}`);
10110
10241
  }
10111
10242
  async function requireKernelIdentity(filePath, subject) {
10112
10243
  const identity = await kernelPathIdentityAsync(filePath);
@@ -10258,7 +10389,7 @@ async function preflightWorkspaceEdit(planned, cwd, options) {
10258
10389
  const newPath = await confine(op.newUri);
10259
10390
  const oldDisk = uriToDiskPath(op.oldUri);
10260
10391
  const newDisk = uriToDiskPath(op.newUri);
10261
- if (path10.resolve(oldDisk).replace(/\\/g, "/") === path10.resolve(newDisk).replace(/\\/g, "/")) {
10392
+ if (toPosix(path10.resolve(oldDisk)) === toPosix(path10.resolve(newDisk))) {
10262
10393
  throw new Error("rename source and destination must differ");
10263
10394
  }
10264
10395
  const source = await stateFor(oldPath);
@@ -10845,21 +10976,14 @@ function clearWorkspaceDiagnosticsCacheAtAndAbove(cwd, ceiling = process.cwd())
10845
10976
  const root = path12.resolve(cwd);
10846
10977
  const workspaceRoot = path12.resolve(ceiling);
10847
10978
  clearWorkspaceDiagnosticsCache(root);
10848
- const relative3 = path12.relative(workspaceRoot, root);
10849
- if (relative3.startsWith(".." + path12.sep) || relative3 === ".." || path12.isAbsolute(relative3)) {
10979
+ if (relativeInside(workspaceRoot, root) === void 0)
10850
10980
  return;
10851
- }
10852
10981
  if (normalizeMapKey(root) === normalizeMapKey(workspaceRoot))
10853
10982
  return;
10854
- let ancestor = path12.dirname(root);
10855
- while (true) {
10983
+ for (const ancestor of walkUpDirs(path12.dirname(root), { spelling: true })) {
10856
10984
  clearWorkspaceDiagnosticsCache(ancestor);
10857
10985
  if (normalizeMapKey(ancestor) === normalizeMapKey(workspaceRoot))
10858
10986
  return;
10859
- const parent = path12.dirname(ancestor);
10860
- if (parent === ancestor)
10861
- return;
10862
- ancestor = parent;
10863
10987
  }
10864
10988
  }
10865
10989
  var _cacheEpochs = createGenerationMap("workspace-diagnostics-cache", {
@@ -11383,7 +11507,7 @@ async function killProcessTree(proc, pid, options = {}) {
11383
11507
  return;
11384
11508
  }
11385
11509
  try {
11386
- const taskkill = `${process.env.SystemRoot ?? "C:\\Windows"}\\System32\\taskkill.exe`;
11510
+ const taskkill = windowsExe("taskkill.exe");
11387
11511
  const killer = nodeSpawn(taskkill, ["/F", "/T", "/PID", String(pid)], {
11388
11512
  shell: false,
11389
11513
  windowsHide: true,
@@ -11395,8 +11519,8 @@ async function killProcessTree(proc, pid, options = {}) {
11395
11519
  proc.unref?.();
11396
11520
  return;
11397
11521
  }
11398
- await new Promise((resolve8) => {
11399
- killer.once("close", () => resolve8());
11522
+ await new Promise((resolve7) => {
11523
+ killer.once("close", () => resolve7());
11400
11524
  killer.once("error", (err) => {
11401
11525
  logLatency({
11402
11526
  type: "phase",
@@ -11405,7 +11529,7 @@ async function killProcessTree(proc, pid, options = {}) {
11405
11529
  durationMs: 0,
11406
11530
  metadata: { pid, platform: "win32", taskkillError: String(err) }
11407
11531
  });
11408
- resolve8();
11532
+ resolve7();
11409
11533
  });
11410
11534
  });
11411
11535
  } catch (err) {
@@ -11463,18 +11587,18 @@ async function killProcessTree(proc, pid, options = {}) {
11463
11587
  proc.unref?.();
11464
11588
  return;
11465
11589
  }
11466
- const exitedInTime = await new Promise((resolve8) => {
11590
+ const exitedInTime = await new Promise((resolve7) => {
11467
11591
  if (proc.exitCode != null || proc.signalCode != null) {
11468
- resolve8(true);
11592
+ resolve7(true);
11469
11593
  return;
11470
11594
  }
11471
11595
  const onExit = () => {
11472
11596
  clearTimeout(timer);
11473
- resolve8(true);
11597
+ resolve7(true);
11474
11598
  };
11475
11599
  const timer = setTimeout(() => {
11476
11600
  proc.off?.("exit", onExit);
11477
- resolve8(false);
11601
+ resolve7(false);
11478
11602
  }, 1500);
11479
11603
  proc.once?.("exit", onExit);
11480
11604
  });
@@ -11664,7 +11788,49 @@ function publicationCountsForPath(state4, normalizedPath) {
11664
11788
  function diagnosticsVersionForPath(state4, normalizedPath) {
11665
11789
  return state4.diagnosticsVersionsByPath?.get(normalizedPath) ?? 0;
11666
11790
  }
11791
+ function diagnosticsPublishedAtForPath(state4, normalizedPath) {
11792
+ const ts = Math.max(state4.pushDiagnosticTimestamps?.get(normalizedPath) ?? 0, state4.documentPullDiagnosticTimestamps?.get(normalizedPath) ?? 0);
11793
+ return ts > 0 ? ts : void 0;
11794
+ }
11667
11795
  var PENDING_RECEIPT_DROPPED = "pending-receipt-dropped";
11796
+ function noteOwnNoticeQueued(state4, normalizedPath, uri, sentVersion) {
11797
+ (state4.ownNoticeEchoes ??= /* @__PURE__ */ new Map()).set(normalizedPath, {
11798
+ uri,
11799
+ sentVersion,
11800
+ flushed: false,
11801
+ sawNonEmpty: false
11802
+ });
11803
+ }
11804
+ function noteOwnNoticeFlushed(state4, changes) {
11805
+ const echoes = state4.ownNoticeEchoes;
11806
+ if (!echoes)
11807
+ return;
11808
+ for (const [normalizedPath, echo] of echoes) {
11809
+ if (!echo.flushed && changes.length === 1 && changes[0]?.uri === echo.uri)
11810
+ echo.flushed = true;
11811
+ else
11812
+ echoes.delete(normalizedPath);
11813
+ }
11814
+ }
11815
+ function holdEmptyEchoOfOwnNotice(state4, normalizedPath, diagnosticCount, docVersion) {
11816
+ const echo = state4.ownNoticeEchoes?.get(normalizedPath);
11817
+ if (!echo || docVersion !== void 0 || echo.sentVersion !== state4.documentVersions.get(normalizedPath))
11818
+ return false;
11819
+ if (diagnosticCount > 0) {
11820
+ echo.sawNonEmpty = true;
11821
+ return false;
11822
+ }
11823
+ if (!echo.flushed || !echo.sawNonEmpty)
11824
+ return false;
11825
+ state4.ownNoticeEchoes?.delete(normalizedPath);
11826
+ countPublication(state4, normalizedPath);
11827
+ incrementDegradationCount({
11828
+ kind: "lsp-watched-echo-held",
11829
+ subject: state4.serverId,
11830
+ reason: "an empty version-less publish followed the client's own watched-files notice for a document the server had already reported on"
11831
+ });
11832
+ return true;
11833
+ }
11668
11834
  function clearDiagnosticsForPath(state4, normalizedPath) {
11669
11835
  const legacy = state4;
11670
11836
  state4.pushDiagnostics?.delete(normalizedPath);
@@ -11679,6 +11845,7 @@ function clearDiagnosticsForPath(state4, normalizedPath) {
11679
11845
  state4.documentPullDiagnosticTimestamps?.delete(normalizedPath);
11680
11846
  state4.diagnosticDocVersions?.delete(normalizedPath);
11681
11847
  state4.nonEmptyAnswerPhases?.delete(normalizedPath);
11848
+ state4.ownNoticeEchoes?.delete(normalizedPath);
11682
11849
  state4.diagnosticBindings?.delete(normalizedPath);
11683
11850
  state4.diagnosticsVersionsByPath?.delete(normalizedPath);
11684
11851
  for (const key of pullSourceKeysForPath(state4, normalizedPath)) {
@@ -12038,6 +12205,9 @@ function setupIncomingHandlers(state4, initialization, onDiagnosticsPublished) {
12038
12205
  }
12039
12206
  return;
12040
12207
  }
12208
+ if (holdEmptyEchoOfOwnNotice(state4, normalizedPath, newDiags.length, docVersion)) {
12209
+ return;
12210
+ }
12041
12211
  if (PUB_DEBUG) {
12042
12212
  logExtension({
12043
12213
  subsystem: "lsp-pub",
@@ -12747,7 +12917,7 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
12747
12917
  const retryBudgetMs = strategy.pullRetryBudgetMs > 0 ? Math.min(timeoutMs, strategy.pullRetryBudgetMs) : 0;
12748
12918
  const startedAt = Date.now();
12749
12919
  while (outcome.status !== "found" && Date.now() - startedAt < retryBudgetMs) {
12750
- await new Promise((resolve8) => setTimeout(resolve8, PULL_DIAGNOSTICS_RETRY_INTERVAL_MS));
12920
+ await new Promise((resolve7) => setTimeout(resolve7, PULL_DIAGNOSTICS_RETRY_INTERVAL_MS));
12751
12921
  outcome = await clientRequestPullDiagnostics(state4, filePath, Math.max(0, retryBudgetMs - (Date.now() - startedAt)));
12752
12922
  if (outcome.status === "clean")
12753
12923
  sawClean = true;
@@ -12769,7 +12939,7 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
12769
12939
  return;
12770
12940
  }
12771
12941
  const answerStored = () => hasFreshDiagnostics() && !isVersionStale() && (state4.pushDiagnostics.has(normalizedPath) || state4.documentPullDiagnostics.has(normalizedPath));
12772
- return new Promise((resolve8) => {
12942
+ return new Promise((resolve7) => {
12773
12943
  let debounceTimer;
12774
12944
  let settleDeferred = storedAnswerSettles();
12775
12945
  const finish = () => {
@@ -12778,7 +12948,7 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
12778
12948
  state4.diagnosticEmitter.off("diagnostics", onDiagnostics);
12779
12949
  state4.diagnosticEmitter.off(PENDING_RECEIPT_DROPPED, onReceiptDropped);
12780
12950
  clearTimeout(timeout);
12781
- resolve8();
12951
+ resolve7();
12782
12952
  };
12783
12953
  const onDiagnostics = (fp) => {
12784
12954
  if (normalizeMapKey(fp) !== normalizedPath)
@@ -12986,6 +13156,8 @@ async function handleNotifyOpenOnce(state4, filePath, content, languageId, prese
12986
13156
  });
12987
13157
  }
12988
13158
  enqueueWatchedChange(state4, normalizedPath, uri, watchedType, onDisk);
13159
+ if (state4.customServer)
13160
+ noteOwnNoticeQueued(state4, normalizedPath, uri, 0);
12989
13161
  }
12990
13162
  if (!isClientAlive(state4))
12991
13163
  return false;
@@ -13017,9 +13189,9 @@ function enqueueDocumentNotify(state4, normalizedPath, run, saved = false, readS
13017
13189
  queue = { running: false, active: void 0 };
13018
13190
  state4.notifyChangeQueues.set(normalizedPath, queue);
13019
13191
  }
13020
- return new Promise((resolve8, reject) => {
13192
+ return new Promise((resolve7, reject) => {
13021
13193
  if (queue.closing && !close) {
13022
- resolve8(false);
13194
+ resolve7(false);
13023
13195
  return;
13024
13196
  }
13025
13197
  const previous = queue?.pending;
@@ -13033,7 +13205,7 @@ function enqueueDocumentNotify(state4, normalizedPath, run, saved = false, readS
13033
13205
  const before = (a, b) => a !== void 0 && b !== void 0 && a < b;
13034
13206
  const stale = previous !== void 0 && (saveOnly || before(readStamp, previous.readStamp) || before(readStamp, lastSent));
13035
13207
  const heldStamp = before(previous?.readStamp, lastSent) ? void 0 : previous?.readStamp;
13036
- waiters.push({ resolve: resolve8, reject, stale });
13208
+ waiters.push({ resolve: resolve7, reject, stale });
13037
13209
  queue.pending = {
13038
13210
  run: stale ? previous.run : run,
13039
13211
  saveOnly: stale ? previous.saveOnly : saveOnly,
@@ -13611,7 +13783,7 @@ function hasNotifyInFlightFor(state4, filePath) {
13611
13783
  }
13612
13784
  async function createLSPClient(options) {
13613
13785
  installCrashGuard();
13614
- const { serverId, process: lspProcess, root, sessionCwd, initialization, initializeTimeoutMs = INITIALIZE_TIMEOUT_MS, launchVariant, settingsSection, role, onDiagnosticsPublished } = options;
13786
+ const { serverId, process: lspProcess, root, sessionCwd, initialization, initializeTimeoutMs = INITIALIZE_TIMEOUT_MS, launchVariant, settingsSection, role, custom, onDiagnosticsPublished } = options;
13615
13787
  void recordLspChild({
13616
13788
  pid: lspProcess.pid,
13617
13789
  serverId,
@@ -13724,6 +13896,8 @@ async function createLSPClient(options) {
13724
13896
  // #4764: the declared role, so a config-load failure gates only an
13725
13897
  // auxiliary scanner's empty publications.
13726
13898
  ...role !== void 0 && { serverRole: role },
13899
+ // #5131 round 2: the echo hold reads a config-declared server only.
13900
+ customServer: custom === true,
13727
13901
  // #3310: one-shot, per client session.
13728
13902
  emptyFirstPublishHoldSpent: false,
13729
13903
  rulesGeneration: 0,
@@ -13759,6 +13933,7 @@ async function createLSPClient(options) {
13759
13933
  (changes) => {
13760
13934
  if (!isClientAlive(state4))
13761
13935
  return;
13936
+ noteOwnNoticeFlushed(state4, changes);
13762
13937
  void safeSendNotification(state4.connection, "workspace/didChangeWatchedFiles", { changes });
13763
13938
  },
13764
13939
  void 0,
@@ -13915,6 +14090,9 @@ async function createLSPClient(options) {
13915
14090
  getDiagnosticsVersionForPath(filePath) {
13916
14091
  return diagnosticsVersionForPath(state4, normalizeMapKey(filePath));
13917
14092
  },
14093
+ getDiagnosticsPublishedAt(filePath) {
14094
+ return diagnosticsPublishedAtForPath(state4, normalizeMapKey(filePath));
14095
+ },
13918
14096
  getPublicationCountsForPath(filePath) {
13919
14097
  return publicationCountsForPath(state4, normalizeMapKey(filePath));
13920
14098
  },
@@ -13927,7 +14105,7 @@ async function createLSPClient(options) {
13927
14105
  for (const key of keys) {
13928
14106
  result.set(key, {
13929
14107
  diags: getMergedDiagnosticsForPath(state4, key),
13930
- ts: Math.max(state4.pushDiagnosticTimestamps.get(key) ?? 0, state4.documentPullDiagnosticTimestamps.get(key) ?? 0),
14108
+ ts: diagnosticsPublishedAtForPath(state4, key) ?? 0,
13931
14109
  binding: state4.diagnosticBindings.get(key)
13932
14110
  });
13933
14111
  }
@@ -13949,7 +14127,7 @@ async function createLSPClient(options) {
13949
14127
  ]);
13950
14128
  for (const key of keys) {
13951
14129
  const diags = getMergedDiagnosticsForPath(state4, key);
13952
- const ts = Math.max(state4.pushDiagnosticTimestamps.get(key) ?? 0, state4.documentPullDiagnosticTimestamps.get(key) ?? 0);
14130
+ const ts = diagnosticsPublishedAtForPath(state4, key) ?? 0;
13953
14131
  if (!predicate(key, ts, diags))
13954
14132
  continue;
13955
14133
  clearDiagnosticsForPath(state4, key);
@@ -14265,8 +14443,8 @@ async function safeSendRequest(connection, method, params, signal, settlement, r
14265
14443
  if (signal) {
14266
14444
  tokenSource = new import_node.CancellationTokenSource();
14267
14445
  if (releaseOnAbort) {
14268
- released = new Promise((resolve8) => {
14269
- release = () => resolve8(RELEASED_ON_ABORT);
14446
+ released = new Promise((resolve7) => {
14447
+ release = () => resolve7(RELEASED_ON_ABORT);
14270
14448
  });
14271
14449
  }
14272
14450
  onAbort = () => {
@@ -14490,7 +14668,7 @@ function fileOperationUriCandidates(uri) {
14490
14668
  return [];
14491
14669
  let uriPath;
14492
14670
  try {
14493
- uriPath = decodeURIComponent(parsed.pathname).replace(/\\/g, "/");
14671
+ uriPath = toPosix(decodeURIComponent(parsed.pathname));
14494
14672
  } catch {
14495
14673
  return [];
14496
14674
  }
@@ -14601,8 +14779,6 @@ var ClientRegistry = class {
14601
14779
  hooks;
14602
14780
  sessionCwd;
14603
14781
  workspaceProbeLogged = /* @__PURE__ */ new Set();
14604
- /** Per-service immutable root-boundary verdicts; root detectors cache hits too. */
14605
- projectBoundaryCache = /* @__PURE__ */ new Map();
14606
14782
  /** Foreign roots are recorded once per normalized root for this service/session. */
14607
14783
  warmStartLogged = /* @__PURE__ */ new Set();
14608
14784
  optionalFailureLogged = /* @__PURE__ */ new Set();
@@ -14802,32 +14978,23 @@ var ClientRegistry = class {
14802
14978
  if (!key.startsWith(prefix))
14803
14979
  continue;
14804
14980
  const ancestorKey = key.slice(prefix.length);
14805
- const pathApi = isWindowsPath(ancestorKey) || isWindowsPath(rootKey) ? path13.win32 : path13;
14806
- const relative3 = pathApi.relative(ancestorKey, rootKey);
14807
- if (relative3 === "" || relative3.startsWith("..") || pathApi.isAbsolute(relative3)) {
14981
+ if (ancestorKey === rootKey || !isWithinForm(rootKey, ancestorKey))
14808
14982
  continue;
14809
- }
14810
14983
  if (!nearestAncestor || ancestorKey.length > nearestAncestor.length) {
14811
14984
  nearestAncestor = ancestorKey;
14812
14985
  }
14813
14986
  }
14814
14987
  if (!nearestAncestor)
14815
14988
  return root;
14816
- const boundaryKey = `${server.id}:${rootKey}`;
14817
- let boundary = this.projectBoundaryCache.get(boundaryKey);
14818
- if (!boundary) {
14819
- boundary = hasProjectBoundaryMarker(root, server);
14820
- this.projectBoundaryCache.set(boundaryKey, boundary);
14821
- }
14822
- if (await boundary)
14989
+ if (await hasProjectBoundaryMarker(root, server))
14823
14990
  return root;
14824
14991
  return this.clients.get(`${server.id}:${nearestAncestor}`)?.root ?? nearestAncestor;
14825
14992
  }
14826
14993
  async withClientSpawnGate(operation) {
14827
14994
  const previous = this.clientSpawnGate;
14828
14995
  let release;
14829
- this.clientSpawnGate = new Promise((resolve8) => {
14830
- release = resolve8;
14996
+ this.clientSpawnGate = new Promise((resolve7) => {
14997
+ release = resolve7;
14831
14998
  });
14832
14999
  await previous;
14833
15000
  try {
@@ -15378,6 +15545,8 @@ var ClientRegistry = class {
15378
15545
  // #4764: the declared role travels with the client, so a failed server
15379
15546
  // config can gate an auxiliary scanner's empty publications only.
15380
15547
  role: server.role,
15548
+ // #5131 round 2: the config-declared flag gates the echo hold.
15549
+ custom: server.custom,
15381
15550
  onDiagnosticsPublished: (serverId) => {
15382
15551
  this.hooks.noteDiagnosticsPublished(serverId);
15383
15552
  }
@@ -15747,8 +15916,9 @@ function admitPackageName(names, name) {
15747
15916
  }
15748
15917
  function declaredPackageNames(startDir) {
15749
15918
  const names = /* @__PURE__ */ new Set();
15750
- let dir = path15.resolve(startDir);
15751
- for (let level = 0; level < ENV_NODE_MODULES_WALK_MAX_LEVELS; level++) {
15919
+ for (const dir of walkUpDirs(startDir, {
15920
+ maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
15921
+ })) {
15752
15922
  try {
15753
15923
  const manifest = JSON.parse(fs12.readFileSync(path15.join(dir, "package.json"), "utf8"));
15754
15924
  for (const field of DECLARING_FIELDS) {
@@ -15767,10 +15937,6 @@ function declaredPackageNames(startDir) {
15767
15937
  }
15768
15938
  } catch {
15769
15939
  }
15770
- const parent = path15.dirname(dir);
15771
- if (parent === dir)
15772
- break;
15773
- dir = parent;
15774
15940
  }
15775
15941
  return names;
15776
15942
  }
@@ -15796,8 +15962,11 @@ function environmentGapKind(diagnostic) {
15796
15962
  return name !== void 0 && NODE_GLOBALS.has(name) ? { code } : void 0;
15797
15963
  }
15798
15964
  function hasResolvableNodeModules(startDir, stat3 = (candidate) => fs12.statSync(candidate)) {
15799
- let dir = path15.resolve(startDir);
15800
- for (let level = 0; level < ENV_NODE_MODULES_WALK_MAX_LEVELS; level++) {
15965
+ let last;
15966
+ for (const dir of walkUpDirs(startDir, {
15967
+ maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
15968
+ })) {
15969
+ last = dir;
15801
15970
  try {
15802
15971
  stat3(path15.join(dir, "node_modules"));
15803
15972
  return true;
@@ -15806,12 +15975,8 @@ function hasResolvableNodeModules(startDir, stat3 = (candidate) => fs12.statSync
15806
15975
  return true;
15807
15976
  }
15808
15977
  }
15809
- const parent = path15.dirname(dir);
15810
- if (parent === dir)
15811
- return false;
15812
- dir = parent;
15813
15978
  }
15814
- return true;
15979
+ return last === void 0 || path15.dirname(last) !== last;
15815
15980
  }
15816
15981
  function demoteEnvironmentGapDiagnostics(diagnostics, options) {
15817
15982
  const candidates = /* @__PURE__ */ new Map();
@@ -15822,7 +15987,7 @@ function demoteEnvironmentGapDiagnostics(diagnostics, options) {
15822
15987
  }
15823
15988
  if (candidates.size === 0)
15824
15989
  return diagnostics;
15825
- const startDir = options.startDir ?? path15.dirname(options.filePath);
15990
+ const startDir = options.startDir ?? path15.dirname(realpathOrResolve(options.filePath));
15826
15991
  if (hasResolvableNodeModules(startDir, options.stat))
15827
15992
  return diagnostics;
15828
15993
  let declared;
@@ -15889,13 +16054,13 @@ function isTsProjectFile(filePath) {
15889
16054
  return TS_PROJECT_EXTENSIONS.has(path16.extname(filePath).toLowerCase());
15890
16055
  }
15891
16056
  function suggestTsconfigInclude(filePath, cwd) {
15892
- const relative3 = toProjectRelativePath(filePath, cwd);
15893
- if (path16.posix.isAbsolute(relative3) || /^[A-Za-z]:/.test(relative3)) {
15894
- const dir = relative3.slice(0, relative3.lastIndexOf("/"));
15895
- return dir ? `${dir}/**` : relative3;
16057
+ const relative2 = toProjectRelativePath(filePath, cwd);
16058
+ if (path16.posix.isAbsolute(relative2) || /^[A-Za-z]:/.test(relative2)) {
16059
+ const dir = relative2.slice(0, relative2.lastIndexOf("/"));
16060
+ return dir ? `${dir}/**` : relative2;
15896
16061
  }
15897
- const segments = relative3.split("/").filter(Boolean);
15898
- return segments.length > 1 ? `${segments[0]}/**` : relative3;
16062
+ const segments = relative2.split("/").filter(Boolean);
16063
+ return segments.length > 1 ? `${segments[0]}/**` : relative2;
15899
16064
  }
15900
16065
  function inferredProjectNotice(filePath, cwd) {
15901
16066
  return `[${INFERRED_PROJECT_MARKER}; add ${suggestTsconfigInclude(filePath, cwd)} to a tsconfig for authoritative checking]`;
@@ -16027,7 +16192,7 @@ function createLazyImport(load) {
16027
16192
  }
16028
16193
 
16029
16194
  // dist/clients/lsp-lazy.js
16030
- var lazyLsp = createLazyImport(() => import("./chunk-2F47TQOA.js"));
16195
+ var lazyLsp = createLazyImport(() => import("./chunk-ZONZ6YY3.js"));
16031
16196
  function warmLspService() {
16032
16197
  return lazyLsp.get();
16033
16198
  }
@@ -16210,12 +16375,23 @@ var DIAGNOSTICS_SEMANTIC_SETTLE_THRESHOLD_MS = Math.max(0, Number.parseInt(proce
16210
16375
  var DIAGNOSTICS_SEMANTIC_SETTLE_WAIT_MS = Math.max(0, Number.parseInt(process.env.PI_LENS_LSP_DIAGNOSTICS_SEMANTIC_SETTLE_MS ?? "400", 10) || 400);
16211
16376
  var EARLY_UNBLOCK_GRACE_MS = Math.max(0, Number.parseInt(process.env.PI_LENS_LSP_EARLY_UNBLOCK_GRACE_MS ?? "400", 10) || 400);
16212
16377
  function unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath) {
16213
- if (spawned.some((entry) => !isAuxiliary(entry.info)))
16214
- return { serverIds: [], disabledServerIds: [], cause: "unstarted" };
16215
16378
  const { disabledServerIds, fallbackServerIds } = disabledPrimaries(filePath);
16216
- const serverIds = [
16217
- .../* @__PURE__ */ new Set([...resolvedPrimaryRoots.keys(), ...disabledServerIds])
16218
- ];
16379
+ const standIns = new Set(fallbackServerIds);
16380
+ const acquired = /* @__PURE__ */ new Set();
16381
+ for (const entry of spawned) {
16382
+ if (isAuxiliary(entry.info))
16383
+ continue;
16384
+ if (entry.info.fallbackFor === void 0 || standIns.has(entry.info.id))
16385
+ return { serverIds: [], disabledServerIds: [], cause: "unstarted" };
16386
+ acquired.add(entry.info.id);
16387
+ }
16388
+ const missing = /* @__PURE__ */ new Set();
16389
+ for (const id of resolvedPrimaryRoots.keys())
16390
+ if (!acquired.has(id))
16391
+ missing.add(id);
16392
+ for (const id of disabledServerIds)
16393
+ missing.add(id);
16394
+ const serverIds = [...missing];
16219
16395
  return {
16220
16396
  serverIds,
16221
16397
  disabledServerIds,
@@ -16300,7 +16476,7 @@ function getMaxWorkspaceDiagnosticFiles() {
16300
16476
  }
16301
16477
  async function collectWorkspaceDiagnosticFiles(root, maxFiles = getMaxWorkspaceDiagnosticFiles(), signal, homeDir) {
16302
16478
  const files2 = [];
16303
- if (isAtOrAboveHomeDir(root, homeDir))
16479
+ if (isAtOrAboveHomeDir(realpathOrResolve(root), realpathOrResolve(homeDir ?? os2.homedir())))
16304
16480
  return files2;
16305
16481
  const ignoreMatcher = getProjectIgnoreMatcher(root);
16306
16482
  await ignoreMatcher.ensureTrackedIndex();
@@ -16344,13 +16520,22 @@ async function collectWorkspaceDiagnosticFiles(root, maxFiles = getMaxWorkspaceD
16344
16520
  }
16345
16521
  var LSPService = class _LSPService {
16346
16522
  static MAX_SIBLING_ANNOUNCEMENTS = 1024;
16523
+ static MAX_UNHELD_STAMPS = 4096;
16347
16524
  state;
16525
+ /**
16526
+ * #4532 gap 13: per path no live client holds open, the content stamp it
16527
+ * had when this service last brought its live servers' view up to date.
16528
+ * Two writers, one meaning: the check (`unheldBytesMoved`) and every
16529
+ * watched-files event this service sends (`noteUnheldSent`). Dropped with
16530
+ * the service; an evicted path is read as one seen for the first time.
16531
+ */
16532
+ unheldStamps = new BoundedFifoMap(_LSPService.MAX_UNHELD_STAMPS);
16348
16533
  /** Content hashes already announced to a sibling root in this service. */
16349
16534
  siblingAnnouncementHashes = new BoundedFifoMap(_LSPService.MAX_SIBLING_ANNOUNCEMENTS);
16350
16535
  /**
16351
16536
  * One first-contact diagnostic wait per custom server in this service
16352
16537
  * generation. Concurrent touches share the probe; a hook cutoff never arms
16353
- * the navigation-only latch, so the next touch can try again.
16538
+ * the diagnostics-unsupported latch, so the next touch can try again.
16354
16539
  */
16355
16540
  firstContactWaits = /* @__PURE__ */ new Map();
16356
16541
  /** Session-scoped adaptive demotion for budget-hitting auxiliaries. */
@@ -16529,6 +16714,7 @@ var LSPService = class _LSPService {
16529
16714
  },
16530
16715
  noteDiagnosticsPublished: (serverId) => {
16531
16716
  this.state.diagnosticsPublished.add(serverId);
16717
+ this.state.diagnosticsUnsupported.delete(serverId);
16532
16718
  }
16533
16719
  }, generationHandoff, sessionCwd);
16534
16720
  this.state = {
@@ -16543,6 +16729,25 @@ var LSPService = class _LSPService {
16543
16729
  diagnosticsUnsupported: /* @__PURE__ */ new Set()
16544
16730
  };
16545
16731
  }
16732
+ /**
16733
+ * Latch a custom push-only server diagnostics-unsupported after silence
16734
+ * through its first-contact wait. The one writer of the latch, so `published`
16735
+ * implies `!unsupported` holds at the add as well as at the publish (#5128):
16736
+ * a publish for another file that landed during this file's wait proves the
16737
+ * server pushes, so the silence is a timeout and no latch is set. Returns
16738
+ * whether the server is now latched.
16739
+ */
16740
+ latchDiagnosticsUnsupported(serverId) {
16741
+ if (this.state.diagnosticsPublished.has(serverId))
16742
+ return false;
16743
+ this.state.diagnosticsUnsupported.add(serverId);
16744
+ recordDegradationOnce({
16745
+ kind: "lsp-diagnostics-unsupported",
16746
+ subject: serverId,
16747
+ reason: "custom server has no pull provider and no publish evidence after first contact wait"
16748
+ });
16749
+ return true;
16750
+ }
16546
16751
  isAuxiliaryWaitDemoted(serverId, root) {
16547
16752
  return this.demotedAuxiliaryServerIds.has(`${serverId}:${normalizeMapKey(root ?? "")}`);
16548
16753
  }
@@ -16607,7 +16812,7 @@ var LSPService = class _LSPService {
16607
16812
  return Promise.resolve();
16608
16813
  }
16609
16814
  this.announceCreatedFiles([filePath]);
16610
- return Promise.all(getServersForFileWithConfig(filePath).map((server) => this.clientRegistry.resolveServerRoot(server, filePath).then((root) => {
16815
+ return Promise.all(this.serversWithLiveReaderRoots(filePath).map((server) => this.clientRegistry.resolveServerRoot(server, filePath).then((root) => {
16611
16816
  if (!root)
16612
16817
  return false;
16613
16818
  const ownKey = `${server.id}:${normalizeMapKey(root)}`;
@@ -16616,6 +16821,26 @@ var LSPService = class _LSPService {
16616
16821
  this.siblingAnnouncementHashes.set(normalizedPath, contentHash2);
16617
16822
  });
16618
16823
  }
16824
+ /**
16825
+ * #4956 F1: the servers a per-file reader that acts only on LIVE clients (or
16826
+ * on a root decision a session already made) walks. An opt-in auxiliary
16827
+ * (`enabledByDefault: false`) joins every JS/TS candidate list whether or not
16828
+ * the operator turned it on, and each reader below resolves a root per
16829
+ * server (a `NearestRoot` walk; negatives are never cached), so a server
16830
+ * nobody started would add that walk to every touch of every file. It is
16831
+ * walked only while this service holds a client for it, which is the only
16832
+ * state in which these readers can find anything to act on.
16833
+ */
16834
+ serversWithLiveReaderRoots(filePath) {
16835
+ return getServersForFileWithConfig(filePath).flatMap((server) => !isOptInAuxiliaryServerId(server.id) || this.holdsClientForServer(server.id) ? [server] : []);
16836
+ }
16837
+ holdsClientForServer(serverId) {
16838
+ const prefix = `${serverId}:`;
16839
+ for (const key of this.state.clients.keys())
16840
+ if (key.startsWith(prefix))
16841
+ return true;
16842
+ return false;
16843
+ }
16619
16844
  notifyLiveClientsForServer(serverId, filePath, type, ownKey, includeOwn) {
16620
16845
  let notified = false;
16621
16846
  const prefix = `${serverId}:`;
@@ -17341,8 +17566,8 @@ var LSPService = class _LSPService {
17341
17566
  return { outstandingMs: 0 };
17342
17567
  }
17343
17568
  let resolveSettled;
17344
- const settled = new Promise((resolve8) => {
17345
- resolveSettled = resolve8;
17569
+ const settled = new Promise((resolve7) => {
17570
+ resolveSettled = resolve7;
17346
17571
  });
17347
17572
  const token = {
17348
17573
  startedAt: Date.now(),
@@ -17431,7 +17656,8 @@ var LSPService = class _LSPService {
17431
17656
  const attached = new Set(spawned.map((entry) => entry.info.id));
17432
17657
  const brokenSkippedServerIds = [];
17433
17658
  const policySkippedServerIds = [];
17434
- for (const server of getServersForFileWithConfig(filePath)) {
17659
+ const candidates = enabledAuxiliaries ? getServersForFileWithConfig(filePath) : aggregateServersForFile(filePath);
17660
+ for (const server of candidates) {
17435
17661
  if (!isAuxiliary(server))
17436
17662
  continue;
17437
17663
  if (attached.has(server.id))
@@ -17555,8 +17781,8 @@ var LSPService = class _LSPService {
17555
17781
  const effectiveMaxWaitMs = hardCapMs !== void 0 ? serverBaseMs > 0 ? Math.min(serverBaseMs, hardCapMs) : hardCapMs : serverBaseMs;
17556
17782
  let knownSlowResolve;
17557
17783
  const knownSlowSentinel = /* @__PURE__ */ Symbol("lsp-client-wait-known-slow");
17558
- const knownSlow = new Promise((resolve8) => {
17559
- knownSlowResolve = () => resolve8(knownSlowSentinel);
17784
+ const knownSlow = new Promise((resolve7) => {
17785
+ knownSlowResolve = () => resolve7(knownSlowSentinel);
17560
17786
  });
17561
17787
  const noteSpawnInFlight = (serverId) => {
17562
17788
  const knownDurationMs = getSuccessfulLspSpawnDurationMs(serverId);
@@ -17647,8 +17873,8 @@ var LSPService = class _LSPService {
17647
17873
  waitResult = await Promise.race([
17648
17874
  withBudget(),
17649
17875
  knownSlow,
17650
- new Promise((resolve8) => {
17651
- waitTimer = setTimeout(() => resolve8(timeoutSentinel), effectiveMaxWaitMs);
17876
+ new Promise((resolve7) => {
17877
+ waitTimer = setTimeout(() => resolve7(timeoutSentinel), effectiveMaxWaitMs);
17652
17878
  })
17653
17879
  ]);
17654
17880
  } finally {
@@ -17731,15 +17957,15 @@ var LSPService = class _LSPService {
17731
17957
  * aggregate diagnostics pass must not launch them beside a working preferred
17732
17958
  * server merely because it requested `clientScope: "all"`.
17733
17959
  */
17734
- async getClientsForFile(filePath, excludeServerIds, resolvedRoots, auxiliaryRoots) {
17735
- const allServers = getServersForFileWithConfig(filePath);
17960
+ async getClientsForFile(filePath, excludeServerIds, resolvedRoots, auxiliaryRoots, syncOnly = false) {
17961
+ const allServers = syncOnly ? this.serversWithLiveReaderRoots(filePath) : aggregateServersForFile(filePath);
17736
17962
  const servers = excludeServerIds && excludeServerIds.size > 0 ? allServers.filter((s) => !excludeServerIds.has(s.id)) : allServers;
17737
17963
  if (servers.length === 0)
17738
17964
  return { clients: [], serverCountAttempted: 0 };
17739
17965
  const rootedServers = (await Promise.all(servers.map(async (server) => ({
17740
17966
  server,
17741
17967
  root: await this.clientRegistry.resolveServerRoot(server, filePath)
17742
- })))).filter((entry) => entry.root !== void 0);
17968
+ })))).filter((entry) => entry.root !== void 0 && (!isOptInAuxiliaryServerId(entry.server.id) || this.state.clients.get(`${entry.server.id}:${normalizeMapKey(entry.root)}`)?.isAlive() === true));
17743
17969
  for (const { server, root } of rootedServers)
17744
17970
  if (isAuxiliary(server))
17745
17971
  auxiliaryRoots?.set(server.id, normalizeMapKey(root));
@@ -17793,7 +18019,7 @@ var LSPService = class _LSPService {
17793
18019
  async getWarmClientForFile(filePath) {
17794
18020
  if (this.checkDestroyed())
17795
18021
  return void 0;
17796
- const servers = getServersForFileWithConfig(filePath);
18022
+ const servers = this.serversWithLiveReaderRoots(filePath);
17797
18023
  const missed = [];
17798
18024
  for (const server of servers) {
17799
18025
  const root = await this.clientRegistry.resolveServerRoot(server, filePath);
@@ -17915,7 +18141,7 @@ var LSPService = class _LSPService {
17915
18141
  async notifyExternalFileChange(filePath, type) {
17916
18142
  if (this.checkDestroyed())
17917
18143
  return;
17918
- for (const server of getServersForFileWithConfig(filePath)) {
18144
+ for (const server of this.serversWithLiveReaderRoots(filePath)) {
17919
18145
  const root = await this.clientRegistry.resolveServerRoot(server, filePath);
17920
18146
  if (!root)
17921
18147
  continue;
@@ -17934,13 +18160,43 @@ var LSPService = class _LSPService {
17934
18160
  notifyOutOfBandFileChanges(changes) {
17935
18161
  if (this.checkDestroyed() || changes.length === 0)
17936
18162
  return;
17937
- for (const { filePath, type } of changes)
17938
- for (const server of getServersForFileWithConfig(filePath))
17939
- this.notifyLiveClientsForServer(server.id, filePath, type, "", true);
18163
+ for (const { filePath, type } of changes) {
18164
+ const serverIds = /* @__PURE__ */ new Set([
18165
+ ...serverIdsForConfigFile(filePath) ?? [],
18166
+ ...getServersForFileWithConfig(filePath).map((server) => server.id)
18167
+ ]);
18168
+ for (const serverId of serverIds)
18169
+ this.notifyLiveClientsForServer(serverId, filePath, type, "", true);
18170
+ this.noteUnheldSent(filePath);
18171
+ }
17940
18172
  for (const client of this.state.clients.values())
17941
18173
  if (client.isAlive())
17942
18174
  client.notify.flushWatched?.();
17943
18175
  }
18176
+ /**
18177
+ * #4532 gap 13: an event sent for `filePath` brought its live servers' view
18178
+ * up to date, so its {@link unheldStamps} record moves to the stat now (the
18179
+ * bytes hash is kept when the stat is the one already recorded), or goes
18180
+ * with the file (a Deleted event, or a path that cannot be statted). Without this, a sender that announces after it notifies
18181
+ * (#4742's head-move phase) had each path sent twice.
18182
+ */
18183
+ noteUnheldSent(filePath) {
18184
+ const key = normalizeMapKey(filePath);
18185
+ let stat3;
18186
+ try {
18187
+ stat3 = nodeFs2.statSync(filePath, { throwIfNoEntry: false });
18188
+ } catch {
18189
+ stat3 = void 0;
18190
+ }
18191
+ if (stat3 === void 0) {
18192
+ this.unheldStamps.delete(key);
18193
+ return;
18194
+ }
18195
+ const seen = this.unheldStamps.get(key);
18196
+ if (seen?.size === stat3.size && seen.mtimeMs === stat3.mtimeMs)
18197
+ return;
18198
+ this.unheldStamps.set(key, { size: stat3.size, mtimeMs: stat3.mtimeMs });
18199
+ }
17944
18200
  /**
17945
18201
  * #4476: restart the live primary clients whose root overlaps `root` after
17946
18202
  * a dependency install there (see `ClientRegistry.restartPrimaryClientsUnder`).
@@ -17972,12 +18228,20 @@ var LSPService = class _LSPService {
17972
18228
  * workspace sweep (which looks every file up before it touches any), is
17973
18229
  * answered from cache, or by a server that has not heard of the module yet.
17974
18230
  * Each client decides which entries are new to it (`watchedTypeForExisting`).
18231
+ *
18232
+ * #4532 gap 13: `importTargets`, the files the caller's targets import
18233
+ * directly (`importTargetsToAnnounce`), are announced too, and first each
18234
+ * one whose bytes moved since its servers last saw them goes out as Changed
18235
+ * (`sendUnheldChanges`), so a module changed outside pi is re-read before
18236
+ * the importer's answer. Only import targets are checked: a sweep's own
18237
+ * file list (up to 5000) would churn the check's record (#4926 review F2).
17975
18238
  */
17976
- announceCreatedFiles(filePaths) {
18239
+ announceCreatedFiles(filePaths, importTargets = []) {
17977
18240
  if (this.checkDestroyed() || this.state.clients.size === 0)
17978
18241
  return;
18242
+ this.sendUnheldChanges(importTargets);
17979
18243
  const byServer = /* @__PURE__ */ new Map();
17980
- for (const filePath of filePaths) {
18244
+ for (const filePath of [...filePaths, ...importTargets]) {
17981
18245
  let stat3;
17982
18246
  try {
17983
18247
  stat3 = nodeFs2.statSync(filePath);
@@ -17997,6 +18261,112 @@ var LSPService = class _LSPService {
17997
18261
  client.notify.announceCreated(entries);
17998
18262
  }
17999
18263
  }
18264
+ /**
18265
+ * #4532 gap 13: send Changed, now, for each of `filePaths` that no live
18266
+ * client holds open and whose bytes moved since its live servers last saw
18267
+ * them ({@link unheldBytesMoved}), before the caller's read. Each such path
18268
+ * is also noted as changed on disk under the root of every live client of
18269
+ * its servers, the record #4476 writes for a change seen on disk: a cached
18270
+ * answer whose dependency scope holds the path is refused, and a touch
18271
+ * debounced before the change pushes again.
18272
+ */
18273
+ sendUnheldChanges(filePaths) {
18274
+ const changed = [];
18275
+ const at = Date.now();
18276
+ for (const filePath of filePaths) {
18277
+ let stat3;
18278
+ try {
18279
+ stat3 = nodeFs2.statSync(filePath);
18280
+ } catch {
18281
+ continue;
18282
+ }
18283
+ const servers = getServersForFileWithConfig(filePath);
18284
+ if (!this.unheldBytesMoved(filePath, stat3, servers))
18285
+ continue;
18286
+ changed.push({ filePath, type: FILE_CHANGED });
18287
+ for (const client of this.liveClientsOf(servers, filePath))
18288
+ noteWorkspaceFilesChangedOnDisk(client.root, [normalizeMapKey(filePath)], at);
18289
+ }
18290
+ if (changed.length === 0)
18291
+ return;
18292
+ this.notifyOutOfBandFileChanges(changed);
18293
+ logLatency({
18294
+ type: "phase",
18295
+ phase: "lsp_unheld_dependency_changed",
18296
+ filePath: changed[0]?.filePath ?? "",
18297
+ durationMs: Date.now() - at,
18298
+ result: `changed:${changed.length}`,
18299
+ metadata: {
18300
+ changed: changed.length,
18301
+ paths: changed.slice(0, 5).map((change) => change.filePath)
18302
+ }
18303
+ });
18304
+ }
18305
+ /**
18306
+ * #4532 gap 13: whether `filePath`, which no live client holds open, has
18307
+ * bytes a live server of its may not have read. A server keeps the bytes of
18308
+ * a closed module it read for an importer and re-reads them only when a
18309
+ * watched-files event names the file (pyright 1.1.414, measured), so a
18310
+ * module changed outside pi left its importer's answer stale for the
18311
+ * server's life, on the first call and every call after it.
18312
+ *
18313
+ * The record ({@link unheldStamps}) is the content stamp the path had when
18314
+ * this service last brought its live servers' view up to date. An equal
18315
+ * stat is unchanged; a moved stat is read and compared by its bytes, so a
18316
+ * rewrite of the same bytes sends nothing. A path seen for the first time
18317
+ * has no record to compare, so its bytes take the client-start rule a
18318
+ * birth takes ({@link watchedTypeForOpen}, #4320): bytes written at or
18319
+ * after a live server of the path started (less the margin) may be newer
18320
+ * than the bytes that server read, and older ones are what it read. A path every
18321
+ * live client holds is skipped: the open-document sync keeps those views
18322
+ * current. One that some client reads closed is compared and sent, and a
18323
+ * holder's copy of the event is redundant, since its open document wins.
18324
+ */
18325
+ unheldBytesMoved(filePath, stat3, servers) {
18326
+ const live = this.liveClientsOf(servers, filePath);
18327
+ if (live.every((client) => client.holds))
18328
+ return false;
18329
+ const key = normalizeMapKey(filePath);
18330
+ const seen = this.unheldStamps.get(key);
18331
+ if (seen?.size === stat3.size && seen.mtimeMs === stat3.mtimeMs)
18332
+ return false;
18333
+ let stamp = { size: stat3.size, mtimeMs: stat3.mtimeMs };
18334
+ if (stat3.size <= CONTENT_HASH_MAX_BYTES) {
18335
+ try {
18336
+ stamp = stampContentBytes(nodeFs2.readFileSync(filePath), stat3.mtimeMs);
18337
+ } catch (cause) {
18338
+ recordDegradationOnce({
18339
+ kind: "lsp-unheld-dependency-unreadable",
18340
+ subject: key,
18341
+ reason: `could not read a closed module to compare its bytes; a change of its stat is sent as a change: ${cause instanceof Error ? cause.message : String(cause)}`
18342
+ });
18343
+ }
18344
+ }
18345
+ this.unheldStamps.set(key, stamp);
18346
+ if (seen === void 0)
18347
+ return live.some((client) => watchedTypeForOpen(stat3.mtimeMs, client.launchedAt) === FILE_CREATED);
18348
+ return seen.sha256 === void 0 || seen.sha256 !== stamp.sha256;
18349
+ }
18350
+ /**
18351
+ * The live clients of `servers`, each with its root, the launch epoch from
18352
+ * which that server could read a project file, and whether it holds
18353
+ * `filePath` open.
18354
+ */
18355
+ liveClientsOf(servers, filePath) {
18356
+ const live = [];
18357
+ for (const [key, client] of this.state.clients) {
18358
+ if (!client.isAlive())
18359
+ continue;
18360
+ if (!servers.some((server) => key.startsWith(`${server.id}:`)))
18361
+ continue;
18362
+ live.push({
18363
+ root: client.root,
18364
+ launchedAt: this.clientRegistry.clientLaunchStartedAt.get(key) ?? 0,
18365
+ holds: documentIsOpenOn(client, filePath)
18366
+ });
18367
+ }
18368
+ return live;
18369
+ }
18000
18370
  /**
18001
18371
  * #4493 r2: push the disk bytes of `filePaths` to the PRIMARY servers that
18002
18372
  * already hold them, and to no auxiliary. A HEAD move's resync runs this
@@ -18115,7 +18485,7 @@ var LSPService = class _LSPService {
18115
18485
  const changed = /* @__PURE__ */ new Map();
18116
18486
  for (const changedPath of changedPaths) {
18117
18487
  const resolved2 = path17.resolve(changedPath);
18118
- for (const server of getServersForFileWithConfig(resolved2)) {
18488
+ for (const server of this.serversWithLiveReaderRoots(resolved2)) {
18119
18489
  const root = await this.clientRegistry.resolveServerRoot(server, resolved2);
18120
18490
  if (!root)
18121
18491
  continue;
@@ -18191,6 +18561,8 @@ var LSPService = class _LSPService {
18191
18561
  return void 0;
18192
18562
  return this.documentDrift.sweep({
18193
18563
  resync: async (filePath, content, _driftAgeMs, readStamp, saved) => {
18564
+ if (exceedsLspSyncLimits(content).tooLarge)
18565
+ return false;
18194
18566
  await this.touchFile(filePath, content, {
18195
18567
  diagnostics: "none",
18196
18568
  source: "drift_resync",
@@ -18262,7 +18634,7 @@ var LSPService = class _LSPService {
18262
18634
  */
18263
18635
  async serverIdsNotHoldingDocument(filePath) {
18264
18636
  const exclude = /* @__PURE__ */ new Set();
18265
- for (const server of getServersForFileWithConfig(filePath)) {
18637
+ for (const server of this.serversWithLiveReaderRoots(filePath)) {
18266
18638
  const root = await this.clientRegistry.resolveServerRoot(server, filePath);
18267
18639
  const existing = root ? this.state.clients.get(`${server.id}:${normalizeMapKey(root)}`) : void 0;
18268
18640
  if (existing?.isAlive() && documentIsOpenOn(existing, filePath))
@@ -18378,7 +18750,7 @@ var LSPService = class _LSPService {
18378
18750
  let spawned;
18379
18751
  let serverCountAttempted;
18380
18752
  if (useAllClients) {
18381
- const result = await this.getClientsForFile(filePath, options.excludeServerIds, resolvedPrimaryRoots, attemptedAuxiliaryRoots);
18753
+ const result = await this.getClientsForFile(filePath, options.excludeServerIds, resolvedPrimaryRoots, attemptedAuxiliaryRoots, diagnosticsMode === "none");
18382
18754
  spawned = result.clients;
18383
18755
  serverCountAttempted = result.serverCountAttempted;
18384
18756
  } else if (clientScope === "with-auxiliary") {
@@ -18804,41 +19176,17 @@ var LSPService = class _LSPService {
18804
19176
  return waitForDiagnostics().catch(() => void 0);
18805
19177
  let shared = this.firstContactWaits.get(entry.info.id);
18806
19178
  if (!shared) {
18807
- let removeShutdownListener;
18808
- const shutdown = new Promise((resolve8) => {
18809
- const onShutdown = () => resolve8("shutdown");
18810
- if (this.shutdownController.signal.aborted) {
18811
- onShutdown();
18812
- return;
18813
- }
18814
- this.shutdownController.signal.addEventListener("abort", onShutdown, {
18815
- once: true
18816
- });
18817
- removeShutdownListener = () => this.shutdownController.signal.removeEventListener("abort", onShutdown);
18818
- });
18819
- const probe = Promise.race([
18820
- waitForDiagnostics().then(() => "completed", () => "errored"),
18821
- shutdown
18822
- ]);
18823
- const completed = withDeadline(probe, {
18824
- ms: serverTimeout,
18825
- onTimeout: "undefined"
18826
- });
19179
+ const probe = waitForDiagnostics().then(() => "completed", () => "errored");
19180
+ const completed = withDeadline(untilAborted(probe, this.shutdownController.signal, "shutdown"), { ms: serverTimeout, onTimeout: "undefined" });
18827
19181
  shared = completed.then((outcome) => {
18828
19182
  if (outcome === "errored" || outcome === "shutdown") {
18829
19183
  return "errored";
18830
19184
  }
18831
19185
  if (answeredForThisTouch(entry))
18832
19186
  return "answered";
18833
- this.state.diagnosticsUnsupported.add(entry.info.id);
18834
- recordDegradationOnce({
18835
- kind: "lsp-diagnostics-unsupported",
18836
- subject: entry.info.id,
18837
- reason: "custom server has no pull provider and no publish evidence after first contact wait"
18838
- });
19187
+ this.latchDiagnosticsUnsupported(entry.info.id);
18839
19188
  return "silent";
18840
19189
  }).catch(() => "errored").finally(() => {
18841
- removeShutdownListener?.();
18842
19190
  if (this.firstContactWaits.get(entry.info.id) === shared) {
18843
19191
  this.firstContactWaits.delete(entry.info.id);
18844
19192
  }
@@ -18893,8 +19241,8 @@ var LSPService = class _LSPService {
18893
19241
  };
18894
19242
  }
18895
19243
  let timer;
18896
- const timeout = new Promise((resolve8) => {
18897
- timer = setTimeout(() => resolve8(false), budgetMs);
19244
+ const timeout = new Promise((resolve7) => {
19245
+ timer = setTimeout(() => resolve7(false), budgetMs);
18898
19246
  if (typeof timer === "object" && "unref" in timer) {
18899
19247
  timer.unref?.();
18900
19248
  }
@@ -18992,8 +19340,8 @@ var LSPService = class _LSPService {
18992
19340
  const graceMs = readTsserverSyncGraceMs();
18993
19341
  const primaryClient = spawned[0].client;
18994
19342
  const syncRacer = (async () => {
18995
- await new Promise((resolve8) => {
18996
- const timer = setTimeout(resolve8, graceMs);
19343
+ await new Promise((resolve7) => {
19344
+ const timer = setTimeout(resolve7, graceMs);
18997
19345
  timer.unref?.();
18998
19346
  });
18999
19347
  const publishedAt = primaryClient.getAllDiagnostics?.().get(normalizedPath)?.ts;
@@ -19029,13 +19377,9 @@ var LSPService = class _LSPService {
19029
19377
  const entry = spawned.find((candidate) => candidate.info.id === serverId);
19030
19378
  if (!entry || answeredForThisTouch(entry))
19031
19379
  continue;
19032
- this.state.diagnosticsUnsupported.add(serverId);
19380
+ if (!this.latchDiagnosticsUnsupported(serverId))
19381
+ continue;
19033
19382
  diagnosticsUnsupportedServerIds.push(serverId);
19034
- recordDegradationOnce({
19035
- kind: "lsp-diagnostics-unsupported",
19036
- subject: serverId,
19037
- reason: "custom server has no pull provider and no publish evidence after first contact wait"
19038
- });
19039
19383
  }
19040
19384
  for (const entry of spawned) {
19041
19385
  if (entry.info.custom === true && this.state.diagnosticsUnsupported.has(entry.info.id)) {
@@ -19182,6 +19526,13 @@ var LSPService = class _LSPService {
19182
19526
  ...uncoveredDeferredServerIds,
19183
19527
  ...staleWriteAuxiliaryServerIds
19184
19528
  ]);
19529
+ const answerAtMerge = options.collectDiagnostics ? new Map(spawned.map((entry) => [
19530
+ entry.client,
19531
+ {
19532
+ pathVersion: readPathVersion(entry.client),
19533
+ publishedAt: entry.client.getDiagnosticsPublishedAt?.(filePath)
19534
+ }
19535
+ ])) : void 0;
19185
19536
  let collected = options.collectDiagnostics ? tsserverSyncConfirmed !== void 0 ? mergeLspDiagnostics(attributeDiagnostics(spawned[0]?.info.id ?? "unknown", tsserverSyncConfirmed)) : mergeLspDiagnostics([
19186
19537
  // #1459: a DEFERRED server's cache still holds the PREVIOUS
19187
19538
  // content's findings — the resync that would have cleared it never
@@ -19407,6 +19758,27 @@ var LSPService = class _LSPService {
19407
19758
  );
19408
19759
  result.binding = binding;
19409
19760
  }
19761
+ if (collected !== void 0 && !syncConfirmed) {
19762
+ let reusedAnswer;
19763
+ for (const entry of spawned) {
19764
+ if (isAuxiliary(entry.info))
19765
+ continue;
19766
+ if (notifyWriteTimedOutServerIds.includes(entry.info.id))
19767
+ continue;
19768
+ const versionBeforeTouch = diagnosticBaselines.get(entry.client);
19769
+ const merged = answerAtMerge?.get(entry.client);
19770
+ if (versionBeforeTouch !== void 0 && merged?.pathVersion !== void 0 && merged.pathVersion > versionBeforeTouch)
19771
+ continue;
19772
+ const publishedAt = merged?.publishedAt;
19773
+ if (publishedAt === void 0)
19774
+ continue;
19775
+ if (reusedAnswer === void 0 || publishedAt < reusedAnswer.publishedAt) {
19776
+ reusedAnswer = { serverId: entry.info.id, publishedAt };
19777
+ }
19778
+ }
19779
+ if (reusedAnswer)
19780
+ result.reusedAnswer = reusedAnswer;
19781
+ }
19410
19782
  const lateDeliveryPending = unconfirmedServerIds.filter((serverId) => (lateDeliveryServerIds ?? []).includes(serverId));
19411
19783
  if (lateDeliveryPending.length > 0) {
19412
19784
  result.deferredServerIds = lateDeliveryPending;
@@ -19525,7 +19897,7 @@ var LSPService = class _LSPService {
19525
19897
  return void 0;
19526
19898
  if (this.clientRegistry.analysisRootModeForFile(filePath) === "adopted")
19527
19899
  return void 0;
19528
- const candidates = await Promise.all(getServersForFileWithConfig(filePath).map((server) => server.root(filePath)));
19900
+ const candidates = await Promise.all(this.serversWithLiveReaderRoots(filePath).map((server) => server.root(filePath)));
19529
19901
  return candidates.find((candidate) => Boolean(candidate));
19530
19902
  }
19531
19903
  /**
@@ -19610,12 +19982,18 @@ var LSPService = class _LSPService {
19610
19982
  return [];
19611
19983
  }
19612
19984
  const startedAt = Date.now();
19613
- const candidateServerIds = getServersForFileWithConfig(filePath).flatMap((s) => excludeServerIds?.has(s.id) ? [] : [s.id]);
19985
+ const candidateServerIds = aggregateServersForFile(filePath).flatMap((s) => excludeServerIds?.has(s.id) ? [] : [s.id]);
19614
19986
  const resolvedPrimaryRoots = /* @__PURE__ */ new Map();
19615
19987
  const { clients: spawned, serverCountAttempted } = await this.getClientsForFile(filePath, excludeServerIds, resolvedPrimaryRoots);
19616
19988
  if (spawned.length === 0) {
19617
19989
  const stored = this.lastKnownDiagnostics.get(normalizedPath);
19618
- const stale = excludeServerIds !== void 0 && excludeServerIds.size > 0 ? stored?.filter((diagnostic) => !excludeServerIds.has(diagnostic.serverId ?? "")) : stored;
19990
+ const notCandidates = /* @__PURE__ */ new Set();
19991
+ for (const d of stored ?? []) {
19992
+ const id = d.serverId ?? findAuxiliaryProfileForSource(d.source)?.serverId;
19993
+ if (id && !candidateServerIds.includes(id))
19994
+ notCandidates.add(id);
19995
+ }
19996
+ const stale = stored && dropExcludedServers({ diagnostics: stored }, notCandidates).diagnostics;
19619
19997
  const failureKind2 = stale?.length ? "no_clients_stale" : "no_clients";
19620
19998
  const unanswered2 = unansweredPrimaries(spawned, resolvedPrimaryRoots, filePath);
19621
19999
  const unavailablePrimaryServerIds2 = unanswered2.serverIds;
@@ -20044,7 +20422,7 @@ var LSPService = class _LSPService {
20044
20422
  if (this.checkDestroyed()) {
20045
20423
  return { executed: false, reason: "lsp service destroyed" };
20046
20424
  }
20047
- for (const server of getServersForFileWithConfig(filePath)) {
20425
+ for (const server of this.serversWithLiveReaderRoots(filePath)) {
20048
20426
  const root = await this.clientRegistry.resolveServerRoot(server, filePath);
20049
20427
  if (!root)
20050
20428
  continue;
@@ -20125,7 +20503,7 @@ var LSPService = class _LSPService {
20125
20503
  return [];
20126
20504
  const snapshots = [];
20127
20505
  if (filePath) {
20128
- const servers = getServersForFileWithConfig(filePath);
20506
+ const servers = this.serversWithLiveReaderRoots(filePath);
20129
20507
  for (const server of servers) {
20130
20508
  const root = await this.clientRegistry.resolveServerRoot(server, filePath);
20131
20509
  if (!root)
@@ -20392,8 +20770,8 @@ var LSPService = class _LSPService {
20392
20770
  }
20393
20771
  throw err;
20394
20772
  }
20395
- const relOld = path17.relative(cwd, oldFilePath).replace(/\\/g, "/") || path17.basename(oldFilePath);
20396
- const relNew = path17.relative(cwd, newFilePath).replace(/\\/g, "/") || path17.basename(newFilePath);
20773
+ const relOld = toPosix(path17.relative(cwd, oldFilePath)) || path17.basename(oldFilePath);
20774
+ const relNew = toPosix(path17.relative(cwd, newFilePath)) || path17.basename(newFilePath);
20397
20775
  const renameDescription = `Renamed ${relOld} \u2192 ${relNew}`;
20398
20776
  await Promise.all(activeClients.map(async ({ clientKey, serverId, client }) => {
20399
20777
  if (client.getOperationSupport().didRenameFiles !== true) {
@@ -20703,24 +21081,10 @@ var LSPService = class _LSPService {
20703
21081
  // `warmupAttempt` doc on `LSPTouchFileOptions`.
20704
21082
  warmupAttempt: attempt
20705
21083
  });
20706
- await (options.signal ? Promise.race([
20707
- withDeadline(warmupAttempt, {
20708
- ms: timeoutMs,
20709
- onTimeout: "undefined"
20710
- }),
20711
- new Promise((resolve8) => {
20712
- if (options.signal.aborted) {
20713
- resolve8();
20714
- return;
20715
- }
20716
- options.signal.addEventListener("abort", () => resolve8(), {
20717
- once: true
20718
- });
20719
- })
20720
- ]) : withDeadline(warmupAttempt, {
21084
+ await untilAborted(withDeadline(warmupAttempt, {
20721
21085
  ms: timeoutMs,
20722
21086
  onTimeout: "undefined"
20723
- }));
21087
+ }), options.signal);
20724
21088
  const coldServerIds = stillColdServerIds();
20725
21089
  logLatency({
20726
21090
  type: "phase",
@@ -20742,13 +21106,10 @@ var LSPService = class _LSPService {
20742
21106
  if (failedServerIds.length > 0 && !options.signal?.aborted) {
20743
21107
  const backoffMs = warmupRetryBackoffMs();
20744
21108
  if (backoffMs > 0) {
20745
- await new Promise((resolve8) => {
20746
- const timer = setTimeout(resolve8, backoffMs);
21109
+ await untilAborted(new Promise((resolve7) => {
21110
+ const timer = setTimeout(resolve7, backoffMs);
20747
21111
  timer.unref?.();
20748
- options.signal?.addEventListener("abort", () => resolve8(), {
20749
- once: true
20750
- });
20751
- });
21112
+ }), options.signal);
20752
21113
  }
20753
21114
  if (!options.signal?.aborted) {
20754
21115
  await runWarmupTouch(2);
@@ -20780,6 +21141,10 @@ var LSPService = class _LSPService {
20780
21141
  async runWorkspaceDiagnosticsSwept(cwd, options = {}) {
20781
21142
  const startedAt = Date.now();
20782
21143
  const root = path17.resolve(cwd);
21144
+ const sweepExcludedServerIds = /* @__PURE__ */ new Set([
21145
+ ...WORKSPACE_SWEEP_EXCLUDED_SERVER_IDS,
21146
+ ...options.excludeServerIds ?? []
21147
+ ]);
20783
21148
  const { signal } = options;
20784
21149
  void this.sweepDocumentDrift().catch(() => {
20785
21150
  });
@@ -20795,7 +21160,7 @@ var LSPService = class _LSPService {
20795
21160
  let lastHeartbeat = Date.now();
20796
21161
  const workspaceDiagnosticsCacheCtx = createWorkspaceDiagnosticsCacheContext(root);
20797
21162
  const workspaceSweepScopeKey = buildScopeKey("all", [
20798
- ...WORKSPACE_SWEEP_EXCLUDED_SERVER_IDS
21163
+ ...sweepExcludedServerIds
20799
21164
  ]);
20800
21165
  const touchScopedOpenDependencies = async (filePath) => {
20801
21166
  if (options.files === void 0)
@@ -20828,11 +21193,7 @@ var LSPService = class _LSPService {
20828
21193
  }));
20829
21194
  return !capped;
20830
21195
  };
20831
- this.announceCreatedFiles([
20832
- ...files2,
20833
- ...goPackageFilesToAnnounce(files2),
20834
- ...await importTargetsToAnnounce(root, files2.filter((filePath) => !workspaceDiagnosticsCacheCtx.servesClean(filePath, workspaceSweepScopeKey)), (filePath, scope) => workspaceDiagnosticsCacheCtx.noteImportScope(filePath, scope))
20835
- ]);
21196
+ this.announceCreatedFiles([...files2, ...goPackageFilesToAnnounce(files2)], await importTargetsToAnnounce(root, files2.filter((filePath) => !workspaceDiagnosticsCacheCtx.servesClean(filePath, workspaceSweepScopeKey)), (filePath, scope) => workspaceDiagnosticsCacheCtx.noteImportScope(filePath, scope)));
20836
21197
  const cachedResults = [];
20837
21198
  const filesToTouch = [];
20838
21199
  const writeIndexByPath = /* @__PURE__ */ new Map();
@@ -20913,7 +21274,7 @@ var LSPService = class _LSPService {
20913
21274
  contentCache.set(filePath, content);
20914
21275
  const languageId = getLanguageId2(filePath) ?? "plaintext";
20915
21276
  const preOpenAttempt = withDeadline((async () => {
20916
- const { clients } = await this.getClientsForFile(filePath, WORKSPACE_SWEEP_EXCLUDED_SERVER_IDS);
21277
+ const { clients } = await this.getClientsForFile(filePath, sweepExcludedServerIds);
20917
21278
  for (const entry of clients) {
20918
21279
  let auxKey;
20919
21280
  if (isAuxiliary(entry.info)) {
@@ -20931,18 +21292,7 @@ var LSPService = class _LSPService {
20931
21292
  }
20932
21293
  }
20933
21294
  })(), { ms: perFileMs, onTimeout: "undefined" });
20934
- await (signal ? Promise.race([
20935
- preOpenAttempt,
20936
- new Promise((resolve8) => {
20937
- if (signal.aborted) {
20938
- resolve8();
20939
- return;
20940
- }
20941
- signal.addEventListener("abort", () => resolve8(), {
20942
- once: true
20943
- });
20944
- })
20945
- ]) : preOpenAttempt);
21295
+ await untilAborted(preOpenAttempt, signal);
20946
21296
  }
20947
21297
  };
20948
21298
  const markServiceDestroyed = (remainingFiles) => {
@@ -20971,7 +21321,8 @@ var LSPService = class _LSPService {
20971
21321
  if (attached && !attached.available) {
20972
21322
  await this.ensureWarmForSweep(filePath, { signal });
20973
21323
  }
20974
- const touchResult = attached?.available ? {
21324
+ const answer = attached?.available ? dropExcludedServers(attached.response, sweepExcludedServerIds) : void 0;
21325
+ const touchResult = answer ? {
20975
21326
  // #4645: the incumbent's membership answer, applied on receipt
20976
21327
  // through the owner's rule. This sweep records its rows into
20977
21328
  // the workspace cache, and an attached process has no live
@@ -20979,11 +21330,11 @@ var LSPService = class _LSPService {
20979
21330
  // rows: the form the batch cache stores (`replayable()`). The
20980
21331
  // environment rule still runs at render, against the install
20981
21332
  // state of that render.
20982
- diags: attached.response.projectIdentity === void 0 ? attached.response.diagnostics : await demoteInferredProjectDiagnostics(attached.response.diagnostics, {
21333
+ diags: answer.projectIdentity === void 0 ? answer.diagnostics : await demoteInferredProjectDiagnostics(answer.diagnostics, {
20983
21334
  filePath,
20984
21335
  cwd,
20985
21336
  identityCache: /* @__PURE__ */ new Map([
20986
- [filePath, attached.response.projectIdentity]
21337
+ [filePath, answer.projectIdentity]
20987
21338
  ])
20988
21339
  }),
20989
21340
  // #1470: the incumbent's coverage gap crosses the socket as an
@@ -20991,9 +21342,12 @@ var LSPService = class _LSPService {
20991
21342
  // reads. Dropping it here would let a partially covered
20992
21343
  // incumbent answer be persisted as a confirmed sweep result —
20993
21344
  // the same false clean this change closes on the local route.
20994
- ...attached.response.unconfirmedServerIds !== void 0 && {
20995
- unconfirmedServerIds: attached.response.unconfirmedServerIds
20996
- }
21345
+ ...answer.unconfirmedServerIds !== void 0 && {
21346
+ unconfirmedServerIds: answer.unconfirmedServerIds
21347
+ },
21348
+ // #5030: the incumbent's content binding, read below as a local
21349
+ // touch's is. An incumbent that sends none reads as not current.
21350
+ binding: warmAnswerBinding(answer)
20997
21351
  } : await withDeadline(this.touchFile(filePath, content, {
20998
21352
  diagnostics: "document",
20999
21353
  collectDiagnostics: true,
@@ -21003,7 +21357,7 @@ var LSPService = class _LSPService {
21003
21357
  // `opengrep-client.ts` CLI extractor (one project-wide scan,
21004
21358
  // cached, read via extractors.ts) instead — see the
21005
21359
  // `excludeServerIds` doc on `LSPTouchFileOptions`.
21006
- excludeServerIds: WORKSPACE_SWEEP_EXCLUDED_SERVER_IDS,
21360
+ excludeServerIds: sweepExcludedServerIds,
21007
21361
  // #645: lets a workspaceIndexing server (marksman) pay its
21008
21362
  // full wait budget only once across this whole sweep.
21009
21363
  sweepIndexGate
@@ -21210,6 +21564,9 @@ var LSPService = class _LSPService {
21210
21564
  if (result.error || result.timedOut || (result.unconfirmedServerIds?.length ?? 0) > 0 || scannedAt === void 0) {
21211
21565
  continue;
21212
21566
  }
21567
+ if (result.boundToCurrentDisk === false && result.contentHash === void 0) {
21568
+ continue;
21569
+ }
21213
21570
  if (pullAnsweredFiles.has(result.filePath) && result.contentHash === void 0) {
21214
21571
  workspaceDiagnosticsCacheCtx.forget(result.filePath);
21215
21572
  continue;
@@ -21578,6 +21935,8 @@ async function hasAuxiliaryLspPublishedForRoot(serverId, filePath) {
21578
21935
 
21579
21936
  export {
21580
21937
  resetWorkspaceDiagnosticsCacheSession,
21938
+ noteWorkspaceFilesChangedOnDisk,
21939
+ noteWorkspaceDependenciesChanged,
21581
21940
  importTargetsToAnnounce,
21582
21941
  goPackageFilesToAnnounce,
21583
21942
  getLspBudgetIdleTimeoutMs,
@@ -21590,9 +21949,12 @@ export {
21590
21949
  calculateRuleComplexity,
21591
21950
  buildEffectiveAstGrepCatalog,
21592
21951
  isRuleIgnoredForPath,
21952
+ isOptInAuxiliaryServerId,
21593
21953
  enabledAuxiliaryLspServerIds,
21594
21954
  configDisabledAuxiliaryLspServerIds,
21955
+ enabledOptInAuxiliaryLspServerIds,
21595
21956
  findAuxiliaryProfileForSource,
21957
+ dropExcludedServers,
21596
21958
  applyAuxiliarySuppressions,
21597
21959
  retagAuxiliaryDiagnostics,
21598
21960
  armDeferredLspWork,
@@ -21615,6 +21977,7 @@ export {
21615
21977
  beginScope,
21616
21978
  retireScope,
21617
21979
  nextOrderTurn,
21980
+ sessionCell,
21618
21981
  scopeCell,
21619
21982
  lineContentHash,
21620
21983
  ReadGuard,
@@ -21634,6 +21997,9 @@ export {
21634
21997
  touchCoverageGap,
21635
21998
  touchCompletedConfirmationPolicy,
21636
21999
  hashDiagnosticContent,
22000
+ warmAnswerBinding,
22001
+ readBoundToCurrentDisk,
22002
+ SERVER_CONFIG_FILE_NAMES,
21637
22003
  groupFilesByPrimaryServer,
21638
22004
  runPerServerGroups,
21639
22005
  STALE_LINE_MARKER,