pi-lens 4.2.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (671) hide show
  1. package/CHANGELOG.md +1562 -0
  2. package/README.md +157 -24
  3. package/config/dependency-cruiser-eager-allowlist.json +6 -2
  4. package/dist/chunk-22AVIGXS.js +560 -0
  5. package/dist/chunk-27BBHSZC.js +106 -0
  6. package/dist/chunk-2BEMIWEW.js +51 -0
  7. package/dist/chunk-2EECBNC5.js +89 -0
  8. package/dist/chunk-34U7PLGE.js +23 -0
  9. package/dist/chunk-3I5QFT3N.js +181 -0
  10. package/dist/chunk-3MED75HT.js +37 -0
  11. package/dist/chunk-47D2BO4S.js +87 -0
  12. package/dist/chunk-4RERDEXR.js +348 -0
  13. package/dist/chunk-4W2PLC4J.js +27 -0
  14. package/dist/chunk-52H5B5TC.js +202 -0
  15. package/dist/chunk-54B42YRX.js +27 -0
  16. package/dist/chunk-5RXBNSW2.js +266 -0
  17. package/dist/chunk-5THXD6X5.js +201 -0
  18. package/dist/chunk-5W3R6LFT.js +24 -0
  19. package/dist/chunk-5ZEJHV35.js +341 -0
  20. package/dist/chunk-6P62QVEA.js +118 -0
  21. package/dist/chunk-6QIUX4EP.js +459 -0
  22. package/dist/chunk-6VCD4VKZ.js +78 -0
  23. package/dist/chunk-7F72PXY2.js +326 -0
  24. package/dist/chunk-7FBF7NPR.js +998 -0
  25. package/dist/chunk-7U2IDNXN.js +37 -0
  26. package/dist/chunk-ABBOA7UD.js +157 -0
  27. package/dist/chunk-AHDW3GPE.js +50 -0
  28. package/dist/chunk-AJ3QXTRQ.js +756 -0
  29. package/dist/chunk-AJVLWNFN.js +1610 -0
  30. package/dist/chunk-AJXODZY6.js +112 -0
  31. package/dist/chunk-ARFCXG7S.js +84 -0
  32. package/dist/chunk-AS44CFQ4.js +708 -0
  33. package/dist/chunk-AWE5TMPO.js +38 -0
  34. package/dist/chunk-B3I2UUT4.js +4692 -0
  35. package/dist/chunk-BRJKOBZP.js +331 -0
  36. package/dist/chunk-BW5KFIQC.js +59 -0
  37. package/dist/chunk-C2AUYXQH.js +149 -0
  38. package/dist/chunk-CGGAIP7J.js +29 -0
  39. package/dist/chunk-D6QS3U6M.js +30 -0
  40. package/dist/chunk-DFVMIKMQ.js +349 -0
  41. package/dist/chunk-DIULIWKU.js +169 -0
  42. package/dist/chunk-DQ2NZ7C4.js +2317 -0
  43. package/dist/chunk-E2WFBRHM.js +213 -0
  44. package/dist/chunk-E4MAEDPM.js +50 -0
  45. package/dist/chunk-EOKRQ3SA.js +30 -0
  46. package/dist/chunk-F3AU2TMM.js +2626 -0
  47. package/dist/chunk-F3P7VQ7H.js +170 -0
  48. package/dist/chunk-FC4RP4I2.js +12 -0
  49. package/dist/chunk-FJNKANOS.js +32 -0
  50. package/dist/chunk-GUOGVTCQ.js +146 -0
  51. package/dist/chunk-GVXA6CCE.js +18 -0
  52. package/dist/chunk-HHYAELLJ.js +2334 -0
  53. package/dist/chunk-HMFXILPV.js +83 -0
  54. package/dist/chunk-HVUZXSWK.js +421 -0
  55. package/dist/chunk-HWBZIGMJ.js +62 -0
  56. package/dist/chunk-I3R7GKDR.js +17 -0
  57. package/dist/chunk-I7SPGOWI.js +55 -0
  58. package/dist/chunk-IIXOAGHR.js +38 -0
  59. package/dist/chunk-IVP5KAB7.js +2250 -0
  60. package/dist/chunk-IXEBJSUE.js +22 -0
  61. package/dist/chunk-JOLITGCC.js +27 -0
  62. package/dist/chunk-K6VYLB2U.js +145 -0
  63. package/dist/chunk-LJDODBBZ.js +78 -0
  64. package/dist/chunk-LNAKEO63.js +78 -0
  65. package/dist/chunk-LSMJ6KBE.js +4139 -0
  66. package/dist/chunk-LW6XKDZQ.js +5565 -0
  67. package/dist/chunk-N3YQJI6O.js +899 -0
  68. package/dist/chunk-NABLC7W3.js +148 -0
  69. package/dist/chunk-NKOUFPQF.js +659 -0
  70. package/dist/chunk-NL5GLMFI.js +211 -0
  71. package/dist/chunk-NMABWBZN.js +327 -0
  72. package/dist/chunk-NTHH2J74.js +27 -0
  73. package/dist/chunk-NTUJEGDZ.js +59 -0
  74. package/dist/chunk-NXL4FFQQ.js +47 -0
  75. package/dist/chunk-NXPS2L6U.js +466 -0
  76. package/dist/chunk-O5WILGMI.js +42 -0
  77. package/dist/chunk-O6TQT6RI.js +48 -0
  78. package/dist/chunk-OAXNDZJ7.js +323 -0
  79. package/dist/chunk-ODEEOXPH.js +44 -0
  80. package/dist/chunk-OQGFCZJ4.js +4533 -0
  81. package/dist/chunk-ORTMY4Q4.js +282 -0
  82. package/dist/chunk-OS32RNR2.js +442 -0
  83. package/dist/chunk-PAK6IDME.js +189 -0
  84. package/dist/chunk-PWFHBTSF.js +406 -0
  85. package/dist/chunk-Q5U6FMDI.js +2352 -0
  86. package/dist/chunk-QOZXJ4NA.js +3364 -0
  87. package/dist/chunk-QYF5S6P6.js +45 -0
  88. package/dist/chunk-RIISMHKN.js +36 -0
  89. package/dist/chunk-RPD4ZSB7.js +25 -0
  90. package/dist/chunk-RPD5K5NC.js +79 -0
  91. package/dist/chunk-RUOG5D2C.js +262 -0
  92. package/dist/chunk-T4ERT73Y.js +599 -0
  93. package/dist/chunk-T6D4Q4AQ.js +54 -0
  94. package/dist/chunk-TGPXLY2J.js +391 -0
  95. package/dist/chunk-TLGFBM3F.js +12116 -0
  96. package/dist/chunk-TO6WL3GM.js +88 -0
  97. package/dist/chunk-TT22N74J.js +517 -0
  98. package/dist/chunk-TVN5N6GY.js +21216 -0
  99. package/dist/chunk-U3VGR4VU.js +308 -0
  100. package/dist/chunk-UK3CMEAL.js +1250 -0
  101. package/dist/chunk-UOPVJQ4N.js +103 -0
  102. package/dist/chunk-UXVNL3D7.js +23 -0
  103. package/dist/chunk-UY752QSN.js +45 -0
  104. package/dist/chunk-V5PXFSZK.js +188 -0
  105. package/dist/chunk-V7R425XG.js +398 -0
  106. package/dist/chunk-VCSRSYLF.js +81 -0
  107. package/dist/chunk-VD4JQCQC.js +162 -0
  108. package/dist/chunk-VDBPVIKD.js +62 -0
  109. package/dist/chunk-VHQLPIRJ.js +114 -0
  110. package/dist/chunk-VN2AXLEX.js +5414 -0
  111. package/dist/chunk-VNMT7C64.js +478 -0
  112. package/dist/chunk-WONERJTP.js +309 -0
  113. package/dist/chunk-XECLWQZN.js +85 -0
  114. package/dist/chunk-XIMYZ3JA.js +27 -0
  115. package/dist/chunk-XK4CIILI.js +144 -0
  116. package/dist/chunk-Y4T27COV.js +562 -0
  117. package/dist/chunk-YGVYKNSN.js +1860 -0
  118. package/dist/chunk-YLF3PPT5.js +308 -0
  119. package/dist/chunk-YSNFMJKN.js +14 -0
  120. package/dist/chunk-Z3CCVDUB.js +76 -0
  121. package/dist/chunk-Z54ZSOBZ.js +61 -0
  122. package/dist/chunk-ZAWW3AF6.js +97 -0
  123. package/dist/chunk-ZMOL6RQC.js +167 -0
  124. package/dist/index.js +19039 -8956
  125. package/dist/mcp/analyze-cli.js +186 -228
  126. package/dist/mcp/cli.js +137 -98
  127. package/dist/mcp/server.js +22592 -1564
  128. package/dist/mcp/worker.js +97 -38
  129. package/dist/probes/installer.js +135 -0
  130. package/dist/workers/project-snapshot-persist-worker.js +22 -0
  131. package/dist/workers/review-graph-persist-worker.js +15 -0
  132. package/docs/adr/0001-stale-advisory-live-arm.md +29 -0
  133. package/docs/adr/0002-workspace-hash-rendezvous.md +30 -0
  134. package/docs/adr/0003-git-guard-latch-writer.md +203 -0
  135. package/docs/adr/0004-disposition-policy-seam.md +38 -0
  136. package/docs/adr/0005-tool-availability-enforcement-seam.md +29 -0
  137. package/docs/adr/0006-derived-state-benchmark-first.md +31 -0
  138. package/docs/adr/0007-end-to-end-witness-per-seam-slice.md +38 -0
  139. package/docs/adr/0008-turn-end-lane-interface.md +165 -0
  140. package/docs/adr/0009-reported-path-attribution.md +114 -0
  141. package/docs/adr/README.md +26 -0
  142. package/docs/agent-guide.md +13 -4
  143. package/docs/agent-tools.md +60 -1
  144. package/docs/ast-grep_rules_catalog.md +6 -4
  145. package/docs/configuration.md +75 -2
  146. package/docs/engineering-principles.md +202 -0
  147. package/docs/environment-variables.md +113 -6
  148. package/docs/features.md +10 -6
  149. package/docs/globalconfig.md +7 -1
  150. package/docs/io-bridge-v2-migration.md +94 -0
  151. package/docs/language-coverage.md +17 -0
  152. package/docs/lsp-capability-matrix.md +131 -32
  153. package/docs/lsp-idle-eviction.md +124 -0
  154. package/docs/mcp.md +21 -5
  155. package/docs/merge-queue-rollout.md +77 -0
  156. package/docs/pi-lens-fixer.md +161 -39
  157. package/docs/pi-lens-investigator.md +77 -20
  158. package/docs/pi-lens-merge-policy.md +694 -0
  159. package/docs/pi-lens-monitor.md +73 -7
  160. package/docs/pi-lens-retro.md +6 -4
  161. package/docs/pi-lens-reviewer.md +190 -34
  162. package/docs/pi-lens-subagent.md +247 -37
  163. package/docs/pi-lens-warden.md +18 -7
  164. package/docs/public-api-stability.md +56 -0
  165. package/docs/release-qa-baseline.md +86 -17
  166. package/docs/rfcs/3654-unified-io-bridge-v2.md +316 -0
  167. package/docs/servercapabilities.md +66 -52
  168. package/docs/settings.md +13 -3
  169. package/docs/subagent-compat.md +1 -1
  170. package/docs/usage.md +5 -1
  171. package/grammars/tree-sitter-bash.wasm +0 -0
  172. package/grammars/tree-sitter-bash.wasm.json +3 -3
  173. package/package.json +23 -9
  174. package/rules/ast-grep-rules/rule-tests/advisory-registry-subset-test.yml +41 -0
  175. package/rules/ast-grep-rules/rule-tests/no-assert-tuple-test.yml +13 -0
  176. package/rules/ast-grep-rules/rule-tests/no-boolean-in-except-test.yml +26 -0
  177. package/rules/ast-grep-rules/rule-tests/no-http-headers-bracket-access-test.yml +10 -0
  178. package/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +18 -0
  179. package/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-python-test.yml +4 -3
  180. package/rules/ast-grep-rules/rules/advisory-registry-subset.yml +50 -0
  181. package/rules/ast-grep-rules/rules/go-no-fmt-println.yml +2 -2
  182. package/rules/ast-grep-rules/rules/no-assert-tuple.yml +23 -13
  183. package/rules/ast-grep-rules/rules/no-boolean-in-except.yml +7 -3
  184. package/rules/ast-grep-rules/rules/no-console-except-error-js.yml +2 -2
  185. package/rules/ast-grep-rules/rules/no-console-except-error.yml +2 -2
  186. package/rules/ast-grep-rules/rules/no-http-headers-bracket-access.yml +12 -7
  187. package/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +44 -0
  188. package/rules/ast-grep-rules/rules/unchecked-throwing-call-python.yml +5 -3
  189. package/rules/tree-sitter-queries/typescript/console-statement.yml +2 -2
  190. package/scripts/analyze-pi-lens-logs.mjs +1275 -62
  191. package/scripts/download-grammars.js +5 -0
  192. package/scripts/grammars.lock.json +6 -1
  193. package/scripts/install-selftest.mjs +38 -35
  194. package/scripts/lib/host-provided-deps.mjs +13 -4
  195. package/scripts/lib/web-tree-sitter-dir.mjs +141 -0
  196. package/dist/clients/actionable-warnings-logger.js +0 -35
  197. package/dist/clients/actionable-warnings.js +0 -1594
  198. package/dist/clients/advisory-provenance.js +0 -457
  199. package/dist/clients/agent-behavior-client.js +0 -147
  200. package/dist/clients/agent-nudge.js +0 -325
  201. package/dist/clients/analysed-root.js +0 -1
  202. package/dist/clients/ast-grep-client.js +0 -731
  203. package/dist/clients/ast-grep-rule-manager.js +0 -146
  204. package/dist/clients/ast-grep-tool-logger.js +0 -118
  205. package/dist/clients/ast-grep-types.js +0 -10
  206. package/dist/clients/ast-grep-yaml-synth.js +0 -154
  207. package/dist/clients/atomic-write-staging.js +0 -75
  208. package/dist/clients/atomic-write.js +0 -189
  209. package/dist/clients/availability-probe-flight.js +0 -12
  210. package/dist/clients/bash-file-access.js +0 -1056
  211. package/dist/clients/biome-client.js +0 -357
  212. package/dist/clients/blocker-freshness.js +0 -837
  213. package/dist/clients/blocker-past-eof.js +0 -129
  214. package/dist/clients/bootstrap.js +0 -569
  215. package/dist/clients/bounded-cache.js +0 -190
  216. package/dist/clients/bounded-pid-file-lock.js +0 -202
  217. package/dist/clients/bounded-telemetry.js +0 -295
  218. package/dist/clients/build-identity.js +0 -95
  219. package/dist/clients/bundled-resource-health.js +0 -113
  220. package/dist/clients/bus-events-logger.js +0 -105
  221. package/dist/clients/bus-publish.js +0 -171
  222. package/dist/clients/cache/rule-cache.js +0 -190
  223. package/dist/clients/cache-manager.js +0 -465
  224. package/dist/clients/cache-observability.js +0 -1313
  225. package/dist/clients/call-graph.js +0 -852
  226. package/dist/clients/cargo-manifest.js +0 -422
  227. package/dist/clients/cascade-budget.js +0 -196
  228. package/dist/clients/cascade-format.js +0 -315
  229. package/dist/clients/cascade-logger.js +0 -31
  230. package/dist/clients/cascade-types.js +0 -9
  231. package/dist/clients/child-unref.js +0 -115
  232. package/dist/clients/code-quality-warnings.js +0 -286
  233. package/dist/clients/codebase-model.js +0 -173
  234. package/dist/clients/collateral-test-role.js +0 -40
  235. package/dist/clients/complexity-client.js +0 -462
  236. package/dist/clients/config-core/deny.js +0 -221
  237. package/dist/clients/config-core/index.js +0 -50
  238. package/dist/clients/config-core/merge.js +0 -357
  239. package/dist/clients/config-core/normalize.js +0 -340
  240. package/dist/clients/config-core/process-spec.js +0 -248
  241. package/dist/clients/config-core/provenance.js +0 -164
  242. package/dist/clients/config-core/records.js +0 -218
  243. package/dist/clients/config-core/resolve.js +0 -125
  244. package/dist/clients/config-core/safe-object.js +0 -78
  245. package/dist/clients/config-core/schema.js +0 -165
  246. package/dist/clients/config-diagnostic-codes.js +0 -283
  247. package/dist/clients/config-locations.js +0 -160
  248. package/dist/clients/config-resolve.js +0 -792
  249. package/dist/clients/config-schema.js +0 -251
  250. package/dist/clients/config-warn.js +0 -407
  251. package/dist/clients/console-guard-install.js +0 -26
  252. package/dist/clients/cooperative-budget.js +0 -42
  253. package/dist/clients/dead-code-client.js +0 -510
  254. package/dist/clients/dead-code-logger.js +0 -30
  255. package/dist/clients/deadline-utils.js +0 -280
  256. package/dist/clients/debug-handles.js +0 -211
  257. package/dist/clients/debug-heap.js +0 -174
  258. package/dist/clients/deferred-lsp-work.js +0 -106
  259. package/dist/clients/degradation-ledger.js +0 -396
  260. package/dist/clients/demoted-finding-render.js +0 -169
  261. package/dist/clients/dependency-checker.js +0 -862
  262. package/dist/clients/deps/ast-grep-napi.js +0 -22
  263. package/dist/clients/deps/js-yaml.js +0 -9
  264. package/dist/clients/deps/minimatch.js +0 -4
  265. package/dist/clients/deps/pi-tui.js +0 -14
  266. package/dist/clients/deps/typebox.js +0 -14
  267. package/dist/clients/deps/vscode-jsonrpc.js +0 -1
  268. package/dist/clients/deps/web-tree-sitter.js +0 -24
  269. package/dist/clients/diagnostic-dispositions.js +0 -594
  270. package/dist/clients/diagnostic-line-freshness.js +0 -305
  271. package/dist/clients/diagnostic-logger.js +0 -73
  272. package/dist/clients/diagnostic-tracker.js +0 -105
  273. package/dist/clients/diagnostics-publish.js +0 -230
  274. package/dist/clients/dispatch/ast-grep-catalog.js +0 -65
  275. package/dist/clients/dispatch/auxiliary-lsp.js +0 -343
  276. package/dist/clients/dispatch/collect-later-tier.js +0 -35
  277. package/dist/clients/dispatch/diagnostic-taxonomy.js +0 -66
  278. package/dist/clients/dispatch/dispatcher.js +0 -1269
  279. package/dist/clients/dispatch/fact-provider-types.js +0 -1
  280. package/dist/clients/dispatch/fact-rule-runner.js +0 -17
  281. package/dist/clients/dispatch/fact-runner.js +0 -30
  282. package/dist/clients/dispatch/fact-scheduler.js +0 -68
  283. package/dist/clients/dispatch/fact-store.js +0 -377
  284. package/dist/clients/dispatch/facts/comment-facts.js +0 -22
  285. package/dist/clients/dispatch/facts/file-content.js +0 -19
  286. package/dist/clients/dispatch/facts/function-facts.js +0 -348
  287. package/dist/clients/dispatch/facts/import-facts.js +0 -204
  288. package/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -34
  289. package/dist/clients/dispatch/facts/try-catch-facts.js +0 -119
  290. package/dist/clients/dispatch/finding-policy.js +0 -222
  291. package/dist/clients/dispatch/indent-detect.js +0 -411
  292. package/dist/clients/dispatch/inline-suppressions.js +0 -70
  293. package/dist/clients/dispatch/integration.js +0 -2377
  294. package/dist/clients/dispatch/lazy.js +0 -11
  295. package/dist/clients/dispatch/pending-runner-findings.js +0 -87
  296. package/dist/clients/dispatch/plan.js +0 -278
  297. package/dist/clients/dispatch/priorities.js +0 -20
  298. package/dist/clients/dispatch/rule-id-normalize.js +0 -50
  299. package/dist/clients/dispatch/rule-ignores.js +0 -62
  300. package/dist/clients/dispatch/rule-policy.js +0 -135
  301. package/dist/clients/dispatch/rules/async-noise.js +0 -40
  302. package/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
  303. package/dist/clients/dispatch/rules/cors-wildcard.js +0 -54
  304. package/dist/clients/dispatch/rules/error-obscuring.js +0 -32
  305. package/dist/clients/dispatch/rules/error-swallowing.js +0 -31
  306. package/dist/clients/dispatch/rules/framework-call-noise.js +0 -67
  307. package/dist/clients/dispatch/rules/high-complexity.js +0 -72
  308. package/dist/clients/dispatch/rules/high-fan-out.js +0 -74
  309. package/dist/clients/dispatch/rules/high-import-coupling.js +0 -37
  310. package/dist/clients/dispatch/rules/missing-error-propagation.js +0 -62
  311. package/dist/clients/dispatch/rules/no-commented-credentials.js +0 -52
  312. package/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -42
  313. package/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
  314. package/dist/clients/dispatch/rules/unsafe-boundary.js +0 -126
  315. package/dist/clients/dispatch/runner-context.js +0 -52
  316. package/dist/clients/dispatch/runners/actionlint.js +0 -113
  317. package/dist/clients/dispatch/runners/ast-grep-napi.js +0 -1196
  318. package/dist/clients/dispatch/runners/biome-check.js +0 -283
  319. package/dist/clients/dispatch/runners/cpp-check.js +0 -236
  320. package/dist/clients/dispatch/runners/credo.js +0 -80
  321. package/dist/clients/dispatch/runners/cue-vet.js +0 -398
  322. package/dist/clients/dispatch/runners/dart-analyze.js +0 -202
  323. package/dist/clients/dispatch/runners/detekt.js +0 -169
  324. package/dist/clients/dispatch/runners/dotnet-build.js +0 -159
  325. package/dist/clients/dispatch/runners/elixir-check.js +0 -210
  326. package/dist/clients/dispatch/runners/eslint.js +0 -154
  327. package/dist/clients/dispatch/runners/fact-rules.js +0 -29
  328. package/dist/clients/dispatch/runners/fish-indent.js +0 -69
  329. package/dist/clients/dispatch/runners/gleam-check.js +0 -87
  330. package/dist/clients/dispatch/runners/go-vet.js +0 -90
  331. package/dist/clients/dispatch/runners/golangci-lint.js +0 -120
  332. package/dist/clients/dispatch/runners/hadolint.js +0 -79
  333. package/dist/clients/dispatch/runners/helm-lint.js +0 -171
  334. package/dist/clients/dispatch/runners/helm-render.js +0 -940
  335. package/dist/clients/dispatch/runners/htmlhint.js +0 -108
  336. package/dist/clients/dispatch/runners/index.js +0 -108
  337. package/dist/clients/dispatch/runners/javac.js +0 -89
  338. package/dist/clients/dispatch/runners/ktlint.js +0 -136
  339. package/dist/clients/dispatch/runners/lsp.js +0 -378
  340. package/dist/clients/dispatch/runners/markdownlint.js +0 -160
  341. package/dist/clients/dispatch/runners/mypy.js +0 -101
  342. package/dist/clients/dispatch/runners/oxlint.js +0 -398
  343. package/dist/clients/dispatch/runners/php-lint.js +0 -62
  344. package/dist/clients/dispatch/runners/phpstan.js +0 -120
  345. package/dist/clients/dispatch/runners/prisma-validate.js +0 -62
  346. package/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -445
  347. package/dist/clients/dispatch/runners/pyright.js +0 -169
  348. package/dist/clients/dispatch/runners/rubocop.js +0 -90
  349. package/dist/clients/dispatch/runners/ruff.js +0 -89
  350. package/dist/clients/dispatch/runners/rust-clippy.js +0 -251
  351. package/dist/clients/dispatch/runners/shellcheck.js +0 -169
  352. package/dist/clients/dispatch/runners/shfmt.js +0 -102
  353. package/dist/clients/dispatch/runners/spellcheck.js +0 -121
  354. package/dist/clients/dispatch/runners/spotbugs.js +0 -259
  355. package/dist/clients/dispatch/runners/sqlfluff.js +0 -174
  356. package/dist/clients/dispatch/runners/stylelint.js +0 -158
  357. package/dist/clients/dispatch/runners/swiftlint.js +0 -154
  358. package/dist/clients/dispatch/runners/taplo.js +0 -168
  359. package/dist/clients/dispatch/runners/terragrunt.js +0 -168
  360. package/dist/clients/dispatch/runners/tflint.js +0 -110
  361. package/dist/clients/dispatch/runners/tree-sitter.js +0 -620
  362. package/dist/clients/dispatch/runners/trivy-config.js +0 -247
  363. package/dist/clients/dispatch/runners/utils/availability-policy.js +0 -496
  364. package/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -90
  365. package/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -85
  366. package/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -274
  367. package/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1701
  368. package/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -101
  369. package/dist/clients/dispatch/runners/utils/tool-failure.js +0 -235
  370. package/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -169
  371. package/dist/clients/dispatch/runners/utils.js +0 -15
  372. package/dist/clients/dispatch/runners/vale.js +0 -116
  373. package/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -242
  374. package/dist/clients/dispatch/runners/yamllint.js +0 -85
  375. package/dist/clients/dispatch/runners/zig-check.js +0 -91
  376. package/dist/clients/dispatch/suppress-writer.js +0 -69
  377. package/dist/clients/dispatch/tool-profile.js +0 -30
  378. package/dist/clients/dispatch/types.js +0 -21
  379. package/dist/clients/dispatch/utils/format-utils.js +0 -45
  380. package/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -35
  381. package/dist/clients/disposition-logger.js +0 -32
  382. package/dist/clients/disposition-publish.js +0 -124
  383. package/dist/clients/durable-store.js +0 -97
  384. package/dist/clients/effective-config.js +0 -413
  385. package/dist/clients/env-utils.js +0 -83
  386. package/dist/clients/error-class.js +0 -23
  387. package/dist/clients/eval-timestamp.js +0 -17
  388. package/dist/clients/event-loop-hold.js +0 -274
  389. package/dist/clients/event-loop-monitor.js +0 -250
  390. package/dist/clients/extension-log.js +0 -504
  391. package/dist/clients/extension-mode.js +0 -73
  392. package/dist/clients/feature-hints.js +0 -103
  393. package/dist/clients/file-kinds.js +0 -412
  394. package/dist/clients/file-role.js +0 -134
  395. package/dist/clients/file-time.js +0 -160
  396. package/dist/clients/file-utils.js +0 -1032
  397. package/dist/clients/finding-delivery-gate.js +0 -463
  398. package/dist/clients/finding-identity.js +0 -88
  399. package/dist/clients/fix-worklog.js +0 -103
  400. package/dist/clients/format-events-publish.js +0 -343
  401. package/dist/clients/format-service.js +0 -222
  402. package/dist/clients/formatters-lazy.js +0 -9
  403. package/dist/clients/formatters.js +0 -1994
  404. package/dist/clients/freshness-cadence.js +0 -17
  405. package/dist/clients/freshness.js +0 -38
  406. package/dist/clients/generated-artifacts.js +0 -394
  407. package/dist/clients/generation-guard.js +0 -215
  408. package/dist/clients/git-guard.js +0 -923
  409. package/dist/clients/git-tracked-ignore.js +0 -243
  410. package/dist/clients/gitleaks-client.js +0 -509
  411. package/dist/clients/go-client.js +0 -104
  412. package/dist/clients/govulncheck-client.js +0 -605
  413. package/dist/clients/gradle-ktfmt-style.js +0 -252
  414. package/dist/clients/grammar-source.js +0 -465
  415. package/dist/clients/gzip-stage-write.js +0 -135
  416. package/dist/clients/hashline-anchor.js +0 -424
  417. package/dist/clients/hook-budgets.js +0 -76
  418. package/dist/clients/host-edit-normalize.js +0 -140
  419. package/dist/clients/host-ports.js +0 -39
  420. package/dist/clients/indent-retarget.js +0 -154
  421. package/dist/clients/install-diagnostics.js +0 -143
  422. package/dist/clients/installer/index.js +0 -5167
  423. package/dist/clients/installer/managed-tool-refresh-session.js +0 -58
  424. package/dist/clients/installer/managed-tool-refresh.js +0 -783
  425. package/dist/clients/instance-reaper-state.js +0 -7
  426. package/dist/clients/instance-reaper.js +0 -1137
  427. package/dist/clients/instance-registry-lock.js +0 -145
  428. package/dist/clients/instance-registry.js +0 -773
  429. package/dist/clients/jscpd-client.js +0 -370
  430. package/dist/clients/json-cache-read.js +0 -65
  431. package/dist/clients/knip-client.js +0 -788
  432. package/dist/clients/language-policy.js +0 -252
  433. package/dist/clients/language-profile.js +0 -361
  434. package/dist/clients/language-registry.js +0 -603
  435. package/dist/clients/latency-logger.js +0 -719
  436. package/dist/clients/lazy-import.js +0 -21
  437. package/dist/clients/ledger-bounds.js +0 -54
  438. package/dist/clients/lens-config.js +0 -346
  439. package/dist/clients/lens-engine.js +0 -358
  440. package/dist/clients/lens-events.js +0 -125
  441. package/dist/clients/lens-flag-registry.js +0 -467
  442. package/dist/clients/lens-map.js +0 -1156
  443. package/dist/clients/live-bus-emitter.js +0 -74
  444. package/dist/clients/log-cleanup.js +0 -222
  445. package/dist/clients/lsp/aggregation.js +0 -178
  446. package/dist/clients/lsp/cascade-tier.js +0 -421
  447. package/dist/clients/lsp/client.js +0 -4465
  448. package/dist/clients/lsp/config.js +0 -689
  449. package/dist/clients/lsp/diagnostic-binding.js +0 -225
  450. package/dist/clients/lsp/document-drift.js +0 -467
  451. package/dist/clients/lsp/edits.js +0 -1219
  452. package/dist/clients/lsp/index.js +0 -8305
  453. package/dist/clients/lsp/inferred-project.js +0 -216
  454. package/dist/clients/lsp/jvm-runtime.js +0 -298
  455. package/dist/clients/lsp/language.js +0 -63
  456. package/dist/clients/lsp/launch.js +0 -725
  457. package/dist/clients/lsp/lombok.js +0 -158
  458. package/dist/clients/lsp/path-utils.js +0 -5
  459. package/dist/clients/lsp/pending-aux-coverage.js +0 -251
  460. package/dist/clients/lsp/position-encoding.js +0 -61
  461. package/dist/clients/lsp/ruby-drive-dirs.js +0 -83
  462. package/dist/clients/lsp/server.js +0 -3209
  463. package/dist/clients/lsp/session-roots.js +0 -192
  464. package/dist/clients/lsp/spawn-history.js +0 -17
  465. package/dist/clients/lsp/sync-kind.js +0 -42
  466. package/dist/clients/lsp/tsserver-sync.js +0 -332
  467. package/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
  468. package/dist/clients/lsp/wait-policy/classification.js +0 -85
  469. package/dist/clients/lsp/wait-policy/index.js +0 -10
  470. package/dist/clients/lsp/wait-policy/strategies.js +0 -303
  471. package/dist/clients/lsp/watch-queue.js +0 -61
  472. package/dist/clients/lsp/workspace-diagnostics-cache.js +0 -639
  473. package/dist/clients/lsp/workspace-diagnostics-session.js +0 -30
  474. package/dist/clients/lsp/workspace-sweep-hold.js +0 -184
  475. package/dist/clients/lsp-budget.js +0 -186
  476. package/dist/clients/lsp-document-symbols.js +0 -110
  477. package/dist/clients/lsp-lazy.js +0 -9
  478. package/dist/clients/lsp-mutation.js +0 -396
  479. package/dist/clients/lsp-status.js +0 -59
  480. package/dist/clients/map-with-concurrency.js +0 -40
  481. package/dist/clients/mcp/analyze.js +0 -420
  482. package/dist/clients/mcp/host-shim.js +0 -31
  483. package/dist/clients/mcp/ipc.js +0 -335
  484. package/dist/clients/mcp/review.js +0 -151
  485. package/dist/clients/mcp/session.js +0 -412
  486. package/dist/clients/memory-sampler.js +0 -208
  487. package/dist/clients/message-end-attribution.js +0 -30
  488. package/dist/clients/metrics-client.js +0 -107
  489. package/dist/clients/metrics-history.js +0 -327
  490. package/dist/clients/middle-man-analysis.js +0 -263
  491. package/dist/clients/model-provider.js +0 -53
  492. package/dist/clients/module-report-lsp.js +0 -189
  493. package/dist/clients/module-report.js +0 -2150
  494. package/dist/clients/mutating-tool.js +0 -651
  495. package/dist/clients/mutation-attribution.js +0 -368
  496. package/dist/clients/mutation-bridge.js +0 -240
  497. package/dist/clients/ndjson-logger.js +0 -734
  498. package/dist/clients/observed-mutation-sources.js +0 -101
  499. package/dist/clients/observed-mutation.js +0 -1253
  500. package/dist/clients/oldtext-autopatch.js +0 -128
  501. package/dist/clients/opaque-mutation-scan.js +0 -496
  502. package/dist/clients/opengrep-client.js +0 -328
  503. package/dist/clients/opengrep-config.js +0 -76
  504. package/dist/clients/package-manager.js +0 -607
  505. package/dist/clients/package-root.js +0 -38
  506. package/dist/clients/partial-edit-apply.js +0 -439
  507. package/dist/clients/path-attribution-telemetry.js +0 -43
  508. package/dist/clients/path-keyed-map.js +0 -108
  509. package/dist/clients/path-utils.js +0 -1244
  510. package/dist/clients/performance-report.js +0 -331
  511. package/dist/clients/persist-debounce.js +0 -70
  512. package/dist/clients/persistent-reverify.js +0 -271
  513. package/dist/clients/php-cs-fixer-config.js +0 -119
  514. package/dist/clients/pipeline.js +0 -1425
  515. package/dist/clients/post-autofix-notice.js +0 -37
  516. package/dist/clients/print-mode.js +0 -21
  517. package/dist/clients/probe-home-state.js +0 -228
  518. package/dist/clients/process-bridge.js +0 -66
  519. package/dist/clients/process-singletons.js +0 -210
  520. package/dist/clients/process-snapshot.js +0 -68
  521. package/dist/clients/project-changes.js +0 -181
  522. package/dist/clients/project-conventions.js +0 -171
  523. package/dist/clients/project-diagnostics/cache.js +0 -137
  524. package/dist/clients/project-diagnostics/extractors.js +0 -109
  525. package/dist/clients/project-diagnostics/fresh-fetch.js +0 -650
  526. package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -118
  527. package/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -47
  528. package/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -40
  529. package/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -34
  530. package/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -38
  531. package/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -47
  532. package/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -48
  533. package/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -40
  534. package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -127
  535. package/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -81
  536. package/dist/clients/project-diagnostics/scanner.js +0 -520
  537. package/dist/clients/project-diagnostics/types.js +0 -1
  538. package/dist/clients/project-lens-config.js +0 -799
  539. package/dist/clients/project-report.js +0 -701
  540. package/dist/clients/project-scale.js +0 -237
  541. package/dist/clients/project-scan-policy.js +0 -11
  542. package/dist/clients/project-snapshot-fingerprint.js +0 -48
  543. package/dist/clients/project-snapshot-persist-worker.js +0 -20
  544. package/dist/clients/project-snapshot.js +0 -1653
  545. package/dist/clients/project-trust.js +0 -181
  546. package/dist/clients/python-environment.js +0 -217
  547. package/dist/clients/python-provenance.js +0 -639
  548. package/dist/clients/quiet-window-config.js +0 -47
  549. package/dist/clients/quiet-window.js +0 -236
  550. package/dist/clients/read-bridge.js +0 -139
  551. package/dist/clients/read-expansion.js +0 -266
  552. package/dist/clients/read-guard-logger.js +0 -251
  553. package/dist/clients/read-guard-tool-lines.js +0 -1306
  554. package/dist/clients/read-guard.js +0 -1561
  555. package/dist/clients/recent-touches.js +0 -240
  556. package/dist/clients/redact/secrets.js +0 -449
  557. package/dist/clients/resource-sampler.js +0 -628
  558. package/dist/clients/reverse-deps.js +0 -270
  559. package/dist/clients/review-graph/builder.js +0 -5118
  560. package/dist/clients/review-graph/format.js +0 -33
  561. package/dist/clients/review-graph/git-identity.js +0 -157
  562. package/dist/clients/review-graph/import-resolvers.js +0 -481
  563. package/dist/clients/review-graph/persist-worker.js +0 -10
  564. package/dist/clients/review-graph/query.js +0 -244
  565. package/dist/clients/review-graph/revision-drift.js +0 -21
  566. package/dist/clients/review-graph/service.js +0 -96
  567. package/dist/clients/review-graph/shared-extraction-ir.js +0 -82
  568. package/dist/clients/review-graph/symbol-id.js +0 -103
  569. package/dist/clients/review-graph/tsconfig-paths.js +0 -299
  570. package/dist/clients/review-graph/types.js +0 -1
  571. package/dist/clients/review-graph/workspace-modules.js +0 -449
  572. package/dist/clients/review-graph-logger.js +0 -81
  573. package/dist/clients/ruff-client.js +0 -152
  574. package/dist/clients/rules-scanner.js +0 -131
  575. package/dist/clients/run-duration.js +0 -55
  576. package/dist/clients/runtime-agent-end.js +0 -746
  577. package/dist/clients/runtime-config.js +0 -77
  578. package/dist/clients/runtime-context.js +0 -211
  579. package/dist/clients/runtime-coordinator.js +0 -1290
  580. package/dist/clients/runtime-session.js +0 -2485
  581. package/dist/clients/runtime-tool-call.js +0 -1284
  582. package/dist/clients/runtime-tool-result.js +0 -2034
  583. package/dist/clients/runtime-turn.js +0 -3600
  584. package/dist/clients/rust-client.js +0 -97
  585. package/dist/clients/safe-spawn.js +0 -2166
  586. package/dist/clients/sanitize.js +0 -286
  587. package/dist/clients/scan-utils.js +0 -25
  588. package/dist/clients/scratch-tree-policy.js +0 -165
  589. package/dist/clients/search-read-registration.js +0 -94
  590. package/dist/clients/secret-findings.js +0 -114
  591. package/dist/clients/security-scan-client.js +0 -352
  592. package/dist/clients/session-event-guard.js +0 -297
  593. package/dist/clients/session-lifecycle.js +0 -484
  594. package/dist/clients/session-start-observability.js +0 -94
  595. package/dist/clients/session-state-store.js +0 -101
  596. package/dist/clients/session-summary.js +0 -15
  597. package/dist/clients/sessionstart-logger.js +0 -27
  598. package/dist/clients/sg-runner.js +0 -876
  599. package/dist/clients/sgconfig.js +0 -347
  600. package/dist/clients/shared-checkout-guard.js +0 -338
  601. package/dist/clients/single-flight.js +0 -158
  602. package/dist/clients/situational-tool-telemetry.js +0 -108
  603. package/dist/clients/skills-resolver.js +0 -141
  604. package/dist/clients/slow-fs.js +0 -138
  605. package/dist/clients/smells-rollup.js +0 -231
  606. package/dist/clients/source-filter.js +0 -596
  607. package/dist/clients/source-walker.js +0 -211
  608. package/dist/clients/spawn-output-cap.js +0 -37
  609. package/dist/clients/spawn-timeout-cooldown.js +0 -110
  610. package/dist/clients/stale-marker.js +0 -17
  611. package/dist/clients/startup-scan.js +0 -400
  612. package/dist/clients/startup-timing.js +0 -130
  613. package/dist/clients/string-utils.js +0 -33
  614. package/dist/clients/subagent-mode.js +0 -111
  615. package/dist/clients/symbol-containment.js +0 -24
  616. package/dist/clients/symbol-types.js +0 -5
  617. package/dist/clients/test-runner-client.js +0 -2507
  618. package/dist/clients/test-runner-delivery.js +0 -287
  619. package/dist/clients/todo-scanner.js +0 -229
  620. package/dist/clients/tool-agreement.js +0 -423
  621. package/dist/clients/tool-config.js +0 -249
  622. package/dist/clients/tool-cwd.js +0 -270
  623. package/dist/clients/tool-definition.js +0 -47
  624. package/dist/clients/tool-event.js +0 -105
  625. package/dist/clients/tool-policy.js +0 -2755
  626. package/dist/clients/tool-probe.js +0 -53
  627. package/dist/clients/tool-render.js +0 -156
  628. package/dist/clients/tool-set-policy.js +0 -118
  629. package/dist/clients/tree-sitter-cache.js +0 -364
  630. package/dist/clients/tree-sitter-client.js +0 -4134
  631. package/dist/clients/tree-sitter-logger.js +0 -100
  632. package/dist/clients/tree-sitter-navigator.js +0 -269
  633. package/dist/clients/tree-sitter-query-loader.js +0 -569
  634. package/dist/clients/tree-sitter-shared.js +0 -158
  635. package/dist/clients/tree-sitter-symbol-extractor.js +0 -1265
  636. package/dist/clients/trivy-client.js +0 -467
  637. package/dist/clients/tui-fit.js +0 -50
  638. package/dist/clients/turn-context.js +0 -52
  639. package/dist/clients/turn-summary-render.js +0 -72
  640. package/dist/clients/turn-summary.js +0 -132
  641. package/dist/clients/typos-config.js +0 -29
  642. package/dist/clients/user-notify.js +0 -51
  643. package/dist/clients/vanished-instance-marker.js +0 -57
  644. package/dist/clients/warm-attach.js +0 -246
  645. package/dist/clients/widget-state.js +0 -1677
  646. package/dist/clients/word-index-logger.js +0 -49
  647. package/dist/clients/word-index-store.js +0 -459
  648. package/dist/clients/word-index.js +0 -2080
  649. package/dist/clients/workspace-topology.js +0 -389
  650. package/dist/clients/write-ordering-guard.js +0 -65
  651. package/dist/clients/zizmor-config.js +0 -327
  652. package/dist/i18n.js +0 -69
  653. package/dist/mcp/build-staleness.js +0 -124
  654. package/dist/scripts/lib/process-scan.mjs +0 -583
  655. package/dist/scripts/lib/skills-predicate.mjs +0 -129
  656. package/dist/tools/activate-tools.js +0 -87
  657. package/dist/tools/ast-grep-outline.js +0 -137
  658. package/dist/tools/ast-grep-replace.js +0 -244
  659. package/dist/tools/ast-grep-search.js +0 -762
  660. package/dist/tools/effective-config.js +0 -90
  661. package/dist/tools/lens-diagnostic-mark.js +0 -375
  662. package/dist/tools/lens-diagnostics.js +0 -2544
  663. package/dist/tools/lsp-diagnostics.js +0 -1634
  664. package/dist/tools/lsp-navigation.js +0 -1367
  665. package/dist/tools/lsp-structured-output.js +0 -294
  666. package/dist/tools/module-report.js +0 -382
  667. package/dist/tools/project-report.js +0 -86
  668. package/dist/tools/render-compact.js +0 -374
  669. package/dist/tools/scan-progress.js +0 -53
  670. package/dist/tools/shared.js +0 -29
  671. package/dist/tools/symbol-search.js +0 -155
@@ -0,0 +1,2317 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+ import {
3
+ CANONICAL_GLOBAL_CONFIG_FILE,
4
+ CANONICAL_PROJECT_CONFIG_FILE,
5
+ FRESHNESS_CADENCE_MS,
6
+ GLOBAL_CONFIG_LOCATIONS,
7
+ LEGACY_ROOT_LSP_KEYS,
8
+ LSP_NAMESPACE_KEY,
9
+ PROJECT_CONFIG_BASENAMES,
10
+ PROJECT_CONFIG_LOCATIONS,
11
+ configSearchDirs,
12
+ dirMtimesStillFresh,
13
+ errorClassName,
14
+ findPiLensConfigMarkerInDir,
15
+ getPiLensGlobalConfigPath,
16
+ isResolvedGlobalConfigPath
17
+ } from "./chunk-VNMT7C64.js";
18
+ import {
19
+ DEGRADATION_ENTRIES_PER_KIND,
20
+ GLOBAL_NON_FLAG_CONFIG_SECTIONS,
21
+ GLOBAL_ONLY_NON_FLAG_KEYS,
22
+ LENS_FLAGS,
23
+ LENS_TOOL_NAMES,
24
+ PROJECT_FOREIGN_CONFIG_NAMESPACES,
25
+ PROJECT_FOREIGN_NAMESPACE_HONORED_KEYS,
26
+ PROJECT_NON_FLAG_CONFIG_SECTIONS,
27
+ PROJECT_SCOPED_LENS_FLAGS,
28
+ assignFlagConfigSection,
29
+ flagConfigSectionKeys,
30
+ hasFlagConfigPath,
31
+ readFlagConfigValue,
32
+ readToolConfig,
33
+ recordDegradationOnce
34
+ } from "./chunk-N3YQJI6O.js";
35
+ import {
36
+ logExtension
37
+ } from "./chunk-O6TQT6RI.js";
38
+ import {
39
+ CONFIG_SCHEMA_ANCHOR_KEY,
40
+ CONFIG_SCHEMA_ID,
41
+ DEPRECATED_CONFIG_SURFACES,
42
+ STABILITY_TIER_KEY,
43
+ withConfigDiagnosticCode
44
+ } from "./chunk-5THXD6X5.js";
45
+ import {
46
+ redactSecrets,
47
+ toPositiveFinite
48
+ } from "./chunk-UK3CMEAL.js";
49
+ import {
50
+ BoundedLruCache
51
+ } from "./chunk-ABBOA7UD.js";
52
+ import {
53
+ homeRelativePath,
54
+ isAtOrAboveHomeDir,
55
+ isWindowsPath,
56
+ walkUpDirs
57
+ } from "./chunk-Q5U6FMDI.js";
58
+
59
+ // dist/clients/generated-artifacts.js
60
+ import * as fs from "node:fs";
61
+ import * as path from "node:path";
62
+ var DEFAULT_HEADER_BYTES = 4096;
63
+ var GENERATED_DIR_NAMES = /* @__PURE__ */ new Set([
64
+ "generated",
65
+ "__generated__",
66
+ "codegen",
67
+ "__codegen__",
68
+ "generated-sources",
69
+ "generated_sources",
70
+ "dist",
71
+ "openapi-generated",
72
+ ".openapi-generator"
73
+ ]);
74
+ var GENERATED_HEADER_PATTERNS = [
75
+ /@generated\b/i,
76
+ /@ts-nocheck\b/i,
77
+ /\bcode generated\b/i,
78
+ /\bdo not edit\b/i,
79
+ /\bautomatically generated\b/i,
80
+ /\bthis file was generated\b/i,
81
+ /\bgenerated by protoc\b/i,
82
+ /\bgenerated by graphql-code-generator\b/i,
83
+ /\bgenerated by openapi-generator\b/i,
84
+ /\bgenerated by swagger codegen\b/i
85
+ ];
86
+ var LOCKFILE_NAMES = /* @__PURE__ */ new Set([
87
+ "package-lock.json",
88
+ "packages.lock.json",
89
+ "npm-shrinkwrap.json",
90
+ "pnpm-lock.yaml",
91
+ "yarn.lock",
92
+ "bun.lock",
93
+ "cargo.lock",
94
+ "composer.lock",
95
+ "gemfile.lock",
96
+ "poetry.lock",
97
+ "uv.lock",
98
+ "go.sum"
99
+ ]);
100
+ var GENERATED_FILE_PATTERNS = [
101
+ /(^|[._-])generated([._-]|$)/i,
102
+ /(^|[._-])gen([._-])/i,
103
+ /_generated\.(go|rs|py|rb|java|kt|ts|tsx|js|jsx|mjs|cjs)$/i,
104
+ /_gen\.(go|rs|py|rb|java|kt|ts|tsx|js|jsx|mjs|cjs)$/i,
105
+ /\.pb\.(go|ts|tsx|js|jsx|mjs|cjs)$/i,
106
+ /_pb2(_grpc)?\.py$/i,
107
+ /\.sql\.(go|ts|js)$/i,
108
+ /_sqlc\.go$/i,
109
+ /\.g\.([jt]sx?|mjs|cjs|rs|go)$/i
110
+ ];
111
+ var MINIFIED_BUNDLE_FILE_PATTERNS = [
112
+ /\.min\.(js|mjs|cjs|css)$/i,
113
+ /\.(bundle|chunk)\.(js|mjs|cjs|css)$/i
114
+ ];
115
+ var DECLARATION_FILE_PATTERNS = [/\.d\.ts$/i, /\.d\.mts$/i, /\.d\.cts$/i];
116
+ function pathSegments(filePath) {
117
+ return path.normalize(filePath).split(/[\\/]+/).filter(Boolean);
118
+ }
119
+ function basenameForShape(filePath) {
120
+ return isWindowsPath(filePath) ? path.win32.basename(filePath) : path.basename(filePath);
121
+ }
122
+ function isGeneratedArtifactDirectoryName(dirName) {
123
+ return GENERATED_DIR_NAMES.has(dirName.trim().toLowerCase());
124
+ }
125
+ function isDeclarationFile(filePath) {
126
+ const base = basenameForShape(filePath).toLowerCase();
127
+ return DECLARATION_FILE_PATTERNS.some((pattern) => pattern.test(base));
128
+ }
129
+ function hasStrongGeneratedArtifactPath(filePath) {
130
+ const segments = pathSegments(filePath);
131
+ const dirSegments = segments.slice(0, -1);
132
+ if (dirSegments.some((segment) => isGeneratedArtifactDirectoryName(segment))) {
133
+ return true;
134
+ }
135
+ const base = basenameForShape(filePath);
136
+ if (LOCKFILE_NAMES.has(base.toLowerCase()))
137
+ return true;
138
+ return MINIFIED_BUNDLE_FILE_PATTERNS.some((pattern) => pattern.test(base));
139
+ }
140
+ function hasWeakGeneratedFileNamePattern(filePath) {
141
+ const base = basenameForShape(filePath);
142
+ return GENERATED_FILE_PATTERNS.some((pattern) => pattern.test(base));
143
+ }
144
+ function hasGeneratedArtifactContent(content) {
145
+ const header = content.slice(0, DEFAULT_HEADER_BYTES);
146
+ return GENERATED_HEADER_PATTERNS.some((pattern) => pattern.test(header));
147
+ }
148
+ var MACHINE_EMITTED_LINE_SHAPE_MIN_CONTENT = 2048;
149
+ var MACHINE_EMITTED_LINE_SHAPE_MEAN_THRESHOLD = 2500;
150
+ function classifyMachineEmittedLineShape(content) {
151
+ const contentLength = content.length;
152
+ if (contentLength < MACHINE_EMITTED_LINE_SHAPE_MIN_CONTENT) {
153
+ return { generated: false, meanLineLength: 0 };
154
+ }
155
+ let nonEmptyLineTotal = 0;
156
+ let nonEmptyLineCount = 0;
157
+ let currentLineLength = 0;
158
+ for (let i = 0; i < contentLength; i++) {
159
+ const code = content.charCodeAt(i);
160
+ if (code === 10) {
161
+ if (currentLineLength > 0) {
162
+ nonEmptyLineTotal += currentLineLength;
163
+ nonEmptyLineCount += 1;
164
+ }
165
+ currentLineLength = 0;
166
+ } else if (code !== 13) {
167
+ currentLineLength += 1;
168
+ }
169
+ }
170
+ if (currentLineLength > 0) {
171
+ nonEmptyLineTotal += currentLineLength;
172
+ nonEmptyLineCount += 1;
173
+ }
174
+ if (nonEmptyLineCount === 0)
175
+ return { generated: false, meanLineLength: 0 };
176
+ const meanLineLength = nonEmptyLineTotal / nonEmptyLineCount;
177
+ return {
178
+ generated: meanLineLength > MACHINE_EMITTED_LINE_SHAPE_MEAN_THRESHOLD,
179
+ meanLineLength
180
+ };
181
+ }
182
+ var HEADER_VERDICT_MEMO_CAP = 5e4;
183
+ var headerAnalysisMemo = new BoundedLruCache(HEADER_VERDICT_MEMO_CAP);
184
+ function readFileHeader(filePath, maxBytes = DEFAULT_HEADER_BYTES) {
185
+ let fd;
186
+ try {
187
+ fd = fs.openSync(filePath, "r");
188
+ const buffer = Buffer.alloc(Math.max(0, maxBytes));
189
+ const bytesRead = fs.readSync(fd, buffer, 0, buffer.length, 0);
190
+ return buffer.toString("utf8", 0, bytesRead);
191
+ } catch {
192
+ return void 0;
193
+ } finally {
194
+ if (fd !== void 0) {
195
+ try {
196
+ fs.closeSync(fd);
197
+ } catch {
198
+ }
199
+ }
200
+ }
201
+ }
202
+ function analyzeFileHeader(filePath, maxBytes) {
203
+ let key;
204
+ try {
205
+ const st = fs.statSync(filePath);
206
+ key = `${st.mtimeMs}:${st.size}:${maxBytes}:${filePath}`;
207
+ } catch {
208
+ return void 0;
209
+ }
210
+ const cached = headerAnalysisMemo.get(key);
211
+ if (cached !== void 0)
212
+ return cached;
213
+ const header = readFileHeader(filePath, maxBytes);
214
+ const analysis = header === void 0 ? { banner: false, shape: { generated: false, meanLineLength: 0 } } : {
215
+ banner: hasGeneratedArtifactContent(header),
216
+ shape: classifyMachineEmittedLineShape(header)
217
+ };
218
+ headerAnalysisMemo.set(key, analysis);
219
+ return analysis;
220
+ }
221
+ function classifyGeneratedOrArtifactDetailed(filePath, options = {}) {
222
+ if (hasStrongGeneratedArtifactPath(filePath)) {
223
+ return { verdict: "generated", evidence: "strong" };
224
+ }
225
+ if (options.includeDeclarations && isDeclarationFile(filePath)) {
226
+ return { verdict: "generated", evidence: "strong" };
227
+ }
228
+ const weakNameMatch = hasWeakGeneratedFileNamePattern(filePath);
229
+ if (options.content !== void 0) {
230
+ if (hasGeneratedArtifactContent(options.content)) {
231
+ return { verdict: "generated", evidence: "content" };
232
+ }
233
+ const shape = classifyMachineEmittedLineShape(options.content);
234
+ if (shape.generated) {
235
+ return {
236
+ verdict: "generated",
237
+ evidence: "line-shape",
238
+ lineShapeMean: shape.meanLineLength
239
+ };
240
+ }
241
+ return { verdict: weakNameMatch ? "override" : "clean" };
242
+ }
243
+ if (options.readContentHeader) {
244
+ const analysis = analyzeFileHeader(filePath, options.maxHeaderBytes ?? DEFAULT_HEADER_BYTES);
245
+ if (analysis?.banner) {
246
+ return { verdict: "generated", evidence: "content" };
247
+ }
248
+ if (analysis?.shape.generated) {
249
+ return {
250
+ verdict: "generated",
251
+ evidence: "line-shape",
252
+ lineShapeMean: analysis.shape.meanLineLength
253
+ };
254
+ }
255
+ return { verdict: weakNameMatch ? "override" : "clean" };
256
+ }
257
+ return weakNameMatch ? { verdict: "generated", evidence: "name-only" } : { verdict: "clean" };
258
+ }
259
+ function classifyGeneratedOrArtifact(filePath, options = {}) {
260
+ return classifyGeneratedOrArtifactDetailed(filePath, options).verdict;
261
+ }
262
+ function isGeneratedOrArtifact(filePath, options = {}) {
263
+ return classifyGeneratedOrArtifact(filePath, options) === "generated";
264
+ }
265
+
266
+ // dist/clients/file-role.js
267
+ import { basename as basename2, dirname, win32 as win322 } from "node:path";
268
+ var RE_EXPORT_LINE = /^export\s+(type\s+)?\*\s+from\s+|^export\s*\{[^}]*\}\s+from\s+/;
269
+ function isReExportBarrel(content) {
270
+ const lines = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith("//") && !l.startsWith("*") && !l.startsWith("/*"));
271
+ return lines.length > 0 && lines.every((l) => RE_EXPORT_LINE.test(l));
272
+ }
273
+ function isTypeStub(content) {
274
+ const lines = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith("//") && !l.startsWith("*") && !l.startsWith("/*") && l !== "{" && l !== "}");
275
+ if (lines.length < 4)
276
+ return false;
277
+ const typeOnlyLines = lines.filter((l) => /^(export\s+)?(interface|type|abstract\s+class|declare\s+(class|function|const|var|let|module|namespace|enum))\s+/.test(l) || /^(import\s+type\s+|import\s+\{)/.test(l) || /^export\s+type\s+\{/.test(l));
278
+ return typeOnlyLines.length / lines.length >= 0.75;
279
+ }
280
+ function testFileNameMatches(rawBase, base) {
281
+ return base.includes(".test.") || base.includes(".spec.") || base.includes("_test.") || base.includes("_spec.") || base.startsWith("test_") || base.startsWith("spec_") || /(Test|Tests|TestCase)\.(java|kt|kts|cs|fs|php)$/.test(rawBase);
282
+ }
283
+ function isTestFileName(filePath) {
284
+ const windowsShaped = isWindowsPath(filePath);
285
+ const rawBase = windowsShaped ? win322.basename(filePath) : basename2(filePath);
286
+ return testFileNameMatches(rawBase, rawBase.toLowerCase());
287
+ }
288
+ function detectFileRole(filePath, content) {
289
+ const windowsShaped = isWindowsPath(filePath);
290
+ const rawBase = windowsShaped ? win322.basename(filePath) : basename2(filePath);
291
+ const base = rawBase.toLowerCase();
292
+ const dir = (windowsShaped ? win322.dirname(filePath) : dirname(filePath)).replace(/\\/g, "/").toLowerCase();
293
+ if (testFileNameMatches(rawBase, base) || /(^|[\\/])__tests__([\\/]|$)/.test(dir) || dir.includes("/test/") || dir.includes("/tests/") || dir.includes("/spec/") || dir.includes("/specs/") || /[/_-]tests?\/?$/.test(dir) || /[/_-]specs?\/?$/.test(dir))
294
+ return "test";
295
+ if (isGeneratedOrArtifact(filePath, { content, includeDeclarations: false })) {
296
+ return "generated";
297
+ }
298
+ const forwardDir = dir.replace(/\\/g, "/");
299
+ if (forwardDir.includes("/migrations/") || forwardDir.includes("/migration/") || /\/\d{4,}_[a-z]/.test(forwardDir + "/" + base))
300
+ return "migration";
301
+ if (base.endsWith(".config.ts") || base.endsWith(".config.js") || base.endsWith(".config.mjs") || base.endsWith(".config.cjs") || base === "vite.config.ts" || base === "jest.config.ts" || base === "jest.config.js" || base === "webpack.config.js" || base === "rollup.config.js" || base === "tailwind.config.js" || base === "tailwind.config.ts" || base === "next.config.js" || base === "next.config.mjs")
302
+ return "config";
303
+ if (base.endsWith(".d.ts"))
304
+ return "stub";
305
+ if (content && isTypeStub(content))
306
+ return "stub";
307
+ const isIndexFile = base === "index.ts" || base === "index.tsx" || base === "index.js" || base === "index.mjs" || base === "index.cjs" || base === "index.jsx" || base === "__init__.py" || base === "mod.rs";
308
+ if (isIndexFile) {
309
+ if (content && isReExportBarrel(content))
310
+ return "re-export";
311
+ return "init";
312
+ }
313
+ return "source";
314
+ }
315
+
316
+ // dist/clients/user-notify.js
317
+ var notifierGetter;
318
+ function notifyUserDegradation(message, level = "warning", options) {
319
+ try {
320
+ const notify = notifierGetter?.();
321
+ const coded = options?.code ? withConfigDiagnosticCode(message, options.code) : message;
322
+ notify?.(coded, level);
323
+ } catch {
324
+ }
325
+ }
326
+
327
+ // dist/clients/config-warn.js
328
+ var SUBSYSTEM_CONFIG_LABEL = {
329
+ "lsp-config": "LSP config",
330
+ "lens-config": "global config",
331
+ "project-lens-config": "project config"
332
+ };
333
+ var IGNORED_CONFIG_CODE = "PILENS_CFG_0001";
334
+ var IGNORED_CONFIG_KIND = "config-ignored";
335
+ var DEPRECATED_CONFIG_KIND = "config-deprecated";
336
+ var SUPPRESSED_NOTICE_CODE = "PILENS_CFG_0007";
337
+ var SUPPRESSED_NOTICE_KIND = "config-notice-suppressed";
338
+ var DEPRECATION_NOUN_BY_CODE = new Map(DEPRECATED_CONFIG_SURFACES.map((row) => [
339
+ row.code,
340
+ row.kind === "file" ? "location" : "key"
341
+ ]));
342
+ var warnedIgnoredConfigs = /* @__PURE__ */ new Set();
343
+ var JSON_PARSE_POSITION = /at position (\d+) \(line (\d+) column (\d+)\)/;
344
+ function isSyntaxError(error) {
345
+ return typeof error === "object" && error !== null && error.name === "SyntaxError" && typeof error.message === "string";
346
+ }
347
+ function lineColAt(sourceText, offset) {
348
+ let line = 1;
349
+ let lastNewline = -1;
350
+ for (let i = 0; i < offset; i++) {
351
+ if (sourceText[i] === "\n") {
352
+ line++;
353
+ lastNewline = i;
354
+ }
355
+ }
356
+ return { line, col: offset - lastNewline };
357
+ }
358
+ function parseUnexpectedTokenMessage(message) {
359
+ const prefix = "Unexpected token '";
360
+ if (!message.startsWith(prefix))
361
+ return void 0;
362
+ const closeIdx = message.indexOf("', ", prefix.length);
363
+ const token = message.slice(prefix.length, closeIdx);
364
+ let rest = message.slice(closeIdx + 3);
365
+ if (rest.startsWith("..."))
366
+ rest = rest.slice(3);
367
+ if (!rest.startsWith('"'))
368
+ return void 0;
369
+ rest = rest.slice(1);
370
+ const truncatedSuffix = '"... is not valid JSON';
371
+ const plainSuffix = '" is not valid JSON';
372
+ const snippet = rest.endsWith(truncatedSuffix) ? rest.slice(0, -truncatedSuffix.length) : rest.endsWith(plainSuffix) ? rest.slice(0, -plainSuffix.length) : void 0;
373
+ return snippet === void 0 ? void 0 : { token, snippet };
374
+ }
375
+ function locateSyntaxErrorOffset(message, sourceText) {
376
+ const stated = JSON_PARSE_POSITION.exec(message);
377
+ if (stated)
378
+ return Number(stated[1]);
379
+ const parsed = parseUnexpectedTokenMessage(message);
380
+ if (!parsed)
381
+ return void 0;
382
+ const { token, snippet } = parsed;
383
+ const snippetAt = sourceText.indexOf(snippet);
384
+ if (snippetAt === -1 || sourceText.indexOf(snippet, snippetAt + 1) !== -1) {
385
+ return void 0;
386
+ }
387
+ const tokenAt = snippet.indexOf(token);
388
+ const onlyTokenOccurrence = tokenAt !== -1 && snippet.indexOf(token, tokenAt + 1) === -1;
389
+ return snippetAt + (onlyTokenOccurrence ? tokenAt : 0);
390
+ }
391
+ function normalizeParseErrorReason(error, options = {}) {
392
+ if (options.classOnly) {
393
+ return errorClassName(error);
394
+ }
395
+ if (isSyntaxError(error)) {
396
+ if (options.sourceText !== void 0) {
397
+ const offset = locateSyntaxErrorOffset(error.message, options.sourceText);
398
+ if (offset !== void 0) {
399
+ const { line, col } = lineColAt(options.sourceText, offset);
400
+ return `${error.name} at line ${line} col ${col}`;
401
+ }
402
+ return error.name;
403
+ }
404
+ const match = JSON_PARSE_POSITION.exec(error.message);
405
+ return match ? `${error.name} at line ${match[2]} col ${match[3]}` : error.name;
406
+ }
407
+ const message = error instanceof Error ? error.message : String(error);
408
+ return redactSecrets(message);
409
+ }
410
+ function degradationKindFor(suppressedNotice, deprecationNoun) {
411
+ if (suppressedNotice)
412
+ return SUPPRESSED_NOTICE_KIND;
413
+ return deprecationNoun ? DEPRECATED_CONFIG_KIND : IGNORED_CONFIG_KIND;
414
+ }
415
+ function noticeMessage(options) {
416
+ const label = SUBSYSTEM_CONFIG_LABEL[options.subsystem];
417
+ if (options.suppressedNotice) {
418
+ return `${label} notices for ${options.file} were summarised: ${options.reason}`;
419
+ }
420
+ return options.deprecationNoun ? `deprecated ${label} ${options.deprecationNoun} in ${options.file}: ${options.reason}` : `ignoring invalid ${label} ${options.file}: ${options.reason}`;
421
+ }
422
+ function warnIgnoredConfigOnce(options) {
423
+ const { subsystem, file, key } = options;
424
+ const code = options.code ?? IGNORED_CONFIG_CODE;
425
+ const reason = redactSecrets(typeof options.reason === "string" ? options.reason : normalizeParseErrorReason(options.reason.parseError, {
426
+ sourceText: options.reason.sourceText
427
+ }));
428
+ const suppressedNotice = code === SUPPRESSED_NOTICE_CODE;
429
+ const deprecationNoun = suppressedNotice ? void 0 : DEPRECATION_NOUN_BY_CODE.get(code);
430
+ recordDegradationOnce({
431
+ kind: degradationKindFor(suppressedNotice, deprecationNoun),
432
+ subject: key ? `${file}\0${key}` : file,
433
+ reason,
434
+ metadata: { subsystem, configPath: file },
435
+ code
436
+ });
437
+ const latchKey = `${subsystem}\0${file}\0${key ?? ""}\0${reason}`;
438
+ if (warnedIgnoredConfigs.has(latchKey))
439
+ return;
440
+ warnedIgnoredConfigs.add(latchKey);
441
+ const message = noticeMessage({
442
+ subsystem,
443
+ file,
444
+ reason,
445
+ suppressedNotice,
446
+ deprecationNoun
447
+ });
448
+ logExtension({
449
+ subsystem,
450
+ level: "warn",
451
+ message: withConfigDiagnosticCode(message, code),
452
+ metadata: { configPath: file, reason, code, ...key ? { key } : {} }
453
+ });
454
+ notifyUserDegradation(`pi-lens: ${message}`, "warning", { code });
455
+ }
456
+
457
+ // dist/clients/project-lens-config.js
458
+ import * as fs3 from "node:fs";
459
+ import * as os2 from "node:os";
460
+ import * as path3 from "node:path";
461
+
462
+ // dist/clients/config-resolve.js
463
+ import * as fs2 from "node:fs";
464
+ import * as os from "node:os";
465
+ import * as path2 from "node:path";
466
+
467
+ // dist/clients/config-core/provenance.js
468
+ var SOURCE_TIERS = [
469
+ "builtin",
470
+ "global",
471
+ "project",
472
+ "nested-project",
473
+ "env",
474
+ "cli",
475
+ "host"
476
+ ];
477
+ var TIER_CLASS = {
478
+ builtin: "default",
479
+ global: "operator",
480
+ project: "repo",
481
+ "nested-project": "repo",
482
+ env: "operator",
483
+ cli: "operator",
484
+ host: "operator"
485
+ };
486
+ function tierPrecedence(tier) {
487
+ return SOURCE_TIERS.indexOf(tier);
488
+ }
489
+ function isOperatorTier(tier) {
490
+ return TIER_CLASS[tier] === "operator";
491
+ }
492
+ function provenanceView(resolved, homeDir) {
493
+ const entries = [...resolved.provenance.values()].map((entry) => ({
494
+ key: entry.key,
495
+ tier: entry.tier,
496
+ ...entry.file === void 0 ? {} : { file: homeRelativePath(entry.file, homeDir) },
497
+ ...entry.trust === void 0 ? {} : { trust: entry.trust }
498
+ })).sort((left, right) => compareKeys(left.key, right.key));
499
+ return { entries };
500
+ }
501
+ function provenanceFor(resolved, pointer) {
502
+ let candidate = pointer;
503
+ for (; ; ) {
504
+ const entry = resolved.provenance.get(candidate);
505
+ if (entry)
506
+ return entry;
507
+ if (candidate === "")
508
+ return void 0;
509
+ const cut = candidate.lastIndexOf("/");
510
+ candidate = cut <= 0 ? "" : candidate.slice(0, cut);
511
+ }
512
+ }
513
+ function compareKeys(left, right) {
514
+ if (left < right)
515
+ return -1;
516
+ return left > right ? 1 : 0;
517
+ }
518
+
519
+ // dist/clients/config-core/deny.js
520
+ function provenanceOfContribution(source, key) {
521
+ if (!source)
522
+ return void 0;
523
+ return {
524
+ tier: source.tier,
525
+ key,
526
+ ...source.file === void 0 ? {} : { file: source.file },
527
+ ...source.trust === void 0 ? {} : { trust: source.trust }
528
+ };
529
+ }
530
+ function denyProvenance(contributions, resolution, key) {
531
+ return provenanceOfContribution(contributions[resolution.winner], key);
532
+ }
533
+ function denyMemberProvenance(contributions, resolution, key) {
534
+ const entries = [];
535
+ resolution.memberWinners.forEach((index, position) => {
536
+ const pointer = `${key}/${position}`;
537
+ const entry = provenanceOfContribution(contributions[index], pointer);
538
+ if (entry)
539
+ entries.push(entry);
540
+ });
541
+ return entries;
542
+ }
543
+ var EMPTY_MEMBER_WINNERS = Object.freeze([]);
544
+ function byPrecedence(contributions) {
545
+ return contributions.map((contribution, index) => ({ contribution, index })).sort((left, right) => tierPrecedence(left.contribution.tier) - tierPrecedence(right.contribution.tier));
546
+ }
547
+ function resolveBooleanDeny(contributions) {
548
+ const ordered = byPrecedence(contributions);
549
+ if (ordered.length === 0)
550
+ return {
551
+ value: void 0,
552
+ winner: -1,
553
+ denied: false,
554
+ memberWinners: EMPTY_MEMBER_WINNERS
555
+ };
556
+ const denials = ordered.filter((entry) => entry.contribution.value === false);
557
+ if (denials.length === 0) {
558
+ const last = ordered[ordered.length - 1];
559
+ return {
560
+ value: last.contribution.value,
561
+ winner: last.index,
562
+ denied: false,
563
+ memberWinners: EMPTY_MEMBER_WINNERS
564
+ };
565
+ }
566
+ const operatorDenial = denials.find((entry) => isOperatorTier(entry.contribution.tier));
567
+ if (operatorDenial) {
568
+ return {
569
+ value: false,
570
+ winner: operatorDenial.index,
571
+ denied: true,
572
+ memberWinners: EMPTY_MEMBER_WINNERS
573
+ };
574
+ }
575
+ const firstDenial = denials[0];
576
+ const lift = ordered.find((entry) => entry.contribution.value === true && isOperatorTier(entry.contribution.tier) && tierPrecedence(entry.contribution.tier) > tierPrecedence(firstDenial.contribution.tier));
577
+ if (lift) {
578
+ return {
579
+ value: true,
580
+ winner: lift.index,
581
+ denied: false,
582
+ memberWinners: EMPTY_MEMBER_WINNERS
583
+ };
584
+ }
585
+ return {
586
+ value: false,
587
+ winner: firstDenial.index,
588
+ denied: true,
589
+ memberWinners: EMPTY_MEMBER_WINNERS
590
+ };
591
+ }
592
+ function resolveArrayDeny(contributions) {
593
+ const ordered = byPrecedence(contributions);
594
+ const seen = /* @__PURE__ */ new Set();
595
+ const members = [];
596
+ const memberWinners = [];
597
+ let winner = -1;
598
+ for (const entry of ordered) {
599
+ const value = entry.contribution.value;
600
+ if (!Array.isArray(value))
601
+ continue;
602
+ for (const member of value) {
603
+ const identity = primitiveIdentity(member);
604
+ if (identity !== void 0) {
605
+ if (seen.has(identity))
606
+ continue;
607
+ seen.add(identity);
608
+ }
609
+ members.push(member);
610
+ memberWinners.push(entry.index);
611
+ if (winner === -1)
612
+ winner = entry.index;
613
+ }
614
+ }
615
+ if (winner === -1) {
616
+ const last = ordered[ordered.length - 1];
617
+ return {
618
+ value: members,
619
+ winner: last ? last.index : -1,
620
+ denied: false,
621
+ memberWinners
622
+ };
623
+ }
624
+ return { value: members, winner, denied: members.length > 0, memberWinners };
625
+ }
626
+ function primitiveIdentity(member) {
627
+ if (typeof member === "string")
628
+ return `s:${member}`;
629
+ if (typeof member === "number" || typeof member === "boolean") {
630
+ return `p:${String(member)}`;
631
+ }
632
+ if (member === null)
633
+ return "null";
634
+ return void 0;
635
+ }
636
+
637
+ // dist/clients/config-core/safe-object.js
638
+ var MAX_CONFIG_DEPTH = 32;
639
+ var UNSAFE_CONFIG_KEYS = [
640
+ "__proto__",
641
+ "constructor",
642
+ "prototype"
643
+ ];
644
+ var UNSAFE_KEY_SET = new Set(UNSAFE_CONFIG_KEYS);
645
+ function isUnsafeConfigKey(name) {
646
+ return UNSAFE_KEY_SET.has(name);
647
+ }
648
+ var UNSAFE_KEY_REASON = "config key would modify the object prototype; ignored";
649
+ function safeAssign(target, name, value) {
650
+ if (isUnsafeConfigKey(name))
651
+ return false;
652
+ Object.defineProperty(target, name, {
653
+ value,
654
+ writable: true,
655
+ enumerable: true,
656
+ configurable: true
657
+ });
658
+ return true;
659
+ }
660
+
661
+ // dist/clients/config-core/records.js
662
+ var MAX_MIGRATION_RECORDS = DEGRADATION_ENTRIES_PER_KIND;
663
+ var MAX_RECORD_KEY_LENGTH = 120;
664
+ var UNBOUNDED_RECORD_CODES = /* @__PURE__ */ new Set(["PILENS_CFG_0008"]);
665
+ var SUBJECT_SEPARATOR = String.fromCharCode(0);
666
+ function migrationSubject(file, key) {
667
+ return key.length > 0 ? `${file}${SUBJECT_SEPARATOR}${key}` : file;
668
+ }
669
+ function stripControlCharacters(text) {
670
+ let out = "";
671
+ for (const character of text) {
672
+ const code = character.codePointAt(0) ?? 0;
673
+ out += code < 32 || code === 127 ? " " : character;
674
+ }
675
+ return out;
676
+ }
677
+ function boundedKeyLabel(key) {
678
+ const printable = stripControlCharacters(key).trim();
679
+ const bounded = printable.length > MAX_RECORD_KEY_LENGTH ? `${printable.slice(0, MAX_RECORD_KEY_LENGTH)}...` : printable;
680
+ return redactSecrets(bounded);
681
+ }
682
+ function jsonTypeName(value) {
683
+ if (value === null)
684
+ return "null";
685
+ if (Array.isArray(value))
686
+ return "array";
687
+ return typeof value;
688
+ }
689
+ var UNANCHORED_RECORD_LABEL = "(config resolution)";
690
+ var MigrationRecordCollector = class {
691
+ kept = [];
692
+ dropped;
693
+ limit;
694
+ /**
695
+ * `priorDropped` SEEDS the drop count with records an EARLIER bound already
696
+ * discarded before this collector saw the list (#2426 review round 6, F1).
697
+ *
698
+ * The shared resolution is bounded twice by construction: `resolveConfig`
699
+ * runs its own collector across every source, and the loader then finalizes
700
+ * what survived plus the deprecation records it composes itself. Only the
701
+ * second bound used to be counted, so a `.pi-lens.json` whose 40 refused
702
+ * keys were truncated to 19 told the user ONE notice had been suppressed
703
+ * when 21 had. A suppression count that undercounts is worse than no count:
704
+ * it tells the user the list they were shown is almost complete.
705
+ */
706
+ constructor(limit = MAX_MIGRATION_RECORDS, priorDropped = 0) {
707
+ this.limit = Math.max(0, Math.trunc(limit));
708
+ this.dropped = Math.max(0, Math.trunc(priorDropped));
709
+ }
710
+ add(record4) {
711
+ if (this.kept.length >= this.limit) {
712
+ if (UNBOUNDED_RECORD_CODES.has(record4.code)) {
713
+ this.kept.push(record4);
714
+ return;
715
+ }
716
+ this.dropped += 1;
717
+ return;
718
+ }
719
+ this.kept.push(record4);
720
+ }
721
+ /** The retained records, oldest first. */
722
+ get records() {
723
+ return this.kept;
724
+ }
725
+ /** How many records the bound discarded. Counted, never silently zero. */
726
+ get droppedCount() {
727
+ return this.dropped;
728
+ }
729
+ /**
730
+ * The retained records plus, when the bound discarded any, ONE record
731
+ * counting them.
732
+ *
733
+ * The whole of "bound a record list and say so when it truncates" lives
734
+ * here, and nowhere else (#2426 review round 5, F-A/F-B/S-A). Three
735
+ * producers had grown their own copy of it — the shared resolution, the
736
+ * project loader's unknown-key scan, and (by omission, which is how the
737
+ * defect showed) the project loader's legacy-document enumeration, which
738
+ * shipped its records raw and let one file's key count set the
739
+ * notification count. A fourth producer must not have to remember any of
740
+ * this: it calls `finalizeRecords` and is bounded.
741
+ *
742
+ * Two finalized lists that anchor to the SAME file and suppress the SAME
743
+ * number of records render one notice, not two. That is the warn-once
744
+ * latch doing its documented job: both records state the identical fact
745
+ * about the identical file, and the user has one thing to do about it.
746
+ */
747
+ finalize(anchor) {
748
+ if (this.dropped === 0)
749
+ return this.kept;
750
+ const file = anchor?.file ?? UNANCHORED_RECORD_LABEL;
751
+ return [
752
+ ...this.kept,
753
+ {
754
+ code: "PILENS_CFG_0007",
755
+ file,
756
+ key: "",
757
+ subject: migrationSubject(file, ""),
758
+ reason: `${this.dropped} further config notices were suppressed by the bound of ${MAX_MIGRATION_RECORDS}`,
759
+ ...anchor?.tier === void 0 ? {} : { tier: anchor.tier }
760
+ }
761
+ ];
762
+ }
763
+ };
764
+ function finalizeRecords(records, anchor, priorDropped = 0) {
765
+ const collector = new MigrationRecordCollector(MAX_MIGRATION_RECORDS - 1, priorDropped);
766
+ for (const record4 of records)
767
+ collector.add(record4);
768
+ return collector.finalize(anchor);
769
+ }
770
+
771
+ // dist/clients/config-core/schema.js
772
+ function isConfigObject(value) {
773
+ return typeof value === "object" && value !== null && !Array.isArray(value);
774
+ }
775
+ var MERGE_STRATEGY_KEY = "x-merge-strategy";
776
+ var DEFAULT_MERGE_STRATEGY = "replace";
777
+ var KEYED_PREFIX = "keyed:";
778
+ function isMergeStrategy(value) {
779
+ if (typeof value !== "string")
780
+ return false;
781
+ if (value === "replace" || value === "append")
782
+ return true;
783
+ return value.startsWith(KEYED_PREFIX) && value.length > KEYED_PREFIX.length;
784
+ }
785
+ function mergeStrategyOf(node) {
786
+ const declared = node?.[MERGE_STRATEGY_KEY];
787
+ return isMergeStrategy(declared) ? declared : DEFAULT_MERGE_STRATEGY;
788
+ }
789
+ function keyedField(strategy) {
790
+ return strategy.startsWith(KEYED_PREFIX) ? strategy.slice(KEYED_PREFIX.length) : void 0;
791
+ }
792
+ var DENY_KEY = "x-deny";
793
+ var DENY_POLICIES = ["boolean-false", "array-union"];
794
+ function isDenyPolicy(value) {
795
+ return typeof value === "string" && DENY_POLICIES.includes(value);
796
+ }
797
+ function denyPolicyOf(node) {
798
+ const declared = node?.[DENY_KEY];
799
+ return isDenyPolicy(declared) ? declared : void 0;
800
+ }
801
+ function isSchemaNode(value) {
802
+ return typeof value === "object" && value !== null && !Array.isArray(value);
803
+ }
804
+ function isPlainObject(value) {
805
+ return typeof value === "object" && value !== null && !Array.isArray(value);
806
+ }
807
+ function schemaType(node) {
808
+ const declared = node?.type;
809
+ return typeof declared === "string" ? declared : void 0;
810
+ }
811
+ var SCHEMA_TYPES = [
812
+ "object",
813
+ "array",
814
+ "string",
815
+ "number",
816
+ "integer",
817
+ "boolean",
818
+ "null"
819
+ ];
820
+ var SCHEMA_TYPE_SET = new Set(SCHEMA_TYPES);
821
+ function isKnownSchemaType(declared) {
822
+ return declared !== void 0 && SCHEMA_TYPE_SET.has(declared);
823
+ }
824
+ function propertySchema(node, name) {
825
+ if (!node)
826
+ return void 0;
827
+ const properties = node.properties;
828
+ if (isSchemaNode(properties) && Object.hasOwn(properties, name)) {
829
+ const child = properties[name];
830
+ if (isSchemaNode(child))
831
+ return child;
832
+ }
833
+ const patterns = node.patternProperties;
834
+ if (isSchemaNode(patterns)) {
835
+ for (const [pattern, child] of Object.entries(patterns)) {
836
+ if (!isSchemaNode(child))
837
+ continue;
838
+ let matcher;
839
+ try {
840
+ matcher = new RegExp(pattern);
841
+ } catch {
842
+ continue;
843
+ }
844
+ if (matcher.test(name))
845
+ return child;
846
+ }
847
+ }
848
+ return void 0;
849
+ }
850
+ function additionalPropertyPolicy(node) {
851
+ const declared = node?.additionalProperties;
852
+ if (declared === true)
853
+ return { kind: "keep" };
854
+ if (isSchemaNode(declared))
855
+ return { kind: "validate", schema: declared };
856
+ return { kind: "drop" };
857
+ }
858
+ function itemsSchema(node) {
859
+ const declared = node?.items;
860
+ return isSchemaNode(declared) ? declared : void 0;
861
+ }
862
+
863
+ // dist/clients/config-core/merge.js
864
+ function merge(sources, schema, options = {}) {
865
+ const ordered = [...sources].map((source, order) => ({ source, order })).sort((left, right) => {
866
+ const byTier = tierPrecedence(left.source.tier) - tierPrecedence(right.source.tier);
867
+ return byTier !== 0 ? byTier : left.order - right.order;
868
+ }).map((entry, rank) => ({ source: entry.source, rank }));
869
+ const contributions = [];
870
+ for (const entry of ordered) {
871
+ const value2 = entry.source.value;
872
+ if (value2 === void 0)
873
+ continue;
874
+ contributions.push({ source: entry.source, value: value2, rank: entry.rank });
875
+ }
876
+ const provenance = /* @__PURE__ */ new Map();
877
+ const context = {
878
+ provenance,
879
+ collector: options.collector ?? new MigrationRecordCollector(),
880
+ file: options.file ?? ""
881
+ };
882
+ const value = mergeNode(contributions, schema, "", context, 0);
883
+ return { value, provenance };
884
+ }
885
+ function record(context, entry) {
886
+ const key = boundedKeyLabel(entry.key);
887
+ context.collector.add({
888
+ code: entry.code,
889
+ file: context.file,
890
+ key,
891
+ subject: migrationSubject(context.file, key),
892
+ reason: entry.reason
893
+ });
894
+ }
895
+ function provenanceOf(contribution, key) {
896
+ const { source } = contribution;
897
+ return {
898
+ tier: source.tier,
899
+ key,
900
+ ...source.file === void 0 ? {} : { file: source.file },
901
+ ...source.trust === void 0 ? {} : { trust: source.trust }
902
+ };
903
+ }
904
+ function stamp(context, contribution, key) {
905
+ context.provenance.set(key, provenanceOf(contribution, key));
906
+ }
907
+ function mergeNode(contributions, schema, key, context, depth) {
908
+ if (contributions.length === 0)
909
+ return void 0;
910
+ if (depth > MAX_CONFIG_DEPTH) {
911
+ record(context, {
912
+ code: "PILENS_CFG_0005",
913
+ key,
914
+ reason: `config nesting exceeds ${MAX_CONFIG_DEPTH} levels; ignored`
915
+ });
916
+ return void 0;
917
+ }
918
+ const denyPolicy = denyPolicyOf(schema);
919
+ if (denyPolicy)
920
+ return mergeDeny(contributions, denyPolicy, key, context);
921
+ if (isObjectNode(schema, contributions)) {
922
+ return mergeObject(contributions, schema, key, context, depth);
923
+ }
924
+ if (isArrayNode(schema, contributions)) {
925
+ return mergeArray(contributions, schema, key, context, depth);
926
+ }
927
+ const winner = contributions[contributions.length - 1];
928
+ stamp(context, winner, key);
929
+ return winner.value;
930
+ }
931
+ function isObjectNode(schema, contributions) {
932
+ const declared = schemaType(schema);
933
+ if (declared === "object")
934
+ return true;
935
+ if (isKnownSchemaType(declared))
936
+ return false;
937
+ if (schema && isSchemaNode(schema.properties))
938
+ return true;
939
+ return contributions.every((entry) => isPlainObject(entry.value));
940
+ }
941
+ function isArrayNode(schema, contributions) {
942
+ const declared = schemaType(schema);
943
+ if (declared === "array")
944
+ return true;
945
+ if (isKnownSchemaType(declared))
946
+ return false;
947
+ return contributions.every((entry) => Array.isArray(entry.value));
948
+ }
949
+ function mergeDeny(contributions, policy, key, context) {
950
+ const denyContributions = contributions.map((entry2) => ({
951
+ tier: entry2.source.tier,
952
+ value: entry2.value,
953
+ ...entry2.source.file === void 0 ? {} : { file: entry2.source.file },
954
+ ...entry2.source.trust === void 0 ? {} : { trust: entry2.source.trust }
955
+ }));
956
+ const resolution = policy === "boolean-false" ? resolveBooleanDeny(denyContributions) : resolveArrayDeny(denyContributions);
957
+ const entry = denyProvenance(denyContributions, resolution, key);
958
+ if (entry)
959
+ context.provenance.set(key, entry);
960
+ for (const member of denyMemberProvenance(denyContributions, resolution, key)) {
961
+ context.provenance.set(member.key, member);
962
+ }
963
+ return resolution.value;
964
+ }
965
+ function mergeObject(contributions, schema, key, context, depth) {
966
+ const objects = contributions.filter((entry) => isConfigObject(entry.value));
967
+ if (objects.length === 0) {
968
+ const winner = contributions[contributions.length - 1];
969
+ stamp(context, winner, key);
970
+ return winner.value;
971
+ }
972
+ const names = [];
973
+ for (const entry of objects) {
974
+ for (const name of Object.keys(entry.value)) {
975
+ if (names.includes(name))
976
+ continue;
977
+ if (isUnsafeConfigKey(name)) {
978
+ record(context, {
979
+ code: "PILENS_CFG_0006",
980
+ key: `${key}/${name}`,
981
+ reason: UNSAFE_KEY_REASON
982
+ });
983
+ continue;
984
+ }
985
+ names.push(name);
986
+ }
987
+ }
988
+ const out = {};
989
+ for (const name of names) {
990
+ const childKey = `${key}/${name}`;
991
+ const childContributions = [];
992
+ for (const entry of objects) {
993
+ const parent = entry.value;
994
+ if (!Object.hasOwn(parent, name))
995
+ continue;
996
+ childContributions.push({
997
+ source: entry.source,
998
+ value: parent[name],
999
+ rank: entry.rank
1000
+ });
1001
+ }
1002
+ const merged = mergeNode(childContributions, propertySchema(schema, name), childKey, context, depth + 1);
1003
+ if (merged !== void 0)
1004
+ safeAssign(out, name, merged);
1005
+ }
1006
+ return out;
1007
+ }
1008
+ function mergeArray(contributions, schema, key, context, depth) {
1009
+ const arrays = contributions.filter((entry) => Array.isArray(entry.value));
1010
+ if (arrays.length === 0) {
1011
+ const winner2 = contributions[contributions.length - 1];
1012
+ stamp(context, winner2, key);
1013
+ return winner2.value;
1014
+ }
1015
+ const strategy = mergeStrategyOf(schema);
1016
+ const keyed = keyedField(strategy);
1017
+ if (keyed !== void 0) {
1018
+ return mergeKeyedArray(arrays, schema, keyed, key, context, depth);
1019
+ }
1020
+ if (strategy === "append")
1021
+ return appendArrays(arrays, key, context);
1022
+ const winner = arrays[arrays.length - 1];
1023
+ stamp(context, winner, key);
1024
+ return [...winner.value];
1025
+ }
1026
+ function appendArrays(arrays, key, context) {
1027
+ const out = [];
1028
+ for (const entry of arrays) {
1029
+ for (const member of entry.value) {
1030
+ stamp(context, entry, `${key}/${out.length}`);
1031
+ out.push(member);
1032
+ }
1033
+ }
1034
+ stamp(context, arrays[0], key);
1035
+ return out;
1036
+ }
1037
+ function mergeKeyedArray(arrays, schema, field, key, context, depth) {
1038
+ const items = itemsSchema(schema);
1039
+ const order = [];
1040
+ const groups = /* @__PURE__ */ new Map();
1041
+ const unkeyed = [];
1042
+ for (const entry of arrays) {
1043
+ for (const member of entry.value) {
1044
+ const identity = keyIdentity(member, field);
1045
+ const memberContribution = {
1046
+ source: entry.source,
1047
+ value: member,
1048
+ rank: entry.rank
1049
+ };
1050
+ if (identity === void 0) {
1051
+ unkeyed.push(memberContribution);
1052
+ continue;
1053
+ }
1054
+ const group = groups.get(identity);
1055
+ if (group) {
1056
+ group.push(memberContribution);
1057
+ continue;
1058
+ }
1059
+ order.push(identity);
1060
+ groups.set(identity, [memberContribution]);
1061
+ }
1062
+ }
1063
+ const out = [];
1064
+ const pushMerged = (group) => {
1065
+ const merged = mergeNode(group, items, `${key}/${out.length}`, context, depth + 1);
1066
+ if (merged !== void 0)
1067
+ out.push(merged);
1068
+ };
1069
+ for (const identity of order)
1070
+ pushMerged(groups.get(identity) ?? []);
1071
+ for (const entry of unkeyed)
1072
+ pushMerged([entry]);
1073
+ stamp(context, arrays[0], key);
1074
+ return out;
1075
+ }
1076
+ function keyIdentity(member, field) {
1077
+ if (!isConfigObject(member))
1078
+ return void 0;
1079
+ const value = member[field];
1080
+ if (typeof value === "string")
1081
+ return `s:${value}`;
1082
+ if (typeof value === "number" && Number.isFinite(value)) {
1083
+ return `n:${String(value)}`;
1084
+ }
1085
+ return void 0;
1086
+ }
1087
+
1088
+ // dist/clients/config-core/normalize.js
1089
+ var DROPPED = /* @__PURE__ */ Symbol("dropped");
1090
+ var OPEN_SCHEMA = { additionalProperties: true };
1091
+ function validate(raw, schema, options = {}) {
1092
+ const collector = options.collector ?? new MigrationRecordCollector();
1093
+ const file = options.file ?? "";
1094
+ const context = {
1095
+ collector,
1096
+ file,
1097
+ tier: options.tier,
1098
+ path: []
1099
+ };
1100
+ let walked;
1101
+ try {
1102
+ walked = walk(raw, schema, context, 0, /* @__PURE__ */ new Set());
1103
+ } catch (error) {
1104
+ record2(context, {
1105
+ code: "PILENS_CFG_0005",
1106
+ key: "",
1107
+ reason: `config validation failed internally (${errorClassName(error)}); document ignored`
1108
+ });
1109
+ walked = DROPPED;
1110
+ }
1111
+ return {
1112
+ value: walked === DROPPED ? void 0 : walked,
1113
+ records: collector.records,
1114
+ droppedRecordCount: collector.droppedCount
1115
+ };
1116
+ }
1117
+ function pointerOf(path4) {
1118
+ return path4.length === 0 ? "" : `/${path4.join("/")}`;
1119
+ }
1120
+ function record2(context, entry) {
1121
+ const key = boundedKeyLabel(entry.key);
1122
+ context.collector.add({
1123
+ code: entry.code,
1124
+ file: context.file,
1125
+ key,
1126
+ subject: migrationSubject(context.file, key),
1127
+ reason: entry.reason,
1128
+ tier: context.tier
1129
+ });
1130
+ }
1131
+ function walk(value, schema, context, depth, onPath) {
1132
+ const pointer = pointerOf(context.path);
1133
+ if (depth > MAX_CONFIG_DEPTH) {
1134
+ record2(context, {
1135
+ code: "PILENS_CFG_0005",
1136
+ key: pointer,
1137
+ reason: `config nesting exceeds ${MAX_CONFIG_DEPTH} levels; ignored`
1138
+ });
1139
+ return DROPPED;
1140
+ }
1141
+ if (typeof value === "object" && value !== null) {
1142
+ if (onPath.has(value)) {
1143
+ record2(context, {
1144
+ code: "PILENS_CFG_0005",
1145
+ key: pointer,
1146
+ reason: "config value refers to itself; ignored"
1147
+ });
1148
+ return DROPPED;
1149
+ }
1150
+ }
1151
+ const declared = schemaType(schema);
1152
+ if (declared === "object")
1153
+ return walkObject(value, schema, context, depth, onPath);
1154
+ if (declared === "array")
1155
+ return walkArray(value, schema, context, depth, onPath);
1156
+ if (isKnownSchemaType(declared)) {
1157
+ return walkScalar(value, schema, context, declared);
1158
+ }
1159
+ return walkOpaque(value, schema, context, depth, onPath);
1160
+ }
1161
+ function walkOpaque(value, schema, context, depth, onPath) {
1162
+ if (isPlainObject(value)) {
1163
+ const effective = claimsChildren(schema) ? schema : OPEN_SCHEMA;
1164
+ return walkObject(value, effective, context, depth, onPath);
1165
+ }
1166
+ if (Array.isArray(value)) {
1167
+ return walkArray(value, schema, context, depth, onPath);
1168
+ }
1169
+ return walkLeaf(value, schema, context);
1170
+ }
1171
+ function claimsChildren(schema) {
1172
+ if (!schema)
1173
+ return false;
1174
+ return isSchemaNode(schema.properties) || isSchemaNode(schema.patternProperties) || schema.additionalProperties !== void 0;
1175
+ }
1176
+ function walkLeaf(value, schema, context) {
1177
+ if (!isConfigScalar(value)) {
1178
+ record2(context, {
1179
+ code: "PILENS_CFG_0005",
1180
+ key: pointerOf(context.path),
1181
+ reason: `config value is not valid JSON data (${jsonTypeName(value)}); ignored`
1182
+ });
1183
+ return DROPPED;
1184
+ }
1185
+ return checkEnum(value, schema, context) ? value : DROPPED;
1186
+ }
1187
+ function isConfigScalar(value) {
1188
+ if (value === null)
1189
+ return true;
1190
+ const type = typeof value;
1191
+ if (type === "string" || type === "boolean")
1192
+ return true;
1193
+ return type === "number" && Number.isFinite(value);
1194
+ }
1195
+ function walkObject(value, schema, context, depth, onPath) {
1196
+ if (!isPlainObject(value)) {
1197
+ record2(context, {
1198
+ code: "PILENS_CFG_0005",
1199
+ key: pointerOf(context.path),
1200
+ reason: `expected an object, got ${jsonTypeName(value)}; ignored`
1201
+ });
1202
+ return DROPPED;
1203
+ }
1204
+ const nextPath = onPath.add(value);
1205
+ const policy = additionalPropertyPolicy(schema);
1206
+ const out = {};
1207
+ for (const [name, child] of Object.entries(value)) {
1208
+ if (rejectUnsafeKey(name, context))
1209
+ continue;
1210
+ const childSchema = propertySchema(schema, name);
1211
+ let effective = childSchema;
1212
+ if (!childSchema) {
1213
+ if (policy.kind === "drop") {
1214
+ context.path.push(name);
1215
+ record2(context, {
1216
+ code: "PILENS_CFG_0004",
1217
+ key: pointerOf(context.path),
1218
+ reason: "unknown config field; ignored"
1219
+ });
1220
+ context.path.pop();
1221
+ continue;
1222
+ }
1223
+ effective = policy.kind === "validate" ? policy.schema : void 0;
1224
+ }
1225
+ context.path.push(name);
1226
+ const walked = walk(child, effective, context, depth + 1, nextPath);
1227
+ context.path.pop();
1228
+ if (walked !== DROPPED)
1229
+ safeAssign(out, name, walked);
1230
+ }
1231
+ nextPath.delete(value);
1232
+ return out;
1233
+ }
1234
+ function rejectUnsafeKey(name, context) {
1235
+ if (!isUnsafeConfigKey(name))
1236
+ return false;
1237
+ context.path.push(name);
1238
+ record2(context, {
1239
+ code: "PILENS_CFG_0006",
1240
+ key: pointerOf(context.path),
1241
+ reason: UNSAFE_KEY_REASON
1242
+ });
1243
+ context.path.pop();
1244
+ return true;
1245
+ }
1246
+ function walkArray(value, schema, context, depth, onPath) {
1247
+ if (!Array.isArray(value)) {
1248
+ record2(context, {
1249
+ code: "PILENS_CFG_0005",
1250
+ key: pointerOf(context.path),
1251
+ reason: `expected an array, got ${jsonTypeName(value)}; ignored`
1252
+ });
1253
+ return DROPPED;
1254
+ }
1255
+ const nextPath = onPath.add(value);
1256
+ const items = itemsSchema(schema);
1257
+ const out = [];
1258
+ for (const [index, entry] of value.entries()) {
1259
+ context.path.push(String(index));
1260
+ const walked = walk(entry, items, context, depth + 1, nextPath);
1261
+ context.path.pop();
1262
+ if (walked !== DROPPED)
1263
+ out.push(walked);
1264
+ }
1265
+ nextPath.delete(value);
1266
+ return out;
1267
+ }
1268
+ var SCALAR_CHECKS = {
1269
+ string: (value) => typeof value === "string",
1270
+ number: (value) => typeof value === "number" && Number.isFinite(value),
1271
+ integer: (value) => typeof value === "number" && Number.isInteger(value),
1272
+ boolean: (value) => typeof value === "boolean",
1273
+ null: (value) => value === null
1274
+ };
1275
+ function walkScalar(value, schema, context, declared) {
1276
+ const check = SCALAR_CHECKS[declared];
1277
+ if (!check(value)) {
1278
+ record2(context, {
1279
+ code: "PILENS_CFG_0005",
1280
+ key: pointerOf(context.path),
1281
+ reason: `expected ${declared}, got ${jsonTypeName(value)}; ignored`
1282
+ });
1283
+ return DROPPED;
1284
+ }
1285
+ return checkEnum(value, schema, context) ? value : DROPPED;
1286
+ }
1287
+ function checkEnum(value, schema, context) {
1288
+ const allowed = schema?.enum;
1289
+ if (!Array.isArray(allowed))
1290
+ return true;
1291
+ if (allowed.some((candidate) => Object.is(candidate, value)))
1292
+ return true;
1293
+ record2(context, {
1294
+ code: "PILENS_CFG_0005",
1295
+ key: pointerOf(context.path),
1296
+ reason: `value is not one of ${allowed.map((candidate) => JSON.stringify(candidate)).join(", ")}; ignored`
1297
+ });
1298
+ return false;
1299
+ }
1300
+
1301
+ // dist/clients/config-core/resolve.js
1302
+ function anchorSource(sources) {
1303
+ try {
1304
+ const last = sources?.[sources.length - 1];
1305
+ return last === void 0 || typeof last.file !== "string" ? void 0 : { file: last.file, tier: last.tier };
1306
+ } catch {
1307
+ return void 0;
1308
+ }
1309
+ }
1310
+ function resolveConfig(options) {
1311
+ const collector = new MigrationRecordCollector(options.maxRecords);
1312
+ try {
1313
+ const normalized = options.sources.map((source) => ({
1314
+ tier: source.tier,
1315
+ ...source.file === void 0 ? {} : { file: source.file },
1316
+ ...source.trust === void 0 ? {} : { trust: source.trust },
1317
+ value: validate(source.value, options.schema, {
1318
+ file: source.file ?? "",
1319
+ tier: source.tier,
1320
+ collector
1321
+ }).value
1322
+ }));
1323
+ return {
1324
+ resolved: merge(normalized, options.schema, { collector }),
1325
+ records: collector.records,
1326
+ droppedRecordCount: collector.droppedCount
1327
+ };
1328
+ } catch (error) {
1329
+ const anchor = anchorSource(options.sources);
1330
+ const file = anchor?.file ?? "";
1331
+ collector.add({
1332
+ code: "PILENS_CFG_0008",
1333
+ file,
1334
+ key: "",
1335
+ subject: migrationSubject(file, ""),
1336
+ reason: `config resolution failed internally (${errorClassName(error)}); configuration ignored`,
1337
+ ...anchor ? { tier: anchor.tier } : {}
1338
+ });
1339
+ return {
1340
+ // The empty resolution, built by the merger from no sources rather than
1341
+ // asserted into existence: `merge([])` is already "nothing resolved".
1342
+ resolved: merge([], options.schema),
1343
+ records: collector.records,
1344
+ droppedRecordCount: collector.droppedCount
1345
+ };
1346
+ }
1347
+ }
1348
+
1349
+ // dist/clients/config-schema.js
1350
+ var CONFIG_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
1351
+ function opaque(tier) {
1352
+ return { [STABILITY_TIER_KEY]: tier };
1353
+ }
1354
+ var LSP_KEY_TYPES = {
1355
+ servers: "object",
1356
+ serverOverrides: "object",
1357
+ disabledServers: "array",
1358
+ warmFiles: "array"
1359
+ };
1360
+ var LSP_KEY_DENY = {
1361
+ disabledServers: "array-union"
1362
+ };
1363
+ function denyAnnotation(key) {
1364
+ const policy = LSP_KEY_DENY[key];
1365
+ return policy === void 0 ? {} : { [DENY_KEY]: policy };
1366
+ }
1367
+ function lspServerEntryNode() {
1368
+ return {
1369
+ type: "object",
1370
+ additionalProperties: true,
1371
+ [STABILITY_TIER_KEY]: "experimental",
1372
+ properties: {
1373
+ covers: {
1374
+ type: "array",
1375
+ items: { type: "string", [STABILITY_TIER_KEY]: "experimental" },
1376
+ [MERGE_STRATEGY_KEY]: "replace",
1377
+ [STABILITY_TIER_KEY]: "experimental"
1378
+ }
1379
+ }
1380
+ };
1381
+ }
1382
+ function lspNamespace() {
1383
+ const properties = {
1384
+ // Reserved but deliberately UNTYPED. `lens-config.ts` already rejects a
1385
+ // non-boolean here with `lsp.enabled must be a boolean` — a message that
1386
+ // names the key and the expected type — and it is the one every flag in
1387
+ // the registry shares. Declaring `type: "boolean"` would make `validate()`
1388
+ // drop the value first and replace that message with the core's generic
1389
+ // `expected boolean, got string`, which is strictly less useful. The flag
1390
+ // sections move into the schema when their diagnostics do, not before.
1391
+ enabled: { [STABILITY_TIER_KEY]: "stable" }
1392
+ };
1393
+ for (const key of LEGACY_ROOT_LSP_KEYS) {
1394
+ const declared = LSP_KEY_TYPES[key];
1395
+ properties[key] = {
1396
+ ...declared ? { type: declared } : {},
1397
+ [STABILITY_TIER_KEY]: "experimental",
1398
+ ...declared === "object" ? key === "servers" ? (
1399
+ // #3968: server entries are TYPED — each carries the covers
1400
+ // claim node — while staying open on every other field.
1401
+ { additionalProperties: lspServerEntryNode() }
1402
+ ) : { additionalProperties: true } : {},
1403
+ ...denyAnnotation(key)
1404
+ };
1405
+ }
1406
+ return {
1407
+ type: "object",
1408
+ additionalProperties: true,
1409
+ [STABILITY_TIER_KEY]: "stable",
1410
+ properties
1411
+ };
1412
+ }
1413
+ function buildConfigSchema() {
1414
+ const properties = {};
1415
+ for (const key of [
1416
+ ...flagConfigSectionKeys(LENS_FLAGS),
1417
+ ...GLOBAL_NON_FLAG_CONFIG_SECTIONS,
1418
+ ...PROJECT_NON_FLAG_CONFIG_SECTIONS
1419
+ ]) {
1420
+ properties[key] = opaque("stable");
1421
+ }
1422
+ properties.tools = {
1423
+ type: "object",
1424
+ additionalProperties: true,
1425
+ properties: Object.fromEntries(LENS_TOOL_NAMES.map((name) => [
1426
+ name,
1427
+ {
1428
+ type: "object",
1429
+ additionalProperties: true,
1430
+ properties: {
1431
+ enabled: { type: "boolean", [STABILITY_TIER_KEY]: "experimental" }
1432
+ },
1433
+ [STABILITY_TIER_KEY]: "experimental"
1434
+ }
1435
+ ])),
1436
+ [STABILITY_TIER_KEY]: "stable"
1437
+ };
1438
+ for (const key of PROJECT_FOREIGN_CONFIG_NAMESPACES) {
1439
+ properties[key] ??= opaque("experimental");
1440
+ }
1441
+ for (const key of [
1442
+ "knip",
1443
+ "jscpd",
1444
+ "madge",
1445
+ "gitleaks",
1446
+ "govulncheck",
1447
+ "deadCode",
1448
+ "complexity"
1449
+ ]) {
1450
+ properties[key] = {
1451
+ type: "object",
1452
+ additionalProperties: true,
1453
+ properties: {
1454
+ enabled: { type: "boolean", [STABILITY_TIER_KEY]: "experimental" }
1455
+ },
1456
+ [STABILITY_TIER_KEY]: "stable"
1457
+ };
1458
+ }
1459
+ properties.startup = {
1460
+ type: "object",
1461
+ additionalProperties: true,
1462
+ properties: {
1463
+ mode: {
1464
+ type: "string",
1465
+ enum: ["quick", "full", "minimal"],
1466
+ [STABILITY_TIER_KEY]: "experimental"
1467
+ },
1468
+ scans: {
1469
+ type: "object",
1470
+ additionalProperties: true,
1471
+ properties: {
1472
+ enabled: { type: "boolean", [STABILITY_TIER_KEY]: "experimental" }
1473
+ },
1474
+ [STABILITY_TIER_KEY]: "experimental"
1475
+ }
1476
+ },
1477
+ [STABILITY_TIER_KEY]: "stable"
1478
+ };
1479
+ for (const key of LEGACY_ROOT_LSP_KEYS) {
1480
+ properties[key] = opaque("experimental");
1481
+ }
1482
+ properties[LSP_NAMESPACE_KEY] = lspNamespace();
1483
+ properties[CONFIG_SCHEMA_ANCHOR_KEY] = {
1484
+ type: "string",
1485
+ description: "Identity anchor naming the schema version this config was written against.",
1486
+ [STABILITY_TIER_KEY]: "stable"
1487
+ };
1488
+ return {
1489
+ $schema: CONFIG_SCHEMA_DIALECT,
1490
+ $id: CONFIG_SCHEMA_ID,
1491
+ type: "object",
1492
+ // See shape 1 in the module doc: deliberately open, so the loaders keep
1493
+ // their own richer unknown-key diagnostics.
1494
+ additionalProperties: true,
1495
+ properties
1496
+ };
1497
+ }
1498
+ var PI_LENS_CONFIG_SCHEMA = buildConfigSchema();
1499
+
1500
+ // dist/clients/config-resolve.js
1501
+ function readConfigDocument(file) {
1502
+ let text;
1503
+ try {
1504
+ text = fs2.readFileSync(file, "utf-8");
1505
+ } catch (error) {
1506
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
1507
+ return { status: "missing" };
1508
+ }
1509
+ return { status: "error", error };
1510
+ }
1511
+ try {
1512
+ return { status: "ok", value: JSON.parse(text) };
1513
+ } catch (error) {
1514
+ return { status: "error", error, sourceText: text };
1515
+ }
1516
+ }
1517
+ function canonicalGlobalFile(options) {
1518
+ if (options.globalConfigPath !== void 0)
1519
+ return options.globalConfigPath;
1520
+ return options.globalDir === void 0 ? void 0 : path2.join(options.globalDir, CANONICAL_GLOBAL_CONFIG_FILE);
1521
+ }
1522
+ function collectDocuments(dir, locations, tier, onReadError) {
1523
+ const documents = [];
1524
+ for (const location of locations) {
1525
+ const file = path2.join(dir, location.relativePath);
1526
+ if (tier !== "global" && isResolvedGlobalConfigPath(file))
1527
+ continue;
1528
+ const outcome = readConfigDocument(file);
1529
+ if (outcome.status === "missing")
1530
+ continue;
1531
+ if (outcome.status === "error") {
1532
+ onReadError?.({
1533
+ file,
1534
+ location,
1535
+ tier,
1536
+ error: outcome.error,
1537
+ sourceText: outcome.sourceText
1538
+ });
1539
+ continue;
1540
+ }
1541
+ documents.push({ tier, file, location, value: outcome.value });
1542
+ }
1543
+ return documents;
1544
+ }
1545
+ function collectPiLensConfigDocuments(options) {
1546
+ const documents = [];
1547
+ const { globalDir, onReadError } = options;
1548
+ const globalConfigPath = canonicalGlobalFile(options);
1549
+ if (globalDir !== void 0 || globalConfigPath !== void 0) {
1550
+ for (const location of GLOBAL_CONFIG_LOCATIONS) {
1551
+ const file = location.relativePath === CANONICAL_GLOBAL_CONFIG_FILE ? globalConfigPath : globalDir === void 0 ? void 0 : path2.join(globalDir, location.relativePath);
1552
+ if (file === void 0)
1553
+ continue;
1554
+ const outcome = readConfigDocument(file);
1555
+ if (outcome.status === "missing")
1556
+ continue;
1557
+ if (outcome.status === "error") {
1558
+ onReadError?.({
1559
+ file,
1560
+ location,
1561
+ tier: "global",
1562
+ error: outcome.error,
1563
+ sourceText: outcome.sourceText
1564
+ });
1565
+ continue;
1566
+ }
1567
+ documents.push({ tier: "global", file, location, value: outcome.value });
1568
+ }
1569
+ }
1570
+ if (options.cwd !== void 0) {
1571
+ const dirs = configSearchDirs(options.cwd, options.homeDir ?? os.homedir()).reverse();
1572
+ const bearing = dirs.map((dir) => ({
1573
+ dir,
1574
+ found: collectDocuments(dir, PROJECT_CONFIG_LOCATIONS, "project", onReadError)
1575
+ })).filter((entry) => entry.found.length > 0);
1576
+ bearing.forEach((entry, index) => {
1577
+ const tier = index === 0 ? "project" : "nested-project";
1578
+ for (const document of entry.found)
1579
+ documents.push({ ...document, tier });
1580
+ });
1581
+ }
1582
+ return documents;
1583
+ }
1584
+ function emptyTierCounts() {
1585
+ return Object.fromEntries(SOURCE_TIERS.map((tier) => [tier, 0]));
1586
+ }
1587
+ function summarizeConfigResolution(resolution, homeDir) {
1588
+ const countsByTier = emptyTierCounts();
1589
+ for (const entry of resolution.provenance.values()) {
1590
+ countsByTier[entry.tier] += 1;
1591
+ }
1592
+ return {
1593
+ documents: resolution.documents.map((document) => ({
1594
+ tier: document.tier,
1595
+ file: homeRelativePath(document.file, homeDir),
1596
+ legacy: document.location.legacy
1597
+ })),
1598
+ countsByTier,
1599
+ recordCount: resolution.records.length
1600
+ };
1601
+ }
1602
+ function resolvePiLensConfig(options) {
1603
+ const documents = collectPiLensConfigDocuments(options);
1604
+ const sources = configSources(documents);
1605
+ const resolution = resolveConfig({
1606
+ sources,
1607
+ schema: PI_LENS_CONFIG_SCHEMA
1608
+ });
1609
+ return {
1610
+ value: resolution.resolved.value ?? {},
1611
+ provenance: resolution.resolved.provenance,
1612
+ records: finalizeRecords(
1613
+ [
1614
+ ...resolution.records,
1615
+ ...deprecationRecords(documents, options.homeDir ?? os.homedir(), canonicalGlobalFile(options))
1616
+ ],
1617
+ documentAnchor(documents),
1618
+ // The core ALREADY truncated (#2426 review round 6, F1). Its drop count
1619
+ // is seeded here so the one `PILENS_CFG_0007` a user reads names the
1620
+ // whole truncation rather than the part this bound performed.
1621
+ resolution.droppedRecordCount
1622
+ ),
1623
+ documents
1624
+ };
1625
+ }
1626
+ function resolveOnePiLensConfigDocument(document, homeDir = os.homedir()) {
1627
+ const resolution = resolveConfig({
1628
+ sources: [
1629
+ { tier: document.tier, file: document.file, value: document.value }
1630
+ ],
1631
+ schema: PI_LENS_CONFIG_SCHEMA
1632
+ });
1633
+ return {
1634
+ value: resolution.resolved.value ?? {},
1635
+ records: finalizeRecords(
1636
+ [...resolution.records, ...deprecationRecords([document], homeDir)],
1637
+ documentAnchor([document]),
1638
+ // Same double bound as the multi-document path above (round 6, F1).
1639
+ resolution.droppedRecordCount
1640
+ )
1641
+ };
1642
+ }
1643
+ function documentAnchor(documents) {
1644
+ const last = documents[documents.length - 1];
1645
+ return last === void 0 ? void 0 : { file: last.file, tier: last.tier };
1646
+ }
1647
+ function projectLocationFor(file) {
1648
+ const base = path2.basename(file);
1649
+ return PROJECT_CONFIG_LOCATIONS.find((candidate) => path2.posix.basename(candidate.relativePath) === base) ?? PROJECT_CONFIG_LOCATIONS[PROJECT_CONFIG_LOCATIONS.length - 1];
1650
+ }
1651
+ var WINDOW_BY_SURFACE = new Map(DEPRECATED_CONFIG_SURFACES.map((row) => [row.surface, row]));
1652
+ function windowSuffix(surface) {
1653
+ const row = surface === void 0 ? void 0 : WINDOW_BY_SURFACE.get(surface);
1654
+ return row ? ` (deprecated since ${row.deprecatedSince}; read for the last time before ${row.removeNotBefore})` : "";
1655
+ }
1656
+ function canonicalDestination(document, homeDir, globalFile) {
1657
+ if (document.tier === "global") {
1658
+ return homeRelativePath(globalFile ?? path2.join(path2.dirname(document.file), CANONICAL_GLOBAL_CONFIG_FILE), homeDir);
1659
+ }
1660
+ return CANONICAL_PROJECT_CONFIG_FILE;
1661
+ }
1662
+ function lspNamespaceKeyFor(document, key) {
1663
+ if (key === LSP_NAMESPACE_KEY)
1664
+ return void 0;
1665
+ if (document.location.lspScoped) {
1666
+ return recognizedKeysFor(document.location).has(key) ? key : void 0;
1667
+ }
1668
+ return LEGACY_ROOT_LSP_KEYS.includes(key) ? key : void 0;
1669
+ }
1670
+ function assignRaw(target, key, value) {
1671
+ Object.defineProperty(target, key, {
1672
+ value,
1673
+ writable: true,
1674
+ enumerable: true,
1675
+ configurable: true
1676
+ });
1677
+ }
1678
+ function configSources(documents) {
1679
+ const sources = [];
1680
+ for (const document of documents) {
1681
+ const value = document.value;
1682
+ const namespaced = {};
1683
+ const rest = {};
1684
+ for (const key of topLevelKeys(value)) {
1685
+ const entry = value[key];
1686
+ const target = lspNamespaceKeyFor(document, key);
1687
+ if (target === void 0)
1688
+ assignRaw(rest, key, entry);
1689
+ else
1690
+ assignRaw(namespaced, target, entry);
1691
+ }
1692
+ const base = { tier: document.tier, file: document.file };
1693
+ if (Object.keys(namespaced).length === 0) {
1694
+ sources.push({ ...base, value });
1695
+ continue;
1696
+ }
1697
+ sources.push({ ...base, value: { [LSP_NAMESPACE_KEY]: namespaced } });
1698
+ sources.push({ ...base, value: rest });
1699
+ }
1700
+ return sources;
1701
+ }
1702
+ function canonicalKeyFor(document, key) {
1703
+ const namespaced = lspNamespaceKeyFor(document, key);
1704
+ return namespaced === void 0 ? key : `${LSP_NAMESPACE_KEY}.${namespaced}`;
1705
+ }
1706
+ function topLevelKeys(value) {
1707
+ return value && typeof value === "object" && !Array.isArray(value) ? Object.keys(value) : [];
1708
+ }
1709
+ function schemaPropertyKeys(node) {
1710
+ const properties = node?.properties;
1711
+ return properties !== null && typeof properties === "object" && !Array.isArray(properties) ? Object.keys(properties) : [];
1712
+ }
1713
+ var CANONICAL_TOP_LEVEL_KEYS = new Set(schemaPropertyKeys(PI_LENS_CONFIG_SCHEMA));
1714
+ var LSP_DOCUMENT_KEYS = new Set(schemaPropertyKeys(PI_LENS_CONFIG_SCHEMA.properties?.[LSP_NAMESPACE_KEY]));
1715
+ function recognizedKeysFor(location) {
1716
+ return location.lspScoped ? LSP_DOCUMENT_KEYS : CANONICAL_TOP_LEVEL_KEYS;
1717
+ }
1718
+ function deprecationRecords(documents, homeDir, globalFile) {
1719
+ const records = [];
1720
+ for (const document of documents) {
1721
+ if (document.location.legacy) {
1722
+ const destination = canonicalDestination(document, homeDir, globalFile);
1723
+ const recognized = recognizedKeysFor(document.location);
1724
+ let unrecognized = 0;
1725
+ for (const key of topLevelKeys(document.value)) {
1726
+ if (!recognized.has(key)) {
1727
+ unrecognized += 1;
1728
+ continue;
1729
+ }
1730
+ const canonicalKey = canonicalKeyFor(document, key);
1731
+ records.push(record3({
1732
+ code: "PILENS_CFG_0003",
1733
+ file: document.file,
1734
+ key,
1735
+ canonicalKey,
1736
+ tier: document.tier,
1737
+ reason: `move "${key}" to ${destination}` + (canonicalKey === key ? "" : ` under "${canonicalKey}"`) + windowSuffix(document.location.surface)
1738
+ }));
1739
+ }
1740
+ if (unrecognized > 0) {
1741
+ const plural = unrecognized === 1 ? "it was" : "they were";
1742
+ records.push({
1743
+ code: "PILENS_CFG_0003",
1744
+ file: document.file,
1745
+ key: "",
1746
+ // An LSP-scoped legacy file moves WHOLESALE into the `lsp`
1747
+ // namespace, so naming that namespace is literally true here — and
1748
+ // it is what routes this record to the LSP loader's subsystem, the
1749
+ // same key-derived ownership every other record uses.
1750
+ ...document.location.lspScoped ? { canonicalKey: LSP_NAMESPACE_KEY } : {},
1751
+ subject: migrationSubject(document.file, ""),
1752
+ tier: document.tier,
1753
+ reason: `this file is at a deprecated location; move it to ${destination}. ` + (unrecognized === 1 ? "1 of its top-level keys is not a recognized pi-lens setting" : `${unrecognized} of its top-level keys are not recognized pi-lens settings`) + `, and ${plural} not migrated${windowSuffix(document.location.surface)}`
1754
+ });
1755
+ }
1756
+ continue;
1757
+ }
1758
+ for (const key of topLevelKeys(document.value)) {
1759
+ if (!LEGACY_ROOT_LSP_KEYS.includes(key))
1760
+ continue;
1761
+ const canonicalKey = `${LSP_NAMESPACE_KEY}.${key}`;
1762
+ records.push(record3({
1763
+ code: "PILENS_CFG_0002",
1764
+ file: document.file,
1765
+ key,
1766
+ canonicalKey,
1767
+ tier: document.tier,
1768
+ reason: `move "${key}" to "${canonicalKey}" in the same file${windowSuffix(key)}`
1769
+ }));
1770
+ }
1771
+ }
1772
+ return records;
1773
+ }
1774
+ function record3(input) {
1775
+ return {
1776
+ code: input.code,
1777
+ file: input.file,
1778
+ key: input.key,
1779
+ canonicalKey: input.canonicalKey,
1780
+ subject: migrationSubject(input.file, input.key),
1781
+ reason: input.reason,
1782
+ tier: input.tier
1783
+ };
1784
+ }
1785
+ function configRecordOwner(record4) {
1786
+ const key = record4.canonicalKey ?? record4.key;
1787
+ if (key.length === 0)
1788
+ return void 0;
1789
+ const head = (key.startsWith("/") ? key.slice(1) : key).split(/[./]/)[0] ?? "";
1790
+ if (head.length === 0)
1791
+ return void 0;
1792
+ return head === LSP_NAMESPACE_KEY || LEGACY_ROOT_LSP_KEYS.includes(head) ? "lsp" : "pi-lens";
1793
+ }
1794
+ function piLensSubsystemFor(tier) {
1795
+ if (tier === "global")
1796
+ return "lens-config";
1797
+ if (tier === "project" || tier === "nested-project") {
1798
+ return "project-lens-config";
1799
+ }
1800
+ return void 0;
1801
+ }
1802
+ function configRecordSubsystems(record4) {
1803
+ const owner = configRecordOwner(record4);
1804
+ const piLens = piLensSubsystemFor(record4.tier);
1805
+ const piLensSubsystems = piLens ? [piLens] : ["lens-config", "project-lens-config"];
1806
+ if (owner === "lsp")
1807
+ return ["lsp-config"];
1808
+ if (owner === "pi-lens")
1809
+ return piLensSubsystems;
1810
+ if (piLens)
1811
+ return [piLens];
1812
+ return ["lsp-config", ...piLensSubsystems];
1813
+ }
1814
+ function configFileSubsystem(location, tier) {
1815
+ if (location.lspScoped)
1816
+ return "lsp-config";
1817
+ return tier === "global" ? "lens-config" : "project-lens-config";
1818
+ }
1819
+ function reportConfigReadFailure(failure) {
1820
+ warnIgnoredConfigOnce({
1821
+ subsystem: configFileSubsystem(failure.location, failure.tier),
1822
+ file: failure.file,
1823
+ reason: { parseError: failure.error, sourceText: failure.sourceText }
1824
+ });
1825
+ }
1826
+ function reportPiLensConfigRecords(records) {
1827
+ for (const record4 of records) {
1828
+ for (const subsystem of configRecordSubsystems(record4)) {
1829
+ warnIgnoredConfigOnce({
1830
+ subsystem,
1831
+ file: record4.file,
1832
+ key: record4.key.length > 0 ? record4.key : void 0,
1833
+ reason: record4.reason,
1834
+ code: record4.code
1835
+ });
1836
+ }
1837
+ }
1838
+ }
1839
+ function ignoredRecordCollector(configPath, tier) {
1840
+ const noted = [];
1841
+ const note = (reason, code = "PILENS_CFG_0001") => {
1842
+ let notedRecord = {
1843
+ code: "PILENS_CFG_0001",
1844
+ file: configPath,
1845
+ key: "",
1846
+ subject: migrationSubject(configPath, ""),
1847
+ reason: typeof reason === "string" ? reason : normalizeParseErrorReason(reason.parseError, {
1848
+ sourceText: reason.sourceText
1849
+ }),
1850
+ tier
1851
+ };
1852
+ if (code !== "PILENS_CFG_0001")
1853
+ notedRecord.code = code;
1854
+ noted.push(notedRecord);
1855
+ };
1856
+ return {
1857
+ note,
1858
+ records: () => finalizeRecords(noted, { file: configPath, tier })
1859
+ };
1860
+ }
1861
+ function lspSectionOf(value) {
1862
+ const namespace = value[LSP_NAMESPACE_KEY];
1863
+ return namespace && typeof namespace === "object" && !Array.isArray(namespace) ? namespace : {};
1864
+ }
1865
+
1866
+ // dist/clients/project-lens-config.js
1867
+ var REVIEW_GRAPH_MAX_FILES_MIN = 100;
1868
+ var REVIEW_GRAPH_MAX_FILES_MAX = 2e4;
1869
+ var EMPTY_PROJECT_CONFIG = {
1870
+ ignore: [],
1871
+ rules: {},
1872
+ maxProjectFiles: void 0,
1873
+ reviewGraph: void 0,
1874
+ raw: void 0,
1875
+ configPath: void 0
1876
+ };
1877
+ var configCache = /* @__PURE__ */ new Map();
1878
+ var discoveryCache = /* @__PURE__ */ new Map();
1879
+ function loadCachedConfigFile(info) {
1880
+ const cached = configCache.get(info.path);
1881
+ if (cached && cached.mtimeMs === info.mtimeMs && cached.size === info.size) {
1882
+ replayConfigNotices(cached);
1883
+ return cached.config;
1884
+ }
1885
+ const parsed = parseConfigFile(info.path);
1886
+ const entry = {
1887
+ mtimeMs: info.mtimeMs,
1888
+ size: info.size,
1889
+ config: parsed.config,
1890
+ records: parsed.records,
1891
+ ignored: parsed.ignored
1892
+ };
1893
+ configCache.set(info.path, entry);
1894
+ replayConfigNotices(entry);
1895
+ return parsed.config;
1896
+ }
1897
+ function replayConfigNotices(entry) {
1898
+ reportPiLensConfigRecords(entry.records);
1899
+ for (const record4 of entry.ignored) {
1900
+ warnIgnoredConfigOnce({
1901
+ subsystem: "project-lens-config",
1902
+ file: record4.file,
1903
+ reason: record4.reason,
1904
+ code: record4.code
1905
+ });
1906
+ }
1907
+ }
1908
+ function loadPiLensProjectConfig(startDir, preloadedInfo) {
1909
+ const entry = discoveryEntryFor(startDir);
1910
+ const configInfo = preloadedInfo ?? freshInfoFor(entry);
1911
+ const selectedLegacyPath = configInfo?.path;
1912
+ reportPiLensConfigRecords(entry.legacyRecords.filter((record4) => record4.file !== selectedLegacyPath));
1913
+ if (!configInfo)
1914
+ return EMPTY_PROJECT_CONFIG;
1915
+ return loadCachedConfigFile(configInfo);
1916
+ }
1917
+ function findPiLensConfigInDir(dir) {
1918
+ const marker = findPiLensConfigMarkerInDir(dir);
1919
+ if (!marker)
1920
+ return void 0;
1921
+ return {
1922
+ path: marker.path,
1923
+ dir: marker.dir,
1924
+ mtimeMs: marker.mtimeMs,
1925
+ size: marker.size
1926
+ };
1927
+ }
1928
+ function findNestedProjectMutationValue(spec, editedFilePath, projectRoot, homeDir = os2.homedir()) {
1929
+ const root = path3.resolve(projectRoot);
1930
+ const start = path3.dirname(path3.resolve(editedFilePath));
1931
+ for (const dir of walkUpDirs(start)) {
1932
+ if (isAtOrAboveHomeDir(dir, homeDir))
1933
+ break;
1934
+ const rel = path3.relative(root, dir);
1935
+ if (rel.startsWith("..") || path3.isAbsolute(rel))
1936
+ break;
1937
+ const config = loadPiLensConfigInDir(dir);
1938
+ const enabled = readFlagConfigValue(config, spec.configKey);
1939
+ if (enabled !== void 0)
1940
+ return { value: enabled, dir };
1941
+ if (dir === root)
1942
+ break;
1943
+ }
1944
+ return void 0;
1945
+ }
1946
+ function loadPiLensConfigInDir(dir) {
1947
+ const info = findPiLensConfigInDir(dir);
1948
+ if (!info)
1949
+ return EMPTY_PROJECT_CONFIG;
1950
+ return loadCachedConfigFile(info);
1951
+ }
1952
+ function discoveryEntryFor(startDir) {
1953
+ const cacheKey = path3.resolve(startDir);
1954
+ const cached = discoveryCache.get(cacheKey);
1955
+ if (cached && discoveryCacheStillFresh(cached))
1956
+ return cached;
1957
+ const discovered = discoverPiLensProjectConfig(cacheKey);
1958
+ discoveryCache.set(cacheKey, discovered);
1959
+ return discovered;
1960
+ }
1961
+ function findPiLensProjectConfig(startDir) {
1962
+ return freshInfoFor(discoveryEntryFor(startDir));
1963
+ }
1964
+ function freshInfoFor(entry) {
1965
+ if (!entry.info)
1966
+ return void 0;
1967
+ const stat = safeFileStat(entry.info.path);
1968
+ if (!stat?.isFile())
1969
+ return entry.info;
1970
+ return { ...entry.info, mtimeMs: stat.mtimeMs, size: stat.size };
1971
+ }
1972
+ function safeFileStat(filePath) {
1973
+ try {
1974
+ return fs3.statSync(filePath);
1975
+ } catch {
1976
+ return void 0;
1977
+ }
1978
+ }
1979
+ function safeDirMtimeMs(dir) {
1980
+ try {
1981
+ return fs3.statSync(dir).mtimeMs;
1982
+ } catch {
1983
+ return -1;
1984
+ }
1985
+ }
1986
+ function discoveryCacheStillFresh(entry) {
1987
+ if (!dirMtimesStillFresh(entry.dirMtimes)) {
1988
+ return false;
1989
+ }
1990
+ if (entry.info === void 0 && Date.now() - entry.checkedAtMs >= FRESHNESS_CADENCE_MS) {
1991
+ return false;
1992
+ }
1993
+ return entry.legacySources.every((source) => {
1994
+ const stat = safeFileStat(source.path);
1995
+ return stat?.isFile() === true && stat.mtimeMs === source.mtimeMs && stat.size === source.size;
1996
+ });
1997
+ }
1998
+ var LEGACY_PROJECT_LOCATIONS = PROJECT_CONFIG_LOCATIONS.filter((location) => location.legacy);
1999
+ function discoverPiLensProjectConfig(startDir) {
2000
+ const dirMtimes = [];
2001
+ const legacyDocuments = [];
2002
+ const legacySources = [];
2003
+ let info;
2004
+ for (const dir of configSearchDirs(startDir)) {
2005
+ dirMtimes.push({ dir, mtimeMs: safeDirMtimeMs(dir) });
2006
+ if (!info) {
2007
+ for (const name of PROJECT_CONFIG_BASENAMES) {
2008
+ const candidate = path3.join(dir, name);
2009
+ if (isResolvedGlobalConfigPath(candidate))
2010
+ continue;
2011
+ const stat = safeFileStat(candidate);
2012
+ if (stat?.isFile()) {
2013
+ info = {
2014
+ path: candidate,
2015
+ dir,
2016
+ mtimeMs: stat.mtimeMs,
2017
+ size: stat.size
2018
+ };
2019
+ break;
2020
+ }
2021
+ }
2022
+ }
2023
+ for (const location of LEGACY_PROJECT_LOCATIONS) {
2024
+ const file = path3.join(dir, location.relativePath);
2025
+ if (isResolvedGlobalConfigPath(file))
2026
+ continue;
2027
+ const stat = safeFileStat(file);
2028
+ if (!stat?.isFile())
2029
+ continue;
2030
+ legacySources.push({
2031
+ path: file,
2032
+ mtimeMs: stat.mtimeMs,
2033
+ size: stat.size
2034
+ });
2035
+ const outcome = readConfigDocument(file);
2036
+ if (outcome.status === "error") {
2037
+ reportConfigReadFailure({
2038
+ file,
2039
+ location,
2040
+ tier: "project",
2041
+ error: outcome.error,
2042
+ sourceText: outcome.sourceText
2043
+ });
2044
+ continue;
2045
+ }
2046
+ if (outcome.status !== "ok")
2047
+ continue;
2048
+ legacyDocuments.push({
2049
+ tier: "project",
2050
+ file,
2051
+ location,
2052
+ value: outcome.value
2053
+ });
2054
+ }
2055
+ }
2056
+ return {
2057
+ info,
2058
+ dirMtimes: bearingDirMtimes(dirMtimes, info),
2059
+ legacyRecords: legacyDeprecationRecords(legacyDocuments),
2060
+ legacySources,
2061
+ checkedAtMs: Date.now()
2062
+ };
2063
+ }
2064
+ function legacyDeprecationRecords(documents) {
2065
+ const home = os2.homedir();
2066
+ return documents.flatMap((document) => finalizeRecords(deprecationRecords([document], home), {
2067
+ file: document.file,
2068
+ tier: document.tier
2069
+ }));
2070
+ }
2071
+ function bearingDirMtimes(dirMtimes, info) {
2072
+ if (info) {
2073
+ const bearing = dirMtimes.findIndex((entry) => entry.dir === info.dir);
2074
+ return bearing < 0 ? [...dirMtimes] : dirMtimes.slice(0, bearing + 1);
2075
+ }
2076
+ return dirMtimes.slice(0, 1);
2077
+ }
2078
+ function parseRulePolicyList(note, ruleId, key, value) {
2079
+ if (!Array.isArray(value)) {
2080
+ note(`rules.${ruleId}.${key} must be an array of strings`);
2081
+ return { list: [], invalid: true };
2082
+ }
2083
+ const list = [];
2084
+ for (const entry of value) {
2085
+ if (typeof entry !== "string")
2086
+ continue;
2087
+ const trimmed = entry.trim();
2088
+ if (trimmed.length > 0)
2089
+ list.push(trimmed);
2090
+ }
2091
+ if (list.length === 0) {
2092
+ if (value.length > 0) {
2093
+ note(`rules.${ruleId}.${key} must contain at least one non-empty string`);
2094
+ return { list: [], invalid: true };
2095
+ }
2096
+ return { list: [], invalid: false };
2097
+ }
2098
+ return { list, invalid: false };
2099
+ }
2100
+ var NO_RECORDS = [];
2101
+ function parseConfigFile(configPath) {
2102
+ const { note, records: ignoredRecords } = ignoredRecordCollector(configPath, "project");
2103
+ const outcome = readConfigDocument(configPath);
2104
+ if (outcome.status === "error") {
2105
+ note({ parseError: outcome.error, sourceText: outcome.sourceText });
2106
+ return {
2107
+ config: EMPTY_PROJECT_CONFIG,
2108
+ records: NO_RECORDS,
2109
+ ignored: ignoredRecords()
2110
+ };
2111
+ }
2112
+ if (outcome.status === "missing") {
2113
+ return {
2114
+ config: EMPTY_PROJECT_CONFIG,
2115
+ records: NO_RECORDS,
2116
+ ignored: NO_RECORDS
2117
+ };
2118
+ }
2119
+ if (!outcome.value || typeof outcome.value !== "object" || Array.isArray(outcome.value)) {
2120
+ note("top-level value must be an object");
2121
+ return {
2122
+ config: EMPTY_PROJECT_CONFIG,
2123
+ records: NO_RECORDS,
2124
+ ignored: ignoredRecords()
2125
+ };
2126
+ }
2127
+ const resolved = resolveOnePiLensConfigDocument({
2128
+ tier: "project",
2129
+ file: configPath,
2130
+ location: projectLocationFor(configPath),
2131
+ value: outcome.value
2132
+ });
2133
+ const raw = resolved.value;
2134
+ const obj = resolved.value;
2135
+ const ignore = Array.isArray(obj.ignore) ? obj.ignore.filter((p) => typeof p === "string") : [];
2136
+ const mutations = {};
2137
+ for (const spec of PROJECT_SCOPED_LENS_FLAGS) {
2138
+ assignFlagConfigSection(obj, mutations, spec.configKey, note);
2139
+ }
2140
+ const toolConfig = readToolConfig(obj, note);
2141
+ const rules = {};
2142
+ if (obj.rules && typeof obj.rules === "object" && !Array.isArray(obj.rules)) {
2143
+ const rawRules = obj.rules;
2144
+ for (const [ruleId, ruleCfg] of Object.entries(rawRules)) {
2145
+ if (!ruleCfg || typeof ruleCfg !== "object" || Array.isArray(ruleCfg)) {
2146
+ note(`rules.${ruleId} must be an object with threshold, disable, or select; ignored`);
2147
+ continue;
2148
+ }
2149
+ const r = ruleCfg;
2150
+ const entry = {};
2151
+ if (typeof r.threshold === "number" && Number.isFinite(r.threshold) && r.threshold > 0) {
2152
+ entry.threshold = r.threshold;
2153
+ } else if ("threshold" in r) {
2154
+ note(`rules.${ruleId}.threshold must be a positive finite number`);
2155
+ }
2156
+ if ("disable" in r) {
2157
+ const parsed = parseRulePolicyList(note, ruleId, "disable", r.disable);
2158
+ if (!parsed.invalid && parsed.list.length > 0)
2159
+ entry.disable = parsed.list;
2160
+ }
2161
+ if ("select" in r) {
2162
+ const parsed = parseRulePolicyList(note, ruleId, "select", r.select);
2163
+ if (!parsed.invalid && parsed.list.length > 0)
2164
+ entry.select = parsed.list;
2165
+ }
2166
+ if (entry.threshold !== void 0 || entry.disable || entry.select) {
2167
+ rules[ruleId] = entry;
2168
+ } else if (!("threshold" in r) && !("disable" in r) && !("select" in r)) {
2169
+ note(`rules.${ruleId} has no recognized setting (threshold, disable, select); ignored`);
2170
+ }
2171
+ }
2172
+ }
2173
+ let maxProjectFiles;
2174
+ if ("maxProjectFiles" in obj) {
2175
+ if (typeof obj.maxProjectFiles === "number" && Number.isFinite(obj.maxProjectFiles) && obj.maxProjectFiles > 0) {
2176
+ maxProjectFiles = obj.maxProjectFiles;
2177
+ } else {
2178
+ note("maxProjectFiles must be a positive finite number");
2179
+ }
2180
+ }
2181
+ let reviewGraph;
2182
+ if (obj.reviewGraph !== void 0) {
2183
+ if (!obj.reviewGraph || typeof obj.reviewGraph !== "object" || Array.isArray(obj.reviewGraph)) {
2184
+ note("reviewGraph must be an object");
2185
+ } else {
2186
+ const rg = obj.reviewGraph;
2187
+ if ("maxFiles" in rg) {
2188
+ const parsed = toPositiveFinite(rg.maxFiles);
2189
+ if (parsed > 0) {
2190
+ const clamped = Math.min(REVIEW_GRAPH_MAX_FILES_MAX, Math.max(REVIEW_GRAPH_MAX_FILES_MIN, Math.floor(parsed)));
2191
+ reviewGraph = { maxFiles: clamped };
2192
+ } else {
2193
+ note("reviewGraph.maxFiles must be a positive finite number");
2194
+ }
2195
+ }
2196
+ }
2197
+ }
2198
+ let startup;
2199
+ if (obj.startup !== void 0) {
2200
+ if (!obj.startup || typeof obj.startup !== "object" || Array.isArray(obj.startup)) {
2201
+ note("startup must be an object");
2202
+ } else {
2203
+ const section = obj.startup;
2204
+ if (section.mode === "quick" || section.mode === "full" || section.mode === "minimal") {
2205
+ startup = { mode: section.mode };
2206
+ } else if ("mode" in section) {
2207
+ note('startup.mode must be "quick", "full", or "minimal"');
2208
+ }
2209
+ if (section.scans !== void 0) {
2210
+ if (!section.scans || typeof section.scans !== "object" || Array.isArray(section.scans)) {
2211
+ note("startup.scans must be an object");
2212
+ } else if (typeof section.scans.enabled === "boolean") {
2213
+ startup ??= {};
2214
+ startup.scans = {
2215
+ enabled: section.scans.enabled
2216
+ };
2217
+ } else if ("enabled" in section.scans) {
2218
+ note("startup.scans.enabled must be a boolean");
2219
+ }
2220
+ }
2221
+ }
2222
+ }
2223
+ const knownProjectKeys = /* @__PURE__ */ new Set([
2224
+ ...PROJECT_NON_FLAG_CONFIG_SECTIONS,
2225
+ ...flagConfigSectionKeys(PROJECT_SCOPED_LENS_FLAGS),
2226
+ ...PROJECT_FOREIGN_CONFIG_NAMESPACES
2227
+ ]);
2228
+ const globalScopeOnlyKeys = new Set([
2229
+ ...flagConfigSectionKeys(LENS_FLAGS),
2230
+ ...GLOBAL_NON_FLAG_CONFIG_SECTIONS
2231
+ ].filter((key) => !knownProjectKeys.has(key)));
2232
+ const projectScoped = new Set(PROJECT_SCOPED_LENS_FLAGS.map((spec) => spec.configKey));
2233
+ const globalScopeOnlyFlagKeys = LENS_FLAGS.map((spec) => spec.configKey).filter((configKey) => !projectScoped.has(configKey));
2234
+ const globalScopeOnlyDottedKeys = [
2235
+ ...globalScopeOnlyFlagKeys,
2236
+ ...GLOBAL_ONLY_NON_FLAG_KEYS
2237
+ ];
2238
+ const globalConfigLabel = homeRelativePath(getPiLensGlobalConfigPath(), os2.homedir());
2239
+ const warnUnhonoredKey = (label, globalOnly) => {
2240
+ if (!globalOnly) {
2241
+ note(`unknown key "${label}" is not a recognized pi-lens setting (check for a typo); ignored`);
2242
+ return;
2243
+ }
2244
+ const hasCliFlag = LENS_FLAGS.some(({ configKey }) => configKey === label || configKey.startsWith(`${label}.`));
2245
+ const cliClause = hasCliFlag ? " or pass the matching CLI flag" : "";
2246
+ note(`"${label}" is a global-only pi-lens setting and is not honored in a project .pi-lens.json (set it in ${globalConfigLabel}${cliClause}); ignored`);
2247
+ };
2248
+ for (const key of Object.keys(obj)) {
2249
+ if (knownProjectKeys.has(key))
2250
+ continue;
2251
+ warnUnhonoredKey(key, globalScopeOnlyKeys.has(key));
2252
+ }
2253
+ for (const [namespace, honored] of PROJECT_FOREIGN_NAMESPACE_HONORED_KEYS) {
2254
+ const section = obj[namespace];
2255
+ if (!section || typeof section !== "object" || Array.isArray(section)) {
2256
+ continue;
2257
+ }
2258
+ for (const key of Object.keys(section)) {
2259
+ if (honored.includes(key))
2260
+ continue;
2261
+ const dotted = `${namespace}.${key}`;
2262
+ warnUnhonoredKey(dotted, globalScopeOnlyDottedKeys.some((configKey) => configKey === dotted || configKey.startsWith(`${dotted}.`)));
2263
+ }
2264
+ }
2265
+ for (const configKey of globalScopeOnlyDottedKeys) {
2266
+ const dotIndex = configKey.indexOf(".");
2267
+ if (dotIndex < 0)
2268
+ continue;
2269
+ if (!knownProjectKeys.has(configKey.slice(0, dotIndex)))
2270
+ continue;
2271
+ if (!hasFlagConfigPath(obj, configKey))
2272
+ continue;
2273
+ warnUnhonoredKey(configKey, true);
2274
+ }
2275
+ return {
2276
+ config: {
2277
+ ...toolConfig === void 0 ? {} : { tools: toolConfig },
2278
+ ...startup === void 0 ? {} : { startup },
2279
+ ignore,
2280
+ rules,
2281
+ ...mutations,
2282
+ maxProjectFiles,
2283
+ reviewGraph,
2284
+ raw,
2285
+ configPath
2286
+ },
2287
+ records: resolved.records,
2288
+ ignored: ignoredRecords()
2289
+ };
2290
+ }
2291
+
2292
+ export {
2293
+ isGeneratedArtifactDirectoryName,
2294
+ isDeclarationFile,
2295
+ classifyGeneratedOrArtifactDetailed,
2296
+ isTestFileName,
2297
+ detectFileRole,
2298
+ notifyUserDegradation,
2299
+ warnIgnoredConfigOnce,
2300
+ provenanceView,
2301
+ provenanceFor,
2302
+ compareKeys,
2303
+ migrationSubject,
2304
+ readConfigDocument,
2305
+ summarizeConfigResolution,
2306
+ resolvePiLensConfig,
2307
+ resolveOnePiLensConfigDocument,
2308
+ reportConfigReadFailure,
2309
+ reportPiLensConfigRecords,
2310
+ ignoredRecordCollector,
2311
+ lspSectionOf,
2312
+ loadPiLensProjectConfig,
2313
+ findPiLensConfigInDir,
2314
+ findNestedProjectMutationValue,
2315
+ loadPiLensConfigInDir,
2316
+ findPiLensProjectConfig
2317
+ };