pi-lens 4.4.12 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-USER.md +12 -12
- package/CHANGELOG.md +304 -0
- package/README.md +105 -217
- package/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/dist/{chunk-OVPR3GQ6.js → chunk-25CAONWT.js} +52 -23
- package/dist/{chunk-W6VLB6LL.js → chunk-2APSZHHI.js} +61 -3
- package/dist/{chunk-E3PNZDPH.js → chunk-2DWNYVUN.js} +34 -2
- package/dist/{chunk-ME6MF2N2.js → chunk-2RQREVGO.js} +1 -1
- package/dist/{chunk-7T64QA5D.js → chunk-2XALJI2K.js} +42 -41
- package/dist/{chunk-VU2PRGRI.js → chunk-2YQ5LI7R.js} +4 -4
- package/dist/{chunk-DFAY7JUN.js → chunk-35UJUF27.js} +18 -4
- package/dist/{chunk-PTJXMYRY.js → chunk-3IWMNN2S.js} +17 -18
- package/dist/chunk-3UTDLQWO.js +88 -0
- package/dist/chunk-3Z7Z3B7V.js +27 -0
- package/dist/{chunk-AD7JDEI6.js → chunk-4E4OCW3L.js} +17 -17
- package/dist/{chunk-6GWCYEP7.js → chunk-4GLSO2EM.js} +69 -19
- package/dist/{chunk-QJ4T73J5.js → chunk-5HVDD7IA.js} +1 -1
- package/dist/{chunk-ZRQMENT4.js → chunk-62PIU4TO.js} +1 -1
- package/dist/{chunk-HWMNTQBJ.js → chunk-6MDWNZ7E.js} +32 -11
- package/dist/{chunk-WLD6BGON.js → chunk-6MWX2J5H.js} +4 -0
- package/dist/{chunk-SF7KSXB5.js → chunk-6MZLS6CK.js} +7 -7
- package/dist/{chunk-ORYQGVC3.js → chunk-7BWPQZHE.js} +3 -3
- package/dist/{chunk-5FDUKJZO.js → chunk-7JMEPY6P.js} +10 -10
- package/dist/{chunk-MOEWCPMC.js → chunk-7ORBRDFY.js} +2 -2
- package/dist/chunk-7WAQ3K26.js +52 -0
- package/dist/{chunk-5EEWCJG7.js → chunk-AB26NAHA.js} +9 -9
- package/dist/{chunk-IC4L65U7.js → chunk-AFSG6YUB.js} +13 -14
- package/dist/{chunk-2HWVG3IM.js → chunk-ALTHJUZO.js} +2 -2
- package/dist/{chunk-R67WQ5RY.js → chunk-AOEVZXR6.js} +9 -9
- package/dist/{chunk-F7AMFFVK.js → chunk-ARTCVE6I.js} +9 -9
- package/dist/{chunk-HGEE5LDW.js → chunk-B2QO7GHY.js} +1 -1
- package/dist/{chunk-HSTN27NR.js → chunk-BJGWP4UX.js} +10 -10
- package/dist/{chunk-6EXGCXM5.js → chunk-BKJ6WZKP.js} +99 -5
- package/dist/{chunk-6JLNZ6DP.js → chunk-BQ72NQQM.js} +11 -11
- package/dist/{chunk-WTSQKJAR.js → chunk-BWGNVM33.js} +11 -11
- package/dist/{chunk-IT7MFVGP.js → chunk-BYIEU4E4.js} +2 -2
- package/dist/{chunk-ILC2B7IJ.js → chunk-CDAJQBKJ.js} +11 -11
- package/dist/{chunk-HJWF7CGW.js → chunk-D3UQWOCB.js} +17 -17
- package/dist/{chunk-OEPWTSUG.js → chunk-DHFJS2I4.js} +8 -8
- package/dist/{chunk-SUIZOCSY.js → chunk-DKXIUGNA.js} +2 -2
- package/dist/{chunk-3R3Z54J7.js → chunk-DLGJYQML.js} +2 -2
- package/dist/{chunk-D6ANA6YU.js → chunk-DNJJVKJZ.js} +64 -56
- package/dist/{chunk-OYXD2MOM.js → chunk-EBXCYEII.js} +3 -3
- package/dist/chunk-EH6EHFW2.js +73 -0
- package/dist/{chunk-HRQTYU2T.js → chunk-EKQDQPX6.js} +10 -10
- package/dist/{chunk-DZSQXG66.js → chunk-EXHSWN3P.js} +1093 -411
- package/dist/{chunk-PCREZ4HJ.js → chunk-F7BFIENK.js} +35 -36
- package/dist/{chunk-LD7SXICE.js → chunk-FD4LJQ6Y.js} +5 -5
- package/dist/{chunk-7ZVEFWOE.js → chunk-GFCPPCNR.js} +11 -11
- package/dist/{chunk-B4FAFEBP.js → chunk-GIK6VUCY.js} +1 -1
- package/dist/{chunk-JLMS7EMD.js → chunk-GNK2IHVG.js} +17 -16
- package/dist/{chunk-7424ANRU.js → chunk-H6DNTQ4V.js} +2 -2
- package/dist/{chunk-TOOXNL6M.js → chunk-HERQPNY6.js} +8 -8
- package/dist/{chunk-NZINZCHB.js → chunk-HFIFEH46.js} +3 -3
- package/dist/{chunk-PXGVB2CY.js → chunk-HKRESBMC.js} +21 -19
- package/dist/{chunk-PK3GDU4M.js → chunk-HMXWZUQW.js} +1 -1
- package/dist/{chunk-75TVYCQW.js → chunk-HOWHAKXO.js} +6 -6
- package/dist/{chunk-K2GV34T2.js → chunk-HUWW77QY.js} +27 -38
- package/dist/{chunk-OHEUOWYT.js → chunk-IO6P3NBP.js} +1 -1
- package/dist/{chunk-PPYUBO6Y.js → chunk-J7VNGHLN.js} +2 -2
- package/dist/{chunk-IZ36G463.js → chunk-JGCBMCCS.js} +8 -8
- package/dist/{chunk-OF2YGDUE.js → chunk-KIQSNH3F.js} +39 -40
- package/dist/{chunk-HYDJUVOE.js → chunk-KSQJBGRO.js} +5 -5
- package/dist/{chunk-T5EGSBM2.js → chunk-KXKM2DFP.js} +4 -4
- package/dist/chunk-L3Q72QGQ.js +25 -0
- package/dist/{chunk-AVBEPUCD.js → chunk-LDPY22FS.js} +2 -2
- package/dist/{chunk-ET3DSSFZ.js → chunk-M3QGXGY4.js} +3796 -3825
- package/dist/{chunk-YLW26OHX.js → chunk-MET776XM.js} +35 -61
- package/dist/{chunk-X33QECRJ.js → chunk-MKQFSW2Q.js} +2 -2
- package/dist/{chunk-7BEADGAZ.js → chunk-MKW7ZUTT.js} +3 -3
- package/dist/{chunk-6EIV3H7O.js → chunk-N2U644ZW.js} +4 -11
- package/dist/{chunk-AYDE7RFV.js → chunk-NAACKIKT.js} +2 -2
- package/dist/{chunk-O6LCSHHI.js → chunk-NHHS5T52.js} +1 -1
- package/dist/{chunk-DIIDMDZU.js → chunk-NIZKGBOU.js} +51 -27
- package/dist/chunk-NNDZ7DOP.js +3040 -0
- package/dist/{chunk-MV6ST2KT.js → chunk-NZ7NSKIW.js} +14 -13
- package/dist/{chunk-AAIVSSUU.js → chunk-OG3UCAHV.js} +35 -12
- package/dist/{chunk-C6V2DSZZ.js → chunk-OHTHVILU.js} +12 -12
- package/dist/{chunk-AGEQRJ5A.js → chunk-P7EV5ISR.js} +17 -2
- package/dist/{chunk-G3LR6V6N.js → chunk-PVV27TOX.js} +20 -18
- package/dist/{chunk-3MHY4BQY.js → chunk-Q32RJDYC.js} +4 -4
- package/dist/{chunk-BMMRLJA4.js → chunk-Q4UQNTLB.js} +29 -12
- package/dist/{chunk-FDLGJFAE.js → chunk-QQGZY2BR.js} +3 -3
- package/dist/{chunk-E5SSUV2A.js → chunk-S247BOH2.js} +4 -4
- package/dist/{chunk-NCDH2JB7.js → chunk-S7KUDW73.js} +136 -18
- package/dist/{chunk-GHATCG2A.js → chunk-SJ2SR432.js} +23 -19
- package/dist/{chunk-SRXYSLMW.js → chunk-SL4G67AP.js} +2 -2
- package/dist/chunk-T2D2WWP6.js +847 -0
- package/dist/{chunk-JRSS6KM4.js → chunk-T7KHGEJ5.js} +3 -3
- package/dist/{chunk-YTXFNCVN.js → chunk-TABDCX35.js} +2 -2
- package/dist/chunk-TFSBHRL2.js +25 -0
- package/dist/{chunk-S6ZQFPOX.js → chunk-TQKWR5AZ.js} +7 -7
- package/dist/chunk-TQWRH25U.js +35 -0
- package/dist/chunk-TWAQFMLW.js +110 -0
- package/dist/{chunk-Y7XMKBFP.js → chunk-UARVPNAU.js} +35 -27
- package/dist/chunk-UWBD3JMH.js +56 -0
- package/dist/{chunk-AZXTLZHE.js → chunk-VEF3GFOL.js} +170 -166
- package/dist/{chunk-QY6J2FTK.js → chunk-W2JPGW7Q.js} +28 -25
- package/dist/{chunk-HYR25MV3.js → chunk-W2YHHNY3.js} +9 -8
- package/dist/{chunk-3PMLYGJN.js → chunk-WA6U2URH.js} +9 -9
- package/dist/{chunk-JKAVKTMY.js → chunk-WAK2AXQQ.js} +18 -21
- package/dist/{chunk-K2LD6YNH.js → chunk-WH6O4IFD.js} +10 -10
- package/dist/{chunk-KXDQD34C.js → chunk-WJ7GY5WJ.js} +1 -1
- package/dist/{chunk-3QMLB4TI.js → chunk-WWZLT6AM.js} +2 -2
- package/dist/{chunk-ZWZD4TJ5.js → chunk-XRLZ75YY.js} +39 -40
- package/dist/chunk-XWWFESYZ.js +27 -0
- package/dist/chunk-XZSXSM4K.js +27 -0
- package/dist/{chunk-D2ZYRI7M.js → chunk-Y2LIOCA7.js} +1 -1
- package/dist/{chunk-Z6WTLVUL.js → chunk-YIEHUKX2.js} +291 -255
- package/dist/{chunk-NRVWLTOY.js → chunk-YOMLAKU6.js} +231 -190
- package/dist/{chunk-3EIZMRXI.js → chunk-YV7XVYSJ.js} +11 -11
- package/dist/{chunk-T6PPK3T6.js → chunk-ZVQUYCBU.js} +1317 -708
- package/dist/index.js +10797 -7167
- package/dist/mcp/analyze-cli.js +11 -11
- package/dist/mcp/cli.js +42 -41
- package/dist/mcp/server.js +813 -469
- package/dist/mcp/worker.js +60 -61
- package/dist/probes/installer.js +22 -20
- package/docs/architecture.md +113 -0
- package/docs/ast-grep_rules_catalog.md +2 -2
- package/docs/ci-bot-pr-checks.md +18 -9
- package/docs/ci.md +25 -4
- package/docs/defect-shapes.md +83 -30
- package/docs/dependencies.md +10 -10
- package/docs/features.md +3 -3
- package/docs/globalconfig.md +1 -0
- package/docs/invariants/dispatch-runners.md +28 -1
- package/docs/invariants/lsp-trust-exec.md +19 -0
- package/docs/language-coverage.md +39 -0
- package/docs/lsp-capability-matrix.md +13 -7
- package/docs/lsp-idle-eviction.md +3 -2
- package/docs/module-report-read-symbol.md +6 -2
- package/docs/pi-lens-fixer.md +4 -0
- package/docs/pi-lens-merge-policy.md +4 -3
- package/docs/pi-lens-orchestration.md +2 -1
- package/docs/pi-lens-reviewer.md +4 -5
- package/docs/pi-lens-subagent.md +7 -3
- package/docs/prose-standard.md +112 -0
- package/docs/servercapabilities.md +1 -1
- package/docs/settings.md +1 -0
- package/docs/usage.md +51 -0
- package/package.json +1 -1
- package/rules/ast-grep-rules/rule-tests/array-callback-return-js-test.yml +23 -0
- package/rules/ast-grep-rules/rule-tests/array-callback-return-test.yml +23 -0
- package/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-js-test.yml +8 -0
- package/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-test.yml +8 -0
- package/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-js-test.yml +16 -0
- package/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-test.yml +16 -0
- package/rules/ast-grep-rules/rules/array-callback-return-js.yml +8 -0
- package/rules/ast-grep-rules/rules/array-callback-return.yml +8 -0
- package/rules/ast-grep-rules/rules/no-negation-in-equality-check-js.yml +17 -5
- package/rules/ast-grep-rules/rules/no-negation-in-equality-check.yml +17 -5
- package/rules/ast-grep-rules/rules/unchecked-throwing-call-js.yml +8 -1
- package/rules/ast-grep-rules/rules/unchecked-throwing-call.yml +8 -1
- package/rules/tree-sitter-queries/typescript/ts-react-antipatterns.yml +8 -0
- package/dist/chunk-3VWEZ6H2.js +0 -72
- package/dist/chunk-5KLRCUDT.js +0 -67
- package/dist/chunk-7KWI5UHL.js +0 -28
- package/dist/chunk-7M64NTAK.js +0 -38
- package/dist/chunk-BEIPWPVR.js +0 -1037
- package/dist/chunk-D7OEGXDX.js +0 -2417
- package/dist/chunk-FVQKX5KI.js +0 -50
- package/dist/chunk-KUDUKKQE.js +0 -89
- package/dist/chunk-TM3A3K7T.js +0 -28
- package/dist/chunk-TS5EIWEF.js +0 -25
- package/dist/chunk-VD7MQFEV.js +0 -56
- package/dist/chunk-YLHJWAQS.js +0 -256
- package/dist/chunk-YULIERZW.js +0 -27
- package/dist/chunk-Z2W5YJBW.js +0 -25
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
classifyBridgeMutation,
|
|
3
4
|
createReadGuardEditBatchSummary,
|
|
4
5
|
displayedMessage,
|
|
5
6
|
findingIdentity,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
normalizeMessage,
|
|
10
11
|
sanitizeCorrelationId,
|
|
11
12
|
stableFindingId
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-35UJUF27.js";
|
|
13
14
|
import {
|
|
14
15
|
mapWithConcurrency
|
|
15
16
|
} from "./chunk-XIMYZ3JA.js";
|
|
@@ -41,24 +42,20 @@ import {
|
|
|
41
42
|
resolveLspServerCwd,
|
|
42
43
|
serverTraits,
|
|
43
44
|
withLspProjectCodePermission
|
|
44
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-YIEHUKX2.js";
|
|
45
46
|
import {
|
|
46
47
|
findLocalOpengrepConfig
|
|
47
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-J7VNGHLN.js";
|
|
48
49
|
import {
|
|
49
50
|
emitBounded
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import {
|
|
52
|
-
loadProjectSnapshot,
|
|
53
|
-
readJsonCache
|
|
54
|
-
} from "./chunk-YLW26OHX.js";
|
|
51
|
+
} from "./chunk-AB26NAHA.js";
|
|
55
52
|
import {
|
|
56
53
|
acquireWorkspaceSweepHold,
|
|
57
54
|
configureLspServiceLifecycle,
|
|
58
55
|
getOwnedLspService,
|
|
59
56
|
peekOwnedLspService,
|
|
60
57
|
resetOwnedLspService
|
|
61
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-B2QO7GHY.js";
|
|
62
59
|
import {
|
|
63
60
|
RUNTIME_CONFIG,
|
|
64
61
|
collectForwardImportMtimes,
|
|
@@ -73,31 +70,40 @@ import {
|
|
|
73
70
|
lineTextAt,
|
|
74
71
|
pathBirthtimeMs,
|
|
75
72
|
scanDocumentContent
|
|
76
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-S7KUDW73.js";
|
|
77
74
|
import {
|
|
78
75
|
js_yaml_default
|
|
79
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-2DWNYVUN.js";
|
|
77
|
+
import {
|
|
78
|
+
loadProjectSnapshot
|
|
79
|
+
} from "./chunk-MET776XM.js";
|
|
80
80
|
import {
|
|
81
81
|
EXTENSION_TO_LSP_ID,
|
|
82
82
|
lspLanguageId,
|
|
83
83
|
resolveFilenameLanguage
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-NAACKIKT.js";
|
|
85
85
|
import {
|
|
86
86
|
diagnosticsIpcPathForCwd,
|
|
87
87
|
requestWarmCodeActions,
|
|
88
88
|
requestWarmDiagnostics
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-6MDWNZ7E.js";
|
|
90
|
+
import {
|
|
91
|
+
semanticFor
|
|
92
|
+
} from "./chunk-2APSZHHI.js";
|
|
90
93
|
import {
|
|
91
94
|
findLocalZizmorConfig,
|
|
92
95
|
logSessionStart
|
|
93
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-YOMLAKU6.js";
|
|
94
97
|
import {
|
|
95
98
|
findLocalBinUpwards,
|
|
96
99
|
isProjectLocalBinPath
|
|
97
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-25CAONWT.js";
|
|
98
101
|
import {
|
|
99
102
|
getLspCapableKinds
|
|
100
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-HOWHAKXO.js";
|
|
104
|
+
import {
|
|
105
|
+
readJsonCache
|
|
106
|
+
} from "./chunk-TQWRH25U.js";
|
|
101
107
|
import {
|
|
102
108
|
createGenerationMap,
|
|
103
109
|
createGenerationSource,
|
|
@@ -116,19 +122,19 @@ import {
|
|
|
116
122
|
sampleProcessTreeCpuPercent,
|
|
117
123
|
selectLivePeerInstances,
|
|
118
124
|
windowsExe
|
|
119
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-M3QGXGY4.js";
|
|
120
126
|
import {
|
|
121
127
|
createSingleFlight
|
|
122
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-GIK6VUCY.js";
|
|
129
|
+
import {
|
|
130
|
+
PathKeyedMap,
|
|
131
|
+
detectFileRole
|
|
132
|
+
} from "./chunk-N2U644ZW.js";
|
|
123
133
|
import {
|
|
124
134
|
SPECIAL_FILENAMES,
|
|
125
135
|
getLanguageId,
|
|
126
136
|
isJstsFactFile
|
|
127
|
-
} from "./chunk-
|
|
128
|
-
import {
|
|
129
|
-
PathKeyedMap,
|
|
130
|
-
detectFileRole
|
|
131
|
-
} from "./chunk-6EIV3H7O.js";
|
|
137
|
+
} from "./chunk-SL4G67AP.js";
|
|
132
138
|
import {
|
|
133
139
|
CONTENT_HASH_MAX_BYTES,
|
|
134
140
|
hashContentBytes,
|
|
@@ -144,17 +150,17 @@ import {
|
|
|
144
150
|
readAdoptedProjectTrust,
|
|
145
151
|
untilAborted,
|
|
146
152
|
withDeadline,
|
|
147
|
-
withTimeout,
|
|
148
153
|
writeFileAtomic
|
|
149
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-EKQDQPX6.js";
|
|
150
155
|
import {
|
|
151
156
|
compareOrdinal,
|
|
152
157
|
incrementDegradationCount,
|
|
153
158
|
logExtension,
|
|
154
159
|
recordDegradation,
|
|
155
160
|
recordDegradationOnce,
|
|
161
|
+
spawnAbortScope,
|
|
156
162
|
truncateForLedger
|
|
157
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-P7EV5ISR.js";
|
|
158
164
|
import {
|
|
159
165
|
freshnessFromMtime
|
|
160
166
|
} from "./chunk-S26LC76R.js";
|
|
@@ -171,7 +177,7 @@ import {
|
|
|
171
177
|
nonNegativeIntEnv,
|
|
172
178
|
phaseFinished,
|
|
173
179
|
phaseStarted
|
|
174
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-HUWW77QY.js";
|
|
175
181
|
import {
|
|
176
182
|
BoundedFifoMap,
|
|
177
183
|
BoundedLruCache,
|
|
@@ -190,12 +196,13 @@ import {
|
|
|
190
196
|
realpathOrResolve,
|
|
191
197
|
realpathOrResolveAsync,
|
|
192
198
|
relativeInside,
|
|
199
|
+
rootsOverlap,
|
|
193
200
|
toPosix,
|
|
194
201
|
toProjectRelativePath,
|
|
195
202
|
uriToDiskPath,
|
|
196
203
|
uriToPath,
|
|
197
204
|
walkUpDirs
|
|
198
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-6MWX2J5H.js";
|
|
199
206
|
import {
|
|
200
207
|
__commonJS,
|
|
201
208
|
__require,
|
|
@@ -3622,7 +3629,7 @@ var require_main = __commonJS({
|
|
|
3622
3629
|
ril_1.default.install();
|
|
3623
3630
|
var path18 = __importStar(__require("path"));
|
|
3624
3631
|
var os3 = __importStar(__require("os"));
|
|
3625
|
-
var
|
|
3632
|
+
var fs14 = __importStar(__require("fs"));
|
|
3626
3633
|
var crypto_1 = __require("crypto");
|
|
3627
3634
|
var net_1 = __require("net");
|
|
3628
3635
|
var api_1 = require_api();
|
|
@@ -3763,7 +3770,7 @@ var require_main = __commonJS({
|
|
|
3763
3770
|
}
|
|
3764
3771
|
let randomLength = 32;
|
|
3765
3772
|
const fixedLength = "/lsp-.sock".length;
|
|
3766
|
-
const tmpDir =
|
|
3773
|
+
const tmpDir = fs14.realpathSync(XDG_RUNTIME_DIR ?? os3.tmpdir());
|
|
3767
3774
|
const limit = safeIpcPathLengths.get(process.platform);
|
|
3768
3775
|
if (limit !== void 0) {
|
|
3769
3776
|
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
|
|
@@ -3876,7 +3883,7 @@ var CASCADE_DIAGNOSTICS_TTL_MS = 24e4;
|
|
|
3876
3883
|
|
|
3877
3884
|
// dist/clients/lsp/index.js
|
|
3878
3885
|
import * as nodeFs2 from "node:fs";
|
|
3879
|
-
import
|
|
3886
|
+
import fs13 from "node:fs/promises";
|
|
3880
3887
|
import os2 from "node:os";
|
|
3881
3888
|
import path17 from "node:path";
|
|
3882
3889
|
import { pathToFileURL as pathToFileURL3, URL as URL3 } from "node:url";
|
|
@@ -4055,7 +4062,7 @@ async function importTargetsToAnnounce(cwd, importers, onScope) {
|
|
|
4055
4062
|
reason: `resolved the imports of ${CREATED_IMPORT_SCAN_MAX_FILES} of ${importers.length} files in one diagnostics call`
|
|
4056
4063
|
});
|
|
4057
4064
|
}
|
|
4058
|
-
const { extractForwardImports } = await import("./chunk-
|
|
4065
|
+
const { extractForwardImports } = await import("./chunk-3IWMNN2S.js");
|
|
4059
4066
|
const targets = /* @__PURE__ */ new Set();
|
|
4060
4067
|
const reexports = /* @__PURE__ */ new Map();
|
|
4061
4068
|
let resolved2 = 0;
|
|
@@ -4418,7 +4425,7 @@ function isZizmorIgnoreSuppressed(d, content) {
|
|
|
4418
4425
|
const ruleId = String(d.code ?? "").toLowerCase();
|
|
4419
4426
|
return match[1].split(",").map((s) => s.trim().toLowerCase()).includes(ruleId);
|
|
4420
4427
|
}
|
|
4421
|
-
var blockOnErrorWhenAllowed = (d, { blockingAllowed }) => blockingAllowed && d.severity === 1 ? "
|
|
4428
|
+
var blockOnErrorWhenAllowed = (d, { blockingAllowed }) => semanticFor(blockingAllowed && d.severity === 1 ? "error" : "warning");
|
|
4422
4429
|
var AUXILIARY_LSP_PROFILES = [
|
|
4423
4430
|
{
|
|
4424
4431
|
serverId: "opengrep",
|
|
@@ -4511,8 +4518,7 @@ var AUXILIARY_LSP_PROFILES = [
|
|
|
4511
4518
|
optInFlag: "lens-fallow",
|
|
4512
4519
|
// Advisory in this cut: no `allowBlocking`, so even an ERROR-severity
|
|
4513
4520
|
// finding stays a warning. fallow publishes unused-code findings as LSP
|
|
4514
|
-
// HINT (severity 4, the editor's greyed-out tag)
|
|
4515
|
-
// conversion would render as no semantic at all.
|
|
4521
|
+
// HINT (severity 4, the editor's greyed-out tag); those stay advisory too.
|
|
4516
4522
|
semantic: () => "warning",
|
|
4517
4523
|
defectClass: (d) => {
|
|
4518
4524
|
const code = String(d.code ?? "");
|
|
@@ -5233,6 +5239,9 @@ function resetPendingAuxiliaryCoverage() {
|
|
|
5233
5239
|
// dist/clients/lsp-mutation.js
|
|
5234
5240
|
import * as path7 from "node:path";
|
|
5235
5241
|
|
|
5242
|
+
// dist/clients/fix-run-restore.js
|
|
5243
|
+
import * as fs3 from "node:fs";
|
|
5244
|
+
|
|
5236
5245
|
// dist/clients/file-mutation-queue.js
|
|
5237
5246
|
var loadHostSdk;
|
|
5238
5247
|
var hostQueue;
|
|
@@ -5279,6 +5288,121 @@ async function withHostFileMutationQueues(filePaths, fn) {
|
|
|
5279
5288
|
// dist/clients/fix-run-restore.js
|
|
5280
5289
|
var FIX_RUN_MAX_FILE_BYTES = 1024 * 1024;
|
|
5281
5290
|
var FIX_RUN_HASH_BYTE_BUDGET = 64 * 1024 * 1024;
|
|
5291
|
+
var REGISTRY_FAMILY = "fix-run-restore";
|
|
5292
|
+
var REGISTRY_VERSION = 2;
|
|
5293
|
+
function registry() {
|
|
5294
|
+
return getProcessSingleton(REGISTRY_FAMILY, REGISTRY_VERSION, () => ({
|
|
5295
|
+
active: /* @__PURE__ */ new Set(),
|
|
5296
|
+
pendingCalls: /* @__PURE__ */ new Map()
|
|
5297
|
+
}));
|
|
5298
|
+
}
|
|
5299
|
+
function callsOn(run, key, exceptId) {
|
|
5300
|
+
const calls = [];
|
|
5301
|
+
for (const [id, call] of run.calls)
|
|
5302
|
+
if (id !== exceptId && call.key === key)
|
|
5303
|
+
calls.push(call);
|
|
5304
|
+
return calls;
|
|
5305
|
+
}
|
|
5306
|
+
function coversContradiction(captured, own, text) {
|
|
5307
|
+
for (const edit of captured) {
|
|
5308
|
+
const added = normalized(edit.newText);
|
|
5309
|
+
const removed = normalized(edit.oldText ?? "");
|
|
5310
|
+
if (added.length > 0 && !text.includes(added) && !own.some((stated) => normalized(stated.oldText ?? "").includes(added)))
|
|
5311
|
+
return false;
|
|
5312
|
+
if (removed.length > 0 && !added.includes(removed) && text.includes(removed) && !own.some((stated) => normalized(stated.newText).includes(removed)))
|
|
5313
|
+
return false;
|
|
5314
|
+
}
|
|
5315
|
+
return true;
|
|
5316
|
+
}
|
|
5317
|
+
function covers(stated, own, disk, text) {
|
|
5318
|
+
if (!own || verdictFor(disk, own) !== "verified")
|
|
5319
|
+
return false;
|
|
5320
|
+
if (own.content !== void 0)
|
|
5321
|
+
return true;
|
|
5322
|
+
if (stated.content !== void 0)
|
|
5323
|
+
return false;
|
|
5324
|
+
return coversContradiction(stated.edits ?? [], own.edits ?? [], text);
|
|
5325
|
+
}
|
|
5326
|
+
function accountedByOwnCall(run, key, stated, disk, exceptId) {
|
|
5327
|
+
if (!stated)
|
|
5328
|
+
return false;
|
|
5329
|
+
const text = normalized(disk.toString("utf8"));
|
|
5330
|
+
for (const call of callsOn(run, key, exceptId))
|
|
5331
|
+
if (covers(stated, call.expected, disk, text))
|
|
5332
|
+
return true;
|
|
5333
|
+
return false;
|
|
5334
|
+
}
|
|
5335
|
+
function captureVerdict(run, key, bytes, expected) {
|
|
5336
|
+
const verdict = verdictFor(bytes, expected);
|
|
5337
|
+
return verdict === "overwritten" && accountedByOwnCall(run, key, expected, bytes) ? "accounted" : verdict;
|
|
5338
|
+
}
|
|
5339
|
+
function keepsNewerCapture(stated, verdict, bytes, old) {
|
|
5340
|
+
if (verdict !== "overwritten")
|
|
5341
|
+
return false;
|
|
5342
|
+
if (old?.verdict !== "verified" || !old.bytes.equals(bytes))
|
|
5343
|
+
return false;
|
|
5344
|
+
const own = old.expected;
|
|
5345
|
+
if (!stated || !own || own.content !== void 0 || stated.content !== void 0)
|
|
5346
|
+
return false;
|
|
5347
|
+
return coversContradiction(stated.edits ?? [], own.edits ?? [], normalized(bytes.toString("utf8")));
|
|
5348
|
+
}
|
|
5349
|
+
function noteAgentMutation(filePath, expected) {
|
|
5350
|
+
const { active } = registry();
|
|
5351
|
+
if (active.size === 0)
|
|
5352
|
+
return;
|
|
5353
|
+
let key;
|
|
5354
|
+
for (const run of active) {
|
|
5355
|
+
key ??= normalizeMapKey(filePath);
|
|
5356
|
+
const file = run.files.get(key);
|
|
5357
|
+
if (!file)
|
|
5358
|
+
continue;
|
|
5359
|
+
try {
|
|
5360
|
+
const bytes = fs3.readFileSync(file.filePath);
|
|
5361
|
+
if (hashContentBytes(bytes) === file.hash) {
|
|
5362
|
+
delete file.capture;
|
|
5363
|
+
continue;
|
|
5364
|
+
}
|
|
5365
|
+
const old = file.capture;
|
|
5366
|
+
const verdict = captureVerdict(run, key, bytes, expected);
|
|
5367
|
+
if (old && (old.verdict === "overwritten" || !old.bytes.equals(bytes) && (old.verdict === "unverifiable" || old.displaced)))
|
|
5368
|
+
file.superseded = file.superseded === "overwritten" || old.verdict === "overwritten" ? "overwritten" : "unverifiable";
|
|
5369
|
+
if (!keepsNewerCapture(expected, verdict, bytes, old))
|
|
5370
|
+
file.capture = { bytes, verdict, expected };
|
|
5371
|
+
} catch {
|
|
5372
|
+
delete file.capture;
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
}
|
|
5376
|
+
function normalized(text) {
|
|
5377
|
+
return text.replace(/\r\n/g, "\n");
|
|
5378
|
+
}
|
|
5379
|
+
function verdictFor(bytes, expected) {
|
|
5380
|
+
if (!expected)
|
|
5381
|
+
return "unverifiable";
|
|
5382
|
+
const text = normalized(bytes.toString("utf8"));
|
|
5383
|
+
if (expected.content !== void 0)
|
|
5384
|
+
return text === normalized(expected.content) ? "verified" : "overwritten";
|
|
5385
|
+
const edits = expected.edits ?? [];
|
|
5386
|
+
let checkable = 0;
|
|
5387
|
+
for (const edit of edits) {
|
|
5388
|
+
const added = normalized(edit.newText);
|
|
5389
|
+
const removed = normalized(edit.oldText ?? "");
|
|
5390
|
+
let checked = false;
|
|
5391
|
+
if (added.length > 0) {
|
|
5392
|
+
checked = true;
|
|
5393
|
+
if (!text.includes(added))
|
|
5394
|
+
return "overwritten";
|
|
5395
|
+
}
|
|
5396
|
+
if (removed.length > 0 && !added.includes(removed)) {
|
|
5397
|
+
checked = true;
|
|
5398
|
+
if (text.includes(removed))
|
|
5399
|
+
return "overwritten";
|
|
5400
|
+
}
|
|
5401
|
+
if (checked)
|
|
5402
|
+
checkable += 1;
|
|
5403
|
+
}
|
|
5404
|
+
return edits.length > 0 && checkable === edits.length ? "verified" : "unverifiable";
|
|
5405
|
+
}
|
|
5282
5406
|
|
|
5283
5407
|
// dist/clients/observed-mutation.js
|
|
5284
5408
|
import * as path5 from "node:path";
|
|
@@ -5400,10 +5524,10 @@ function hashFile(filePath) {
|
|
|
5400
5524
|
|
|
5401
5525
|
// dist/clients/read-guard.js
|
|
5402
5526
|
import { constants as bufferConstants } from "node:buffer";
|
|
5403
|
-
import * as
|
|
5527
|
+
import * as fs5 from "node:fs";
|
|
5404
5528
|
|
|
5405
5529
|
// dist/clients/file-time.js
|
|
5406
|
-
import * as
|
|
5530
|
+
import * as fs4 from "node:fs";
|
|
5407
5531
|
import * as path4 from "node:path";
|
|
5408
5532
|
var globalState = {
|
|
5409
5533
|
reads: /* @__PURE__ */ new Map()
|
|
@@ -5496,7 +5620,7 @@ var FileTimeError = class extends Error {
|
|
|
5496
5620
|
};
|
|
5497
5621
|
function createStamp(filePath) {
|
|
5498
5622
|
try {
|
|
5499
|
-
const stats =
|
|
5623
|
+
const stats = fs4.statSync(filePath);
|
|
5500
5624
|
return {
|
|
5501
5625
|
readAt: /* @__PURE__ */ new Date(),
|
|
5502
5626
|
mtime: stats.mtime.getTime(),
|
|
@@ -5561,15 +5685,15 @@ function probeCtxActive(ctx) {
|
|
|
5561
5685
|
}
|
|
5562
5686
|
|
|
5563
5687
|
// dist/clients/session-scope.js
|
|
5564
|
-
var
|
|
5565
|
-
var
|
|
5688
|
+
var REGISTRY_FAMILY2 = "session-scope.registry";
|
|
5689
|
+
var REGISTRY_VERSION2 = 1;
|
|
5566
5690
|
function carriedCounter(cell, field) {
|
|
5567
5691
|
const value = cell?.[field];
|
|
5568
5692
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
5569
5693
|
}
|
|
5570
|
-
function
|
|
5694
|
+
function registry2() {
|
|
5571
5695
|
let seed = { nextTicket: 0, orderTurn: 0 };
|
|
5572
|
-
return getProcessSingleton(
|
|
5696
|
+
return getProcessSingleton(REGISTRY_FAMILY2, REGISTRY_VERSION2, () => seed, (previous) => {
|
|
5573
5697
|
seed = {
|
|
5574
5698
|
nextTicket: carriedCounter(previous, "nextTicket"),
|
|
5575
5699
|
orderTurn: carriedCounter(previous, "orderTurn")
|
|
@@ -5630,7 +5754,7 @@ var Scope = class {
|
|
|
5630
5754
|
}
|
|
5631
5755
|
};
|
|
5632
5756
|
function drawTicket() {
|
|
5633
|
-
const state4 =
|
|
5757
|
+
const state4 = registry2();
|
|
5634
5758
|
state4.nextTicket += 1;
|
|
5635
5759
|
return state4.nextTicket;
|
|
5636
5760
|
}
|
|
@@ -5647,7 +5771,7 @@ function moveBranch(scope) {
|
|
|
5647
5771
|
scope.moveBranch();
|
|
5648
5772
|
}
|
|
5649
5773
|
function nextOrderTurn() {
|
|
5650
|
-
const state4 =
|
|
5774
|
+
const state4 = registry2();
|
|
5651
5775
|
state4.orderTurn += 1;
|
|
5652
5776
|
return state4.orderTurn;
|
|
5653
5777
|
}
|
|
@@ -5672,6 +5796,19 @@ function logScopeTransition(scope, args) {
|
|
|
5672
5796
|
}
|
|
5673
5797
|
});
|
|
5674
5798
|
}
|
|
5799
|
+
function recordDroppedRead(handle, site, writeBranchEpoch) {
|
|
5800
|
+
const captured = handle[CAPTURED_SCOPE];
|
|
5801
|
+
if (!captured?.branch.isCurrent())
|
|
5802
|
+
return;
|
|
5803
|
+
if (writeBranchEpoch !== handle.branchEpoch)
|
|
5804
|
+
return;
|
|
5805
|
+
const reason = captured.scope.retiredBy();
|
|
5806
|
+
incrementDegradationCount({
|
|
5807
|
+
kind: "session-scope-read-dropped",
|
|
5808
|
+
subject: `${reason}:${site}`,
|
|
5809
|
+
reason: `a ${site} read-guard write of scope ${captured.scope.scopeId} was dropped after the scope retired (${reason}); its entry is still on its conversation's branch`
|
|
5810
|
+
});
|
|
5811
|
+
}
|
|
5675
5812
|
var SESSION_INDEX_FAMILY = "session-scope.session-index";
|
|
5676
5813
|
var SESSION_INDEX_VERSION = 1;
|
|
5677
5814
|
function sessionIndex() {
|
|
@@ -5731,7 +5868,7 @@ var READ_BINDING_MAX_BYTES = 4 * 1024 * 1024;
|
|
|
5731
5868
|
var ABSENT_SIZE = -1;
|
|
5732
5869
|
function observeAuthoredBytes(filePath, knownHash, authoredRanges) {
|
|
5733
5870
|
try {
|
|
5734
|
-
const stat3 =
|
|
5871
|
+
const stat3 = fs5.statSync(filePath);
|
|
5735
5872
|
const hash = knownHash !== void 0 ? knownHash : stat3.size <= READ_BINDING_MAX_BYTES ? hashFileBytes(filePath) : void 0;
|
|
5736
5873
|
return {
|
|
5737
5874
|
size: stat3.size,
|
|
@@ -5740,7 +5877,7 @@ function observeAuthoredBytes(filePath, knownHash, authoredRanges) {
|
|
|
5740
5877
|
...hash !== void 0 && { hash },
|
|
5741
5878
|
...authoredRanges !== void 0 && { authoredRanges },
|
|
5742
5879
|
...authoredRanges !== void 0 && {
|
|
5743
|
-
authoredLineCount: splitLines(
|
|
5880
|
+
authoredLineCount: splitLines(fs5.readFileSync(filePath, "utf-8")).length
|
|
5744
5881
|
}
|
|
5745
5882
|
};
|
|
5746
5883
|
} catch {
|
|
@@ -5772,7 +5909,7 @@ function isValidAuthoredRanges(value) {
|
|
|
5772
5909
|
function authoredBytesIntact(filePath, authored) {
|
|
5773
5910
|
let stat3;
|
|
5774
5911
|
try {
|
|
5775
|
-
stat3 =
|
|
5912
|
+
stat3 = fs5.statSync(filePath);
|
|
5776
5913
|
} catch {
|
|
5777
5914
|
return authored.size === ABSENT_SIZE;
|
|
5778
5915
|
}
|
|
@@ -5830,7 +5967,7 @@ var READ_GUARD_MAX_CHECKED_PATHS_PER_CALL = 128;
|
|
|
5830
5967
|
var READ_GUARD_IDLE_EVICT_MS_DEFAULT = 30 * 6e4;
|
|
5831
5968
|
function _currentContentMatchesBindingForTests(filePath, binding) {
|
|
5832
5969
|
try {
|
|
5833
|
-
const content =
|
|
5970
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
5834
5971
|
const boundContent = binding.fullFile ? content : splitLines(content).slice(binding.offset - 1, binding.offset - 1 + binding.limit).join("\n");
|
|
5835
5972
|
return hashContentBytes(Buffer.from(boundContent, "utf8")) === binding.hash;
|
|
5836
5973
|
} catch {
|
|
@@ -5845,10 +5982,10 @@ function splitLines(text) {
|
|
|
5845
5982
|
return text.split(/\r?\n/);
|
|
5846
5983
|
}
|
|
5847
5984
|
function lineContentHash(line) {
|
|
5848
|
-
const
|
|
5985
|
+
const normalized2 = line.replace(/\s+/g, "");
|
|
5849
5986
|
let hash = 2166136261;
|
|
5850
|
-
for (let i = 0; i <
|
|
5851
|
-
hash = Math.imul(hash ^
|
|
5987
|
+
for (let i = 0; i < normalized2.length; i++) {
|
|
5988
|
+
hash = Math.imul(hash ^ normalized2.charCodeAt(i), 16777619);
|
|
5852
5989
|
}
|
|
5853
5990
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
5854
5991
|
}
|
|
@@ -5898,8 +6035,8 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5898
6035
|
const lines = /* @__PURE__ */ new Map();
|
|
5899
6036
|
let fd;
|
|
5900
6037
|
try {
|
|
5901
|
-
fd =
|
|
5902
|
-
const size =
|
|
6038
|
+
fd = fs5.openSync(filePath, "r");
|
|
6039
|
+
const size = fs5.fstatSync(fd).size;
|
|
5903
6040
|
if (size > SCAN_MAX_BYTES)
|
|
5904
6041
|
return overByteGate(filePath, size);
|
|
5905
6042
|
const byteBudget = size > 0 ? size : SCAN_MAX_BYTES + 1;
|
|
@@ -5910,7 +6047,7 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5910
6047
|
let parts = [];
|
|
5911
6048
|
const keepLine = () => lines.set(lineNo, Buffer.concat(parts).toString("utf8"));
|
|
5912
6049
|
while (consumed < byteBudget && !done(lineNo)) {
|
|
5913
|
-
const n =
|
|
6050
|
+
const n = fs5.readSync(fd, chunk, 0, Math.min(chunk.length, byteBudget - consumed), null);
|
|
5914
6051
|
if (n === 0)
|
|
5915
6052
|
break;
|
|
5916
6053
|
consumed += n;
|
|
@@ -5966,7 +6103,7 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5966
6103
|
return void 0;
|
|
5967
6104
|
} finally {
|
|
5968
6105
|
if (fd !== void 0)
|
|
5969
|
-
|
|
6106
|
+
fs5.closeSync(fd);
|
|
5970
6107
|
}
|
|
5971
6108
|
}
|
|
5972
6109
|
function overByteGate(filePath, bytes) {
|
|
@@ -5998,7 +6135,7 @@ function currentLinesMatchReadSnapshot(filePath, read, [startLine, endLine]) {
|
|
|
5998
6135
|
}
|
|
5999
6136
|
let lines;
|
|
6000
6137
|
try {
|
|
6001
|
-
lines = splitLines(
|
|
6138
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
6002
6139
|
} catch {
|
|
6003
6140
|
return {
|
|
6004
6141
|
checked: true,
|
|
@@ -6766,7 +6903,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
6766
6903
|
*/
|
|
6767
6904
|
isNewFile(filePath) {
|
|
6768
6905
|
try {
|
|
6769
|
-
return !
|
|
6906
|
+
return !fs5.existsSync(filePath);
|
|
6770
6907
|
} catch {
|
|
6771
6908
|
return true;
|
|
6772
6909
|
}
|
|
@@ -7141,7 +7278,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7141
7278
|
if (!Array.isArray(records) || records.length === 0)
|
|
7142
7279
|
continue;
|
|
7143
7280
|
const filePath = this.key(rawPath);
|
|
7144
|
-
const exists =
|
|
7281
|
+
const exists = fs5.existsSync(filePath);
|
|
7145
7282
|
for (const read of records) {
|
|
7146
7283
|
const id = read?.toolCallId;
|
|
7147
7284
|
if (!exists || typeof id !== "string" || !onBranch.has(id)) {
|
|
@@ -7237,7 +7374,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7237
7374
|
let evidence;
|
|
7238
7375
|
try {
|
|
7239
7376
|
evidence = writtenContent !== void 0 ? deliveredLineEvidence(writtenContent, 1) : {
|
|
7240
|
-
lineCount: splitLines(
|
|
7377
|
+
lineCount: splitLines(fs5.readFileSync(filePath, "utf-8")).length,
|
|
7241
7378
|
lineHashes: void 0
|
|
7242
7379
|
};
|
|
7243
7380
|
} catch {
|
|
@@ -7263,7 +7400,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7263
7400
|
canIgnoreStalenessByHashes(filePath, reads, touchedLines, editRanges) {
|
|
7264
7401
|
let lines;
|
|
7265
7402
|
try {
|
|
7266
|
-
lines = splitLines(
|
|
7403
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
7267
7404
|
} catch {
|
|
7268
7405
|
return false;
|
|
7269
7406
|
}
|
|
@@ -7403,7 +7540,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7403
7540
|
}
|
|
7404
7541
|
let lines;
|
|
7405
7542
|
try {
|
|
7406
|
-
lines = splitLines(
|
|
7543
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
7407
7544
|
} catch {
|
|
7408
7545
|
return void 0;
|
|
7409
7546
|
}
|
|
@@ -7612,6 +7749,8 @@ var ANSI_C_ESCAPES = new Map(Object.entries({
|
|
|
7612
7749
|
"?": 63
|
|
7613
7750
|
}).map(([escape, value]) => [escape.charCodeAt(0), value]));
|
|
7614
7751
|
var MOVE_CLUSTER_LETTERS = new Set("abdfilnprRsvx");
|
|
7752
|
+
var RSYNC_VALUE_LETTERS = new Set("eBTfM@");
|
|
7753
|
+
var TAR_VALUE_LETTERS = new Set("bCfFgHIKLNTVX");
|
|
7615
7754
|
|
|
7616
7755
|
// dist/clients/opaque-mutation-scan.js
|
|
7617
7756
|
var OPAQUE_HASH_BUDGET_BYTES = 8 * 1024 * 1024;
|
|
@@ -7872,10 +8011,10 @@ function createBusPublisher(liveEmitter5, options) {
|
|
|
7872
8011
|
return {
|
|
7873
8012
|
publish(call) {
|
|
7874
8013
|
const { event } = call;
|
|
7875
|
-
let
|
|
8014
|
+
let normalized2;
|
|
7876
8015
|
const cwd = () => {
|
|
7877
|
-
|
|
7878
|
-
return
|
|
8016
|
+
normalized2 ??= normalizeFilePath(call.cwd);
|
|
8017
|
+
return normalized2;
|
|
7879
8018
|
};
|
|
7880
8019
|
const extra = call.extra ?? {};
|
|
7881
8020
|
if (call.enabled === false) {
|
|
@@ -7963,6 +8102,8 @@ function isBusPublishEnabled() {
|
|
|
7963
8102
|
}
|
|
7964
8103
|
|
|
7965
8104
|
// dist/clients/format-events-publish.js
|
|
8105
|
+
var BUS_FORMAT_QUEUED_EVENT = "pilens:format:queued";
|
|
8106
|
+
var BUS_FORMAT_QUEUED_VERSION = 1;
|
|
7966
8107
|
var liveEmitter2 = createLiveBusEmitter();
|
|
7967
8108
|
var queuedPublisher = createBusPublisher(liveEmitter2, {
|
|
7968
8109
|
module: "format-events-publish"
|
|
@@ -7976,9 +8117,285 @@ var donePublisher = createBusPublisher(liveEmitter2, {
|
|
|
7976
8117
|
var autofixStartPublisher = createBusPublisher(liveEmitter2, {
|
|
7977
8118
|
module: "format-events-publish"
|
|
7978
8119
|
});
|
|
8120
|
+
function publishFormatQueued(args) {
|
|
8121
|
+
queuedPublisher.publish({
|
|
8122
|
+
event: BUS_FORMAT_QUEUED_EVENT,
|
|
8123
|
+
enabled: isBusPublishEnabled(),
|
|
8124
|
+
cwd: args.cwd,
|
|
8125
|
+
build: (cwd) => ({
|
|
8126
|
+
v: BUS_FORMAT_QUEUED_VERSION,
|
|
8127
|
+
source: "pi-lens",
|
|
8128
|
+
filePath: normalizeFilePath(args.filePath),
|
|
8129
|
+
cwd,
|
|
8130
|
+
tool: args.tool,
|
|
8131
|
+
kinds: args.kinds,
|
|
8132
|
+
...args.ownerSessionId === void 0 ? {} : { ownerSessionId: args.ownerSessionId },
|
|
8133
|
+
...args.turnIndex === void 0 ? {} : { turnIndex: args.turnIndex },
|
|
8134
|
+
...args.batchId === void 0 ? {} : { batchId: args.batchId }
|
|
8135
|
+
}),
|
|
8136
|
+
emittedFields: () => ({ fileCount: 1 }),
|
|
8137
|
+
dbg: args.dbg
|
|
8138
|
+
});
|
|
8139
|
+
}
|
|
7979
8140
|
|
|
7980
8141
|
// dist/clients/mutation-bridge.js
|
|
7981
8142
|
var MUTATION_BRIDGE_KEY = /* @__PURE__ */ Symbol.for("pi-lens:mutation-bridge");
|
|
8143
|
+
function isValidRange(value) {
|
|
8144
|
+
if (!Array.isArray(value) || value.length !== 2)
|
|
8145
|
+
return false;
|
|
8146
|
+
const [start, end] = value;
|
|
8147
|
+
return typeof start === "number" && typeof end === "number" && Number.isInteger(start) && Number.isInteger(end) && start >= 1 && end >= start;
|
|
8148
|
+
}
|
|
8149
|
+
function mutationEntryProblem(entry) {
|
|
8150
|
+
if (typeof entry !== "object" || entry === null)
|
|
8151
|
+
return "entry must be an object";
|
|
8152
|
+
const e = entry;
|
|
8153
|
+
if (typeof e["filePath"] !== "string" || e["filePath"] === "")
|
|
8154
|
+
return "filePath must be a non-empty string";
|
|
8155
|
+
const kind = e["kind"];
|
|
8156
|
+
if (kind !== "write" && kind !== "edit")
|
|
8157
|
+
return 'kind must be "edit" or "write"';
|
|
8158
|
+
if (e["touchedLines"] !== void 0 && !isValidRange(e["touchedLines"]))
|
|
8159
|
+
return "touchedLines must be 1-indexed [start, end]";
|
|
8160
|
+
const editRanges = e["editRanges"];
|
|
8161
|
+
if (editRanges !== void 0) {
|
|
8162
|
+
if (!Array.isArray(editRanges) || editRanges.length === 0)
|
|
8163
|
+
return "edit ranges must be a non-empty array";
|
|
8164
|
+
if (!editRanges.every(isValidRange))
|
|
8165
|
+
return "edit ranges must be 1-indexed [start, end] with start <= end";
|
|
8166
|
+
}
|
|
8167
|
+
if (e["consumer"] !== void 0 && typeof e["consumer"] !== "string")
|
|
8168
|
+
return "consumer must be a string";
|
|
8169
|
+
if (e["importsChanged"] !== void 0 && typeof e["importsChanged"] !== "boolean")
|
|
8170
|
+
return "importsChanged must be a boolean";
|
|
8171
|
+
if (e["deferAutofix"] !== void 0 && typeof e["deferAutofix"] !== "boolean")
|
|
8172
|
+
return "deferAutofix must be a boolean";
|
|
8173
|
+
const provenance = e["provenance"];
|
|
8174
|
+
if (provenance !== void 0 && provenance !== "observed" && provenance !== "settled-sweep")
|
|
8175
|
+
return 'provenance must be "observed" or "settled-sweep"';
|
|
8176
|
+
if (e["toolCallId"] !== void 0 && typeof e["toolCallId"] !== "string")
|
|
8177
|
+
return "toolCallId must be a string";
|
|
8178
|
+
return void 0;
|
|
8179
|
+
}
|
|
8180
|
+
function resolveReadGuardBranchEpoch(value, currentEpoch) {
|
|
8181
|
+
if (value === void 0)
|
|
8182
|
+
return void 0;
|
|
8183
|
+
const wellFormed = typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
8184
|
+
if (wellFormed && value <= currentEpoch)
|
|
8185
|
+
return value;
|
|
8186
|
+
recordDegradationOnce({
|
|
8187
|
+
kind: "mutation-bridge-invalid-branch-epoch",
|
|
8188
|
+
subject: "readGuardBranchEpoch",
|
|
8189
|
+
// #3677 review round 1 F3: `typeof`, never `String(value)` — a
|
|
8190
|
+
// null-proto object has no `toString`, and the throw dropped the whole
|
|
8191
|
+
// record (turn state, receipt, deferral) out of the bridge's try.
|
|
8192
|
+
reason: wellFormed ? `ignored a readGuardBranchEpoch above the live epoch (${value} > ${currentEpoch})` : `ignored a foreign readGuardBranchEpoch (typeof ${typeof value}) (current ${currentEpoch})`
|
|
8193
|
+
});
|
|
8194
|
+
return void 0;
|
|
8195
|
+
}
|
|
8196
|
+
function resolveChangedRange(classification, deps, filePath) {
|
|
8197
|
+
if (classification.touchedLines) {
|
|
8198
|
+
const [start, end] = classification.touchedLines;
|
|
8199
|
+
return { start, end };
|
|
8200
|
+
}
|
|
8201
|
+
if (classification.editRanges && classification.editRanges.length > 0) {
|
|
8202
|
+
const starts = classification.editRanges.map(([start]) => start);
|
|
8203
|
+
const ends = classification.editRanges.map(([, end]) => end);
|
|
8204
|
+
return { start: Math.min(...starts), end: Math.max(...ends) };
|
|
8205
|
+
}
|
|
8206
|
+
return { start: 1, end: Math.max(1, deps.countFileLines(filePath)) };
|
|
8207
|
+
}
|
|
8208
|
+
function resolveAuthorshipRanges(classification) {
|
|
8209
|
+
if (classification.authorshipUnknown === true)
|
|
8210
|
+
return void 0;
|
|
8211
|
+
if (classification.editRanges && classification.editRanges.length > 0)
|
|
8212
|
+
return classification.editRanges;
|
|
8213
|
+
if (classification.touchedLines)
|
|
8214
|
+
return [classification.touchedLines];
|
|
8215
|
+
return void 0;
|
|
8216
|
+
}
|
|
8217
|
+
function rejectedOutcome(reason, detail) {
|
|
8218
|
+
return { recorded: false, accepted: false, reason, detail, queued: [] };
|
|
8219
|
+
}
|
|
8220
|
+
function stampLiveMutation(ctx, stampReadGuard) {
|
|
8221
|
+
const { entry, classification, runtime, filePath } = ctx;
|
|
8222
|
+
const lineage = entry.lineage;
|
|
8223
|
+
let sessionLive = true;
|
|
8224
|
+
if (lineage !== void 0 && lineage.guardedWrite(filePath, () => true) !== true) {
|
|
8225
|
+
sessionLive = false;
|
|
8226
|
+
if (stampReadGuard) {
|
|
8227
|
+
recordDroppedRead(lineage, entry.provenance ?? classification.toolName, entry.readGuardBranchEpoch ?? lineage.branchEpoch);
|
|
8228
|
+
}
|
|
8229
|
+
}
|
|
8230
|
+
const stamp = sessionLive ? resolveReadGuardBranchEpoch(entry.readGuardBranchEpoch, runtime.readGuard.currentBranchEpoch) : void 0;
|
|
8231
|
+
if (sessionLive && stampReadGuard)
|
|
8232
|
+
runStage(ctx, "stamp", () => stampReadGuardWrite(ctx, stamp));
|
|
8233
|
+
return { sessionLive, stamp };
|
|
8234
|
+
}
|
|
8235
|
+
function stampReadGuardWrite(ctx, stamp) {
|
|
8236
|
+
const { entry, classification, runtime, filePath } = ctx;
|
|
8237
|
+
{
|
|
8238
|
+
const authoredRanges = resolveAuthorshipRanges(classification);
|
|
8239
|
+
runtime.readGuard.recordWritten?.(filePath, {
|
|
8240
|
+
...stamp !== void 0 && { branchEpoch: stamp },
|
|
8241
|
+
// A process bridge reports a mutation, not the bytes delivered to the
|
|
8242
|
+
// conversation. Credit authorship, but leave FileTime at its last
|
|
8243
|
+
// conversation-backed observation (#3865).
|
|
8244
|
+
stampFileTime: false,
|
|
8245
|
+
// Nor may it re-baseline an existing authorship over bytes it wrote
|
|
8246
|
+
// around (#4131, #4187 R2-4): only the observed replay had a
|
|
8247
|
+
// pre-write check, its tool_call's retire. The rest (a co-process
|
|
8248
|
+
// producer, ast_grep_replace or an LSP edit) may create a first
|
|
8249
|
+
// authorship; settled-sweep drift never does (#4210). A drain retired
|
|
8250
|
+
// a changed authorship just before it wrote: the pre-write check
|
|
8251
|
+
// `recordWritten` reads from an omitted flag.
|
|
8252
|
+
...ctx.writer !== "drain" && {
|
|
8253
|
+
advanceAuthorship: entry.provenance === "observed"
|
|
8254
|
+
},
|
|
8255
|
+
// A first bridge credit is limited to the producer's reported range;
|
|
8256
|
+
// settled-sweep drift has no producer evidence and may not create one.
|
|
8257
|
+
...authoredRanges !== void 0 && { authoredRanges },
|
|
8258
|
+
authorship: authoredRanges !== void 0 ? "partial" : entry.kind === "write" ? "whole-file" : "unknown",
|
|
8259
|
+
allowFirstAuthorship: entry.provenance !== "settled-sweep",
|
|
8260
|
+
// #4187 R4-1: and an observed replay advances only a path its OWN
|
|
8261
|
+
// call licensed at tool_call (`ReadGuard.noteCheckedPaths`), since a
|
|
8262
|
+
// tool writes a set wider than the one it named. An entry with no
|
|
8263
|
+
// call (a co-process producer, a server-initiated edit) names none.
|
|
8264
|
+
...entry.toolCallId !== void 0 && { toolCallId: entry.toolCallId }
|
|
8265
|
+
});
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8268
|
+
function runStage(ctx, stage, run) {
|
|
8269
|
+
try {
|
|
8270
|
+
run();
|
|
8271
|
+
return true;
|
|
8272
|
+
} catch (err) {
|
|
8273
|
+
ctx.deps.dbg?.(`mutation_bridge: ${stage} failed for ${ctx.filePath}: ${err}`);
|
|
8274
|
+
recordDegradationOnce({
|
|
8275
|
+
kind: "mutation-bridge-stage-failed",
|
|
8276
|
+
subject: stage,
|
|
8277
|
+
reason: `the ${stage} stage of a mutation record threw for ${ctx.filePath}; the other stages still ran: ${err}`
|
|
8278
|
+
});
|
|
8279
|
+
return false;
|
|
8280
|
+
}
|
|
8281
|
+
}
|
|
8282
|
+
function applyTurnAndChangeLog(ctx, sessionLive) {
|
|
8283
|
+
const { entry, classification, deps, runtime, filePath, projectRoot } = ctx;
|
|
8284
|
+
const changedRange = resolveChangedRange(classification, deps, filePath);
|
|
8285
|
+
if (sessionLive) {
|
|
8286
|
+
runStage(ctx, "turn-state", () => deps.getCacheManager().addModifiedRange?.(filePath, changedRange, entry.importsChanged ?? false, projectRoot, entry.sessionId ?? runtime.telemetrySessionId));
|
|
8287
|
+
}
|
|
8288
|
+
if (!sessionLive && ctx.writer === "drain")
|
|
8289
|
+
return;
|
|
8290
|
+
runtime.recordProjectMutation?.({
|
|
8291
|
+
filePath,
|
|
8292
|
+
source: ctx.source,
|
|
8293
|
+
cwd: projectRoot,
|
|
8294
|
+
changedRange,
|
|
8295
|
+
// #4943: the writing session's change-log row (the turn-state range above
|
|
8296
|
+
// reads the same entry field).
|
|
8297
|
+
sessionId: entry.sessionId,
|
|
8298
|
+
onAppendError: (err) => deps.dbg?.(`mutation_bridge: change log append failed: ${err}`)
|
|
8299
|
+
});
|
|
8300
|
+
noteMutationHandled(filePath);
|
|
8301
|
+
}
|
|
8302
|
+
function queueDeferredMutation(ctx, sessionLive, stamp, queued) {
|
|
8303
|
+
const { entry, classification, runtime, filePath, projectRoot, dispatchCwd } = ctx;
|
|
8304
|
+
if (!sessionLive || entry.deferAutofix === false)
|
|
8305
|
+
return;
|
|
8306
|
+
for (const kind of ["autofix", "format"]) {
|
|
8307
|
+
const landed = runtime.deferMutation?.(
|
|
8308
|
+
filePath,
|
|
8309
|
+
dispatchCwd,
|
|
8310
|
+
classification.toolName,
|
|
8311
|
+
projectRoot,
|
|
8312
|
+
kind,
|
|
8313
|
+
// #4943: the writing session owns the record, so its own settle drains
|
|
8314
|
+
// it (the same owner the turn-state range above reads).
|
|
8315
|
+
entry.sessionId ?? runtime.telemetrySessionId,
|
|
8316
|
+
projectRoot,
|
|
8317
|
+
// #3521: the settled sweep's epoch, so a record it queues after
|
|
8318
|
+
// a /tree is not credited to the new branch. #3677: a value this
|
|
8319
|
+
// scope cannot hold is dropped (undefined), so the merge uses the
|
|
8320
|
+
// current epoch.
|
|
8321
|
+
stamp
|
|
8322
|
+
);
|
|
8323
|
+
if (landed)
|
|
8324
|
+
queued.push(kind);
|
|
8325
|
+
}
|
|
8326
|
+
}
|
|
8327
|
+
function runMutationBookkeeping(ctx, queued) {
|
|
8328
|
+
const stampReadGuard = ctx.deps.shouldStampReadGuard?.() ?? true;
|
|
8329
|
+
const { sessionLive, stamp } = stampLiveMutation(ctx, stampReadGuard);
|
|
8330
|
+
applyTurnAndChangeLog(ctx, sessionLive);
|
|
8331
|
+
runStage(ctx, "deferral", () => queueDeferredMutation(ctx, sessionLive, stamp, queued));
|
|
8332
|
+
return sessionLive;
|
|
8333
|
+
}
|
|
8334
|
+
function recordMutationOutcome(entry, deps, opts) {
|
|
8335
|
+
const problem = mutationEntryProblem(entry);
|
|
8336
|
+
if (problem !== void 0) {
|
|
8337
|
+
deps.dbg?.(`mutation_bridge: dropped malformed entry: ${problem}`);
|
|
8338
|
+
return rejectedOutcome("malformed", problem);
|
|
8339
|
+
}
|
|
8340
|
+
const valid = entry;
|
|
8341
|
+
if (!deps.isRecordable(valid.filePath)) {
|
|
8342
|
+
deps.dbg?.(`mutation_bridge: out of scope ${valid.filePath}`);
|
|
8343
|
+
return rejectedOutcome("out-of-scope", valid.filePath);
|
|
8344
|
+
}
|
|
8345
|
+
const outcome = runAdmittedMutation(valid, deps, opts);
|
|
8346
|
+
if (outcome.queued.length > 0)
|
|
8347
|
+
publishQueued(valid, deps, outcome.queued);
|
|
8348
|
+
return outcome;
|
|
8349
|
+
}
|
|
8350
|
+
function publishQueued(entry, deps, queued) {
|
|
8351
|
+
const publish = deps.publishFormatQueued ?? publishFormatQueued;
|
|
8352
|
+
try {
|
|
8353
|
+
publish({
|
|
8354
|
+
filePath: entry.filePath,
|
|
8355
|
+
cwd: deps.getDispatchCwd(entry.filePath),
|
|
8356
|
+
tool: entry.kind,
|
|
8357
|
+
kinds: [...queued],
|
|
8358
|
+
...deps.dbg !== void 0 && { dbg: deps.dbg }
|
|
8359
|
+
});
|
|
8360
|
+
} catch (err) {
|
|
8361
|
+
deps.dbg?.(`mutation_bridge: format-queued publish failed for ${entry.filePath}: ${err}`);
|
|
8362
|
+
}
|
|
8363
|
+
}
|
|
8364
|
+
function runAdmittedMutation(entry, deps, opts) {
|
|
8365
|
+
const writer3 = opts?.writer ?? "agent";
|
|
8366
|
+
if (writer3 === "agent")
|
|
8367
|
+
(deps.noteAgentMutation ?? noteAgentMutation)(entry.filePath);
|
|
8368
|
+
const classification = classifyBridgeMutation(entry);
|
|
8369
|
+
const ctx = {
|
|
8370
|
+
entry,
|
|
8371
|
+
classification,
|
|
8372
|
+
deps,
|
|
8373
|
+
writer: writer3,
|
|
8374
|
+
source: opts?.source ?? `agent-tool:${classification.toolName}`,
|
|
8375
|
+
runtime: deps.getRuntime(),
|
|
8376
|
+
filePath: entry.filePath,
|
|
8377
|
+
projectRoot: deps.getProjectRoot(),
|
|
8378
|
+
dispatchCwd: deps.getDispatchCwd(entry.filePath)
|
|
8379
|
+
};
|
|
8380
|
+
const queued = [];
|
|
8381
|
+
let sessionLive = true;
|
|
8382
|
+
try {
|
|
8383
|
+
sessionLive = runMutationBookkeeping(ctx, queued);
|
|
8384
|
+
} catch (err) {
|
|
8385
|
+
deps.dbg?.(`mutation_bridge: recording failed for ${ctx.filePath}: ${err}`);
|
|
8386
|
+
return {
|
|
8387
|
+
recorded: false,
|
|
8388
|
+
accepted: false,
|
|
8389
|
+
reason: "bookkeeping-error",
|
|
8390
|
+
detail: `${err}`,
|
|
8391
|
+
queued
|
|
8392
|
+
};
|
|
8393
|
+
}
|
|
8394
|
+
if (entry.toolCallId !== void 0)
|
|
8395
|
+
ctx.runtime.noteCallWrite?.(entry.toolCallId, ctx.filePath);
|
|
8396
|
+
const accepted = sessionLive || opts?.rejectStaleLineage !== true;
|
|
8397
|
+
return accepted ? { recorded: true, accepted: true, queued } : { recorded: true, accepted: false, reason: "stale-lineage", queued };
|
|
8398
|
+
}
|
|
7982
8399
|
function getMutationBridge() {
|
|
7983
8400
|
const candidate = getProcessBridge(MUTATION_BRIDGE_KEY, 1);
|
|
7984
8401
|
return typeof candidate?.recordMutation === "function" ? candidate : void 0;
|
|
@@ -8083,129 +8500,92 @@ function uniqueDetails(files2, fileDetails) {
|
|
|
8083
8500
|
importsChanged: true
|
|
8084
8501
|
});
|
|
8085
8502
|
}
|
|
8503
|
+
function lspMutationEntry(context, filePath, detail) {
|
|
8504
|
+
const known = detail.authorshipUnknown !== true;
|
|
8505
|
+
const editRanges = detail.ranges && known ? detail.ranges.map(({ start, end }) => [start, end]) : detail.range && known ? [[detail.range.start, detail.range.end]] : void 0;
|
|
8506
|
+
return {
|
|
8507
|
+
filePath,
|
|
8508
|
+
kind: "edit",
|
|
8509
|
+
...detail.range !== void 0 && {
|
|
8510
|
+
touchedLines: [detail.range.start, detail.range.end]
|
|
8511
|
+
},
|
|
8512
|
+
...!known && { authorshipUnknown: true },
|
|
8513
|
+
...editRanges !== void 0 ? { editRanges } : {},
|
|
8514
|
+
...context.sessionId !== void 0 && { sessionId: context.sessionId },
|
|
8515
|
+
consumer: context.tool,
|
|
8516
|
+
// The server computed the bytes and the call's own `tool_call` retire
|
|
8517
|
+
// licenses the advance (#3525, #4187 R4-1): an observed write.
|
|
8518
|
+
provenance: "observed",
|
|
8519
|
+
// The tsserver organize-imports or add-import case is exactly the
|
|
8520
|
+
// import-changing one (#2450 review round 2, F1).
|
|
8521
|
+
importsChanged: detail.importsChanged ?? true,
|
|
8522
|
+
// An LSP-applied edit queues no deferred autofix or format pass (#2450
|
|
8523
|
+
// review round 2, F3).
|
|
8524
|
+
deferAutofix: false,
|
|
8525
|
+
...context.session && { lineage: context.session },
|
|
8526
|
+
...context.toolCallId !== void 0 && {
|
|
8527
|
+
toolCallId: context.toolCallId
|
|
8528
|
+
}
|
|
8529
|
+
};
|
|
8530
|
+
}
|
|
8531
|
+
function directBookkeepingDeps(context, runtime, cacheManager) {
|
|
8532
|
+
const readGuard = context.readGuard;
|
|
8533
|
+
return {
|
|
8534
|
+
getRuntime: () => ({
|
|
8535
|
+
turnIndex: runtime.turnIndex ?? 0,
|
|
8536
|
+
telemetrySessionId: runtime.telemetrySessionId,
|
|
8537
|
+
readGuard: {
|
|
8538
|
+
// An LSP entry names no `readGuardBranchEpoch`, so the seam never
|
|
8539
|
+
// compares against this.
|
|
8540
|
+
currentBranchEpoch: 0,
|
|
8541
|
+
...readGuard !== void 0 && {
|
|
8542
|
+
recordWritten: (filePath, opts) => readGuard.recordWritten(filePath, opts)
|
|
8543
|
+
}
|
|
8544
|
+
},
|
|
8545
|
+
...runtime.recordProjectMutation !== void 0 && {
|
|
8546
|
+
recordProjectMutation: (args) => runtime.recordProjectMutation?.(args)
|
|
8547
|
+
},
|
|
8548
|
+
...runtime.noteCallWrite !== void 0 && {
|
|
8549
|
+
noteCallWrite: (toolCallId, filePath) => runtime.noteCallWrite?.(toolCallId, filePath)
|
|
8550
|
+
}
|
|
8551
|
+
}),
|
|
8552
|
+
getCacheManager: () => ({
|
|
8553
|
+
addModifiedRange: (filePath, range, importsChanged, cwd, sessionId) => cacheManager.addModifiedRange(filePath, range, importsChanged, cwd, sessionId ?? void 0, void 0, runtime.projectRoot ?? context.cwd)
|
|
8554
|
+
}),
|
|
8555
|
+
getProjectRoot: () => context.cwd,
|
|
8556
|
+
getDispatchCwd: () => context.cwd,
|
|
8557
|
+
// Every detail carries a range (`uniqueDetails`), so the seam never
|
|
8558
|
+
// counts lines; a resource operation must not re-read the file.
|
|
8559
|
+
countFileLines: () => 1,
|
|
8560
|
+
// `bookkeepLspMutation` applied `context.isRecordable` already.
|
|
8561
|
+
isRecordable: () => true,
|
|
8562
|
+
shouldStampReadGuard: () => readGuard !== void 0,
|
|
8563
|
+
noteAgentMutation: () => void 0,
|
|
8564
|
+
...context.dbg !== void 0 && { dbg: context.dbg }
|
|
8565
|
+
};
|
|
8566
|
+
}
|
|
8086
8567
|
function bookkeepLspMutation(context, files2, fileDetails) {
|
|
8087
8568
|
const details = uniqueDetails(files2, fileDetails);
|
|
8088
|
-
const
|
|
8569
|
+
const runtime = context.runtime;
|
|
8570
|
+
const cacheManager = context.cacheManager;
|
|
8571
|
+
const deps = runtime && cacheManager ? directBookkeepingDeps(context, runtime, cacheManager) : void 0;
|
|
8089
8572
|
for (const detail of details) {
|
|
8090
8573
|
const filePath = path7.resolve(detail.filePath);
|
|
8091
|
-
const sessionLive = !context.session || context.session.guardedWrite(filePath, () => true) !== void 0;
|
|
8092
8574
|
if (context.isRecordable && !context.isRecordable(filePath)) {
|
|
8093
8575
|
context.dbg?.(`lsp mutation not recordable, skipping ${filePath}`);
|
|
8094
8576
|
continue;
|
|
8095
8577
|
}
|
|
8096
|
-
let
|
|
8097
|
-
if (
|
|
8098
|
-
|
|
8099
|
-
context.
|
|
8100
|
-
stampFileTime: false,
|
|
8101
|
-
advanceAuthorship: true,
|
|
8102
|
-
...detail.authorshipUnknown !== true && detail.ranges !== void 0 && {
|
|
8103
|
-
authorship: "partial",
|
|
8104
|
-
authoredRanges: detail.ranges.map(({ start, end }) => [start, end])
|
|
8105
|
-
},
|
|
8106
|
-
...detail.authorshipUnknown === true && { authorship: "unknown" },
|
|
8107
|
-
...context.toolCallId !== void 0 && {
|
|
8108
|
-
toolCallId: context.toolCallId
|
|
8109
|
-
}
|
|
8110
|
-
});
|
|
8111
|
-
} catch (err) {
|
|
8112
|
-
context.dbg?.(`lsp mutation read-guard stamp failed for ${filePath}: ${err}`);
|
|
8113
|
-
}
|
|
8114
|
-
}
|
|
8115
|
-
if (useBridgeFallback) {
|
|
8116
|
-
const bridge = getMutationBridge();
|
|
8117
|
-
if (!bridge) {
|
|
8118
|
-
accepted = false;
|
|
8119
|
-
recordDegradationOnce({
|
|
8120
|
-
kind: "lsp-mutation-bridge-unmounted",
|
|
8121
|
-
subject: "lsp-mutation:no-bridge",
|
|
8122
|
-
reason: "workspace/applyEdit bookkeeping fell back to the mutation bridge, but no bridge is mounted in this process (e.g. the MCP server, which never runs pi's extension activation) \u2014 the write is unrecorded (no read-guard stamp, no turn-state entry, no change-log receipt)."
|
|
8123
|
-
});
|
|
8124
|
-
if (!noBridgeDbgLogged) {
|
|
8125
|
-
noBridgeDbgLogged = true;
|
|
8126
|
-
context.dbg?.(`lsp mutation bridge unavailable, dropping bookkeeping for ${filePath}`);
|
|
8127
|
-
}
|
|
8128
|
-
} else {
|
|
8129
|
-
try {
|
|
8130
|
-
const editRanges = detail.ranges && detail.authorshipUnknown !== true ? detail.ranges.map(({ start, end }) => [start, end]) : detail.range && detail.authorshipUnknown !== true ? [[detail.range.start, detail.range.end]] : void 0;
|
|
8131
|
-
const recorded = bridge.recordMutation({
|
|
8132
|
-
filePath,
|
|
8133
|
-
kind: "edit",
|
|
8134
|
-
...detail.range !== void 0 && {
|
|
8135
|
-
touchedLines: [detail.range.start, detail.range.end]
|
|
8136
|
-
},
|
|
8137
|
-
...detail.authorshipUnknown === true && {
|
|
8138
|
-
authorshipUnknown: true
|
|
8139
|
-
},
|
|
8140
|
-
...editRanges !== void 0 ? { editRanges } : {},
|
|
8141
|
-
...context.sessionId !== void 0 && {
|
|
8142
|
-
sessionId: context.sessionId
|
|
8143
|
-
},
|
|
8144
|
-
consumer: context.tool,
|
|
8145
|
-
provenance: "observed",
|
|
8146
|
-
// Real value threaded through, not the bridge's own
|
|
8147
|
-
// historical `false` default (#2450 review round 2, F1) —
|
|
8148
|
-
// the tsserver organize-imports/add-import case is exactly
|
|
8149
|
-
// the import-changing one.
|
|
8150
|
-
importsChanged: detail.importsChanged ?? true,
|
|
8151
|
-
// Equivalence with the direct branch below, which never
|
|
8152
|
-
// enqueues a deferred autofix/format pass for an LSP-applied
|
|
8153
|
-
// edit (#2450 review round 2, F3).
|
|
8154
|
-
deferAutofix: false,
|
|
8155
|
-
...context.session && { lineage: context.session },
|
|
8156
|
-
// #4187 R4-1: the same license the direct branch threads, so
|
|
8157
|
-
// the two branches stay equivalent for the same write.
|
|
8158
|
-
...context.toolCallId !== void 0 && {
|
|
8159
|
-
toolCallId: context.toolCallId
|
|
8160
|
-
}
|
|
8161
|
-
});
|
|
8162
|
-
if (!recorded) {
|
|
8163
|
-
accepted = false;
|
|
8164
|
-
context.dbg?.(`lsp mutation bridge dropped ${filePath} (recordMutation() returned false \u2014 see the mutation_bridge debug output for the reason: malformed entry, out-of-scope path, or a bookkeeping error)`);
|
|
8165
|
-
}
|
|
8166
|
-
} catch (err) {
|
|
8167
|
-
accepted = false;
|
|
8168
|
-
context.dbg?.(`lsp mutation bridge fallback failed for ${filePath}: ${err}`);
|
|
8169
|
-
}
|
|
8170
|
-
}
|
|
8171
|
-
} else {
|
|
8172
|
-
const runtime = context.runtime;
|
|
8173
|
-
runtime?.recordProjectMutation?.({
|
|
8174
|
-
filePath,
|
|
8175
|
-
source: context.source,
|
|
8176
|
-
cwd: context.cwd,
|
|
8177
|
-
changedRange: detail.range,
|
|
8178
|
-
// #4943: the issuing activation's change-log row.
|
|
8179
|
-
sessionId: context.sessionId,
|
|
8180
|
-
onAppendError: (err) => context.dbg?.(`lsp mutation project change append failed for ${filePath}: ${err}`)
|
|
8578
|
+
let sessionLive;
|
|
8579
|
+
if (deps) {
|
|
8580
|
+
recordMutationOutcome(lspMutationEntry(context, filePath, detail), deps, {
|
|
8581
|
+
source: context.source
|
|
8181
8582
|
});
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
context.cwd,
|
|
8189
|
-
context.sessionId ?? runtime?.telemetrySessionId,
|
|
8190
|
-
void 0,
|
|
8191
|
-
// #2504 review round 2 (F1). #2504 added a containment
|
|
8192
|
-
// filter to `addModifiedRange` and gave it `cwd` as the
|
|
8193
|
-
// project root. On THIS path `cwd` is the calling
|
|
8194
|
-
// directory, which `tools/lsp-navigation.ts` scopes to a
|
|
8195
|
-
// sub-package while the LSP client's root spans the whole
|
|
8196
|
-
// monorepo — so a server-initiated edit on a sibling
|
|
8197
|
-
// package (#2450) and every edit whose context carries a
|
|
8198
|
-
// separate bookkeeping cwd (#2479) were silently dropped
|
|
8199
|
-
// from the worklist. Same root the `isRecordable` gate a
|
|
8200
|
-
// few frames up already uses: `runtime.projectRoot`,
|
|
8201
|
-
// falling back to `cwd` when no runtime is threaded.
|
|
8202
|
-
runtime?.projectRoot ?? context.cwd
|
|
8203
|
-
);
|
|
8204
|
-
} catch (err) {
|
|
8205
|
-
context.dbg?.(`lsp mutation modified-range tracking failed for ${filePath}: ${err}`);
|
|
8206
|
-
}
|
|
8207
|
-
}
|
|
8208
|
-
noteMutationHandled(filePath);
|
|
8583
|
+
sessionLive = !context.session || context.session.isCurrent();
|
|
8584
|
+
} else {
|
|
8585
|
+
sessionLive = !context.session || context.session.guardedWrite(filePath, () => true) !== void 0;
|
|
8586
|
+
if (sessionLive)
|
|
8587
|
+
stampFallbackReadGuard(context, filePath, detail);
|
|
8588
|
+
recordThroughBridge(context, filePath, detail);
|
|
8209
8589
|
}
|
|
8210
8590
|
if (sessionLive && context.recordAutofix && context.source === "autofix") {
|
|
8211
8591
|
const key = normalizeMapKey(filePath);
|
|
@@ -8216,13 +8596,53 @@ function bookkeepLspMutation(context, files2, fileDetails) {
|
|
|
8216
8596
|
context.recordAutofix(filePath);
|
|
8217
8597
|
}
|
|
8218
8598
|
}
|
|
8219
|
-
if (accepted && context.acceptedFiles && !context.acceptedFiles.includes(filePath))
|
|
8220
|
-
context.acceptedFiles.push(filePath);
|
|
8221
8599
|
}
|
|
8222
8600
|
if (context.publishFilesTouched && files2.length > 0) {
|
|
8223
8601
|
context.publishFilesTouched(files2);
|
|
8224
8602
|
}
|
|
8225
8603
|
}
|
|
8604
|
+
function stampFallbackReadGuard(context, filePath, detail) {
|
|
8605
|
+
if (!context.readGuard)
|
|
8606
|
+
return;
|
|
8607
|
+
try {
|
|
8608
|
+
context.readGuard.recordWritten(filePath, {
|
|
8609
|
+
stampFileTime: false,
|
|
8610
|
+
advanceAuthorship: true,
|
|
8611
|
+
...detail.authorshipUnknown !== true && detail.ranges !== void 0 && {
|
|
8612
|
+
authorship: "partial",
|
|
8613
|
+
authoredRanges: detail.ranges.map(({ start, end }) => [start, end])
|
|
8614
|
+
},
|
|
8615
|
+
...detail.authorshipUnknown === true && { authorship: "unknown" },
|
|
8616
|
+
...context.toolCallId !== void 0 && {
|
|
8617
|
+
toolCallId: context.toolCallId
|
|
8618
|
+
}
|
|
8619
|
+
});
|
|
8620
|
+
} catch (err) {
|
|
8621
|
+
context.dbg?.(`lsp mutation read-guard stamp failed for ${filePath}: ${err}`);
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
function recordThroughBridge(context, filePath, detail) {
|
|
8625
|
+
const bridge = getMutationBridge();
|
|
8626
|
+
if (!bridge) {
|
|
8627
|
+
recordDegradationOnce({
|
|
8628
|
+
kind: "lsp-mutation-bridge-unmounted",
|
|
8629
|
+
subject: "lsp-mutation:no-bridge",
|
|
8630
|
+
reason: "workspace/applyEdit bookkeeping fell back to the mutation bridge, but no bridge is mounted in this process (e.g. the MCP server, which never runs pi's extension activation) \u2014 the write is unrecorded (no read-guard stamp, no turn-state entry, no change-log receipt)."
|
|
8631
|
+
});
|
|
8632
|
+
if (!noBridgeDbgLogged) {
|
|
8633
|
+
noBridgeDbgLogged = true;
|
|
8634
|
+
context.dbg?.(`lsp mutation bridge unavailable, dropping bookkeeping for ${filePath}`);
|
|
8635
|
+
}
|
|
8636
|
+
return;
|
|
8637
|
+
}
|
|
8638
|
+
try {
|
|
8639
|
+
if (bridge.recordMutation(lspMutationEntry(context, filePath, detail)))
|
|
8640
|
+
return;
|
|
8641
|
+
context.dbg?.(`lsp mutation bridge dropped ${filePath} (recordMutation() returned false \u2014 see the mutation_bridge debug output for the reason: malformed entry, out-of-scope path, or a bookkeeping error)`);
|
|
8642
|
+
} catch (err) {
|
|
8643
|
+
context.dbg?.(`lsp mutation bridge fallback failed for ${filePath}: ${err}`);
|
|
8644
|
+
}
|
|
8645
|
+
}
|
|
8226
8646
|
function telemetryFor(context, options) {
|
|
8227
8647
|
const combined = combineResults(allResults(options));
|
|
8228
8648
|
const requestedTotal = options.requestedTotal ?? combined.requestedTotal;
|
|
@@ -8319,7 +8739,7 @@ function recordLspMutationOutcome(context, status) {
|
|
|
8319
8739
|
|
|
8320
8740
|
// dist/clients/lsp/diagnostic-binding.js
|
|
8321
8741
|
import { createHash as createHash4 } from "node:crypto";
|
|
8322
|
-
import * as
|
|
8742
|
+
import * as fs6 from "node:fs";
|
|
8323
8743
|
function resolveTouchVerdict(input) {
|
|
8324
8744
|
const unavailableIds = [...new Set(input.unavailablePrimaryServerIds ?? [])];
|
|
8325
8745
|
if (unavailableIds.length > 0) {
|
|
@@ -8340,11 +8760,18 @@ function resolveTouchVerdict(input) {
|
|
|
8340
8760
|
return { inconclusive: false };
|
|
8341
8761
|
}
|
|
8342
8762
|
const serverIds = [.../* @__PURE__ */ new Set([...notifyIds, ...waitIds])];
|
|
8343
|
-
const
|
|
8763
|
+
const loadingIds = new Set(input.loadingServerIds ?? []);
|
|
8764
|
+
const failedIds = new Set(input.loadFailedServerIds ?? []);
|
|
8765
|
+
const lapsedNotReady = waitIds.length > 0 && waitIds.every((id) => loadingIds.has(id) || failedIds.has(id));
|
|
8766
|
+
const lapsedLoadFailed = lapsedNotReady && waitIds.some((id) => failedIds.has(id));
|
|
8767
|
+
const reason = notifyIds.length > 0 && input.diagnosticsTimedOut ? "mixed" : notifyIds.length > 0 ? "notify-write" : lapsedLoadFailed ? "server-load-failed" : lapsedNotReady ? "server-loading" : "diagnostics-wait";
|
|
8344
8768
|
return {
|
|
8345
8769
|
inconclusive: true,
|
|
8346
8770
|
...serverIds.length > 0 && { inconclusiveServerIds: serverIds },
|
|
8347
|
-
inconclusiveReason: reason
|
|
8771
|
+
inconclusiveReason: reason,
|
|
8772
|
+
...reason === "server-load-failed" && input.loadFailureDetail !== void 0 && {
|
|
8773
|
+
inconclusiveDetail: input.loadFailureDetail
|
|
8774
|
+
}
|
|
8348
8775
|
};
|
|
8349
8776
|
}
|
|
8350
8777
|
var PRIMARY_UNAVAILABLE_CAUSE = {
|
|
@@ -8421,7 +8848,7 @@ function createDiskBindingCache() {
|
|
|
8421
8848
|
return "unknown";
|
|
8422
8849
|
let stat3;
|
|
8423
8850
|
try {
|
|
8424
|
-
stat3 =
|
|
8851
|
+
stat3 = fs6.statSync(filePath);
|
|
8425
8852
|
} catch {
|
|
8426
8853
|
return "unknown";
|
|
8427
8854
|
}
|
|
@@ -8429,7 +8856,7 @@ function createDiskBindingCache() {
|
|
|
8429
8856
|
if (!cached || cached.mtimeMs !== stat3.mtimeMs || cached.size !== stat3.size) {
|
|
8430
8857
|
let diskHash;
|
|
8431
8858
|
try {
|
|
8432
|
-
diskHash = hashDiagnosticContent(
|
|
8859
|
+
diskHash = hashDiagnosticContent(fs6.readFileSync(filePath, "utf-8"));
|
|
8433
8860
|
} catch {
|
|
8434
8861
|
return "unknown";
|
|
8435
8862
|
}
|
|
@@ -8448,11 +8875,18 @@ function createDiskBindingCache() {
|
|
|
8448
8875
|
import { basename } from "node:path";
|
|
8449
8876
|
var CONFIG_FILE_SERVERS = /* @__PURE__ */ new Map([
|
|
8450
8877
|
["pyrightconfig.json", ["python"]],
|
|
8451
|
-
["pyproject.toml", ["python"]]
|
|
8878
|
+
["pyproject.toml", ["python"]],
|
|
8879
|
+
["Cargo.toml", ["rust"]],
|
|
8880
|
+
["go.mod", ["go"]],
|
|
8881
|
+
["go.work", ["go"]]
|
|
8452
8882
|
]);
|
|
8453
8883
|
var SERVER_CONFIG_FILE_NAMES = [
|
|
8454
8884
|
...CONFIG_FILE_SERVERS.keys()
|
|
8455
8885
|
];
|
|
8886
|
+
var BELOW_ROOT_CONFIG_FILE_NAMES = /* @__PURE__ */ new Set([
|
|
8887
|
+
"Cargo.toml",
|
|
8888
|
+
"go.mod"
|
|
8889
|
+
]);
|
|
8456
8890
|
function serverIdsForConfigFile(filePath) {
|
|
8457
8891
|
return CONFIG_FILE_SERVERS.get(basename(filePath));
|
|
8458
8892
|
}
|
|
@@ -8522,12 +8956,12 @@ async function runPerServerGroups(groups, concurrency, processGroup, signal) {
|
|
|
8522
8956
|
import path13 from "node:path";
|
|
8523
8957
|
|
|
8524
8958
|
// dist/clients/widget-state.js
|
|
8525
|
-
import { readFileSync as
|
|
8959
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
8526
8960
|
import { stat } from "node:fs/promises";
|
|
8527
8961
|
import { pathToFileURL } from "node:url";
|
|
8528
8962
|
|
|
8529
8963
|
// dist/clients/diagnostic-line-freshness.js
|
|
8530
|
-
import * as
|
|
8964
|
+
import * as fs7 from "node:fs";
|
|
8531
8965
|
|
|
8532
8966
|
// dist/clients/stale-marker.js
|
|
8533
8967
|
var STALE_LINE_MARKER = "[stale \u2014 re-run to confirm]";
|
|
@@ -8544,13 +8978,13 @@ function rememberInSharedCache(cache, filePath, entry) {
|
|
|
8544
8978
|
cache.set(filePath, entry);
|
|
8545
8979
|
}
|
|
8546
8980
|
function countNewlinesChunked(filePath, sizeBytes) {
|
|
8547
|
-
const fd =
|
|
8981
|
+
const fd = fs7.openSync(filePath, "r");
|
|
8548
8982
|
try {
|
|
8549
8983
|
const buffer = Buffer.allocUnsafe(Math.min(NEWLINE_SCAN_CHUNK_BYTES, sizeBytes) || 1);
|
|
8550
8984
|
let newlineCount = 0;
|
|
8551
8985
|
let position = 0;
|
|
8552
8986
|
while (position < sizeBytes) {
|
|
8553
|
-
const bytesRead =
|
|
8987
|
+
const bytesRead = fs7.readSync(fd, buffer, 0, buffer.length, position);
|
|
8554
8988
|
if (bytesRead <= 0)
|
|
8555
8989
|
break;
|
|
8556
8990
|
for (let i = 0; i < bytesRead; i++) {
|
|
@@ -8561,13 +8995,13 @@ function countNewlinesChunked(filePath, sizeBytes) {
|
|
|
8561
8995
|
}
|
|
8562
8996
|
return newlineCount;
|
|
8563
8997
|
} finally {
|
|
8564
|
-
|
|
8998
|
+
fs7.closeSync(fd);
|
|
8565
8999
|
}
|
|
8566
9000
|
}
|
|
8567
9001
|
function getCachedLineCount(filePath, cache = sharedLineCountCache) {
|
|
8568
9002
|
let stat3;
|
|
8569
9003
|
try {
|
|
8570
|
-
stat3 =
|
|
9004
|
+
stat3 = fs7.statSync(filePath);
|
|
8571
9005
|
} catch {
|
|
8572
9006
|
return void 0;
|
|
8573
9007
|
}
|
|
@@ -8622,7 +9056,7 @@ function demotePastEofDiagnostics(args) {
|
|
|
8622
9056
|
}
|
|
8623
9057
|
let sizeBytes;
|
|
8624
9058
|
try {
|
|
8625
|
-
sizeBytes =
|
|
9059
|
+
sizeBytes = fs7.statSync(args.filePath).size;
|
|
8626
9060
|
} catch {
|
|
8627
9061
|
sizeBytes = 0;
|
|
8628
9062
|
}
|
|
@@ -8652,8 +9086,8 @@ function resyncDocumentOnPastEof(filePath) {
|
|
|
8652
9086
|
void (async () => {
|
|
8653
9087
|
try {
|
|
8654
9088
|
const [{ getOwnedLspService: getOwnedLspService2 }, content] = await Promise.all([
|
|
8655
|
-
import("./chunk-
|
|
8656
|
-
|
|
9089
|
+
import("./chunk-EBXCYEII.js"),
|
|
9090
|
+
fs7.promises.readFile(filePath, "utf-8")
|
|
8657
9091
|
]);
|
|
8658
9092
|
await getOwnedLspService2().openFile(filePath, content, { preserveDiagnostics: false });
|
|
8659
9093
|
} catch {
|
|
@@ -8750,7 +9184,7 @@ function inlineBlockerPlaces(blockers, filePath) {
|
|
|
8750
9184
|
}
|
|
8751
9185
|
|
|
8752
9186
|
// dist/clients/diagnostic-dispositions.js
|
|
8753
|
-
import * as
|
|
9187
|
+
import * as fs8 from "node:fs";
|
|
8754
9188
|
import * as path9 from "node:path";
|
|
8755
9189
|
|
|
8756
9190
|
// dist/clients/disposition-logger.js
|
|
@@ -8840,7 +9274,7 @@ function statePath(cwd) {
|
|
|
8840
9274
|
return path9.join(getProjectDataDir(cwd), "cache", "diagnostic-dispositions.json");
|
|
8841
9275
|
}
|
|
8842
9276
|
var stateCache = null;
|
|
8843
|
-
var dispositionStatSync =
|
|
9277
|
+
var dispositionStatSync = fs8.statSync;
|
|
8844
9278
|
function hasAnyDispositionMarks(cwd) {
|
|
8845
9279
|
return Boolean(readState(cwd).dispositions) || hasDeferredThisSession(cwd);
|
|
8846
9280
|
}
|
|
@@ -8854,7 +9288,7 @@ function hasStrictDispositionMarks(cwd) {
|
|
|
8854
9288
|
}
|
|
8855
9289
|
return false;
|
|
8856
9290
|
}
|
|
8857
|
-
var multiFileReadFileSync =
|
|
9291
|
+
var multiFileReadFileSync = fs8.readFileSync;
|
|
8858
9292
|
function readState(cwd) {
|
|
8859
9293
|
const p = statePath(cwd);
|
|
8860
9294
|
let stat3;
|
|
@@ -8879,7 +9313,7 @@ function readState(cwd) {
|
|
|
8879
9313
|
}
|
|
8880
9314
|
let state4;
|
|
8881
9315
|
try {
|
|
8882
|
-
const parsed = JSON.parse(
|
|
9316
|
+
const parsed = JSON.parse(fs8.readFileSync(p, "utf-8"));
|
|
8883
9317
|
state4 = parsed && typeof parsed === "object" ? parsed : {};
|
|
8884
9318
|
} catch {
|
|
8885
9319
|
state4 = {};
|
|
@@ -9010,7 +9444,7 @@ function cachedAnchorMarks(input) {
|
|
|
9010
9444
|
return { marks: "weak-only" };
|
|
9011
9445
|
let stat3;
|
|
9012
9446
|
try {
|
|
9013
|
-
stat3 =
|
|
9447
|
+
stat3 = fs8.statSync(anchor);
|
|
9014
9448
|
} catch {
|
|
9015
9449
|
return cited ? { marks: "refused" } : { marks: "weak-only" };
|
|
9016
9450
|
}
|
|
@@ -9057,11 +9491,11 @@ function filterPerFileGroup(diagnostics, cwd, filePathOf, applyGroup) {
|
|
|
9057
9491
|
}
|
|
9058
9492
|
|
|
9059
9493
|
// dist/clients/session-state-store.js
|
|
9060
|
-
import { promises as
|
|
9494
|
+
import { promises as fs9 } from "node:fs";
|
|
9061
9495
|
async function dropStaleFiles(widget, savedAt) {
|
|
9062
9496
|
const checked = await Promise.all(widget.files.map(async (file) => {
|
|
9063
9497
|
try {
|
|
9064
|
-
const st = await
|
|
9498
|
+
const st = await fs9.stat(file.filePath);
|
|
9065
9499
|
return freshnessFromMtime({
|
|
9066
9500
|
mtimeMs: st.mtimeMs,
|
|
9067
9501
|
referenceMs: savedAt,
|
|
@@ -9172,6 +9606,7 @@ function isBlocking(d) {
|
|
|
9172
9606
|
var files = /* @__PURE__ */ new Map();
|
|
9173
9607
|
var sessionLanguages = [];
|
|
9174
9608
|
var requestRenderFn = null;
|
|
9609
|
+
var widgetChangeFn = null;
|
|
9175
9610
|
var diagnosticsWriteGuard = new WriteOrderingGuard();
|
|
9176
9611
|
var runnerWriteGuard = new WriteOrderingGuard();
|
|
9177
9612
|
var MAX_STORED_DIAGNOSTICS_PER_FILE = 12;
|
|
@@ -9210,7 +9645,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9210
9645
|
let source = content ?? target.content;
|
|
9211
9646
|
if (source === void 0) {
|
|
9212
9647
|
try {
|
|
9213
|
-
source =
|
|
9648
|
+
source = readFileSync7(target.filePath, "utf8");
|
|
9214
9649
|
} catch {
|
|
9215
9650
|
recordDegradationOnce({
|
|
9216
9651
|
kind: "widget-disposition-reconcile-fallback",
|
|
@@ -9262,7 +9697,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9262
9697
|
active.add(d);
|
|
9263
9698
|
}
|
|
9264
9699
|
}
|
|
9265
|
-
const
|
|
9700
|
+
const normalized2 = current.flatMap((diagnostic) => {
|
|
9266
9701
|
const anchor = diagnostic.citedFile ?? target.filePath;
|
|
9267
9702
|
const decision = anchor === target.filePath ? void 0 : citedMarks.get(anchor);
|
|
9268
9703
|
const refused = decision?.marks === "refused";
|
|
@@ -9299,7 +9734,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9299
9734
|
if (!diagnosticsWriteGuard.shouldWrite(fileMapKey(target.filePath), writeIndex))
|
|
9300
9735
|
return;
|
|
9301
9736
|
const { hasFinalDiagnosticsSnapshot, touchedAt } = rec;
|
|
9302
|
-
commitDiagnostics(rec, target.filePath,
|
|
9737
|
+
commitDiagnostics(rec, target.filePath, normalized2, Date.now(), fileMapKey(target.filePath), false);
|
|
9303
9738
|
if (!hasFinalDiagnosticsSnapshot) {
|
|
9304
9739
|
rec.hasFinalDiagnosticsSnapshot = false;
|
|
9305
9740
|
rec.touchedAt = touchedAt;
|
|
@@ -9323,6 +9758,7 @@ function clearWidgetState() {
|
|
|
9323
9758
|
diagnosticsWriteGuard.clear();
|
|
9324
9759
|
runnerWriteGuard.clear();
|
|
9325
9760
|
nextInactivePruneSize = MAX_INACTIVE_FILE_RECORDS + 1;
|
|
9761
|
+
requestRender();
|
|
9326
9762
|
}
|
|
9327
9763
|
var WIDGET_STATE_VERSION = 3;
|
|
9328
9764
|
function exportWidgetState() {
|
|
@@ -9385,7 +9821,7 @@ function importWidgetState(state4) {
|
|
|
9385
9821
|
}
|
|
9386
9822
|
pruneInactiveFileRecords();
|
|
9387
9823
|
sessionLanguages = state4.sessionLanguages ?? [];
|
|
9388
|
-
|
|
9824
|
+
requestRender();
|
|
9389
9825
|
return true;
|
|
9390
9826
|
}
|
|
9391
9827
|
var widgetStore = defineSessionStore({
|
|
@@ -9464,7 +9900,6 @@ function recordDiagnostics(filePath, diagnostics, writeIndex, observedAt, unchec
|
|
|
9464
9900
|
runnerWriteGuard.shouldWrite(key, writeIndex);
|
|
9465
9901
|
const observedTs = observedAt ?? Date.now();
|
|
9466
9902
|
const rec = getOrCreate(filePath, key);
|
|
9467
|
-
commitDiagnostics(rec, filePath, normalizeDiagnostics(filePath, diagnostics, observedTs), observedTs, key);
|
|
9468
9903
|
if (unchecked === void 0) {
|
|
9469
9904
|
delete rec.uncheckedReason;
|
|
9470
9905
|
delete rec.uncheckedInapplicable;
|
|
@@ -9475,6 +9910,7 @@ function recordDiagnostics(filePath, diagnostics, writeIndex, observedAt, unchec
|
|
|
9475
9910
|
else
|
|
9476
9911
|
delete rec.uncheckedInapplicable;
|
|
9477
9912
|
}
|
|
9913
|
+
commitDiagnostics(rec, filePath, normalizeDiagnostics(filePath, diagnostics, observedTs), observedTs, key);
|
|
9478
9914
|
return true;
|
|
9479
9915
|
}
|
|
9480
9916
|
function normalizeDiagnostics(filePath, diagnostics, observedTs) {
|
|
@@ -9497,7 +9933,7 @@ function normalizeDiagnostics(filePath, diagnostics, observedTs) {
|
|
|
9497
9933
|
var retentionIdentity = findingIdentity;
|
|
9498
9934
|
function readContentOrUndefined(filePath) {
|
|
9499
9935
|
try {
|
|
9500
|
-
return
|
|
9936
|
+
return readFileSync7(filePath, "utf8");
|
|
9501
9937
|
} catch {
|
|
9502
9938
|
recordDegradationOnce({
|
|
9503
9939
|
kind: "widget-mark-anchor-unreadable",
|
|
@@ -9551,12 +9987,12 @@ function retainSuppressedRows(previous, incoming, filePath) {
|
|
|
9551
9987
|
];
|
|
9552
9988
|
}
|
|
9553
9989
|
function commitDiagnostics(rec, filePath, incoming, observedAt, key = fileMapKey(filePath), retainSuppressed = true) {
|
|
9554
|
-
const
|
|
9555
|
-
rec.diagnosticCounts = countDiagnostics(
|
|
9556
|
-
rec.diagnostics = capStoredDiagnostics(
|
|
9557
|
-
rec.allDiagnostics =
|
|
9990
|
+
const normalized2 = retainSuppressed ? retainSuppressedRows(rec.allDiagnostics, incoming, filePath) : incoming;
|
|
9991
|
+
rec.diagnosticCounts = countDiagnostics(normalized2);
|
|
9992
|
+
rec.diagnostics = capStoredDiagnostics(normalized2);
|
|
9993
|
+
rec.allDiagnostics = normalized2;
|
|
9558
9994
|
rec.hasFinalDiagnosticsSnapshot = true;
|
|
9559
|
-
rec.touchedAt = freshestObservation(
|
|
9995
|
+
rec.touchedAt = freshestObservation(normalized2, observedAt ?? Date.now());
|
|
9560
9996
|
files.set(key, rec);
|
|
9561
9997
|
requestRender();
|
|
9562
9998
|
}
|
|
@@ -9692,7 +10128,7 @@ async function reconcileStaleWidgetFiles(onStaleFile) {
|
|
|
9692
10128
|
rec.touchedAt = Math.max(Date.now(), v.mtimeMs);
|
|
9693
10129
|
}
|
|
9694
10130
|
if (changed > 0)
|
|
9695
|
-
|
|
10131
|
+
requestRender();
|
|
9696
10132
|
return changed;
|
|
9697
10133
|
}
|
|
9698
10134
|
async function reconcileStaleWidgetDependencyBlockers(cwd, turnIndex) {
|
|
@@ -9733,7 +10169,7 @@ async function reconcileStaleWidgetDependencyBlockers(cwd, turnIndex) {
|
|
|
9733
10169
|
}
|
|
9734
10170
|
}
|
|
9735
10171
|
if (demoted > 0)
|
|
9736
|
-
|
|
10172
|
+
requestRender();
|
|
9737
10173
|
return { demoted, truncatedImports };
|
|
9738
10174
|
}
|
|
9739
10175
|
function getWidgetBlockingFilesForSweep() {
|
|
@@ -9767,7 +10203,7 @@ function markWidgetFileBlockersStale(filePath, reason) {
|
|
|
9767
10203
|
if (changed) {
|
|
9768
10204
|
rec.diagnosticCounts = countDiagnostics(rec.allDiagnostics);
|
|
9769
10205
|
rec.diagnostics = capStoredDiagnostics(rec.allDiagnostics);
|
|
9770
|
-
|
|
10206
|
+
requestRender();
|
|
9771
10207
|
}
|
|
9772
10208
|
return changed;
|
|
9773
10209
|
}
|
|
@@ -9806,7 +10242,7 @@ function retireWidgetDependencyDriftBlockers(filePath) {
|
|
|
9806
10242
|
if (!changed)
|
|
9807
10243
|
return false;
|
|
9808
10244
|
renderedDependencyDriftFiles.delete(rec.filePath);
|
|
9809
|
-
|
|
10245
|
+
requestRender();
|
|
9810
10246
|
return true;
|
|
9811
10247
|
}
|
|
9812
10248
|
function getFileDiagnosticSummaries() {
|
|
@@ -9927,6 +10363,15 @@ function capStoredDiagnostics(diagnostics) {
|
|
|
9927
10363
|
}
|
|
9928
10364
|
function requestRender() {
|
|
9929
10365
|
requestRenderFn?.();
|
|
10366
|
+
try {
|
|
10367
|
+
widgetChangeFn?.();
|
|
10368
|
+
} catch (err) {
|
|
10369
|
+
recordDegradationOnce({
|
|
10370
|
+
kind: "widget-change-listener-failed",
|
|
10371
|
+
subject: "widget-store",
|
|
10372
|
+
reason: `store-change listener threw: ${err instanceof Error ? err.message : String(err)}`
|
|
10373
|
+
});
|
|
10374
|
+
}
|
|
9930
10375
|
}
|
|
9931
10376
|
|
|
9932
10377
|
// dist/clients/lsp/client.js
|
|
@@ -9940,18 +10385,18 @@ import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
|
9940
10385
|
var import_node = __toESM(require_main(), 1);
|
|
9941
10386
|
|
|
9942
10387
|
// dist/clients/lsp/aggregation.js
|
|
9943
|
-
async function raceToCompletion(
|
|
10388
|
+
async function raceToCompletion(promises4, shouldComplete, options = { timeoutMs: 1500 }) {
|
|
9944
10389
|
const results = [];
|
|
9945
|
-
results.length =
|
|
10390
|
+
results.length = promises4.length;
|
|
9946
10391
|
results.fill(void 0);
|
|
9947
10392
|
let graceTimer;
|
|
9948
10393
|
let auxGraceTimer;
|
|
9949
10394
|
let completed = false;
|
|
9950
|
-
let remaining =
|
|
10395
|
+
let remaining = promises4.length;
|
|
9951
10396
|
const descriptors = options.descriptors ?? [];
|
|
9952
10397
|
const hasAuxiliaries = descriptors.some((d) => isAuxiliary(d));
|
|
9953
10398
|
const auxIndices = hasAuxiliaries ? new Set(descriptors.map((d, i) => isAuxiliary(d) ? i : -1).filter((i) => i >= 0)) : /* @__PURE__ */ new Set();
|
|
9954
|
-
const languageCount =
|
|
10399
|
+
const languageCount = promises4.length - auxIndices.size;
|
|
9955
10400
|
let languageRemaining = languageCount;
|
|
9956
10401
|
let auxGraceStarted = false;
|
|
9957
10402
|
return new Promise((resolve7) => {
|
|
@@ -10007,10 +10452,10 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
|
|
|
10007
10452
|
}
|
|
10008
10453
|
}
|
|
10009
10454
|
};
|
|
10010
|
-
for (let i = 0; i <
|
|
10455
|
+
for (let i = 0; i < promises4.length; i++) {
|
|
10011
10456
|
const index = i;
|
|
10012
10457
|
const isAux = auxIndices.has(index);
|
|
10013
|
-
|
|
10458
|
+
promises4[i].then((result) => {
|
|
10014
10459
|
if (!completed) {
|
|
10015
10460
|
results[index] = result;
|
|
10016
10461
|
remaining--;
|
|
@@ -10031,8 +10476,8 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
|
|
|
10031
10476
|
}
|
|
10032
10477
|
|
|
10033
10478
|
// dist/clients/lsp/edits.js
|
|
10034
|
-
import
|
|
10035
|
-
import { readFileSync as
|
|
10479
|
+
import fs10 from "node:fs/promises";
|
|
10480
|
+
import { readFileSync as readFileSync8, realpathSync, statSync as statSync8 } from "node:fs";
|
|
10036
10481
|
import path10 from "node:path";
|
|
10037
10482
|
import { URL as URL2 } from "node:url";
|
|
10038
10483
|
|
|
@@ -10312,8 +10757,8 @@ function normalizeTextEditsForContent(content, edits, encoding) {
|
|
|
10312
10757
|
}
|
|
10313
10758
|
function applyTextEditsToString(content, edits, positionEncoding = "utf-16") {
|
|
10314
10759
|
const lines = content.split("\n");
|
|
10315
|
-
const
|
|
10316
|
-
for (const edit of
|
|
10760
|
+
const normalized2 = sortEditsForApplication(normalizeTextEditsForContent(content, edits, positionEncoding));
|
|
10761
|
+
for (const edit of normalized2) {
|
|
10317
10762
|
const { start, end } = edit.range;
|
|
10318
10763
|
if (start.line === end.line) {
|
|
10319
10764
|
const line = lines[start.line] ?? "";
|
|
@@ -10499,8 +10944,8 @@ function captureRenameExpectedContent(edit, cwd, requestedAtMs, readTrackedSend,
|
|
|
10499
10944
|
let mtimeMs;
|
|
10500
10945
|
try {
|
|
10501
10946
|
realPath = realpathSync.native(diskPath);
|
|
10502
|
-
content =
|
|
10503
|
-
mtimeMs =
|
|
10947
|
+
content = readFileSync8(realPath, "utf-8");
|
|
10948
|
+
mtimeMs = statSync8(realPath).mtimeMs;
|
|
10504
10949
|
} catch {
|
|
10505
10950
|
continue;
|
|
10506
10951
|
}
|
|
@@ -10689,7 +11134,7 @@ function summarizeWorkspaceEdit(edit, cwd) {
|
|
|
10689
11134
|
}
|
|
10690
11135
|
async function lstatOrMissing(filePath) {
|
|
10691
11136
|
try {
|
|
10692
|
-
return await
|
|
11137
|
+
return await fs10.lstat(filePath);
|
|
10693
11138
|
} catch (err) {
|
|
10694
11139
|
if (err.code === "ENOENT")
|
|
10695
11140
|
return void 0;
|
|
@@ -10701,7 +11146,7 @@ function isSameFsIdentity(a, b) {
|
|
|
10701
11146
|
}
|
|
10702
11147
|
async function bigintLstatOrMissing(filePath) {
|
|
10703
11148
|
try {
|
|
10704
|
-
return await
|
|
11149
|
+
return await fs10.lstat(filePath, { bigint: true });
|
|
10705
11150
|
} catch (err) {
|
|
10706
11151
|
if (err.code === "ENOENT")
|
|
10707
11152
|
return void 0;
|
|
@@ -10821,7 +11266,7 @@ async function preflightWorkspaceEdit(planned, cwd, options) {
|
|
|
10821
11266
|
const physicalPath = resolveVirtualPath(filePath);
|
|
10822
11267
|
if (!physicalPath)
|
|
10823
11268
|
throw new Error(`text edit target does not exist: ${filePath}`);
|
|
10824
|
-
const content = await
|
|
11269
|
+
const content = await fs10.readFile(physicalPath, "utf-8");
|
|
10825
11270
|
const expected = options.expectedContent?.get(await realpathOrResolveAsync(physicalPath));
|
|
10826
11271
|
if (expected !== void 0 && expected !== content) {
|
|
10827
11272
|
refuseStaleWorkspaceEdit(filePath, "the file changed after the edit was computed from it");
|
|
@@ -10840,12 +11285,12 @@ async function preflightWorkspaceEdit(planned, cwd, options) {
|
|
|
10840
11285
|
}
|
|
10841
11286
|
const content = await contentFor(filePath2, state5);
|
|
10842
11287
|
const encoding = options.positionEncoding ?? "utf-16";
|
|
10843
|
-
const
|
|
10844
|
-
text.set(op,
|
|
11288
|
+
const normalized2 = normalizeTextEditsForContent(content, op.edits, encoding);
|
|
11289
|
+
text.set(op, normalized2);
|
|
10845
11290
|
for (const origin of op.origins ?? []) {
|
|
10846
11291
|
textByOrigin.set(textEditOriginKey(origin), normalizeTextEditsForContent(content, origin.edits, encoding));
|
|
10847
11292
|
}
|
|
10848
|
-
state5.content = applyTextEditsToString(content,
|
|
11293
|
+
state5.content = applyTextEditsToString(content, normalized2);
|
|
10849
11294
|
continue;
|
|
10850
11295
|
}
|
|
10851
11296
|
if (op.kind === "create") {
|
|
@@ -11025,14 +11470,14 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11025
11470
|
skipOperation(op);
|
|
11026
11471
|
continue;
|
|
11027
11472
|
}
|
|
11028
|
-
const content = await
|
|
11473
|
+
const content = await fs10.readFile(diskPath, "utf-8");
|
|
11029
11474
|
const updated = applyTextEditsToString(content, edits, "utf-16");
|
|
11030
11475
|
const changesLineCount = edits.some((edit2) => {
|
|
11031
11476
|
const removedLines = edit2.range.end.line - edit2.range.start.line;
|
|
11032
11477
|
const insertedLines = (edit2.newText.match(/\r\n|\r|\n/g) ?? []).length;
|
|
11033
11478
|
return removedLines !== insertedLines;
|
|
11034
11479
|
});
|
|
11035
|
-
await
|
|
11480
|
+
await fs10.writeFile(diskPath, updated, "utf-8");
|
|
11036
11481
|
const start = Math.min(...edits.map((item) => item.range.start.line + 1));
|
|
11037
11482
|
const end = Math.max(...edits.map((item) => item.range.end.line + (item.range.end.character === 0 && item.range.end.line > item.range.start.line ? 0 : 1)));
|
|
11038
11483
|
touchedFiles.add(filePath);
|
|
@@ -11051,11 +11496,11 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11051
11496
|
} else if (op.kind === "create") {
|
|
11052
11497
|
const filePath = uriToPath(op.uri);
|
|
11053
11498
|
const diskPath = uriToDiskPath(op.uri);
|
|
11054
|
-
await
|
|
11499
|
+
await fs10.mkdir(path10.dirname(diskPath), { recursive: true });
|
|
11055
11500
|
if (op.options?.overwrite)
|
|
11056
|
-
await
|
|
11501
|
+
await fs10.writeFile(diskPath, "", "utf-8");
|
|
11057
11502
|
else
|
|
11058
|
-
await
|
|
11503
|
+
await fs10.writeFile(diskPath, "", { flag: "wx" });
|
|
11059
11504
|
resourceChanges.push({ filePath: diskPath, type: FILE_CREATED });
|
|
11060
11505
|
touchedFiles.add(filePath);
|
|
11061
11506
|
fileDetails.push({
|
|
@@ -11071,10 +11516,10 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11071
11516
|
const newPath = uriToPath(op.newUri);
|
|
11072
11517
|
const oldDisk = uriToDiskPath(op.oldUri);
|
|
11073
11518
|
const newDisk = uriToDiskPath(op.newUri);
|
|
11074
|
-
await
|
|
11519
|
+
await fs10.mkdir(path10.dirname(newDisk), { recursive: true });
|
|
11075
11520
|
if (op.options?.overwrite)
|
|
11076
|
-
await
|
|
11077
|
-
await
|
|
11521
|
+
await fs10.rm(newDisk, { recursive: true, force: true });
|
|
11522
|
+
await fs10.rename(oldDisk, newDisk);
|
|
11078
11523
|
resourceChanges.push({ filePath: oldDisk, type: FILE_DELETED }, { filePath: newDisk, type: FILE_CREATED });
|
|
11079
11524
|
touchedFiles.add(oldPath);
|
|
11080
11525
|
touchedFiles.add(newPath);
|
|
@@ -11094,7 +11539,7 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11094
11539
|
} else {
|
|
11095
11540
|
const filePath = uriToPath(op.uri);
|
|
11096
11541
|
const diskPath = uriToDiskPath(op.uri);
|
|
11097
|
-
await
|
|
11542
|
+
await fs10.rm(diskPath, {
|
|
11098
11543
|
recursive: op.options?.recursive === true,
|
|
11099
11544
|
force: false
|
|
11100
11545
|
});
|
|
@@ -11317,7 +11762,7 @@ async function attemptTsserverSyncDiagnostics(file, svc) {
|
|
|
11317
11762
|
}
|
|
11318
11763
|
|
|
11319
11764
|
// dist/clients/lsp/workspace-diagnostics-cache.js
|
|
11320
|
-
import * as
|
|
11765
|
+
import * as fs11 from "node:fs";
|
|
11321
11766
|
import * as path12 from "node:path";
|
|
11322
11767
|
|
|
11323
11768
|
// dist/clients/reverse-deps.js
|
|
@@ -11376,9 +11821,9 @@ function buildReverseDependencyIndexFromGraph(args) {
|
|
|
11376
11821
|
source: "review-graph"
|
|
11377
11822
|
};
|
|
11378
11823
|
for (const filePath of args.graph.fileNodes.keys()) {
|
|
11379
|
-
const
|
|
11380
|
-
index.imports[
|
|
11381
|
-
index.importedBy[
|
|
11824
|
+
const normalized2 = normalizeMapKey(filePath);
|
|
11825
|
+
index.imports[normalized2] ??= [];
|
|
11826
|
+
index.importedBy[normalized2] ??= [];
|
|
11382
11827
|
}
|
|
11383
11828
|
for (const edge of args.graph.edges) {
|
|
11384
11829
|
if (edge.kind !== "imports")
|
|
@@ -11407,28 +11852,28 @@ function buildReverseDependencyIndexFromSnapshot(snapshot) {
|
|
|
11407
11852
|
source: "project-snapshot"
|
|
11408
11853
|
};
|
|
11409
11854
|
for (const [filePath, file] of fileEntries) {
|
|
11410
|
-
const
|
|
11855
|
+
const normalized2 = normalizeMapKey(file.path || filePath);
|
|
11411
11856
|
if (Array.isArray(file.imports)) {
|
|
11412
11857
|
const imports = sortedUnique(file.imports);
|
|
11413
|
-
index.imports[
|
|
11858
|
+
index.imports[normalized2] = imports;
|
|
11414
11859
|
for (const imported of imports) {
|
|
11415
11860
|
index.importedBy[imported] ??= [];
|
|
11416
|
-
index.importedBy[imported].push(
|
|
11861
|
+
index.importedBy[imported].push(normalized2);
|
|
11417
11862
|
}
|
|
11418
11863
|
}
|
|
11419
|
-
index.importedBy[
|
|
11864
|
+
index.importedBy[normalized2] ??= [];
|
|
11420
11865
|
}
|
|
11421
11866
|
for (const [filePath, importers] of Object.entries(reverseDeps)) {
|
|
11422
|
-
const
|
|
11423
|
-
index.importedBy[
|
|
11424
|
-
...index.importedBy[
|
|
11867
|
+
const normalized2 = normalizeMapKey(filePath);
|
|
11868
|
+
index.importedBy[normalized2] = sortedUnique([
|
|
11869
|
+
...index.importedBy[normalized2] ?? [],
|
|
11425
11870
|
...importers
|
|
11426
11871
|
]);
|
|
11427
|
-
for (const importer of index.importedBy[
|
|
11872
|
+
for (const importer of index.importedBy[normalized2]) {
|
|
11428
11873
|
if (index.imports[importer] === void 0)
|
|
11429
11874
|
continue;
|
|
11430
|
-
if (!index.imports[importer].includes(
|
|
11431
|
-
index.imports[importer].push(
|
|
11875
|
+
if (!index.imports[importer].includes(normalized2)) {
|
|
11876
|
+
index.imports[importer].push(normalized2);
|
|
11432
11877
|
}
|
|
11433
11878
|
}
|
|
11434
11879
|
}
|
|
@@ -11509,7 +11954,7 @@ function loadWorkspaceDiagnosticsCache(cwd) {
|
|
|
11509
11954
|
}
|
|
11510
11955
|
function saveWorkspaceDiagnosticsCache(cwd, cache) {
|
|
11511
11956
|
const filePath = cachePath(cwd);
|
|
11512
|
-
|
|
11957
|
+
fs11.mkdirSync(path12.dirname(filePath), { recursive: true });
|
|
11513
11958
|
writeFileAtomic(filePath, JSON.stringify(cache, null, 2), {
|
|
11514
11959
|
bestEffort: false
|
|
11515
11960
|
});
|
|
@@ -11543,7 +11988,7 @@ function classifyWorkspaceDiagnosticsCacheExpiry(entry, now, sessionStartedAt, f
|
|
|
11543
11988
|
function isEntryFresh(filePath, entry, getImports) {
|
|
11544
11989
|
let ownStat;
|
|
11545
11990
|
try {
|
|
11546
|
-
ownStat =
|
|
11991
|
+
ownStat = fs11.statSync(filePath);
|
|
11547
11992
|
} catch {
|
|
11548
11993
|
return false;
|
|
11549
11994
|
}
|
|
@@ -11567,7 +12012,7 @@ function isEntryFresh(filePath, entry, getImports) {
|
|
|
11567
12012
|
for (const dep of imports) {
|
|
11568
12013
|
let mtimeMs;
|
|
11569
12014
|
try {
|
|
11570
|
-
mtimeMs =
|
|
12015
|
+
mtimeMs = fs11.statSync(dep).mtimeMs;
|
|
11571
12016
|
} catch {
|
|
11572
12017
|
return false;
|
|
11573
12018
|
}
|
|
@@ -11855,6 +12300,14 @@ var CLIENT_CAPABILITIES = {
|
|
|
11855
12300
|
// implement" — the `window/workDoneProgress/create` handler below stays as
|
|
11856
12301
|
// a defensive no-op in case a server ignores capabilities and asks anyway.
|
|
11857
12302
|
window: {},
|
|
12303
|
+
// #5487: rust-analyzer announces `experimental/serverStatus` (health plus
|
|
12304
|
+
// `quiescent`) only to a client that asks for it here, and answers a pull
|
|
12305
|
+
// with an empty authoritative report while it is still loading. This is the
|
|
12306
|
+
// readiness signal `$/progress` would also carry, without the
|
|
12307
|
+
// `window.workDoneProgress` advertisement #974 withdrew. A server that does
|
|
12308
|
+
// not know the key ignores it (LSP `experimental` is opaque); the gate only
|
|
12309
|
+
// acts on a server that then sends the notification.
|
|
12310
|
+
experimental: { serverStatusNotification: true },
|
|
11858
12311
|
workspace: {
|
|
11859
12312
|
workspaceFolders: true,
|
|
11860
12313
|
configuration: true,
|
|
@@ -11883,7 +12336,10 @@ var CLIENT_CAPABILITIES = {
|
|
|
11883
12336
|
typeDefinition: { dynamicRegistration: false },
|
|
11884
12337
|
implementation: { dynamicRegistration: false },
|
|
11885
12338
|
references: { dynamicRegistration: false },
|
|
11886
|
-
documentSymbol: {
|
|
12339
|
+
documentSymbol: {
|
|
12340
|
+
dynamicRegistration: false,
|
|
12341
|
+
hierarchicalDocumentSymbolSupport: true
|
|
12342
|
+
},
|
|
11887
12343
|
codeAction: {
|
|
11888
12344
|
dynamicRegistration: false,
|
|
11889
12345
|
dataSupport: true,
|
|
@@ -11979,6 +12435,7 @@ function disposeClientConnection(state4) {
|
|
|
11979
12435
|
state4.connection.dispose();
|
|
11980
12436
|
} catch {
|
|
11981
12437
|
}
|
|
12438
|
+
state4.diagnosticEmitter.emit(SERVER_STATUS_CHANGED);
|
|
11982
12439
|
}
|
|
11983
12440
|
async function killProcessTree(proc, pid, options = {}) {
|
|
11984
12441
|
if ((proc.exitCode != null || proc.signalCode != null) && !options.processExiting) {
|
|
@@ -12282,6 +12739,8 @@ function diagnosticsPublishedAtForPath(state4, normalizedPath) {
|
|
|
12282
12739
|
return ts > 0 ? ts : void 0;
|
|
12283
12740
|
}
|
|
12284
12741
|
var PENDING_RECEIPT_DROPPED = "pending-receipt-dropped";
|
|
12742
|
+
var SERVER_STATUS_CHANGED = "server-status-changed";
|
|
12743
|
+
var SERVER_STATUS_MESSAGE_MAX_CHARS = 200;
|
|
12285
12744
|
function noteOwnNoticeQueued(state4, normalizedPath, uri, sentVersion) {
|
|
12286
12745
|
(state4.ownNoticeEchoes ??= /* @__PURE__ */ new Map()).set(normalizedPath, {
|
|
12287
12746
|
uri,
|
|
@@ -12672,6 +13131,10 @@ function setupIncomingHandlers(state4, initialization, onDiagnosticsPublished) {
|
|
|
12672
13131
|
if (newDiags.length === 0 && auxiliaryEmptyIsNotEvidence(state4, normalizedPath, docVersion)) {
|
|
12673
13132
|
return;
|
|
12674
13133
|
}
|
|
13134
|
+
if (newDiags.length === 0 && serverNotReady(state4)) {
|
|
13135
|
+
noteReadinessGate(state4);
|
|
13136
|
+
return;
|
|
13137
|
+
}
|
|
12675
13138
|
onDiagnosticsPublished?.(state4.serverId);
|
|
12676
13139
|
const fence = state4.diagnosticFences.get(normalizedPath);
|
|
12677
13140
|
if (docVersion === void 0 && fence) {
|
|
@@ -12916,6 +13379,26 @@ function setupIncomingHandlers(state4, initialization, onDiagnosticsPublished) {
|
|
|
12916
13379
|
delete state4.configLoadFailure;
|
|
12917
13380
|
rebaselineForRulesRefresh(state4);
|
|
12918
13381
|
});
|
|
13382
|
+
state4.connection.onNotification("experimental/serverStatus", (params) => {
|
|
13383
|
+
const quiescent = params?.quiescent;
|
|
13384
|
+
if (typeof quiescent !== "boolean")
|
|
13385
|
+
return;
|
|
13386
|
+
const failed = params?.health === "error";
|
|
13387
|
+
const message = failed && typeof params?.message === "string" ? params.message.slice(0, SERVER_STATUS_MESSAGE_MAX_CHARS) : void 0;
|
|
13388
|
+
const previous = state4.serverStatus;
|
|
13389
|
+
if (previous?.quiescent === quiescent && previous.failed === failed) {
|
|
13390
|
+
if (message !== void 0)
|
|
13391
|
+
previous.message = message;
|
|
13392
|
+
return;
|
|
13393
|
+
}
|
|
13394
|
+
state4.serverStatus = {
|
|
13395
|
+
quiescent,
|
|
13396
|
+
failed,
|
|
13397
|
+
...message !== void 0 && { message },
|
|
13398
|
+
revision: (previous?.revision ?? 0) + 1
|
|
13399
|
+
};
|
|
13400
|
+
state4.diagnosticEmitter.emit(SERVER_STATUS_CHANGED);
|
|
13401
|
+
});
|
|
12919
13402
|
let refreshRepullRunning = false;
|
|
12920
13403
|
let refreshRepullRerunRequested = false;
|
|
12921
13404
|
const runRefreshRepullPool = async () => {
|
|
@@ -12953,7 +13436,7 @@ function setupIncomingHandlers(state4, initialization, onDiagnosticsPublished) {
|
|
|
12953
13436
|
} else {
|
|
12954
13437
|
refreshRepullRunning = true;
|
|
12955
13438
|
setImmediate(() => {
|
|
12956
|
-
void runRefreshRepullPool();
|
|
13439
|
+
void spawnAbortScope.run(REFRESH_REPULL_SIGNAL, () => runRefreshRepullPool());
|
|
12957
13440
|
});
|
|
12958
13441
|
}
|
|
12959
13442
|
}
|
|
@@ -13028,7 +13511,7 @@ async function clientRequestPullDiagnostics(state4, filePath, budgetMs = PULL_RE
|
|
|
13028
13511
|
const attempts = sources.map((identifier) => pullDiagnosticSource(state4, filePath, budgetMs, identifier));
|
|
13029
13512
|
const settled = await raceToCompletion(attempts, (results) => results.some((r) => r.status === "found" && r.primaryCount > 0), {
|
|
13030
13513
|
// No graceMs: finalize the instant a source answers for this file.
|
|
13031
|
-
// The per-request `
|
|
13514
|
+
// The per-request `withDeadline` inside each attempt is the real bound;
|
|
13032
13515
|
// this deadline is only a backstop, so it sits just past it.
|
|
13033
13516
|
timeoutMs: Math.max(1, Math.min(PULL_REQUEST_TIMEOUT_MS, budgetMs)) + PULL_RACE_BACKSTOP_MARGIN_MS
|
|
13034
13517
|
});
|
|
@@ -13049,9 +13532,13 @@ function aggregatePullOutcomes(state4, filePath, outcomes) {
|
|
|
13049
13532
|
}
|
|
13050
13533
|
return outcomes.some((o) => o.status === "clean") ? { status: "clean" } : { status: "unavailable" };
|
|
13051
13534
|
}
|
|
13535
|
+
var PULL_ABORTED = /* @__PURE__ */ Symbol("pull-aborted");
|
|
13052
13536
|
async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
13053
13537
|
if (!isClientAlive(state4))
|
|
13054
13538
|
return { status: "unavailable" };
|
|
13539
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13540
|
+
if (abortSignal?.aborted)
|
|
13541
|
+
return { status: "unavailable" };
|
|
13055
13542
|
const normalizedPath = normalizeMapKey(filePath);
|
|
13056
13543
|
if (budgetMs < PULL_MIN_USABLE_BUDGET_MS) {
|
|
13057
13544
|
emitBounded("lsp_pull_skipped_budget_exhausted", `${state4.serverId}::${pullSourceKey(normalizedPath, identifier)}`, {
|
|
@@ -13078,6 +13565,7 @@ async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
|
13078
13565
|
const generation = pullGenerationFor(state4, normalizedPath);
|
|
13079
13566
|
const requestSequence = claimPullRequestSequence(state4, sourceKey);
|
|
13080
13567
|
const requestStartedAt = Date.now();
|
|
13568
|
+
const statusAtSend = state4.serverStatus;
|
|
13081
13569
|
const effectiveTimeoutMs = Math.max(1, Math.min(PULL_REQUEST_TIMEOUT_MS, budgetMs));
|
|
13082
13570
|
const pullAbort = new AbortController();
|
|
13083
13571
|
const pullSettlement = { cancelled: false };
|
|
@@ -13089,7 +13577,12 @@ async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
|
13089
13577
|
...previousResultId !== void 0 && { previousResultId }
|
|
13090
13578
|
}, pullAbort.signal, pullSettlement);
|
|
13091
13579
|
try {
|
|
13092
|
-
const report = await
|
|
13580
|
+
const report = await withDeadline(untilAborted(requestPromise, abortSignal, PULL_ABORTED), { ms: effectiveTimeoutMs });
|
|
13581
|
+
if (report === PULL_ABORTED) {
|
|
13582
|
+
trackAbandonedPullRequest(state4, sourceKey, requestPromise);
|
|
13583
|
+
pullAbort.abort();
|
|
13584
|
+
return { status: "unavailable" };
|
|
13585
|
+
}
|
|
13093
13586
|
if (!report) {
|
|
13094
13587
|
recordPullFailure(state4, "textDocument/diagnostic", new Error("empty response"));
|
|
13095
13588
|
return { status: "unavailable" };
|
|
@@ -13099,6 +13592,10 @@ async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
|
13099
13592
|
if (pullGenerationFor(state4, normalizedPath) !== generation || !isNewestPullRequest(state4, sourceKey, requestSequence)) {
|
|
13100
13593
|
return { status: "unavailable" };
|
|
13101
13594
|
}
|
|
13595
|
+
if (reportCarriesNothing(report) && !pullAnswerIsSettled(state4, statusAtSend)) {
|
|
13596
|
+
noteReadinessGate(state4);
|
|
13597
|
+
return { status: "unavailable" };
|
|
13598
|
+
}
|
|
13102
13599
|
let primaryCount;
|
|
13103
13600
|
if (report.kind === "unchanged") {
|
|
13104
13601
|
primaryCount = pullSourceDiagnostics(state4, normalizedPath, identifier).length;
|
|
@@ -13290,7 +13787,9 @@ async function clientRequestWorkspaceDiagnostics(state4, budgetMs) {
|
|
|
13290
13787
|
const workspacePullSettlement = { cancelled: false };
|
|
13291
13788
|
const workspaceRequestPromise = safeSendRequest(state4.connection, "workspace/diagnostic", { previousResultIds }, workspacePullAbort.signal, workspacePullSettlement);
|
|
13292
13789
|
try {
|
|
13293
|
-
const report = await
|
|
13790
|
+
const report = await withDeadline(workspaceRequestPromise, {
|
|
13791
|
+
ms: workspacePullTimeoutMs
|
|
13792
|
+
});
|
|
13294
13793
|
if (!report || !Array.isArray(report.items))
|
|
13295
13794
|
return void 0;
|
|
13296
13795
|
const out = [];
|
|
@@ -13386,6 +13885,119 @@ async function clientRequestWorkspaceDiagnostics(state4, budgetMs) {
|
|
|
13386
13885
|
return void 0;
|
|
13387
13886
|
}
|
|
13388
13887
|
}
|
|
13888
|
+
function waitForQuiescence(state4, budgetMs) {
|
|
13889
|
+
if (state4.serverStatus?.quiescent !== false)
|
|
13890
|
+
return Promise.resolve(true);
|
|
13891
|
+
if (budgetMs <= 0 || !isClientAlive(state4))
|
|
13892
|
+
return Promise.resolve(false);
|
|
13893
|
+
return new Promise((resolve7) => {
|
|
13894
|
+
const finish = (ready) => {
|
|
13895
|
+
clearTimeout(timer);
|
|
13896
|
+
state4.diagnosticEmitter.off(SERVER_STATUS_CHANGED, onChange);
|
|
13897
|
+
resolve7(ready);
|
|
13898
|
+
};
|
|
13899
|
+
const onChange = () => {
|
|
13900
|
+
if (!isClientAlive(state4))
|
|
13901
|
+
finish(false);
|
|
13902
|
+
else if (state4.serverStatus?.quiescent !== false)
|
|
13903
|
+
finish(true);
|
|
13904
|
+
};
|
|
13905
|
+
const timer = setTimeout(() => finish(false), budgetMs);
|
|
13906
|
+
state4.diagnosticEmitter.on(SERVER_STATUS_CHANGED, onChange);
|
|
13907
|
+
});
|
|
13908
|
+
}
|
|
13909
|
+
var PULL_UNSETTLED = /* @__PURE__ */ Symbol("pull-unsettled");
|
|
13910
|
+
var REFRESH_REPULL_SIGNAL = new AbortController().signal;
|
|
13911
|
+
function pullAnswerIsSettled(state4, sentAt) {
|
|
13912
|
+
const now = state4.serverStatus;
|
|
13913
|
+
return sentAt?.revision === now?.revision && now?.quiescent !== false && now?.failed !== true;
|
|
13914
|
+
}
|
|
13915
|
+
function serverNotReady(state4) {
|
|
13916
|
+
return state4.serverStatus?.quiescent === false || !!state4.serverStatus?.failed;
|
|
13917
|
+
}
|
|
13918
|
+
function readinessBlockOf(state4) {
|
|
13919
|
+
if (!isClientAlive(state4))
|
|
13920
|
+
return void 0;
|
|
13921
|
+
const announced = state4.serverStatus;
|
|
13922
|
+
if (announced?.quiescent === false)
|
|
13923
|
+
return { reason: "server-loading" };
|
|
13924
|
+
if (announced?.failed) {
|
|
13925
|
+
return {
|
|
13926
|
+
reason: "server-load-failed",
|
|
13927
|
+
...announced.message !== void 0 && { detail: announced.message }
|
|
13928
|
+
};
|
|
13929
|
+
}
|
|
13930
|
+
return void 0;
|
|
13931
|
+
}
|
|
13932
|
+
function reportCarriesNothing(report) {
|
|
13933
|
+
return (report.items?.length ?? 0) === 0;
|
|
13934
|
+
}
|
|
13935
|
+
async function pullDiagnosticsWhenReady(state4, filePath, budgetMs, deadlineAt) {
|
|
13936
|
+
let requestBudgetMs = budgetMs;
|
|
13937
|
+
let waitedForReadiness = false;
|
|
13938
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13939
|
+
for (; ; ) {
|
|
13940
|
+
if (state4.serverStatus?.quiescent === false) {
|
|
13941
|
+
waitedForReadiness = true;
|
|
13942
|
+
noteReadinessGate(state4);
|
|
13943
|
+
const ready = await untilAborted(waitForQuiescence(state4, deadlineAt - Date.now()), abortSignal, false);
|
|
13944
|
+
if (!ready)
|
|
13945
|
+
return PULL_UNSETTLED;
|
|
13946
|
+
requestBudgetMs = deadlineAt - Date.now();
|
|
13947
|
+
}
|
|
13948
|
+
const sentAt = state4.serverStatus;
|
|
13949
|
+
const outcome = await clientRequestPullDiagnostics(state4, filePath, requestBudgetMs);
|
|
13950
|
+
if (outcome.status === "found")
|
|
13951
|
+
return outcome;
|
|
13952
|
+
const settled = pullAnswerIsSettled(state4, sentAt);
|
|
13953
|
+
if (!settled)
|
|
13954
|
+
waitedForReadiness = true;
|
|
13955
|
+
const retryAfterBeat = settled && waitedForReadiness && outcome.status === "unavailable" && isClientAlive(state4);
|
|
13956
|
+
if (settled && !retryAfterBeat)
|
|
13957
|
+
return outcome;
|
|
13958
|
+
if (state4.serverStatus?.failed && state4.serverStatus.quiescent !== false) {
|
|
13959
|
+
noteReadinessGate(state4);
|
|
13960
|
+
return PULL_UNSETTLED;
|
|
13961
|
+
}
|
|
13962
|
+
const remainingMs = deadlineAt - Date.now();
|
|
13963
|
+
if (remainingMs <= 0)
|
|
13964
|
+
return PULL_UNSETTLED;
|
|
13965
|
+
if (retryAfterBeat) {
|
|
13966
|
+
await new Promise((resolve7) => setTimeout(resolve7, Math.min(PULL_DIAGNOSTICS_RETRY_INTERVAL_MS, remainingMs)));
|
|
13967
|
+
}
|
|
13968
|
+
requestBudgetMs = deadlineAt - Date.now();
|
|
13969
|
+
}
|
|
13970
|
+
}
|
|
13971
|
+
function noteReadinessGate(state4) {
|
|
13972
|
+
const announced = state4.serverStatus;
|
|
13973
|
+
const loadFailed = announced?.failed === true && announced.quiescent !== false;
|
|
13974
|
+
emitBounded(
|
|
13975
|
+
"lsp_server_loading_gated",
|
|
13976
|
+
// A failed load is its own rising edge: a server that failed after it
|
|
13977
|
+
// finished loading still gets its record.
|
|
13978
|
+
loadFailed ? `${state4.serverId}:load-failed` : state4.serverId,
|
|
13979
|
+
{
|
|
13980
|
+
filePath: state4.root,
|
|
13981
|
+
durationMs: 0,
|
|
13982
|
+
metadata: {
|
|
13983
|
+
serverId: state4.serverId,
|
|
13984
|
+
quiescent: announced?.quiescent,
|
|
13985
|
+
revision: announced?.revision,
|
|
13986
|
+
...loadFailed && {
|
|
13987
|
+
loadFailed: true,
|
|
13988
|
+
...announced?.message !== void 0 && {
|
|
13989
|
+
message: announced.message
|
|
13990
|
+
}
|
|
13991
|
+
}
|
|
13992
|
+
}
|
|
13993
|
+
},
|
|
13994
|
+
{
|
|
13995
|
+
ledgerKind: "lsp-server-loading-gated",
|
|
13996
|
+
reason: loadFailed ? `${state4.serverId}: workspace failed to load${announced?.message ? ` (${announced.message})` : ""}` : `${state4.serverId}: pull held to the server's announced readiness`,
|
|
13997
|
+
risingEdgePer: "identity"
|
|
13998
|
+
}
|
|
13999
|
+
);
|
|
14000
|
+
}
|
|
13389
14001
|
async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {}) {
|
|
13390
14002
|
const normalizedPath = normalizeMapKey(filePath);
|
|
13391
14003
|
const minVersion = options.minVersion;
|
|
@@ -13400,12 +14012,17 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
|
|
|
13400
14012
|
};
|
|
13401
14013
|
if (state4.workspaceDiagnosticsSupport.mode === "pull") {
|
|
13402
14014
|
const pullSettleStartedAt = Date.now();
|
|
13403
|
-
|
|
14015
|
+
const pullDeadlineAt = pullSettleStartedAt + timeoutMs;
|
|
14016
|
+
const firstPull = await pullDiagnosticsWhenReady(state4, filePath, timeoutMs, pullDeadlineAt);
|
|
14017
|
+
if (firstPull === PULL_UNSETTLED)
|
|
14018
|
+
return "deadline-expired";
|
|
14019
|
+
let outcome = firstPull;
|
|
13404
14020
|
if (outcome.status === "found") {
|
|
13405
14021
|
logTypeScriptPullSettle(state4, normalizedPath, Date.now() - pullSettleStartedAt, pullSettleSource);
|
|
13406
14022
|
return "answered";
|
|
13407
14023
|
}
|
|
13408
14024
|
let sawClean = outcome.status === "clean";
|
|
14025
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13409
14026
|
const strategy = getStrategy(state4.serverId, state4.launchVariant);
|
|
13410
14027
|
const retryBudgetMs = strategy.pullRetryBudgetMs > 0 ? Math.min(timeoutMs, strategy.pullRetryBudgetMs) : 0;
|
|
13411
14028
|
const startedAt = Date.now();
|
|
@@ -13415,6 +14032,9 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
|
|
|
13415
14032
|
if (outcome.status === "clean")
|
|
13416
14033
|
sawClean = true;
|
|
13417
14034
|
}
|
|
14035
|
+
if (!sawClean && outcome.status !== "found" && abortSignal?.aborted) {
|
|
14036
|
+
return "deadline-expired";
|
|
14037
|
+
}
|
|
13418
14038
|
if (options.pullOnly) {
|
|
13419
14039
|
const answered = outcome.status === "found" || sawClean;
|
|
13420
14040
|
if (answered) {
|
|
@@ -13905,6 +14525,7 @@ async function clientShutdownOnce(state4, options) {
|
|
|
13905
14525
|
cancelDocumentNotifyQueues(state4);
|
|
13906
14526
|
state4.projectIdentityProbedFiles?.clear();
|
|
13907
14527
|
state4.watchQueue?.cancel();
|
|
14528
|
+
state4.diagnosticEmitter.emit(SERVER_STATUS_CHANGED);
|
|
13908
14529
|
state4.diagnosticEmitter.removeAllListeners();
|
|
13909
14530
|
let shutdownRequestTimedOut = false;
|
|
13910
14531
|
let exitNotifyTimedOut = false;
|
|
@@ -13913,7 +14534,7 @@ async function clientShutdownOnce(state4, options) {
|
|
|
13913
14534
|
try {
|
|
13914
14535
|
if (!options.fast) {
|
|
13915
14536
|
try {
|
|
13916
|
-
const shutdownAck = await
|
|
14537
|
+
const shutdownAck = await withDeadline(safeSendRequest(state4.connection, "shutdown", {}), { ms: SHUTDOWN_REQUEST_TIMEOUT_MS });
|
|
13917
14538
|
if (shutdownAck === void 0)
|
|
13918
14539
|
shutdownRequestUndelivered = true;
|
|
13919
14540
|
} catch (err) {
|
|
@@ -13924,7 +14545,7 @@ async function clientShutdownOnce(state4, options) {
|
|
|
13924
14545
|
}
|
|
13925
14546
|
}
|
|
13926
14547
|
try {
|
|
13927
|
-
const exitSent = await
|
|
14548
|
+
const exitSent = await withDeadline(safeSendNotification(state4.connection, "exit", {}), { ms: EXIT_NOTIFY_TIMEOUT_MS });
|
|
13928
14549
|
if (exitSent === false)
|
|
13929
14550
|
exitNotifyUndelivered = true;
|
|
13930
14551
|
} catch (err) {
|
|
@@ -14000,8 +14621,19 @@ async function navRequest(state4, method, params, staleCheckPath, timeoutMs = NA
|
|
|
14000
14621
|
const normalizedPath = staleCheckPath !== void 0 ? normalizeMapKey(staleCheckPath) : void 0;
|
|
14001
14622
|
const requestVersion = normalizedPath !== void 0 ? state4.documentVersions.get(normalizedPath) : void 0;
|
|
14002
14623
|
const requestStartedAt = Date.now();
|
|
14003
|
-
const
|
|
14004
|
-
|
|
14624
|
+
const result = await safeSendRequest(state4.connection, method, params, signal, void 0, {
|
|
14625
|
+
timeoutMs,
|
|
14626
|
+
cancel: true,
|
|
14627
|
+
onLateSettle: (answered) => {
|
|
14628
|
+
if (answered) {
|
|
14629
|
+
recordNavLateAnswerTelemetry({
|
|
14630
|
+
method,
|
|
14631
|
+
scope: normalizedPath,
|
|
14632
|
+
requestStartedAt
|
|
14633
|
+
});
|
|
14634
|
+
}
|
|
14635
|
+
}
|
|
14636
|
+
}).catch((err) => {
|
|
14005
14637
|
if (isNavTimeoutError(err, timeoutMs)) {
|
|
14006
14638
|
recordNavTimeoutTelemetry({
|
|
14007
14639
|
method,
|
|
@@ -14009,15 +14641,6 @@ async function navRequest(state4, method, params, staleCheckPath, timeoutMs = NA
|
|
|
14009
14641
|
budgetMs: timeoutMs,
|
|
14010
14642
|
elapsedMs: Date.now() - requestStartedAt
|
|
14011
14643
|
});
|
|
14012
|
-
armNavLateAnswerTelemetry({
|
|
14013
|
-
requestPromise,
|
|
14014
|
-
method,
|
|
14015
|
-
scope: normalizedPath,
|
|
14016
|
-
requestStartedAt
|
|
14017
|
-
});
|
|
14018
|
-
throw new LspRequestTimeoutError(method, timeoutMs, Date.now() - requestStartedAt);
|
|
14019
|
-
}
|
|
14020
|
-
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14021
14644
|
throw new LspRequestTimeoutError(method, timeoutMs, Date.now() - requestStartedAt);
|
|
14022
14645
|
}
|
|
14023
14646
|
throw err;
|
|
@@ -14049,24 +14672,21 @@ function recordNavTimeoutTelemetry(args) {
|
|
|
14049
14672
|
reason: `timeout budget=${args.budgetMs}ms elapsed=${args.elapsedMs}ms`
|
|
14050
14673
|
});
|
|
14051
14674
|
}
|
|
14052
|
-
function
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
}
|
|
14068
|
-
}, () => {
|
|
14069
|
-
});
|
|
14675
|
+
function recordNavLateAnswerTelemetry(args) {
|
|
14676
|
+
try {
|
|
14677
|
+
const elapsedMs = Date.now() - args.requestStartedAt;
|
|
14678
|
+
emitBounded("lsp_nav_late_answer_discarded", `${args.method}:${args.scope ?? NAV_REQUEST_NO_PATH_SCOPE}`, {
|
|
14679
|
+
type: "phase",
|
|
14680
|
+
filePath: args.scope ?? NAV_REQUEST_NO_PATH_SCOPE,
|
|
14681
|
+
durationMs: elapsedMs,
|
|
14682
|
+
metadata: { method: args.method }
|
|
14683
|
+
}, {
|
|
14684
|
+
ledgerKind: "lsp-nav-late-answer",
|
|
14685
|
+
risingEdgePer: "identity",
|
|
14686
|
+
reason: `late nav answer discarded after ${elapsedMs}ms`
|
|
14687
|
+
});
|
|
14688
|
+
} catch {
|
|
14689
|
+
}
|
|
14070
14690
|
}
|
|
14071
14691
|
function chooseLivenessProbe(state4) {
|
|
14072
14692
|
if (state4.operationSupport?.workspaceSymbol === true) {
|
|
@@ -14103,7 +14723,7 @@ function firstOpenDocumentUri(state4) {
|
|
|
14103
14723
|
}
|
|
14104
14724
|
return void 0;
|
|
14105
14725
|
}
|
|
14106
|
-
async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS) {
|
|
14726
|
+
async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS, signal) {
|
|
14107
14727
|
if (!isClientAlive(state4))
|
|
14108
14728
|
return false;
|
|
14109
14729
|
const probe = chooseLivenessProbe(state4);
|
|
@@ -14119,7 +14739,9 @@ async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS)
|
|
|
14119
14739
|
return isClientAlive(state4);
|
|
14120
14740
|
}
|
|
14121
14741
|
try {
|
|
14122
|
-
await
|
|
14742
|
+
await safeSendRequest(state4.connection, probe.method, probe.params, signal, void 0, { timeoutMs, cancel: true });
|
|
14743
|
+
if (signal?.aborted)
|
|
14744
|
+
return false;
|
|
14123
14745
|
} catch (err) {
|
|
14124
14746
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14125
14747
|
return false;
|
|
@@ -14150,10 +14772,7 @@ async function runServerCommand(state4, command, args, timeoutMs = EXECUTE_COMMA
|
|
|
14150
14772
|
try {
|
|
14151
14773
|
let result;
|
|
14152
14774
|
try {
|
|
14153
|
-
result = await
|
|
14154
|
-
command,
|
|
14155
|
-
arguments: args ?? []
|
|
14156
|
-
}), timeoutMs);
|
|
14775
|
+
result = await safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, void 0, void 0, { timeoutMs, cancel: false });
|
|
14157
14776
|
} catch (err) {
|
|
14158
14777
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14159
14778
|
return {
|
|
@@ -14183,15 +14802,11 @@ async function runReadOnlyServerCommand(state4, command, args, timeoutMs = PROBE
|
|
|
14183
14802
|
reason: `command "${command}" is not advertised by the ${state4.serverId} server`
|
|
14184
14803
|
};
|
|
14185
14804
|
}
|
|
14186
|
-
const abandon = new AbortController();
|
|
14187
|
-
const request = safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, abandon.signal, void 0, true);
|
|
14188
14805
|
try {
|
|
14189
|
-
const result = await
|
|
14806
|
+
const result = await safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, void 0, void 0, { timeoutMs, cancel: true });
|
|
14190
14807
|
return { executed: true, result };
|
|
14191
14808
|
} catch (err) {
|
|
14192
14809
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14193
|
-
abandon.abort();
|
|
14194
|
-
await request;
|
|
14195
14810
|
recordDegradationOnce({
|
|
14196
14811
|
kind: "lsp-readonly-command-released",
|
|
14197
14812
|
subject: state4.serverId,
|
|
@@ -14237,8 +14852,8 @@ function stripDocumentVersions(edit) {
|
|
|
14237
14852
|
}
|
|
14238
14853
|
async function normalizeClientWorkspaceEdit(state4, edit) {
|
|
14239
14854
|
validateWorkspaceEditVersions(state4, edit);
|
|
14240
|
-
const
|
|
14241
|
-
return stripDocumentVersions(
|
|
14855
|
+
const normalized2 = await normalizeWorkspaceEditToUtf16(edit, state4.positionEncoding, state4.root);
|
|
14856
|
+
return stripDocumentVersions(normalized2);
|
|
14242
14857
|
}
|
|
14243
14858
|
async function resolveCodeActionBestEffort(state4, action) {
|
|
14244
14859
|
if (!isClientAlive(state4))
|
|
@@ -14259,7 +14874,7 @@ async function resolveCodeActionBestEffort(state4, action) {
|
|
|
14259
14874
|
}
|
|
14260
14875
|
let resolved2;
|
|
14261
14876
|
try {
|
|
14262
|
-
resolved2 = await
|
|
14877
|
+
resolved2 = await safeSendRequest(state4.connection, "codeAction/resolve", action, getAmbientAbortSignal(), void 0, { timeoutMs: NAV_REQUEST_TIMEOUT_MS, cancel: true });
|
|
14263
14878
|
} catch {
|
|
14264
14879
|
return action;
|
|
14265
14880
|
}
|
|
@@ -14456,7 +15071,7 @@ async function createLSPClient(options) {
|
|
|
14456
15071
|
setupConnectionLifecycle(state4, recentStderr);
|
|
14457
15072
|
let initResult;
|
|
14458
15073
|
try {
|
|
14459
|
-
initResult = await
|
|
15074
|
+
initResult = await withDeadline(safeSendRequest(connection, "initialize", {
|
|
14460
15075
|
processId: process.pid,
|
|
14461
15076
|
rootUri: pathToFileURL2(root).href,
|
|
14462
15077
|
workspaceFolders: [
|
|
@@ -14464,7 +15079,7 @@ async function createLSPClient(options) {
|
|
|
14464
15079
|
],
|
|
14465
15080
|
capabilities: CLIENT_CAPABILITIES,
|
|
14466
15081
|
initializationOptions: initialization
|
|
14467
|
-
}), initializeTimeoutMs);
|
|
15082
|
+
}), { ms: initializeTimeoutMs });
|
|
14468
15083
|
} catch (err) {
|
|
14469
15084
|
state4.shutdownRequested = true;
|
|
14470
15085
|
const pid = lspProcess.pid;
|
|
@@ -14556,7 +15171,9 @@ async function createLSPClient(options) {
|
|
|
14556
15171
|
/** Pre-request health check — returns error string if dead. */
|
|
14557
15172
|
checkAlive: () => checkProcessAlive(),
|
|
14558
15173
|
/** #1277: cheap request round-trip proving the server still responds. */
|
|
14559
|
-
pingLiveness: (timeoutMs) => clientPingLiveness(state4, timeoutMs),
|
|
15174
|
+
pingLiveness: (timeoutMs, signal) => clientPingLiveness(state4, timeoutMs, signal),
|
|
15175
|
+
/** #5487: the server announced it is still loading (see interface doc). */
|
|
15176
|
+
readinessBlock: () => readinessBlockOf(state4),
|
|
14560
15177
|
/** #2358: the OS pid of the live server process (see interface doc). */
|
|
14561
15178
|
getProcessPid: () => lspProcess.pid,
|
|
14562
15179
|
notify: {
|
|
@@ -14760,7 +15377,7 @@ async function createLSPClient(options) {
|
|
|
14760
15377
|
},
|
|
14761
15378
|
async codeAction(filePath, line, character, endLine, endCharacter) {
|
|
14762
15379
|
if (!isClientAlive(state4))
|
|
14763
|
-
return
|
|
15380
|
+
return void 0;
|
|
14764
15381
|
const uri = pathToFileURL2(filePath).href;
|
|
14765
15382
|
const result = await navRequest(state4, "textDocument/codeAction", {
|
|
14766
15383
|
textDocument: { uri },
|
|
@@ -14772,8 +15389,12 @@ async function createLSPClient(options) {
|
|
|
14772
15389
|
diagnostics: getMergedDiagnosticsForPath(state4, normalizeMapKey(filePath))
|
|
14773
15390
|
}
|
|
14774
15391
|
}, filePath);
|
|
14775
|
-
if (
|
|
15392
|
+
if (result === void 0)
|
|
15393
|
+
return void 0;
|
|
15394
|
+
if (result === null)
|
|
14776
15395
|
return [];
|
|
15396
|
+
if (!Array.isArray(result))
|
|
15397
|
+
return void 0;
|
|
14777
15398
|
const actions = result.filter((item) => typeof item === "object" && item !== null && "title" in item);
|
|
14778
15399
|
return Promise.all(actions.map((action) => resolveCodeActionBestEffort(state4, action)));
|
|
14779
15400
|
},
|
|
@@ -14938,26 +15559,36 @@ async function safeSendNotification(connection, method, params) {
|
|
|
14938
15559
|
}
|
|
14939
15560
|
var activeRequestsByConnection = /* @__PURE__ */ new WeakMap();
|
|
14940
15561
|
var RELEASED_ON_ABORT = /* @__PURE__ */ Symbol("released-on-abort");
|
|
15562
|
+
var RELEASED_ON_TIMEOUT = /* @__PURE__ */ Symbol("released-on-timeout");
|
|
14941
15563
|
function isConnectionBusy(connection) {
|
|
14942
15564
|
return (activeRequestsByConnection.get(connection) ?? 0) > 0;
|
|
14943
15565
|
}
|
|
14944
|
-
async function safeSendRequest(connection, method, params, signal, settlement,
|
|
15566
|
+
async function safeSendRequest(connection, method, params, signal, settlement, bound) {
|
|
14945
15567
|
if (signal?.aborted)
|
|
14946
15568
|
return void 0;
|
|
14947
15569
|
let tokenSource;
|
|
14948
15570
|
let onAbort;
|
|
14949
15571
|
let released;
|
|
14950
15572
|
let release;
|
|
14951
|
-
|
|
15573
|
+
let timer;
|
|
15574
|
+
let timeoutError;
|
|
15575
|
+
if (signal || bound?.cancel)
|
|
14952
15576
|
tokenSource = new import_node.CancellationTokenSource();
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
15577
|
+
if (bound) {
|
|
15578
|
+
released = new Promise((resolve7) => {
|
|
15579
|
+
release = resolve7;
|
|
15580
|
+
});
|
|
15581
|
+
timer = setTimeout(() => {
|
|
15582
|
+
timeoutError = new Error(`Timeout after ${bound.timeoutMs}ms`);
|
|
15583
|
+
if (bound.cancel)
|
|
15584
|
+
tokenSource?.cancel();
|
|
15585
|
+
release?.(RELEASED_ON_TIMEOUT);
|
|
15586
|
+
}, Math.max(0, bound.timeoutMs));
|
|
15587
|
+
}
|
|
15588
|
+
if (signal) {
|
|
14958
15589
|
onAbort = () => {
|
|
14959
15590
|
tokenSource?.cancel();
|
|
14960
|
-
release?.();
|
|
15591
|
+
release?.(RELEASED_ON_ABORT);
|
|
14961
15592
|
};
|
|
14962
15593
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
14963
15594
|
}
|
|
@@ -14969,9 +15600,15 @@ async function safeSendRequest(connection, method, params, signal, settlement, r
|
|
|
14969
15600
|
try {
|
|
14970
15601
|
if (!released)
|
|
14971
15602
|
return await send();
|
|
14972
|
-
const
|
|
14973
|
-
|
|
15603
|
+
const sent = Promise.resolve(send());
|
|
15604
|
+
const reply = await Promise.race([sent, released]);
|
|
15605
|
+
if (reply === RELEASED_ON_ABORT || reply === RELEASED_ON_TIMEOUT) {
|
|
15606
|
+
const lateHook = reply === RELEASED_ON_TIMEOUT ? bound?.onLateSettle : void 0;
|
|
15607
|
+
sent.then(() => lateHook?.(true), () => lateHook?.(false));
|
|
15608
|
+
if (reply === RELEASED_ON_TIMEOUT)
|
|
15609
|
+
throw timeoutError;
|
|
14974
15610
|
return void 0;
|
|
15611
|
+
}
|
|
14975
15612
|
return reply;
|
|
14976
15613
|
} catch (err) {
|
|
14977
15614
|
if (isCancellationError(err)) {
|
|
@@ -14996,6 +15633,8 @@ async function safeSendRequest(connection, method, params, signal, settlement, r
|
|
|
14996
15633
|
activeRequestsByConnection.set(connection, remaining);
|
|
14997
15634
|
else
|
|
14998
15635
|
activeRequestsByConnection.delete(connection);
|
|
15636
|
+
if (timer)
|
|
15637
|
+
clearTimeout(timer);
|
|
14999
15638
|
if (signal && onAbort)
|
|
15000
15639
|
signal.removeEventListener("abort", onAbort);
|
|
15001
15640
|
tokenSource?.dispose();
|
|
@@ -15420,7 +16059,7 @@ var ClientRegistry = class {
|
|
|
15420
16059
|
admitAdoptedRoot(root, filePath) {
|
|
15421
16060
|
if (this.analysisRootModeForFile(filePath) !== "adopted")
|
|
15422
16061
|
return false;
|
|
15423
|
-
const
|
|
16062
|
+
const normalized2 = normalizeMapKey(root);
|
|
15424
16063
|
const liveRoots = /* @__PURE__ */ new Set();
|
|
15425
16064
|
for (const key of this.clients.keys()) {
|
|
15426
16065
|
if (this.adoptedClientKeys.has(key))
|
|
@@ -15430,16 +16069,16 @@ var ClientRegistry = class {
|
|
|
15430
16069
|
if (!liveRoots.has(root2))
|
|
15431
16070
|
this.adoptedRootLastUsedAt.delete(root2);
|
|
15432
16071
|
}
|
|
15433
|
-
if (liveRoots.has(
|
|
15434
|
-
this.adoptedRootLastUsedAt.set(
|
|
16072
|
+
if (liveRoots.has(normalized2)) {
|
|
16073
|
+
this.adoptedRootLastUsedAt.set(normalized2, Date.now());
|
|
15435
16074
|
return true;
|
|
15436
16075
|
}
|
|
15437
16076
|
if (this.adoptedRootLastUsedAt.size < ADOPTED_ROOT_CAP) {
|
|
15438
|
-
this.adoptedRootLastUsedAt.set(
|
|
16077
|
+
this.adoptedRootLastUsedAt.set(normalized2, Date.now());
|
|
15439
16078
|
return true;
|
|
15440
16079
|
}
|
|
15441
|
-
this.adoptedRootLastUsedAt.set(
|
|
15442
|
-
const victim = [...this.adoptedRootLastUsedAt.keys()].sort((a, b) => (this.adoptedRootLastUsedAt.get(a) ?? 0) - (this.adoptedRootLastUsedAt.get(b) ?? 0)).find((candidate) => candidate !==
|
|
16080
|
+
this.adoptedRootLastUsedAt.set(normalized2, Date.now());
|
|
16081
|
+
const victim = [...this.adoptedRootLastUsedAt.keys()].sort((a, b) => (this.adoptedRootLastUsedAt.get(a) ?? 0) - (this.adoptedRootLastUsedAt.get(b) ?? 0)).find((candidate) => candidate !== normalized2);
|
|
15443
16082
|
if (!victim)
|
|
15444
16083
|
return true;
|
|
15445
16084
|
this.adoptedRootLastUsedAt.delete(victim);
|
|
@@ -15668,14 +16307,13 @@ var ClientRegistry = class {
|
|
|
15668
16307
|
*/
|
|
15669
16308
|
async restartPrimaryClientsUnder(root) {
|
|
15670
16309
|
const rootKey = normalizeMapKey(root);
|
|
15671
|
-
const overlaps = (clientRoot) => isWithinForm(clientRoot, rootKey) || isWithinForm(rootKey, clientRoot);
|
|
15672
16310
|
return this.withClientSpawnGate(async () => {
|
|
15673
16311
|
if (this.isDestroyed)
|
|
15674
16312
|
return [];
|
|
15675
16313
|
const victims = [];
|
|
15676
16314
|
for (const [key, client] of this.clients) {
|
|
15677
16315
|
const { serverId, root: clientRoot } = parseClientKey(key);
|
|
15678
|
-
if (client.isAlive() && !isAuxiliary(getServerById(serverId)) &&
|
|
16316
|
+
if (client.isAlive() && !isAuxiliary(getServerById(serverId)) && rootsOverlap(clientRoot, rootKey))
|
|
15679
16317
|
victims.push([key, client]);
|
|
15680
16318
|
}
|
|
15681
16319
|
for (const [key] of victims)
|
|
@@ -16023,20 +16661,22 @@ var ClientRegistry = class {
|
|
|
16023
16661
|
recordLsp(server.id, root, "spawn_start");
|
|
16024
16662
|
try {
|
|
16025
16663
|
const projectCodeAllowed = this.analysisRootModeForFile(filePath) !== "adopted";
|
|
16026
|
-
|
|
16664
|
+
let spawned = await withLspProjectCodePermission(projectCodeAllowed, () => server.spawn(root, {
|
|
16027
16665
|
allowInstall,
|
|
16028
16666
|
projectCodeAllowed,
|
|
16029
16667
|
sessionRoot: this.sessionCwd ?? process.cwd()
|
|
16030
16668
|
}));
|
|
16031
|
-
|
|
16669
|
+
const abortSpawn = (launched) => {
|
|
16032
16670
|
try {
|
|
16033
|
-
|
|
16671
|
+
launched?.process?.process?.kill();
|
|
16034
16672
|
} catch {
|
|
16035
16673
|
}
|
|
16036
16674
|
logSessionStart(`lsp spawn ${server.id}: aborted (service shut down mid-spawn)`);
|
|
16037
16675
|
this.noteSpawnVerdict(key, "declined");
|
|
16038
16676
|
return void 0;
|
|
16039
|
-
}
|
|
16677
|
+
};
|
|
16678
|
+
if (this.isDestroyed)
|
|
16679
|
+
return abortSpawn(spawned);
|
|
16040
16680
|
if (!spawned) {
|
|
16041
16681
|
logSessionStart(`lsp spawn ${server.id}: unavailable (${Date.now() - startedAt}ms)`);
|
|
16042
16682
|
recordLsp(server.id, root, "spawn_failed", Date.now() - startedAt);
|
|
@@ -16058,29 +16698,48 @@ var ClientRegistry = class {
|
|
|
16058
16698
|
this.noteSpawnVerdict(key, "failed");
|
|
16059
16699
|
return void 0;
|
|
16060
16700
|
}
|
|
16061
|
-
const
|
|
16062
|
-
|
|
16063
|
-
|
|
16064
|
-
|
|
16065
|
-
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
|
|
16077
|
-
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16701
|
+
const connect = (launched) => {
|
|
16702
|
+
const override = getServerInitOverride(server.id, filePath);
|
|
16703
|
+
const mergedInit = launched.launchVariant === "classic" ? mergeInitializationOptions(override?.initializationOptions, launched.initialization) : mergeInitializationOptions(launched.initialization, override?.initializationOptions);
|
|
16704
|
+
this.hooks.rearmFirstContact(server.id);
|
|
16705
|
+
return createLSPClient({
|
|
16706
|
+
serverId: server.id,
|
|
16707
|
+
process: launched.process,
|
|
16708
|
+
root,
|
|
16709
|
+
sessionCwd: this.sessionCwd,
|
|
16710
|
+
initialization: mergedInit,
|
|
16711
|
+
initializeTimeoutMs: server.initializeTimeoutMs,
|
|
16712
|
+
launchVariant: launched.launchVariant,
|
|
16713
|
+
settingsSection: server.settingsSection,
|
|
16714
|
+
// #4764: the declared role travels with the client, so a failed server
|
|
16715
|
+
// config can gate an auxiliary scanner's empty publications only.
|
|
16716
|
+
role: server.role,
|
|
16717
|
+
// #5131 round 2: the config-declared flag gates the echo hold; a
|
|
16718
|
+
// built-in row with the same behaviour declares `echoesOwnNotice`.
|
|
16719
|
+
custom: server.custom,
|
|
16720
|
+
echoesOwnNotice: server.echoesOwnNotice,
|
|
16721
|
+
onDiagnosticsPublished: (serverId) => {
|
|
16722
|
+
this.hooks.noteDiagnosticsPublished(serverId);
|
|
16723
|
+
}
|
|
16724
|
+
});
|
|
16725
|
+
};
|
|
16726
|
+
let client;
|
|
16727
|
+
try {
|
|
16728
|
+
client = await connect(spawned);
|
|
16729
|
+
} catch (err) {
|
|
16730
|
+
const fallback = spawned.initializeFallback;
|
|
16731
|
+
if (!fallback)
|
|
16732
|
+
throw err;
|
|
16733
|
+
if (this.isDestroyed)
|
|
16734
|
+
return abortSpawn(void 0);
|
|
16735
|
+
const replacement = await withLspProjectCodePermission(projectCodeAllowed, () => fallback(err));
|
|
16736
|
+
if (!replacement)
|
|
16737
|
+
throw err;
|
|
16738
|
+
if (this.isDestroyed)
|
|
16739
|
+
return abortSpawn(replacement);
|
|
16740
|
+
spawned = replacement;
|
|
16741
|
+
client = await connect(spawned);
|
|
16742
|
+
}
|
|
16084
16743
|
if (this.isDestroyed) {
|
|
16085
16744
|
client.shutdown({ fast: true }).catch(() => {
|
|
16086
16745
|
});
|
|
@@ -16386,7 +17045,7 @@ function auxWaitBudgetMs(serverId, isCold, configuredCeilingMs, declaredWaitMs)
|
|
|
16386
17045
|
import * as path16 from "node:path";
|
|
16387
17046
|
|
|
16388
17047
|
// dist/clients/lsp/environment-gap.js
|
|
16389
|
-
import * as
|
|
17048
|
+
import * as fs12 from "node:fs";
|
|
16390
17049
|
import { isBuiltin } from "node:module";
|
|
16391
17050
|
import * as path15 from "node:path";
|
|
16392
17051
|
var ENVIRONMENT_GAP_MARKER = "no dependency install resolved for this workspace";
|
|
@@ -16450,7 +17109,7 @@ function declaredPackageNames(startDir) {
|
|
|
16450
17109
|
maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
|
|
16451
17110
|
})) {
|
|
16452
17111
|
try {
|
|
16453
|
-
const manifest = JSON.parse(
|
|
17112
|
+
const manifest = JSON.parse(fs12.readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
16454
17113
|
for (const field of DECLARING_FIELDS) {
|
|
16455
17114
|
const declared = manifest[field];
|
|
16456
17115
|
if (typeof declared !== "object" || declared === null)
|
|
@@ -16491,7 +17150,7 @@ function environmentGapKind(diagnostic) {
|
|
|
16491
17150
|
const name = MISSING_NAME.exec(message)?.[1];
|
|
16492
17151
|
return name !== void 0 && NODE_GLOBALS.has(name) ? { code } : void 0;
|
|
16493
17152
|
}
|
|
16494
|
-
function hasResolvableNodeModules(startDir, stat3 = (candidate) =>
|
|
17153
|
+
function hasResolvableNodeModules(startDir, stat3 = (candidate) => fs12.statSync(candidate)) {
|
|
16495
17154
|
let last;
|
|
16496
17155
|
for (const dir of walkUpDirs(startDir, {
|
|
16497
17156
|
maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
|
|
@@ -16712,7 +17371,7 @@ function createLazyImport(load) {
|
|
|
16712
17371
|
}
|
|
16713
17372
|
|
|
16714
17373
|
// dist/clients/lsp-lazy.js
|
|
16715
|
-
var lazyLsp = createLazyImport(() => import("./chunk-
|
|
17374
|
+
var lazyLsp = createLazyImport(() => import("./chunk-EH6EHFW2.js"));
|
|
16716
17375
|
function warmLspService() {
|
|
16717
17376
|
return lazyLsp.get();
|
|
16718
17377
|
}
|
|
@@ -16837,7 +17496,7 @@ var SCOPED_DEPENDENCY_TOUCH_MAX = 32;
|
|
|
16837
17496
|
var RENAME_NOTIFY_TIMEOUT_MS = Math.max(50, Number.parseInt(process.env.PI_LENS_LSP_RENAME_NOTIFY_TIMEOUT_MS ?? "1500", 10) || 1500);
|
|
16838
17497
|
async function runRenameNotify(send, timeoutMs) {
|
|
16839
17498
|
try {
|
|
16840
|
-
await
|
|
17499
|
+
await withDeadline(send(), { ms: timeoutMs });
|
|
16841
17500
|
return { ok: true };
|
|
16842
17501
|
} catch (err) {
|
|
16843
17502
|
const timedOut = err instanceof Error && err.message.startsWith("Timeout after");
|
|
@@ -18212,7 +18871,7 @@ var LSPService = class _LSPService {
|
|
|
18212
18871
|
const separator = key.indexOf(":");
|
|
18213
18872
|
const serverId = separator >= 0 ? key.slice(0, separator) : key;
|
|
18214
18873
|
const root = normalizeMapKey(client.root);
|
|
18215
|
-
const sameOrNested =
|
|
18874
|
+
const sameOrNested = rootsOverlap(root, normalizedCwd);
|
|
18216
18875
|
if (!sameOrNested)
|
|
18217
18876
|
continue;
|
|
18218
18877
|
entries.push({ clientKey: key, serverId, client });
|
|
@@ -18941,7 +19600,7 @@ var LSPService = class _LSPService {
|
|
|
18941
19600
|
const readStamp = performance.now();
|
|
18942
19601
|
let content;
|
|
18943
19602
|
try {
|
|
18944
|
-
content = await
|
|
19603
|
+
content = await fs13.readFile(filePath, "utf8");
|
|
18945
19604
|
} catch {
|
|
18946
19605
|
continue;
|
|
18947
19606
|
}
|
|
@@ -19530,6 +20189,9 @@ var LSPService = class _LSPService {
|
|
|
19530
20189
|
let diagnosticsTimedOut = false;
|
|
19531
20190
|
let diagnosticsUnansweredServerIds = [];
|
|
19532
20191
|
let diagnosticsUnansweredPrimaryServerIds = [];
|
|
20192
|
+
const loadingExpiredServerIds = /* @__PURE__ */ new Set();
|
|
20193
|
+
const loadFailedExpiredServerIds = /* @__PURE__ */ new Set();
|
|
20194
|
+
let loadFailureDetail;
|
|
19533
20195
|
const retractPrimaryTimeoutAttribution = () => {
|
|
19534
20196
|
diagnosticsUnansweredPrimaryServerIds = [];
|
|
19535
20197
|
diagnosticsUnansweredServerIds = diagnosticsUnansweredServerIds.filter((id) => !primaryServerIds.has(id));
|
|
@@ -19705,6 +20367,13 @@ var LSPService = class _LSPService {
|
|
|
19705
20367
|
}) : entry.client.waitForDiagnostics(filePath, serverTimeout)).then((outcome) => {
|
|
19706
20368
|
if (outcome === "deadline-expired" && !isAuxiliary(entry.info) && !isSilentOnCleanServer(entry)) {
|
|
19707
20369
|
expiredWaitServerIds.add(entry.info.id);
|
|
20370
|
+
const block = entry.client.readinessBlock?.();
|
|
20371
|
+
if (block?.reason === "server-loading") {
|
|
20372
|
+
loadingExpiredServerIds.add(entry.info.id);
|
|
20373
|
+
} else if (block?.reason === "server-load-failed") {
|
|
20374
|
+
loadFailedExpiredServerIds.add(entry.info.id);
|
|
20375
|
+
loadFailureDetail ??= block.detail;
|
|
20376
|
+
}
|
|
19708
20377
|
}
|
|
19709
20378
|
return outcome;
|
|
19710
20379
|
});
|
|
@@ -19987,43 +20656,45 @@ var LSPService = class _LSPService {
|
|
|
19987
20656
|
const hasWaitedPrimary = waited.some((entry) => !isAuxiliary(entry.info));
|
|
19988
20657
|
const hasUnsupportedPrimary = diagnosticsUnsupportedServerIds.some((serverId) => spawned.some((entry) => entry.info.id === serverId && !isAuxiliary(entry.info)));
|
|
19989
20658
|
diagnosticsTimedOut = !hasWaitedPrimary && !hasUnsupportedPrimary || diagnosticsUnansweredPrimaryServerIds.length > 0;
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
|
|
20659
|
+
if (getAmbientAbortSignal()?.aborted !== true) {
|
|
20660
|
+
for (const entry of unanswered2) {
|
|
20661
|
+
incrementDegradationCount({
|
|
20662
|
+
kind: "lsp-diagnostics-timeout",
|
|
20663
|
+
// `info.id` is the authoritative server identity carried by
|
|
20664
|
+
// every spawned entry. The client test doubles (and some
|
|
20665
|
+
// lightweight clients) need not expose a serverId property;
|
|
20666
|
+
// ledger recording must never abort the touch or alter #570's
|
|
20667
|
+
// timeout-preserves-last-known-diagnostics semantics.
|
|
20668
|
+
subject: entry.info.id,
|
|
20669
|
+
reason: "diagnostics wait timed out"
|
|
20670
|
+
});
|
|
20671
|
+
}
|
|
20672
|
+
logLatency({
|
|
20673
|
+
type: "phase",
|
|
20674
|
+
phase: "lsp_diagnostics_timeout",
|
|
20675
|
+
filePath: normalizedPath,
|
|
20676
|
+
durationMs: waitedMs,
|
|
20677
|
+
metadata: {
|
|
20678
|
+
source,
|
|
20679
|
+
// #1444: WHICH server(s) burned the budget — without this the
|
|
20680
|
+
// ~221/day timeout rows can't be attributed to a server at all.
|
|
20681
|
+
// `info.id` (not `client.serverId`) for the same reason the
|
|
20682
|
+
// degradation ledger above uses it: test doubles and lightweight
|
|
20683
|
+
// clients need not expose `serverId`.
|
|
20684
|
+
serverIds: spawned.map((e) => e.info.id),
|
|
20685
|
+
clientScope,
|
|
20686
|
+
diagnosticsMode,
|
|
20687
|
+
timeoutMs,
|
|
20688
|
+
// #1549: which of those servers actually produced no evidence, and
|
|
20689
|
+
// whether the lapse is attributable to a primary (the touch is
|
|
20690
|
+
// inconclusive) or only to auxiliaries (a named coverage gap, with
|
|
20691
|
+
// the primary's findings intact). Without these two fields a
|
|
20692
|
+
// forensic sweep cannot tell the two apart at all.
|
|
20693
|
+
unansweredServerIds: diagnosticsUnansweredServerIds,
|
|
20694
|
+
attributedToPrimary: diagnosticsTimedOut
|
|
20695
|
+
}
|
|
20000
20696
|
});
|
|
20001
20697
|
}
|
|
20002
|
-
logLatency({
|
|
20003
|
-
type: "phase",
|
|
20004
|
-
phase: "lsp_diagnostics_timeout",
|
|
20005
|
-
filePath: normalizedPath,
|
|
20006
|
-
durationMs: waitedMs,
|
|
20007
|
-
metadata: {
|
|
20008
|
-
source,
|
|
20009
|
-
// #1444: WHICH server(s) burned the budget — without this the
|
|
20010
|
-
// ~221/day timeout rows can't be attributed to a server at all.
|
|
20011
|
-
// `info.id` (not `client.serverId`) for the same reason the
|
|
20012
|
-
// degradation ledger above uses it: test doubles and lightweight
|
|
20013
|
-
// clients need not expose `serverId`.
|
|
20014
|
-
serverIds: spawned.map((e) => e.info.id),
|
|
20015
|
-
clientScope,
|
|
20016
|
-
diagnosticsMode,
|
|
20017
|
-
timeoutMs,
|
|
20018
|
-
// #1549: which of those servers actually produced no evidence, and
|
|
20019
|
-
// whether the lapse is attributable to a primary (the touch is
|
|
20020
|
-
// inconclusive) or only to auxiliaries (a named coverage gap, with
|
|
20021
|
-
// the primary's findings intact). Without these two fields a
|
|
20022
|
-
// forensic sweep cannot tell the two apart at all.
|
|
20023
|
-
unansweredServerIds: diagnosticsUnansweredServerIds,
|
|
20024
|
-
attributedToPrimary: diagnosticsTimedOut
|
|
20025
|
-
}
|
|
20026
|
-
});
|
|
20027
20698
|
}
|
|
20028
20699
|
if (diagnosticsTimedOut && !primaryNotifyWriteTimedOut && clientScope === "all") {
|
|
20029
20700
|
try {
|
|
@@ -20032,7 +20703,7 @@ var LSPService = class _LSPService {
|
|
|
20032
20703
|
const snapshots = await this.getCapabilitySnapshots(filePath);
|
|
20033
20704
|
const allSilent = outstanding.every((entry) => classifyServerWaitTier(entry.client.serverId, snapshots.find((s) => s.serverId === entry.client.serverId)) === "tier3-silent");
|
|
20034
20705
|
if (allSilent) {
|
|
20035
|
-
const liveness = await Promise.all(outstanding.map((entry) => (entry.client.pingLiveness?.() ?? Promise.resolve(true)).catch(() => false)));
|
|
20706
|
+
const liveness = await Promise.all(outstanding.map((entry) => (entry.client.pingLiveness?.(void 0, getAmbientAbortSignal()) ?? Promise.resolve(true)).catch(() => false)));
|
|
20036
20707
|
if (liveness.every(Boolean)) {
|
|
20037
20708
|
diagnosticsTimedOut = false;
|
|
20038
20709
|
retractPrimaryTimeoutAttribution();
|
|
@@ -20126,7 +20797,7 @@ var LSPService = class _LSPService {
|
|
|
20126
20797
|
try {
|
|
20127
20798
|
const snapshots = await this.getCapabilitySnapshots(filePath);
|
|
20128
20799
|
if (classifyCascadeWaitTier(this, filePath, snapshots) === "tier3-silent") {
|
|
20129
|
-
const alive = await (spawned[0].client.pingLiveness?.() ?? Promise.resolve(true)).catch(() => false);
|
|
20800
|
+
const alive = await (spawned[0].client.pingLiveness?.(void 0, getAmbientAbortSignal()) ?? Promise.resolve(true)).catch(() => false);
|
|
20130
20801
|
if (alive) {
|
|
20131
20802
|
diagnosticsTimedOut = false;
|
|
20132
20803
|
retractPrimaryTimeoutAttribution();
|
|
@@ -20155,7 +20826,10 @@ var LSPService = class _LSPService {
|
|
|
20155
20826
|
primaryUnavailableCause: unanswered.cause,
|
|
20156
20827
|
primaryNotifyWriteTimedOutServerIds,
|
|
20157
20828
|
diagnosticsTimedOut,
|
|
20158
|
-
diagnosticsUnansweredServerIds: diagnosticsUnansweredPrimaryServerIds
|
|
20829
|
+
diagnosticsUnansweredServerIds: diagnosticsUnansweredPrimaryServerIds,
|
|
20830
|
+
loadingServerIds: [...loadingExpiredServerIds],
|
|
20831
|
+
loadFailedServerIds: [...loadFailedExpiredServerIds],
|
|
20832
|
+
...loadFailureDetail !== void 0 && { loadFailureDetail }
|
|
20159
20833
|
});
|
|
20160
20834
|
const inconclusive = verdict.inconclusive;
|
|
20161
20835
|
const skippedAuxiliaries = collected !== void 0 ? await this.skippedAuxiliaryServerIds(filePath, clientScope, options, spawned) : { brokenSkippedServerIds: [], policySkippedServerIds: [] };
|
|
@@ -20252,6 +20926,9 @@ var LSPService = class _LSPService {
|
|
|
20252
20926
|
result.inconclusiveServerIds = verdict.inconclusiveServerIds;
|
|
20253
20927
|
}
|
|
20254
20928
|
result.inconclusiveReason = verdict.inconclusiveReason;
|
|
20929
|
+
if (verdict.inconclusiveDetail !== void 0) {
|
|
20930
|
+
result.inconclusiveDetail = verdict.inconclusiveDetail;
|
|
20931
|
+
}
|
|
20255
20932
|
if (verdict.disabledPrimaryServerIds) {
|
|
20256
20933
|
result.disabledPrimaryServerIds = verdict.disabledPrimaryServerIds;
|
|
20257
20934
|
}
|
|
@@ -20367,6 +21044,9 @@ var LSPService = class _LSPService {
|
|
|
20367
21044
|
...verdict.inconclusiveReason && {
|
|
20368
21045
|
inconclusiveReason: verdict.inconclusiveReason
|
|
20369
21046
|
},
|
|
21047
|
+
...verdict.inconclusiveDetail !== void 0 && {
|
|
21048
|
+
inconclusiveDetail: verdict.inconclusiveDetail
|
|
21049
|
+
},
|
|
20370
21050
|
// #1470: the touch's own honesty verdict, so a `cut_off` row in
|
|
20371
21051
|
// `lsp_aux_wait_outcome` can be joined to the touch that produced it and
|
|
20372
21052
|
// shown NOT to have claimed confirmation for that server's coverage.
|
|
@@ -21127,7 +21807,7 @@ var LSPService = class _LSPService {
|
|
|
21127
21807
|
async codeAction(filePath, line, character, endLine, endCharacter) {
|
|
21128
21808
|
const spawned = await this.getClientForFile(filePath, NAV_CLIENT_WAIT_TIMEOUT_MS);
|
|
21129
21809
|
if (!spawned)
|
|
21130
|
-
return
|
|
21810
|
+
return void 0;
|
|
21131
21811
|
if (!spawned.client.getOperationSupport().codeAction) {
|
|
21132
21812
|
throw new Error("__UNSUPPORTED__ Active LSP server does not advertise support for codeAction");
|
|
21133
21813
|
}
|
|
@@ -21262,7 +21942,7 @@ var LSPService = class _LSPService {
|
|
|
21262
21942
|
status: "failed"
|
|
21263
21943
|
});
|
|
21264
21944
|
}
|
|
21265
|
-
const content = await
|
|
21945
|
+
const content = await fs13.readFile(oldFilePath, "utf-8");
|
|
21266
21946
|
const languageId = getLanguageId2(oldFilePath) ?? "plaintext";
|
|
21267
21947
|
const resyncFailures = [];
|
|
21268
21948
|
await Promise.all(openDocuments.map(async ({ serverId, client }) => {
|
|
@@ -21672,7 +22352,8 @@ var LSPService = class _LSPService {
|
|
|
21672
22352
|
failedServerIds = stillColdServerIds();
|
|
21673
22353
|
}
|
|
21674
22354
|
}
|
|
21675
|
-
|
|
22355
|
+
const abandoned = options.signal?.aborted === true || getAmbientAbortSignal()?.aborted === true;
|
|
22356
|
+
if (failedServerIds.length > 0 && !abandoned) {
|
|
21676
22357
|
for (let i = 0; i < servers.length; i++) {
|
|
21677
22358
|
const key = keys[i];
|
|
21678
22359
|
if (key !== void 0 && failedServerIds.includes(servers[i].id) && this.state.clients.get(key) === warmedClients[i]) {
|
|
@@ -21736,7 +22417,7 @@ var LSPService = class _LSPService {
|
|
|
21736
22417
|
await Promise.all(openImports.slice(0, SCOPED_DEPENDENCY_TOUCH_MAX).map(async (dependency) => {
|
|
21737
22418
|
let content;
|
|
21738
22419
|
try {
|
|
21739
|
-
content = await
|
|
22420
|
+
content = await fs13.readFile(dependency, "utf8");
|
|
21740
22421
|
} catch {
|
|
21741
22422
|
return;
|
|
21742
22423
|
}
|
|
@@ -22557,6 +23238,7 @@ export {
|
|
|
22557
23238
|
warmAnswerBinding,
|
|
22558
23239
|
readBoundToCurrentDisk,
|
|
22559
23240
|
SERVER_CONFIG_FILE_NAMES,
|
|
23241
|
+
BELOW_ROOT_CONFIG_FILE_NAMES,
|
|
22560
23242
|
LspRequestTimeoutError,
|
|
22561
23243
|
isLspRequestTimeoutError,
|
|
22562
23244
|
groupFilesByPrimaryServer,
|