pi-lens 4.3.0 → 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 (650) hide show
  1. package/CHANGELOG.md +1064 -0
  2. package/README.md +115 -25
  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 +16456 -8335
  125. package/dist/mcp/analyze-cli.js +186 -232
  126. package/dist/mcp/cli.js +137 -98
  127. package/dist/mcp/server.js +22589 -1573
  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/agent-guide.md +13 -4
  133. package/docs/agent-tools.md +42 -0
  134. package/docs/ast-grep_rules_catalog.md +3 -2
  135. package/docs/configuration.md +20 -1
  136. package/docs/environment-variables.md +52 -2
  137. package/docs/features.md +8 -4
  138. package/docs/globalconfig.md +1 -0
  139. package/docs/io-bridge-v2-migration.md +94 -0
  140. package/docs/lsp-capability-matrix.md +36 -4
  141. package/docs/lsp-idle-eviction.md +124 -0
  142. package/docs/mcp.md +21 -5
  143. package/docs/merge-queue-rollout.md +77 -0
  144. package/docs/pi-lens-fixer.md +156 -88
  145. package/docs/pi-lens-investigator.md +74 -26
  146. package/docs/pi-lens-merge-policy.md +694 -0
  147. package/docs/pi-lens-monitor.md +73 -7
  148. package/docs/pi-lens-retro.md +6 -4
  149. package/docs/pi-lens-reviewer.md +188 -48
  150. package/docs/pi-lens-subagent.md +246 -45
  151. package/docs/pi-lens-warden.md +18 -7
  152. package/docs/public-api-stability.md +55 -0
  153. package/docs/release-qa-baseline.md +84 -17
  154. package/docs/rfcs/3654-unified-io-bridge-v2.md +316 -0
  155. package/docs/servercapabilities.md +53 -49
  156. package/docs/settings.md +1 -0
  157. package/docs/usage.md +5 -1
  158. package/grammars/tree-sitter-bash.wasm +0 -0
  159. package/grammars/tree-sitter-bash.wasm.json +3 -3
  160. package/package.json +19 -7
  161. package/rules/ast-grep-rules/rule-tests/advisory-registry-subset-test.yml +41 -0
  162. package/rules/ast-grep-rules/rules/advisory-registry-subset.yml +50 -0
  163. package/scripts/analyze-pi-lens-logs.mjs +1275 -62
  164. package/scripts/download-grammars.js +5 -0
  165. package/scripts/grammars.lock.json +6 -1
  166. package/scripts/install-selftest.mjs +33 -34
  167. package/scripts/lib/host-provided-deps.mjs +13 -4
  168. package/scripts/lib/web-tree-sitter-dir.mjs +18 -0
  169. package/dist/clients/actionable-warnings-logger.js +0 -35
  170. package/dist/clients/actionable-warnings.js +0 -1610
  171. package/dist/clients/advisory-provenance.js +0 -593
  172. package/dist/clients/agent-behavior-client.js +0 -147
  173. package/dist/clients/agent-nudge.js +0 -325
  174. package/dist/clients/analysed-root.js +0 -1
  175. package/dist/clients/ast-grep-client.js +0 -731
  176. package/dist/clients/ast-grep-rule-manager.js +0 -146
  177. package/dist/clients/ast-grep-tool-logger.js +0 -118
  178. package/dist/clients/ast-grep-types.js +0 -10
  179. package/dist/clients/ast-grep-yaml-synth.js +0 -154
  180. package/dist/clients/atomic-write-staging.js +0 -75
  181. package/dist/clients/atomic-write.js +0 -189
  182. package/dist/clients/availability-probe-flight.js +0 -12
  183. package/dist/clients/bash-file-access.js +0 -1056
  184. package/dist/clients/biome-client.js +0 -357
  185. package/dist/clients/blocker-freshness.js +0 -837
  186. package/dist/clients/blocker-past-eof.js +0 -129
  187. package/dist/clients/bootstrap.js +0 -569
  188. package/dist/clients/bounded-cache.js +0 -190
  189. package/dist/clients/bounded-pid-file-lock.js +0 -202
  190. package/dist/clients/bounded-telemetry.js +0 -295
  191. package/dist/clients/build-identity.js +0 -95
  192. package/dist/clients/bundled-resource-health.js +0 -113
  193. package/dist/clients/bus-events-logger.js +0 -105
  194. package/dist/clients/bus-publish.js +0 -171
  195. package/dist/clients/cache/rule-cache.js +0 -190
  196. package/dist/clients/cache-manager.js +0 -524
  197. package/dist/clients/cache-observability.js +0 -1313
  198. package/dist/clients/call-graph.js +0 -852
  199. package/dist/clients/cargo-manifest.js +0 -422
  200. package/dist/clients/cascade-budget.js +0 -196
  201. package/dist/clients/cascade-format.js +0 -315
  202. package/dist/clients/cascade-logger.js +0 -31
  203. package/dist/clients/cascade-types.js +0 -9
  204. package/dist/clients/child-unref.js +0 -124
  205. package/dist/clients/code-quality-warnings.js +0 -286
  206. package/dist/clients/codebase-model.js +0 -173
  207. package/dist/clients/collateral-test-role.js +0 -40
  208. package/dist/clients/complexity-client.js +0 -462
  209. package/dist/clients/config-core/deny.js +0 -221
  210. package/dist/clients/config-core/index.js +0 -50
  211. package/dist/clients/config-core/merge.js +0 -357
  212. package/dist/clients/config-core/normalize.js +0 -340
  213. package/dist/clients/config-core/process-spec.js +0 -248
  214. package/dist/clients/config-core/provenance.js +0 -164
  215. package/dist/clients/config-core/records.js +0 -218
  216. package/dist/clients/config-core/resolve.js +0 -125
  217. package/dist/clients/config-core/safe-object.js +0 -78
  218. package/dist/clients/config-core/schema.js +0 -165
  219. package/dist/clients/config-diagnostic-codes.js +0 -285
  220. package/dist/clients/config-locations.js +0 -388
  221. package/dist/clients/config-resolve.js +0 -798
  222. package/dist/clients/config-schema.js +0 -251
  223. package/dist/clients/config-warn.js +0 -407
  224. package/dist/clients/console-guard-install.js +0 -26
  225. package/dist/clients/cooperative-budget.js +0 -42
  226. package/dist/clients/dead-code-client.js +0 -510
  227. package/dist/clients/dead-code-logger.js +0 -30
  228. package/dist/clients/deadline-utils.js +0 -280
  229. package/dist/clients/debug-handles.js +0 -211
  230. package/dist/clients/debug-heap.js +0 -174
  231. package/dist/clients/deferred-lsp-work.js +0 -106
  232. package/dist/clients/degradation-ledger.js +0 -426
  233. package/dist/clients/demoted-finding-render.js +0 -169
  234. package/dist/clients/dependency-checker.js +0 -885
  235. package/dist/clients/deps/ast-grep-napi.js +0 -22
  236. package/dist/clients/deps/js-yaml.js +0 -9
  237. package/dist/clients/deps/minimatch.js +0 -4
  238. package/dist/clients/deps/pi-tui.js +0 -14
  239. package/dist/clients/deps/typebox.js +0 -14
  240. package/dist/clients/deps/vscode-jsonrpc.js +0 -1
  241. package/dist/clients/deps/web-tree-sitter.js +0 -24
  242. package/dist/clients/diagnostic-dispositions.js +0 -630
  243. package/dist/clients/diagnostic-line-freshness.js +0 -305
  244. package/dist/clients/diagnostic-logger.js +0 -73
  245. package/dist/clients/diagnostic-tracker.js +0 -105
  246. package/dist/clients/diagnostics-publish.js +0 -230
  247. package/dist/clients/dispatch/ast-grep-catalog.js +0 -65
  248. package/dist/clients/dispatch/auxiliary-lsp.js +0 -343
  249. package/dist/clients/dispatch/collect-later-tier.js +0 -35
  250. package/dist/clients/dispatch/diagnostic-taxonomy.js +0 -66
  251. package/dist/clients/dispatch/dispatcher.js +0 -1269
  252. package/dist/clients/dispatch/fact-provider-types.js +0 -1
  253. package/dist/clients/dispatch/fact-rule-runner.js +0 -17
  254. package/dist/clients/dispatch/fact-runner.js +0 -30
  255. package/dist/clients/dispatch/fact-scheduler.js +0 -68
  256. package/dist/clients/dispatch/fact-store.js +0 -377
  257. package/dist/clients/dispatch/facts/comment-facts.js +0 -22
  258. package/dist/clients/dispatch/facts/file-content.js +0 -19
  259. package/dist/clients/dispatch/facts/function-facts.js +0 -348
  260. package/dist/clients/dispatch/facts/import-facts.js +0 -204
  261. package/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -34
  262. package/dist/clients/dispatch/facts/try-catch-facts.js +0 -119
  263. package/dist/clients/dispatch/finding-policy.js +0 -339
  264. package/dist/clients/dispatch/indent-detect.js +0 -417
  265. package/dist/clients/dispatch/inline-suppressions.js +0 -89
  266. package/dist/clients/dispatch/integration.js +0 -2377
  267. package/dist/clients/dispatch/lazy.js +0 -11
  268. package/dist/clients/dispatch/pending-runner-findings.js +0 -87
  269. package/dist/clients/dispatch/plan.js +0 -278
  270. package/dist/clients/dispatch/priorities.js +0 -20
  271. package/dist/clients/dispatch/rule-id-normalize.js +0 -50
  272. package/dist/clients/dispatch/rule-ignores.js +0 -69
  273. package/dist/clients/dispatch/rule-policy.js +0 -135
  274. package/dist/clients/dispatch/rules/async-noise.js +0 -40
  275. package/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
  276. package/dist/clients/dispatch/rules/cors-wildcard.js +0 -54
  277. package/dist/clients/dispatch/rules/error-obscuring.js +0 -32
  278. package/dist/clients/dispatch/rules/error-swallowing.js +0 -31
  279. package/dist/clients/dispatch/rules/framework-call-noise.js +0 -67
  280. package/dist/clients/dispatch/rules/high-complexity.js +0 -72
  281. package/dist/clients/dispatch/rules/high-fan-out.js +0 -74
  282. package/dist/clients/dispatch/rules/high-import-coupling.js +0 -37
  283. package/dist/clients/dispatch/rules/missing-error-propagation.js +0 -62
  284. package/dist/clients/dispatch/rules/no-commented-credentials.js +0 -52
  285. package/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -42
  286. package/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
  287. package/dist/clients/dispatch/rules/unsafe-boundary.js +0 -126
  288. package/dist/clients/dispatch/runner-context.js +0 -52
  289. package/dist/clients/dispatch/runners/actionlint.js +0 -111
  290. package/dist/clients/dispatch/runners/ast-grep-napi.js +0 -1196
  291. package/dist/clients/dispatch/runners/biome-check.js +0 -296
  292. package/dist/clients/dispatch/runners/cpp-check.js +0 -219
  293. package/dist/clients/dispatch/runners/credo.js +0 -82
  294. package/dist/clients/dispatch/runners/cue-vet.js +0 -416
  295. package/dist/clients/dispatch/runners/dart-analyze.js +0 -183
  296. package/dist/clients/dispatch/runners/detekt.js +0 -176
  297. package/dist/clients/dispatch/runners/dotnet-build.js +0 -164
  298. package/dist/clients/dispatch/runners/elixir-check.js +0 -195
  299. package/dist/clients/dispatch/runners/eslint.js +0 -137
  300. package/dist/clients/dispatch/runners/fact-rules.js +0 -29
  301. package/dist/clients/dispatch/runners/fish-indent.js +0 -69
  302. package/dist/clients/dispatch/runners/gleam-check.js +0 -167
  303. package/dist/clients/dispatch/runners/go-vet.js +0 -104
  304. package/dist/clients/dispatch/runners/golangci-lint.js +0 -135
  305. package/dist/clients/dispatch/runners/hadolint.js +0 -91
  306. package/dist/clients/dispatch/runners/helm-lint.js +0 -171
  307. package/dist/clients/dispatch/runners/helm-render.js +0 -940
  308. package/dist/clients/dispatch/runners/htmlhint.js +0 -117
  309. package/dist/clients/dispatch/runners/index.js +0 -108
  310. package/dist/clients/dispatch/runners/javac.js +0 -99
  311. package/dist/clients/dispatch/runners/ktlint.js +0 -110
  312. package/dist/clients/dispatch/runners/lsp.js +0 -379
  313. package/dist/clients/dispatch/runners/markdownlint.js +0 -167
  314. package/dist/clients/dispatch/runners/mypy.js +0 -102
  315. package/dist/clients/dispatch/runners/oxlint.js +0 -414
  316. package/dist/clients/dispatch/runners/php-lint.js +0 -85
  317. package/dist/clients/dispatch/runners/phpstan.js +0 -120
  318. package/dist/clients/dispatch/runners/prisma-validate.js +0 -62
  319. package/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -445
  320. package/dist/clients/dispatch/runners/pyright.js +0 -169
  321. package/dist/clients/dispatch/runners/rubocop.js +0 -99
  322. package/dist/clients/dispatch/runners/ruff.js +0 -88
  323. package/dist/clients/dispatch/runners/rust-clippy.js +0 -256
  324. package/dist/clients/dispatch/runners/shellcheck.js +0 -173
  325. package/dist/clients/dispatch/runners/shfmt.js +0 -102
  326. package/dist/clients/dispatch/runners/spellcheck.js +0 -128
  327. package/dist/clients/dispatch/runners/spotbugs.js +0 -259
  328. package/dist/clients/dispatch/runners/sqlfluff.js +0 -183
  329. package/dist/clients/dispatch/runners/stylelint.js +0 -166
  330. package/dist/clients/dispatch/runners/swiftlint.js +0 -163
  331. package/dist/clients/dispatch/runners/taplo.js +0 -174
  332. package/dist/clients/dispatch/runners/terragrunt.js +0 -168
  333. package/dist/clients/dispatch/runners/tflint.js +0 -125
  334. package/dist/clients/dispatch/runners/tree-sitter.js +0 -643
  335. package/dist/clients/dispatch/runners/trivy-config.js +0 -253
  336. package/dist/clients/dispatch/runners/utils/availability-policy.js +0 -496
  337. package/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -90
  338. package/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -95
  339. package/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -274
  340. package/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1701
  341. package/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -101
  342. package/dist/clients/dispatch/runners/utils/tool-failure.js +0 -235
  343. package/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -169
  344. package/dist/clients/dispatch/runners/utils.js +0 -15
  345. package/dist/clients/dispatch/runners/vale.js +0 -128
  346. package/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -242
  347. package/dist/clients/dispatch/runners/yamllint.js +0 -95
  348. package/dist/clients/dispatch/runners/zig-check.js +0 -79
  349. package/dist/clients/dispatch/suppress-writer.js +0 -79
  350. package/dist/clients/dispatch/tool-profile.js +0 -30
  351. package/dist/clients/dispatch/types.js +0 -21
  352. package/dist/clients/dispatch/utils/format-utils.js +0 -45
  353. package/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -35
  354. package/dist/clients/disposition-logger.js +0 -32
  355. package/dist/clients/disposition-publish.js +0 -124
  356. package/dist/clients/durable-store.js +0 -97
  357. package/dist/clients/effective-config.js +0 -415
  358. package/dist/clients/env-utils.js +0 -83
  359. package/dist/clients/error-class.js +0 -23
  360. package/dist/clients/eval-timestamp.js +0 -17
  361. package/dist/clients/event-loop-hold.js +0 -274
  362. package/dist/clients/event-loop-monitor.js +0 -250
  363. package/dist/clients/extension-log.js +0 -504
  364. package/dist/clients/extension-mode.js +0 -73
  365. package/dist/clients/feature-hints.js +0 -103
  366. package/dist/clients/file-kinds.js +0 -412
  367. package/dist/clients/file-role.js +0 -134
  368. package/dist/clients/file-time.js +0 -160
  369. package/dist/clients/file-utils.js +0 -1032
  370. package/dist/clients/finding-delivery-gate.js +0 -494
  371. package/dist/clients/finding-identity.js +0 -88
  372. package/dist/clients/fix-worklog.js +0 -103
  373. package/dist/clients/format-events-publish.js +0 -343
  374. package/dist/clients/format-service.js +0 -222
  375. package/dist/clients/formatters-lazy.js +0 -9
  376. package/dist/clients/formatters.js +0 -2032
  377. package/dist/clients/freshness-cadence.js +0 -17
  378. package/dist/clients/freshness.js +0 -38
  379. package/dist/clients/generated-artifacts.js +0 -394
  380. package/dist/clients/generation-guard.js +0 -215
  381. package/dist/clients/git-guard.js +0 -1136
  382. package/dist/clients/git-tracked-ignore.js +0 -243
  383. package/dist/clients/gitleaks-client.js +0 -509
  384. package/dist/clients/go-client.js +0 -104
  385. package/dist/clients/govulncheck-client.js +0 -605
  386. package/dist/clients/gradle-ktfmt-style.js +0 -348
  387. package/dist/clients/grammar-source.js +0 -465
  388. package/dist/clients/gzip-stage-write.js +0 -135
  389. package/dist/clients/hashline-anchor.js +0 -424
  390. package/dist/clients/hook-budgets.js +0 -76
  391. package/dist/clients/host-edit-normalize.js +0 -140
  392. package/dist/clients/host-ports.js +0 -39
  393. package/dist/clients/indent-retarget.js +0 -154
  394. package/dist/clients/inline-blocker-dispositions.js +0 -186
  395. package/dist/clients/install-diagnostics.js +0 -156
  396. package/dist/clients/installer/index.js +0 -5416
  397. package/dist/clients/installer/managed-tool-refresh-session.js +0 -58
  398. package/dist/clients/installer/managed-tool-refresh.js +0 -783
  399. package/dist/clients/instance-reaper-state.js +0 -7
  400. package/dist/clients/instance-reaper.js +0 -1137
  401. package/dist/clients/instance-registry-lock.js +0 -145
  402. package/dist/clients/instance-registry.js +0 -773
  403. package/dist/clients/jscpd-client.js +0 -378
  404. package/dist/clients/json-cache-read.js +0 -65
  405. package/dist/clients/knip-client.js +0 -788
  406. package/dist/clients/language-policy.js +0 -252
  407. package/dist/clients/language-profile.js +0 -361
  408. package/dist/clients/language-registry.js +0 -603
  409. package/dist/clients/latency-logger.js +0 -727
  410. package/dist/clients/lazy-import.js +0 -21
  411. package/dist/clients/ledger-bounds.js +0 -54
  412. package/dist/clients/lens-config.js +0 -404
  413. package/dist/clients/lens-engine.js +0 -358
  414. package/dist/clients/lens-events.js +0 -125
  415. package/dist/clients/lens-flag-registry.js +0 -467
  416. package/dist/clients/lens-map.js +0 -1156
  417. package/dist/clients/live-bus-emitter.js +0 -74
  418. package/dist/clients/log-cleanup.js +0 -222
  419. package/dist/clients/lsp/aggregation.js +0 -178
  420. package/dist/clients/lsp/cascade-tier.js +0 -421
  421. package/dist/clients/lsp/client.js +0 -4593
  422. package/dist/clients/lsp/config.js +0 -691
  423. package/dist/clients/lsp/content-limits.js +0 -41
  424. package/dist/clients/lsp/diagnostic-binding.js +0 -225
  425. package/dist/clients/lsp/document-drift.js +0 -467
  426. package/dist/clients/lsp/edits.js +0 -1219
  427. package/dist/clients/lsp/index.js +0 -8305
  428. package/dist/clients/lsp/inferred-project.js +0 -216
  429. package/dist/clients/lsp/jvm-runtime.js +0 -298
  430. package/dist/clients/lsp/language.js +0 -63
  431. package/dist/clients/lsp/launch.js +0 -746
  432. package/dist/clients/lsp/lombok.js +0 -158
  433. package/dist/clients/lsp/path-utils.js +0 -5
  434. package/dist/clients/lsp/pending-aux-coverage.js +0 -251
  435. package/dist/clients/lsp/position-encoding.js +0 -61
  436. package/dist/clients/lsp/ruby-drive-dirs.js +0 -83
  437. package/dist/clients/lsp/server.js +0 -3290
  438. package/dist/clients/lsp/session-roots.js +0 -192
  439. package/dist/clients/lsp/spawn-history.js +0 -17
  440. package/dist/clients/lsp/sync-kind.js +0 -56
  441. package/dist/clients/lsp/tsserver-sync.js +0 -332
  442. package/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
  443. package/dist/clients/lsp/wait-policy/classification.js +0 -85
  444. package/dist/clients/lsp/wait-policy/index.js +0 -10
  445. package/dist/clients/lsp/wait-policy/strategies.js +0 -392
  446. package/dist/clients/lsp/watch-queue.js +0 -61
  447. package/dist/clients/lsp/workspace-diagnostics-cache.js +0 -639
  448. package/dist/clients/lsp/workspace-diagnostics-session.js +0 -30
  449. package/dist/clients/lsp/workspace-sweep-hold.js +0 -184
  450. package/dist/clients/lsp-budget.js +0 -186
  451. package/dist/clients/lsp-document-symbols.js +0 -110
  452. package/dist/clients/lsp-lazy.js +0 -9
  453. package/dist/clients/lsp-mutation.js +0 -396
  454. package/dist/clients/lsp-status.js +0 -59
  455. package/dist/clients/map-with-concurrency.js +0 -40
  456. package/dist/clients/mcp/analyze.js +0 -420
  457. package/dist/clients/mcp/host-shim.js +0 -31
  458. package/dist/clients/mcp/ipc.js +0 -523
  459. package/dist/clients/mcp/review.js +0 -197
  460. package/dist/clients/mcp/session.js +0 -412
  461. package/dist/clients/memory-sampler.js +0 -208
  462. package/dist/clients/message-end-attribution.js +0 -30
  463. package/dist/clients/metrics-client.js +0 -107
  464. package/dist/clients/metrics-history.js +0 -327
  465. package/dist/clients/middle-man-analysis.js +0 -263
  466. package/dist/clients/model-provider.js +0 -53
  467. package/dist/clients/module-report-lsp.js +0 -189
  468. package/dist/clients/module-report.js +0 -2150
  469. package/dist/clients/mutating-tool.js +0 -651
  470. package/dist/clients/mutation-attribution.js +0 -368
  471. package/dist/clients/mutation-bridge.js +0 -240
  472. package/dist/clients/ndjson-logger.js +0 -734
  473. package/dist/clients/observed-mutation-sources.js +0 -101
  474. package/dist/clients/observed-mutation.js +0 -1253
  475. package/dist/clients/oldtext-autopatch.js +0 -128
  476. package/dist/clients/opaque-mutation-scan.js +0 -496
  477. package/dist/clients/opengrep-client.js +0 -333
  478. package/dist/clients/opengrep-config.js +0 -76
  479. package/dist/clients/package-manager.js +0 -607
  480. package/dist/clients/package-root.js +0 -38
  481. package/dist/clients/partial-edit-apply.js +0 -439
  482. package/dist/clients/path-attribution-telemetry.js +0 -43
  483. package/dist/clients/path-keyed-map.js +0 -108
  484. package/dist/clients/path-utils.js +0 -1244
  485. package/dist/clients/performance-report.js +0 -331
  486. package/dist/clients/persist-debounce.js +0 -70
  487. package/dist/clients/persistent-reverify.js +0 -271
  488. package/dist/clients/php-cs-fixer-config.js +0 -119
  489. package/dist/clients/pipeline.js +0 -1480
  490. package/dist/clients/post-autofix-notice.js +0 -37
  491. package/dist/clients/print-mode.js +0 -21
  492. package/dist/clients/probe-home-state.js +0 -228
  493. package/dist/clients/process-bridge.js +0 -66
  494. package/dist/clients/process-singletons.js +0 -210
  495. package/dist/clients/process-snapshot.js +0 -68
  496. package/dist/clients/project-changes.js +0 -181
  497. package/dist/clients/project-conventions.js +0 -171
  498. package/dist/clients/project-diagnostics/cache.js +0 -137
  499. package/dist/clients/project-diagnostics/extractors.js +0 -109
  500. package/dist/clients/project-diagnostics/fresh-fetch.js +0 -668
  501. package/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -118
  502. package/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -47
  503. package/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -40
  504. package/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -34
  505. package/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -38
  506. package/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -47
  507. package/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -48
  508. package/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -40
  509. package/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -127
  510. package/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -81
  511. package/dist/clients/project-diagnostics/scanner.js +0 -520
  512. package/dist/clients/project-diagnostics/types.js +0 -1
  513. package/dist/clients/project-lens-config.js +0 -807
  514. package/dist/clients/project-report.js +0 -701
  515. package/dist/clients/project-scale.js +0 -237
  516. package/dist/clients/project-scan-policy.js +0 -11
  517. package/dist/clients/project-snapshot-fingerprint.js +0 -48
  518. package/dist/clients/project-snapshot-persist-worker.js +0 -20
  519. package/dist/clients/project-snapshot.js +0 -1653
  520. package/dist/clients/project-trust.js +0 -181
  521. package/dist/clients/python-environment.js +0 -217
  522. package/dist/clients/python-provenance.js +0 -639
  523. package/dist/clients/quiet-window-config.js +0 -47
  524. package/dist/clients/quiet-window.js +0 -236
  525. package/dist/clients/read-bridge.js +0 -139
  526. package/dist/clients/read-expansion.js +0 -266
  527. package/dist/clients/read-guard-logger.js +0 -251
  528. package/dist/clients/read-guard-tool-lines.js +0 -1306
  529. package/dist/clients/read-guard.js +0 -1561
  530. package/dist/clients/recent-touches.js +0 -240
  531. package/dist/clients/redact/secrets.js +0 -449
  532. package/dist/clients/resource-sampler.js +0 -628
  533. package/dist/clients/reverse-deps.js +0 -270
  534. package/dist/clients/review-graph/builder.js +0 -5126
  535. package/dist/clients/review-graph/format.js +0 -33
  536. package/dist/clients/review-graph/git-identity.js +0 -163
  537. package/dist/clients/review-graph/import-resolvers.js +0 -481
  538. package/dist/clients/review-graph/persist-worker.js +0 -10
  539. package/dist/clients/review-graph/query.js +0 -244
  540. package/dist/clients/review-graph/revision-drift.js +0 -21
  541. package/dist/clients/review-graph/service.js +0 -96
  542. package/dist/clients/review-graph/shared-extraction-ir.js +0 -82
  543. package/dist/clients/review-graph/symbol-id.js +0 -103
  544. package/dist/clients/review-graph/tsconfig-paths.js +0 -299
  545. package/dist/clients/review-graph/types.js +0 -1
  546. package/dist/clients/review-graph/workspace-modules.js +0 -449
  547. package/dist/clients/review-graph-logger.js +0 -81
  548. package/dist/clients/ruff-client.js +0 -179
  549. package/dist/clients/rules-scanner.js +0 -131
  550. package/dist/clients/run-duration.js +0 -55
  551. package/dist/clients/runtime-agent-end.js +0 -746
  552. package/dist/clients/runtime-config.js +0 -77
  553. package/dist/clients/runtime-context.js +0 -211
  554. package/dist/clients/runtime-coordinator.js +0 -1324
  555. package/dist/clients/runtime-session.js +0 -2485
  556. package/dist/clients/runtime-tool-call.js +0 -1295
  557. package/dist/clients/runtime-tool-result.js +0 -2049
  558. package/dist/clients/runtime-turn.js +0 -3767
  559. package/dist/clients/rust-client.js +0 -97
  560. package/dist/clients/safe-spawn.js +0 -2357
  561. package/dist/clients/sanitize.js +0 -286
  562. package/dist/clients/scan-utils.js +0 -25
  563. package/dist/clients/scratch-tree-policy.js +0 -165
  564. package/dist/clients/search-read-registration.js +0 -94
  565. package/dist/clients/secret-findings.js +0 -114
  566. package/dist/clients/security-scan-client.js +0 -352
  567. package/dist/clients/session-event-guard.js +0 -297
  568. package/dist/clients/session-lifecycle.js +0 -484
  569. package/dist/clients/session-start-observability.js +0 -94
  570. package/dist/clients/session-state-store.js +0 -101
  571. package/dist/clients/session-summary.js +0 -15
  572. package/dist/clients/sessionstart-logger.js +0 -27
  573. package/dist/clients/sg-runner.js +0 -876
  574. package/dist/clients/sgconfig.js +0 -347
  575. package/dist/clients/shared-checkout-guard.js +0 -338
  576. package/dist/clients/single-flight.js +0 -158
  577. package/dist/clients/situational-tool-telemetry.js +0 -108
  578. package/dist/clients/skills-resolver.js +0 -141
  579. package/dist/clients/slow-fs.js +0 -138
  580. package/dist/clients/smells-rollup.js +0 -231
  581. package/dist/clients/source-filter.js +0 -596
  582. package/dist/clients/source-walker.js +0 -211
  583. package/dist/clients/spawn-output-cap.js +0 -120
  584. package/dist/clients/spawn-timeout-cooldown.js +0 -110
  585. package/dist/clients/stale-marker.js +0 -17
  586. package/dist/clients/startup-scan.js +0 -400
  587. package/dist/clients/startup-timing.js +0 -130
  588. package/dist/clients/string-utils.js +0 -33
  589. package/dist/clients/subagent-mode.js +0 -111
  590. package/dist/clients/symbol-containment.js +0 -24
  591. package/dist/clients/symbol-types.js +0 -5
  592. package/dist/clients/test-runner-client.js +0 -2507
  593. package/dist/clients/test-runner-delivery.js +0 -287
  594. package/dist/clients/todo-scanner.js +0 -229
  595. package/dist/clients/tool-agreement.js +0 -423
  596. package/dist/clients/tool-config.js +0 -249
  597. package/dist/clients/tool-cwd.js +0 -270
  598. package/dist/clients/tool-definition.js +0 -47
  599. package/dist/clients/tool-event.js +0 -105
  600. package/dist/clients/tool-policy.js +0 -2755
  601. package/dist/clients/tool-probe.js +0 -53
  602. package/dist/clients/tool-render.js +0 -156
  603. package/dist/clients/tool-set-policy.js +0 -118
  604. package/dist/clients/tree-sitter-cache.js +0 -364
  605. package/dist/clients/tree-sitter-client.js +0 -4195
  606. package/dist/clients/tree-sitter-logger.js +0 -100
  607. package/dist/clients/tree-sitter-navigator.js +0 -269
  608. package/dist/clients/tree-sitter-query-loader.js +0 -569
  609. package/dist/clients/tree-sitter-shared.js +0 -158
  610. package/dist/clients/tree-sitter-symbol-extractor.js +0 -1265
  611. package/dist/clients/trivy-client.js +0 -467
  612. package/dist/clients/tui-fit.js +0 -50
  613. package/dist/clients/turn-context.js +0 -52
  614. package/dist/clients/turn-end/lane.js +0 -51
  615. package/dist/clients/turn-end/lanes/govulncheck.js +0 -112
  616. package/dist/clients/turn-end/lanes/secrets.js +0 -204
  617. package/dist/clients/turn-summary-render.js +0 -72
  618. package/dist/clients/turn-summary.js +0 -132
  619. package/dist/clients/typos-config.js +0 -29
  620. package/dist/clients/user-notify.js +0 -51
  621. package/dist/clients/vanished-instance-marker.js +0 -57
  622. package/dist/clients/warm-attach.js +0 -305
  623. package/dist/clients/widget-state.js +0 -1808
  624. package/dist/clients/word-index-logger.js +0 -49
  625. package/dist/clients/word-index-store.js +0 -459
  626. package/dist/clients/word-index.js +0 -2080
  627. package/dist/clients/workspace-topology.js +0 -443
  628. package/dist/clients/write-ordering-guard.js +0 -65
  629. package/dist/clients/zizmor-config.js +0 -340
  630. package/dist/i18n.js +0 -69
  631. package/dist/mcp/build-staleness.js +0 -124
  632. package/dist/scripts/lib/process-scan.mjs +0 -583
  633. package/dist/scripts/lib/skills-predicate.mjs +0 -129
  634. package/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -123
  635. package/dist/tools/activate-tools.js +0 -87
  636. package/dist/tools/ast-grep-outline.js +0 -137
  637. package/dist/tools/ast-grep-replace.js +0 -244
  638. package/dist/tools/ast-grep-search.js +0 -762
  639. package/dist/tools/effective-config.js +0 -90
  640. package/dist/tools/lens-diagnostic-mark.js +0 -375
  641. package/dist/tools/lens-diagnostics.js +0 -2571
  642. package/dist/tools/lsp-diagnostics.js +0 -1745
  643. package/dist/tools/lsp-navigation.js +0 -1367
  644. package/dist/tools/lsp-structured-output.js +0 -294
  645. package/dist/tools/module-report.js +0 -382
  646. package/dist/tools/project-report.js +0 -86
  647. package/dist/tools/render-compact.js +0 -374
  648. package/dist/tools/scan-progress.js +0 -53
  649. package/dist/tools/shared.js +0 -29
  650. package/dist/tools/symbol-search.js +0 -155
@@ -0,0 +1,2352 @@
1
+ import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
+
3
+ // node_modules/balanced-match/dist/esm/index.js
4
+ var balanced = (a, b, str) => {
5
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
6
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
7
+ const r = ma !== null && mb != null && range(ma, mb, str);
8
+ return r && {
9
+ start: r[0],
10
+ end: r[1],
11
+ pre: str.slice(0, r[0]),
12
+ body: str.slice(r[0] + ma.length, r[1]),
13
+ post: str.slice(r[1] + mb.length)
14
+ };
15
+ };
16
+ var maybeMatch = (reg, str) => {
17
+ const m = str.match(reg);
18
+ return m ? m[0] : null;
19
+ };
20
+ var range = (a, b, str) => {
21
+ let begs, beg, left, right = void 0, result;
22
+ let ai = str.indexOf(a);
23
+ let bi = str.indexOf(b, ai + 1);
24
+ let i = ai;
25
+ if (ai >= 0 && bi > 0) {
26
+ if (a === b) {
27
+ return [ai, bi];
28
+ }
29
+ begs = [];
30
+ left = str.length;
31
+ while (i >= 0 && !result) {
32
+ if (i === ai) {
33
+ begs.push(i);
34
+ ai = str.indexOf(a, i + 1);
35
+ } else if (begs.length === 1) {
36
+ const r = begs.pop();
37
+ if (r !== void 0)
38
+ result = [r, bi];
39
+ } else {
40
+ beg = begs.pop();
41
+ if (beg !== void 0 && beg < left) {
42
+ left = beg;
43
+ right = bi;
44
+ }
45
+ bi = str.indexOf(b, i + 1);
46
+ }
47
+ i = ai < bi && ai >= 0 ? ai : bi;
48
+ }
49
+ if (begs.length && right !== void 0) {
50
+ result = [left, right];
51
+ }
52
+ }
53
+ return result;
54
+ };
55
+
56
+ // node_modules/brace-expansion/dist/esm/index.js
57
+ var escSlash = "\0SLASH" + Math.random() + "\0";
58
+ var escOpen = "\0OPEN" + Math.random() + "\0";
59
+ var escClose = "\0CLOSE" + Math.random() + "\0";
60
+ var escComma = "\0COMMA" + Math.random() + "\0";
61
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
62
+ var escSlashPattern = new RegExp(escSlash, "g");
63
+ var escOpenPattern = new RegExp(escOpen, "g");
64
+ var escClosePattern = new RegExp(escClose, "g");
65
+ var escCommaPattern = new RegExp(escComma, "g");
66
+ var escPeriodPattern = new RegExp(escPeriod, "g");
67
+ var slashPattern = /\\\\/g;
68
+ var openPattern = /\\{/g;
69
+ var closePattern = /\\}/g;
70
+ var commaPattern = /\\,/g;
71
+ var periodPattern = /\\\./g;
72
+ var EXPANSION_MAX = 1e5;
73
+ var EXPANSION_MAX_LENGTH = 4e6;
74
+ var EXPANSION_MAX_DEPTH = 1e3;
75
+ var EXPANSION_MAX_REWRITES = 1e3;
76
+ function numeric(str) {
77
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
78
+ }
79
+ function escapeBraces(str) {
80
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
81
+ }
82
+ function unescapeBraces(str) {
83
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
84
+ }
85
+ function pushAll(target, items) {
86
+ for (let i = 0; i < items.length; i++) {
87
+ target.push(items[i]);
88
+ }
89
+ }
90
+ function parseCommaParts(str) {
91
+ const parts = [];
92
+ let carry = "";
93
+ for (; ; ) {
94
+ const m = balanced("{", "}", str);
95
+ if (!m) {
96
+ const tail = str.split(",");
97
+ tail[0] = carry + tail[0];
98
+ pushAll(parts, tail);
99
+ return parts;
100
+ }
101
+ const { pre, body, post } = m;
102
+ const p = pre.split(",");
103
+ p[0] = carry + p[0];
104
+ p[p.length - 1] += "{" + body + "}";
105
+ if (!post.length) {
106
+ pushAll(parts, p);
107
+ return parts;
108
+ }
109
+ carry = p.pop();
110
+ pushAll(parts, p);
111
+ str = post;
112
+ }
113
+ }
114
+ function expand(str, options = {}) {
115
+ if (!str) {
116
+ return [];
117
+ }
118
+ const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
119
+ if (str.slice(0, 2) === "{}") {
120
+ str = "\\{\\}" + str.slice(2);
121
+ }
122
+ return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
123
+ }
124
+ function embrace(str) {
125
+ return "{" + str + "}";
126
+ }
127
+ function isPadded(el) {
128
+ return /^-?0\d/.test(el);
129
+ }
130
+ function lte(i, y) {
131
+ return i <= y;
132
+ }
133
+ function gte(i, y) {
134
+ return i >= y;
135
+ }
136
+ function combine(acc, pre, values, max, maxLength, dropEmpties) {
137
+ const out = [];
138
+ let length = 0;
139
+ for (let a = 0; a < acc.length; a++) {
140
+ for (let v = 0; v < values.length; v++) {
141
+ if (out.length >= max)
142
+ return out;
143
+ const expansion = acc[a] + pre + values[v];
144
+ if (dropEmpties && !expansion)
145
+ continue;
146
+ if (length + expansion.length > maxLength)
147
+ return out;
148
+ out.push(expansion);
149
+ length += expansion.length;
150
+ }
151
+ }
152
+ return out;
153
+ }
154
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
155
+ const n = body.split(/\.\./);
156
+ const N = [];
157
+ if (n[0] === void 0 || n[1] === void 0) {
158
+ return N;
159
+ }
160
+ const x = numeric(n[0]);
161
+ const y = numeric(n[1]);
162
+ const width = Math.max(n[0].length, n[1].length);
163
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
164
+ let test = lte;
165
+ const reverse = y < x;
166
+ if (reverse) {
167
+ incr *= -1;
168
+ test = gte;
169
+ }
170
+ const pad = n.some(isPadded);
171
+ let length = 0;
172
+ for (let i = x; test(i, y) && N.length < max; i += incr) {
173
+ let c;
174
+ if (isAlphaSequence) {
175
+ c = String.fromCharCode(i);
176
+ if (c === "\\") {
177
+ c = "";
178
+ }
179
+ } else {
180
+ c = String(i);
181
+ if (pad) {
182
+ const need = width - c.length;
183
+ if (need > 0) {
184
+ const z = new Array(need + 1).join("0");
185
+ if (i < 0) {
186
+ c = "-" + z + c.slice(1);
187
+ } else {
188
+ c = z + c;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ if (length + c.length > maxLength)
194
+ break;
195
+ N.push(c);
196
+ length += c.length;
197
+ }
198
+ return N;
199
+ }
200
+ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
201
+ if (depth > maxDepth) {
202
+ return [str];
203
+ }
204
+ let acc = [""];
205
+ let rewrites = 0;
206
+ let dropEmpties = false;
207
+ let firstGroup = true;
208
+ for (; ; ) {
209
+ const m = balanced("{", "}", str);
210
+ if (!m) {
211
+ return combine(acc, str, [""], max, maxLength, dropEmpties);
212
+ }
213
+ const pre = m.pre;
214
+ if (/\$$/.test(pre)) {
215
+ acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
216
+ firstGroup = false;
217
+ if (!m.post.length)
218
+ break;
219
+ str = m.post;
220
+ continue;
221
+ }
222
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
223
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
224
+ const isSequence = isNumericSequence || isAlphaSequence;
225
+ const isOptions = m.body.indexOf(",") >= 0;
226
+ if (!isSequence && !isOptions) {
227
+ if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
228
+ rewrites++;
229
+ str = m.pre + "{" + m.body + escClose + m.post;
230
+ isTop = true;
231
+ continue;
232
+ }
233
+ return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
234
+ }
235
+ if (firstGroup) {
236
+ dropEmpties = isTop && !isSequence;
237
+ firstGroup = false;
238
+ }
239
+ let values;
240
+ if (isSequence) {
241
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
242
+ } else {
243
+ let n = parseCommaParts(m.body);
244
+ if (n.length === 1 && n[0] !== void 0) {
245
+ n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
246
+ if (n.length === 1) {
247
+ acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
248
+ if (!m.post.length)
249
+ break;
250
+ str = m.post;
251
+ continue;
252
+ }
253
+ }
254
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
255
+ for (let d = 0; dropsEmpties && d < acc.length; d++) {
256
+ if (acc[d]) {
257
+ dropsEmpties = false;
258
+ }
259
+ }
260
+ values = [];
261
+ let valuesLength = 0;
262
+ outer: for (let j = 0; j < n.length; j++) {
263
+ const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
264
+ for (let k = 0; k < expanded.length; k++) {
265
+ const v = expanded[k];
266
+ if (dropsEmpties && !v)
267
+ continue;
268
+ if (values.length >= max || valuesLength + v.length > maxLength) {
269
+ break outer;
270
+ }
271
+ values.push(v);
272
+ valuesLength += v.length;
273
+ }
274
+ }
275
+ }
276
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
277
+ if (!m.post.length)
278
+ break;
279
+ str = m.post;
280
+ }
281
+ return acc;
282
+ }
283
+
284
+ // node_modules/minimatch/dist/esm/assert-valid-pattern.js
285
+ var MAX_PATTERN_LENGTH = 1024 * 64;
286
+ var assertValidPattern = (pattern) => {
287
+ if (typeof pattern !== "string") {
288
+ throw new TypeError("invalid pattern");
289
+ }
290
+ if (pattern.length > MAX_PATTERN_LENGTH) {
291
+ throw new TypeError("pattern is too long");
292
+ }
293
+ };
294
+
295
+ // node_modules/minimatch/dist/esm/brace-expressions.js
296
+ var posixClasses = {
297
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
298
+ "[:alpha:]": ["\\p{L}\\p{Nl}", true],
299
+ "[:ascii:]": ["\\x00-\\x7f", false],
300
+ "[:blank:]": ["\\p{Zs}\\t", true],
301
+ "[:cntrl:]": ["\\p{Cc}", true],
302
+ "[:digit:]": ["\\p{Nd}", true],
303
+ "[:graph:]": ["\\p{Z}\\p{C}", true, true],
304
+ "[:lower:]": ["\\p{Ll}", true],
305
+ "[:print:]": ["\\p{C}", true],
306
+ "[:punct:]": ["\\p{P}", true],
307
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
308
+ "[:upper:]": ["\\p{Lu}", true],
309
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
310
+ "[:xdigit:]": ["A-Fa-f0-9", false]
311
+ };
312
+ var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
313
+ var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
314
+ var rangesToString = (ranges) => ranges.join("");
315
+ var parseClass = (glob, position) => {
316
+ const pos = position;
317
+ if (glob.charAt(pos) !== "[") {
318
+ throw new Error("not in a brace expression");
319
+ }
320
+ const ranges = [];
321
+ const negs = [];
322
+ let i = pos + 1;
323
+ let sawStart = false;
324
+ let uflag = false;
325
+ let escaping = false;
326
+ let negate = false;
327
+ let endPos = pos;
328
+ let rangeStart = "";
329
+ WHILE: while (i < glob.length) {
330
+ const c = glob.charAt(i);
331
+ if ((c === "!" || c === "^") && i === pos + 1) {
332
+ negate = true;
333
+ i++;
334
+ continue;
335
+ }
336
+ if (c === "]" && sawStart && !escaping) {
337
+ endPos = i + 1;
338
+ break;
339
+ }
340
+ sawStart = true;
341
+ if (c === "\\") {
342
+ if (!escaping) {
343
+ escaping = true;
344
+ i++;
345
+ continue;
346
+ }
347
+ }
348
+ if (c === "[" && !escaping) {
349
+ for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
350
+ if (glob.startsWith(cls, i)) {
351
+ if (rangeStart) {
352
+ return ["$.", false, glob.length - pos, true];
353
+ }
354
+ i += cls.length;
355
+ if (neg)
356
+ negs.push(unip);
357
+ else
358
+ ranges.push(unip);
359
+ uflag = uflag || u;
360
+ continue WHILE;
361
+ }
362
+ }
363
+ }
364
+ escaping = false;
365
+ if (rangeStart) {
366
+ if (c > rangeStart) {
367
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
368
+ } else if (c === rangeStart) {
369
+ ranges.push(braceEscape(c));
370
+ }
371
+ rangeStart = "";
372
+ i++;
373
+ continue;
374
+ }
375
+ if (glob.startsWith("-]", i + 1)) {
376
+ ranges.push(braceEscape(c + "-"));
377
+ i += 2;
378
+ continue;
379
+ }
380
+ if (glob.startsWith("-", i + 1)) {
381
+ rangeStart = c;
382
+ i += 2;
383
+ continue;
384
+ }
385
+ ranges.push(braceEscape(c));
386
+ i++;
387
+ }
388
+ if (endPos < i) {
389
+ return ["", false, 0, false];
390
+ }
391
+ if (!ranges.length && !negs.length) {
392
+ return ["$.", false, glob.length - pos, true];
393
+ }
394
+ if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
395
+ const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
396
+ return [regexpEscape(r), false, endPos - pos, false];
397
+ }
398
+ const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
399
+ const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
400
+ const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
401
+ return [comb, uflag, endPos - pos, true];
402
+ };
403
+
404
+ // node_modules/minimatch/dist/esm/unescape.js
405
+ var unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
406
+ if (magicalBraces) {
407
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
408
+ }
409
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
410
+ };
411
+
412
+ // node_modules/minimatch/dist/esm/ast.js
413
+ var _a;
414
+ var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
415
+ var isExtglobType = (c) => types.has(c);
416
+ var isExtglobAST = (c) => isExtglobType(c.type);
417
+ var adoptionMap = /* @__PURE__ */ new Map([
418
+ ["!", ["@"]],
419
+ ["?", ["?", "@"]],
420
+ ["@", ["@"]],
421
+ ["*", ["*", "+", "?", "@"]],
422
+ ["+", ["+", "@"]]
423
+ ]);
424
+ var adoptionWithSpaceMap = /* @__PURE__ */ new Map([
425
+ ["!", ["?"]],
426
+ ["@", ["?"]],
427
+ ["+", ["?", "*"]]
428
+ ]);
429
+ var adoptionAnyMap = /* @__PURE__ */ new Map([
430
+ ["!", ["?", "@"]],
431
+ ["?", ["?", "@"]],
432
+ ["@", ["?", "@"]],
433
+ ["*", ["*", "+", "?", "@"]],
434
+ ["+", ["+", "@", "?", "*"]]
435
+ ]);
436
+ var usurpMap = /* @__PURE__ */ new Map([
437
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
438
+ [
439
+ "?",
440
+ /* @__PURE__ */ new Map([
441
+ ["*", "*"],
442
+ ["+", "*"]
443
+ ])
444
+ ],
445
+ [
446
+ "@",
447
+ /* @__PURE__ */ new Map([
448
+ ["!", "!"],
449
+ ["?", "?"],
450
+ ["@", "@"],
451
+ ["*", "*"],
452
+ ["+", "+"]
453
+ ])
454
+ ],
455
+ [
456
+ "+",
457
+ /* @__PURE__ */ new Map([
458
+ ["?", "*"],
459
+ ["*", "*"]
460
+ ])
461
+ ]
462
+ ]);
463
+ var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
464
+ var startNoDot = "(?!\\.)";
465
+ var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
466
+ var justDots = /* @__PURE__ */ new Set(["..", "."]);
467
+ var reSpecials = new Set("().*{}+?[]^$\\!");
468
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
469
+ var qmark = "[^/]";
470
+ var star = qmark + "*?";
471
+ var starNoEmpty = qmark + "+?";
472
+ var ID = 0;
473
+ var AST = class {
474
+ type;
475
+ #root;
476
+ #hasMagic;
477
+ #uflag = false;
478
+ #parts = [];
479
+ #parent;
480
+ #parentIndex;
481
+ #negs;
482
+ #filledNegs = false;
483
+ #options;
484
+ #toString;
485
+ // set to true if it's an extglob with no children
486
+ // (which really means one child of '')
487
+ #emptyExt = false;
488
+ id = ++ID;
489
+ get depth() {
490
+ return (this.#parent?.depth ?? -1) + 1;
491
+ }
492
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
493
+ return {
494
+ "@@type": "AST",
495
+ id: this.id,
496
+ type: this.type,
497
+ root: this.#root.id,
498
+ parent: this.#parent?.id,
499
+ depth: this.depth,
500
+ partsLength: this.#parts.length,
501
+ parts: this.#parts
502
+ };
503
+ }
504
+ constructor(type, parent, options = {}) {
505
+ this.type = type;
506
+ if (type)
507
+ this.#hasMagic = true;
508
+ this.#parent = parent;
509
+ this.#root = this.#parent ? this.#parent.#root : this;
510
+ this.#options = this.#root === this ? options : this.#root.#options;
511
+ this.#negs = this.#root === this ? [] : this.#root.#negs;
512
+ if (type === "!" && !this.#root.#filledNegs)
513
+ this.#negs.push(this);
514
+ this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
515
+ }
516
+ get hasMagic() {
517
+ if (this.#hasMagic !== void 0)
518
+ return this.#hasMagic;
519
+ for (const p of this.#parts) {
520
+ if (typeof p === "string")
521
+ continue;
522
+ if (p.type || p.hasMagic)
523
+ return this.#hasMagic = true;
524
+ }
525
+ return this.#hasMagic;
526
+ }
527
+ // reconstructs the pattern
528
+ toString() {
529
+ return this.#toString !== void 0 ? this.#toString : !this.type ? this.#toString = this.#parts.map((p) => String(p)).join("") : this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
530
+ }
531
+ #fillNegs() {
532
+ if (this !== this.#root)
533
+ throw new Error("should only call on root");
534
+ if (this.#filledNegs)
535
+ return this;
536
+ this.toString();
537
+ this.#filledNegs = true;
538
+ let n;
539
+ while (n = this.#negs.pop()) {
540
+ if (n.type !== "!")
541
+ continue;
542
+ let p = n;
543
+ let pp = p.#parent;
544
+ while (pp) {
545
+ for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
546
+ for (const part of n.#parts) {
547
+ if (typeof part === "string") {
548
+ throw new Error("string part in extglob AST??");
549
+ }
550
+ part.copyIn(pp.#parts[i]);
551
+ }
552
+ }
553
+ p = pp;
554
+ pp = p.#parent;
555
+ }
556
+ }
557
+ return this;
558
+ }
559
+ push(...parts) {
560
+ for (const p of parts) {
561
+ if (p === "")
562
+ continue;
563
+ if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) {
564
+ throw new Error("invalid part: " + p);
565
+ }
566
+ this.#parts.push(p);
567
+ }
568
+ }
569
+ toJSON() {
570
+ const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
571
+ if (this.isStart() && !this.type)
572
+ ret.unshift([]);
573
+ if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
574
+ ret.push({});
575
+ }
576
+ return ret;
577
+ }
578
+ isStart() {
579
+ if (this.#root === this)
580
+ return true;
581
+ if (!this.#parent?.isStart())
582
+ return false;
583
+ if (this.#parentIndex === 0)
584
+ return true;
585
+ const p = this.#parent;
586
+ for (let i = 0; i < this.#parentIndex; i++) {
587
+ const pp = p.#parts[i];
588
+ if (!(pp instanceof _a && pp.type === "!")) {
589
+ return false;
590
+ }
591
+ }
592
+ return true;
593
+ }
594
+ isEnd() {
595
+ if (this.#root === this)
596
+ return true;
597
+ if (this.#parent?.type === "!")
598
+ return true;
599
+ if (!this.#parent?.isEnd())
600
+ return false;
601
+ if (!this.type)
602
+ return this.#parent?.isEnd();
603
+ const pl = this.#parent ? this.#parent.#parts.length : 0;
604
+ return this.#parentIndex === pl - 1;
605
+ }
606
+ copyIn(part) {
607
+ if (typeof part === "string")
608
+ this.push(part);
609
+ else
610
+ this.push(part.clone(this));
611
+ }
612
+ clone(parent) {
613
+ const c = new _a(this.type, parent);
614
+ for (const p of this.#parts) {
615
+ c.copyIn(p);
616
+ }
617
+ return c;
618
+ }
619
+ static #parseAST(str, ast, pos, opt, extDepth) {
620
+ const maxDepth = opt.maxExtglobRecursion ?? 2;
621
+ let escaping = false;
622
+ let inBrace = false;
623
+ let braceStart = -1;
624
+ let braceNeg = false;
625
+ if (ast.type === null) {
626
+ let i2 = pos;
627
+ let acc2 = "";
628
+ while (i2 < str.length) {
629
+ const c = str.charAt(i2++);
630
+ if (escaping || c === "\\") {
631
+ escaping = !escaping;
632
+ acc2 += c;
633
+ continue;
634
+ }
635
+ if (inBrace) {
636
+ if (i2 === braceStart + 1) {
637
+ if (c === "^" || c === "!") {
638
+ braceNeg = true;
639
+ }
640
+ } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
641
+ inBrace = false;
642
+ }
643
+ acc2 += c;
644
+ continue;
645
+ } else if (c === "[") {
646
+ inBrace = true;
647
+ braceStart = i2;
648
+ braceNeg = false;
649
+ acc2 += c;
650
+ continue;
651
+ }
652
+ const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth;
653
+ if (doRecurse) {
654
+ ast.push(acc2);
655
+ acc2 = "";
656
+ const ext2 = new _a(c, ast);
657
+ i2 = _a.#parseAST(str, ext2, i2, opt, extDepth + 1);
658
+ ast.push(ext2);
659
+ continue;
660
+ }
661
+ acc2 += c;
662
+ }
663
+ ast.push(acc2);
664
+ return i2;
665
+ }
666
+ let i = pos + 1;
667
+ let part = new _a(null, ast);
668
+ const parts = [];
669
+ let acc = "";
670
+ while (i < str.length) {
671
+ const c = str.charAt(i++);
672
+ if (escaping || c === "\\") {
673
+ escaping = !escaping;
674
+ acc += c;
675
+ continue;
676
+ }
677
+ if (inBrace) {
678
+ if (i === braceStart + 1) {
679
+ if (c === "^" || c === "!") {
680
+ braceNeg = true;
681
+ }
682
+ } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
683
+ inBrace = false;
684
+ }
685
+ acc += c;
686
+ continue;
687
+ } else if (c === "[") {
688
+ inBrace = true;
689
+ braceStart = i;
690
+ braceNeg = false;
691
+ acc += c;
692
+ continue;
693
+ }
694
+ const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
695
+ (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
696
+ if (doRecurse) {
697
+ const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
698
+ part.push(acc);
699
+ acc = "";
700
+ const ext2 = new _a(c, part);
701
+ part.push(ext2);
702
+ i = _a.#parseAST(str, ext2, i, opt, extDepth + depthAdd);
703
+ continue;
704
+ }
705
+ if (c === "|") {
706
+ part.push(acc);
707
+ acc = "";
708
+ parts.push(part);
709
+ part = new _a(null, ast);
710
+ continue;
711
+ }
712
+ if (c === ")") {
713
+ if (acc === "" && ast.#parts.length === 0) {
714
+ ast.#emptyExt = true;
715
+ }
716
+ part.push(acc);
717
+ acc = "";
718
+ ast.push(...parts, part);
719
+ return i;
720
+ }
721
+ acc += c;
722
+ }
723
+ ast.type = null;
724
+ ast.#hasMagic = void 0;
725
+ ast.#parts = [str.substring(pos - 1)];
726
+ return i;
727
+ }
728
+ #canAdoptWithSpace(child) {
729
+ return this.#canAdopt(child, adoptionWithSpaceMap);
730
+ }
731
+ #canAdopt(child, map = adoptionMap) {
732
+ if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) {
733
+ return false;
734
+ }
735
+ const gc = child.#parts[0];
736
+ if (!gc || typeof gc !== "object" || gc.type === null) {
737
+ return false;
738
+ }
739
+ return this.#canAdoptType(gc.type, map);
740
+ }
741
+ #canAdoptType(c, map = adoptionAnyMap) {
742
+ return !!map.get(this.type)?.includes(c);
743
+ }
744
+ #adoptWithSpace(child, index) {
745
+ const gc = child.#parts[0];
746
+ const blank = new _a(null, gc, this.options);
747
+ blank.#parts.push("");
748
+ gc.push(blank);
749
+ this.#adopt(child, index);
750
+ }
751
+ #adopt(child, index) {
752
+ const gc = child.#parts[0];
753
+ this.#parts.splice(index, 1, ...gc.#parts);
754
+ for (const p of gc.#parts) {
755
+ if (typeof p === "object")
756
+ p.#parent = this;
757
+ }
758
+ this.#toString = void 0;
759
+ }
760
+ #canUsurpType(c) {
761
+ const m = usurpMap.get(this.type);
762
+ return !!m?.has(c);
763
+ }
764
+ #canUsurp(child) {
765
+ if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) {
766
+ return false;
767
+ }
768
+ const gc = child.#parts[0];
769
+ if (!gc || typeof gc !== "object" || gc.type === null) {
770
+ return false;
771
+ }
772
+ return this.#canUsurpType(gc.type);
773
+ }
774
+ #usurp(child) {
775
+ const m = usurpMap.get(this.type);
776
+ const gc = child.#parts[0];
777
+ const nt = m?.get(gc.type);
778
+ if (!nt)
779
+ return false;
780
+ this.#parts = gc.#parts;
781
+ for (const p of this.#parts) {
782
+ if (typeof p === "object") {
783
+ p.#parent = this;
784
+ }
785
+ }
786
+ this.type = nt;
787
+ this.#toString = void 0;
788
+ this.#emptyExt = false;
789
+ }
790
+ static fromGlob(pattern, options = {}) {
791
+ const ast = new _a(null, void 0, options);
792
+ _a.#parseAST(pattern, ast, 0, options, 0);
793
+ return ast;
794
+ }
795
+ // returns the regular expression if there's magic, or the unescaped
796
+ // string if not.
797
+ toMMPattern() {
798
+ if (this !== this.#root)
799
+ return this.#root.toMMPattern();
800
+ const glob = this.toString();
801
+ const [re, body, hasMagic, uflag] = this.toRegExpSource();
802
+ const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
803
+ if (!anyMagic) {
804
+ return body;
805
+ }
806
+ const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
807
+ return Object.assign(new RegExp(`^${re}$`, flags), {
808
+ _src: re,
809
+ _glob: glob
810
+ });
811
+ }
812
+ get options() {
813
+ return this.#options;
814
+ }
815
+ // returns the string match, the regexp source, whether there's magic
816
+ // in the regexp (so a regular expression is required) and whether or
817
+ // not the uflag is needed for the regular expression (for posix classes)
818
+ // TODO: instead of injecting the start/end at this point, just return
819
+ // the BODY of the regexp, along with the start/end portions suitable
820
+ // for binding the start/end in either a joined full-path makeRe context
821
+ // (where we bind to (^|/), or a standalone matchPart context (where
822
+ // we bind to ^, and not /). Otherwise slashes get duped!
823
+ //
824
+ // In part-matching mode, the start is:
825
+ // - if not isStart: nothing
826
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
827
+ // - if dots allowed or not possible: ^
828
+ // - if dots possible and not allowed: ^(?!\.)
829
+ // end is:
830
+ // - if not isEnd(): nothing
831
+ // - else: $
832
+ //
833
+ // In full-path matching mode, we put the slash at the START of the
834
+ // pattern, so start is:
835
+ // - if first pattern: same as part-matching mode
836
+ // - if not isStart(): nothing
837
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
838
+ // - if dots allowed or not possible: /
839
+ // - if dots possible and not allowed: /(?!\.)
840
+ // end is:
841
+ // - if last pattern, same as part-matching mode
842
+ // - else nothing
843
+ //
844
+ // Always put the (?:$|/) on negated tails, though, because that has to be
845
+ // there to bind the end of the negated pattern portion, and it's easier to
846
+ // just stick it in now rather than try to inject it later in the middle of
847
+ // the pattern.
848
+ //
849
+ // We can just always return the same end, and leave it up to the caller
850
+ // to know whether it's going to be used joined or in parts.
851
+ // And, if the start is adjusted slightly, can do the same there:
852
+ // - if not isStart: nothing
853
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
854
+ // - if dots allowed or not possible: (?:/|^)
855
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
856
+ //
857
+ // But it's better to have a simpler binding without a conditional, for
858
+ // performance, so probably better to return both start options.
859
+ //
860
+ // Then the caller just ignores the end if it's not the first pattern,
861
+ // and the start always gets applied.
862
+ //
863
+ // But that's always going to be $ if it's the ending pattern, or nothing,
864
+ // so the caller can just attach $ at the end of the pattern when building.
865
+ //
866
+ // So the todo is:
867
+ // - better detect what kind of start is needed
868
+ // - return both flavors of starting pattern
869
+ // - attach $ at the end of the pattern when creating the actual RegExp
870
+ //
871
+ // Ah, but wait, no, that all only applies to the root when the first pattern
872
+ // is not an extglob. If the first pattern IS an extglob, then we need all
873
+ // that dot prevention biz to live in the extglob portions, because eg
874
+ // +(*|.x*) can match .xy but not .yx.
875
+ //
876
+ // So, return the two flavors if it's #root and the first child is not an
877
+ // AST, otherwise leave it to the child AST to handle it, and there,
878
+ // use the (?:^|/) style of start binding.
879
+ //
880
+ // Even simplified further:
881
+ // - Since the start for a join is eg /(?!\.) and the start for a part
882
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
883
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
884
+ toRegExpSource(allowDot) {
885
+ const dot = allowDot ?? !!this.#options.dot;
886
+ if (this.#root === this) {
887
+ this.#flatten();
888
+ this.#fillNegs();
889
+ }
890
+ if (!isExtglobAST(this)) {
891
+ const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
892
+ const src = this.#parts.map((p) => {
893
+ const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
894
+ this.#hasMagic = this.#hasMagic || hasMagic;
895
+ this.#uflag = this.#uflag || uflag;
896
+ return re;
897
+ }).join("");
898
+ let start2 = "";
899
+ if (this.isStart()) {
900
+ if (typeof this.#parts[0] === "string") {
901
+ const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
902
+ if (!dotTravAllowed) {
903
+ const aps = addPatternStart;
904
+ const needNoTrav = (
905
+ // dots are allowed, and the pattern starts with [ or .
906
+ dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
907
+ src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
908
+ src.startsWith("\\.\\.") && aps.has(src.charAt(4))
909
+ );
910
+ const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
911
+ start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
912
+ }
913
+ }
914
+ }
915
+ let end = "";
916
+ if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
917
+ end = "(?:$|\\/)";
918
+ }
919
+ const final2 = start2 + src + end;
920
+ return [
921
+ final2,
922
+ unescape(src),
923
+ this.#hasMagic = !!this.#hasMagic,
924
+ this.#uflag
925
+ ];
926
+ }
927
+ const repeated = this.type === "*" || this.type === "+";
928
+ const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
929
+ let body = this.#partsToRegExp(dot);
930
+ if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
931
+ const s = this.toString();
932
+ const me = this;
933
+ me.#parts = [s];
934
+ me.type = null;
935
+ me.#hasMagic = void 0;
936
+ return [s, unescape(this.toString()), false, false];
937
+ }
938
+ let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
939
+ if (bodyDotAllowed === body) {
940
+ bodyDotAllowed = "";
941
+ }
942
+ if (bodyDotAllowed) {
943
+ body = `(?:${body})(?:${bodyDotAllowed})*?`;
944
+ }
945
+ let final = "";
946
+ if (this.type === "!" && this.#emptyExt) {
947
+ final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
948
+ } else {
949
+ const close = this.type === "!" ? (
950
+ // !() must match something,but !(x) can match ''
951
+ "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
952
+ ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
953
+ final = start + body + close;
954
+ }
955
+ return [
956
+ final,
957
+ unescape(body),
958
+ this.#hasMagic = !!this.#hasMagic,
959
+ this.#uflag
960
+ ];
961
+ }
962
+ #flatten() {
963
+ if (!isExtglobAST(this)) {
964
+ for (const p of this.#parts) {
965
+ if (typeof p === "object") {
966
+ p.#flatten();
967
+ }
968
+ }
969
+ } else {
970
+ let iterations = 0;
971
+ let done = false;
972
+ do {
973
+ done = true;
974
+ for (let i = 0; i < this.#parts.length; i++) {
975
+ const c = this.#parts[i];
976
+ if (typeof c === "object") {
977
+ c.#flatten();
978
+ if (this.#canAdopt(c)) {
979
+ done = false;
980
+ this.#adopt(c, i);
981
+ } else if (this.#canAdoptWithSpace(c)) {
982
+ done = false;
983
+ this.#adoptWithSpace(c, i);
984
+ } else if (this.#canUsurp(c)) {
985
+ done = false;
986
+ this.#usurp(c);
987
+ }
988
+ }
989
+ }
990
+ } while (!done && ++iterations < 10);
991
+ }
992
+ this.#toString = void 0;
993
+ }
994
+ #partsToRegExp(dot) {
995
+ return this.#parts.map((p) => {
996
+ if (typeof p === "string") {
997
+ throw new Error("string type in extglob ast??");
998
+ }
999
+ const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
1000
+ this.#uflag = this.#uflag || uflag;
1001
+ return re;
1002
+ }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
1003
+ }
1004
+ static #parseGlob(glob, hasMagic, noEmpty = false) {
1005
+ let escaping = false;
1006
+ let re = "";
1007
+ let uflag = false;
1008
+ let inStar = false;
1009
+ for (let i = 0; i < glob.length; i++) {
1010
+ const c = glob.charAt(i);
1011
+ if (escaping) {
1012
+ escaping = false;
1013
+ re += (reSpecials.has(c) ? "\\" : "") + c;
1014
+ continue;
1015
+ }
1016
+ if (c === "*") {
1017
+ if (inStar)
1018
+ continue;
1019
+ inStar = true;
1020
+ re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
1021
+ hasMagic = true;
1022
+ continue;
1023
+ } else {
1024
+ inStar = false;
1025
+ }
1026
+ if (c === "\\") {
1027
+ if (i === glob.length - 1) {
1028
+ re += "\\\\";
1029
+ } else {
1030
+ escaping = true;
1031
+ }
1032
+ continue;
1033
+ }
1034
+ if (c === "[") {
1035
+ const [src, needUflag, consumed, magic] = parseClass(glob, i);
1036
+ if (consumed) {
1037
+ re += src;
1038
+ uflag = uflag || needUflag;
1039
+ i += consumed - 1;
1040
+ hasMagic = hasMagic || magic;
1041
+ continue;
1042
+ }
1043
+ }
1044
+ if (c === "?") {
1045
+ re += qmark;
1046
+ hasMagic = true;
1047
+ continue;
1048
+ }
1049
+ re += regExpEscape(c);
1050
+ }
1051
+ return [re, unescape(glob), !!hasMagic, uflag];
1052
+ }
1053
+ };
1054
+ _a = AST;
1055
+
1056
+ // node_modules/minimatch/dist/esm/escape.js
1057
+ var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
1058
+ if (magicalBraces) {
1059
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
1060
+ }
1061
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
1062
+ };
1063
+
1064
+ // node_modules/minimatch/dist/esm/index.js
1065
+ var minimatch = (p, pattern, options = {}) => {
1066
+ assertValidPattern(pattern);
1067
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1068
+ return false;
1069
+ }
1070
+ return new Minimatch(pattern, options).match(p);
1071
+ };
1072
+ var starDotExtRE = /^\*+([^+@!?*[(]*)$/;
1073
+ var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
1074
+ var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
1075
+ var starDotExtTestNocase = (ext2) => {
1076
+ ext2 = ext2.toLowerCase();
1077
+ return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
1078
+ };
1079
+ var starDotExtTestNocaseDot = (ext2) => {
1080
+ ext2 = ext2.toLowerCase();
1081
+ return (f) => f.toLowerCase().endsWith(ext2);
1082
+ };
1083
+ var starDotStarRE = /^\*+\.\*+$/;
1084
+ var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
1085
+ var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
1086
+ var dotStarRE = /^\.\*+$/;
1087
+ var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
1088
+ var starRE = /^\*+$/;
1089
+ var starTest = (f) => f.length !== 0 && !f.startsWith(".");
1090
+ var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
1091
+ var qmarksRE = /^\?+([^+@!?*[(]*)?$/;
1092
+ var qmarksTestNocase = ([$0, ext2 = ""]) => {
1093
+ const noext = qmarksTestNoExt([$0]);
1094
+ if (!ext2)
1095
+ return noext;
1096
+ ext2 = ext2.toLowerCase();
1097
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
1098
+ };
1099
+ var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
1100
+ const noext = qmarksTestNoExtDot([$0]);
1101
+ if (!ext2)
1102
+ return noext;
1103
+ ext2 = ext2.toLowerCase();
1104
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
1105
+ };
1106
+ var qmarksTestDot = ([$0, ext2 = ""]) => {
1107
+ const noext = qmarksTestNoExtDot([$0]);
1108
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
1109
+ };
1110
+ var qmarksTest = ([$0, ext2 = ""]) => {
1111
+ const noext = qmarksTestNoExt([$0]);
1112
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
1113
+ };
1114
+ var qmarksTestNoExt = ([$0]) => {
1115
+ const len = $0.length;
1116
+ return (f) => f.length === len && !f.startsWith(".");
1117
+ };
1118
+ var qmarksTestNoExtDot = ([$0]) => {
1119
+ const len = $0.length;
1120
+ return (f) => f.length === len && f !== "." && f !== "..";
1121
+ };
1122
+ var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
1123
+ var path = {
1124
+ win32: { sep: "\\" },
1125
+ posix: { sep: "/" }
1126
+ };
1127
+ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
1128
+ minimatch.sep = sep;
1129
+ var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
1130
+ minimatch.GLOBSTAR = GLOBSTAR;
1131
+ var qmark2 = "[^/]";
1132
+ var star2 = qmark2 + "*?";
1133
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
1134
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
1135
+ var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
1136
+ minimatch.filter = filter;
1137
+ var ext = (a, b = {}) => Object.assign({}, a, b);
1138
+ var defaults = (def) => {
1139
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
1140
+ return minimatch;
1141
+ }
1142
+ const orig = minimatch;
1143
+ const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
1144
+ return Object.assign(m, {
1145
+ Minimatch: class Minimatch extends orig.Minimatch {
1146
+ constructor(pattern, options = {}) {
1147
+ super(pattern, ext(def, options));
1148
+ }
1149
+ static defaults(options) {
1150
+ return orig.defaults(ext(def, options)).Minimatch;
1151
+ }
1152
+ },
1153
+ AST: class AST extends orig.AST {
1154
+ /* c8 ignore start */
1155
+ constructor(type, parent, options = {}) {
1156
+ super(type, parent, ext(def, options));
1157
+ }
1158
+ /* c8 ignore stop */
1159
+ static fromGlob(pattern, options = {}) {
1160
+ return orig.AST.fromGlob(pattern, ext(def, options));
1161
+ }
1162
+ },
1163
+ unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
1164
+ escape: (s, options = {}) => orig.escape(s, ext(def, options)),
1165
+ filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
1166
+ defaults: (options) => orig.defaults(ext(def, options)),
1167
+ makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
1168
+ braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
1169
+ match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
1170
+ sep: orig.sep,
1171
+ GLOBSTAR
1172
+ });
1173
+ };
1174
+ minimatch.defaults = defaults;
1175
+ var braceExpand = (pattern, options = {}) => {
1176
+ assertValidPattern(pattern);
1177
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1178
+ return [pattern];
1179
+ }
1180
+ return expand(pattern, { max: options.braceExpandMax });
1181
+ };
1182
+ minimatch.braceExpand = braceExpand;
1183
+ var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
1184
+ minimatch.makeRe = makeRe;
1185
+ var match = (list, pattern, options = {}) => {
1186
+ const mm = new Minimatch(pattern, options);
1187
+ list = list.filter((f) => mm.match(f));
1188
+ if (mm.options.nonull && !list.length) {
1189
+ list.push(pattern);
1190
+ }
1191
+ return list;
1192
+ };
1193
+ minimatch.match = match;
1194
+ var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1195
+ var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1196
+ var Minimatch = class {
1197
+ options;
1198
+ set;
1199
+ pattern;
1200
+ windowsPathsNoEscape;
1201
+ nonegate;
1202
+ negate;
1203
+ comment;
1204
+ empty;
1205
+ preserveMultipleSlashes;
1206
+ partial;
1207
+ globSet;
1208
+ globParts;
1209
+ nocase;
1210
+ isWindows;
1211
+ platform;
1212
+ windowsNoMagicRoot;
1213
+ maxGlobstarRecursion;
1214
+ regexp;
1215
+ constructor(pattern, options = {}) {
1216
+ assertValidPattern(pattern);
1217
+ options = options || {};
1218
+ this.options = options;
1219
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
1220
+ this.pattern = pattern;
1221
+ this.platform = options.platform || defaultPlatform;
1222
+ this.isWindows = this.platform === "win32";
1223
+ const awe = "allowWindowsEscape";
1224
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
1225
+ if (this.windowsPathsNoEscape) {
1226
+ this.pattern = this.pattern.replace(/\\/g, "/");
1227
+ }
1228
+ this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
1229
+ this.regexp = null;
1230
+ this.negate = false;
1231
+ this.nonegate = !!options.nonegate;
1232
+ this.comment = false;
1233
+ this.empty = false;
1234
+ this.partial = !!options.partial;
1235
+ this.nocase = !!this.options.nocase;
1236
+ this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
1237
+ this.globSet = [];
1238
+ this.globParts = [];
1239
+ this.set = [];
1240
+ this.make();
1241
+ }
1242
+ hasMagic() {
1243
+ if (this.options.magicalBraces && this.set.length > 1) {
1244
+ return true;
1245
+ }
1246
+ for (const pattern of this.set) {
1247
+ for (const part of pattern) {
1248
+ if (typeof part !== "string")
1249
+ return true;
1250
+ }
1251
+ }
1252
+ return false;
1253
+ }
1254
+ debug(..._) {
1255
+ }
1256
+ make() {
1257
+ const pattern = this.pattern;
1258
+ const options = this.options;
1259
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1260
+ this.comment = true;
1261
+ return;
1262
+ }
1263
+ if (!pattern) {
1264
+ this.empty = true;
1265
+ return;
1266
+ }
1267
+ this.parseNegate();
1268
+ this.globSet = [...new Set(this.braceExpand())];
1269
+ if (options.debug) {
1270
+ this.debug = (...args) => console.error(...args);
1271
+ }
1272
+ this.debug(this.pattern, this.globSet);
1273
+ const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
1274
+ this.globParts = this.preprocess(rawGlobParts);
1275
+ this.debug(this.pattern, this.globParts);
1276
+ let set = this.globParts.map((s, _, __) => {
1277
+ if (this.isWindows && this.windowsNoMagicRoot) {
1278
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
1279
+ const isDrive = /^[a-z]:/i.test(s[0]);
1280
+ if (isUNC) {
1281
+ return [
1282
+ ...s.slice(0, 4),
1283
+ ...s.slice(4).map((ss) => this.parse(ss))
1284
+ ];
1285
+ } else if (isDrive) {
1286
+ return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
1287
+ }
1288
+ }
1289
+ return s.map((ss) => this.parse(ss));
1290
+ });
1291
+ this.debug(this.pattern, set);
1292
+ this.set = set.filter((s) => s.indexOf(false) === -1);
1293
+ if (this.isWindows) {
1294
+ for (let i = 0; i < this.set.length; i++) {
1295
+ const p = this.set[i];
1296
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
1297
+ p[2] = "?";
1298
+ }
1299
+ }
1300
+ }
1301
+ this.debug(this.pattern, this.set);
1302
+ }
1303
+ // various transforms to equivalent pattern sets that are
1304
+ // faster to process in a filesystem walk. The goal is to
1305
+ // eliminate what we can, and push all ** patterns as far
1306
+ // to the right as possible, even if it increases the number
1307
+ // of patterns that we have to process.
1308
+ preprocess(globParts) {
1309
+ if (this.options.noglobstar) {
1310
+ for (const partset of globParts) {
1311
+ for (let j = 0; j < partset.length; j++) {
1312
+ if (partset[j] === "**") {
1313
+ partset[j] = "*";
1314
+ }
1315
+ }
1316
+ }
1317
+ }
1318
+ const { optimizationLevel = 1 } = this.options;
1319
+ if (optimizationLevel >= 2) {
1320
+ globParts = this.firstPhasePreProcess(globParts);
1321
+ globParts = this.secondPhasePreProcess(globParts);
1322
+ } else if (optimizationLevel >= 1) {
1323
+ globParts = this.levelOneOptimize(globParts);
1324
+ } else {
1325
+ globParts = this.adjascentGlobstarOptimize(globParts);
1326
+ }
1327
+ return globParts;
1328
+ }
1329
+ // just get rid of adjascent ** portions
1330
+ adjascentGlobstarOptimize(globParts) {
1331
+ return globParts.map((parts) => {
1332
+ let gs = -1;
1333
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1334
+ let i = gs;
1335
+ while (parts[i + 1] === "**") {
1336
+ i++;
1337
+ }
1338
+ if (i !== gs) {
1339
+ parts.splice(gs, i - gs);
1340
+ }
1341
+ }
1342
+ return parts;
1343
+ });
1344
+ }
1345
+ // get rid of adjascent ** and resolve .. portions
1346
+ levelOneOptimize(globParts) {
1347
+ return globParts.map((parts) => {
1348
+ parts = parts.reduce((set, part) => {
1349
+ const prev = set[set.length - 1];
1350
+ if (part === "**" && prev === "**") {
1351
+ return set;
1352
+ }
1353
+ if (part === "..") {
1354
+ if (prev && prev !== ".." && prev !== "." && prev !== "**") {
1355
+ set.pop();
1356
+ return set;
1357
+ }
1358
+ }
1359
+ set.push(part);
1360
+ return set;
1361
+ }, []);
1362
+ return parts.length === 0 ? [""] : parts;
1363
+ });
1364
+ }
1365
+ levelTwoFileOptimize(parts) {
1366
+ if (!Array.isArray(parts)) {
1367
+ parts = this.slashSplit(parts);
1368
+ }
1369
+ let didSomething = false;
1370
+ do {
1371
+ didSomething = false;
1372
+ if (!this.preserveMultipleSlashes) {
1373
+ for (let i = 1; i < parts.length - 1; i++) {
1374
+ const p = parts[i];
1375
+ if (i === 1 && p === "" && parts[0] === "")
1376
+ continue;
1377
+ if (p === "." || p === "") {
1378
+ didSomething = true;
1379
+ parts.splice(i, 1);
1380
+ i--;
1381
+ }
1382
+ }
1383
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1384
+ didSomething = true;
1385
+ parts.pop();
1386
+ }
1387
+ }
1388
+ let dd = 0;
1389
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1390
+ const p = parts[dd - 1];
1391
+ if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
1392
+ didSomething = true;
1393
+ parts.splice(dd - 1, 2);
1394
+ dd -= 2;
1395
+ }
1396
+ }
1397
+ } while (didSomething);
1398
+ return parts.length === 0 ? [""] : parts;
1399
+ }
1400
+ // First phase: single-pattern processing
1401
+ // <pre> is 1 or more portions
1402
+ // <rest> is 1 or more portions
1403
+ // <p> is any portion other than ., .., '', or **
1404
+ // <e> is . or ''
1405
+ //
1406
+ // **/.. is *brutal* for filesystem walking performance, because
1407
+ // it effectively resets the recursive walk each time it occurs,
1408
+ // and ** cannot be reduced out by a .. pattern part like a regexp
1409
+ // or most strings (other than .., ., and '') can be.
1410
+ //
1411
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1412
+ // <pre>/<e>/<rest> -> <pre>/<rest>
1413
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
1414
+ // **/**/<rest> -> **/<rest>
1415
+ //
1416
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1417
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
1418
+ firstPhasePreProcess(globParts) {
1419
+ let didSomething = false;
1420
+ do {
1421
+ didSomething = false;
1422
+ for (let parts of globParts) {
1423
+ let gs = -1;
1424
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1425
+ let gss = gs;
1426
+ while (parts[gss + 1] === "**") {
1427
+ gss++;
1428
+ }
1429
+ if (gss > gs) {
1430
+ parts.splice(gs + 1, gss - gs);
1431
+ }
1432
+ let next = parts[gs + 1];
1433
+ const p = parts[gs + 2];
1434
+ const p2 = parts[gs + 3];
1435
+ if (next !== "..")
1436
+ continue;
1437
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
1438
+ continue;
1439
+ }
1440
+ didSomething = true;
1441
+ parts.splice(gs, 1);
1442
+ const other = parts.slice(0);
1443
+ other[gs] = "**";
1444
+ globParts.push(other);
1445
+ gs--;
1446
+ }
1447
+ if (!this.preserveMultipleSlashes) {
1448
+ for (let i = 1; i < parts.length - 1; i++) {
1449
+ const p = parts[i];
1450
+ if (i === 1 && p === "" && parts[0] === "")
1451
+ continue;
1452
+ if (p === "." || p === "") {
1453
+ didSomething = true;
1454
+ parts.splice(i, 1);
1455
+ i--;
1456
+ }
1457
+ }
1458
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1459
+ didSomething = true;
1460
+ parts.pop();
1461
+ }
1462
+ }
1463
+ let dd = 0;
1464
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1465
+ const p = parts[dd - 1];
1466
+ if (p && p !== "." && p !== ".." && p !== "**") {
1467
+ didSomething = true;
1468
+ const needDot = dd === 1 && parts[dd + 1] === "**";
1469
+ const splin = needDot ? ["."] : [];
1470
+ parts.splice(dd - 1, 2, ...splin);
1471
+ if (parts.length === 0)
1472
+ parts.push("");
1473
+ dd -= 2;
1474
+ }
1475
+ }
1476
+ }
1477
+ } while (didSomething);
1478
+ return globParts;
1479
+ }
1480
+ // second phase: multi-pattern dedupes
1481
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1482
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1483
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1484
+ //
1485
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1486
+ // ^-- not valid because ** doens't follow symlinks
1487
+ secondPhasePreProcess(globParts) {
1488
+ for (let i = 0; i < globParts.length - 1; i++) {
1489
+ for (let j = i + 1; j < globParts.length; j++) {
1490
+ const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
1491
+ if (matched) {
1492
+ globParts[i] = [];
1493
+ globParts[j] = matched;
1494
+ break;
1495
+ }
1496
+ }
1497
+ }
1498
+ return globParts.filter((gs) => gs.length);
1499
+ }
1500
+ partsMatch(a, b, emptyGSMatch = false) {
1501
+ let ai = 0;
1502
+ let bi = 0;
1503
+ let result = [];
1504
+ let which = "";
1505
+ while (ai < a.length && bi < b.length) {
1506
+ if (a[ai] === b[bi]) {
1507
+ result.push(which === "b" ? b[bi] : a[ai]);
1508
+ ai++;
1509
+ bi++;
1510
+ } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1511
+ result.push(a[ai]);
1512
+ ai++;
1513
+ } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1514
+ result.push(b[bi]);
1515
+ bi++;
1516
+ } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1517
+ if (which === "b")
1518
+ return false;
1519
+ which = "a";
1520
+ result.push(a[ai]);
1521
+ ai++;
1522
+ bi++;
1523
+ } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1524
+ if (which === "a")
1525
+ return false;
1526
+ which = "b";
1527
+ result.push(b[bi]);
1528
+ ai++;
1529
+ bi++;
1530
+ } else {
1531
+ return false;
1532
+ }
1533
+ }
1534
+ return a.length === b.length && result;
1535
+ }
1536
+ parseNegate() {
1537
+ if (this.nonegate)
1538
+ return;
1539
+ const pattern = this.pattern;
1540
+ let negate = false;
1541
+ let negateOffset = 0;
1542
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
1543
+ negate = !negate;
1544
+ negateOffset++;
1545
+ }
1546
+ if (negateOffset)
1547
+ this.pattern = pattern.slice(negateOffset);
1548
+ this.negate = negate;
1549
+ }
1550
+ // set partial to true to test if, for example,
1551
+ // "/a/b" matches the start of "/*/b/*/d"
1552
+ // Partial means, if you run out of file before you run
1553
+ // out of pattern, then that's fine, as long as all
1554
+ // the parts match.
1555
+ matchOne(file, pattern, partial = false) {
1556
+ let fileStartIndex = 0;
1557
+ let patternStartIndex = 0;
1558
+ if (this.isWindows) {
1559
+ const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1560
+ const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1561
+ const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1562
+ const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1563
+ const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1564
+ const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1565
+ if (typeof fdi === "number" && typeof pdi === "number") {
1566
+ const [fd, pd] = [
1567
+ file[fdi],
1568
+ pattern[pdi]
1569
+ ];
1570
+ if (fd.toLowerCase() === pd.toLowerCase()) {
1571
+ pattern[pdi] = fd;
1572
+ patternStartIndex = pdi;
1573
+ fileStartIndex = fdi;
1574
+ }
1575
+ }
1576
+ }
1577
+ const { optimizationLevel = 1 } = this.options;
1578
+ if (optimizationLevel >= 2) {
1579
+ file = this.levelTwoFileOptimize(file);
1580
+ }
1581
+ if (pattern.includes(GLOBSTAR)) {
1582
+ return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
1583
+ }
1584
+ return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
1585
+ }
1586
+ #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
1587
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
1588
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
1589
+ const [head, body, tail] = partial ? [
1590
+ pattern.slice(patternIndex, firstgs),
1591
+ pattern.slice(firstgs + 1),
1592
+ []
1593
+ ] : [
1594
+ pattern.slice(patternIndex, firstgs),
1595
+ pattern.slice(firstgs + 1, lastgs),
1596
+ pattern.slice(lastgs + 1)
1597
+ ];
1598
+ if (head.length) {
1599
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
1600
+ if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
1601
+ return false;
1602
+ }
1603
+ fileIndex += head.length;
1604
+ patternIndex += head.length;
1605
+ }
1606
+ let fileTailMatch = 0;
1607
+ if (tail.length) {
1608
+ if (tail.length + fileIndex > file.length)
1609
+ return false;
1610
+ let tailStart = file.length - tail.length;
1611
+ if (this.#matchOne(file, tail, partial, tailStart, 0)) {
1612
+ fileTailMatch = tail.length;
1613
+ } else {
1614
+ if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
1615
+ return false;
1616
+ }
1617
+ tailStart--;
1618
+ if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
1619
+ return false;
1620
+ }
1621
+ fileTailMatch = tail.length + 1;
1622
+ }
1623
+ }
1624
+ if (!body.length) {
1625
+ let sawSome = !!fileTailMatch;
1626
+ for (let i2 = fileIndex; i2 < file.length - fileTailMatch; i2++) {
1627
+ const f = String(file[i2]);
1628
+ sawSome = true;
1629
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
1630
+ return false;
1631
+ }
1632
+ }
1633
+ return partial || sawSome;
1634
+ }
1635
+ const bodySegments = [[[], 0]];
1636
+ let currentBody = bodySegments[0];
1637
+ let nonGsParts = 0;
1638
+ const nonGsPartsSums = [0];
1639
+ for (const b of body) {
1640
+ if (b === GLOBSTAR) {
1641
+ nonGsPartsSums.push(nonGsParts);
1642
+ currentBody = [[], 0];
1643
+ bodySegments.push(currentBody);
1644
+ } else {
1645
+ currentBody[0].push(b);
1646
+ nonGsParts++;
1647
+ }
1648
+ }
1649
+ let i = bodySegments.length - 1;
1650
+ const fileLength = file.length - fileTailMatch;
1651
+ for (const b of bodySegments) {
1652
+ b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
1653
+ }
1654
+ return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
1655
+ }
1656
+ // return false for "nope, not matching"
1657
+ // return null for "not matching, cannot keep trying"
1658
+ #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
1659
+ const bs = bodySegments[bodyIndex];
1660
+ if (!bs) {
1661
+ for (let i = fileIndex; i < file.length; i++) {
1662
+ sawTail = true;
1663
+ const f = file[i];
1664
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
1665
+ return false;
1666
+ }
1667
+ }
1668
+ return sawTail;
1669
+ }
1670
+ const [body, after] = bs;
1671
+ while (fileIndex <= after) {
1672
+ const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
1673
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
1674
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
1675
+ if (sub !== false) {
1676
+ return sub;
1677
+ }
1678
+ }
1679
+ const f = file[fileIndex];
1680
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
1681
+ return false;
1682
+ }
1683
+ fileIndex++;
1684
+ }
1685
+ return partial || null;
1686
+ }
1687
+ #matchOne(file, pattern, partial, fileIndex, patternIndex) {
1688
+ let fi;
1689
+ let pi;
1690
+ let pl;
1691
+ let fl;
1692
+ for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1693
+ this.debug("matchOne loop");
1694
+ let p = pattern[pi];
1695
+ let f = file[fi];
1696
+ this.debug(pattern, p, f);
1697
+ if (p === false || p === GLOBSTAR) {
1698
+ return false;
1699
+ }
1700
+ let hit;
1701
+ if (typeof p === "string") {
1702
+ hit = f === p;
1703
+ this.debug("string match", p, f, hit);
1704
+ } else {
1705
+ hit = p.test(f);
1706
+ this.debug("pattern match", p, f, hit);
1707
+ }
1708
+ if (!hit)
1709
+ return false;
1710
+ }
1711
+ if (fi === fl && pi === pl) {
1712
+ return true;
1713
+ } else if (fi === fl) {
1714
+ return partial;
1715
+ } else if (pi === pl) {
1716
+ return fi === fl - 1 && file[fi] === "";
1717
+ } else {
1718
+ throw new Error("wtf?");
1719
+ }
1720
+ }
1721
+ braceExpand() {
1722
+ return braceExpand(this.pattern, this.options);
1723
+ }
1724
+ parse(pattern) {
1725
+ assertValidPattern(pattern);
1726
+ const options = this.options;
1727
+ if (pattern === "**")
1728
+ return GLOBSTAR;
1729
+ if (pattern === "")
1730
+ return "";
1731
+ let m;
1732
+ let fastTest = null;
1733
+ if (m = pattern.match(starRE)) {
1734
+ fastTest = options.dot ? starTestDot : starTest;
1735
+ } else if (m = pattern.match(starDotExtRE)) {
1736
+ fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
1737
+ } else if (m = pattern.match(qmarksRE)) {
1738
+ fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
1739
+ } else if (m = pattern.match(starDotStarRE)) {
1740
+ fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
1741
+ } else if (m = pattern.match(dotStarRE)) {
1742
+ fastTest = dotStarTest;
1743
+ }
1744
+ const re = AST.fromGlob(pattern, this.options).toMMPattern();
1745
+ if (fastTest && typeof re === "object") {
1746
+ Reflect.defineProperty(re, "test", { value: fastTest });
1747
+ }
1748
+ return re;
1749
+ }
1750
+ makeRe() {
1751
+ if (this.regexp || this.regexp === false)
1752
+ return this.regexp;
1753
+ const set = this.set;
1754
+ if (!set.length) {
1755
+ this.regexp = false;
1756
+ return this.regexp;
1757
+ }
1758
+ const options = this.options;
1759
+ const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
1760
+ const flags = new Set(options.nocase ? ["i"] : []);
1761
+ let re = set.map((pattern) => {
1762
+ const pp = pattern.map((p) => {
1763
+ if (p instanceof RegExp) {
1764
+ for (const f of p.flags.split(""))
1765
+ flags.add(f);
1766
+ }
1767
+ return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
1768
+ });
1769
+ pp.forEach((p, i) => {
1770
+ const next = pp[i + 1];
1771
+ const prev = pp[i - 1];
1772
+ if (p !== GLOBSTAR || prev === GLOBSTAR) {
1773
+ return;
1774
+ }
1775
+ if (prev === void 0) {
1776
+ if (next !== void 0 && next !== GLOBSTAR) {
1777
+ pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
1778
+ } else {
1779
+ pp[i] = twoStar;
1780
+ }
1781
+ } else if (next === void 0) {
1782
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
1783
+ } else if (next !== GLOBSTAR) {
1784
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
1785
+ pp[i + 1] = GLOBSTAR;
1786
+ }
1787
+ });
1788
+ const filtered = pp.filter((p) => p !== GLOBSTAR);
1789
+ if (this.partial && filtered.length >= 1) {
1790
+ const prefixes = [];
1791
+ for (let i = 1; i <= filtered.length; i++) {
1792
+ prefixes.push(filtered.slice(0, i).join("/"));
1793
+ }
1794
+ return "(?:" + prefixes.join("|") + ")";
1795
+ }
1796
+ return filtered.join("/");
1797
+ }).join("|");
1798
+ const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
1799
+ re = "^" + open + re + close + "$";
1800
+ if (this.partial) {
1801
+ re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
1802
+ }
1803
+ if (this.negate)
1804
+ re = "^(?!" + re + ").+$";
1805
+ try {
1806
+ this.regexp = new RegExp(re, [...flags].join(""));
1807
+ } catch {
1808
+ this.regexp = false;
1809
+ }
1810
+ return this.regexp;
1811
+ }
1812
+ slashSplit(p) {
1813
+ if (this.preserveMultipleSlashes) {
1814
+ return p.split("/");
1815
+ } else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
1816
+ return ["", ...p.split(/\/+/)];
1817
+ } else {
1818
+ return p.split(/\/+/);
1819
+ }
1820
+ }
1821
+ match(f, partial = this.partial) {
1822
+ this.debug("match", f, this.pattern);
1823
+ if (this.comment) {
1824
+ return false;
1825
+ }
1826
+ if (this.empty) {
1827
+ return f === "";
1828
+ }
1829
+ if (f === "/" && partial) {
1830
+ return true;
1831
+ }
1832
+ const options = this.options;
1833
+ if (this.isWindows) {
1834
+ f = f.split("\\").join("/");
1835
+ }
1836
+ const ff = this.slashSplit(f);
1837
+ this.debug(this.pattern, "split", ff);
1838
+ const set = this.set;
1839
+ this.debug(this.pattern, "set", set);
1840
+ let filename = ff[ff.length - 1];
1841
+ if (!filename) {
1842
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
1843
+ filename = ff[i];
1844
+ }
1845
+ }
1846
+ for (const pattern of set) {
1847
+ let file = ff;
1848
+ if (options.matchBase && pattern.length === 1) {
1849
+ file = [filename];
1850
+ }
1851
+ const hit = this.matchOne(file, pattern, partial);
1852
+ if (hit) {
1853
+ if (options.flipNegate) {
1854
+ return true;
1855
+ }
1856
+ return !this.negate;
1857
+ }
1858
+ }
1859
+ if (options.flipNegate) {
1860
+ return false;
1861
+ }
1862
+ return this.negate;
1863
+ }
1864
+ static defaults(def) {
1865
+ return minimatch.defaults(def).Minimatch;
1866
+ }
1867
+ };
1868
+ minimatch.AST = AST;
1869
+ minimatch.Minimatch = Minimatch;
1870
+ minimatch.escape = escape;
1871
+ minimatch.unescape = unescape;
1872
+
1873
+ // dist/clients/path-utils.js
1874
+ import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
1875
+ import * as os from "node:os";
1876
+ import * as path2 from "node:path";
1877
+ import { win32 } from "node:path";
1878
+ import { fileURLToPath, pathToFileURL } from "node:url";
1879
+ function isWindowsPath(filePath) {
1880
+ return /^[A-Za-z]:/.test(filePath) || filePath.startsWith("\\");
1881
+ }
1882
+ function toPosix(filePath) {
1883
+ return filePath.replace(/\\/g, "/");
1884
+ }
1885
+ function isFullyQualifiedWin32(filePath) {
1886
+ return win32.isAbsolute(filePath) && win32.parse(filePath).root.length > 1;
1887
+ }
1888
+ function isFullyQualifiedPosix(filePath) {
1889
+ return path2.posix.isAbsolute(filePath) && !isWindowsPath(filePath);
1890
+ }
1891
+ function isFullyQualified(filePath) {
1892
+ return process.platform === "win32" ? isFullyQualifiedWin32(filePath) : isFullyQualifiedPosix(filePath);
1893
+ }
1894
+ function isAbsoluteFilePath(filePath) {
1895
+ const p = isWindowsPath(filePath) ? win32 : path2;
1896
+ return p.isAbsolute(filePath);
1897
+ }
1898
+ function adoptCanonicalCasing(held, canonical) {
1899
+ const heldParts = held.split("/");
1900
+ const realParts = canonical.split("/");
1901
+ let i = heldParts.length - 1;
1902
+ let j = realParts.length - 1;
1903
+ let changed = false;
1904
+ while (i >= 0 && j >= 0) {
1905
+ const a = heldParts[i];
1906
+ const b = realParts[j];
1907
+ if (a !== b) {
1908
+ if (a.toLowerCase() !== b.toLowerCase())
1909
+ break;
1910
+ heldParts[i] = b;
1911
+ changed = true;
1912
+ }
1913
+ i--;
1914
+ j--;
1915
+ }
1916
+ return changed ? heldParts.join("/") : held;
1917
+ }
1918
+ function normalizeFilePath(filePath) {
1919
+ if (process.platform === "win32") {
1920
+ if (filePath === "")
1921
+ return "";
1922
+ if (!isFullyQualifiedWin32(filePath)) {
1923
+ return win32.normalize(filePath).replace(/\\/g, "/");
1924
+ }
1925
+ }
1926
+ const normalized = filePath.replace(/\\/g, "/");
1927
+ if (process.platform !== "win32" && !isWindowsPath(normalized)) {
1928
+ const folded = normalized === "" || normalized.startsWith("//") ? normalized : path2.posix.normalize(normalized);
1929
+ try {
1930
+ const canonical = realpathSync.native(folded);
1931
+ if (canonical === folded)
1932
+ return folded;
1933
+ const adopted = adoptCanonicalCasing(folded, canonical);
1934
+ if (adopted === folded)
1935
+ return folded;
1936
+ return realpathSync.native(adopted) === canonical ? adopted : folded;
1937
+ } catch {
1938
+ return folded;
1939
+ }
1940
+ }
1941
+ try {
1942
+ const canonical = realpathSync.native(filePath);
1943
+ return canonical.replace(/\\/g, "/");
1944
+ } catch {
1945
+ try {
1946
+ return resolveNonExisting(filePath);
1947
+ } catch {
1948
+ const resolved = win32.normalize(win32.resolve(filePath));
1949
+ return resolved.replace(/\\/g, "/").toLowerCase();
1950
+ }
1951
+ }
1952
+ }
1953
+ function realpathOrResolve(filePath) {
1954
+ const resolved = path2.resolve(filePath);
1955
+ try {
1956
+ return realpathSync(resolved);
1957
+ } catch {
1958
+ return resolved;
1959
+ }
1960
+ }
1961
+ function normalizeLoggedPath(value) {
1962
+ return isFullyQualifiedWin32(value) || isFullyQualifiedPosix(value) ? normalizeFilePath(value) : value;
1963
+ }
1964
+ function resolveNonExisting(filePath) {
1965
+ const resolved = win32.resolve(filePath);
1966
+ let current = resolved;
1967
+ const nonExistentParts = [];
1968
+ while (true) {
1969
+ if (existsSync(current)) {
1970
+ const canonical = realpathSync.native(current);
1971
+ if (nonExistentParts.length === 0) {
1972
+ return canonical.replace(/\\/g, "/");
1973
+ }
1974
+ const tail = nonExistentParts.reverse().join("/").toLowerCase();
1975
+ const base = canonical.replace(/\\/g, "/");
1976
+ return base.endsWith("/") ? base + tail : `${base}/${tail}`;
1977
+ }
1978
+ const parent = win32.dirname(current);
1979
+ if (parent === current) {
1980
+ throw new Error("No existing parent found");
1981
+ }
1982
+ nonExistentParts.push(win32.basename(current));
1983
+ current = parent;
1984
+ }
1985
+ }
1986
+ function uriToPath(uri) {
1987
+ try {
1988
+ const filePath = fileURLToPath(uri);
1989
+ return normalizeFilePath(filePath);
1990
+ } catch {
1991
+ return normalizeFilePath(uri);
1992
+ }
1993
+ }
1994
+ function uriToDiskPath(uri) {
1995
+ try {
1996
+ return fileURLToPath(uri);
1997
+ } catch {
1998
+ return uri;
1999
+ }
2000
+ }
2001
+ function normalizeMapKey(filePath) {
2002
+ return normalizeFilePath(filePath);
2003
+ }
2004
+ function toProjectRelativePath(filePath, projectRoot) {
2005
+ const p = isWindowsPath(filePath) ? win32 : path2;
2006
+ if (!p.isAbsolute(filePath))
2007
+ return filePath.replace(/\\/g, "/");
2008
+ const inside = (root, file) => {
2009
+ const relative = p.relative(p.resolve(root), file);
2010
+ return relative && relative !== ".." && !relative.startsWith(`..${p.sep}`) && !p.isAbsolute(relative) ? relative.replace(/\\/g, "/") : void 0;
2011
+ };
2012
+ const direct = inside(projectRoot, filePath);
2013
+ if (direct !== void 0)
2014
+ return direct;
2015
+ const canonical = inside(normalizeFilePath(projectRoot), normalizeFilePath(filePath));
2016
+ if (canonical !== void 0)
2017
+ return canonical;
2018
+ return filePath.replace(/\\/g, "/");
2019
+ }
2020
+ function normalizeEphemeralMapKey(filePath) {
2021
+ if (process.platform !== "win32" && !filePath.includes("\\"))
2022
+ return filePath;
2023
+ const slashed = filePath.replace(/\\/g, "/");
2024
+ return process.platform === "win32" ? slashed.toLowerCase() : slashed;
2025
+ }
2026
+ function pathsEqual(a, b) {
2027
+ return normalizeFilePath(a) === normalizeFilePath(b);
2028
+ }
2029
+ function* walkUpDirs(startDir) {
2030
+ let current = path2.resolve(startDir);
2031
+ while (true) {
2032
+ yield current;
2033
+ const parent = path2.dirname(current);
2034
+ if (parent === current)
2035
+ return;
2036
+ current = parent;
2037
+ }
2038
+ }
2039
+ function findNearestContaining(startDir, candidates) {
2040
+ for (const dir of walkUpDirs(startDir)) {
2041
+ for (const name of candidates) {
2042
+ if (existsSync(path2.join(dir, name)))
2043
+ return dir;
2044
+ }
2045
+ }
2046
+ return void 0;
2047
+ }
2048
+ function findLocalToolConfig(startDir, names, options = {}) {
2049
+ const homeDir = options.homeDir !== void 0 ? path2.resolve(options.homeDir) : void 0;
2050
+ for (const dir of walkUpDirs(startDir || process.cwd())) {
2051
+ if (homeDir !== void 0 && isAtOrAboveHomeDir(dir, homeDir)) {
2052
+ return void 0;
2053
+ }
2054
+ for (const name of names) {
2055
+ const candidate = path2.join(dir, name);
2056
+ if (existsSync(candidate))
2057
+ return candidate;
2058
+ }
2059
+ }
2060
+ return void 0;
2061
+ }
2062
+ function isRealGitMarker(markerPath, details) {
2063
+ const detailed = details === true;
2064
+ try {
2065
+ const marker = statSync(markerPath);
2066
+ let valid = false;
2067
+ if (marker.isDirectory()) {
2068
+ statSync(path2.join(markerPath, "HEAD"));
2069
+ valid = true;
2070
+ } else if (marker.isFile()) {
2071
+ valid = readFileSync(markerPath, "utf8").split(/\r?\n/, 1)[0].startsWith("gitdir:");
2072
+ }
2073
+ if (!detailed)
2074
+ return valid;
2075
+ return { kind: valid ? "valid" : "absent" };
2076
+ } catch (cause) {
2077
+ if (!detailed)
2078
+ return false;
2079
+ if (typeof cause === "object" && cause !== null && "code" in cause && (cause.code === "ENOENT" || cause.code === "ENOTDIR")) {
2080
+ return { kind: "absent" };
2081
+ }
2082
+ return { kind: "unavailable", cause };
2083
+ }
2084
+ }
2085
+ function findNearestMarkerRoot(startDir, markers, options = {}) {
2086
+ const boundaries = options.boundaries ?? [];
2087
+ const homeDir = path2.resolve(options.homeDir ?? os.homedir());
2088
+ const markerPredicate = options.markerPredicate ?? (() => true);
2089
+ let current = path2.resolve(startDir);
2090
+ for (let depth = 0; depth < 64; depth++) {
2091
+ if (isAtOrAboveHomeDir(current, homeDir))
2092
+ return null;
2093
+ if (markers.some((m) => existsSync(path2.join(current, m)) && markerPredicate(path2.join(current, m))))
2094
+ return current;
2095
+ if (boundaries.some((m) => existsSync(path2.join(current, m))))
2096
+ return null;
2097
+ const parent = path2.dirname(current);
2098
+ if (parent === current)
2099
+ return null;
2100
+ current = parent;
2101
+ }
2102
+ return null;
2103
+ }
2104
+ function findNearestMarkerRootDetailed(startDir, markers, options) {
2105
+ const homeDir = path2.resolve(options.homeDir ?? os.homedir());
2106
+ let current = path2.resolve(startDir);
2107
+ for (let depth = 0; depth < 64; depth++) {
2108
+ if (isAtOrAboveHomeDir(current, homeDir))
2109
+ return { kind: "not-found", reason: "home-ceiling" };
2110
+ for (const marker of markers) {
2111
+ const markerPath = path2.join(current, marker);
2112
+ const checked = options.markerPredicate(markerPath);
2113
+ if (checked.kind === "unavailable")
2114
+ return { kind: "unavailable", markerPath, cause: checked.cause };
2115
+ if (checked.kind === "valid")
2116
+ return { kind: "found", root: current };
2117
+ }
2118
+ const parent = path2.dirname(current);
2119
+ if (parent === current)
2120
+ return { kind: "not-found", reason: "root" };
2121
+ current = parent;
2122
+ }
2123
+ return { kind: "not-found", reason: "depth-limit" };
2124
+ }
2125
+ function isAtOrAboveHomeDir(dir, homeDir = os.homedir(), pathImpl = path2) {
2126
+ const rel = pathImpl.relative(pathImpl.resolve(dir), pathImpl.resolve(homeDir));
2127
+ return !rel.startsWith("..") && !pathImpl.isAbsolute(rel);
2128
+ }
2129
+ function homeRelativePath(filePath, homeDir = os.homedir()) {
2130
+ if (filePath.length === 0)
2131
+ return filePath;
2132
+ const candidate = toPosix(filePath);
2133
+ const home = toPosix(homeDir).replace(/\/+$/, "");
2134
+ if (home.length === 0)
2135
+ return filePath;
2136
+ const fold = (text) => process.platform === "win32" ? text.toLowerCase() : text;
2137
+ const foldedHome = fold(home);
2138
+ const foldedCandidate = fold(candidate);
2139
+ if (foldedCandidate === foldedHome)
2140
+ return "~";
2141
+ if (!foldedCandidate.startsWith(`${foldedHome}/`))
2142
+ return filePath;
2143
+ return `~${candidate.slice(home.length)}`;
2144
+ }
2145
+ function isUnderDir(child, parent) {
2146
+ const normChild = normalizeFilePath(child);
2147
+ const normParent = normalizeFilePath(parent);
2148
+ const parentPrefix = normParent.endsWith("/") ? normParent : `${normParent}/`;
2149
+ return normChild === normParent || normChild.startsWith(parentPrefix);
2150
+ }
2151
+ var VENDOR_DIR_NAMES = /* @__PURE__ */ new Set([
2152
+ "node_modules",
2153
+ "vendor",
2154
+ "vendors",
2155
+ "third_party",
2156
+ "third-party"
2157
+ ]);
2158
+ function isExternalOrVendorFile(filePath, projectRoot) {
2159
+ if (!isUnderDir(filePath, projectRoot))
2160
+ return true;
2161
+ const normalized = normalizeFilePath(filePath);
2162
+ const rootNorm = normalizeFilePath(projectRoot);
2163
+ const rel = normalized.startsWith(rootNorm + "/") ? normalized.slice(rootNorm.length + 1) : normalized;
2164
+ return rel.split("/").some((seg) => VENDOR_DIR_NAMES.has(seg));
2165
+ }
2166
+ function nameMatchesMarkerGlob(name, pattern) {
2167
+ return minimatch(name, pattern, {
2168
+ dot: true,
2169
+ nocase: process.platform === "win32"
2170
+ });
2171
+ }
2172
+ function direntsHaveMarkerGlobMatch(entries, pattern) {
2173
+ return entries.some((entry) => (entry.isFile() || entry.isSymbolicLink()) && nameMatchesMarkerGlob(entry.name, pattern));
2174
+ }
2175
+ var CARGO_WORKSPACE_MEMBER_DIALECT = {
2176
+ name: "cargo",
2177
+ globstar: "pattern-never-matches",
2178
+ wildcardCrossesSeparator: false,
2179
+ characterClasses: false,
2180
+ normalizePattern: (pattern) => pattern.replace(/\/+$/, "")
2181
+ };
2182
+ var UV_WORKSPACE_MEMBERS_DIALECT = {
2183
+ name: "uv-members",
2184
+ globstar: "crosses-components",
2185
+ wildcardCrossesSeparator: false,
2186
+ characterClasses: true,
2187
+ normalizePattern: (pattern) => path2.posix.normalize(toPosix(pattern))
2188
+ };
2189
+ var UV_WORKSPACE_EXCLUDE_DIALECT = {
2190
+ name: "uv-exclude",
2191
+ globstar: "crosses-components",
2192
+ wildcardCrossesSeparator: true,
2193
+ characterClasses: true,
2194
+ normalizePattern: (pattern) => path2.posix.normalize(toPosix(pattern))
2195
+ };
2196
+ function findCharacterClassEnd(segment, open) {
2197
+ let i = open + 1;
2198
+ if (segment[i] === "!" || segment[i] === "^")
2199
+ i += 1;
2200
+ if (segment[i] === "]")
2201
+ i += 1;
2202
+ for (; i < segment.length; i += 1)
2203
+ if (segment[i] === "]")
2204
+ return i;
2205
+ return -1;
2206
+ }
2207
+ function stepAcceptsChar(crossesSeparator, ch) {
2208
+ return crossesSeparator ? ch !== "\n" && ch !== "\r" && ch !== "\u2028" && ch !== "\u2029" : ch !== "/";
2209
+ }
2210
+ function compileWorkspaceMemberPattern(pattern, dialect) {
2211
+ const isGlobstar = (component) => component === "**" && dialect.globstar === "crosses-components";
2212
+ const components = pattern.split("/");
2213
+ const steps = [];
2214
+ let needSeparator = false;
2215
+ for (let c = 0; c < components.length; c += 1) {
2216
+ if (needSeparator)
2217
+ steps.push({ kind: "literal", char: "/" });
2218
+ needSeparator = false;
2219
+ const component = components[c];
2220
+ if (isGlobstar(component)) {
2221
+ if (c === components.length - 1) {
2222
+ steps.push({ kind: "one", crossesSeparator: true });
2223
+ steps.push({ kind: "star", crossesSeparator: true });
2224
+ continue;
2225
+ }
2226
+ const split = { kind: "split", alternative: -1 };
2227
+ steps.push(split);
2228
+ steps.push({ kind: "one", crossesSeparator: true });
2229
+ steps.push({ kind: "star", crossesSeparator: true });
2230
+ steps.push({ kind: "literal", char: "/" });
2231
+ split.alternative = steps.length;
2232
+ continue;
2233
+ }
2234
+ for (let i = 0; i < component.length; i += 1) {
2235
+ const ch = component[i];
2236
+ if (ch === "*") {
2237
+ steps.push({
2238
+ kind: "star",
2239
+ crossesSeparator: dialect.wildcardCrossesSeparator
2240
+ });
2241
+ continue;
2242
+ }
2243
+ if (ch === "?") {
2244
+ steps.push({
2245
+ kind: "one",
2246
+ crossesSeparator: dialect.wildcardCrossesSeparator
2247
+ });
2248
+ continue;
2249
+ }
2250
+ if (ch === "[" && dialect.characterClasses) {
2251
+ const close = findCharacterClassEnd(component, i);
2252
+ if (close !== -1) {
2253
+ const body = component.slice(i + 1, close).replace(/[\\\]]/g, "\\$&");
2254
+ const source = body.startsWith("!") ? `[^${body.slice(1)}]` : `[${body}]`;
2255
+ let match2;
2256
+ try {
2257
+ match2 = new RegExp(`^${source}$`);
2258
+ } catch {
2259
+ return void 0;
2260
+ }
2261
+ steps.push({ kind: "class", match: match2 });
2262
+ i = close;
2263
+ continue;
2264
+ }
2265
+ }
2266
+ steps.push({ kind: "literal", char: ch });
2267
+ }
2268
+ needSeparator = true;
2269
+ }
2270
+ return steps;
2271
+ }
2272
+ var WORKSPACE_GLOB_MEMO_CELL_CAP = 2e6;
2273
+ function matchesWorkspaceMemberSteps(steps, subject, onCap) {
2274
+ const stepCount = steps.length;
2275
+ const width = subject.length + 1;
2276
+ if ((stepCount + 1) * width > WORKSPACE_GLOB_MEMO_CELL_CAP) {
2277
+ onCap?.();
2278
+ return false;
2279
+ }
2280
+ const table = new Uint8Array((stepCount + 1) * width);
2281
+ for (let p = subject.length; p >= 0; p -= 1) {
2282
+ const atEnd = p === subject.length;
2283
+ table[stepCount * width + p] = atEnd ? 1 : 0;
2284
+ for (let s = stepCount - 1; s >= 0; s -= 1) {
2285
+ const step = steps[s];
2286
+ const next = (s + 1) * width;
2287
+ let matched = 0;
2288
+ switch (step.kind) {
2289
+ case "literal":
2290
+ matched = !atEnd && subject[p] === step.char ? table[next + p + 1] : 0;
2291
+ break;
2292
+ case "one":
2293
+ matched = !atEnd && stepAcceptsChar(step.crossesSeparator, subject[p]) ? table[next + p + 1] : 0;
2294
+ break;
2295
+ case "class":
2296
+ matched = !atEnd && step.match.test(subject[p]) ? table[next + p + 1] : 0;
2297
+ break;
2298
+ case "star":
2299
+ matched = table[next + p] === 1 || !atEnd && stepAcceptsChar(step.crossesSeparator, subject[p]) && table[s * width + p + 1] === 1 ? 1 : 0;
2300
+ break;
2301
+ case "split":
2302
+ matched = table[step.alternative * width + p] === 1 || table[next + p] === 1 ? 1 : 0;
2303
+ break;
2304
+ }
2305
+ table[s * width + p] = matched;
2306
+ }
2307
+ }
2308
+ return table[0] === 1;
2309
+ }
2310
+ function matchesWorkspaceMemberPattern(pattern, relativePath, dialect, onCap) {
2311
+ const normalized = dialect.normalizePattern(pattern);
2312
+ if (dialect.globstar === "pattern-never-matches" && normalized.includes("**")) {
2313
+ return false;
2314
+ }
2315
+ const steps = compileWorkspaceMemberPattern(normalized, dialect);
2316
+ return steps !== void 0 && matchesWorkspaceMemberSteps(steps, relativePath, onCap);
2317
+ }
2318
+
2319
+ export {
2320
+ minimatch,
2321
+ Minimatch,
2322
+ isWindowsPath,
2323
+ toPosix,
2324
+ isFullyQualifiedWin32,
2325
+ isFullyQualified,
2326
+ isAbsoluteFilePath,
2327
+ normalizeFilePath,
2328
+ realpathOrResolve,
2329
+ normalizeLoggedPath,
2330
+ uriToPath,
2331
+ uriToDiskPath,
2332
+ normalizeMapKey,
2333
+ toProjectRelativePath,
2334
+ normalizeEphemeralMapKey,
2335
+ pathsEqual,
2336
+ walkUpDirs,
2337
+ findNearestContaining,
2338
+ findLocalToolConfig,
2339
+ isRealGitMarker,
2340
+ findNearestMarkerRoot,
2341
+ findNearestMarkerRootDetailed,
2342
+ isAtOrAboveHomeDir,
2343
+ homeRelativePath,
2344
+ isUnderDir,
2345
+ isExternalOrVendorFile,
2346
+ nameMatchesMarkerGlob,
2347
+ direntsHaveMarkerGlobMatch,
2348
+ CARGO_WORKSPACE_MEMBER_DIALECT,
2349
+ UV_WORKSPACE_MEMBERS_DIALECT,
2350
+ UV_WORKSPACE_EXCLUDE_DIALECT,
2351
+ matchesWorkspaceMemberPattern
2352
+ };