@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
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Which URLs the extension may ask anyone to fetch.
3
+ *
4
+ * One predicate serves two consumers with different consequences: the URL reader
5
+ * refuses a URL that fails it, and the search feature skips a source that fails it
6
+ * (and also checks DNS, because it contacts the site itself).
7
+ *
8
+ * Address literals are filtered against special-purpose IPv4 ranges and global IPv6
9
+ * space. This conservative filter is not a claim about DNS or future allocations.
10
+ */
11
+ import { isIP } from "node:net";
12
+
13
+ /** Normalised URLs longer than this are refused rather than echoed or requested. */
14
+ const MAX_URL_LENGTH = 2_048;
15
+
16
+ /** IPv4 ranges outside the global unicast space (IANA special-purpose registry). */
17
+ const IPV4_NOT_GLOBAL: Array<[string, number]> = [
18
+ ["0.0.0.0", 8],
19
+ ["10.0.0.0", 8],
20
+ ["100.64.0.0", 10],
21
+ ["127.0.0.0", 8],
22
+ ["169.254.0.0", 16],
23
+ ["172.16.0.0", 12],
24
+ ["192.0.0.0", 24],
25
+ ["192.0.2.0", 24],
26
+ ["192.88.99.0", 24],
27
+ ["192.168.0.0", 16],
28
+ ["198.18.0.0", 15],
29
+ ["198.51.100.0", 24],
30
+ ["203.0.113.0", 24],
31
+ ["224.0.0.0", 4],
32
+ ["240.0.0.0", 4],
33
+ ];
34
+
35
+ /** Special-purpose blocks inside 2000::/3 that are not globally reachable. */
36
+ const IPV6_NOT_GLOBAL: Array<[number[], number]> = [
37
+ [[0x2001, 0x0000], 23],
38
+ [[0x2001, 0x0db8], 32],
39
+ [[0x2002], 16],
40
+ [[0x3fff, 0x0000], 20],
41
+ ];
42
+
43
+ function ipv4Number(address: string): number {
44
+ return address.split(".").reduce((value, part) => value * 256 + Number(part), 0);
45
+ }
46
+
47
+ function inIpv4Range(value: number, [base, prefix]: [string, number]): boolean {
48
+ const size = 2 ** (32 - prefix);
49
+ const start = ipv4Number(base);
50
+ return value >= start && value < start + size;
51
+ }
52
+
53
+ function isGlobalIpv4(address: string): boolean {
54
+ const value = ipv4Number(address);
55
+ return value !== 0xffffffff && !IPV4_NOT_GLOBAL.some((range) => inIpv4Range(value, range));
56
+ }
57
+
58
+ /** Expand an IPv6 literal to eight 16-bit words, or undefined if it does not parse. */
59
+ function ipv6Words(address: string): number[] | undefined {
60
+ let canonical: string;
61
+ try {
62
+ // The URL parser canonicalises every spelling, including embedded dotted IPv4.
63
+ canonical = new URL(`http://[${address}]/`).hostname.slice(1, -1);
64
+ } catch {
65
+ return undefined;
66
+ }
67
+ const halves = canonical.split("::");
68
+ if (halves.length > 2) return undefined;
69
+ const left = halves[0] ? halves[0].split(":") : [];
70
+ const right = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
71
+ const missing = 8 - left.length - right.length;
72
+ if (missing < 0 || (halves.length === 1 && missing !== 0)) return undefined;
73
+ const words = [...left, ...Array<string>(missing).fill("0"), ...right].map((word) =>
74
+ Number.parseInt(word, 16),
75
+ );
76
+ return words.every((word) => Number.isInteger(word) && word >= 0 && word <= 0xffff)
77
+ ? words
78
+ : undefined;
79
+ }
80
+
81
+ function inIpv6Block(words: number[], [base, prefix]: [number[], number]): boolean {
82
+ for (let bit = 0; bit < prefix; bit += 16) {
83
+ const index = bit / 16;
84
+ const width = Math.min(16, prefix - bit);
85
+ const mask = (0xffff << (16 - width)) & 0xffff;
86
+ if ((words[index] & mask) !== ((base[index] ?? 0) & mask)) return false;
87
+ }
88
+ return true;
89
+ }
90
+
91
+ function isGlobalIpv6(address: string): boolean {
92
+ const words = ipv6Words(address);
93
+ if (!words) return false;
94
+ // IPv4-mapped (::ffff:a.b.c.d) and IPv4-translated (::ffff:0:a.b.c.d) forms carry an
95
+ // IPv4 destination: judge that address, so public IPv4 stays reachable.
96
+ const mapped = words.slice(0, 5).every((word) => word === 0) && words[5] === 0xffff;
97
+ const translated =
98
+ words.slice(0, 4).every((word) => word === 0) && words[4] === 0xffff && words[5] === 0;
99
+ if (mapped || translated) {
100
+ return isGlobalIpv4([words[6] >> 8, words[6] & 255, words[7] >> 8, words[7] & 255].join("."));
101
+ }
102
+ if ((words[0] & 0xe000) !== 0x2000) return false; // global unicast is 2000::/3
103
+ return !IPV6_NOT_GLOBAL.some((block) => inIpv6Block(words, block));
104
+ }
105
+
106
+ /** Strip URL brackets and an interface zone (`fe80::1%eth0`). */
107
+ function bareAddress(address: string): string {
108
+ const bare = address.startsWith("[") && address.endsWith("]") ? address.slice(1, -1) : address;
109
+ return bare.split("%")[0];
110
+ }
111
+
112
+ /** Whether an IP literal is globally routable. Names are not addresses: false. */
113
+ function isGloballyRoutable(address: string): boolean {
114
+ const bare = bareAddress(address);
115
+ const version = isIP(bare);
116
+ if (version === 4) return isGlobalIpv4(bare);
117
+ if (version === 6) return isGlobalIpv6(bare);
118
+ return false;
119
+ }
120
+
121
+ /** True for an IP literal outside the global space. Host names return false. */
122
+ export function isPrivateAddress(address: string): boolean {
123
+ const bare = bareAddress(address);
124
+ return isIP(bare) !== 0 && !isGloballyRoutable(bare);
125
+ }
126
+
127
+ /** Special-use names that only resolve on a local network (RFC 6761 and later). */
128
+ const LOCAL_NAME_SUFFIXES = [
129
+ "localhost",
130
+ "local",
131
+ "localdomain",
132
+ "internal",
133
+ "home.arpa",
134
+ "invalid",
135
+ "test",
136
+ "onion",
137
+ "alt",
138
+ ];
139
+
140
+ /** Whether a host name or literal can only mean the local machine or network. */
141
+ function isLocalHost(hostname: string): boolean {
142
+ const host = hostname.toLowerCase().replace(/\.$/, "");
143
+ if (!host) return true;
144
+ if (isIP(bareAddress(host))) return !isGloballyRoutable(host);
145
+ // Decimal, hex, and short dotted forms (127.1, 0x7f000001) are IP literals too.
146
+ // Node's URL parser does not always canonicalise them into dotted quads.
147
+ if (/^(?:0x[0-9a-f]+|\d+)$/i.test(host)) return true;
148
+ if (/^(?:\d{1,3}|0x[0-9a-f]{1,2})(?:\.(?:\d{1,3}|0x[0-9a-f]{1,2})){1,3}$/i.test(host)) {
149
+ return true;
150
+ }
151
+ // A single-label name resolves through a local search domain, never on the internet.
152
+ if (!host.includes(".")) return true;
153
+ return LOCAL_NAME_SUFFIXES.some((suffix) => host === suffix || host.endsWith(`.${suffix}`));
154
+ }
155
+
156
+ export type UrlCheck =
157
+ | { ok: true; url: string }
158
+ | { ok: false; reason: "missing" | "invalid" | "scheme" | "credentials" | "local" | "too-long" };
159
+
160
+ /**
161
+ * May this URL be requested on the user's behalf? The answer is about the URL alone:
162
+ * a public http(s) address with no embedded credentials and a bounded length.
163
+ */
164
+ export function checkPublicUrl(raw: string): UrlCheck {
165
+ const trimmed = typeof raw === "string" ? raw.trim() : "";
166
+ if (!trimmed) return { ok: false, reason: "missing" };
167
+ let parsed: URL;
168
+ try {
169
+ parsed = new URL(trimmed);
170
+ } catch {
171
+ return { ok: false, reason: "invalid" };
172
+ }
173
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
174
+ return { ok: false, reason: "scheme" };
175
+ if (parsed.username || parsed.password) return { ok: false, reason: "credentials" };
176
+ if (isLocalHost(parsed.hostname)) return { ok: false, reason: "local" };
177
+ const url = parsed.toString();
178
+ if (url.length > MAX_URL_LENGTH) return { ok: false, reason: "too-long" };
179
+ return { ok: true, url };
180
+ }
@@ -0,0 +1,149 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { antigravityEnv, isRecord } from "./util.js";
5
+
6
+ const AGY_SETTINGS_FILE = join(homedir(), ".gemini", "antigravity-cli", "settings.json");
7
+
8
+ function getPiSettingsPath(): string {
9
+ const agentDir = process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent");
10
+ return join(agentDir, "settings.json");
11
+ }
12
+
13
+ export type CreditsStatus = {
14
+ enabled: boolean;
15
+ source: "env" | "pi_settings" | "antigravity_settings" | "default";
16
+ detail: string;
17
+ };
18
+
19
+ /**
20
+ * Check whether credit overages are explicitly configured via env or settings.
21
+ */
22
+ export function getCreditsStatus(): CreditsStatus {
23
+ // 1. Environment variable check
24
+ const envVal =
25
+ antigravityEnv("USE_CREDITS") ?? antigravityEnv("USE_G1_CREDITS") ?? process.env.USE_G1_CREDITS;
26
+ if (envVal !== undefined) {
27
+ const trimmed = envVal.trim().toLowerCase();
28
+ const isTrue = ["1", "true", "yes", "on", "enable", "enabled"].includes(trimmed);
29
+ const isFalse = ["0", "false", "no", "off", "disable", "disabled"].includes(trimmed);
30
+ if (isTrue || isFalse) {
31
+ return {
32
+ enabled: isTrue,
33
+ source: "env",
34
+ detail: `Environment variable (ANTIGRAVITY_USE_CREDITS=${envVal})`,
35
+ };
36
+ }
37
+ }
38
+
39
+ // 2. Pi settings (~/.pi/agent/settings.json)
40
+ const piSettingsPath = getPiSettingsPath();
41
+ try {
42
+ if (existsSync(piSettingsPath)) {
43
+ const parsed = JSON.parse(readFileSync(piSettingsPath, "utf8")) as Record<string, unknown>;
44
+ if (typeof parsed.useG1Credits === "boolean") {
45
+ return {
46
+ enabled: parsed.useG1Credits,
47
+ source: "pi_settings",
48
+ detail: `~/.pi/agent/settings.json (useG1Credits: ${parsed.useG1Credits})`,
49
+ };
50
+ }
51
+ if (typeof parsed.useCredits === "boolean") {
52
+ return {
53
+ enabled: parsed.useCredits,
54
+ source: "pi_settings",
55
+ detail: `~/.pi/agent/settings.json (useCredits: ${parsed.useCredits})`,
56
+ };
57
+ }
58
+ if (isRecord(parsed.antigravity)) {
59
+ if (typeof parsed.antigravity.useCredits === "boolean") {
60
+ return {
61
+ enabled: parsed.antigravity.useCredits,
62
+ source: "pi_settings",
63
+ detail: `~/.pi/agent/settings.json (antigravity.useCredits: ${parsed.antigravity.useCredits})`,
64
+ };
65
+ }
66
+ if (typeof parsed.antigravity.useG1Credits === "boolean") {
67
+ return {
68
+ enabled: parsed.antigravity.useG1Credits,
69
+ source: "pi_settings",
70
+ detail: `~/.pi/agent/settings.json (antigravity.useG1Credits: ${parsed.antigravity.useG1Credits})`,
71
+ };
72
+ }
73
+ }
74
+ }
75
+ } catch {
76
+ // Unreadable Pi settings leave credit overages disabled.
77
+ }
78
+
79
+ // 3. Antigravity CLI / IDE settings (~/.gemini/antigravity-cli/settings.json)
80
+ try {
81
+ if (existsSync(AGY_SETTINGS_FILE)) {
82
+ const agyData = JSON.parse(readFileSync(AGY_SETTINGS_FILE, "utf8")) as Record<
83
+ string,
84
+ unknown
85
+ >;
86
+ if (agyData.useG1Credits === true || agyData.useAiCredits === true) {
87
+ return {
88
+ enabled: true,
89
+ source: "antigravity_settings",
90
+ detail: `~/.gemini/antigravity-cli/settings.json (useG1Credits: true)`,
91
+ };
92
+ }
93
+ if (agyData.useG1Credits === false || agyData.useAiCredits === false) {
94
+ return {
95
+ enabled: false,
96
+ source: "antigravity_settings",
97
+ detail: `~/.gemini/antigravity-cli/settings.json (useG1Credits: false)`,
98
+ };
99
+ }
100
+ }
101
+ } catch {
102
+ // Unreadable CLI settings leave credit overages disabled.
103
+ }
104
+
105
+ return {
106
+ enabled: false,
107
+ source: "default",
108
+ detail: "Default (disabled; enable with /antigravity.credits on)",
109
+ };
110
+ }
111
+
112
+ export function isCreditsEnabled(): boolean {
113
+ return getCreditsStatus().enabled;
114
+ }
115
+
116
+ function readSettingsObject(path: string): Record<string, unknown> {
117
+ const parsed = JSON.parse(readFileSync(path, "utf8")) as unknown;
118
+ if (!isRecord(parsed)) {
119
+ throw new Error(`${path} is not a JSON object`);
120
+ }
121
+ return parsed;
122
+ }
123
+
124
+ export function setCreditsEnabled(enabled: boolean): void {
125
+ // Update Pi's settings only. A parse failure must not replace the file with `{ useG1Credits }`.
126
+ const piSettingsPath = getPiSettingsPath();
127
+ try {
128
+ const piData = existsSync(piSettingsPath) ? readSettingsObject(piSettingsPath) : {};
129
+ piData.useG1Credits = enabled;
130
+ writeFileSync(piSettingsPath, `${JSON.stringify(piData, null, 2)}\n`, {
131
+ encoding: "utf8",
132
+ mode: 0o600,
133
+ });
134
+ } catch (error) {
135
+ const message = error instanceof Error ? error.message : String(error);
136
+ throw new Error(`Failed to update ${piSettingsPath}: ${message}`, { cause: error });
137
+ }
138
+
139
+ // Keep the official CLI flag in sync only when that file already exists and parses.
140
+ // Never create it, and never overwrite it after a parse error.
141
+ if (!existsSync(AGY_SETTINGS_FILE)) return;
142
+ try {
143
+ const agyData = readSettingsObject(AGY_SETTINGS_FILE);
144
+ agyData.useG1Credits = enabled;
145
+ writeFileSync(AGY_SETTINGS_FILE, `${JSON.stringify(agyData, null, 2)}\n`, "utf8");
146
+ } catch {
147
+ // Leave the CLI file untouched.
148
+ }
149
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared HTML text helpers.
3
+ *
4
+ * Search titles and fetched pages both come out of Google's services as markup, so
5
+ * entity decoding lives here rather than in either feature.
6
+ */
7
+
8
+ /** Decoded form of a numeric entity, or the entity as written when the value is not a code point. */
9
+ function fromCodePoint(match: string, code: number): string {
10
+ return Number.isInteger(code) && code >= 0 && code <= 0x10ffff
11
+ ? String.fromCodePoint(code)
12
+ : match;
13
+ }
14
+
15
+ /** Replace HTML entities with their characters, leaving whitespace exactly as written. */
16
+ function decodeEntityText(text: string): string {
17
+ return text
18
+ .replace(/&#(\d+);/g, (match, code: string) => fromCodePoint(match, Number(code)))
19
+ .replace(/&#x([0-9a-f]+);/gi, (match, code: string) => fromCodePoint(match, parseInt(code, 16)))
20
+ .replace(/&quot;/g, '"')
21
+ .replace(/&apos;|&#39;/g, "'")
22
+ .replace(/&lt;/g, "<")
23
+ .replace(/&gt;/g, ">")
24
+ .replace(/&nbsp;/g, " ")
25
+ .replace(/&amp;/g, "&");
26
+ }
27
+
28
+ /** Entity decoding for one line of prose: collapsed to single spaces and trimmed. */
29
+ export function decodeHtmlEntities(text: string): string {
30
+ return decodeEntityText(text).replace(/\s+/g, " ").trim();
31
+ }
@@ -1,3 +1,5 @@
1
1
  export * from "./util.js";
2
2
  export * from "./security.js";
3
3
  export * from "./http.js";
4
+ export * from "./credits.js";
5
+ export * from "./html.js";
@@ -40,20 +40,179 @@ export function assertSafeApiBaseUrl(raw: string): string {
40
40
  return `${url.origin}${path === "/" ? "" : path}`;
41
41
  }
42
42
 
43
- /** Redact bearer tokens, refresh tokens, and similar secrets from diagnostics/errors. */
44
- export function redactSecrets(text: string): string {
45
- return text
46
- .replace(/\bya29\.[A-Za-z0-9._~+/-]+=*/g, "[redacted-access-token]")
47
- .replace(/\b1\/[A-Za-z0-9_-]{20,}/g, "[redacted-refresh-token]")
48
- .replace(/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi, "Bearer [redacted]")
49
- .replace(
50
- /("?(?:access_token|refresh_token|id_token|token|client_secret|code_verifier|authorization)"?\s*[:=]\s*")[^"]*(")/gi,
51
- "$1[redacted]$2",
52
- )
53
- .replace(
54
- /("?(?:access_token|refresh_token|id_token|token|client_secret|code_verifier|authorization)"?\s*[:=]\s*)[^\s&,}]+/gi,
55
- "$1[redacted]",
43
+ /**
44
+ * One redaction policy, expressed as contexts rather than as one list of names.
45
+ *
46
+ * - Shapes: values Google issues have stable shapes (access tokens `ya29.`, refresh
47
+ * tokens `1//`, authorization codes `4/0A`, JWTs), so they are hidden wherever
48
+ * they appear, with or without a name.
49
+ * - URL parameters: in a query or fragment a name is secret when its last word is a
50
+ * credential word (`?subscription_key=`, `#access_token=`). A value is looked
51
+ * inside only when it carries the syntax of a context itself: a nested query or URL,
52
+ * or a bare `name=value` assignment.
53
+ * - Assignments in free text (`token=...`, `"password": "..."`): the same words,
54
+ * minus the ones that are ordinary prose or diagnostics ({@link PROSE_WORDS}).
55
+ *
56
+ * Strings a page supplies are content, not secrets, and are never passed through here.
57
+ */
58
+ const CREDENTIAL_WORDS = new Set([
59
+ "token",
60
+ "secret",
61
+ "password",
62
+ "passwd",
63
+ "pwd",
64
+ "key",
65
+ "apikey",
66
+ "signature",
67
+ "sig",
68
+ "credential",
69
+ "credentials",
70
+ "bearer",
71
+ "jwt",
72
+ "auth",
73
+ "authorization",
74
+ "session",
75
+ "sessionid",
76
+ "sid",
77
+ "code",
78
+ "state",
79
+ "nonce",
80
+ "verifier",
81
+ "otp",
82
+ ]);
83
+
84
+ /** Compound names whose last word alone is not a credential word. */
85
+ const CREDENTIAL_SUFFIXES = ["accesskeyid", "accesskey", "privatekey", "clientsecret"];
86
+
87
+ /**
88
+ * Words that name credentials in a URL but are ordinary in prose and diagnostics
89
+ * ("exit code=1", "model state=UNAVAILABLE", "session=expired"). In free text they
90
+ * are only redacted when the value has a credential shape.
91
+ */
92
+ const PROSE_WORDS = new Set([
93
+ "code",
94
+ "state",
95
+ "nonce",
96
+ "session",
97
+ "sessionid",
98
+ "sid",
99
+ "auth",
100
+ "key",
101
+ "sig",
102
+ "signature",
103
+ "credential",
104
+ "jwt",
105
+ ]);
106
+
107
+ function nameWords(name: string): string[] {
108
+ return name
109
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
110
+ .toLowerCase()
111
+ .split(/[^a-z0-9]+/)
112
+ .filter(Boolean);
113
+ }
114
+
115
+ /** Whether a parameter or field name carries a credential. */
116
+ function isCredentialName(name: string, inProse: boolean): boolean {
117
+ const words = nameWords(name);
118
+ const last = words.at(-1);
119
+ if (!last) return false;
120
+ const credentialQualifier =
121
+ words.length > 1 &&
122
+ words.some((word) =>
123
+ /^(?:oauth|amz|goog|api|private|subscription|signing|access|secret|client)$/.test(word),
56
124
  );
125
+ if (CREDENTIAL_WORDS.has(last)) return !inProse || !PROSE_WORDS.has(last) || credentialQualifier;
126
+ const compact = words.join("");
127
+ return CREDENTIAL_SUFFIXES.some((suffix) => compact.endsWith(suffix));
128
+ }
129
+
130
+ /** A value long and random enough to be a credential rather than a word. */
131
+ function looksLikeCredential(value: string): boolean {
132
+ return value.length >= 16 && /[0-9]/.test(value) && /^[A-Za-z0-9._~+/=-]+$/.test(value);
133
+ }
134
+
135
+ const TOKEN_SHAPES: Array<[RegExp, string]> = [
136
+ [/\bya29\.[A-Za-z0-9._~+/-]+=*/g, "[redacted-access-token]"],
137
+ [/\b1\/\/?[A-Za-z0-9_-]{20,}/g, "[redacted-refresh-token]"],
138
+ [/\b4\/0A[A-Za-z0-9_-]{10,}/g, "[redacted-authorization-code]"],
139
+ [/\bGOCSPX-[A-Za-z0-9_-]{10,}/g, "[redacted-client-secret]"],
140
+ [/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g, "[redacted-jwt]"],
141
+ [/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi, "Bearer [redacted]"],
142
+ ];
143
+
144
+ function decodeComponent(value: string): string | undefined {
145
+ try {
146
+ return decodeURIComponent(value.replace(/\+/g, " "));
147
+ } catch {
148
+ return undefined;
149
+ }
150
+ }
151
+
152
+ /**
153
+ * A query or fragment parameter. The name excludes `?`, so each separator is looked
154
+ * at once and a URL with many separators is redacted in linear time.
155
+ */
156
+ const URL_PARAMETER = /([?&#])([^=&#?\s]{1,256})=([^&#\s"'<>]*)/g;
157
+
158
+ function redactParameters(text: string, depth = 0): string {
159
+ return text.replace(URL_PARAMETER, (match, separator: string, name: string, value: string) => {
160
+ const decodedName = decodeComponent(name);
161
+ if (decodedName === undefined) return match;
162
+ if (isCredentialName(decodedName, false)) return `${separator}${name}=[redacted]`;
163
+ // Look inside a value only when it carries a context's own syntax.
164
+ const decoded = decodeComponent(value);
165
+ if (!decoded) return match;
166
+ const nested =
167
+ /^[?&#]/.test(decoded) || /:\/\/[^\s]*[?#]/.test(decoded)
168
+ ? depth >= 8 || redactParameters(decoded, depth + 1) !== decoded
169
+ : /^[\w.-]{1,64}=\S+$/.test(decoded) &&
170
+ isCredentialName(decoded.slice(0, decoded.indexOf("=")), false);
171
+ return nested ? `${separator}${name}=[redacted]` : match;
172
+ });
173
+ }
174
+
175
+ /**
176
+ * A name followed by `:` or `=` and a value. A quoted value keeps its quotes, so a
177
+ * JSON document stays valid JSON after redaction.
178
+ */
179
+ const ASSIGNMENT =
180
+ /(["']?)\b([A-Za-z][\w.-]{0,63})\1(\s*[:=]\s*)(?:"((?:[^"\\\n]|\\.)*)"|'([^'\n]*)'|([^\s"',;&}\]]+))/g;
181
+
182
+ function redactAssignments(text: string): string {
183
+ return text.replace(
184
+ ASSIGNMENT,
185
+ (
186
+ match,
187
+ quote: string,
188
+ name: string,
189
+ separator: string,
190
+ double?: string,
191
+ single?: string,
192
+ bare?: string,
193
+ ) => {
194
+ const value = double ?? single ?? bare ?? "";
195
+ if (!value || value.startsWith("[redacted")) return match;
196
+ const words = nameWords(name);
197
+ const last = words.at(-1) ?? "";
198
+ if (!isCredentialName(name, true) && !(PROSE_WORDS.has(last) && looksLikeCredential(value)))
199
+ return match;
200
+ const redacted =
201
+ double !== undefined
202
+ ? '"[redacted]"'
203
+ : single !== undefined
204
+ ? "'[redacted]'"
205
+ : "[redacted]";
206
+ return `${quote}${name}${quote}${separator}${redacted}`;
207
+ },
208
+ );
209
+ }
210
+
211
+ /** Redact credentials from text the extension renders: errors, diagnostics and URLs. */
212
+ export function redactSecrets(text: string): string {
213
+ let redacted = text.replace(/\b(https?:\/\/)[^/?#\s]*@/gi, "$1[redacted]@");
214
+ for (const [shape, replacement] of TOKEN_SHAPES) redacted = redacted.replace(shape, replacement);
215
+ return redactAssignments(redactParameters(redacted));
57
216
  }
58
217
 
59
218
  const VALIDATION_URL_HOST = "accounts.google.com";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shared handling for text that came from somewhere else: a page, the fetch service,
3
+ * or a quota report.
4
+ *
5
+ * Two operations with two scopes:
6
+ * - {@link repairText} keeps structure and length, replacing only ill-formed UTF-16.
7
+ * It applies to every third-party string, including page bodies.
8
+ * - {@link cleanText} flattens a value to one bounded line. It applies only to labels
9
+ * and metadata, never to a page body, whose line structure is the content.
10
+ *
11
+ * The length cuts never split a surrogate pair. Each caller chooses the direction:
12
+ * an end that must stay inside a limit moves back, a range end moves forward, and a
13
+ * range start moves back.
14
+ */
15
+ import { sanitizeText } from "./util.js";
16
+
17
+ /** Replace lone surrogates with U+FFFD. One code unit in, one code unit out. */
18
+ export function repairText(text: string): string {
19
+ return sanitizeText(text);
20
+ }
21
+
22
+ /** Whether index falls between the two halves of a surrogate pair. */
23
+ function splitsPair(text: string, index: number): boolean {
24
+ if (index <= 0 || index >= text.length) return false;
25
+ const before = text.charCodeAt(index - 1);
26
+ const after = text.charCodeAt(index);
27
+ return before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff;
28
+ }
29
+
30
+ /** Move a boundary back off a surrogate pair. */
31
+ export function boundaryBack(text: string, index: number): number {
32
+ return splitsPair(text, index) ? index - 1 : index;
33
+ }
34
+
35
+ /** Move a boundary forward off a surrogate pair. */
36
+ export function boundaryForward(text: string, index: number): number {
37
+ return splitsPair(text, index) ? index + 1 : index;
38
+ }
39
+
40
+ /** Cut text to at most limit code units without splitting a character. */
41
+ export function capText(text: string, limit: number): string {
42
+ if (text.length <= limit) return text;
43
+ return text.slice(0, boundaryBack(text, Math.max(0, limit)));
44
+ }
45
+
46
+ /** One bounded, single-line value: control characters and line breaks become spaces. */
47
+ export function cleanText(value: string | undefined, limit: number): string | undefined {
48
+ if (!value) return undefined;
49
+ const cleaned = repairText(value)
50
+ .replace(/[\p{Cc}\u2028\u2029]+/gu, " ")
51
+ .replace(/\s+/g, " ")
52
+ .trim();
53
+ if (!cleaned) return undefined;
54
+ if (cleaned.length <= limit) return cleaned;
55
+ return `${capText(cleaned, Math.max(0, limit - 1))}…`;
56
+ }
57
+
58
+ /** Keep the head and the tail of a long value, eliding the middle. */
59
+ export function elideMiddle(value: string, limit: number): string {
60
+ if (value.length <= limit) return value;
61
+ if (limit < 3) return capText(value, limit);
62
+ const keep = limit - 1;
63
+ const headEnd = boundaryBack(value, Math.ceil(keep / 2));
64
+ const tailStart = boundaryForward(value, value.length - (keep - Math.ceil(keep / 2)));
65
+ return `${value.slice(0, headEnd)}…${value.slice(tailStart)}`;
66
+ }
@@ -6,11 +6,12 @@ export function antigravityEnv(name: string): string | undefined {
6
6
  }
7
7
 
8
8
  /**
9
- * Whether a model-facing extra tool (`google_search`, `generate_image`) is registered.
10
- * `ANTIGRAVITY_NO_EXTRA_TOOLS=1` disables both; `ANTIGRAVITY_NO_SEARCH_TOOL=1` and
11
- * `ANTIGRAVITY_NO_IMAGE_TOOL=1` disable one, e.g. to avoid clashing with another search provider.
9
+ * Whether a model-facing extra tool (`google_search`, `read_url_content`,
10
+ * `generate_image`) is registered. `ANTIGRAVITY_NO_EXTRA_TOOLS=1` disables all of them;
11
+ * `ANTIGRAVITY_NO_SEARCH_TOOL=1`, `ANTIGRAVITY_NO_FETCH_TOOL=1`, and
12
+ * `ANTIGRAVITY_NO_IMAGE_TOOL=1` disable one, e.g. to avoid clashing with another provider.
12
13
  */
13
- export function isExtraToolEnabled(tool: "SEARCH" | "IMAGE"): boolean {
14
+ export function isExtraToolEnabled(tool: "SEARCH" | "IMAGE" | "FETCH"): boolean {
14
15
  return antigravityEnv("NO_EXTRA_TOOLS") !== "1" && antigravityEnv(`NO_${tool}_TOOL`) !== "1";
15
16
  }
16
17