@herbertgao/pi-extensions 2026.11.11 → 2026.11.13

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 (262) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +13 -11
  3. package/THIRD_PARTY_NOTICES.md +3 -3
  4. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +10 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +3 -4
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.md +3 -4
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary/core.ts +22 -15
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary/index.ts +22 -8
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +0 -29
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +5 -2
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +60 -39
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +3 -2
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +0 -40
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-parse.ts +4 -1
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +21 -3
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/format.ts +15 -0
  17. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  18. package/node_modules/@herbertgao/pi-impeccable/CHANGELOG.md +6 -0
  19. package/node_modules/@herbertgao/pi-impeccable/README.md +2 -2
  20. package/node_modules/@herbertgao/pi-impeccable/package.json +4 -4
  21. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/SKILL.md +2 -2
  22. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/adapt.md +1 -1
  23. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/animate.md +17 -0
  24. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique-rubric.md +496 -0
  25. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique.md +12 -504
  26. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/motion-reviewer.md +29 -0
  27. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/hooks.md +3 -3
  28. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work-comp.md +24 -0
  29. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work-world.md +20 -0
  30. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work.md +5 -34
  31. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/typeset.md +6 -0
  32. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/VERSION +1 -1
  33. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/engine-checksums.txt +5 -5
  34. package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/live-browser.js +17 -18
  35. package/node_modules/@herbertgao/pi-inline-skill-commands/LICENSE +21 -0
  36. package/node_modules/@herbertgao/pi-inline-skill-commands/README.md +33 -0
  37. package/node_modules/@herbertgao/pi-inline-skill-commands/package.json +53 -0
  38. package/node_modules/@herbertgao/pi-inline-skill-commands/src/index.ts +213 -0
  39. package/node_modules/pi-antigravity/README.md +58 -9
  40. package/node_modules/pi-antigravity/docs/reader-guarantees.md +35 -0
  41. package/node_modules/pi-antigravity/package.json +15 -6
  42. package/node_modules/pi-antigravity/src/client/client.ts +63 -14
  43. package/node_modules/pi-antigravity/src/client/enterprise.ts +150 -0
  44. package/node_modules/pi-antigravity/src/client/index.ts +1 -0
  45. package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +7 -0
  46. package/node_modules/pi-antigravity/src/features/generate-image.ts +56 -2
  47. package/node_modules/pi-antigravity/src/features/read-url-content.ts +124 -0
  48. package/node_modules/pi-antigravity/src/image/image.ts +16 -2
  49. package/node_modules/pi-antigravity/src/index.ts +145 -2
  50. package/node_modules/pi-antigravity/src/models/discovery.ts +3 -4
  51. package/node_modules/pi-antigravity/src/models/grouping.ts +39 -15
  52. package/node_modules/pi-antigravity/src/models/models.ts +126 -14
  53. package/node_modules/pi-antigravity/src/stream/stream.ts +189 -30
  54. package/node_modules/pi-antigravity/src/types/types.ts +30 -1
  55. package/node_modules/pi-antigravity/src/usage/usage.ts +58 -0
  56. package/node_modules/pi-antigravity/src/utils/address.ts +180 -0
  57. package/node_modules/pi-antigravity/src/utils/credits.ts +149 -0
  58. package/node_modules/pi-antigravity/src/utils/html.ts +31 -0
  59. package/node_modules/pi-antigravity/src/utils/index.ts +2 -0
  60. package/node_modules/pi-antigravity/src/utils/security.ts +172 -13
  61. package/node_modules/pi-antigravity/src/utils/text.ts +66 -0
  62. package/node_modules/pi-antigravity/src/utils/util.ts +5 -4
  63. package/node_modules/pi-antigravity/src/web-fetch/document.ts +83 -0
  64. package/node_modules/pi-antigravity/src/web-fetch/fences.ts +24 -0
  65. package/node_modules/pi-antigravity/src/web-fetch/header.ts +97 -0
  66. package/node_modules/pi-antigravity/src/web-fetch/index.ts +3 -0
  67. package/node_modules/pi-antigravity/src/web-fetch/inspect.ts +328 -0
  68. package/node_modules/pi-antigravity/src/web-fetch/limits.ts +4 -0
  69. package/node_modules/pi-antigravity/src/web-fetch/markdown.ts +744 -0
  70. package/node_modules/pi-antigravity/src/web-fetch/mdn.ts +164 -0
  71. package/node_modules/pi-antigravity/src/web-fetch/media.ts +11 -0
  72. package/node_modules/pi-antigravity/src/web-fetch/metadata.ts +9 -0
  73. package/node_modules/pi-antigravity/src/web-fetch/representation.ts +93 -0
  74. package/node_modules/pi-antigravity/src/web-fetch/save.ts +71 -0
  75. package/node_modules/pi-antigravity/src/web-fetch/sites.ts +138 -0
  76. package/node_modules/pi-antigravity/src/web-fetch/vendor.d.ts +9 -0
  77. package/node_modules/pi-antigravity/src/web-fetch/web-fetch.ts +957 -0
  78. package/node_modules/pi-antigravity/tsconfig.json +2 -2
  79. package/node_modules/pi-commandcode-provider/CHANGELOG.md +10 -0
  80. package/node_modules/pi-commandcode-provider/README.md +2 -2
  81. package/node_modules/pi-commandcode-provider/package.json +1 -1
  82. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +15 -9
  83. package/node_modules/pi-commandcode-provider/src/oauth.ts +69 -12
  84. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  85. package/node_modules/pi-lens/CHANGELOG.md +172 -0
  86. package/node_modules/pi-lens/README.md +103 -217
  87. package/node_modules/pi-lens/dist/{chunk-KXDQD34C.js → chunk-27JQHK7Y.js} +1 -1
  88. package/node_modules/pi-lens/dist/{chunk-W6VLB6LL.js → chunk-2APSZHHI.js} +61 -3
  89. package/node_modules/pi-lens/dist/{chunk-5EEWCJG7.js → chunk-2H5GHZKC.js} +8 -8
  90. package/node_modules/pi-lens/dist/{chunk-TS5EIWEF.js → chunk-2H7NFZ4Q.js} +11 -11
  91. package/node_modules/pi-lens/dist/{chunk-6GWCYEP7.js → chunk-37IDWT6O.js} +64 -16
  92. package/node_modules/pi-lens/dist/{chunk-OEPWTSUG.js → chunk-3PAS2ERX.js} +8 -8
  93. package/node_modules/pi-lens/dist/{chunk-ET3DSSFZ.js → chunk-3PO4YYOX.js} +9 -17
  94. package/node_modules/pi-lens/dist/{chunk-C6V2DSZZ.js → chunk-3QXFUP6T.js} +11 -11
  95. package/node_modules/pi-lens/dist/{chunk-HWMNTQBJ.js → chunk-3TSMQZG6.js} +32 -11
  96. package/node_modules/pi-lens/dist/{chunk-QY6J2FTK.js → chunk-4DAHGU3V.js} +15 -14
  97. package/node_modules/pi-lens/dist/{chunk-PCREZ4HJ.js → chunk-4IZZEN63.js} +33 -34
  98. package/node_modules/pi-lens/dist/{chunk-OYXD2MOM.js → chunk-5HBQL7DH.js} +2 -2
  99. package/node_modules/pi-lens/dist/{chunk-B4FAFEBP.js → chunk-5JB4WENL.js} +1 -1
  100. package/node_modules/pi-lens/dist/chunk-5YJXF2IS.js +56 -0
  101. package/node_modules/pi-lens/dist/{chunk-GHATCG2A.js → chunk-6CFSDLHE.js} +22 -18
  102. package/node_modules/pi-lens/dist/{chunk-FVQKX5KI.js → chunk-6E5QLMWI.js} +24 -22
  103. package/node_modules/pi-lens/dist/{chunk-AVBEPUCD.js → chunk-6GLMMGCX.js} +2 -2
  104. package/node_modules/pi-lens/dist/{chunk-YTXFNCVN.js → chunk-74AMPWNC.js} +2 -2
  105. package/node_modules/pi-lens/dist/{chunk-K2GV34T2.js → chunk-7CLWC2UH.js} +26 -37
  106. package/node_modules/pi-lens/dist/{chunk-MOEWCPMC.js → chunk-7DPXUPRF.js} +2 -2
  107. package/node_modules/pi-lens/dist/{chunk-7BEADGAZ.js → chunk-7U36VQL6.js} +2 -2
  108. package/node_modules/pi-lens/dist/{chunk-PPYUBO6Y.js → chunk-7WKVCZI4.js} +1 -1
  109. package/node_modules/pi-lens/dist/{chunk-ILC2B7IJ.js → chunk-7ZVTFLCC.js} +10 -10
  110. package/node_modules/pi-lens/dist/{chunk-IT7MFVGP.js → chunk-ADYQRETD.js} +2 -2
  111. package/node_modules/pi-lens/dist/{chunk-NCDH2JB7.js → chunk-ARTYCUGF.js} +25 -10
  112. package/node_modules/pi-lens/dist/{chunk-Z6WTLVUL.js → chunk-AXAR5ZW2.js} +225 -104
  113. package/node_modules/pi-lens/dist/{chunk-PK3GDU4M.js → chunk-AZG5UJYY.js} +1 -1
  114. package/node_modules/pi-lens/dist/{chunk-NRVWLTOY.js → chunk-B2OXE4AH.js} +60 -21
  115. package/node_modules/pi-lens/dist/{chunk-ORYQGVC3.js → chunk-B42AIWPJ.js} +2 -2
  116. package/node_modules/pi-lens/dist/{chunk-IC4L65U7.js → chunk-BBSDJTOV.js} +12 -13
  117. package/node_modules/pi-lens/dist/{chunk-HJWF7CGW.js → chunk-BKWFDWYM.js} +16 -16
  118. package/node_modules/pi-lens/dist/{chunk-D2ZYRI7M.js → chunk-C5PLBTNR.js} +1 -1
  119. package/node_modules/pi-lens/dist/{chunk-SRXYSLMW.js → chunk-CQY2HEH7.js} +1 -1
  120. package/node_modules/pi-lens/dist/{chunk-7424ANRU.js → chunk-CXQYK4YT.js} +1 -1
  121. package/node_modules/pi-lens/dist/{chunk-HYR25MV3.js → chunk-CZJGAOKL.js} +8 -7
  122. package/node_modules/pi-lens/dist/{chunk-DIIDMDZU.js → chunk-DCA2MXVQ.js} +11 -11
  123. package/node_modules/pi-lens/dist/{chunk-K2LD6YNH.js → chunk-DFKOA74L.js} +9 -9
  124. package/node_modules/pi-lens/dist/{chunk-AYDE7RFV.js → chunk-DI4AZZNY.js} +2 -2
  125. package/node_modules/pi-lens/dist/{chunk-6EXGCXM5.js → chunk-G53LBDNU.js} +99 -5
  126. package/node_modules/pi-lens/dist/chunk-GCSDF5IE.js +27 -0
  127. package/node_modules/pi-lens/dist/{chunk-5KLRCUDT.js → chunk-H5API74E.js} +6 -6
  128. package/node_modules/pi-lens/dist/chunk-HBX55MWO.js +27 -0
  129. package/node_modules/pi-lens/dist/{chunk-JRSS6KM4.js → chunk-HIJ4CHFF.js} +2 -2
  130. package/node_modules/pi-lens/dist/{chunk-3MHY4BQY.js → chunk-HIRBC72R.js} +4 -4
  131. package/node_modules/pi-lens/dist/{chunk-F7AMFFVK.js → chunk-HRLF35WL.js} +8 -8
  132. package/node_modules/pi-lens/dist/{chunk-HSTN27NR.js → chunk-I2FYOZNW.js} +9 -9
  133. package/node_modules/pi-lens/dist/{chunk-5FDUKJZO.js → chunk-I3NZVAMN.js} +9 -9
  134. package/node_modules/pi-lens/dist/{chunk-NZINZCHB.js → chunk-INBK3HIT.js} +3 -3
  135. package/node_modules/pi-lens/dist/{chunk-PXGVB2CY.js → chunk-J2ZB5MDS.js} +20 -18
  136. package/node_modules/pi-lens/dist/{chunk-HYDJUVOE.js → chunk-JGUDT5KD.js} +4 -4
  137. package/node_modules/pi-lens/dist/chunk-JOIKBUQN.js +88 -0
  138. package/node_modules/pi-lens/dist/{chunk-AZXTLZHE.js → chunk-K4Z7MK6T.js} +169 -165
  139. package/node_modules/pi-lens/dist/{chunk-WTSQKJAR.js → chunk-K7O6AHSJ.js} +10 -10
  140. package/node_modules/pi-lens/dist/{chunk-S6ZQFPOX.js → chunk-KNJH6WJQ.js} +6 -6
  141. package/node_modules/pi-lens/dist/{chunk-SUIZOCSY.js → chunk-KNSOA43J.js} +1 -1
  142. package/node_modules/pi-lens/dist/{chunk-3QMLB4TI.js → chunk-KXGTLAUW.js} +2 -2
  143. package/node_modules/pi-lens/dist/{chunk-OHEUOWYT.js → chunk-KZ732ZVW.js} +1 -1
  144. package/node_modules/pi-lens/dist/{chunk-G3LR6V6N.js → chunk-L6BDRYUK.js} +19 -17
  145. package/node_modules/pi-lens/dist/{chunk-OVPR3GQ6.js → chunk-LGH2HHZG.js} +24 -6
  146. package/node_modules/pi-lens/dist/{chunk-3R3Z54J7.js → chunk-LOEJFTF2.js} +1 -1
  147. package/node_modules/pi-lens/dist/{chunk-HGEE5LDW.js → chunk-LQQNFCQJ.js} +1 -1
  148. package/node_modules/pi-lens/dist/chunk-LVLPA32Q.js +810 -0
  149. package/node_modules/pi-lens/dist/chunk-M2YMBT5G.js +73 -0
  150. package/node_modules/pi-lens/dist/{chunk-Z2W5YJBW.js → chunk-MJRGPEQ5.js} +11 -11
  151. package/node_modules/pi-lens/dist/{chunk-3EIZMRXI.js → chunk-MOAVEPC4.js} +10 -10
  152. package/node_modules/pi-lens/dist/{chunk-TOOXNL6M.js → chunk-NGNBJIUO.js} +7 -7
  153. package/node_modules/pi-lens/dist/{chunk-AGEQRJ5A.js → chunk-NHA5K226.js} +1 -1
  154. package/node_modules/pi-lens/dist/{chunk-YLW26OHX.js → chunk-NNEQOC3U.js} +31 -59
  155. package/node_modules/pi-lens/dist/{chunk-ZWZD4TJ5.js → chunk-O2MHF7QM.js} +35 -36
  156. package/node_modules/pi-lens/dist/{chunk-PTJXMYRY.js → chunk-OLWGYBYT.js} +15 -16
  157. package/node_modules/pi-lens/dist/{chunk-JKAVKTMY.js → chunk-OZQQ3AIR.js} +17 -20
  158. package/node_modules/pi-lens/dist/{chunk-6JLNZ6DP.js → chunk-P5MSLVUW.js} +10 -10
  159. package/node_modules/pi-lens/dist/{chunk-OF2YGDUE.js → chunk-PFJLYRO3.js} +37 -38
  160. package/node_modules/pi-lens/dist/chunk-PKWEBMCA.js +2957 -0
  161. package/node_modules/pi-lens/dist/{chunk-JLMS7EMD.js → chunk-PPQHMSPH.js} +16 -15
  162. package/node_modules/pi-lens/dist/{chunk-6EIV3H7O.js → chunk-PQF6YGYB.js} +12 -5
  163. package/node_modules/pi-lens/dist/{chunk-VU2PRGRI.js → chunk-PQXUZYTQ.js} +4 -4
  164. package/node_modules/pi-lens/dist/{chunk-MV6ST2KT.js → chunk-Q7J3JYJ2.js} +13 -12
  165. package/node_modules/pi-lens/dist/{chunk-BMMRLJA4.js → chunk-QE5DJ7MX.js} +27 -10
  166. package/node_modules/pi-lens/dist/{chunk-IZ36G463.js → chunk-QE7BJQ6K.js} +7 -7
  167. package/node_modules/pi-lens/dist/{chunk-E5SSUV2A.js → chunk-QMWKSYWB.js} +4 -4
  168. package/node_modules/pi-lens/dist/{chunk-QJ4T73J5.js → chunk-QV3JPCMK.js} +1 -1
  169. package/node_modules/pi-lens/dist/{chunk-3PMLYGJN.js → chunk-R4L7KZ7R.js} +5 -5
  170. package/node_modules/pi-lens/dist/{chunk-7ZVEFWOE.js → chunk-RIH3UBK4.js} +10 -10
  171. package/node_modules/pi-lens/dist/{chunk-T5EGSBM2.js → chunk-RJ3APNIP.js} +3 -3
  172. package/node_modules/pi-lens/dist/{chunk-AAIVSSUU.js → chunk-S6MCMD27.js} +35 -12
  173. package/node_modules/pi-lens/dist/{chunk-SF7KSXB5.js → chunk-SCU62JLX.js} +6 -6
  174. package/node_modules/pi-lens/dist/{chunk-FDLGJFAE.js → chunk-SDYLT45T.js} +3 -3
  175. package/node_modules/pi-lens/dist/chunk-TFKN5EIR.js +27 -0
  176. package/node_modules/pi-lens/dist/{chunk-Y7XMKBFP.js → chunk-TKOFTLGB.js} +34 -26
  177. package/node_modules/pi-lens/dist/chunk-TQWRH25U.js +35 -0
  178. package/node_modules/pi-lens/dist/{chunk-DZSQXG66.js → chunk-TWEOJE3D.js} +277 -62
  179. package/node_modules/pi-lens/dist/{chunk-R67WQ5RY.js → chunk-UN72ZAJ5.js} +8 -8
  180. package/node_modules/pi-lens/dist/{chunk-AD7JDEI6.js → chunk-UNP6Y4JV.js} +16 -16
  181. package/node_modules/pi-lens/dist/{chunk-D6ANA6YU.js → chunk-VGRGW4UL.js} +63 -55
  182. package/node_modules/pi-lens/dist/{chunk-DFAY7JUN.js → chunk-VSQT6IHZ.js} +2 -2
  183. package/node_modules/pi-lens/dist/{chunk-7T64QA5D.js → chunk-VWEBZ2JV.js} +39 -38
  184. package/node_modules/pi-lens/dist/{chunk-HRQTYU2T.js → chunk-W26QZ3OM.js} +1 -1
  185. package/node_modules/pi-lens/dist/{chunk-2HWVG3IM.js → chunk-XDNWR7SG.js} +2 -2
  186. package/node_modules/pi-lens/dist/{chunk-75TVYCQW.js → chunk-XSC3BCN3.js} +5 -5
  187. package/node_modules/pi-lens/dist/{chunk-ME6MF2N2.js → chunk-YCR6ZYTE.js} +1 -1
  188. package/node_modules/pi-lens/dist/{chunk-LD7SXICE.js → chunk-ZI7YHV6I.js} +5 -5
  189. package/node_modules/pi-lens/dist/{chunk-E3PNZDPH.js → chunk-ZQSSO7LO.js} +33 -1
  190. package/node_modules/pi-lens/dist/{chunk-T6PPK3T6.js → chunk-ZULZS2I6.js} +385 -407
  191. package/node_modules/pi-lens/dist/index.js +6508 -5413
  192. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +9 -9
  193. package/node_modules/pi-lens/dist/mcp/cli.js +39 -38
  194. package/node_modules/pi-lens/dist/mcp/server.js +602 -345
  195. package/node_modules/pi-lens/dist/mcp/worker.js +57 -58
  196. package/node_modules/pi-lens/dist/probes/installer.js +19 -17
  197. package/node_modules/pi-lens/docs/architecture.md +113 -0
  198. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +2 -2
  199. package/node_modules/pi-lens/docs/ci.md +18 -4
  200. package/node_modules/pi-lens/docs/defect-shapes.md +41 -3
  201. package/node_modules/pi-lens/docs/dependencies.md +10 -10
  202. package/node_modules/pi-lens/docs/features.md +3 -3
  203. package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +13 -1
  204. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +19 -0
  205. package/node_modules/pi-lens/docs/language-coverage.md +39 -0
  206. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +10 -4
  207. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +1 -1
  208. package/node_modules/pi-lens/docs/pi-lens-fixer.md +4 -0
  209. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +1 -1
  210. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +4 -5
  211. package/node_modules/pi-lens/docs/pi-lens-subagent.md +5 -2
  212. package/node_modules/pi-lens/docs/prose-standard.md +112 -0
  213. package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
  214. package/node_modules/pi-lens/docs/usage.md +50 -0
  215. package/node_modules/pi-lens/package.json +1 -1
  216. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/array-callback-return-js-test.yml +23 -0
  217. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/array-callback-return-test.yml +23 -0
  218. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-js-test.yml +8 -0
  219. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-negation-in-equality-check-test.yml +8 -0
  220. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-js-test.yml +16 -0
  221. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/unchecked-throwing-call-test.yml +16 -0
  222. package/node_modules/pi-lens/rules/ast-grep-rules/rules/array-callback-return-js.yml +8 -0
  223. package/node_modules/pi-lens/rules/ast-grep-rules/rules/array-callback-return.yml +8 -0
  224. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-negation-in-equality-check-js.yml +17 -5
  225. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-negation-in-equality-check.yml +17 -5
  226. package/node_modules/pi-lens/rules/ast-grep-rules/rules/unchecked-throwing-call-js.yml +8 -1
  227. package/node_modules/pi-lens/rules/ast-grep-rules/rules/unchecked-throwing-call.yml +8 -1
  228. package/node_modules/pi-lens/rules/tree-sitter-queries/typescript/ts-react-antipatterns.yml +8 -0
  229. package/node_modules/pi-web-access/CHANGELOG.md +29 -0
  230. package/node_modules/pi-web-access/README.md +35 -15
  231. package/node_modules/pi-web-access/anysearch.ts +7 -3
  232. package/node_modules/pi-web-access/autom.ts +196 -0
  233. package/node_modules/pi-web-access/cloro.ts +254 -0
  234. package/node_modules/pi-web-access/curator-page.ts +7 -1
  235. package/node_modules/pi-web-access/curator-server.ts +3 -0
  236. package/node_modules/pi-web-access/dist/index.js +12931 -12111
  237. package/node_modules/pi-web-access/dist/mcp-cli.js +1188 -416
  238. package/node_modules/pi-web-access/domain-filter-normalization.ts +30 -0
  239. package/node_modules/pi-web-access/duckduckgo-rate-limit.ts +144 -34
  240. package/node_modules/pi-web-access/duckduckgo.ts +11 -3
  241. package/node_modules/pi-web-access/extract.ts +60 -4
  242. package/node_modules/pi-web-access/gemini-search.ts +25 -5
  243. package/node_modules/pi-web-access/index.ts +9 -1
  244. package/node_modules/pi-web-access/package.json +2 -2
  245. package/node_modules/pi-web-access/page-query.ts +12 -3
  246. package/node_modules/pi-web-access/specstream.ts +276 -0
  247. package/node_modules/pi-web-access/tool-activation.ts +21 -6
  248. package/node_modules/pi-web-access/utils.ts +4 -0
  249. package/node_modules/pi-web-access/video-extract.ts +2 -2
  250. package/node_modules/pi-web-access/web-tool-core.ts +24 -5
  251. package/node_modules/pi-web-access/youtube-extract.ts +2 -2
  252. package/package.json +13 -7
  253. package/node_modules/pi-lens/dist/chunk-3VWEZ6H2.js +0 -72
  254. package/node_modules/pi-lens/dist/chunk-7KWI5UHL.js +0 -28
  255. package/node_modules/pi-lens/dist/chunk-7M64NTAK.js +0 -38
  256. package/node_modules/pi-lens/dist/chunk-BEIPWPVR.js +0 -1037
  257. package/node_modules/pi-lens/dist/chunk-D7OEGXDX.js +0 -2417
  258. package/node_modules/pi-lens/dist/chunk-KUDUKKQE.js +0 -89
  259. package/node_modules/pi-lens/dist/chunk-TM3A3K7T.js +0 -28
  260. package/node_modules/pi-lens/dist/chunk-VD7MQFEV.js +0 -56
  261. package/node_modules/pi-lens/dist/chunk-YLHJWAQS.js +0 -256
  262. package/node_modules/pi-lens/dist/chunk-YULIERZW.js +0 -27
@@ -1,1037 +0,0 @@
1
- import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
2
- import {
3
- getToolCommandSpec,
4
- shouldAutoInstallTool
5
- } from "./chunk-D7OEGXDX.js";
6
- import {
7
- BUILTIN_SERVER_RUNNER_COVERS,
8
- getServersForFileWithConfig,
9
- isAuxiliary,
10
- resolveAnalysisRootPath
11
- } from "./chunk-Z6WTLVUL.js";
12
- import {
13
- emitBounded
14
- } from "./chunk-5EEWCJG7.js";
15
- import {
16
- ensureTool,
17
- findManagedToolBinary,
18
- getInstallAttempt,
19
- getLastEnsureResolutionSource,
20
- getToolInstallStrategy,
21
- isSpawnableCommand,
22
- logSessionStart,
23
- resetPathWalkMemo
24
- } from "./chunk-NRVWLTOY.js";
25
- import {
26
- resolveToolCwd
27
- } from "./chunk-YLHJWAQS.js";
28
- import {
29
- findGlobalBinary,
30
- findLocalBinAt,
31
- findLocalBinUpwards,
32
- localBinPath
33
- } from "./chunk-OVPR3GQ6.js";
34
- import {
35
- createAvailabilityProbeFlight,
36
- probeToolAsync
37
- } from "./chunk-3QMLB4TI.js";
38
- import {
39
- classifyProbeFailure,
40
- createAvailabilityLatch,
41
- describeInstallAttempt,
42
- describeProbeEvidence,
43
- isLatchingOutcome,
44
- logAvailabilityDecision,
45
- startHostStallSampler
46
- } from "./chunk-AVBEPUCD.js";
47
- import {
48
- NODE_MODULES_BIN_DIRS,
49
- VENDOR_BIN_DIRS,
50
- VENV_BIN_DIRS,
51
- createGenerationSource,
52
- getGlobalPiLensDir,
53
- isInSpawnTimeoutCooldown,
54
- resolveWindowsCommandForEnvironment,
55
- safeSpawnAsync
56
- } from "./chunk-ET3DSSFZ.js";
57
- import {
58
- PathKeyedMap
59
- } from "./chunk-6EIV3H7O.js";
60
- import {
61
- getProjectTrustState
62
- } from "./chunk-HRQTYU2T.js";
63
- import {
64
- compareOrdinal,
65
- incrementDegradationCount
66
- } from "./chunk-AGEQRJ5A.js";
67
- import {
68
- isUnderDir,
69
- normalizeEphemeralMapKey,
70
- normalizeMapKey
71
- } from "./chunk-WLD6BGON.js";
72
-
73
- // dist/clients/dispatch/runners/utils/runner-helpers.js
74
- import * as fs from "node:fs";
75
- import * as path from "node:path";
76
- import { delimiter, resolve as resolveCommandPath } from "node:path";
77
- function lspPrimaryCoversFile(ctx, runnerId) {
78
- if (ctx.pi?.getFlag?.("no-lsp"))
79
- return void 0;
80
- const primary = getServersForFileWithConfig(ctx.filePath).find((s) => !isAuxiliary(s));
81
- if (!primary)
82
- return void 0;
83
- const fact = primary.custom ? void 0 : BUILTIN_SERVER_RUNNER_COVERS.get(primary.id);
84
- const covers = primary.covers ?? fact?.runnerIds;
85
- if (!covers?.includes(runnerId))
86
- return void 0;
87
- const gateCommands = fact ? fact.gateCommands : primary.custom ? primary.command ? [primary.command] : void 0 : [];
88
- if (gateCommands === void 0)
89
- return void 0;
90
- return {
91
- serverId: primary.id,
92
- gateCommands,
93
- claimSource: fact ? "builtin-fact" : "declared"
94
- };
95
- }
96
- async function coveringLaneAvailable(ctx, cover) {
97
- for (const gate of cover.gateCommands) {
98
- if (!await ctx.hasTool(gate))
99
- return false;
100
- }
101
- return true;
102
- }
103
- function managedNodeToolCandidates(tool) {
104
- const base = path.join(getGlobalPiLensDir(), "tools", "node_modules", ".bin", tool);
105
- return process.platform === "win32" ? [`${base}.cmd`, `${base}.exe`, base] : [base];
106
- }
107
- var managedBinaryVerdicts = /* @__PURE__ */ new Map();
108
- var managedVerifyInFlight = /* @__PURE__ */ new Map();
109
- var MANAGED_VERIFY_TIMEOUT_MS = 5e3;
110
- var MANAGED_VERIFY_COOLDOWN_MS = 6e4;
111
- var MANAGED_VERIFY_COOLDOWN_MAX_MS = 15 * 6e4;
112
- function managedVerifyCooldownMs(attempts) {
113
- return Math.min(MANAGED_VERIFY_COOLDOWN_MAX_MS, MANAGED_VERIFY_COOLDOWN_MS * 2 ** (attempts - 1));
114
- }
115
- async function runManagedVerification(candidate, stamp, priorAttempts, generation, verificationArgs = ["--version"]) {
116
- let transient = false;
117
- let ok;
118
- try {
119
- const { verifyToolBinary } = await import("./probes/installer.js");
120
- ok = await verifyToolBinary(candidate, void 0, () => {
121
- transient = true;
122
- }, MANAGED_VERIFY_TIMEOUT_MS, verificationArgs);
123
- } catch {
124
- transient = true;
125
- ok = false;
126
- }
127
- if (!ok && transient) {
128
- const attempts = priorAttempts + 1;
129
- generation.guardedWrite(stamp, () => {
130
- managedBinaryVerdicts.set(stamp, {
131
- verdict: "unverified",
132
- attempts,
133
- retryAtMs: Date.now() + managedVerifyCooldownMs(attempts)
134
- });
135
- });
136
- return "unverified";
137
- }
138
- generation.guardedWrite(stamp, () => {
139
- managedBinaryVerdicts.set(stamp, { verdict: ok ? "ok" : "broken" });
140
- });
141
- if (!ok) {
142
- logSessionStart(`dispatch availability: managed shim ${candidate} exists but does not run; falling through to PATH`);
143
- }
144
- return ok ? "ok" : "broken";
145
- }
146
- async function verifyManagedCandidate(candidate, verificationArgs = ["--version"]) {
147
- let stamp;
148
- try {
149
- const stat = fs.statSync(candidate);
150
- stamp = `${candidate}:${stat.mtimeMs}:${stat.size}`;
151
- } catch {
152
- return "absent";
153
- }
154
- const memo = managedBinaryVerdicts.get(stamp);
155
- let priorAttempts = 0;
156
- if (memo) {
157
- if (memo.verdict !== "unverified")
158
- return memo.verdict;
159
- if (Date.now() < memo.retryAtMs)
160
- return "unverified";
161
- priorAttempts = memo.attempts;
162
- }
163
- const existing = managedVerifyInFlight.get(stamp);
164
- if (existing)
165
- return existing;
166
- const generation = availabilityGeneration.capture();
167
- const probe = runManagedVerification(candidate, stamp, priorAttempts, generation, verificationArgs).finally(() => {
168
- generation.guardedWrite(stamp, () => {
169
- if (managedVerifyInFlight.get(stamp) === probe) {
170
- managedVerifyInFlight.delete(stamp);
171
- }
172
- });
173
- });
174
- managedVerifyInFlight.set(stamp, probe);
175
- return probe;
176
- }
177
- async function findManagedNodeToolBinary(tool, verificationArgs = ["--version"]) {
178
- for (const candidate of managedNodeToolCandidates(tool)) {
179
- const verdict = await verifyManagedCandidate(candidate, verificationArgs);
180
- if (verdict === "ok" || verdict === "unverified")
181
- return candidate;
182
- }
183
- return null;
184
- }
185
- async function findManagedReleaseBinary(tool, verificationArgs = ["--version"]) {
186
- const candidate = await findManagedToolBinary(tool);
187
- if (!candidate)
188
- return null;
189
- const verdict = await verifyManagedCandidate(candidate, verificationArgs);
190
- return verdict === "ok" || verdict === "unverified" ? candidate : null;
191
- }
192
- function resolveAdoptedRootCommand(command, ctx, cwd) {
193
- const candidates = managedNodeToolCandidates(command);
194
- let selected = candidates.find((candidate) => candidate && fs.existsSync(candidate));
195
- if (!selected) {
196
- if (process.platform === "win32") {
197
- selected = resolveWindowsCommandForEnvironment(command, cwd, process.env)?.resolvedPath;
198
- } else {
199
- selected = (process.env.PATH ?? "").split(delimiter).map((dir) => resolveCommandPath(cwd, dir, command)).find((candidate) => {
200
- try {
201
- fs.accessSync(candidate, fs.constants.X_OK);
202
- return fs.statSync(candidate).isFile();
203
- } catch {
204
- return false;
205
- }
206
- });
207
- }
208
- }
209
- if (!selected)
210
- return null;
211
- try {
212
- const binary = fs.realpathSync.native(selected);
213
- const session = ctx.projectRoot ?? ctx.cwd;
214
- const adopted = resolveAnalysisRootPath(ctx.filePath, session);
215
- if (!adopted)
216
- return null;
217
- const roots = [adopted, session].map((root) => fs.realpathSync.native(root));
218
- if (roots.some((root) => binary === root || isUnderDir(binary, root) || isUnderDir(selected, root))) {
219
- emitBounded("adopted_root_binary_refused", `${ctx.filePath}:${command}:${binary}`, {
220
- filePath: ctx.filePath,
221
- durationMs: 0,
222
- metadata: { command, binary }
223
- }, {
224
- ledgerKind: "adopted-root-binary-refused",
225
- risingEdgePer: "identity"
226
- });
227
- return null;
228
- }
229
- return binary;
230
- } catch {
231
- return null;
232
- }
233
- }
234
- function createVenvFinder(command, windowsExt = "", verificationArgs = ["--version"], allowProjectLocal = true, projectBinDirs = VENV_BIN_DIRS) {
235
- return async (cwd) => {
236
- if (allowProjectLocal) {
237
- const venvBin = localBinPath(findLocalBinAt(command, cwd, {
238
- windowsExt,
239
- binDirs: projectBinDirs
240
- }));
241
- if (venvBin)
242
- return { path: venvBin, rung: "venv" };
243
- }
244
- const managed = await findManagedNodeToolBinary(command, verificationArgs);
245
- if (managed)
246
- return { path: managed, rung: "managed-dir" };
247
- const release = await findManagedReleaseBinary(command, verificationArgs);
248
- if (release)
249
- return { path: release, rung: "managed-release" };
250
- return { path: command, rung: "path" };
251
- };
252
- }
253
- async function resolveManagedToolClient(options) {
254
- const probed = await options.probe();
255
- if (probed.outcome !== "missing")
256
- return probed;
257
- if (!shouldAutoInstallTool(options.toolId))
258
- return probed;
259
- const state = installStateFor(options.cwd, options.toolId);
260
- if (state.suppressed)
261
- return probed;
262
- const installed = await ensureTool(options.toolId);
263
- if (!installed) {
264
- noteInstallFailure(options.toolId, options.cwd);
265
- return probed;
266
- }
267
- const value = await options.acceptInstalled(installed);
268
- if (value === null) {
269
- noteInstallFailure(options.toolId, options.cwd);
270
- return { outcome: "non-installable" };
271
- }
272
- noteInstallSuccess(options.toolId, options.cwd);
273
- return { outcome: "success", value };
274
- }
275
- async function getManagedToolEnvironment(_toolId, cwd) {
276
- let env;
277
- try {
278
- const { getToolEnvironment } = await import("./probes/installer.js");
279
- env = await getToolEnvironment();
280
- } catch {
281
- env = { ...process.env };
282
- }
283
- if (!cwd)
284
- return env;
285
- if (getProjectTrustState() !== "trusted")
286
- return env;
287
- const separator = process.platform === "win32" ? ";" : ":";
288
- const currentPath = env.PATH || env.Path || process.env.PATH || "";
289
- const localBin = path.join(cwd, "node_modules", ".bin");
290
- const augmentedPath = `${localBin}${separator}${currentPath}`;
291
- return {
292
- ...env,
293
- PATH: augmentedPath,
294
- ...process.platform === "win32" ? { Path: augmentedPath } : {}
295
- };
296
- }
297
- async function discoverManagedTool(toolId) {
298
- return await ensureTool(toolId, { allowInstall: false }) ?? null;
299
- }
300
- var installAttemptsByCwd = new PathKeyedMap(normalizeMapKey);
301
- var resolveInstallInFlightByCwd = new PathKeyedMap(normalizeEphemeralMapKey);
302
- var correctedAvailabilityByCwd = new PathKeyedMap(normalizeMapKey);
303
- var uncorrectedEmissionsByCwd = new PathKeyedMap(normalizeMapKey);
304
- var latchedUnavailableByCwd = new PathKeyedMap(normalizeMapKey);
305
- var availabilityGeneration = createGenerationSource("dispatch-availability");
306
- var getDispatchAvailabilityGeneration = () => availabilityGeneration.current();
307
- var checkerProbeFlights = createAvailabilityProbeFlight({ generation: getDispatchAvailabilityGeneration });
308
- function recordAvailabilityProbeOverrun(tool, key, elapsedMs, budgetMs, failure) {
309
- if (budgetMs === void 0 || elapsedMs <= budgetMs)
310
- return;
311
- if (failure === "timeout" && elapsedMs <= budgetMs * 2)
312
- return;
313
- incrementDegradationCount({
314
- kind: "availability-probe-overrun",
315
- subject: `${tool}:${key}`,
316
- reason: `probe took ${Math.round(elapsedMs)}ms; budget was ${Math.round(budgetMs)}ms`
317
- });
318
- }
319
- function installStateFor(cwd, toolId) {
320
- let states = installAttemptsByCwd.get(cwd);
321
- if (!states) {
322
- states = /* @__PURE__ */ new Map();
323
- installAttemptsByCwd.set(cwd, states);
324
- }
325
- let state = states.get(toolId);
326
- if (!state) {
327
- state = { attempts: 0, suppressed: false };
328
- states.set(toolId, state);
329
- }
330
- return state;
331
- }
332
- function noteInstallFailure(toolId, cwd) {
333
- const state = installStateFor(cwd, toolId);
334
- state.attempts += 1;
335
- state.suppressed = true;
336
- logSessionStart(`dispatch availability ${toolId}: install attempt ${state.attempts} failed; suppressing retries until the next session or a successful install`);
337
- }
338
- function noteInstallSuccess(toolId, cwd) {
339
- const states = installAttemptsByCwd.get(cwd);
340
- states?.delete(toolId);
341
- if (states?.size === 0)
342
- installAttemptsByCwd.delete(cwd);
343
- }
344
- function hasId(map, cwd, id) {
345
- return map.get(cwd)?.has(id) ?? false;
346
- }
347
- function addId(map, cwd, id) {
348
- let ids = map.get(cwd);
349
- if (!ids) {
350
- ids = /* @__PURE__ */ new Set();
351
- map.set(cwd, ids);
352
- }
353
- ids.add(id);
354
- }
355
- function deleteIds(map, cwd, ids) {
356
- const existing = map.get(cwd);
357
- if (!existing)
358
- return;
359
- for (const id of ids)
360
- existing.delete(id);
361
- if (existing.size === 0)
362
- map.delete(cwd);
363
- }
364
- function hasCorrectedAvailability(cwd, toolId) {
365
- return hasId(correctedAvailabilityByCwd, cwd, toolId);
366
- }
367
- function noteAvailabilityCorrected(cwd, toolId) {
368
- addId(correctedAvailabilityByCwd, cwd, toolId);
369
- }
370
- function noteLatchedUnavailable(cwd, tool) {
371
- addId(latchedUnavailableByCwd, cwd, tool);
372
- }
373
- function clearLatchedUnavailable(cwd, ...tools) {
374
- deleteIds(latchedUnavailableByCwd, cwd, tools);
375
- }
376
- function latchKeysFor(toolId, command) {
377
- const keys = [toolId];
378
- if (command)
379
- keys.push(command, path.basename(command));
380
- return keys;
381
- }
382
- function hasLatchedUnavailable(cwd, tools) {
383
- return tools.some((tool) => hasId(latchedUnavailableByCwd, cwd, tool));
384
- }
385
- function sourceTagForToolId(toolId) {
386
- switch (getToolInstallStrategy(toolId)) {
387
- case "npm":
388
- return "managed-dir";
389
- case "pip":
390
- return "pip-user";
391
- case "github":
392
- return "github-release";
393
- case "archive":
394
- return "archive-dist";
395
- case "maven":
396
- return "maven-jar";
397
- case "gem":
398
- case void 0:
399
- default:
400
- return void 0;
401
- }
402
- }
403
- function describeManagedResolution(tool, resolution) {
404
- if (resolution.rung !== "managed-dir" && resolution.rung !== "managed-release") {
405
- return {};
406
- }
407
- const source = sourceTagForToolId(tool);
408
- return {
409
- binary: path.basename(resolution.path),
410
- ...source !== void 0 && { source }
411
- };
412
- }
413
- function resolvedTagForAttempt(toolId, attempt) {
414
- if (attempt?.outcome === "declined" || attempt?.outcome === "skipped") {
415
- return "declined";
416
- }
417
- return getLastEnsureResolutionSource(toolId) === "path" ? "path" : "cache";
418
- }
419
- function emitCompensatingAvailableRow(cwd, toolId, installStartedAt, installedPath, latchKeys) {
420
- if (hasCorrectedAvailability(cwd, toolId))
421
- return;
422
- const correctsLatchedRow = hasLatchedUnavailable(cwd, latchKeys);
423
- if (correctsLatchedRow) {
424
- noteAvailabilityCorrected(cwd, toolId);
425
- clearLatchedUnavailable(cwd, ...latchKeys);
426
- } else {
427
- if (hasId(uncorrectedEmissionsByCwd, cwd, toolId))
428
- return;
429
- addId(uncorrectedEmissionsByCwd, cwd, toolId);
430
- }
431
- const attempt = getInstallAttempt(toolId);
432
- const installEvidence = describeInstallAttempt(attempt);
433
- const evidence = {
434
- ...installEvidence,
435
- binary: path.basename(installedPath),
436
- source: sourceTagForToolId(toolId),
437
- // Set alongside any non-"succeeded" outcome: the path is truthy but
438
- // nothing ran this call, so it came from an already-known-good answer
439
- // rather than a fresh attempt (#1612 review F2).
440
- ...installEvidence.install !== "succeeded" && {
441
- resolved: resolvedTagForAttempt(toolId, attempt)
442
- },
443
- // The whole point of the memo split, on the record: a reader can tell a
444
- // row that cleared a latched `unavailable` from one that corrected
445
- // nothing, without re-deriving it from the surrounding rows (#1674
446
- // review F4).
447
- correctsLatchedRow
448
- };
449
- logAvailabilityDecision({
450
- tool: toolId,
451
- verdict: "available",
452
- outcome: "success",
453
- cause: "ok",
454
- elapsedMs: Date.now() - installStartedAt,
455
- // `checker.reset()`/a fresh probe just cleared whatever cache stood
456
- // behind this call, so nothing is actually held pinned the instant
457
- // this row is written — the very next probe starts fresh
458
- // (#1612 review F3). Writing `true` here would claim a durability
459
- // this call doesn't have.
460
- latched: false,
461
- classifiedBy: "caller",
462
- evidence
463
- }, cwd);
464
- }
465
- function resetDispatchAvailabilityState() {
466
- installAttemptsByCwd.clear();
467
- resolveInstallInFlightByCwd.clear();
468
- correctedAvailabilityByCwd.clear();
469
- uncorrectedEmissionsByCwd.clear();
470
- latchedUnavailableByCwd.clear();
471
- managedBinaryVerdicts.clear();
472
- managedVerifyInFlight.clear();
473
- resetPathWalkMemo();
474
- availabilityGeneration.bump();
475
- checkerProbeFlights.clear();
476
- cwdProbeFlights.clear();
477
- }
478
- function createAvailabilityChecker(command, windowsExt = "", versionArgs = ["--version"], options = {}) {
479
- const cacheByCwd = new PathKeyedMap(normalizeEphemeralMapKey);
480
- const inFlightByCwd = new PathKeyedMap(normalizeEphemeralMapKey);
481
- let checkerGeneration = availabilityGeneration.current();
482
- let checkerFlightGeneration = 0;
483
- const findCommand = options.pathOnly ? async () => ({ path: command, rung: "path" }) : createVenvFinder(command, windowsExt, versionArgs, options.allowProjectLocal !== false, options.projectBinDirs);
484
- const findBeyondProject = createVenvFinder(command, windowsExt, versionArgs, false);
485
- function ensureCurrentGeneration() {
486
- if (checkerGeneration === availabilityGeneration.current())
487
- return;
488
- cacheByCwd.clear();
489
- inFlightByCwd.clear();
490
- checkerGeneration = availabilityGeneration.current();
491
- checkerFlightGeneration++;
492
- }
493
- const reset = () => {
494
- cacheByCwd.clear();
495
- inFlightByCwd.clear();
496
- checkerGeneration = availabilityGeneration.current();
497
- checkerFlightGeneration++;
498
- };
499
- function getCache(cwd) {
500
- ensureCurrentGeneration();
501
- const key = path.resolve(cwd || process.cwd());
502
- const existing = cacheByCwd.get(key);
503
- if (existing)
504
- return existing;
505
- const created = {
506
- latch: createAvailabilityLatch(),
507
- command: null,
508
- elapsedMs: 0
509
- };
510
- cacheByCwd.set(key, created);
511
- return created;
512
- }
513
- function noteDecision(cache, resolvedCwd, verdict) {
514
- cache.elapsedMs = verdict.elapsedMs;
515
- let retryAfterMs;
516
- if (verdict.available) {
517
- cache.latch.noteAvailable(verdict.cause);
518
- } else {
519
- cache.command = null;
520
- const delay = cache.latch.noteUnavailable(verdict.outcome, verdict.cause);
521
- if (delay > 0)
522
- retryAfterMs = delay;
523
- }
524
- const latched = verdict.available || isLatchingOutcome(verdict.outcome);
525
- if (!verdict.available && latched) {
526
- noteLatchedUnavailable(resolvedCwd, command);
527
- } else if (verdict.available) {
528
- clearLatchedUnavailable(resolvedCwd, ...latchKeysFor(command));
529
- }
530
- logAvailabilityDecision({
531
- tool: command,
532
- verdict: verdict.available ? "available" : "unavailable",
533
- outcome: verdict.outcome,
534
- cause: verdict.cause,
535
- elapsedMs: verdict.elapsedMs,
536
- latched,
537
- // Every caller passes this (#2209); a direct key, not a conditional
538
- // spread, keeps it visible to the call-shaped classifiedBy sweep.
539
- classifiedBy: verdict.classifiedBy,
540
- ...verdict.evidence !== void 0 && { evidence: verdict.evidence },
541
- ...verdict.hostStallMs !== void 0 && {
542
- hostStallMs: verdict.hostStallMs
543
- },
544
- ...retryAfterMs !== void 0 && { retryAfterMs },
545
- budgetMs: options.probeTimeout ?? 5e3
546
- }, resolvedCwd);
547
- }
548
- async function isAvailableAsync(cwd) {
549
- ensureCurrentGeneration();
550
- const resolvedCwd = cwd || process.cwd();
551
- const cache = getCache(resolvedCwd);
552
- const answer = cache.latch.read();
553
- if (answer === false)
554
- return false;
555
- if (answer === true) {
556
- if (cache.command && await isSpawnableCommand(cache.command)) {
557
- return true;
558
- }
559
- cache.latch.reset();
560
- cache.command = null;
561
- }
562
- const key = path.resolve(resolvedCwd);
563
- const existing = inFlightByCwd.get(key);
564
- if (existing)
565
- return existing;
566
- const promiseGeneration = checkerGeneration;
567
- let promise;
568
- promise = (async () => {
569
- const fastPath = await options.fastPath?.();
570
- if (fastPath) {
571
- cache.command = fastPath;
572
- noteDecision(cache, resolvedCwd, {
573
- available: true,
574
- outcome: "success",
575
- cause: "fast-path",
576
- elapsedMs: 0,
577
- // Caller-asserted, and justifiably: an on-disk shim IS the tool, so
578
- // there is no spawn to derive anything from (#1500).
579
- classifiedBy: "caller"
580
- });
581
- return true;
582
- }
583
- try {
584
- const cwdStat = await fs.promises.stat(resolvedCwd);
585
- if (!cwdStat.isDirectory()) {
586
- noteDecision(cache, resolvedCwd, {
587
- available: false,
588
- outcome: "non-installable",
589
- cause: "bad-cwd",
590
- elapsedMs: 0,
591
- // The workspace is gone. Asserted from a stat, not a probe, and it
592
- // must never read as "the tool is missing" (#1500).
593
- classifiedBy: "caller"
594
- });
595
- return false;
596
- }
597
- } catch {
598
- noteDecision(cache, resolvedCwd, {
599
- available: false,
600
- outcome: "non-installable",
601
- cause: "bad-cwd",
602
- elapsedMs: 0,
603
- classifiedBy: "caller"
604
- });
605
- return false;
606
- }
607
- const resolveStartedAt = Date.now();
608
- let resolution = await findCommand(resolvedCwd);
609
- let resolveMs = Date.now() - resolveStartedAt;
610
- for (; ; ) {
611
- const cmd = resolution.path;
612
- if (isInSpawnTimeoutCooldown(cmd)) {
613
- noteDecision(cache, resolvedCwd, {
614
- available: false,
615
- outcome: "transient",
616
- cause: "probe-timeout",
617
- elapsedMs: 0,
618
- classifiedBy: "caller",
619
- evidence: {
620
- command: cmd,
621
- status: null
622
- }
623
- });
624
- return false;
625
- }
626
- const env = await options.environment?.(resolvedCwd);
627
- const stallSampler = startHostStallSampler();
628
- const startedAt = Date.now();
629
- let result;
630
- let hostStallMs;
631
- let probeJoined = false;
632
- try {
633
- const shared = checkerProbeFlights.run(`checker:${command}|${versionArgs.join("|")}|${key}|${checkerFlightGeneration}|${windowsExt}|${cmd}|${JSON.stringify(Object.entries(env ?? {}).sort(([a], [b]) => compareOrdinal(a, b)))}`, () => (
634
- // A bare PATH-only probe goes through the cwd-less probe seam
635
- // (#2894): nothing it answers is read out of a project.
636
- options.pathOnly ? probeToolAsync(cmd, versionArgs, {
637
- timeout: options.probeTimeout ?? 5e3,
638
- ...env !== void 0 && { env },
639
- input: ""
640
- }) : safeSpawnAsync(cmd, versionArgs, {
641
- timeout: options.probeTimeout ?? 5e3,
642
- cwd: resolvedCwd,
643
- env,
644
- input: ""
645
- })
646
- ));
647
- probeJoined = shared.joined;
648
- result = await shared.promise;
649
- } finally {
650
- hostStallMs = stallSampler.stop();
651
- }
652
- const elapsedMs = Date.now() - startedAt;
653
- recordAvailabilityProbeOverrun(command, resolvedCwd, elapsedMs, options.probeTimeout ?? 5e3, result.failure);
654
- if (!result.error && result.status === 0) {
655
- cache.command = cmd;
656
- noteDecision(cache, resolvedCwd, {
657
- available: true,
658
- outcome: "success",
659
- cause: "ok",
660
- elapsedMs,
661
- hostStallMs,
662
- classifiedBy: probeJoined ? "joined" : "probe",
663
- evidence: {
664
- ...describeProbeEvidence(result),
665
- ...describeManagedResolution(command, resolution),
666
- resolveMs
667
- }
668
- });
669
- return true;
670
- }
671
- const { outcome, cause, evidence } = classifyProbeFailure(result, {
672
- hostStallMs,
673
- unclassifiedFailureOutcome: options.unclassifiedFailureOutcome
674
- });
675
- if (resolution.rung === "venv" && isLatchingOutcome(outcome)) {
676
- const fallStartedAt = Date.now();
677
- resolution = await findBeyondProject(resolvedCwd);
678
- resolveMs += Date.now() - fallStartedAt;
679
- continue;
680
- }
681
- if (result.spawnFailure?.kind === "tool-not-found")
682
- resetPathWalkMemo();
683
- noteDecision(cache, resolvedCwd, {
684
- available: false,
685
- outcome,
686
- cause,
687
- elapsedMs,
688
- hostStallMs,
689
- classifiedBy: probeJoined ? "joined" : "probe",
690
- evidence
691
- });
692
- return false;
693
- }
694
- })().finally(() => {
695
- if (checkerGeneration === promiseGeneration && inFlightByCwd.get(key) === promise) {
696
- inFlightByCwd.delete(key);
697
- }
698
- });
699
- inFlightByCwd.set(key, promise);
700
- return promise;
701
- }
702
- function getCommand(cwd) {
703
- ensureCurrentGeneration();
704
- const cache = getCache(cwd || process.cwd());
705
- return cache.command;
706
- }
707
- function getOutcome(cwd) {
708
- ensureCurrentGeneration();
709
- return getCache(cwd || process.cwd()).latch.getOutcome();
710
- }
711
- function getVerdict(cwd) {
712
- ensureCurrentGeneration();
713
- const { latch, elapsedMs } = getCache(cwd || process.cwd());
714
- const outcome = latch.getOutcome();
715
- return {
716
- outcome,
717
- cause: latch.getCause(),
718
- elapsedMs,
719
- latched: outcome === null || isLatchingOutcome(outcome),
720
- retryAtMs: latch.getRetryAtMs()
721
- };
722
- }
723
- return { isAvailableAsync, getCommand, getOutcome, getVerdict, reset };
724
- }
725
- var cwdProbeFlights = createAvailabilityProbeFlight({
726
- generation: getDispatchAvailabilityGeneration
727
- });
728
- function createCwdCachedProbe(probe, options) {
729
- const latchByCwd = new PathKeyedMap(normalizeEphemeralMapKey);
730
- const inFlightByCwd = new PathKeyedMap(normalizeEphemeralMapKey);
731
- let probeGeneration = availabilityGeneration.current();
732
- function clear() {
733
- latchByCwd.clear();
734
- inFlightByCwd.clear();
735
- }
736
- function ensureCurrentGeneration() {
737
- if (probeGeneration === availabilityGeneration.current())
738
- return;
739
- clear();
740
- probeGeneration = availabilityGeneration.current();
741
- }
742
- function latchFor(key) {
743
- const existing = latchByCwd.get(key);
744
- if (existing)
745
- return existing;
746
- const created = createAvailabilityLatch();
747
- latchByCwd.set(key, created);
748
- return created;
749
- }
750
- function note(latch, key, verdict) {
751
- let retryAfterMs;
752
- if (verdict.available) {
753
- latch.noteAvailable(verdict.cause);
754
- } else {
755
- const delay = latch.noteUnavailable(verdict.outcome, verdict.cause);
756
- if (delay > 0)
757
- retryAfterMs = delay;
758
- }
759
- const latched = verdict.available || isLatchingOutcome(verdict.outcome);
760
- if (!verdict.available && latched) {
761
- noteLatchedUnavailable(key, options.tool);
762
- } else if (verdict.available) {
763
- clearLatchedUnavailable(key, ...latchKeysFor(options.tool));
764
- }
765
- logAvailabilityDecision({
766
- tool: options.tool,
767
- verdict: verdict.available ? "available" : "unavailable",
768
- outcome: verdict.outcome,
769
- cause: verdict.cause,
770
- elapsedMs: verdict.elapsedMs,
771
- latched,
772
- hostStallMs: verdict.hostStallMs,
773
- ...retryAfterMs !== void 0 && { retryAfterMs },
774
- ...options.budgetMs !== void 0 && { budgetMs: options.budgetMs },
775
- // Every verdict here is derived from the probe this seam just ran.
776
- classifiedBy: verdict.classifiedBy ?? "probe",
777
- ...verdict.evidence !== void 0 && { evidence: verdict.evidence }
778
- }, key);
779
- }
780
- const run = (cwd) => {
781
- ensureCurrentGeneration();
782
- const key = path.resolve(cwd || process.cwd());
783
- const latch = latchFor(key);
784
- const memo = latch.read();
785
- if (memo !== null)
786
- return Promise.resolve(memo);
787
- const existing = inFlightByCwd.get(key);
788
- if (existing)
789
- return existing;
790
- const promiseGeneration = probeGeneration;
791
- let promise;
792
- promise = (async () => {
793
- const stallSampler = startHostStallSampler();
794
- const startedAt = Date.now();
795
- let result;
796
- let thrown;
797
- let probeJoined = false;
798
- try {
799
- const shared = cwdProbeFlights.run(`cwd:${options.tool}|${options.flightKeyComponent ?? ""}|${key}`, () => probe(key));
800
- probeJoined = shared.joined;
801
- result = await shared.promise;
802
- } catch (error) {
803
- thrown = error;
804
- }
805
- const hostStallMs = stallSampler.stop();
806
- const elapsedMs = Date.now() - startedAt;
807
- const shape = result ?? {
808
- error: thrown instanceof Error ? thrown : new Error(String(thrown))
809
- };
810
- recordAvailabilityProbeOverrun(options.tool, key, elapsedMs, options.budgetMs, shape.failure);
811
- if (result && !result.error && result.status === 0) {
812
- note(latch, key, {
813
- available: true,
814
- outcome: "success",
815
- cause: "ok",
816
- elapsedMs,
817
- hostStallMs,
818
- classifiedBy: probeJoined ? "joined" : "probe",
819
- evidence: describeProbeEvidence(result, options.tool)
820
- });
821
- return true;
822
- }
823
- const { outcome, cause, evidence } = classifyProbeFailure(shape, {
824
- hostStallMs,
825
- command: options.tool,
826
- unclassifiedFailureOutcome: options.unclassifiedFailureOutcome
827
- });
828
- note(latch, key, {
829
- available: false,
830
- outcome,
831
- cause,
832
- elapsedMs,
833
- hostStallMs,
834
- classifiedBy: probeJoined ? "joined" : "probe",
835
- evidence
836
- });
837
- return false;
838
- })().finally(() => {
839
- if (probeGeneration === promiseGeneration && inFlightByCwd.get(key) === promise) {
840
- inFlightByCwd.delete(key);
841
- }
842
- });
843
- inFlightByCwd.set(key, promise);
844
- return promise;
845
- };
846
- const cached = run;
847
- cached.getVerdict = (cwd) => {
848
- ensureCurrentGeneration();
849
- const latch = latchFor(path.resolve(cwd || process.cwd()));
850
- const outcome = latch.getOutcome();
851
- return {
852
- outcome,
853
- cause: latch.getCause(),
854
- elapsedMs: 0,
855
- // Read the OUTCOME, never `read()`: `read()` answers `null` both for a
856
- // cwd that was never probed and for a transient verdict whose cooldown
857
- // expired, and `!== false` turned both of those into `latched: true` —
858
- // the opposite of the truth in the expired case.
859
- latched: outcome !== null && isLatchingOutcome(outcome),
860
- retryAtMs: latch.getRetryAtMs()
861
- };
862
- };
863
- cached.reset = () => {
864
- clear();
865
- probeGeneration = availabilityGeneration.current();
866
- };
867
- return cached;
868
- }
869
- function resolveNodeToolCommand(cwd, toolName, windowsExt = ".cmd") {
870
- const local = localBinPath(findLocalBinAt(toolName, cwd, { windowsExt }));
871
- if (local)
872
- return local;
873
- return toolName;
874
- }
875
- function resolveToolCommand(cwd, toolId) {
876
- const spec = getToolCommandSpec(toolId);
877
- if (!spec)
878
- return null;
879
- return resolveNodeToolCommand(cwd, spec.command, spec.windowsExt ?? ".cmd");
880
- }
881
- function resolveVendorToolCommand(cwd, toolName, windowsExt = ".bat") {
882
- return localBinPath(findLocalBinUpwards(toolName, cwd, {
883
- windowsExt,
884
- binDirs: VENDOR_BIN_DIRS
885
- })) ?? null;
886
- }
887
- var toolBinaryCheckers = /* @__PURE__ */ new Map();
888
- function toolBinaryChecker(toolId) {
889
- const existing = toolBinaryCheckers.get(toolId);
890
- if (existing)
891
- return existing;
892
- const spec = getToolCommandSpec(toolId);
893
- if (!spec)
894
- return null;
895
- const checker = createAvailabilityChecker(spec.command, spec.windowsExt ?? "", spec.versionArgs ?? ["--version"], { projectBinDirs: [...VENV_BIN_DIRS, ...NODE_MODULES_BIN_DIRS] });
896
- toolBinaryCheckers.set(toolId, checker);
897
- return checker;
898
- }
899
- async function resolveToolCommandWithInstallFallback(cwd, toolId) {
900
- const checker = toolBinaryChecker(toolId);
901
- if (!checker)
902
- return null;
903
- return resolveAvailableOrInstall(checker, getToolCommandSpec(toolId)?.managedToolId ?? toolId, cwd);
904
- }
905
- async function verifyOrInstallCommand(command, toolId, cwd, versionArgs = ["--version"], timeout = 5e3) {
906
- const spawnable = await isSpawnableCommand(command);
907
- if (spawnable) {
908
- const versionCheck = await safeSpawnAsync(command, versionArgs, {
909
- timeout,
910
- cwd,
911
- input: "",
912
- cooldown: false
913
- });
914
- if (!versionCheck.error && versionCheck.status === 0) {
915
- return command;
916
- }
917
- return null;
918
- }
919
- if (!shouldAutoInstallTool(toolId))
920
- return null;
921
- const state = installStateFor(cwd, toolId);
922
- if (state.suppressed)
923
- return null;
924
- const installStartedAt = Date.now();
925
- const installed = await ensureTool(toolId);
926
- if (installed) {
927
- noteInstallSuccess(toolId, cwd);
928
- emitCompensatingAvailableRow(cwd, toolId, installStartedAt, installed, latchKeysFor(toolId, command));
929
- return installed;
930
- }
931
- noteInstallFailure(toolId, cwd);
932
- return null;
933
- }
934
- async function resolveCommandArgsWithInstallFallback(command, toolId, cwd, versionArgs = ["--version"], timeout = 5e3) {
935
- const versionCheck = await safeSpawnAsync(command.cmd, [...command.args, ...versionArgs], { timeout, cwd, input: "", cooldown: false });
936
- if (!versionCheck.error && versionCheck.status === 0) {
937
- return command;
938
- }
939
- const installed = await verifyOrInstallCommand(command.cmd, toolId, cwd, versionArgs, timeout);
940
- if (!installed) {
941
- return null;
942
- }
943
- if (installed === command.cmd) {
944
- return command;
945
- }
946
- return { cmd: installed, args: [] };
947
- }
948
- async function resolveAvailableOrInstallUnshared(checker, toolId, cwd) {
949
- const available = await checker.isAvailableAsync(cwd);
950
- if (available) {
951
- return checker.getCommand(cwd);
952
- }
953
- if (checker.getOutcome?.(cwd) !== "missing")
954
- return null;
955
- if (!shouldAutoInstallTool(toolId))
956
- return null;
957
- const state = installStateFor(cwd, toolId);
958
- if (state.suppressed) {
959
- return null;
960
- }
961
- const installStartedAt = Date.now();
962
- const installed = await ensureTool(toolId);
963
- if (installed) {
964
- noteInstallSuccess(toolId, cwd);
965
- checker.reset?.();
966
- noteLatchedUnavailable(cwd, toolId);
967
- emitCompensatingAvailableRow(cwd, toolId, installStartedAt, installed, latchKeysFor(toolId, checker.getCommand(cwd) ?? void 0));
968
- return installed;
969
- }
970
- noteInstallFailure(toolId, cwd);
971
- return null;
972
- }
973
- function resolveAvailableOrInstall(checker, toolId, cwd) {
974
- const key = normalizeEphemeralMapKey(cwd);
975
- let byTool = resolveInstallInFlightByCwd.get(key);
976
- if (!byTool) {
977
- byTool = /* @__PURE__ */ new Map();
978
- resolveInstallInFlightByCwd.set(key, byTool);
979
- }
980
- const existing = byTool.get(toolId);
981
- if (existing)
982
- return existing;
983
- const generation = availabilityGeneration.capture();
984
- const promise = resolveAvailableOrInstallUnshared(checker, toolId, cwd).finally(() => {
985
- generation.guardedWrite(`${toolId}@${key}`, () => {
986
- const current = resolveInstallInFlightByCwd.get(key);
987
- if (current?.get(toolId) === promise) {
988
- current.delete(toolId);
989
- if (current.size === 0)
990
- resolveInstallInFlightByCwd.delete(key);
991
- }
992
- });
993
- });
994
- byTool.set(toolId, promise);
995
- return promise;
996
- }
997
- async function resolveLocalFirstAsync(toolName, cwd, windowsExt = ".cmd") {
998
- const local = localBinPath(findLocalBinAt(toolName, cwd, { windowsExt }));
999
- if (local)
1000
- return { cmd: local, args: [] };
1001
- const globalBin = await findGlobalBinary(toolName, windowsExt);
1002
- if (globalBin)
1003
- return { cmd: globalBin, args: [] };
1004
- const globalCheck = await probeToolAsync(toolName, ["--version"], {
1005
- timeout: 3e3
1006
- });
1007
- if (!globalCheck.error && globalCheck.status === 0) {
1008
- return { cmd: toolName, args: [] };
1009
- }
1010
- return { cmd: "npx", args: ["--no", toolName] };
1011
- }
1012
- var pyright = createAvailabilityChecker("pyright", ".exe");
1013
- var ruff = createAvailabilityChecker("ruff", ".exe");
1014
- var biome = createAvailabilityChecker("biome");
1015
- function resolveRunnerCwd(ctx, tool) {
1016
- return resolveToolCwd("runner", tool, ctx.filePath, ctx).cwd;
1017
- }
1018
-
1019
- export {
1020
- lspPrimaryCoversFile,
1021
- coveringLaneAvailable,
1022
- findManagedNodeToolBinary,
1023
- resolveAdoptedRootCommand,
1024
- resolveManagedToolClient,
1025
- getManagedToolEnvironment,
1026
- discoverManagedTool,
1027
- resetDispatchAvailabilityState,
1028
- createAvailabilityChecker,
1029
- createCwdCachedProbe,
1030
- resolveToolCommand,
1031
- resolveVendorToolCommand,
1032
- resolveToolCommandWithInstallFallback,
1033
- resolveCommandArgsWithInstallFallback,
1034
- resolveAvailableOrInstall,
1035
- resolveLocalFirstAsync,
1036
- resolveRunnerCwd
1037
- };