@herbertgao/pi-extensions 2026.11.12 → 2026.11.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +6 -4
- package/node_modules/@herbertgao/pi-inline-skill-commands/LICENSE +21 -0
- package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +37 -0
- package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +53 -0
- package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +239 -0
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +10 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +37 -7
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +113 -34
- package/node_modules/@herbertgao/pi-subagents/package.json +9 -4
- package/node_modules/@herbertgao/pi-subagents/skills/workflow-authoring/SKILL.md +147 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +48 -32
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +16 -8
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +16 -6
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +99 -7
- package/node_modules/@herbertgao/pi-subagents/src/mention.ts +5 -7
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +26 -0
- package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +13 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +55 -8
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card-redraw.ts +86 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +5 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +478 -115
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +77 -6
- package/node_modules/@herbertgao/pi-subagents/src/workflow/agent-detail.ts +148 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -14
- package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +8 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +507 -57
- package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +41 -11
- package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +106 -34
- package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +43 -5
- package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +93 -153
- package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +283 -71
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +288 -177
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
- package/node_modules/@pi-plugins/fast-mode/package.json +7 -7
- package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
- package/node_modules/pi-lens/CHANGELOG.md +132 -0
- package/node_modules/pi-lens/README.md +2 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
- package/node_modules/pi-lens/dist/{chunk-LGH2HHZG.js → chunk-25CAONWT.js} +36 -25
- package/node_modules/pi-lens/dist/{chunk-ZQSSO7LO.js → chunk-2DWNYVUN.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-YCR6ZYTE.js → chunk-2RQREVGO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VWEBZ2JV.js → chunk-2XALJI2K.js} +40 -40
- package/node_modules/pi-lens/dist/{chunk-PQXUZYTQ.js → chunk-2YQ5LI7R.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-VSQT6IHZ.js → chunk-35UJUF27.js} +18 -4
- package/node_modules/pi-lens/dist/{chunk-OLWGYBYT.js → chunk-3IWMNN2S.js} +17 -17
- package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +88 -0
- package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-UNP6Y4JV.js → chunk-4E4OCW3L.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-37IDWT6O.js → chunk-4GLSO2EM.js} +13 -11
- package/node_modules/pi-lens/dist/{chunk-QV3JPCMK.js → chunk-5HVDD7IA.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZRQMENT4.js → chunk-62PIU4TO.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-3TSMQZG6.js → chunk-6MDWNZ7E.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-WLD6BGON.js → chunk-6MWX2J5H.js} +4 -0
- package/node_modules/pi-lens/dist/{chunk-SCU62JLX.js → chunk-6MZLS6CK.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-B42AIWPJ.js → chunk-7BWPQZHE.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-I3NZVAMN.js → chunk-7JMEPY6P.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-7DPXUPRF.js → chunk-7ORBRDFY.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6E5QLMWI.js → chunk-7WAQ3K26.js} +23 -23
- package/node_modules/pi-lens/dist/{chunk-2H5GHZKC.js → chunk-AB26NAHA.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-BBSDJTOV.js → chunk-AFSG6YUB.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-XDNWR7SG.js → chunk-ALTHJUZO.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-UN72ZAJ5.js → chunk-AOEVZXR6.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-HRLF35WL.js → chunk-ARTCVE6I.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-LQQNFCQJ.js → chunk-B2QO7GHY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-I2FYOZNW.js → chunk-BJGWP4UX.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-G53LBDNU.js → chunk-BKJ6WZKP.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-P5MSLVUW.js → chunk-BQ72NQQM.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-K7O6AHSJ.js → chunk-BWGNVM33.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ADYQRETD.js → chunk-BYIEU4E4.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7ZVTFLCC.js → chunk-CDAJQBKJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-BKWFDWYM.js → chunk-D3UQWOCB.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-3PAS2ERX.js → chunk-DHFJS2I4.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-KNSOA43J.js → chunk-DKXIUGNA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LOEJFTF2.js → chunk-DLGJYQML.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-VGRGW4UL.js → chunk-DNJJVKJZ.js} +31 -31
- package/node_modules/pi-lens/dist/{chunk-5HBQL7DH.js → chunk-EBXCYEII.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +73 -0
- package/node_modules/pi-lens/dist/{chunk-W26QZ3OM.js → chunk-EKQDQPX6.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-TWEOJE3D.js → chunk-EXHSWN3P.js} +844 -377
- package/node_modules/pi-lens/dist/{chunk-4IZZEN63.js → chunk-F7BFIENK.js} +33 -33
- package/node_modules/pi-lens/dist/{chunk-ZI7YHV6I.js → chunk-FD4LJQ6Y.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RIH3UBK4.js → chunk-GFCPPCNR.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-5JB4WENL.js → chunk-GIK6VUCY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-PPQHMSPH.js → chunk-GNK2IHVG.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-CXQYK4YT.js → chunk-H6DNTQ4V.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-NGNBJIUO.js → chunk-HERQPNY6.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-INBK3HIT.js → chunk-HFIFEH46.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-J2ZB5MDS.js → chunk-HKRESBMC.js} +20 -20
- package/node_modules/pi-lens/dist/{chunk-AZG5UJYY.js → chunk-HMXWZUQW.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-XSC3BCN3.js → chunk-HOWHAKXO.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-7CLWC2UH.js → chunk-HUWW77QY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KZ732ZVW.js → chunk-IO6P3NBP.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-7WKVCZI4.js → chunk-J7VNGHLN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QE7BJQ6K.js → chunk-JGCBMCCS.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-PFJLYRO3.js → chunk-KIQSNH3F.js} +34 -34
- package/node_modules/pi-lens/dist/{chunk-JGUDT5KD.js → chunk-KSQJBGRO.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-RJ3APNIP.js → chunk-KXKM2DFP.js} +4 -4
- package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-6GLMMGCX.js → chunk-LDPY22FS.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-3PO4YYOX.js → chunk-M3QGXGY4.js} +3793 -3814
- package/node_modules/pi-lens/dist/{chunk-NNEQOC3U.js → chunk-MET776XM.js} +9 -7
- package/node_modules/pi-lens/dist/{chunk-X33QECRJ.js → chunk-MKQFSW2Q.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-7U36VQL6.js → chunk-MKW7ZUTT.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-PQF6YGYB.js → chunk-N2U644ZW.js} +4 -18
- package/node_modules/pi-lens/dist/{chunk-DI4AZZNY.js → chunk-NAACKIKT.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O6LCSHHI.js → chunk-NHHS5T52.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-DCA2MXVQ.js → chunk-NIZKGBOU.js} +51 -27
- package/node_modules/pi-lens/dist/{chunk-PKWEBMCA.js → chunk-NNDZ7DOP.js} +194 -111
- package/node_modules/pi-lens/dist/{chunk-Q7J3JYJ2.js → chunk-NZ7NSKIW.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-S6MCMD27.js → chunk-OG3UCAHV.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-3QXFUP6T.js → chunk-OHTHVILU.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-NHA5K226.js → chunk-P7EV5ISR.js} +17 -2
- package/node_modules/pi-lens/dist/{chunk-L6BDRYUK.js → chunk-PVV27TOX.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-HIRBC72R.js → chunk-Q32RJDYC.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-QE5DJ7MX.js → chunk-Q4UQNTLB.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-SDYLT45T.js → chunk-QQGZY2BR.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QMWKSYWB.js → chunk-S247BOH2.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-ARTYCUGF.js → chunk-S7KUDW73.js} +121 -18
- package/node_modules/pi-lens/dist/{chunk-6CFSDLHE.js → chunk-SJ2SR432.js} +17 -17
- package/node_modules/pi-lens/dist/{chunk-CQY2HEH7.js → chunk-SL4G67AP.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-LVLPA32Q.js → chunk-T2D2WWP6.js} +48 -11
- package/node_modules/pi-lens/dist/{chunk-HIJ4CHFF.js → chunk-T7KHGEJ5.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-74AMPWNC.js → chunk-TABDCX35.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +25 -0
- package/node_modules/pi-lens/dist/{chunk-KNJH6WJQ.js → chunk-TQKWR5AZ.js} +7 -7
- package/node_modules/pi-lens/dist/chunk-TWAQFMLW.js +110 -0
- package/node_modules/pi-lens/dist/{chunk-TKOFTLGB.js → chunk-UARVPNAU.js} +33 -33
- package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +56 -0
- package/node_modules/pi-lens/dist/{chunk-K4Z7MK6T.js → chunk-VEF3GFOL.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-4DAHGU3V.js → chunk-W2JPGW7Q.js} +27 -25
- package/node_modules/pi-lens/dist/{chunk-CZJGAOKL.js → chunk-W2YHHNY3.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-R4L7KZ7R.js → chunk-WA6U2URH.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-OZQQ3AIR.js → chunk-WAK2AXQQ.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-DFKOA74L.js → chunk-WH6O4IFD.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-27JQHK7Y.js → chunk-WJ7GY5WJ.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-KXGTLAUW.js → chunk-WWZLT6AM.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-O2MHF7QM.js → chunk-XRLZ75YY.js} +38 -38
- package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +27 -0
- package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +27 -0
- package/node_modules/pi-lens/dist/{chunk-C5PLBTNR.js → chunk-Y2LIOCA7.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-AXAR5ZW2.js → chunk-YIEHUKX2.js} +84 -169
- package/node_modules/pi-lens/dist/{chunk-B2OXE4AH.js → chunk-YOMLAKU6.js} +182 -180
- package/node_modules/pi-lens/dist/{chunk-MOAVEPC4.js → chunk-YV7XVYSJ.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-ZULZS2I6.js → chunk-ZVQUYCBU.js} +996 -365
- package/node_modules/pi-lens/dist/index.js +4911 -2376
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
- package/node_modules/pi-lens/dist/mcp/cli.js +40 -40
- package/node_modules/pi-lens/dist/mcp/server.js +321 -234
- package/node_modules/pi-lens/dist/mcp/worker.js +58 -58
- package/node_modules/pi-lens/dist/probes/installer.js +21 -21
- package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +18 -9
- package/node_modules/pi-lens/docs/ci.md +7 -0
- package/node_modules/pi-lens/docs/defect-shapes.md +43 -28
- package/node_modules/pi-lens/docs/globalconfig.md +1 -0
- package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +15 -0
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +3 -3
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +3 -2
- package/node_modules/pi-lens/docs/module-report-read-symbol.md +6 -2
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +3 -2
- package/node_modules/pi-lens/docs/pi-lens-orchestration.md +2 -1
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +2 -1
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +1 -0
- package/node_modules/pi-lens/docs/usage.md +1 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/package.json +9 -4
- package/node_modules/pi-lens/dist/chunk-2H7NFZ4Q.js +0 -25
- package/node_modules/pi-lens/dist/chunk-5YJXF2IS.js +0 -56
- package/node_modules/pi-lens/dist/chunk-GCSDF5IE.js +0 -27
- package/node_modules/pi-lens/dist/chunk-H5API74E.js +0 -67
- package/node_modules/pi-lens/dist/chunk-HBX55MWO.js +0 -27
- package/node_modules/pi-lens/dist/chunk-JOIKBUQN.js +0 -88
- package/node_modules/pi-lens/dist/chunk-M2YMBT5G.js +0 -73
- package/node_modules/pi-lens/dist/chunk-MJRGPEQ5.js +0 -25
- package/node_modules/pi-lens/dist/chunk-TFKN5EIR.js +0 -27
|
@@ -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,23 +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
|
-
} from "./chunk-NNEQOC3U.js";
|
|
51
|
+
} from "./chunk-AB26NAHA.js";
|
|
54
52
|
import {
|
|
55
53
|
acquireWorkspaceSweepHold,
|
|
56
54
|
configureLspServiceLifecycle,
|
|
57
55
|
getOwnedLspService,
|
|
58
56
|
peekOwnedLspService,
|
|
59
57
|
resetOwnedLspService
|
|
60
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-B2QO7GHY.js";
|
|
61
59
|
import {
|
|
62
60
|
RUNTIME_CONFIG,
|
|
63
61
|
collectForwardImportMtimes,
|
|
@@ -72,37 +70,40 @@ import {
|
|
|
72
70
|
lineTextAt,
|
|
73
71
|
pathBirthtimeMs,
|
|
74
72
|
scanDocumentContent
|
|
75
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-S7KUDW73.js";
|
|
76
74
|
import {
|
|
77
75
|
js_yaml_default
|
|
78
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-2DWNYVUN.js";
|
|
77
|
+
import {
|
|
78
|
+
loadProjectSnapshot
|
|
79
|
+
} from "./chunk-MET776XM.js";
|
|
79
80
|
import {
|
|
80
81
|
EXTENSION_TO_LSP_ID,
|
|
81
82
|
lspLanguageId,
|
|
82
83
|
resolveFilenameLanguage
|
|
83
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-NAACKIKT.js";
|
|
84
85
|
import {
|
|
85
86
|
diagnosticsIpcPathForCwd,
|
|
86
87
|
requestWarmCodeActions,
|
|
87
88
|
requestWarmDiagnostics
|
|
88
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-6MDWNZ7E.js";
|
|
89
90
|
import {
|
|
90
91
|
semanticFor
|
|
91
92
|
} from "./chunk-2APSZHHI.js";
|
|
92
93
|
import {
|
|
93
94
|
findLocalZizmorConfig,
|
|
94
95
|
logSessionStart
|
|
95
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-YOMLAKU6.js";
|
|
96
97
|
import {
|
|
97
98
|
findLocalBinUpwards,
|
|
98
99
|
isProjectLocalBinPath
|
|
99
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-25CAONWT.js";
|
|
101
|
+
import {
|
|
102
|
+
getLspCapableKinds
|
|
103
|
+
} from "./chunk-HOWHAKXO.js";
|
|
100
104
|
import {
|
|
101
105
|
readJsonCache
|
|
102
106
|
} from "./chunk-TQWRH25U.js";
|
|
103
|
-
import {
|
|
104
|
-
getLspCapableKinds
|
|
105
|
-
} from "./chunk-XSC3BCN3.js";
|
|
106
107
|
import {
|
|
107
108
|
createGenerationMap,
|
|
108
109
|
createGenerationSource,
|
|
@@ -121,19 +122,19 @@ import {
|
|
|
121
122
|
sampleProcessTreeCpuPercent,
|
|
122
123
|
selectLivePeerInstances,
|
|
123
124
|
windowsExe
|
|
124
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-M3QGXGY4.js";
|
|
125
126
|
import {
|
|
126
127
|
createSingleFlight
|
|
127
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-GIK6VUCY.js";
|
|
129
|
+
import {
|
|
130
|
+
PathKeyedMap,
|
|
131
|
+
detectFileRole
|
|
132
|
+
} from "./chunk-N2U644ZW.js";
|
|
128
133
|
import {
|
|
129
134
|
SPECIAL_FILENAMES,
|
|
130
135
|
getLanguageId,
|
|
131
136
|
isJstsFactFile
|
|
132
|
-
} from "./chunk-
|
|
133
|
-
import {
|
|
134
|
-
PathKeyedMap,
|
|
135
|
-
detectFileRole
|
|
136
|
-
} from "./chunk-PQF6YGYB.js";
|
|
137
|
+
} from "./chunk-SL4G67AP.js";
|
|
137
138
|
import {
|
|
138
139
|
CONTENT_HASH_MAX_BYTES,
|
|
139
140
|
hashContentBytes,
|
|
@@ -149,17 +150,17 @@ import {
|
|
|
149
150
|
readAdoptedProjectTrust,
|
|
150
151
|
untilAborted,
|
|
151
152
|
withDeadline,
|
|
152
|
-
withTimeout,
|
|
153
153
|
writeFileAtomic
|
|
154
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-EKQDQPX6.js";
|
|
155
155
|
import {
|
|
156
156
|
compareOrdinal,
|
|
157
157
|
incrementDegradationCount,
|
|
158
158
|
logExtension,
|
|
159
159
|
recordDegradation,
|
|
160
160
|
recordDegradationOnce,
|
|
161
|
+
spawnAbortScope,
|
|
161
162
|
truncateForLedger
|
|
162
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-P7EV5ISR.js";
|
|
163
164
|
import {
|
|
164
165
|
freshnessFromMtime
|
|
165
166
|
} from "./chunk-S26LC76R.js";
|
|
@@ -176,7 +177,7 @@ import {
|
|
|
176
177
|
nonNegativeIntEnv,
|
|
177
178
|
phaseFinished,
|
|
178
179
|
phaseStarted
|
|
179
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-HUWW77QY.js";
|
|
180
181
|
import {
|
|
181
182
|
BoundedFifoMap,
|
|
182
183
|
BoundedLruCache,
|
|
@@ -195,12 +196,13 @@ import {
|
|
|
195
196
|
realpathOrResolve,
|
|
196
197
|
realpathOrResolveAsync,
|
|
197
198
|
relativeInside,
|
|
199
|
+
rootsOverlap,
|
|
198
200
|
toPosix,
|
|
199
201
|
toProjectRelativePath,
|
|
200
202
|
uriToDiskPath,
|
|
201
203
|
uriToPath,
|
|
202
204
|
walkUpDirs
|
|
203
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-6MWX2J5H.js";
|
|
204
206
|
import {
|
|
205
207
|
__commonJS,
|
|
206
208
|
__require,
|
|
@@ -3627,7 +3629,7 @@ var require_main = __commonJS({
|
|
|
3627
3629
|
ril_1.default.install();
|
|
3628
3630
|
var path18 = __importStar(__require("path"));
|
|
3629
3631
|
var os3 = __importStar(__require("os"));
|
|
3630
|
-
var
|
|
3632
|
+
var fs14 = __importStar(__require("fs"));
|
|
3631
3633
|
var crypto_1 = __require("crypto");
|
|
3632
3634
|
var net_1 = __require("net");
|
|
3633
3635
|
var api_1 = require_api();
|
|
@@ -3768,7 +3770,7 @@ var require_main = __commonJS({
|
|
|
3768
3770
|
}
|
|
3769
3771
|
let randomLength = 32;
|
|
3770
3772
|
const fixedLength = "/lsp-.sock".length;
|
|
3771
|
-
const tmpDir =
|
|
3773
|
+
const tmpDir = fs14.realpathSync(XDG_RUNTIME_DIR ?? os3.tmpdir());
|
|
3772
3774
|
const limit = safeIpcPathLengths.get(process.platform);
|
|
3773
3775
|
if (limit !== void 0) {
|
|
3774
3776
|
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
|
|
@@ -3881,7 +3883,7 @@ var CASCADE_DIAGNOSTICS_TTL_MS = 24e4;
|
|
|
3881
3883
|
|
|
3882
3884
|
// dist/clients/lsp/index.js
|
|
3883
3885
|
import * as nodeFs2 from "node:fs";
|
|
3884
|
-
import
|
|
3886
|
+
import fs13 from "node:fs/promises";
|
|
3885
3887
|
import os2 from "node:os";
|
|
3886
3888
|
import path17 from "node:path";
|
|
3887
3889
|
import { pathToFileURL as pathToFileURL3, URL as URL3 } from "node:url";
|
|
@@ -4060,7 +4062,7 @@ async function importTargetsToAnnounce(cwd, importers, onScope) {
|
|
|
4060
4062
|
reason: `resolved the imports of ${CREATED_IMPORT_SCAN_MAX_FILES} of ${importers.length} files in one diagnostics call`
|
|
4061
4063
|
});
|
|
4062
4064
|
}
|
|
4063
|
-
const { extractForwardImports } = await import("./chunk-
|
|
4065
|
+
const { extractForwardImports } = await import("./chunk-3IWMNN2S.js");
|
|
4064
4066
|
const targets = /* @__PURE__ */ new Set();
|
|
4065
4067
|
const reexports = /* @__PURE__ */ new Map();
|
|
4066
4068
|
let resolved2 = 0;
|
|
@@ -5237,6 +5239,9 @@ function resetPendingAuxiliaryCoverage() {
|
|
|
5237
5239
|
// dist/clients/lsp-mutation.js
|
|
5238
5240
|
import * as path7 from "node:path";
|
|
5239
5241
|
|
|
5242
|
+
// dist/clients/fix-run-restore.js
|
|
5243
|
+
import * as fs3 from "node:fs";
|
|
5244
|
+
|
|
5240
5245
|
// dist/clients/file-mutation-queue.js
|
|
5241
5246
|
var loadHostSdk;
|
|
5242
5247
|
var hostQueue;
|
|
@@ -5283,6 +5288,121 @@ async function withHostFileMutationQueues(filePaths, fn) {
|
|
|
5283
5288
|
// dist/clients/fix-run-restore.js
|
|
5284
5289
|
var FIX_RUN_MAX_FILE_BYTES = 1024 * 1024;
|
|
5285
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
|
+
}
|
|
5286
5406
|
|
|
5287
5407
|
// dist/clients/observed-mutation.js
|
|
5288
5408
|
import * as path5 from "node:path";
|
|
@@ -5404,10 +5524,10 @@ function hashFile(filePath) {
|
|
|
5404
5524
|
|
|
5405
5525
|
// dist/clients/read-guard.js
|
|
5406
5526
|
import { constants as bufferConstants } from "node:buffer";
|
|
5407
|
-
import * as
|
|
5527
|
+
import * as fs5 from "node:fs";
|
|
5408
5528
|
|
|
5409
5529
|
// dist/clients/file-time.js
|
|
5410
|
-
import * as
|
|
5530
|
+
import * as fs4 from "node:fs";
|
|
5411
5531
|
import * as path4 from "node:path";
|
|
5412
5532
|
var globalState = {
|
|
5413
5533
|
reads: /* @__PURE__ */ new Map()
|
|
@@ -5500,7 +5620,7 @@ var FileTimeError = class extends Error {
|
|
|
5500
5620
|
};
|
|
5501
5621
|
function createStamp(filePath) {
|
|
5502
5622
|
try {
|
|
5503
|
-
const stats =
|
|
5623
|
+
const stats = fs4.statSync(filePath);
|
|
5504
5624
|
return {
|
|
5505
5625
|
readAt: /* @__PURE__ */ new Date(),
|
|
5506
5626
|
mtime: stats.mtime.getTime(),
|
|
@@ -5565,15 +5685,15 @@ function probeCtxActive(ctx) {
|
|
|
5565
5685
|
}
|
|
5566
5686
|
|
|
5567
5687
|
// dist/clients/session-scope.js
|
|
5568
|
-
var
|
|
5569
|
-
var
|
|
5688
|
+
var REGISTRY_FAMILY2 = "session-scope.registry";
|
|
5689
|
+
var REGISTRY_VERSION2 = 1;
|
|
5570
5690
|
function carriedCounter(cell, field) {
|
|
5571
5691
|
const value = cell?.[field];
|
|
5572
5692
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
5573
5693
|
}
|
|
5574
|
-
function
|
|
5694
|
+
function registry2() {
|
|
5575
5695
|
let seed = { nextTicket: 0, orderTurn: 0 };
|
|
5576
|
-
return getProcessSingleton(
|
|
5696
|
+
return getProcessSingleton(REGISTRY_FAMILY2, REGISTRY_VERSION2, () => seed, (previous) => {
|
|
5577
5697
|
seed = {
|
|
5578
5698
|
nextTicket: carriedCounter(previous, "nextTicket"),
|
|
5579
5699
|
orderTurn: carriedCounter(previous, "orderTurn")
|
|
@@ -5634,7 +5754,7 @@ var Scope = class {
|
|
|
5634
5754
|
}
|
|
5635
5755
|
};
|
|
5636
5756
|
function drawTicket() {
|
|
5637
|
-
const state4 =
|
|
5757
|
+
const state4 = registry2();
|
|
5638
5758
|
state4.nextTicket += 1;
|
|
5639
5759
|
return state4.nextTicket;
|
|
5640
5760
|
}
|
|
@@ -5651,7 +5771,7 @@ function moveBranch(scope) {
|
|
|
5651
5771
|
scope.moveBranch();
|
|
5652
5772
|
}
|
|
5653
5773
|
function nextOrderTurn() {
|
|
5654
|
-
const state4 =
|
|
5774
|
+
const state4 = registry2();
|
|
5655
5775
|
state4.orderTurn += 1;
|
|
5656
5776
|
return state4.orderTurn;
|
|
5657
5777
|
}
|
|
@@ -5676,6 +5796,19 @@ function logScopeTransition(scope, args) {
|
|
|
5676
5796
|
}
|
|
5677
5797
|
});
|
|
5678
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
|
+
}
|
|
5679
5812
|
var SESSION_INDEX_FAMILY = "session-scope.session-index";
|
|
5680
5813
|
var SESSION_INDEX_VERSION = 1;
|
|
5681
5814
|
function sessionIndex() {
|
|
@@ -5735,7 +5868,7 @@ var READ_BINDING_MAX_BYTES = 4 * 1024 * 1024;
|
|
|
5735
5868
|
var ABSENT_SIZE = -1;
|
|
5736
5869
|
function observeAuthoredBytes(filePath, knownHash, authoredRanges) {
|
|
5737
5870
|
try {
|
|
5738
|
-
const stat3 =
|
|
5871
|
+
const stat3 = fs5.statSync(filePath);
|
|
5739
5872
|
const hash = knownHash !== void 0 ? knownHash : stat3.size <= READ_BINDING_MAX_BYTES ? hashFileBytes(filePath) : void 0;
|
|
5740
5873
|
return {
|
|
5741
5874
|
size: stat3.size,
|
|
@@ -5744,7 +5877,7 @@ function observeAuthoredBytes(filePath, knownHash, authoredRanges) {
|
|
|
5744
5877
|
...hash !== void 0 && { hash },
|
|
5745
5878
|
...authoredRanges !== void 0 && { authoredRanges },
|
|
5746
5879
|
...authoredRanges !== void 0 && {
|
|
5747
|
-
authoredLineCount: splitLines(
|
|
5880
|
+
authoredLineCount: splitLines(fs5.readFileSync(filePath, "utf-8")).length
|
|
5748
5881
|
}
|
|
5749
5882
|
};
|
|
5750
5883
|
} catch {
|
|
@@ -5776,7 +5909,7 @@ function isValidAuthoredRanges(value) {
|
|
|
5776
5909
|
function authoredBytesIntact(filePath, authored) {
|
|
5777
5910
|
let stat3;
|
|
5778
5911
|
try {
|
|
5779
|
-
stat3 =
|
|
5912
|
+
stat3 = fs5.statSync(filePath);
|
|
5780
5913
|
} catch {
|
|
5781
5914
|
return authored.size === ABSENT_SIZE;
|
|
5782
5915
|
}
|
|
@@ -5834,7 +5967,7 @@ var READ_GUARD_MAX_CHECKED_PATHS_PER_CALL = 128;
|
|
|
5834
5967
|
var READ_GUARD_IDLE_EVICT_MS_DEFAULT = 30 * 6e4;
|
|
5835
5968
|
function _currentContentMatchesBindingForTests(filePath, binding) {
|
|
5836
5969
|
try {
|
|
5837
|
-
const content =
|
|
5970
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
5838
5971
|
const boundContent = binding.fullFile ? content : splitLines(content).slice(binding.offset - 1, binding.offset - 1 + binding.limit).join("\n");
|
|
5839
5972
|
return hashContentBytes(Buffer.from(boundContent, "utf8")) === binding.hash;
|
|
5840
5973
|
} catch {
|
|
@@ -5849,10 +5982,10 @@ function splitLines(text) {
|
|
|
5849
5982
|
return text.split(/\r?\n/);
|
|
5850
5983
|
}
|
|
5851
5984
|
function lineContentHash(line) {
|
|
5852
|
-
const
|
|
5985
|
+
const normalized2 = line.replace(/\s+/g, "");
|
|
5853
5986
|
let hash = 2166136261;
|
|
5854
|
-
for (let i = 0; i <
|
|
5855
|
-
hash = Math.imul(hash ^
|
|
5987
|
+
for (let i = 0; i < normalized2.length; i++) {
|
|
5988
|
+
hash = Math.imul(hash ^ normalized2.charCodeAt(i), 16777619);
|
|
5856
5989
|
}
|
|
5857
5990
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
5858
5991
|
}
|
|
@@ -5902,8 +6035,8 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5902
6035
|
const lines = /* @__PURE__ */ new Map();
|
|
5903
6036
|
let fd;
|
|
5904
6037
|
try {
|
|
5905
|
-
fd =
|
|
5906
|
-
const size =
|
|
6038
|
+
fd = fs5.openSync(filePath, "r");
|
|
6039
|
+
const size = fs5.fstatSync(fd).size;
|
|
5907
6040
|
if (size > SCAN_MAX_BYTES)
|
|
5908
6041
|
return overByteGate(filePath, size);
|
|
5909
6042
|
const byteBudget = size > 0 ? size : SCAN_MAX_BYTES + 1;
|
|
@@ -5914,7 +6047,7 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5914
6047
|
let parts = [];
|
|
5915
6048
|
const keepLine = () => lines.set(lineNo, Buffer.concat(parts).toString("utf8"));
|
|
5916
6049
|
while (consumed < byteBudget && !done(lineNo)) {
|
|
5917
|
-
const n =
|
|
6050
|
+
const n = fs5.readSync(fd, chunk, 0, Math.min(chunk.length, byteBudget - consumed), null);
|
|
5918
6051
|
if (n === 0)
|
|
5919
6052
|
break;
|
|
5920
6053
|
consumed += n;
|
|
@@ -5970,7 +6103,7 @@ function scanFileLines(filePath, ranges, opts) {
|
|
|
5970
6103
|
return void 0;
|
|
5971
6104
|
} finally {
|
|
5972
6105
|
if (fd !== void 0)
|
|
5973
|
-
|
|
6106
|
+
fs5.closeSync(fd);
|
|
5974
6107
|
}
|
|
5975
6108
|
}
|
|
5976
6109
|
function overByteGate(filePath, bytes) {
|
|
@@ -6002,7 +6135,7 @@ function currentLinesMatchReadSnapshot(filePath, read, [startLine, endLine]) {
|
|
|
6002
6135
|
}
|
|
6003
6136
|
let lines;
|
|
6004
6137
|
try {
|
|
6005
|
-
lines = splitLines(
|
|
6138
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
6006
6139
|
} catch {
|
|
6007
6140
|
return {
|
|
6008
6141
|
checked: true,
|
|
@@ -6770,7 +6903,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
6770
6903
|
*/
|
|
6771
6904
|
isNewFile(filePath) {
|
|
6772
6905
|
try {
|
|
6773
|
-
return !
|
|
6906
|
+
return !fs5.existsSync(filePath);
|
|
6774
6907
|
} catch {
|
|
6775
6908
|
return true;
|
|
6776
6909
|
}
|
|
@@ -7145,7 +7278,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7145
7278
|
if (!Array.isArray(records) || records.length === 0)
|
|
7146
7279
|
continue;
|
|
7147
7280
|
const filePath = this.key(rawPath);
|
|
7148
|
-
const exists =
|
|
7281
|
+
const exists = fs5.existsSync(filePath);
|
|
7149
7282
|
for (const read of records) {
|
|
7150
7283
|
const id = read?.toolCallId;
|
|
7151
7284
|
if (!exists || typeof id !== "string" || !onBranch.has(id)) {
|
|
@@ -7241,7 +7374,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7241
7374
|
let evidence;
|
|
7242
7375
|
try {
|
|
7243
7376
|
evidence = writtenContent !== void 0 ? deliveredLineEvidence(writtenContent, 1) : {
|
|
7244
|
-
lineCount: splitLines(
|
|
7377
|
+
lineCount: splitLines(fs5.readFileSync(filePath, "utf-8")).length,
|
|
7245
7378
|
lineHashes: void 0
|
|
7246
7379
|
};
|
|
7247
7380
|
} catch {
|
|
@@ -7267,7 +7400,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7267
7400
|
canIgnoreStalenessByHashes(filePath, reads, touchedLines, editRanges) {
|
|
7268
7401
|
let lines;
|
|
7269
7402
|
try {
|
|
7270
|
-
lines = splitLines(
|
|
7403
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
7271
7404
|
} catch {
|
|
7272
7405
|
return false;
|
|
7273
7406
|
}
|
|
@@ -7407,7 +7540,7 @@ Re-read the relevant section, then retry the edit using the current line range/c
|
|
|
7407
7540
|
}
|
|
7408
7541
|
let lines;
|
|
7409
7542
|
try {
|
|
7410
|
-
lines = splitLines(
|
|
7543
|
+
lines = splitLines(fs5.readFileSync(filePath, "utf-8"));
|
|
7411
7544
|
} catch {
|
|
7412
7545
|
return void 0;
|
|
7413
7546
|
}
|
|
@@ -7616,6 +7749,8 @@ var ANSI_C_ESCAPES = new Map(Object.entries({
|
|
|
7616
7749
|
"?": 63
|
|
7617
7750
|
}).map(([escape, value]) => [escape.charCodeAt(0), value]));
|
|
7618
7751
|
var MOVE_CLUSTER_LETTERS = new Set("abdfilnprRsvx");
|
|
7752
|
+
var RSYNC_VALUE_LETTERS = new Set("eBTfM@");
|
|
7753
|
+
var TAR_VALUE_LETTERS = new Set("bCfFgHIKLNTVX");
|
|
7619
7754
|
|
|
7620
7755
|
// dist/clients/opaque-mutation-scan.js
|
|
7621
7756
|
var OPAQUE_HASH_BUDGET_BYTES = 8 * 1024 * 1024;
|
|
@@ -7876,10 +8011,10 @@ function createBusPublisher(liveEmitter5, options) {
|
|
|
7876
8011
|
return {
|
|
7877
8012
|
publish(call) {
|
|
7878
8013
|
const { event } = call;
|
|
7879
|
-
let
|
|
8014
|
+
let normalized2;
|
|
7880
8015
|
const cwd = () => {
|
|
7881
|
-
|
|
7882
|
-
return
|
|
8016
|
+
normalized2 ??= normalizeFilePath(call.cwd);
|
|
8017
|
+
return normalized2;
|
|
7883
8018
|
};
|
|
7884
8019
|
const extra = call.extra ?? {};
|
|
7885
8020
|
if (call.enabled === false) {
|
|
@@ -7967,6 +8102,8 @@ function isBusPublishEnabled() {
|
|
|
7967
8102
|
}
|
|
7968
8103
|
|
|
7969
8104
|
// dist/clients/format-events-publish.js
|
|
8105
|
+
var BUS_FORMAT_QUEUED_EVENT = "pilens:format:queued";
|
|
8106
|
+
var BUS_FORMAT_QUEUED_VERSION = 1;
|
|
7970
8107
|
var liveEmitter2 = createLiveBusEmitter();
|
|
7971
8108
|
var queuedPublisher = createBusPublisher(liveEmitter2, {
|
|
7972
8109
|
module: "format-events-publish"
|
|
@@ -7980,9 +8117,285 @@ var donePublisher = createBusPublisher(liveEmitter2, {
|
|
|
7980
8117
|
var autofixStartPublisher = createBusPublisher(liveEmitter2, {
|
|
7981
8118
|
module: "format-events-publish"
|
|
7982
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
|
+
}
|
|
7983
8140
|
|
|
7984
8141
|
// dist/clients/mutation-bridge.js
|
|
7985
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
|
+
}
|
|
7986
8399
|
function getMutationBridge() {
|
|
7987
8400
|
const candidate = getProcessBridge(MUTATION_BRIDGE_KEY, 1);
|
|
7988
8401
|
return typeof candidate?.recordMutation === "function" ? candidate : void 0;
|
|
@@ -8087,129 +8500,92 @@ function uniqueDetails(files2, fileDetails) {
|
|
|
8087
8500
|
importsChanged: true
|
|
8088
8501
|
});
|
|
8089
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
|
+
}
|
|
8090
8567
|
function bookkeepLspMutation(context, files2, fileDetails) {
|
|
8091
8568
|
const details = uniqueDetails(files2, fileDetails);
|
|
8092
|
-
const
|
|
8569
|
+
const runtime = context.runtime;
|
|
8570
|
+
const cacheManager = context.cacheManager;
|
|
8571
|
+
const deps = runtime && cacheManager ? directBookkeepingDeps(context, runtime, cacheManager) : void 0;
|
|
8093
8572
|
for (const detail of details) {
|
|
8094
8573
|
const filePath = path7.resolve(detail.filePath);
|
|
8095
|
-
const sessionLive = !context.session || context.session.guardedWrite(filePath, () => true) !== void 0;
|
|
8096
8574
|
if (context.isRecordable && !context.isRecordable(filePath)) {
|
|
8097
8575
|
context.dbg?.(`lsp mutation not recordable, skipping ${filePath}`);
|
|
8098
8576
|
continue;
|
|
8099
8577
|
}
|
|
8100
|
-
let
|
|
8101
|
-
if (
|
|
8102
|
-
|
|
8103
|
-
context.
|
|
8104
|
-
stampFileTime: false,
|
|
8105
|
-
advanceAuthorship: true,
|
|
8106
|
-
...detail.authorshipUnknown !== true && detail.ranges !== void 0 && {
|
|
8107
|
-
authorship: "partial",
|
|
8108
|
-
authoredRanges: detail.ranges.map(({ start, end }) => [start, end])
|
|
8109
|
-
},
|
|
8110
|
-
...detail.authorshipUnknown === true && { authorship: "unknown" },
|
|
8111
|
-
...context.toolCallId !== void 0 && {
|
|
8112
|
-
toolCallId: context.toolCallId
|
|
8113
|
-
}
|
|
8114
|
-
});
|
|
8115
|
-
} catch (err) {
|
|
8116
|
-
context.dbg?.(`lsp mutation read-guard stamp failed for ${filePath}: ${err}`);
|
|
8117
|
-
}
|
|
8118
|
-
}
|
|
8119
|
-
if (useBridgeFallback) {
|
|
8120
|
-
const bridge = getMutationBridge();
|
|
8121
|
-
if (!bridge) {
|
|
8122
|
-
accepted = false;
|
|
8123
|
-
recordDegradationOnce({
|
|
8124
|
-
kind: "lsp-mutation-bridge-unmounted",
|
|
8125
|
-
subject: "lsp-mutation:no-bridge",
|
|
8126
|
-
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)."
|
|
8127
|
-
});
|
|
8128
|
-
if (!noBridgeDbgLogged) {
|
|
8129
|
-
noBridgeDbgLogged = true;
|
|
8130
|
-
context.dbg?.(`lsp mutation bridge unavailable, dropping bookkeeping for ${filePath}`);
|
|
8131
|
-
}
|
|
8132
|
-
} else {
|
|
8133
|
-
try {
|
|
8134
|
-
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;
|
|
8135
|
-
const recorded = bridge.recordMutation({
|
|
8136
|
-
filePath,
|
|
8137
|
-
kind: "edit",
|
|
8138
|
-
...detail.range !== void 0 && {
|
|
8139
|
-
touchedLines: [detail.range.start, detail.range.end]
|
|
8140
|
-
},
|
|
8141
|
-
...detail.authorshipUnknown === true && {
|
|
8142
|
-
authorshipUnknown: true
|
|
8143
|
-
},
|
|
8144
|
-
...editRanges !== void 0 ? { editRanges } : {},
|
|
8145
|
-
...context.sessionId !== void 0 && {
|
|
8146
|
-
sessionId: context.sessionId
|
|
8147
|
-
},
|
|
8148
|
-
consumer: context.tool,
|
|
8149
|
-
provenance: "observed",
|
|
8150
|
-
// Real value threaded through, not the bridge's own
|
|
8151
|
-
// historical `false` default (#2450 review round 2, F1) —
|
|
8152
|
-
// the tsserver organize-imports/add-import case is exactly
|
|
8153
|
-
// the import-changing one.
|
|
8154
|
-
importsChanged: detail.importsChanged ?? true,
|
|
8155
|
-
// Equivalence with the direct branch below, which never
|
|
8156
|
-
// enqueues a deferred autofix/format pass for an LSP-applied
|
|
8157
|
-
// edit (#2450 review round 2, F3).
|
|
8158
|
-
deferAutofix: false,
|
|
8159
|
-
...context.session && { lineage: context.session },
|
|
8160
|
-
// #4187 R4-1: the same license the direct branch threads, so
|
|
8161
|
-
// the two branches stay equivalent for the same write.
|
|
8162
|
-
...context.toolCallId !== void 0 && {
|
|
8163
|
-
toolCallId: context.toolCallId
|
|
8164
|
-
}
|
|
8165
|
-
});
|
|
8166
|
-
if (!recorded) {
|
|
8167
|
-
accepted = false;
|
|
8168
|
-
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)`);
|
|
8169
|
-
}
|
|
8170
|
-
} catch (err) {
|
|
8171
|
-
accepted = false;
|
|
8172
|
-
context.dbg?.(`lsp mutation bridge fallback failed for ${filePath}: ${err}`);
|
|
8173
|
-
}
|
|
8174
|
-
}
|
|
8175
|
-
} else {
|
|
8176
|
-
const runtime = context.runtime;
|
|
8177
|
-
runtime?.recordProjectMutation?.({
|
|
8178
|
-
filePath,
|
|
8179
|
-
source: context.source,
|
|
8180
|
-
cwd: context.cwd,
|
|
8181
|
-
changedRange: detail.range,
|
|
8182
|
-
// #4943: the issuing activation's change-log row.
|
|
8183
|
-
sessionId: context.sessionId,
|
|
8184
|
-
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
|
|
8185
8582
|
});
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
context.cwd,
|
|
8193
|
-
context.sessionId ?? runtime?.telemetrySessionId,
|
|
8194
|
-
void 0,
|
|
8195
|
-
// #2504 review round 2 (F1). #2504 added a containment
|
|
8196
|
-
// filter to `addModifiedRange` and gave it `cwd` as the
|
|
8197
|
-
// project root. On THIS path `cwd` is the calling
|
|
8198
|
-
// directory, which `tools/lsp-navigation.ts` scopes to a
|
|
8199
|
-
// sub-package while the LSP client's root spans the whole
|
|
8200
|
-
// monorepo — so a server-initiated edit on a sibling
|
|
8201
|
-
// package (#2450) and every edit whose context carries a
|
|
8202
|
-
// separate bookkeeping cwd (#2479) were silently dropped
|
|
8203
|
-
// from the worklist. Same root the `isRecordable` gate a
|
|
8204
|
-
// few frames up already uses: `runtime.projectRoot`,
|
|
8205
|
-
// falling back to `cwd` when no runtime is threaded.
|
|
8206
|
-
runtime?.projectRoot ?? context.cwd
|
|
8207
|
-
);
|
|
8208
|
-
} catch (err) {
|
|
8209
|
-
context.dbg?.(`lsp mutation modified-range tracking failed for ${filePath}: ${err}`);
|
|
8210
|
-
}
|
|
8211
|
-
}
|
|
8212
|
-
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);
|
|
8213
8589
|
}
|
|
8214
8590
|
if (sessionLive && context.recordAutofix && context.source === "autofix") {
|
|
8215
8591
|
const key = normalizeMapKey(filePath);
|
|
@@ -8220,13 +8596,53 @@ function bookkeepLspMutation(context, files2, fileDetails) {
|
|
|
8220
8596
|
context.recordAutofix(filePath);
|
|
8221
8597
|
}
|
|
8222
8598
|
}
|
|
8223
|
-
if (accepted && context.acceptedFiles && !context.acceptedFiles.includes(filePath))
|
|
8224
|
-
context.acceptedFiles.push(filePath);
|
|
8225
8599
|
}
|
|
8226
8600
|
if (context.publishFilesTouched && files2.length > 0) {
|
|
8227
8601
|
context.publishFilesTouched(files2);
|
|
8228
8602
|
}
|
|
8229
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
|
+
}
|
|
8230
8646
|
function telemetryFor(context, options) {
|
|
8231
8647
|
const combined = combineResults(allResults(options));
|
|
8232
8648
|
const requestedTotal = options.requestedTotal ?? combined.requestedTotal;
|
|
@@ -8323,7 +8739,7 @@ function recordLspMutationOutcome(context, status) {
|
|
|
8323
8739
|
|
|
8324
8740
|
// dist/clients/lsp/diagnostic-binding.js
|
|
8325
8741
|
import { createHash as createHash4 } from "node:crypto";
|
|
8326
|
-
import * as
|
|
8742
|
+
import * as fs6 from "node:fs";
|
|
8327
8743
|
function resolveTouchVerdict(input) {
|
|
8328
8744
|
const unavailableIds = [...new Set(input.unavailablePrimaryServerIds ?? [])];
|
|
8329
8745
|
if (unavailableIds.length > 0) {
|
|
@@ -8432,7 +8848,7 @@ function createDiskBindingCache() {
|
|
|
8432
8848
|
return "unknown";
|
|
8433
8849
|
let stat3;
|
|
8434
8850
|
try {
|
|
8435
|
-
stat3 =
|
|
8851
|
+
stat3 = fs6.statSync(filePath);
|
|
8436
8852
|
} catch {
|
|
8437
8853
|
return "unknown";
|
|
8438
8854
|
}
|
|
@@ -8440,7 +8856,7 @@ function createDiskBindingCache() {
|
|
|
8440
8856
|
if (!cached || cached.mtimeMs !== stat3.mtimeMs || cached.size !== stat3.size) {
|
|
8441
8857
|
let diskHash;
|
|
8442
8858
|
try {
|
|
8443
|
-
diskHash = hashDiagnosticContent(
|
|
8859
|
+
diskHash = hashDiagnosticContent(fs6.readFileSync(filePath, "utf-8"));
|
|
8444
8860
|
} catch {
|
|
8445
8861
|
return "unknown";
|
|
8446
8862
|
}
|
|
@@ -8467,6 +8883,10 @@ var CONFIG_FILE_SERVERS = /* @__PURE__ */ new Map([
|
|
|
8467
8883
|
var SERVER_CONFIG_FILE_NAMES = [
|
|
8468
8884
|
...CONFIG_FILE_SERVERS.keys()
|
|
8469
8885
|
];
|
|
8886
|
+
var BELOW_ROOT_CONFIG_FILE_NAMES = /* @__PURE__ */ new Set([
|
|
8887
|
+
"Cargo.toml",
|
|
8888
|
+
"go.mod"
|
|
8889
|
+
]);
|
|
8470
8890
|
function serverIdsForConfigFile(filePath) {
|
|
8471
8891
|
return CONFIG_FILE_SERVERS.get(basename(filePath));
|
|
8472
8892
|
}
|
|
@@ -8536,12 +8956,12 @@ async function runPerServerGroups(groups, concurrency, processGroup, signal) {
|
|
|
8536
8956
|
import path13 from "node:path";
|
|
8537
8957
|
|
|
8538
8958
|
// dist/clients/widget-state.js
|
|
8539
|
-
import { readFileSync as
|
|
8959
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
8540
8960
|
import { stat } from "node:fs/promises";
|
|
8541
8961
|
import { pathToFileURL } from "node:url";
|
|
8542
8962
|
|
|
8543
8963
|
// dist/clients/diagnostic-line-freshness.js
|
|
8544
|
-
import * as
|
|
8964
|
+
import * as fs7 from "node:fs";
|
|
8545
8965
|
|
|
8546
8966
|
// dist/clients/stale-marker.js
|
|
8547
8967
|
var STALE_LINE_MARKER = "[stale \u2014 re-run to confirm]";
|
|
@@ -8558,13 +8978,13 @@ function rememberInSharedCache(cache, filePath, entry) {
|
|
|
8558
8978
|
cache.set(filePath, entry);
|
|
8559
8979
|
}
|
|
8560
8980
|
function countNewlinesChunked(filePath, sizeBytes) {
|
|
8561
|
-
const fd =
|
|
8981
|
+
const fd = fs7.openSync(filePath, "r");
|
|
8562
8982
|
try {
|
|
8563
8983
|
const buffer = Buffer.allocUnsafe(Math.min(NEWLINE_SCAN_CHUNK_BYTES, sizeBytes) || 1);
|
|
8564
8984
|
let newlineCount = 0;
|
|
8565
8985
|
let position = 0;
|
|
8566
8986
|
while (position < sizeBytes) {
|
|
8567
|
-
const bytesRead =
|
|
8987
|
+
const bytesRead = fs7.readSync(fd, buffer, 0, buffer.length, position);
|
|
8568
8988
|
if (bytesRead <= 0)
|
|
8569
8989
|
break;
|
|
8570
8990
|
for (let i = 0; i < bytesRead; i++) {
|
|
@@ -8575,13 +8995,13 @@ function countNewlinesChunked(filePath, sizeBytes) {
|
|
|
8575
8995
|
}
|
|
8576
8996
|
return newlineCount;
|
|
8577
8997
|
} finally {
|
|
8578
|
-
|
|
8998
|
+
fs7.closeSync(fd);
|
|
8579
8999
|
}
|
|
8580
9000
|
}
|
|
8581
9001
|
function getCachedLineCount(filePath, cache = sharedLineCountCache) {
|
|
8582
9002
|
let stat3;
|
|
8583
9003
|
try {
|
|
8584
|
-
stat3 =
|
|
9004
|
+
stat3 = fs7.statSync(filePath);
|
|
8585
9005
|
} catch {
|
|
8586
9006
|
return void 0;
|
|
8587
9007
|
}
|
|
@@ -8636,7 +9056,7 @@ function demotePastEofDiagnostics(args) {
|
|
|
8636
9056
|
}
|
|
8637
9057
|
let sizeBytes;
|
|
8638
9058
|
try {
|
|
8639
|
-
sizeBytes =
|
|
9059
|
+
sizeBytes = fs7.statSync(args.filePath).size;
|
|
8640
9060
|
} catch {
|
|
8641
9061
|
sizeBytes = 0;
|
|
8642
9062
|
}
|
|
@@ -8666,8 +9086,8 @@ function resyncDocumentOnPastEof(filePath) {
|
|
|
8666
9086
|
void (async () => {
|
|
8667
9087
|
try {
|
|
8668
9088
|
const [{ getOwnedLspService: getOwnedLspService2 }, content] = await Promise.all([
|
|
8669
|
-
import("./chunk-
|
|
8670
|
-
|
|
9089
|
+
import("./chunk-EBXCYEII.js"),
|
|
9090
|
+
fs7.promises.readFile(filePath, "utf-8")
|
|
8671
9091
|
]);
|
|
8672
9092
|
await getOwnedLspService2().openFile(filePath, content, { preserveDiagnostics: false });
|
|
8673
9093
|
} catch {
|
|
@@ -8764,7 +9184,7 @@ function inlineBlockerPlaces(blockers, filePath) {
|
|
|
8764
9184
|
}
|
|
8765
9185
|
|
|
8766
9186
|
// dist/clients/diagnostic-dispositions.js
|
|
8767
|
-
import * as
|
|
9187
|
+
import * as fs8 from "node:fs";
|
|
8768
9188
|
import * as path9 from "node:path";
|
|
8769
9189
|
|
|
8770
9190
|
// dist/clients/disposition-logger.js
|
|
@@ -8854,7 +9274,7 @@ function statePath(cwd) {
|
|
|
8854
9274
|
return path9.join(getProjectDataDir(cwd), "cache", "diagnostic-dispositions.json");
|
|
8855
9275
|
}
|
|
8856
9276
|
var stateCache = null;
|
|
8857
|
-
var dispositionStatSync =
|
|
9277
|
+
var dispositionStatSync = fs8.statSync;
|
|
8858
9278
|
function hasAnyDispositionMarks(cwd) {
|
|
8859
9279
|
return Boolean(readState(cwd).dispositions) || hasDeferredThisSession(cwd);
|
|
8860
9280
|
}
|
|
@@ -8868,7 +9288,7 @@ function hasStrictDispositionMarks(cwd) {
|
|
|
8868
9288
|
}
|
|
8869
9289
|
return false;
|
|
8870
9290
|
}
|
|
8871
|
-
var multiFileReadFileSync =
|
|
9291
|
+
var multiFileReadFileSync = fs8.readFileSync;
|
|
8872
9292
|
function readState(cwd) {
|
|
8873
9293
|
const p = statePath(cwd);
|
|
8874
9294
|
let stat3;
|
|
@@ -8893,7 +9313,7 @@ function readState(cwd) {
|
|
|
8893
9313
|
}
|
|
8894
9314
|
let state4;
|
|
8895
9315
|
try {
|
|
8896
|
-
const parsed = JSON.parse(
|
|
9316
|
+
const parsed = JSON.parse(fs8.readFileSync(p, "utf-8"));
|
|
8897
9317
|
state4 = parsed && typeof parsed === "object" ? parsed : {};
|
|
8898
9318
|
} catch {
|
|
8899
9319
|
state4 = {};
|
|
@@ -9024,7 +9444,7 @@ function cachedAnchorMarks(input) {
|
|
|
9024
9444
|
return { marks: "weak-only" };
|
|
9025
9445
|
let stat3;
|
|
9026
9446
|
try {
|
|
9027
|
-
stat3 =
|
|
9447
|
+
stat3 = fs8.statSync(anchor);
|
|
9028
9448
|
} catch {
|
|
9029
9449
|
return cited ? { marks: "refused" } : { marks: "weak-only" };
|
|
9030
9450
|
}
|
|
@@ -9071,11 +9491,11 @@ function filterPerFileGroup(diagnostics, cwd, filePathOf, applyGroup) {
|
|
|
9071
9491
|
}
|
|
9072
9492
|
|
|
9073
9493
|
// dist/clients/session-state-store.js
|
|
9074
|
-
import { promises as
|
|
9494
|
+
import { promises as fs9 } from "node:fs";
|
|
9075
9495
|
async function dropStaleFiles(widget, savedAt) {
|
|
9076
9496
|
const checked = await Promise.all(widget.files.map(async (file) => {
|
|
9077
9497
|
try {
|
|
9078
|
-
const st = await
|
|
9498
|
+
const st = await fs9.stat(file.filePath);
|
|
9079
9499
|
return freshnessFromMtime({
|
|
9080
9500
|
mtimeMs: st.mtimeMs,
|
|
9081
9501
|
referenceMs: savedAt,
|
|
@@ -9186,6 +9606,7 @@ function isBlocking(d) {
|
|
|
9186
9606
|
var files = /* @__PURE__ */ new Map();
|
|
9187
9607
|
var sessionLanguages = [];
|
|
9188
9608
|
var requestRenderFn = null;
|
|
9609
|
+
var widgetChangeFn = null;
|
|
9189
9610
|
var diagnosticsWriteGuard = new WriteOrderingGuard();
|
|
9190
9611
|
var runnerWriteGuard = new WriteOrderingGuard();
|
|
9191
9612
|
var MAX_STORED_DIAGNOSTICS_PER_FILE = 12;
|
|
@@ -9224,7 +9645,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9224
9645
|
let source = content ?? target.content;
|
|
9225
9646
|
if (source === void 0) {
|
|
9226
9647
|
try {
|
|
9227
|
-
source =
|
|
9648
|
+
source = readFileSync7(target.filePath, "utf8");
|
|
9228
9649
|
} catch {
|
|
9229
9650
|
recordDegradationOnce({
|
|
9230
9651
|
kind: "widget-disposition-reconcile-fallback",
|
|
@@ -9276,7 +9697,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9276
9697
|
active.add(d);
|
|
9277
9698
|
}
|
|
9278
9699
|
}
|
|
9279
|
-
const
|
|
9700
|
+
const normalized2 = current.flatMap((diagnostic) => {
|
|
9280
9701
|
const anchor = diagnostic.citedFile ?? target.filePath;
|
|
9281
9702
|
const decision = anchor === target.filePath ? void 0 : citedMarks.get(anchor);
|
|
9282
9703
|
const refused = decision?.marks === "refused";
|
|
@@ -9313,7 +9734,7 @@ function reconcileWidgetDisposition(cwd, target, _disposition, content) {
|
|
|
9313
9734
|
if (!diagnosticsWriteGuard.shouldWrite(fileMapKey(target.filePath), writeIndex))
|
|
9314
9735
|
return;
|
|
9315
9736
|
const { hasFinalDiagnosticsSnapshot, touchedAt } = rec;
|
|
9316
|
-
commitDiagnostics(rec, target.filePath,
|
|
9737
|
+
commitDiagnostics(rec, target.filePath, normalized2, Date.now(), fileMapKey(target.filePath), false);
|
|
9317
9738
|
if (!hasFinalDiagnosticsSnapshot) {
|
|
9318
9739
|
rec.hasFinalDiagnosticsSnapshot = false;
|
|
9319
9740
|
rec.touchedAt = touchedAt;
|
|
@@ -9337,6 +9758,7 @@ function clearWidgetState() {
|
|
|
9337
9758
|
diagnosticsWriteGuard.clear();
|
|
9338
9759
|
runnerWriteGuard.clear();
|
|
9339
9760
|
nextInactivePruneSize = MAX_INACTIVE_FILE_RECORDS + 1;
|
|
9761
|
+
requestRender();
|
|
9340
9762
|
}
|
|
9341
9763
|
var WIDGET_STATE_VERSION = 3;
|
|
9342
9764
|
function exportWidgetState() {
|
|
@@ -9399,7 +9821,7 @@ function importWidgetState(state4) {
|
|
|
9399
9821
|
}
|
|
9400
9822
|
pruneInactiveFileRecords();
|
|
9401
9823
|
sessionLanguages = state4.sessionLanguages ?? [];
|
|
9402
|
-
|
|
9824
|
+
requestRender();
|
|
9403
9825
|
return true;
|
|
9404
9826
|
}
|
|
9405
9827
|
var widgetStore = defineSessionStore({
|
|
@@ -9478,7 +9900,6 @@ function recordDiagnostics(filePath, diagnostics, writeIndex, observedAt, unchec
|
|
|
9478
9900
|
runnerWriteGuard.shouldWrite(key, writeIndex);
|
|
9479
9901
|
const observedTs = observedAt ?? Date.now();
|
|
9480
9902
|
const rec = getOrCreate(filePath, key);
|
|
9481
|
-
commitDiagnostics(rec, filePath, normalizeDiagnostics(filePath, diagnostics, observedTs), observedTs, key);
|
|
9482
9903
|
if (unchecked === void 0) {
|
|
9483
9904
|
delete rec.uncheckedReason;
|
|
9484
9905
|
delete rec.uncheckedInapplicable;
|
|
@@ -9489,6 +9910,7 @@ function recordDiagnostics(filePath, diagnostics, writeIndex, observedAt, unchec
|
|
|
9489
9910
|
else
|
|
9490
9911
|
delete rec.uncheckedInapplicable;
|
|
9491
9912
|
}
|
|
9913
|
+
commitDiagnostics(rec, filePath, normalizeDiagnostics(filePath, diagnostics, observedTs), observedTs, key);
|
|
9492
9914
|
return true;
|
|
9493
9915
|
}
|
|
9494
9916
|
function normalizeDiagnostics(filePath, diagnostics, observedTs) {
|
|
@@ -9511,7 +9933,7 @@ function normalizeDiagnostics(filePath, diagnostics, observedTs) {
|
|
|
9511
9933
|
var retentionIdentity = findingIdentity;
|
|
9512
9934
|
function readContentOrUndefined(filePath) {
|
|
9513
9935
|
try {
|
|
9514
|
-
return
|
|
9936
|
+
return readFileSync7(filePath, "utf8");
|
|
9515
9937
|
} catch {
|
|
9516
9938
|
recordDegradationOnce({
|
|
9517
9939
|
kind: "widget-mark-anchor-unreadable",
|
|
@@ -9565,12 +9987,12 @@ function retainSuppressedRows(previous, incoming, filePath) {
|
|
|
9565
9987
|
];
|
|
9566
9988
|
}
|
|
9567
9989
|
function commitDiagnostics(rec, filePath, incoming, observedAt, key = fileMapKey(filePath), retainSuppressed = true) {
|
|
9568
|
-
const
|
|
9569
|
-
rec.diagnosticCounts = countDiagnostics(
|
|
9570
|
-
rec.diagnostics = capStoredDiagnostics(
|
|
9571
|
-
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;
|
|
9572
9994
|
rec.hasFinalDiagnosticsSnapshot = true;
|
|
9573
|
-
rec.touchedAt = freshestObservation(
|
|
9995
|
+
rec.touchedAt = freshestObservation(normalized2, observedAt ?? Date.now());
|
|
9574
9996
|
files.set(key, rec);
|
|
9575
9997
|
requestRender();
|
|
9576
9998
|
}
|
|
@@ -9706,7 +10128,7 @@ async function reconcileStaleWidgetFiles(onStaleFile) {
|
|
|
9706
10128
|
rec.touchedAt = Math.max(Date.now(), v.mtimeMs);
|
|
9707
10129
|
}
|
|
9708
10130
|
if (changed > 0)
|
|
9709
|
-
|
|
10131
|
+
requestRender();
|
|
9710
10132
|
return changed;
|
|
9711
10133
|
}
|
|
9712
10134
|
async function reconcileStaleWidgetDependencyBlockers(cwd, turnIndex) {
|
|
@@ -9747,7 +10169,7 @@ async function reconcileStaleWidgetDependencyBlockers(cwd, turnIndex) {
|
|
|
9747
10169
|
}
|
|
9748
10170
|
}
|
|
9749
10171
|
if (demoted > 0)
|
|
9750
|
-
|
|
10172
|
+
requestRender();
|
|
9751
10173
|
return { demoted, truncatedImports };
|
|
9752
10174
|
}
|
|
9753
10175
|
function getWidgetBlockingFilesForSweep() {
|
|
@@ -9781,7 +10203,7 @@ function markWidgetFileBlockersStale(filePath, reason) {
|
|
|
9781
10203
|
if (changed) {
|
|
9782
10204
|
rec.diagnosticCounts = countDiagnostics(rec.allDiagnostics);
|
|
9783
10205
|
rec.diagnostics = capStoredDiagnostics(rec.allDiagnostics);
|
|
9784
|
-
|
|
10206
|
+
requestRender();
|
|
9785
10207
|
}
|
|
9786
10208
|
return changed;
|
|
9787
10209
|
}
|
|
@@ -9820,7 +10242,7 @@ function retireWidgetDependencyDriftBlockers(filePath) {
|
|
|
9820
10242
|
if (!changed)
|
|
9821
10243
|
return false;
|
|
9822
10244
|
renderedDependencyDriftFiles.delete(rec.filePath);
|
|
9823
|
-
|
|
10245
|
+
requestRender();
|
|
9824
10246
|
return true;
|
|
9825
10247
|
}
|
|
9826
10248
|
function getFileDiagnosticSummaries() {
|
|
@@ -9941,6 +10363,15 @@ function capStoredDiagnostics(diagnostics) {
|
|
|
9941
10363
|
}
|
|
9942
10364
|
function requestRender() {
|
|
9943
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
|
+
}
|
|
9944
10375
|
}
|
|
9945
10376
|
|
|
9946
10377
|
// dist/clients/lsp/client.js
|
|
@@ -9954,18 +10385,18 @@ import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
|
9954
10385
|
var import_node = __toESM(require_main(), 1);
|
|
9955
10386
|
|
|
9956
10387
|
// dist/clients/lsp/aggregation.js
|
|
9957
|
-
async function raceToCompletion(
|
|
10388
|
+
async function raceToCompletion(promises4, shouldComplete, options = { timeoutMs: 1500 }) {
|
|
9958
10389
|
const results = [];
|
|
9959
|
-
results.length =
|
|
10390
|
+
results.length = promises4.length;
|
|
9960
10391
|
results.fill(void 0);
|
|
9961
10392
|
let graceTimer;
|
|
9962
10393
|
let auxGraceTimer;
|
|
9963
10394
|
let completed = false;
|
|
9964
|
-
let remaining =
|
|
10395
|
+
let remaining = promises4.length;
|
|
9965
10396
|
const descriptors = options.descriptors ?? [];
|
|
9966
10397
|
const hasAuxiliaries = descriptors.some((d) => isAuxiliary(d));
|
|
9967
10398
|
const auxIndices = hasAuxiliaries ? new Set(descriptors.map((d, i) => isAuxiliary(d) ? i : -1).filter((i) => i >= 0)) : /* @__PURE__ */ new Set();
|
|
9968
|
-
const languageCount =
|
|
10399
|
+
const languageCount = promises4.length - auxIndices.size;
|
|
9969
10400
|
let languageRemaining = languageCount;
|
|
9970
10401
|
let auxGraceStarted = false;
|
|
9971
10402
|
return new Promise((resolve7) => {
|
|
@@ -10021,10 +10452,10 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
|
|
|
10021
10452
|
}
|
|
10022
10453
|
}
|
|
10023
10454
|
};
|
|
10024
|
-
for (let i = 0; i <
|
|
10455
|
+
for (let i = 0; i < promises4.length; i++) {
|
|
10025
10456
|
const index = i;
|
|
10026
10457
|
const isAux = auxIndices.has(index);
|
|
10027
|
-
|
|
10458
|
+
promises4[i].then((result) => {
|
|
10028
10459
|
if (!completed) {
|
|
10029
10460
|
results[index] = result;
|
|
10030
10461
|
remaining--;
|
|
@@ -10045,8 +10476,8 @@ async function raceToCompletion(promises3, shouldComplete, options = { timeoutMs
|
|
|
10045
10476
|
}
|
|
10046
10477
|
|
|
10047
10478
|
// dist/clients/lsp/edits.js
|
|
10048
|
-
import
|
|
10049
|
-
import { readFileSync as
|
|
10479
|
+
import fs10 from "node:fs/promises";
|
|
10480
|
+
import { readFileSync as readFileSync8, realpathSync, statSync as statSync8 } from "node:fs";
|
|
10050
10481
|
import path10 from "node:path";
|
|
10051
10482
|
import { URL as URL2 } from "node:url";
|
|
10052
10483
|
|
|
@@ -10326,8 +10757,8 @@ function normalizeTextEditsForContent(content, edits, encoding) {
|
|
|
10326
10757
|
}
|
|
10327
10758
|
function applyTextEditsToString(content, edits, positionEncoding = "utf-16") {
|
|
10328
10759
|
const lines = content.split("\n");
|
|
10329
|
-
const
|
|
10330
|
-
for (const edit of
|
|
10760
|
+
const normalized2 = sortEditsForApplication(normalizeTextEditsForContent(content, edits, positionEncoding));
|
|
10761
|
+
for (const edit of normalized2) {
|
|
10331
10762
|
const { start, end } = edit.range;
|
|
10332
10763
|
if (start.line === end.line) {
|
|
10333
10764
|
const line = lines[start.line] ?? "";
|
|
@@ -10513,8 +10944,8 @@ function captureRenameExpectedContent(edit, cwd, requestedAtMs, readTrackedSend,
|
|
|
10513
10944
|
let mtimeMs;
|
|
10514
10945
|
try {
|
|
10515
10946
|
realPath = realpathSync.native(diskPath);
|
|
10516
|
-
content =
|
|
10517
|
-
mtimeMs =
|
|
10947
|
+
content = readFileSync8(realPath, "utf-8");
|
|
10948
|
+
mtimeMs = statSync8(realPath).mtimeMs;
|
|
10518
10949
|
} catch {
|
|
10519
10950
|
continue;
|
|
10520
10951
|
}
|
|
@@ -10703,7 +11134,7 @@ function summarizeWorkspaceEdit(edit, cwd) {
|
|
|
10703
11134
|
}
|
|
10704
11135
|
async function lstatOrMissing(filePath) {
|
|
10705
11136
|
try {
|
|
10706
|
-
return await
|
|
11137
|
+
return await fs10.lstat(filePath);
|
|
10707
11138
|
} catch (err) {
|
|
10708
11139
|
if (err.code === "ENOENT")
|
|
10709
11140
|
return void 0;
|
|
@@ -10715,7 +11146,7 @@ function isSameFsIdentity(a, b) {
|
|
|
10715
11146
|
}
|
|
10716
11147
|
async function bigintLstatOrMissing(filePath) {
|
|
10717
11148
|
try {
|
|
10718
|
-
return await
|
|
11149
|
+
return await fs10.lstat(filePath, { bigint: true });
|
|
10719
11150
|
} catch (err) {
|
|
10720
11151
|
if (err.code === "ENOENT")
|
|
10721
11152
|
return void 0;
|
|
@@ -10835,7 +11266,7 @@ async function preflightWorkspaceEdit(planned, cwd, options) {
|
|
|
10835
11266
|
const physicalPath = resolveVirtualPath(filePath);
|
|
10836
11267
|
if (!physicalPath)
|
|
10837
11268
|
throw new Error(`text edit target does not exist: ${filePath}`);
|
|
10838
|
-
const content = await
|
|
11269
|
+
const content = await fs10.readFile(physicalPath, "utf-8");
|
|
10839
11270
|
const expected = options.expectedContent?.get(await realpathOrResolveAsync(physicalPath));
|
|
10840
11271
|
if (expected !== void 0 && expected !== content) {
|
|
10841
11272
|
refuseStaleWorkspaceEdit(filePath, "the file changed after the edit was computed from it");
|
|
@@ -10854,12 +11285,12 @@ async function preflightWorkspaceEdit(planned, cwd, options) {
|
|
|
10854
11285
|
}
|
|
10855
11286
|
const content = await contentFor(filePath2, state5);
|
|
10856
11287
|
const encoding = options.positionEncoding ?? "utf-16";
|
|
10857
|
-
const
|
|
10858
|
-
text.set(op,
|
|
11288
|
+
const normalized2 = normalizeTextEditsForContent(content, op.edits, encoding);
|
|
11289
|
+
text.set(op, normalized2);
|
|
10859
11290
|
for (const origin of op.origins ?? []) {
|
|
10860
11291
|
textByOrigin.set(textEditOriginKey(origin), normalizeTextEditsForContent(content, origin.edits, encoding));
|
|
10861
11292
|
}
|
|
10862
|
-
state5.content = applyTextEditsToString(content,
|
|
11293
|
+
state5.content = applyTextEditsToString(content, normalized2);
|
|
10863
11294
|
continue;
|
|
10864
11295
|
}
|
|
10865
11296
|
if (op.kind === "create") {
|
|
@@ -11039,14 +11470,14 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11039
11470
|
skipOperation(op);
|
|
11040
11471
|
continue;
|
|
11041
11472
|
}
|
|
11042
|
-
const content = await
|
|
11473
|
+
const content = await fs10.readFile(diskPath, "utf-8");
|
|
11043
11474
|
const updated = applyTextEditsToString(content, edits, "utf-16");
|
|
11044
11475
|
const changesLineCount = edits.some((edit2) => {
|
|
11045
11476
|
const removedLines = edit2.range.end.line - edit2.range.start.line;
|
|
11046
11477
|
const insertedLines = (edit2.newText.match(/\r\n|\r|\n/g) ?? []).length;
|
|
11047
11478
|
return removedLines !== insertedLines;
|
|
11048
11479
|
});
|
|
11049
|
-
await
|
|
11480
|
+
await fs10.writeFile(diskPath, updated, "utf-8");
|
|
11050
11481
|
const start = Math.min(...edits.map((item) => item.range.start.line + 1));
|
|
11051
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)));
|
|
11052
11483
|
touchedFiles.add(filePath);
|
|
@@ -11065,11 +11496,11 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11065
11496
|
} else if (op.kind === "create") {
|
|
11066
11497
|
const filePath = uriToPath(op.uri);
|
|
11067
11498
|
const diskPath = uriToDiskPath(op.uri);
|
|
11068
|
-
await
|
|
11499
|
+
await fs10.mkdir(path10.dirname(diskPath), { recursive: true });
|
|
11069
11500
|
if (op.options?.overwrite)
|
|
11070
|
-
await
|
|
11501
|
+
await fs10.writeFile(diskPath, "", "utf-8");
|
|
11071
11502
|
else
|
|
11072
|
-
await
|
|
11503
|
+
await fs10.writeFile(diskPath, "", { flag: "wx" });
|
|
11073
11504
|
resourceChanges.push({ filePath: diskPath, type: FILE_CREATED });
|
|
11074
11505
|
touchedFiles.add(filePath);
|
|
11075
11506
|
fileDetails.push({
|
|
@@ -11085,10 +11516,10 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11085
11516
|
const newPath = uriToPath(op.newUri);
|
|
11086
11517
|
const oldDisk = uriToDiskPath(op.oldUri);
|
|
11087
11518
|
const newDisk = uriToDiskPath(op.newUri);
|
|
11088
|
-
await
|
|
11519
|
+
await fs10.mkdir(path10.dirname(newDisk), { recursive: true });
|
|
11089
11520
|
if (op.options?.overwrite)
|
|
11090
|
-
await
|
|
11091
|
-
await
|
|
11521
|
+
await fs10.rm(newDisk, { recursive: true, force: true });
|
|
11522
|
+
await fs10.rename(oldDisk, newDisk);
|
|
11092
11523
|
resourceChanges.push({ filePath: oldDisk, type: FILE_DELETED }, { filePath: newDisk, type: FILE_CREATED });
|
|
11093
11524
|
touchedFiles.add(oldPath);
|
|
11094
11525
|
touchedFiles.add(newPath);
|
|
@@ -11108,7 +11539,7 @@ async function applyWorkspaceEdit(edit, cwd, options = {}) {
|
|
|
11108
11539
|
} else {
|
|
11109
11540
|
const filePath = uriToPath(op.uri);
|
|
11110
11541
|
const diskPath = uriToDiskPath(op.uri);
|
|
11111
|
-
await
|
|
11542
|
+
await fs10.rm(diskPath, {
|
|
11112
11543
|
recursive: op.options?.recursive === true,
|
|
11113
11544
|
force: false
|
|
11114
11545
|
});
|
|
@@ -11331,7 +11762,7 @@ async function attemptTsserverSyncDiagnostics(file, svc) {
|
|
|
11331
11762
|
}
|
|
11332
11763
|
|
|
11333
11764
|
// dist/clients/lsp/workspace-diagnostics-cache.js
|
|
11334
|
-
import * as
|
|
11765
|
+
import * as fs11 from "node:fs";
|
|
11335
11766
|
import * as path12 from "node:path";
|
|
11336
11767
|
|
|
11337
11768
|
// dist/clients/reverse-deps.js
|
|
@@ -11390,9 +11821,9 @@ function buildReverseDependencyIndexFromGraph(args) {
|
|
|
11390
11821
|
source: "review-graph"
|
|
11391
11822
|
};
|
|
11392
11823
|
for (const filePath of args.graph.fileNodes.keys()) {
|
|
11393
|
-
const
|
|
11394
|
-
index.imports[
|
|
11395
|
-
index.importedBy[
|
|
11824
|
+
const normalized2 = normalizeMapKey(filePath);
|
|
11825
|
+
index.imports[normalized2] ??= [];
|
|
11826
|
+
index.importedBy[normalized2] ??= [];
|
|
11396
11827
|
}
|
|
11397
11828
|
for (const edge of args.graph.edges) {
|
|
11398
11829
|
if (edge.kind !== "imports")
|
|
@@ -11421,28 +11852,28 @@ function buildReverseDependencyIndexFromSnapshot(snapshot) {
|
|
|
11421
11852
|
source: "project-snapshot"
|
|
11422
11853
|
};
|
|
11423
11854
|
for (const [filePath, file] of fileEntries) {
|
|
11424
|
-
const
|
|
11855
|
+
const normalized2 = normalizeMapKey(file.path || filePath);
|
|
11425
11856
|
if (Array.isArray(file.imports)) {
|
|
11426
11857
|
const imports = sortedUnique(file.imports);
|
|
11427
|
-
index.imports[
|
|
11858
|
+
index.imports[normalized2] = imports;
|
|
11428
11859
|
for (const imported of imports) {
|
|
11429
11860
|
index.importedBy[imported] ??= [];
|
|
11430
|
-
index.importedBy[imported].push(
|
|
11861
|
+
index.importedBy[imported].push(normalized2);
|
|
11431
11862
|
}
|
|
11432
11863
|
}
|
|
11433
|
-
index.importedBy[
|
|
11864
|
+
index.importedBy[normalized2] ??= [];
|
|
11434
11865
|
}
|
|
11435
11866
|
for (const [filePath, importers] of Object.entries(reverseDeps)) {
|
|
11436
|
-
const
|
|
11437
|
-
index.importedBy[
|
|
11438
|
-
...index.importedBy[
|
|
11867
|
+
const normalized2 = normalizeMapKey(filePath);
|
|
11868
|
+
index.importedBy[normalized2] = sortedUnique([
|
|
11869
|
+
...index.importedBy[normalized2] ?? [],
|
|
11439
11870
|
...importers
|
|
11440
11871
|
]);
|
|
11441
|
-
for (const importer of index.importedBy[
|
|
11872
|
+
for (const importer of index.importedBy[normalized2]) {
|
|
11442
11873
|
if (index.imports[importer] === void 0)
|
|
11443
11874
|
continue;
|
|
11444
|
-
if (!index.imports[importer].includes(
|
|
11445
|
-
index.imports[importer].push(
|
|
11875
|
+
if (!index.imports[importer].includes(normalized2)) {
|
|
11876
|
+
index.imports[importer].push(normalized2);
|
|
11446
11877
|
}
|
|
11447
11878
|
}
|
|
11448
11879
|
}
|
|
@@ -11523,7 +11954,7 @@ function loadWorkspaceDiagnosticsCache(cwd) {
|
|
|
11523
11954
|
}
|
|
11524
11955
|
function saveWorkspaceDiagnosticsCache(cwd, cache) {
|
|
11525
11956
|
const filePath = cachePath(cwd);
|
|
11526
|
-
|
|
11957
|
+
fs11.mkdirSync(path12.dirname(filePath), { recursive: true });
|
|
11527
11958
|
writeFileAtomic(filePath, JSON.stringify(cache, null, 2), {
|
|
11528
11959
|
bestEffort: false
|
|
11529
11960
|
});
|
|
@@ -11557,7 +11988,7 @@ function classifyWorkspaceDiagnosticsCacheExpiry(entry, now, sessionStartedAt, f
|
|
|
11557
11988
|
function isEntryFresh(filePath, entry, getImports) {
|
|
11558
11989
|
let ownStat;
|
|
11559
11990
|
try {
|
|
11560
|
-
ownStat =
|
|
11991
|
+
ownStat = fs11.statSync(filePath);
|
|
11561
11992
|
} catch {
|
|
11562
11993
|
return false;
|
|
11563
11994
|
}
|
|
@@ -11581,7 +12012,7 @@ function isEntryFresh(filePath, entry, getImports) {
|
|
|
11581
12012
|
for (const dep of imports) {
|
|
11582
12013
|
let mtimeMs;
|
|
11583
12014
|
try {
|
|
11584
|
-
mtimeMs =
|
|
12015
|
+
mtimeMs = fs11.statSync(dep).mtimeMs;
|
|
11585
12016
|
} catch {
|
|
11586
12017
|
return false;
|
|
11587
12018
|
}
|
|
@@ -13005,7 +13436,7 @@ function setupIncomingHandlers(state4, initialization, onDiagnosticsPublished) {
|
|
|
13005
13436
|
} else {
|
|
13006
13437
|
refreshRepullRunning = true;
|
|
13007
13438
|
setImmediate(() => {
|
|
13008
|
-
void runRefreshRepullPool();
|
|
13439
|
+
void spawnAbortScope.run(REFRESH_REPULL_SIGNAL, () => runRefreshRepullPool());
|
|
13009
13440
|
});
|
|
13010
13441
|
}
|
|
13011
13442
|
}
|
|
@@ -13080,7 +13511,7 @@ async function clientRequestPullDiagnostics(state4, filePath, budgetMs = PULL_RE
|
|
|
13080
13511
|
const attempts = sources.map((identifier) => pullDiagnosticSource(state4, filePath, budgetMs, identifier));
|
|
13081
13512
|
const settled = await raceToCompletion(attempts, (results) => results.some((r) => r.status === "found" && r.primaryCount > 0), {
|
|
13082
13513
|
// No graceMs: finalize the instant a source answers for this file.
|
|
13083
|
-
// The per-request `
|
|
13514
|
+
// The per-request `withDeadline` inside each attempt is the real bound;
|
|
13084
13515
|
// this deadline is only a backstop, so it sits just past it.
|
|
13085
13516
|
timeoutMs: Math.max(1, Math.min(PULL_REQUEST_TIMEOUT_MS, budgetMs)) + PULL_RACE_BACKSTOP_MARGIN_MS
|
|
13086
13517
|
});
|
|
@@ -13101,9 +13532,13 @@ function aggregatePullOutcomes(state4, filePath, outcomes) {
|
|
|
13101
13532
|
}
|
|
13102
13533
|
return outcomes.some((o) => o.status === "clean") ? { status: "clean" } : { status: "unavailable" };
|
|
13103
13534
|
}
|
|
13535
|
+
var PULL_ABORTED = /* @__PURE__ */ Symbol("pull-aborted");
|
|
13104
13536
|
async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
13105
13537
|
if (!isClientAlive(state4))
|
|
13106
13538
|
return { status: "unavailable" };
|
|
13539
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13540
|
+
if (abortSignal?.aborted)
|
|
13541
|
+
return { status: "unavailable" };
|
|
13107
13542
|
const normalizedPath = normalizeMapKey(filePath);
|
|
13108
13543
|
if (budgetMs < PULL_MIN_USABLE_BUDGET_MS) {
|
|
13109
13544
|
emitBounded("lsp_pull_skipped_budget_exhausted", `${state4.serverId}::${pullSourceKey(normalizedPath, identifier)}`, {
|
|
@@ -13142,7 +13577,12 @@ async function pullDiagnosticSource(state4, filePath, budgetMs, identifier) {
|
|
|
13142
13577
|
...previousResultId !== void 0 && { previousResultId }
|
|
13143
13578
|
}, pullAbort.signal, pullSettlement);
|
|
13144
13579
|
try {
|
|
13145
|
-
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
|
+
}
|
|
13146
13586
|
if (!report) {
|
|
13147
13587
|
recordPullFailure(state4, "textDocument/diagnostic", new Error("empty response"));
|
|
13148
13588
|
return { status: "unavailable" };
|
|
@@ -13347,7 +13787,9 @@ async function clientRequestWorkspaceDiagnostics(state4, budgetMs) {
|
|
|
13347
13787
|
const workspacePullSettlement = { cancelled: false };
|
|
13348
13788
|
const workspaceRequestPromise = safeSendRequest(state4.connection, "workspace/diagnostic", { previousResultIds }, workspacePullAbort.signal, workspacePullSettlement);
|
|
13349
13789
|
try {
|
|
13350
|
-
const report = await
|
|
13790
|
+
const report = await withDeadline(workspaceRequestPromise, {
|
|
13791
|
+
ms: workspacePullTimeoutMs
|
|
13792
|
+
});
|
|
13351
13793
|
if (!report || !Array.isArray(report.items))
|
|
13352
13794
|
return void 0;
|
|
13353
13795
|
const out = [];
|
|
@@ -13465,6 +13907,7 @@ function waitForQuiescence(state4, budgetMs) {
|
|
|
13465
13907
|
});
|
|
13466
13908
|
}
|
|
13467
13909
|
var PULL_UNSETTLED = /* @__PURE__ */ Symbol("pull-unsettled");
|
|
13910
|
+
var REFRESH_REPULL_SIGNAL = new AbortController().signal;
|
|
13468
13911
|
function pullAnswerIsSettled(state4, sentAt) {
|
|
13469
13912
|
const now = state4.serverStatus;
|
|
13470
13913
|
return sentAt?.revision === now?.revision && now?.quiescent !== false && now?.failed !== true;
|
|
@@ -13492,13 +13935,14 @@ function reportCarriesNothing(report) {
|
|
|
13492
13935
|
async function pullDiagnosticsWhenReady(state4, filePath, budgetMs, deadlineAt) {
|
|
13493
13936
|
let requestBudgetMs = budgetMs;
|
|
13494
13937
|
let waitedForReadiness = false;
|
|
13938
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13495
13939
|
for (; ; ) {
|
|
13496
13940
|
if (state4.serverStatus?.quiescent === false) {
|
|
13497
13941
|
waitedForReadiness = true;
|
|
13498
13942
|
noteReadinessGate(state4);
|
|
13499
|
-
|
|
13943
|
+
const ready = await untilAborted(waitForQuiescence(state4, deadlineAt - Date.now()), abortSignal, false);
|
|
13944
|
+
if (!ready)
|
|
13500
13945
|
return PULL_UNSETTLED;
|
|
13501
|
-
}
|
|
13502
13946
|
requestBudgetMs = deadlineAt - Date.now();
|
|
13503
13947
|
}
|
|
13504
13948
|
const sentAt = state4.serverStatus;
|
|
@@ -13578,6 +14022,7 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
|
|
|
13578
14022
|
return "answered";
|
|
13579
14023
|
}
|
|
13580
14024
|
let sawClean = outcome.status === "clean";
|
|
14025
|
+
const abortSignal = getAmbientAbortSignal();
|
|
13581
14026
|
const strategy = getStrategy(state4.serverId, state4.launchVariant);
|
|
13582
14027
|
const retryBudgetMs = strategy.pullRetryBudgetMs > 0 ? Math.min(timeoutMs, strategy.pullRetryBudgetMs) : 0;
|
|
13583
14028
|
const startedAt = Date.now();
|
|
@@ -13587,6 +14032,9 @@ async function clientWaitForDiagnostics(state4, filePath, timeoutMs, options = {
|
|
|
13587
14032
|
if (outcome.status === "clean")
|
|
13588
14033
|
sawClean = true;
|
|
13589
14034
|
}
|
|
14035
|
+
if (!sawClean && outcome.status !== "found" && abortSignal?.aborted) {
|
|
14036
|
+
return "deadline-expired";
|
|
14037
|
+
}
|
|
13590
14038
|
if (options.pullOnly) {
|
|
13591
14039
|
const answered = outcome.status === "found" || sawClean;
|
|
13592
14040
|
if (answered) {
|
|
@@ -14086,7 +14534,7 @@ async function clientShutdownOnce(state4, options) {
|
|
|
14086
14534
|
try {
|
|
14087
14535
|
if (!options.fast) {
|
|
14088
14536
|
try {
|
|
14089
|
-
const shutdownAck = await
|
|
14537
|
+
const shutdownAck = await withDeadline(safeSendRequest(state4.connection, "shutdown", {}), { ms: SHUTDOWN_REQUEST_TIMEOUT_MS });
|
|
14090
14538
|
if (shutdownAck === void 0)
|
|
14091
14539
|
shutdownRequestUndelivered = true;
|
|
14092
14540
|
} catch (err) {
|
|
@@ -14097,7 +14545,7 @@ async function clientShutdownOnce(state4, options) {
|
|
|
14097
14545
|
}
|
|
14098
14546
|
}
|
|
14099
14547
|
try {
|
|
14100
|
-
const exitSent = await
|
|
14548
|
+
const exitSent = await withDeadline(safeSendNotification(state4.connection, "exit", {}), { ms: EXIT_NOTIFY_TIMEOUT_MS });
|
|
14101
14549
|
if (exitSent === false)
|
|
14102
14550
|
exitNotifyUndelivered = true;
|
|
14103
14551
|
} catch (err) {
|
|
@@ -14173,8 +14621,19 @@ async function navRequest(state4, method, params, staleCheckPath, timeoutMs = NA
|
|
|
14173
14621
|
const normalizedPath = staleCheckPath !== void 0 ? normalizeMapKey(staleCheckPath) : void 0;
|
|
14174
14622
|
const requestVersion = normalizedPath !== void 0 ? state4.documentVersions.get(normalizedPath) : void 0;
|
|
14175
14623
|
const requestStartedAt = Date.now();
|
|
14176
|
-
const
|
|
14177
|
-
|
|
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) => {
|
|
14178
14637
|
if (isNavTimeoutError(err, timeoutMs)) {
|
|
14179
14638
|
recordNavTimeoutTelemetry({
|
|
14180
14639
|
method,
|
|
@@ -14182,15 +14641,6 @@ async function navRequest(state4, method, params, staleCheckPath, timeoutMs = NA
|
|
|
14182
14641
|
budgetMs: timeoutMs,
|
|
14183
14642
|
elapsedMs: Date.now() - requestStartedAt
|
|
14184
14643
|
});
|
|
14185
|
-
armNavLateAnswerTelemetry({
|
|
14186
|
-
requestPromise,
|
|
14187
|
-
method,
|
|
14188
|
-
scope: normalizedPath,
|
|
14189
|
-
requestStartedAt
|
|
14190
|
-
});
|
|
14191
|
-
throw new LspRequestTimeoutError(method, timeoutMs, Date.now() - requestStartedAt);
|
|
14192
|
-
}
|
|
14193
|
-
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14194
14644
|
throw new LspRequestTimeoutError(method, timeoutMs, Date.now() - requestStartedAt);
|
|
14195
14645
|
}
|
|
14196
14646
|
throw err;
|
|
@@ -14222,24 +14672,21 @@ function recordNavTimeoutTelemetry(args) {
|
|
|
14222
14672
|
reason: `timeout budget=${args.budgetMs}ms elapsed=${args.elapsedMs}ms`
|
|
14223
14673
|
});
|
|
14224
14674
|
}
|
|
14225
|
-
function
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
}
|
|
14241
|
-
}, () => {
|
|
14242
|
-
});
|
|
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
|
+
}
|
|
14243
14690
|
}
|
|
14244
14691
|
function chooseLivenessProbe(state4) {
|
|
14245
14692
|
if (state4.operationSupport?.workspaceSymbol === true) {
|
|
@@ -14276,7 +14723,7 @@ function firstOpenDocumentUri(state4) {
|
|
|
14276
14723
|
}
|
|
14277
14724
|
return void 0;
|
|
14278
14725
|
}
|
|
14279
|
-
async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS) {
|
|
14726
|
+
async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS, signal) {
|
|
14280
14727
|
if (!isClientAlive(state4))
|
|
14281
14728
|
return false;
|
|
14282
14729
|
const probe = chooseLivenessProbe(state4);
|
|
@@ -14292,7 +14739,9 @@ async function clientPingLiveness(state4, timeoutMs = LIVENESS_PING_TIMEOUT_MS)
|
|
|
14292
14739
|
return isClientAlive(state4);
|
|
14293
14740
|
}
|
|
14294
14741
|
try {
|
|
14295
|
-
await
|
|
14742
|
+
await safeSendRequest(state4.connection, probe.method, probe.params, signal, void 0, { timeoutMs, cancel: true });
|
|
14743
|
+
if (signal?.aborted)
|
|
14744
|
+
return false;
|
|
14296
14745
|
} catch (err) {
|
|
14297
14746
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14298
14747
|
return false;
|
|
@@ -14323,10 +14772,7 @@ async function runServerCommand(state4, command, args, timeoutMs = EXECUTE_COMMA
|
|
|
14323
14772
|
try {
|
|
14324
14773
|
let result;
|
|
14325
14774
|
try {
|
|
14326
|
-
result = await
|
|
14327
|
-
command,
|
|
14328
|
-
arguments: args ?? []
|
|
14329
|
-
}), timeoutMs);
|
|
14775
|
+
result = await safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, void 0, void 0, { timeoutMs, cancel: false });
|
|
14330
14776
|
} catch (err) {
|
|
14331
14777
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14332
14778
|
return {
|
|
@@ -14356,15 +14802,11 @@ async function runReadOnlyServerCommand(state4, command, args, timeoutMs = PROBE
|
|
|
14356
14802
|
reason: `command "${command}" is not advertised by the ${state4.serverId} server`
|
|
14357
14803
|
};
|
|
14358
14804
|
}
|
|
14359
|
-
const abandon = new AbortController();
|
|
14360
|
-
const request = safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, abandon.signal, void 0, true);
|
|
14361
14805
|
try {
|
|
14362
|
-
const result = await
|
|
14806
|
+
const result = await safeSendRequest(state4.connection, "workspace/executeCommand", { command, arguments: args ?? [] }, void 0, void 0, { timeoutMs, cancel: true });
|
|
14363
14807
|
return { executed: true, result };
|
|
14364
14808
|
} catch (err) {
|
|
14365
14809
|
if (err instanceof Error && err.message.startsWith("Timeout after")) {
|
|
14366
|
-
abandon.abort();
|
|
14367
|
-
await request;
|
|
14368
14810
|
recordDegradationOnce({
|
|
14369
14811
|
kind: "lsp-readonly-command-released",
|
|
14370
14812
|
subject: state4.serverId,
|
|
@@ -14410,8 +14852,8 @@ function stripDocumentVersions(edit) {
|
|
|
14410
14852
|
}
|
|
14411
14853
|
async function normalizeClientWorkspaceEdit(state4, edit) {
|
|
14412
14854
|
validateWorkspaceEditVersions(state4, edit);
|
|
14413
|
-
const
|
|
14414
|
-
return stripDocumentVersions(
|
|
14855
|
+
const normalized2 = await normalizeWorkspaceEditToUtf16(edit, state4.positionEncoding, state4.root);
|
|
14856
|
+
return stripDocumentVersions(normalized2);
|
|
14415
14857
|
}
|
|
14416
14858
|
async function resolveCodeActionBestEffort(state4, action) {
|
|
14417
14859
|
if (!isClientAlive(state4))
|
|
@@ -14432,7 +14874,7 @@ async function resolveCodeActionBestEffort(state4, action) {
|
|
|
14432
14874
|
}
|
|
14433
14875
|
let resolved2;
|
|
14434
14876
|
try {
|
|
14435
|
-
resolved2 = await
|
|
14877
|
+
resolved2 = await safeSendRequest(state4.connection, "codeAction/resolve", action, getAmbientAbortSignal(), void 0, { timeoutMs: NAV_REQUEST_TIMEOUT_MS, cancel: true });
|
|
14436
14878
|
} catch {
|
|
14437
14879
|
return action;
|
|
14438
14880
|
}
|
|
@@ -14629,7 +15071,7 @@ async function createLSPClient(options) {
|
|
|
14629
15071
|
setupConnectionLifecycle(state4, recentStderr);
|
|
14630
15072
|
let initResult;
|
|
14631
15073
|
try {
|
|
14632
|
-
initResult = await
|
|
15074
|
+
initResult = await withDeadline(safeSendRequest(connection, "initialize", {
|
|
14633
15075
|
processId: process.pid,
|
|
14634
15076
|
rootUri: pathToFileURL2(root).href,
|
|
14635
15077
|
workspaceFolders: [
|
|
@@ -14637,7 +15079,7 @@ async function createLSPClient(options) {
|
|
|
14637
15079
|
],
|
|
14638
15080
|
capabilities: CLIENT_CAPABILITIES,
|
|
14639
15081
|
initializationOptions: initialization
|
|
14640
|
-
}), initializeTimeoutMs);
|
|
15082
|
+
}), { ms: initializeTimeoutMs });
|
|
14641
15083
|
} catch (err) {
|
|
14642
15084
|
state4.shutdownRequested = true;
|
|
14643
15085
|
const pid = lspProcess.pid;
|
|
@@ -14729,7 +15171,7 @@ async function createLSPClient(options) {
|
|
|
14729
15171
|
/** Pre-request health check — returns error string if dead. */
|
|
14730
15172
|
checkAlive: () => checkProcessAlive(),
|
|
14731
15173
|
/** #1277: cheap request round-trip proving the server still responds. */
|
|
14732
|
-
pingLiveness: (timeoutMs) => clientPingLiveness(state4, timeoutMs),
|
|
15174
|
+
pingLiveness: (timeoutMs, signal) => clientPingLiveness(state4, timeoutMs, signal),
|
|
14733
15175
|
/** #5487: the server announced it is still loading (see interface doc). */
|
|
14734
15176
|
readinessBlock: () => readinessBlockOf(state4),
|
|
14735
15177
|
/** #2358: the OS pid of the live server process (see interface doc). */
|
|
@@ -14935,7 +15377,7 @@ async function createLSPClient(options) {
|
|
|
14935
15377
|
},
|
|
14936
15378
|
async codeAction(filePath, line, character, endLine, endCharacter) {
|
|
14937
15379
|
if (!isClientAlive(state4))
|
|
14938
|
-
return
|
|
15380
|
+
return void 0;
|
|
14939
15381
|
const uri = pathToFileURL2(filePath).href;
|
|
14940
15382
|
const result = await navRequest(state4, "textDocument/codeAction", {
|
|
14941
15383
|
textDocument: { uri },
|
|
@@ -14947,8 +15389,12 @@ async function createLSPClient(options) {
|
|
|
14947
15389
|
diagnostics: getMergedDiagnosticsForPath(state4, normalizeMapKey(filePath))
|
|
14948
15390
|
}
|
|
14949
15391
|
}, filePath);
|
|
14950
|
-
if (
|
|
15392
|
+
if (result === void 0)
|
|
15393
|
+
return void 0;
|
|
15394
|
+
if (result === null)
|
|
14951
15395
|
return [];
|
|
15396
|
+
if (!Array.isArray(result))
|
|
15397
|
+
return void 0;
|
|
14952
15398
|
const actions = result.filter((item) => typeof item === "object" && item !== null && "title" in item);
|
|
14953
15399
|
return Promise.all(actions.map((action) => resolveCodeActionBestEffort(state4, action)));
|
|
14954
15400
|
},
|
|
@@ -15113,26 +15559,36 @@ async function safeSendNotification(connection, method, params) {
|
|
|
15113
15559
|
}
|
|
15114
15560
|
var activeRequestsByConnection = /* @__PURE__ */ new WeakMap();
|
|
15115
15561
|
var RELEASED_ON_ABORT = /* @__PURE__ */ Symbol("released-on-abort");
|
|
15562
|
+
var RELEASED_ON_TIMEOUT = /* @__PURE__ */ Symbol("released-on-timeout");
|
|
15116
15563
|
function isConnectionBusy(connection) {
|
|
15117
15564
|
return (activeRequestsByConnection.get(connection) ?? 0) > 0;
|
|
15118
15565
|
}
|
|
15119
|
-
async function safeSendRequest(connection, method, params, signal, settlement,
|
|
15566
|
+
async function safeSendRequest(connection, method, params, signal, settlement, bound) {
|
|
15120
15567
|
if (signal?.aborted)
|
|
15121
15568
|
return void 0;
|
|
15122
15569
|
let tokenSource;
|
|
15123
15570
|
let onAbort;
|
|
15124
15571
|
let released;
|
|
15125
15572
|
let release;
|
|
15126
|
-
|
|
15573
|
+
let timer;
|
|
15574
|
+
let timeoutError;
|
|
15575
|
+
if (signal || bound?.cancel)
|
|
15127
15576
|
tokenSource = new import_node.CancellationTokenSource();
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
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) {
|
|
15133
15589
|
onAbort = () => {
|
|
15134
15590
|
tokenSource?.cancel();
|
|
15135
|
-
release?.();
|
|
15591
|
+
release?.(RELEASED_ON_ABORT);
|
|
15136
15592
|
};
|
|
15137
15593
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
15138
15594
|
}
|
|
@@ -15144,9 +15600,15 @@ async function safeSendRequest(connection, method, params, signal, settlement, r
|
|
|
15144
15600
|
try {
|
|
15145
15601
|
if (!released)
|
|
15146
15602
|
return await send();
|
|
15147
|
-
const
|
|
15148
|
-
|
|
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;
|
|
15149
15610
|
return void 0;
|
|
15611
|
+
}
|
|
15150
15612
|
return reply;
|
|
15151
15613
|
} catch (err) {
|
|
15152
15614
|
if (isCancellationError(err)) {
|
|
@@ -15171,6 +15633,8 @@ async function safeSendRequest(connection, method, params, signal, settlement, r
|
|
|
15171
15633
|
activeRequestsByConnection.set(connection, remaining);
|
|
15172
15634
|
else
|
|
15173
15635
|
activeRequestsByConnection.delete(connection);
|
|
15636
|
+
if (timer)
|
|
15637
|
+
clearTimeout(timer);
|
|
15174
15638
|
if (signal && onAbort)
|
|
15175
15639
|
signal.removeEventListener("abort", onAbort);
|
|
15176
15640
|
tokenSource?.dispose();
|
|
@@ -15595,7 +16059,7 @@ var ClientRegistry = class {
|
|
|
15595
16059
|
admitAdoptedRoot(root, filePath) {
|
|
15596
16060
|
if (this.analysisRootModeForFile(filePath) !== "adopted")
|
|
15597
16061
|
return false;
|
|
15598
|
-
const
|
|
16062
|
+
const normalized2 = normalizeMapKey(root);
|
|
15599
16063
|
const liveRoots = /* @__PURE__ */ new Set();
|
|
15600
16064
|
for (const key of this.clients.keys()) {
|
|
15601
16065
|
if (this.adoptedClientKeys.has(key))
|
|
@@ -15605,16 +16069,16 @@ var ClientRegistry = class {
|
|
|
15605
16069
|
if (!liveRoots.has(root2))
|
|
15606
16070
|
this.adoptedRootLastUsedAt.delete(root2);
|
|
15607
16071
|
}
|
|
15608
|
-
if (liveRoots.has(
|
|
15609
|
-
this.adoptedRootLastUsedAt.set(
|
|
16072
|
+
if (liveRoots.has(normalized2)) {
|
|
16073
|
+
this.adoptedRootLastUsedAt.set(normalized2, Date.now());
|
|
15610
16074
|
return true;
|
|
15611
16075
|
}
|
|
15612
16076
|
if (this.adoptedRootLastUsedAt.size < ADOPTED_ROOT_CAP) {
|
|
15613
|
-
this.adoptedRootLastUsedAt.set(
|
|
16077
|
+
this.adoptedRootLastUsedAt.set(normalized2, Date.now());
|
|
15614
16078
|
return true;
|
|
15615
16079
|
}
|
|
15616
|
-
this.adoptedRootLastUsedAt.set(
|
|
15617
|
-
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);
|
|
15618
16082
|
if (!victim)
|
|
15619
16083
|
return true;
|
|
15620
16084
|
this.adoptedRootLastUsedAt.delete(victim);
|
|
@@ -15843,14 +16307,13 @@ var ClientRegistry = class {
|
|
|
15843
16307
|
*/
|
|
15844
16308
|
async restartPrimaryClientsUnder(root) {
|
|
15845
16309
|
const rootKey = normalizeMapKey(root);
|
|
15846
|
-
const overlaps = (clientRoot) => isWithinForm(clientRoot, rootKey) || isWithinForm(rootKey, clientRoot);
|
|
15847
16310
|
return this.withClientSpawnGate(async () => {
|
|
15848
16311
|
if (this.isDestroyed)
|
|
15849
16312
|
return [];
|
|
15850
16313
|
const victims = [];
|
|
15851
16314
|
for (const [key, client] of this.clients) {
|
|
15852
16315
|
const { serverId, root: clientRoot } = parseClientKey(key);
|
|
15853
|
-
if (client.isAlive() && !isAuxiliary(getServerById(serverId)) &&
|
|
16316
|
+
if (client.isAlive() && !isAuxiliary(getServerById(serverId)) && rootsOverlap(clientRoot, rootKey))
|
|
15854
16317
|
victims.push([key, client]);
|
|
15855
16318
|
}
|
|
15856
16319
|
for (const [key] of victims)
|
|
@@ -16582,7 +17045,7 @@ function auxWaitBudgetMs(serverId, isCold, configuredCeilingMs, declaredWaitMs)
|
|
|
16582
17045
|
import * as path16 from "node:path";
|
|
16583
17046
|
|
|
16584
17047
|
// dist/clients/lsp/environment-gap.js
|
|
16585
|
-
import * as
|
|
17048
|
+
import * as fs12 from "node:fs";
|
|
16586
17049
|
import { isBuiltin } from "node:module";
|
|
16587
17050
|
import * as path15 from "node:path";
|
|
16588
17051
|
var ENVIRONMENT_GAP_MARKER = "no dependency install resolved for this workspace";
|
|
@@ -16646,7 +17109,7 @@ function declaredPackageNames(startDir) {
|
|
|
16646
17109
|
maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
|
|
16647
17110
|
})) {
|
|
16648
17111
|
try {
|
|
16649
|
-
const manifest = JSON.parse(
|
|
17112
|
+
const manifest = JSON.parse(fs12.readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
16650
17113
|
for (const field of DECLARING_FIELDS) {
|
|
16651
17114
|
const declared = manifest[field];
|
|
16652
17115
|
if (typeof declared !== "object" || declared === null)
|
|
@@ -16687,7 +17150,7 @@ function environmentGapKind(diagnostic) {
|
|
|
16687
17150
|
const name = MISSING_NAME.exec(message)?.[1];
|
|
16688
17151
|
return name !== void 0 && NODE_GLOBALS.has(name) ? { code } : void 0;
|
|
16689
17152
|
}
|
|
16690
|
-
function hasResolvableNodeModules(startDir, stat3 = (candidate) =>
|
|
17153
|
+
function hasResolvableNodeModules(startDir, stat3 = (candidate) => fs12.statSync(candidate)) {
|
|
16691
17154
|
let last;
|
|
16692
17155
|
for (const dir of walkUpDirs(startDir, {
|
|
16693
17156
|
maxDepth: ENV_NODE_MODULES_WALK_MAX_LEVELS
|
|
@@ -16908,7 +17371,7 @@ function createLazyImport(load) {
|
|
|
16908
17371
|
}
|
|
16909
17372
|
|
|
16910
17373
|
// dist/clients/lsp-lazy.js
|
|
16911
|
-
var lazyLsp = createLazyImport(() => import("./chunk-
|
|
17374
|
+
var lazyLsp = createLazyImport(() => import("./chunk-EH6EHFW2.js"));
|
|
16912
17375
|
function warmLspService() {
|
|
16913
17376
|
return lazyLsp.get();
|
|
16914
17377
|
}
|
|
@@ -17033,7 +17496,7 @@ var SCOPED_DEPENDENCY_TOUCH_MAX = 32;
|
|
|
17033
17496
|
var RENAME_NOTIFY_TIMEOUT_MS = Math.max(50, Number.parseInt(process.env.PI_LENS_LSP_RENAME_NOTIFY_TIMEOUT_MS ?? "1500", 10) || 1500);
|
|
17034
17497
|
async function runRenameNotify(send, timeoutMs) {
|
|
17035
17498
|
try {
|
|
17036
|
-
await
|
|
17499
|
+
await withDeadline(send(), { ms: timeoutMs });
|
|
17037
17500
|
return { ok: true };
|
|
17038
17501
|
} catch (err) {
|
|
17039
17502
|
const timedOut = err instanceof Error && err.message.startsWith("Timeout after");
|
|
@@ -18408,7 +18871,7 @@ var LSPService = class _LSPService {
|
|
|
18408
18871
|
const separator = key.indexOf(":");
|
|
18409
18872
|
const serverId = separator >= 0 ? key.slice(0, separator) : key;
|
|
18410
18873
|
const root = normalizeMapKey(client.root);
|
|
18411
|
-
const sameOrNested =
|
|
18874
|
+
const sameOrNested = rootsOverlap(root, normalizedCwd);
|
|
18412
18875
|
if (!sameOrNested)
|
|
18413
18876
|
continue;
|
|
18414
18877
|
entries.push({ clientKey: key, serverId, client });
|
|
@@ -19137,7 +19600,7 @@ var LSPService = class _LSPService {
|
|
|
19137
19600
|
const readStamp = performance.now();
|
|
19138
19601
|
let content;
|
|
19139
19602
|
try {
|
|
19140
|
-
content = await
|
|
19603
|
+
content = await fs13.readFile(filePath, "utf8");
|
|
19141
19604
|
} catch {
|
|
19142
19605
|
continue;
|
|
19143
19606
|
}
|
|
@@ -20193,43 +20656,45 @@ var LSPService = class _LSPService {
|
|
|
20193
20656
|
const hasWaitedPrimary = waited.some((entry) => !isAuxiliary(entry.info));
|
|
20194
20657
|
const hasUnsupportedPrimary = diagnosticsUnsupportedServerIds.some((serverId) => spawned.some((entry) => entry.info.id === serverId && !isAuxiliary(entry.info)));
|
|
20195
20658
|
diagnosticsTimedOut = !hasWaitedPrimary && !hasUnsupportedPrimary || diagnosticsUnansweredPrimaryServerIds.length > 0;
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
20199
|
-
|
|
20200
|
-
|
|
20201
|
-
|
|
20202
|
-
|
|
20203
|
-
|
|
20204
|
-
|
|
20205
|
-
|
|
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
|
+
}
|
|
20206
20696
|
});
|
|
20207
20697
|
}
|
|
20208
|
-
logLatency({
|
|
20209
|
-
type: "phase",
|
|
20210
|
-
phase: "lsp_diagnostics_timeout",
|
|
20211
|
-
filePath: normalizedPath,
|
|
20212
|
-
durationMs: waitedMs,
|
|
20213
|
-
metadata: {
|
|
20214
|
-
source,
|
|
20215
|
-
// #1444: WHICH server(s) burned the budget — without this the
|
|
20216
|
-
// ~221/day timeout rows can't be attributed to a server at all.
|
|
20217
|
-
// `info.id` (not `client.serverId`) for the same reason the
|
|
20218
|
-
// degradation ledger above uses it: test doubles and lightweight
|
|
20219
|
-
// clients need not expose `serverId`.
|
|
20220
|
-
serverIds: spawned.map((e) => e.info.id),
|
|
20221
|
-
clientScope,
|
|
20222
|
-
diagnosticsMode,
|
|
20223
|
-
timeoutMs,
|
|
20224
|
-
// #1549: which of those servers actually produced no evidence, and
|
|
20225
|
-
// whether the lapse is attributable to a primary (the touch is
|
|
20226
|
-
// inconclusive) or only to auxiliaries (a named coverage gap, with
|
|
20227
|
-
// the primary's findings intact). Without these two fields a
|
|
20228
|
-
// forensic sweep cannot tell the two apart at all.
|
|
20229
|
-
unansweredServerIds: diagnosticsUnansweredServerIds,
|
|
20230
|
-
attributedToPrimary: diagnosticsTimedOut
|
|
20231
|
-
}
|
|
20232
|
-
});
|
|
20233
20698
|
}
|
|
20234
20699
|
if (diagnosticsTimedOut && !primaryNotifyWriteTimedOut && clientScope === "all") {
|
|
20235
20700
|
try {
|
|
@@ -20238,7 +20703,7 @@ var LSPService = class _LSPService {
|
|
|
20238
20703
|
const snapshots = await this.getCapabilitySnapshots(filePath);
|
|
20239
20704
|
const allSilent = outstanding.every((entry) => classifyServerWaitTier(entry.client.serverId, snapshots.find((s) => s.serverId === entry.client.serverId)) === "tier3-silent");
|
|
20240
20705
|
if (allSilent) {
|
|
20241
|
-
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)));
|
|
20242
20707
|
if (liveness.every(Boolean)) {
|
|
20243
20708
|
diagnosticsTimedOut = false;
|
|
20244
20709
|
retractPrimaryTimeoutAttribution();
|
|
@@ -20332,7 +20797,7 @@ var LSPService = class _LSPService {
|
|
|
20332
20797
|
try {
|
|
20333
20798
|
const snapshots = await this.getCapabilitySnapshots(filePath);
|
|
20334
20799
|
if (classifyCascadeWaitTier(this, filePath, snapshots) === "tier3-silent") {
|
|
20335
|
-
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);
|
|
20336
20801
|
if (alive) {
|
|
20337
20802
|
diagnosticsTimedOut = false;
|
|
20338
20803
|
retractPrimaryTimeoutAttribution();
|
|
@@ -21477,7 +21942,7 @@ var LSPService = class _LSPService {
|
|
|
21477
21942
|
status: "failed"
|
|
21478
21943
|
});
|
|
21479
21944
|
}
|
|
21480
|
-
const content = await
|
|
21945
|
+
const content = await fs13.readFile(oldFilePath, "utf-8");
|
|
21481
21946
|
const languageId = getLanguageId2(oldFilePath) ?? "plaintext";
|
|
21482
21947
|
const resyncFailures = [];
|
|
21483
21948
|
await Promise.all(openDocuments.map(async ({ serverId, client }) => {
|
|
@@ -21887,7 +22352,8 @@ var LSPService = class _LSPService {
|
|
|
21887
22352
|
failedServerIds = stillColdServerIds();
|
|
21888
22353
|
}
|
|
21889
22354
|
}
|
|
21890
|
-
|
|
22355
|
+
const abandoned = options.signal?.aborted === true || getAmbientAbortSignal()?.aborted === true;
|
|
22356
|
+
if (failedServerIds.length > 0 && !abandoned) {
|
|
21891
22357
|
for (let i = 0; i < servers.length; i++) {
|
|
21892
22358
|
const key = keys[i];
|
|
21893
22359
|
if (key !== void 0 && failedServerIds.includes(servers[i].id) && this.state.clients.get(key) === warmedClients[i]) {
|
|
@@ -21951,7 +22417,7 @@ var LSPService = class _LSPService {
|
|
|
21951
22417
|
await Promise.all(openImports.slice(0, SCOPED_DEPENDENCY_TOUCH_MAX).map(async (dependency) => {
|
|
21952
22418
|
let content;
|
|
21953
22419
|
try {
|
|
21954
|
-
content = await
|
|
22420
|
+
content = await fs13.readFile(dependency, "utf8");
|
|
21955
22421
|
} catch {
|
|
21956
22422
|
return;
|
|
21957
22423
|
}
|
|
@@ -22772,6 +23238,7 @@ export {
|
|
|
22772
23238
|
warmAnswerBinding,
|
|
22773
23239
|
readBoundToCurrentDisk,
|
|
22774
23240
|
SERVER_CONFIG_FILE_NAMES,
|
|
23241
|
+
BELOW_ROOT_CONFIG_FILE_NAMES,
|
|
22775
23242
|
LspRequestTimeoutError,
|
|
22776
23243
|
isLspRequestTimeoutError,
|
|
22777
23244
|
groupFilesByPrimaryServer,
|