@herbertgao/pi-extensions 2026.10.6 → 2026.10.7

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 (473) hide show
  1. package/README.md +9 -13
  2. package/THIRD_PARTY_NOTICES.md +1 -53
  3. package/extensions/clef-format.mjs +113 -0
  4. package/extensions/clef.mjs +112 -0
  5. package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +1 -1
  6. package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +30 -6
  7. package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
  8. package/node_modules/@dietrichgebert/ponytail/README.md +5 -1
  9. package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
  10. package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +4 -4
  11. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +158 -127
  12. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +5 -0
  13. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +8 -3
  14. package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +14 -8
  15. package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
  16. package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +16 -3
  17. package/node_modules/@dietrichgebert/ponytail/scripts/cursor-hooks.js +13 -3
  18. package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +3 -2
  19. package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +3 -3
  20. package/node_modules/@herbertgao/pi-agency/package.json +2 -2
  21. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  22. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
  23. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
  24. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +283 -136
  25. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +90 -22
  26. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +66 -26
  27. package/node_modules/@herbertgao/pi-cc-extensions/package.json +5 -5
  28. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +8 -0
  29. package/node_modules/@herbertgao/pi-subagents/docs/packages.md +211 -0
  30. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +61 -63
  31. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +24 -16
  32. package/node_modules/@herbertgao/pi-subagents/package.json +5 -5
  33. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +51 -14
  34. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +123 -55
  35. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +144 -13
  36. package/node_modules/@herbertgao/pi-subagents/src/agent-source-badge.ts +78 -0
  37. package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +122 -0
  38. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +171 -79
  39. package/node_modules/@herbertgao/pi-subagents/src/index.ts +597 -296
  40. package/node_modules/@herbertgao/pi-subagents/src/package-resources.ts +724 -0
  41. package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +1 -1
  42. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +66 -0
  43. package/node_modules/@herbertgao/pi-subagents/src/types.ts +26 -4
  44. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -0
  45. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +354 -32
  46. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +33 -15
  47. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +6 -0
  48. package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +48 -2
  49. package/node_modules/@herbertgao/sol-pi/package.json +2 -2
  50. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +3 -3
  51. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +89 -39
  52. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +1 -1
  53. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +4 -4
  54. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +56 -23
  55. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +6 -3
  56. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +3 -1
  57. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +3 -1
  58. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +3 -1
  59. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +3 -1
  60. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +3 -1
  61. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +3 -1
  62. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +3 -1
  63. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +3 -1
  64. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +3 -1
  65. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +5 -2
  66. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +122 -0
  67. package/node_modules/@juicesharp/rpiv-ask-user-question/rpc-fallback.ts +73 -36
  68. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +10 -1
  69. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +15 -13
  70. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +5 -1
  71. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/derivations.ts +15 -0
  72. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +4 -1
  73. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +29 -18
  74. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +1 -1
  75. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/format-answer.ts +5 -2
  76. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/normalize-params.ts +46 -0
  77. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +19 -8
  78. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +9 -2
  79. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +4 -2
  80. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +56 -25
  81. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-pane.ts +131 -46
  82. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +94 -106
  83. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +51 -0
  84. package/node_modules/@juicesharp/rpiv-ask-user-question/view/scroll-window.ts +73 -0
  85. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +31 -10
  86. package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -1
  87. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +474 -93
  88. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  89. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  90. package/node_modules/pi-lens/CHANGELOG.md +88 -0
  91. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +3 -1
  92. package/node_modules/pi-lens/dist/{chunk-BJF25SUG.js → chunk-23WOO7TX.js} +11 -10
  93. package/node_modules/pi-lens/dist/{chunk-WATC3IQR.js → chunk-2B73ZPOK.js} +3 -3
  94. package/node_modules/pi-lens/dist/{chunk-N2IRDBZI.js → chunk-2BBLFX75.js} +101 -11
  95. package/node_modules/pi-lens/dist/{chunk-TA5L5KWQ.js → chunk-2CD5RS6M.js} +2 -2
  96. package/node_modules/pi-lens/dist/{chunk-3TTPKMEF.js → chunk-2VUQMUMT.js} +38 -37
  97. package/node_modules/pi-lens/dist/{chunk-5JHXUETW.js → chunk-3EFKIGZN.js} +3 -3
  98. package/node_modules/pi-lens/dist/chunk-3JNKMP3B.js +17 -0
  99. package/node_modules/pi-lens/dist/{chunk-6P54TMWL.js → chunk-3VPVG5SU.js} +6 -6
  100. package/node_modules/pi-lens/dist/{chunk-ZETYB3XG.js → chunk-3W7IEVVL.js} +44 -28
  101. package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +85 -0
  102. package/node_modules/pi-lens/dist/chunk-466Z26MG.js +30 -0
  103. package/node_modules/pi-lens/dist/{chunk-PCHDGUKT.js → chunk-4UNXBNE2.js} +12 -11
  104. package/node_modules/pi-lens/dist/{chunk-J7WJZ6W7.js → chunk-4W4VLAPJ.js} +12 -11
  105. package/node_modules/pi-lens/dist/{chunk-F5VLZHUW.js → chunk-52FUZI6K.js} +4 -2
  106. package/node_modules/pi-lens/dist/{chunk-H5EV3VMF.js → chunk-5NGR67U5.js} +2 -2
  107. package/node_modules/pi-lens/dist/{chunk-CBD2B5CP.js → chunk-5UCAH366.js} +21 -20
  108. package/node_modules/pi-lens/dist/{chunk-BHWHXMQ2.js → chunk-67WMNWEE.js} +9 -8
  109. package/node_modules/pi-lens/dist/{chunk-USHG4DLH.js → chunk-6C7JWPCP.js} +7 -7
  110. package/node_modules/pi-lens/dist/{chunk-VPWKF3GN.js → chunk-6GFRNVYR.js} +11 -10
  111. package/node_modules/pi-lens/dist/{chunk-3JL6IFD7.js → chunk-6SDEP3AJ.js} +9 -8
  112. package/node_modules/pi-lens/dist/{chunk-NJF2X5XF.js → chunk-6STA6Z7I.js} +19 -17
  113. package/node_modules/pi-lens/dist/{chunk-KJCWXUUS.js → chunk-724UL2TJ.js} +6 -4
  114. package/node_modules/pi-lens/dist/{chunk-MQA2YBAH.js → chunk-76MWC2K6.js} +3 -3
  115. package/node_modules/pi-lens/dist/{chunk-YLN4K6WD.js → chunk-77M37OKR.js} +10 -8
  116. package/node_modules/pi-lens/dist/{chunk-XHSCVSOL.js → chunk-7DYBLXYA.js} +3 -3
  117. package/node_modules/pi-lens/dist/{chunk-OC7LYAU5.js → chunk-AB3YYG6N.js} +24 -10
  118. package/node_modules/pi-lens/dist/{chunk-LD7WFTRX.js → chunk-ACXEQZOU.js} +16 -16
  119. package/node_modules/pi-lens/dist/{chunk-VSMJK3ZJ.js → chunk-AOHZU2BM.js} +1 -1
  120. package/node_modules/pi-lens/dist/{chunk-T4QZ6FEH.js → chunk-AW7R2GWG.js} +65 -8
  121. package/node_modules/pi-lens/dist/{chunk-GAYGGICG.js → chunk-BKE7E7TC.js} +10 -9
  122. package/node_modules/pi-lens/dist/{chunk-EUT3B22Y.js → chunk-BRGDSBJE.js} +13 -12
  123. package/node_modules/pi-lens/dist/{chunk-T54VJRAD.js → chunk-C34ZXZ7O.js} +55 -11
  124. package/node_modules/pi-lens/dist/{chunk-UGSMCQ4D.js → chunk-CHOW74WE.js} +1 -1
  125. package/node_modules/pi-lens/dist/{chunk-H2W2AXD3.js → chunk-CMMHNUZ2.js} +66 -58
  126. package/node_modules/pi-lens/dist/chunk-CSHFH5IN.js +17 -0
  127. package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +56 -0
  128. package/node_modules/pi-lens/dist/{chunk-KJN4IOEJ.js → chunk-EJIUXPBX.js} +1 -1
  129. package/node_modules/pi-lens/dist/{chunk-IQZXOZ7S.js → chunk-EU63SDCG.js} +720 -334
  130. package/node_modules/pi-lens/dist/{chunk-LNOMA3MP.js → chunk-FCSOVF55.js} +107 -3
  131. package/node_modules/pi-lens/dist/{chunk-CFYISHUW.js → chunk-FLKWCIZH.js} +8 -5
  132. package/node_modules/pi-lens/dist/{chunk-OYTMZXRF.js → chunk-FMSO6RDZ.js} +16 -14
  133. package/node_modules/pi-lens/dist/{chunk-IUKPRZER.js → chunk-GAEGEPOC.js} +2 -2
  134. package/node_modules/pi-lens/dist/{chunk-6XX5HCLK.js → chunk-GBPP5P7X.js} +4 -4
  135. package/node_modules/pi-lens/dist/{chunk-TQFBZVCG.js → chunk-GXW6K4YJ.js} +1 -1
  136. package/node_modules/pi-lens/dist/{chunk-ZZUFZUQZ.js → chunk-H6MF6EVN.js} +331 -107
  137. package/node_modules/pi-lens/dist/{chunk-3JSEWUWI.js → chunk-IBGIOBEE.js} +3 -3
  138. package/node_modules/pi-lens/dist/chunk-IZSHAIJ7.js +26 -0
  139. package/node_modules/pi-lens/dist/{chunk-7ELY2CSM.js → chunk-JAU72XNY.js} +16 -14
  140. package/node_modules/pi-lens/dist/chunk-JMYYOTQG.js +77 -0
  141. package/node_modules/pi-lens/dist/{chunk-ELVWJYRV.js → chunk-JSQFTSC6.js} +12 -11
  142. package/node_modules/pi-lens/dist/{chunk-J6DFZDFA.js → chunk-KBG47GHP.js} +4 -4
  143. package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +28 -0
  144. package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +69 -0
  145. package/node_modules/pi-lens/dist/{chunk-XGUL4SLQ.js → chunk-L3BLXZG7.js} +2 -2
  146. package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +31 -0
  147. package/node_modules/pi-lens/dist/{chunk-MTDRLSI7.js → chunk-M6HSLBWY.js} +1064 -986
  148. package/node_modules/pi-lens/dist/chunk-MQLUAEOC.js +162 -0
  149. package/node_modules/pi-lens/dist/{chunk-3MRXIJ6I.js → chunk-MRXKYPCS.js} +2 -2
  150. package/node_modules/pi-lens/dist/{chunk-D65GOCJB.js → chunk-MXGY6KPT.js} +19 -16
  151. package/node_modules/pi-lens/dist/{chunk-G3RLJYA2.js → chunk-N2H3ZPZY.js} +47 -1
  152. package/node_modules/pi-lens/dist/{chunk-HREZQCT3.js → chunk-N3X6Q4YT.js} +3 -3
  153. package/node_modules/pi-lens/dist/{chunk-HSIRMK2D.js → chunk-OCAGUNBC.js} +15 -15
  154. package/node_modules/pi-lens/dist/{chunk-ZOEYVXSV.js → chunk-OXXKQCSV.js} +6 -6
  155. package/node_modules/pi-lens/dist/{chunk-S6AMWKPC.js → chunk-P7266HLM.js} +2 -2
  156. package/node_modules/pi-lens/dist/{chunk-64LU2OVH.js → chunk-PHDMFAKM.js} +12 -2
  157. package/node_modules/pi-lens/dist/{chunk-IMSQR4WO.js → chunk-PNQDPDRC.js} +1 -1
  158. package/node_modules/pi-lens/dist/{chunk-IUR76K6A.js → chunk-Q7DUK4LX.js} +5 -5
  159. package/node_modules/pi-lens/dist/{chunk-CULQYFLU.js → chunk-QGQ5CCCG.js} +2 -2
  160. package/node_modules/pi-lens/dist/{chunk-UEAHAMEI.js → chunk-QHJ6DQ2R.js} +11 -11
  161. package/node_modules/pi-lens/dist/{chunk-BNKLYOOO.js → chunk-QILIYSJF.js} +1 -1
  162. package/node_modules/pi-lens/dist/{chunk-VYKKMYVT.js → chunk-QOBUHWHX.js} +11 -6
  163. package/node_modules/pi-lens/dist/{chunk-3PNFWVHT.js → chunk-QQNQ7SJW.js} +2 -75
  164. package/node_modules/pi-lens/dist/{chunk-7M4T5N3V.js → chunk-R3PCY3YS.js} +14 -13
  165. package/node_modules/pi-lens/dist/{chunk-MGIWSROG.js → chunk-RPLINGVB.js} +7 -7
  166. package/node_modules/pi-lens/dist/{chunk-CMU4RMJB.js → chunk-RWWYJ623.js} +10 -1
  167. package/node_modules/pi-lens/dist/{chunk-3FERWMCH.js → chunk-RXCOMYPY.js} +27 -26
  168. package/node_modules/pi-lens/dist/{chunk-7BX5DWSA.js → chunk-SAEFPSB6.js} +11 -11
  169. package/node_modules/pi-lens/dist/{chunk-N7YNJE5R.js → chunk-SQ4TVJBR.js} +10 -10
  170. package/node_modules/pi-lens/dist/{chunk-DMS52BEP.js → chunk-SS36ZX4J.js} +9 -7
  171. package/node_modules/pi-lens/dist/{chunk-JONGANYH.js → chunk-T6CPIZNT.js} +32 -30
  172. package/node_modules/pi-lens/dist/{chunk-6UYA642J.js → chunk-TYM6OUIT.js} +13 -12
  173. package/node_modules/pi-lens/dist/{chunk-ALQRYH6O.js → chunk-UXGETRP4.js} +13 -12
  174. package/node_modules/pi-lens/dist/{chunk-FGALODG3.js → chunk-UZ3TUTRV.js} +1 -1
  175. package/node_modules/pi-lens/dist/{chunk-J3FZR3YY.js → chunk-VCHXCQFG.js} +3 -3
  176. package/node_modules/pi-lens/dist/{chunk-3P4PF2BX.js → chunk-VCO24T4L.js} +34 -22
  177. package/node_modules/pi-lens/dist/{chunk-O7HZX7CA.js → chunk-VRZP76YM.js} +1 -1
  178. package/node_modules/pi-lens/dist/{chunk-VZHJS6DR.js → chunk-VSSBEUFT.js} +16 -15
  179. package/node_modules/pi-lens/dist/{chunk-U52SAGRM.js → chunk-VWCXW2E7.js} +1 -1
  180. package/node_modules/pi-lens/dist/{chunk-WW5BLB74.js → chunk-WOA4LN2R.js} +2 -2
  181. package/node_modules/pi-lens/dist/{chunk-ZMOMPX2Z.js → chunk-WU567RSC.js} +11 -10
  182. package/node_modules/pi-lens/dist/{chunk-N77WFUL7.js → chunk-XAGLWMJ4.js} +23 -22
  183. package/node_modules/pi-lens/dist/{chunk-WSEWKCXU.js → chunk-XCJN5IJU.js} +4 -4
  184. package/node_modules/pi-lens/dist/{chunk-IR6XFA5P.js → chunk-XIJZVPD5.js} +16 -14
  185. package/node_modules/pi-lens/dist/{chunk-OYOB3ZFG.js → chunk-XMSXXAHW.js} +2 -2
  186. package/node_modules/pi-lens/dist/{chunk-34OCDWOS.js → chunk-XTMJ7XDT.js} +1 -1
  187. package/node_modules/pi-lens/dist/{chunk-Z6BB4JLQ.js → chunk-XVF2VVXP.js} +5 -3
  188. package/node_modules/pi-lens/dist/{chunk-AFZYMAIV.js → chunk-YIUAVF7E.js} +37 -35
  189. package/node_modules/pi-lens/dist/{chunk-NFXP47RV.js → chunk-YSZNHOBY.js} +85 -31
  190. package/node_modules/pi-lens/dist/{chunk-V5MEBST3.js → chunk-YYOIQFRS.js} +21 -21
  191. package/node_modules/pi-lens/dist/chunk-Z527N6YQ.js +28 -0
  192. package/node_modules/pi-lens/dist/{chunk-D6YF5HKX.js → chunk-ZANLILYD.js} +22 -2
  193. package/node_modules/pi-lens/dist/{chunk-2UMYMRI3.js → chunk-ZGDGW2V3.js} +2 -2
  194. package/node_modules/pi-lens/dist/{chunk-6B5I6ICN.js → chunk-ZHFZWTZV.js} +12 -11
  195. package/node_modules/pi-lens/dist/{chunk-OEX24ECI.js → chunk-ZWFS3OEF.js} +51 -41
  196. package/node_modules/pi-lens/dist/{chunk-AXKPQ6ZI.js → chunk-ZXYDQ3TZ.js} +5 -5
  197. package/node_modules/pi-lens/dist/index.js +73783 -71033
  198. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +18 -8
  199. package/node_modules/pi-lens/dist/mcp/cli.js +48 -37
  200. package/node_modules/pi-lens/dist/mcp/server.js +568 -397
  201. package/node_modules/pi-lens/dist/mcp/worker.js +67 -55
  202. package/node_modules/pi-lens/dist/probes/installer.js +20 -19
  203. package/node_modules/pi-lens/docs/astplayground.md +1 -1
  204. package/node_modules/pi-lens/docs/configuration.md +29 -0
  205. package/node_modules/pi-lens/docs/dependencies.md +3 -0
  206. package/node_modules/pi-lens/docs/features.md +2 -2
  207. package/node_modules/pi-lens/docs/globalconfig.md +2 -0
  208. package/node_modules/pi-lens/docs/language-coverage.md +2 -1
  209. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +29 -7
  210. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +38 -47
  211. package/node_modules/pi-lens/docs/pi-lens-fixer.md +4 -0
  212. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +17 -4
  213. package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -1
  214. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +18 -0
  215. package/node_modules/pi-lens/docs/pi-lens-subagent.md +7 -0
  216. package/node_modules/pi-lens/docs/real-harness.md +17 -0
  217. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +37 -2
  218. package/node_modules/pi-lens/docs/servercapabilities.md +15 -4
  219. package/node_modules/pi-lens/docs/settings.md +2 -1
  220. package/node_modules/pi-lens/package.json +1 -1
  221. package/node_modules/pi-provider-qoder/dist/index.js +30 -2
  222. package/node_modules/pi-provider-qoder/package.json +1 -1
  223. package/node_modules/pi-web-access/CHANGELOG.md +50 -0
  224. package/node_modules/pi-web-access/README.md +13 -7
  225. package/node_modules/pi-web-access/brave.ts +20 -2
  226. package/node_modules/pi-web-access/content-find.ts +2 -1
  227. package/node_modules/pi-web-access/dist/index.js +655 -406
  228. package/node_modules/pi-web-access/dist/mcp-cli.js +653 -416
  229. package/node_modules/pi-web-access/duckduckgo.ts +5 -1
  230. package/node_modules/pi-web-access/endpoint-pdf-extract.ts +225 -0
  231. package/node_modules/pi-web-access/extract.ts +51 -13
  232. package/node_modules/pi-web-access/fetch-params.ts +10 -0
  233. package/node_modules/pi-web-access/gemini-api.ts +15 -0
  234. package/node_modules/pi-web-access/gemini-search.ts +32 -152
  235. package/node_modules/pi-web-access/github-issue-pr.ts +80 -68
  236. package/node_modules/pi-web-access/index.ts +3 -0
  237. package/node_modules/pi-web-access/package.json +1 -1
  238. package/node_modules/pi-web-access/pdf-extract.ts +38 -4
  239. package/node_modules/pi-web-access/perplexity.ts +19 -2
  240. package/node_modules/pi-web-access/ssrf-protection.ts +24 -4
  241. package/node_modules/pi-web-access/summary-review.ts +10 -0
  242. package/node_modules/pi-web-access/tool-arguments.ts +5 -2
  243. package/node_modules/pi-web-access/video-extract.ts +6 -2
  244. package/node_modules/pi-web-access/web-tool-core.ts +53 -13
  245. package/package.json +19 -24
  246. package/node_modules/pi-jev-auto-mode/CHANGELOG.md +0 -118
  247. package/node_modules/pi-jev-auto-mode/LICENSE +0 -21
  248. package/node_modules/pi-jev-auto-mode/README.md +0 -292
  249. package/node_modules/pi-jev-auto-mode/SECURITY.md +0 -32
  250. package/node_modules/pi-jev-auto-mode/docs/calibration.md +0 -154
  251. package/node_modules/pi-jev-auto-mode/docs/design.md +0 -164
  252. package/node_modules/pi-jev-auto-mode/docs/security.md +0 -124
  253. package/node_modules/pi-jev-auto-mode/index.ts +0 -1
  254. package/node_modules/pi-jev-auto-mode/package.json +0 -72
  255. package/node_modules/pi-jev-auto-mode/src/call.ts +0 -180
  256. package/node_modules/pi-jev-auto-mode/src/decide.ts +0 -86
  257. package/node_modules/pi-jev-auto-mode/src/extension.ts +0 -881
  258. package/node_modules/pi-jev-auto-mode/src/intent.ts +0 -71
  259. package/node_modules/pi-jev-auto-mode/src/jev/availability.ts +0 -53
  260. package/node_modules/pi-jev-auto-mode/src/jev/criteria.ts +0 -19
  261. package/node_modules/pi-jev-auto-mode/src/jev/decide.ts +0 -187
  262. package/node_modules/pi-jev-auto-mode/src/jev/engine.ts +0 -165
  263. package/node_modules/pi-jev-auto-mode/src/jev/index.ts +0 -20
  264. package/node_modules/pi-jev-auto-mode/src/jev/questions.ts +0 -273
  265. package/node_modules/pi-jev-auto-mode/src/jev/response.ts +0 -64
  266. package/node_modules/pi-jev-auto-mode/src/jev/state.ts +0 -20
  267. package/node_modules/pi-jev-auto-mode/src/jev/transport.ts +0 -117
  268. package/node_modules/pi-jev-auto-mode/src/jev/types.ts +0 -46
  269. package/node_modules/pi-jev-auto-mode/src/policy.ts +0 -558
  270. package/node_modules/pi-jev-auto-mode/src/records.ts +0 -184
  271. package/node_modules/pi-jev-auto-mode/src/settings.ts +0 -349
  272. package/node_modules/pi-jev-auto-mode/src/ui.ts +0 -243
  273. package/node_modules/pi-lens/dist/chunk-2FQ62SPM.js +0 -83
  274. package/node_modules/pi-lens/dist/chunk-7AXO3ZDF.js +0 -30
  275. package/node_modules/pi-lens/dist/chunk-KMGPUKFD.js +0 -25
  276. package/node_modules/pi-lens/dist/chunk-OZJINN4O.js +0 -84
  277. package/node_modules/pi-lens/dist/chunk-RJFED73B.js +0 -79
  278. package/node_modules/pi-lens/dist/chunk-RTQNRM5X.js +0 -27
  279. package/node_modules/pi-lens/dist/chunk-VGEVL5EQ.js +0 -29
  280. package/node_modules/pi-lens/dist/chunk-WPE5FPGR.js +0 -54
  281. package/node_modules/pi-lens/dist/chunk-Z7QQA2KT.js +0 -27
  282. package/node_modules/resume-from/LICENSE +0 -21
  283. package/node_modules/resume-from/README.md +0 -167
  284. package/node_modules/resume-from/dist/adapters/claude-code/adapter.d.ts +0 -20
  285. package/node_modules/resume-from/dist/adapters/claude-code/adapter.js +0 -59
  286. package/node_modules/resume-from/dist/adapters/claude-code/contract.d.ts +0 -8
  287. package/node_modules/resume-from/dist/adapters/claude-code/contract.js +0 -4
  288. package/node_modules/resume-from/dist/adapters/claude-code/entries.d.ts +0 -30
  289. package/node_modules/resume-from/dist/adapters/claude-code/entries.js +0 -107
  290. package/node_modules/resume-from/dist/adapters/claude-code/index.d.ts +0 -3
  291. package/node_modules/resume-from/dist/adapters/claude-code/index.js +0 -2
  292. package/node_modules/resume-from/dist/adapters/claude-code/layout.d.ts +0 -29
  293. package/node_modules/resume-from/dist/adapters/claude-code/layout.js +0 -80
  294. package/node_modules/resume-from/dist/adapters/claude-code/readback.d.ts +0 -9
  295. package/node_modules/resume-from/dist/adapters/claude-code/readback.js +0 -39
  296. package/node_modules/resume-from/dist/adapters/claude-code/reader.d.ts +0 -40
  297. package/node_modules/resume-from/dist/adapters/claude-code/reader.js +0 -436
  298. package/node_modules/resume-from/dist/adapters/claude-code/redaction.d.ts +0 -26
  299. package/node_modules/resume-from/dist/adapters/claude-code/redaction.js +0 -145
  300. package/node_modules/resume-from/dist/adapters/claude-code/validation.d.ts +0 -4
  301. package/node_modules/resume-from/dist/adapters/claude-code/validation.js +0 -39
  302. package/node_modules/resume-from/dist/adapters/claude-code/writer.d.ts +0 -21
  303. package/node_modules/resume-from/dist/adapters/claude-code/writer.js +0 -306
  304. package/node_modules/resume-from/dist/adapters/codex/contract.d.ts +0 -13
  305. package/node_modules/resume-from/dist/adapters/codex/contract.js +0 -4
  306. package/node_modules/resume-from/dist/adapters/codex/index.d.ts +0 -6
  307. package/node_modules/resume-from/dist/adapters/codex/index.js +0 -43
  308. package/node_modules/resume-from/dist/adapters/codex/read.d.ts +0 -44
  309. package/node_modules/resume-from/dist/adapters/codex/read.js +0 -723
  310. package/node_modules/resume-from/dist/adapters/codex/readback.d.ts +0 -9
  311. package/node_modules/resume-from/dist/adapters/codex/readback.js +0 -47
  312. package/node_modules/resume-from/dist/adapters/codex/redaction.d.ts +0 -26
  313. package/node_modules/resume-from/dist/adapters/codex/redaction.js +0 -145
  314. package/node_modules/resume-from/dist/adapters/codex/rollout.d.ts +0 -115
  315. package/node_modules/resume-from/dist/adapters/codex/rollout.js +0 -269
  316. package/node_modules/resume-from/dist/adapters/codex/validation.d.ts +0 -7
  317. package/node_modules/resume-from/dist/adapters/codex/validation.js +0 -78
  318. package/node_modules/resume-from/dist/adapters/codex/write.d.ts +0 -17
  319. package/node_modules/resume-from/dist/adapters/codex/write.js +0 -141
  320. package/node_modules/resume-from/dist/adapters/contract.d.ts +0 -78
  321. package/node_modules/resume-from/dist/adapters/contract.js +0 -4
  322. package/node_modules/resume-from/dist/adapters/pi/adapter.d.ts +0 -15
  323. package/node_modules/resume-from/dist/adapters/pi/adapter.js +0 -213
  324. package/node_modules/resume-from/dist/adapters/pi/contract.d.ts +0 -24
  325. package/node_modules/resume-from/dist/adapters/pi/contract.js +0 -4
  326. package/node_modules/resume-from/dist/adapters/pi/format.d.ts +0 -162
  327. package/node_modules/resume-from/dist/adapters/pi/format.js +0 -223
  328. package/node_modules/resume-from/dist/adapters/pi/index.d.ts +0 -7
  329. package/node_modules/resume-from/dist/adapters/pi/index.js +0 -10
  330. package/node_modules/resume-from/dist/adapters/pi/parse.d.ts +0 -41
  331. package/node_modules/resume-from/dist/adapters/pi/parse.js +0 -371
  332. package/node_modules/resume-from/dist/adapters/pi/redaction.d.ts +0 -26
  333. package/node_modules/resume-from/dist/adapters/pi/redaction.js +0 -145
  334. package/node_modules/resume-from/dist/adapters/pi/serialize.d.ts +0 -20
  335. package/node_modules/resume-from/dist/adapters/pi/serialize.js +0 -87
  336. package/node_modules/resume-from/dist/adapters/pi/validate.d.ts +0 -14
  337. package/node_modules/resume-from/dist/adapters/pi/validate.js +0 -134
  338. package/node_modules/resume-from/dist/bin.d.ts +0 -35
  339. package/node_modules/resume-from/dist/bin.js +0 -135
  340. package/node_modules/resume-from/dist/contract.d.ts +0 -10
  341. package/node_modules/resume-from/dist/contract.js +0 -4
  342. package/node_modules/resume-from/dist/host/agents.d.ts +0 -29
  343. package/node_modules/resume-from/dist/host/agents.js +0 -20
  344. package/node_modules/resume-from/dist/host/cli/args.d.ts +0 -21
  345. package/node_modules/resume-from/dist/host/cli/args.js +0 -187
  346. package/node_modules/resume-from/dist/host/cli/contract.d.ts +0 -27
  347. package/node_modules/resume-from/dist/host/cli/contract.js +0 -4
  348. package/node_modules/resume-from/dist/host/cli/index.d.ts +0 -2
  349. package/node_modules/resume-from/dist/host/cli/index.js +0 -1
  350. package/node_modules/resume-from/dist/host/cli/presentation.d.ts +0 -2
  351. package/node_modules/resume-from/dist/host/cli/presentation.js +0 -11
  352. package/node_modules/resume-from/dist/host/cli/render.d.ts +0 -3
  353. package/node_modules/resume-from/dist/host/cli/render.js +0 -70
  354. package/node_modules/resume-from/dist/host/cli/runner.d.ts +0 -8
  355. package/node_modules/resume-from/dist/host/cli/runner.js +0 -125
  356. package/node_modules/resume-from/dist/host/contract.d.ts +0 -42
  357. package/node_modules/resume-from/dist/host/contract.js +0 -4
  358. package/node_modules/resume-from/dist/host/entry.d.ts +0 -52
  359. package/node_modules/resume-from/dist/host/entry.js +0 -91
  360. package/node_modules/resume-from/dist/host/index.d.ts +0 -11
  361. package/node_modules/resume-from/dist/host/index.js +0 -10
  362. package/node_modules/resume-from/dist/host/pi-extension/command.d.ts +0 -18
  363. package/node_modules/resume-from/dist/host/pi-extension/command.js +0 -126
  364. package/node_modules/resume-from/dist/host/pi-extension/contract.d.ts +0 -34
  365. package/node_modules/resume-from/dist/host/pi-extension/contract.js +0 -4
  366. package/node_modules/resume-from/dist/host/pi-extension/index.d.ts +0 -6
  367. package/node_modules/resume-from/dist/host/pi-extension/index.js +0 -4
  368. package/node_modules/resume-from/dist/host/pi-extension/picker.d.ts +0 -16
  369. package/node_modules/resume-from/dist/host/pi-extension/picker.js +0 -35
  370. package/node_modules/resume-from/dist/host/pi-extension/presentation.d.ts +0 -2
  371. package/node_modules/resume-from/dist/host/pi-extension/presentation.js +0 -11
  372. package/node_modules/resume-from/dist/host/pi-extension/register.d.ts +0 -25
  373. package/node_modules/resume-from/dist/host/pi-extension/register.js +0 -11
  374. package/node_modules/resume-from/dist/host/pi-extension/ui.d.ts +0 -20
  375. package/node_modules/resume-from/dist/host/pi-extension/ui.js +0 -1
  376. package/node_modules/resume-from/dist/host/profile.d.ts +0 -8
  377. package/node_modules/resume-from/dist/host/profile.js +0 -31
  378. package/node_modules/resume-from/dist/host/registry.d.ts +0 -8
  379. package/node_modules/resume-from/dist/host/registry.js +0 -33
  380. package/node_modules/resume-from/dist/host/wiring.d.ts +0 -41
  381. package/node_modules/resume-from/dist/host/wiring.js +0 -66
  382. package/node_modules/resume-from/dist/import/confirmation.d.ts +0 -9
  383. package/node_modules/resume-from/dist/import/confirmation.js +0 -27
  384. package/node_modules/resume-from/dist/import/contract.d.ts +0 -43
  385. package/node_modules/resume-from/dist/import/contract.js +0 -4
  386. package/node_modules/resume-from/dist/import/discovery/contract.d.ts +0 -63
  387. package/node_modules/resume-from/dist/import/discovery/contract.js +0 -4
  388. package/node_modules/resume-from/dist/import/discovery/errors.d.ts +0 -9
  389. package/node_modules/resume-from/dist/import/discovery/errors.js +0 -12
  390. package/node_modules/resume-from/dist/import/discovery/finder.d.ts +0 -11
  391. package/node_modules/resume-from/dist/import/discovery/finder.js +0 -269
  392. package/node_modules/resume-from/dist/import/discovery/homes.d.ts +0 -23
  393. package/node_modules/resume-from/dist/import/discovery/homes.js +0 -83
  394. package/node_modules/resume-from/dist/import/discovery/index.d.ts +0 -2
  395. package/node_modules/resume-from/dist/import/discovery/index.js +0 -2
  396. package/node_modules/resume-from/dist/import/discovery/ordering.d.ts +0 -3
  397. package/node_modules/resume-from/dist/import/discovery/ordering.js +0 -21
  398. package/node_modules/resume-from/dist/import/errors.d.ts +0 -22
  399. package/node_modules/resume-from/dist/import/errors.js +0 -20
  400. package/node_modules/resume-from/dist/import/index.d.ts +0 -3
  401. package/node_modules/resume-from/dist/import/index.js +0 -5
  402. package/node_modules/resume-from/dist/import/landing/contract.d.ts +0 -44
  403. package/node_modules/resume-from/dist/import/landing/contract.js +0 -4
  404. package/node_modules/resume-from/dist/import/landing/errors.d.ts +0 -15
  405. package/node_modules/resume-from/dist/import/landing/errors.js +0 -15
  406. package/node_modules/resume-from/dist/import/landing/handover.d.ts +0 -5
  407. package/node_modules/resume-from/dist/import/landing/handover.js +0 -12
  408. package/node_modules/resume-from/dist/import/landing/index.d.ts +0 -4
  409. package/node_modules/resume-from/dist/import/landing/index.js +0 -4
  410. package/node_modules/resume-from/dist/import/landing/lander.d.ts +0 -7
  411. package/node_modules/resume-from/dist/import/landing/lander.js +0 -133
  412. package/node_modules/resume-from/dist/import/landing/marker.d.ts +0 -9
  413. package/node_modules/resume-from/dist/import/landing/marker.js +0 -46
  414. package/node_modules/resume-from/dist/import/pipeline.d.ts +0 -28
  415. package/node_modules/resume-from/dist/import/pipeline.js +0 -154
  416. package/node_modules/resume-from/dist/import/preview/builder.d.ts +0 -6
  417. package/node_modules/resume-from/dist/import/preview/builder.js +0 -80
  418. package/node_modules/resume-from/dist/import/preview/contract.d.ts +0 -39
  419. package/node_modules/resume-from/dist/import/preview/contract.js +0 -4
  420. package/node_modules/resume-from/dist/import/preview/format.d.ts +0 -19
  421. package/node_modules/resume-from/dist/import/preview/format.js +0 -45
  422. package/node_modules/resume-from/dist/import/preview/index.d.ts +0 -2
  423. package/node_modules/resume-from/dist/import/preview/index.js +0 -1
  424. package/node_modules/resume-from/dist/import/preview/warnings.d.ts +0 -14
  425. package/node_modules/resume-from/dist/import/preview/warnings.js +0 -86
  426. package/node_modules/resume-from/dist/import/transfer/contract.d.ts +0 -48
  427. package/node_modules/resume-from/dist/import/transfer/contract.js +0 -4
  428. package/node_modules/resume-from/dist/import/transfer/index.d.ts +0 -2
  429. package/node_modules/resume-from/dist/import/transfer/index.js +0 -1
  430. package/node_modules/resume-from/dist/import/transfer/rules.d.ts +0 -3
  431. package/node_modules/resume-from/dist/import/transfer/rules.js +0 -228
  432. package/node_modules/resume-from/dist/import/wiring.d.ts +0 -24
  433. package/node_modules/resume-from/dist/import/wiring.js +0 -37
  434. package/node_modules/resume-from/dist/index.d.ts +0 -36
  435. package/node_modules/resume-from/dist/index.js +0 -36
  436. package/node_modules/resume-from/dist/platform/config/contract.d.ts +0 -35
  437. package/node_modules/resume-from/dist/platform/config/contract.js +0 -4
  438. package/node_modules/resume-from/dist/platform/config/defaults.d.ts +0 -16
  439. package/node_modules/resume-from/dist/platform/config/defaults.js +0 -22
  440. package/node_modules/resume-from/dist/platform/config/errors.d.ts +0 -9
  441. package/node_modules/resume-from/dist/platform/config/errors.js +0 -12
  442. package/node_modules/resume-from/dist/platform/config/index.d.ts +0 -5
  443. package/node_modules/resume-from/dist/platform/config/index.js +0 -6
  444. package/node_modules/resume-from/dist/platform/config/loader.d.ts +0 -10
  445. package/node_modules/resume-from/dist/platform/config/loader.js +0 -47
  446. package/node_modules/resume-from/dist/platform/config/paths.d.ts +0 -13
  447. package/node_modules/resume-from/dist/platform/config/paths.js +0 -37
  448. package/node_modules/resume-from/dist/platform/config/validate.d.ts +0 -9
  449. package/node_modules/resume-from/dist/platform/config/validate.js +0 -117
  450. package/node_modules/resume-from/dist/platform/repo/contract.d.ts +0 -36
  451. package/node_modules/resume-from/dist/platform/repo/contract.js +0 -4
  452. package/node_modules/resume-from/dist/platform/repo/git.d.ts +0 -21
  453. package/node_modules/resume-from/dist/platform/repo/git.js +0 -77
  454. package/node_modules/resume-from/dist/platform/repo/index.d.ts +0 -2
  455. package/node_modules/resume-from/dist/platform/repo/index.js +0 -1
  456. package/node_modules/resume-from/dist/platform/repo/reader.d.ts +0 -3
  457. package/node_modules/resume-from/dist/platform/repo/reader.js +0 -170
  458. package/node_modules/resume-from/dist/platform/store/contract.d.ts +0 -31
  459. package/node_modules/resume-from/dist/platform/store/contract.js +0 -4
  460. package/node_modules/resume-from/dist/platform/store/file-committer.d.ts +0 -3
  461. package/node_modules/resume-from/dist/platform/store/file-committer.js +0 -391
  462. package/node_modules/resume-from/dist/platform/store/index.d.ts +0 -2
  463. package/node_modules/resume-from/dist/platform/store/index.js +0 -2
  464. package/node_modules/resume-from/dist/platform/tokens/contract.d.ts +0 -12
  465. package/node_modules/resume-from/dist/platform/tokens/contract.js +0 -4
  466. package/node_modules/resume-from/dist/platform/tokens/estimator.d.ts +0 -12
  467. package/node_modules/resume-from/dist/platform/tokens/estimator.js +0 -111
  468. package/node_modules/resume-from/dist/platform/tokens/index.d.ts +0 -2
  469. package/node_modules/resume-from/dist/platform/tokens/index.js +0 -1
  470. package/node_modules/resume-from/dist/session/contract.d.ts +0 -116
  471. package/node_modules/resume-from/dist/session/contract.js +0 -4
  472. package/node_modules/resume-from/package.json +0 -83
  473. package/node_modules/resume-from/shims/pi/extensions/resume-from.js +0 -118
@@ -1,881 +0,0 @@
1
- /**
2
- * Jev auto mode for the Pi coding agent.
3
- *
4
- * The gate has two layers, and the order matters:
5
- *
6
- * 1. A deterministic policy layer (hard-deny, user rules, dangerous-pattern
7
- * detection, protected paths). Hard-deny is not negotiable.
8
- * 2. A semantic layer (Jev) that only ever sees calls the deterministic layer
9
- * decided to escalate, and whose "allow" can never resurrect a hard-denied
10
- * call.
11
- *
12
- * Anything the semantic layer cannot decide — timeout, malformed response,
13
- * cancelled request, missing engine — blocks the call. Silence is never consent.
14
- */
15
-
16
- import { existsSync } from "node:fs";
17
- import { join } from "node:path";
18
- import {
19
- CONFIG_DIR_NAME,
20
- getAgentDir,
21
- type ExtensionAPI,
22
- type ExtensionContext,
23
- } from "@earendil-works/pi-coding-agent";
24
- import { buildGatedCall, type GatedCall, type RepoFacts, type ToolCallEventLike } from "./call.ts";
25
- import { createManualEngine, type CandidateInput, type DecisionEngine, type EngineEvidence, type EngineVerdict } from "./decide.ts";
26
- import {
27
- DEFAULT_RULES,
28
- createJevEngine,
29
- createSdkTransport,
30
- describeJevAvailability,
31
- describeKeySource,
32
- formatThreshold,
33
- ruleById,
34
- verifyApiKey,
35
- type JevAvailability,
36
- type Observation,
37
- type ObservationMeta,
38
- } from "./jev/index.ts";
39
- import { extractRecentIntent } from "./intent.ts";
40
- import {
41
- dangerousReasons,
42
- evaluateUserCommandRules,
43
- hardDenyReasons,
44
- isReadOnlyCommandChain,
45
- isUserDeclaredSafeCommand,
46
- PROTECTED_DIRECTORY_SEGMENTS,
47
- unique,
48
- } from "./policy.ts";
49
- import {
50
- createRecorder,
51
- registerDecisionEntryRenderer,
52
- type DecisionRecord,
53
- type DecisionRecorder,
54
- } from "./records.ts";
55
- import {
56
- DEFAULT_SETTINGS,
57
- JevAutoModeStore,
58
- isDisplayMode,
59
- isGateScope,
60
- isUncertainAction,
61
- parseThreshold,
62
- type JevAutoModeSettings,
63
- type SettingsScope,
64
- } from "./settings.ts";
65
- import {
66
- buildConfirmationDialog,
67
- describeSettings,
68
- DISPLAY_EXPLANATION,
69
- GATE_SCOPE_EXPLANATION,
70
- UNCERTAIN_EXPLANATION,
71
- formatRuleTable,
72
- POLICY_HEADER,
73
- statusText,
74
- updateStatus,
75
- USAGE_TEXT,
76
- type ObservedCondition,
77
- } from "./ui.ts";
78
-
79
- export const AUTO_MODE_FLAG = "jev-auto-mode";
80
- export const AUTO_MODE_COMMAND = "jev-auto-mode";
81
-
82
- /** The escalation reason for a call no pattern describes, under `gateScope: "all"`. */
83
- export const NOT_KNOWN_SAFE_REASON = "not on the known-safe list";
84
-
85
- /** The engine used when no semantic layer is available. */
86
- export const MANUAL_ENGINE_ID = "manual";
87
-
88
- /** Shown (and used as the block reason) when the gate has no Jev connection. */
89
- export const NO_ENGINE_MESSAGE =
90
- "Not connected to Jev (no TypeSafe API key is set). Run `/jev-auto-mode login` to set a key, or `/jev-auto-mode off` to stop auto mode.";
91
-
92
- /** Structural context: what this extension needs from Pi, and nothing more. */
93
- export interface GateUi {
94
- notify(message: string, type?: "info" | "warning" | "error"): void;
95
- select(title: string, options: string[]): Promise<string | undefined>;
96
- confirm(title: string, message: string): Promise<boolean>;
97
- input(title: string, placeholder?: string): Promise<string | undefined>;
98
- editor(title: string, prefill?: string): Promise<string | undefined>;
99
- setStatus(key: string, text: string | undefined): void;
100
- }
101
-
102
- export interface GateContext {
103
- readonly cwd: string;
104
- readonly hasUI: boolean;
105
- readonly mode?: string;
106
- readonly sessionManager: { getBranch?: () => readonly unknown[]; getEntries?: () => readonly unknown[] };
107
- readonly ui: GateUi;
108
- readonly signal?: AbortSignal;
109
- isProjectTrusted?(): boolean;
110
- }
111
-
112
- export interface DecisionDeps {
113
- readonly engine: DecisionEngine;
114
- readonly record: DecisionRecorder;
115
- readonly now: () => number;
116
- }
117
-
118
- export interface GateState {
119
- settings: JevAutoModeSettings;
120
- policyNotes: string;
121
- scope: SettingsScope;
122
- }
123
-
124
- export interface BlockResult {
125
- readonly block: true;
126
- readonly reason: string;
127
- }
128
-
129
- export function createInitialState(): GateState {
130
- return { settings: DEFAULT_SETTINGS, policyNotes: "", scope: "global" };
131
- }
132
-
133
- function conversationBranch(ctx: GateContext): readonly unknown[] {
134
- const sessionManager = ctx.sessionManager as {
135
- getBranch?: () => readonly unknown[];
136
- getEntries?: () => readonly unknown[];
137
- };
138
- const branch = sessionManager.getBranch?.() ?? sessionManager.getEntries?.() ?? [];
139
- return Array.isArray(branch) ? branch : [];
140
- }
141
-
142
- export function repoFacts(cwd: string, call?: GatedCall): RepoFacts {
143
- // The concrete protection that triggered escalation is listed alongside the
144
- // configured roots, so a question about protected locations can be answered
145
- // against the actual target rather than a generic path list.
146
- const protectedPaths = unique([
147
- ...PROTECTED_DIRECTORY_SEGMENTS,
148
- ...(call?.protectedReason ? [call.protectedReason] : []),
149
- ]);
150
-
151
- return {
152
- cwd,
153
- isGitRepository: existsSync(join(cwd, ".git")),
154
- protectedPaths,
155
- };
156
- }
157
-
158
- interface RecordInput {
159
- readonly call: GatedCall;
160
- readonly reasons: readonly string[];
161
- readonly status: DecisionRecord["status"];
162
- readonly source: DecisionRecord["source"];
163
- readonly rationale: string;
164
- readonly evidence?: EngineEvidence;
165
- }
166
-
167
- function writeRecord(deps: DecisionDeps, input: RecordInput): void {
168
- const record: DecisionRecord = {
169
- tool: input.call.tool,
170
- summary: input.call.summary,
171
- reasons: [...input.reasons],
172
- status: input.status,
173
- source: input.source,
174
- rationale: input.rationale,
175
- ...(input.evidence?.conditions ? { conditions: input.evidence.conditions } : {}),
176
- ...(input.evidence?.decidingRule ? { decidingRule: input.evidence.decidingRule } : {}),
177
- ...(input.evidence?.clearedByIntent ? { clearedByIntent: input.evidence.clearedByIntent } : {}),
178
- ...(input.evidence?.probabilities ? { probabilities: input.evidence.probabilities } : {}),
179
- ...(input.evidence?.model ? { model: input.evidence.model } : {}),
180
- ...(input.evidence?.latencyMs !== undefined ? { latencyMs: input.evidence.latencyMs } : {}),
181
- timestamp: deps.now(),
182
- };
183
- deps.record(record);
184
- }
185
-
186
- function blocked(deps: DecisionDeps, input: RecordInput, reason?: string): BlockResult {
187
- writeRecord(deps, input);
188
- return { block: true, reason: reason ?? input.rationale };
189
- }
190
-
191
- function permit(deps: DecisionDeps, input: RecordInput): undefined {
192
- writeRecord(deps, input);
193
- return undefined;
194
- }
195
-
196
- /** Wraps an engine rationale so the model gets an actionable reason, not a verdict. */
197
- function blockReason(rationale: string): string {
198
- return `Jev auto mode blocked this tool call. ${rationale} Do not repeat the same call unchanged; change the approach or ask the user.`;
199
- }
200
-
201
- /**
202
- * Decide one tool call.
203
- *
204
- * Exported so the whole policy path can be tested without a Pi runtime.
205
- */
206
- export async function evaluateToolCall(
207
- event: ToolCallEventLike,
208
- ctx: GateContext,
209
- state: GateState,
210
- deps: DecisionDeps,
211
- ): Promise<BlockResult | undefined> {
212
- if (!state.settings.enabled) return undefined;
213
-
214
- const call = buildGatedCall(event, {
215
- cwd: ctx.cwd,
216
- extraProtectedPaths: state.settings.extraProtectedPaths,
217
- });
218
- if (!call) return undefined;
219
-
220
- const ruleConfig = {
221
- allowedCommands: state.settings.allowedCommands,
222
- disallowedCommands: state.settings.disallowedCommands,
223
- };
224
-
225
- let reasons: string[];
226
-
227
- if (call.tool === "bash") {
228
- const command = typeof event.input.command === "string" ? event.input.command : "";
229
-
230
- const hardReasons = hardDenyReasons(command);
231
- if (hardReasons.length > 0) {
232
- const rationale = `Non-negotiable safety rule matched: ${hardReasons.join(", ")}.`;
233
- return blocked(deps, { call, reasons: hardReasons, status: "blocked", source: "hard-deny", rationale });
234
- }
235
-
236
- const userRule = evaluateUserCommandRules(command, ruleConfig);
237
- if (userRule?.decision === "deny") {
238
- const rationale = `A user disallowed command pattern matched: ${userRule.pattern}.`;
239
- return blocked(deps, { call, reasons: [userRule.pattern], status: "blocked", source: "user-rule", rationale });
240
- }
241
- if (userRule?.decision === "allow") {
242
- return permit(deps, {
243
- call,
244
- reasons: [],
245
- status: "allowed",
246
- source: "user-rule",
247
- rationale: `A user allow pattern matched: ${userRule.pattern}.`,
248
- });
249
- }
250
-
251
- // A command the user declared safe is theirs to declare: it runs silently, and
252
- // that declaration also outranks a dangerous-pattern match.
253
- if (isUserDeclaredSafeCommand(command, state.settings.safeCommands)) return undefined;
254
-
255
- // A dangerous pattern is a reason to judge, even when the command looks like
256
- // reading (`grep secret ~/.ssh/...`), so it comes before the read-only fast path.
257
- const matchedReasons = dangerousReasons(command, ctx.cwd);
258
- if (matchedReasons.length > 0) {
259
- reasons = matchedReasons;
260
- } else if (isReadOnlyCommandChain(command)) {
261
- return undefined;
262
- } else if (state.settings.gateScope === "matched") {
263
- return undefined;
264
- } else {
265
- reasons = [NOT_KNOWN_SAFE_REASON];
266
- }
267
- } else {
268
- const protectedReasons = unique(
269
- [call.protectedReason, call.outsideCwd ? "write outside the working directory" : undefined].filter(
270
- (reason): reason is string => typeof reason === "string",
271
- ),
272
- );
273
- if (protectedReasons.length === 0) return undefined;
274
- reasons = protectedReasons;
275
- }
276
-
277
- // Without a key there is nothing to judge with. Say so and stop, rather than
278
- // letting a call through unjudged or blocking it with an unexplained verdict.
279
- if (deps.engine.id === MANUAL_ENGINE_ID) {
280
- const rationale = NO_ENGINE_MESSAGE;
281
- writeRecord(deps, {
282
- call,
283
- reasons,
284
- status: "blocked",
285
- source: "unavailable",
286
- rationale,
287
- });
288
- return { block: true, reason: rationale };
289
- }
290
-
291
- const input: CandidateInput = {
292
- call,
293
- reasons,
294
- // "not on the known-safe list" is the scope's own label, not a recognised danger.
295
- flagged: reasons.some((reason) => reason !== NOT_KNOWN_SAFE_REASON),
296
- intent: extractRecentIntent(conversationBranch(ctx)),
297
- policy: state.policyNotes,
298
- repo: repoFacts(ctx.cwd, call),
299
- };
300
-
301
- let verdict: EngineVerdict;
302
- try {
303
- verdict = await deps.engine.judge(input, { signal: ctx.signal });
304
- } catch {
305
- // An engine that throws is an engine that cannot decide. Fail closed.
306
- verdict = {
307
- verdict: "unavailable",
308
- reason: "engine_error",
309
- rationale: "The decision engine threw an error.",
310
- };
311
- }
312
-
313
- if (ctx.signal?.aborted) {
314
- return blocked(deps, {
315
- call,
316
- reasons,
317
- status: "blocked",
318
- source: "unavailable",
319
- rationale: "The request was cancelled before a decision was reached.",
320
- });
321
- }
322
-
323
- const evidence: EngineEvidence = {
324
- ...(verdict.probabilities ? { probabilities: verdict.probabilities } : {}),
325
- ...(verdict.thresholds ? { thresholds: verdict.thresholds } : {}),
326
- ...(verdict.conditions ? { conditions: verdict.conditions } : {}),
327
- ...(verdict.decidingRule ? { decidingRule: verdict.decidingRule } : {}),
328
- ...(verdict.clearedByIntent ? { clearedByIntent: verdict.clearedByIntent } : {}),
329
- ...(verdict.model ? { model: verdict.model } : {}),
330
- ...(verdict.latencyMs !== undefined ? { latencyMs: verdict.latencyMs } : {}),
331
- };
332
-
333
- switch (verdict.verdict) {
334
- case "allow":
335
- return permit(deps, {
336
- call,
337
- reasons,
338
- status: "allowed",
339
- source: "engine",
340
- rationale: verdict.rationale,
341
- evidence,
342
- });
343
-
344
- case "deny":
345
- return blocked(
346
- deps,
347
- { call, reasons, status: "blocked", source: "engine", rationale: verdict.rationale, evidence },
348
- blockReason(verdict.rationale),
349
- );
350
-
351
- case "unavailable": {
352
- const rationale = `No decision was available (${verdict.reason}): ${verdict.rationale}`;
353
- return blocked(
354
- deps,
355
- { call, reasons, status: "blocked", source: "unavailable", rationale, evidence },
356
- blockReason(rationale),
357
- );
358
- }
359
-
360
- case "uncertain": {
361
- // The middle band is a policy decision, not a prompt by default. An auto mode
362
- // that stops to ask the user has handed the decision back to the human, and
363
- // the agent can always ask in conversation if it needs guidance.
364
- if (state.settings.uncertain === "deny") {
365
- const rationale = `No condition decided the call, and the uncertain band is resolved to a block. ${verdict.rationale}`;
366
- return blocked(deps, {
367
- call,
368
- reasons,
369
- status: "blocked",
370
- source: "uncertain",
371
- rationale,
372
- evidence,
373
- });
374
- }
375
-
376
- if (state.settings.uncertain === "allow") {
377
- return permit(deps, {
378
- call,
379
- reasons,
380
- status: "allowed",
381
- source: "uncertain",
382
- rationale: `No condition was violated and the uncertain band is configured to allow. ${verdict.rationale}`,
383
- evidence,
384
- });
385
- }
386
-
387
- if (!ctx.hasUI) {
388
- const rationale = `${verdict.rationale} No UI is available to confirm, so the call was blocked.`;
389
- return blocked(
390
- deps,
391
- { call, reasons, status: "blocked", source: "no-ui", rationale, evidence },
392
- blockReason(rationale),
393
- );
394
- }
395
-
396
- const dialog = buildConfirmationDialog({
397
- tool: call.tool,
398
- ...(call.command === undefined ? {} : { command: call.command }),
399
- ...(call.path === undefined ? {} : { path: call.path }),
400
- reasons,
401
- rationale: verdict.rationale,
402
- });
403
-
404
- const choice = await ctx.ui.select(dialog, ["No", "Yes"]);
405
- if (choice !== "Yes") {
406
- writeRecord(deps, {
407
- call,
408
- reasons,
409
- status: "cancelled",
410
- source: "user",
411
- rationale: "The user declined the confirmation.",
412
- evidence,
413
- });
414
- return { block: true, reason: "Blocked by the user at the Jev auto mode confirmation." };
415
- }
416
-
417
- return permit(deps, {
418
- call,
419
- reasons,
420
- status: "confirmed",
421
- source: "user",
422
- rationale: "The user confirmed the call.",
423
- evidence,
424
- });
425
- }
426
- }
427
- }
428
-
429
- /**
430
- * Pick a rule, then type a value.
431
- *
432
- * The direct form (`threshold <rule> <value>`) is faster once the rule ids are
433
- * known; this exists so tuning does not require remembering them.
434
- */
435
- async function editThreshold(
436
- ctx: { ui: GateUi },
437
- state: GateState,
438
- observed: ReadonlyMap<string, ObservedCondition>,
439
- save: (ctx: GateContext) => Promise<void>,
440
- rebuild: () => Promise<void>,
441
- ): Promise<void> {
442
- const choices = DEFAULT_RULES.map((rule) => {
443
- const threshold = state.settings.thresholds[rule.id] ?? rule.threshold;
444
- const last = observed.get(rule.id);
445
- return `${rule.id} (t=${threshold}${last ? `, last p=${last.probability.toFixed(2)}` : ""})`;
446
- });
447
-
448
- const picked = await ctx.ui.select("Which condition?", choices);
449
- if (picked === undefined) return;
450
- const ruleId = picked.split(" ")[0] ?? "";
451
- const rule = ruleById(ruleId);
452
- if (!rule) return;
453
-
454
- const current = state.settings.thresholds[ruleId] ?? rule.threshold;
455
- const entered = await ctx.ui.input(`${ruleId}: threshold (0.5-1.0, default ${rule.threshold})`, String(current));
456
- if (entered === undefined) return;
457
-
458
- const threshold = parseThreshold(Number(entered.trim()));
459
- if (threshold === undefined) {
460
- ctx.ui.notify(`A threshold must be greater than 0.5 and at most 1.0 (got \`${entered.trim()}\`).`, "error");
461
- return;
462
- }
463
-
464
- state.settings = { ...state.settings, thresholds: { ...state.settings.thresholds, [ruleId]: threshold } };
465
- await save(ctx as unknown as GateContext);
466
- await rebuild();
467
- ctx.ui.notify(`\`${ruleId}\` now requires p >= ${threshold}`, "info");
468
- }
469
-
470
- export interface RegisterOptions {
471
- /** Override the engine (tests, or a different judgment backend). */
472
- readonly engine?: DecisionEngine;
473
- readonly store?: JevAutoModeStore;
474
- readonly record?: DecisionRecorder;
475
- readonly now?: () => number;
476
- /** Transport override, mainly for tests. */
477
- readonly fetch?: (input: string, init?: RequestInit) => Promise<Response>;
478
- readonly env?: NodeJS.ProcessEnv;
479
- /** Calibration channel: every condition of every judgment. */
480
- readonly onObservation?: (observations: readonly Observation[], meta: ObservationMeta) => void;
481
- }
482
-
483
- /**
484
- * Build the semantic engine for the current settings.
485
- *
486
- * With no key the gate still runs its own rules, but a call nothing vouches for is
487
- * blocked with "Not connected to Jev" rather than judged. A missing key must not
488
- * turn into "allow everything".
489
- */
490
- export function createEngine(
491
- settings: JevAutoModeSettings,
492
- options: RegisterOptions = {},
493
- storedApiKey?: string,
494
- ): DecisionEngine {
495
- if (options.engine) return options.engine;
496
-
497
- const availability = describeJevAvailability(options.env ?? process.env, storedApiKey);
498
- if (!availability.available || !availability.apiKey) return createManualEngine();
499
-
500
- return createJevEngine({
501
- transport: createSdkTransport({
502
- apiKey: availability.apiKey,
503
- timeoutMs: settings.timeoutMs,
504
- maxRetries: settings.maxRetries,
505
- ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
506
- }),
507
- model: availability.model,
508
- maxStateCharacters: settings.maxStateCharacters,
509
- thresholds: settings.thresholds,
510
- ...(options.onObservation === undefined ? {} : { onObservation: options.onObservation }),
511
- });
512
- }
513
-
514
- export function register(pi: ExtensionAPI, options: RegisterOptions = {}): void {
515
- const store =
516
- options.store ?? new JevAutoModeStore({ agentDir: getAgentDir(), configDirName: CONFIG_DIR_NAME });
517
- const state = createInitialState();
518
- const observed = new Map<string, ObservedCondition>();
519
- const now = options.now ?? (() => Date.now());
520
-
521
- // Wrap the calibration channel so the tuning table can show what the model last
522
- // answered for each condition, even when the decision did not depend on it.
523
- const engineOptions: RegisterOptions = {
524
- ...options,
525
- onObservation: (observations, meta) => {
526
- const at = now();
527
- for (const observation of observations) {
528
- observed.set(observation.ruleId, { probability: observation.probability, at });
529
- }
530
- options.onObservation?.(observations, meta);
531
- },
532
- };
533
-
534
- let deps: DecisionDeps = {
535
- engine: createEngine(state.settings, engineOptions),
536
- record: options.record ?? createRecorder(pi),
537
- now,
538
- };
539
- let availability: JevAvailability = describeJevAvailability(options.env ?? process.env);
540
- let loaded = false;
541
-
542
- /** Rebuild the engine from the settings and the currently resolvable key. */
543
- const rebuildEngine = async (): Promise<void> => {
544
- const storedApiKey = await store.readStoredApiKey();
545
- availability = describeJevAvailability(options.env ?? process.env, storedApiKey);
546
- deps = { ...deps, engine: createEngine(state.settings, engineOptions, storedApiKey) };
547
- };
548
-
549
- const refresh = async (ctx: GateContext, applyFlag: boolean): Promise<void> => {
550
- const trusted = ctx.isProjectTrusted?.() ?? false;
551
- const loadedSettings = await store.loadSettings(ctx.cwd, trusted);
552
- state.settings = loadedSettings.settings;
553
- state.scope = loadedSettings.scope;
554
- state.policyNotes = await store.loadPolicyNotes();
555
- if (applyFlag && pi.getFlag(AUTO_MODE_FLAG) === true) {
556
- state.settings = { ...state.settings, enabled: true };
557
- }
558
- await rebuildEngine();
559
- loaded = true;
560
- updateStatus(ctx, { enabled: state.settings.enabled, engineId: deps.engine.id, scope: state.scope });
561
- if (state.settings.enabled && deps.engine.id === MANUAL_ENGINE_ID) {
562
- ctx.ui.notify(NO_ENGINE_MESSAGE, "warning");
563
- }
564
- };
565
-
566
- const save = async (ctx: GateContext): Promise<void> => {
567
- await store.saveSettings(state.settings, "global", ctx.cwd);
568
- };
569
-
570
- pi.registerFlag(AUTO_MODE_FLAG, {
571
- description: "Start with Jev auto mode enabled",
572
- type: "boolean",
573
- default: false,
574
- });
575
-
576
- registerDecisionEntryRenderer(pi, () => state.settings.display);
577
-
578
- pi.registerCommand(AUTO_MODE_COMMAND, {
579
- description: "Show or change the Jev auto mode settings",
580
- getArgumentCompletions: (argumentPrefix) => {
581
- const value = String(argumentPrefix ?? "");
582
- const tokens = value.split(/\s+/).filter(Boolean);
583
- if (tokens.length === 0) {
584
- return ["status", "on", "off", "policy", "threshold", "scope", "uncertain", "display", "login", "logout"].map((item) => ({
585
- value: item,
586
- label: item,
587
- }));
588
- }
589
- if (tokens[0] === "threshold") {
590
- if (tokens.length <= 1) {
591
- return ["reset", ...DEFAULT_RULES.map((rule) => rule.id)]
592
- .filter((item) => item.startsWith(tokens[1] ?? ""))
593
- .map((item) => ({ value: `threshold ${item}`, label: item }));
594
- }
595
- if (tokens.length === 2) {
596
- const rule = ruleById(tokens[1] ?? "");
597
- if (!rule) return null;
598
- return [
599
- { value: `threshold ${rule.id}`, label: `current: ${rule.threshold}` },
600
- { value: `threshold ${rule.id} reset`, label: "reset to the calibrated default" },
601
- ];
602
- }
603
- }
604
- return null;
605
- },
606
- handler: async (args, ctx) => {
607
- const gateContext = toGateContext(ctx);
608
- if (!loaded) await refresh(gateContext, true);
609
-
610
- const value = String(args ?? "").trim();
611
- const status = [
612
- statusText({
613
- enabled: state.settings.enabled,
614
- engineId: deps.engine.id,
615
- scope: state.scope,
616
- }),
617
- "",
618
- describeSettings(state.settings, state.scope),
619
- availability.available
620
- ? `semantic layer: ${availability.model} (key from ${describeKeySource(availability.source)})`
621
- : `semantic layer: unavailable (${availability.reason ?? "unknown reason"})`,
622
- ].join("\n");
623
-
624
- if (value === "" || value === "status") {
625
- ctx.ui.notify(status, "info");
626
- return;
627
- }
628
-
629
- if (value === "on" || value === "off") {
630
- state.settings = { ...state.settings, enabled: value === "on" };
631
- await save(gateContext);
632
- updateStatus(gateContext, {
633
- enabled: state.settings.enabled,
634
- engineId: deps.engine.id,
635
- scope: state.scope,
636
- });
637
- ctx.ui.notify(`Jev auto mode ${value === "on" ? "enabled" : "disabled"}.`, "info");
638
- return;
639
- }
640
-
641
- if (value === "policy") {
642
- ctx.ui.notify(state.policyNotes.trim() || "(no policy notes configured)", "info");
643
- return;
644
- }
645
-
646
- if (value === "policy edit") {
647
- const edited = await ctx.ui.editor("Jev auto mode policy", state.policyNotes || POLICY_HEADER);
648
- if (edited === undefined) return;
649
- await store.savePolicyNotes(edited);
650
- state.policyNotes = await store.loadPolicyNotes();
651
- ctx.ui.notify("Policy notes saved.", "info");
652
- return;
653
- }
654
-
655
- if (value === "policy clear") {
656
- const confirmed = await ctx.ui.confirm(
657
- "Clear Jev auto mode policy notes?",
658
- "The semantic layer will fall back to its built-in criteria.",
659
- );
660
- if (!confirmed) return;
661
- await store.savePolicyNotes("");
662
- state.policyNotes = "";
663
- ctx.ui.notify("Policy notes cleared.", "info");
664
- return;
665
- }
666
-
667
- if (value === "login") {
668
- const entered = await ctx.ui.input("TypeSafe API key", "apikey_...");
669
- const apiKey = entered?.trim();
670
- if (!apiKey) {
671
- ctx.ui.notify("Login cancelled: no key entered.", "info");
672
- return;
673
- }
674
-
675
- const verification = await verifyApiKey({
676
- apiKey,
677
- ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
678
- });
679
- if (!verification.ok && verification.reason === "invalid") {
680
- ctx.ui.notify("The API rejected that key, so nothing was saved. Check the key and try again.", "error");
681
- return;
682
- }
683
- if (!verification.ok) {
684
- ctx.ui.notify(
685
- "Could not reach the TypeSafe API to verify the key, so nothing was saved. Check the connection and try again.",
686
- "error",
687
- );
688
- return;
689
- }
690
-
691
- await store.writeStoredApiKey(apiKey);
692
- await rebuildEngine();
693
- updateStatus(gateContext, {
694
- enabled: state.settings.enabled,
695
- engineId: deps.engine.id,
696
- scope: state.scope,
697
- });
698
- ctx.ui.notify(
699
- `API key verified and stored at ${store.credentialPath()} (mode 600).\n\nSemantic layer: ${availability.model} (key from ${describeKeySource(availability.source)})`,
700
- "info",
701
- );
702
- return;
703
- }
704
-
705
- if (value === "logout") {
706
- const storedApiKey = await store.readStoredApiKey();
707
- if (!storedApiKey) {
708
- ctx.ui.notify("No stored API key to remove.", "info");
709
- return;
710
- }
711
- const confirmed = await ctx.ui.confirm(
712
- "Remove the stored TypeSafe API key?",
713
- availability.source === "env"
714
- ? "It is not in use anyway: TYPESAFE_API_KEY takes precedence."
715
- : "Without a key the gate blocks every call it cannot vouch for, and says why.",
716
- );
717
- if (!confirmed) return;
718
-
719
- await store.deleteStoredApiKey();
720
- await rebuildEngine();
721
- updateStatus(gateContext, {
722
- enabled: state.settings.enabled,
723
- engineId: deps.engine.id,
724
- scope: state.scope,
725
- });
726
- ctx.ui.notify(
727
- availability.available
728
- ? `Stored key removed. Still using ${describeKeySource(availability.source)}.`
729
- : "Stored key removed. The gate will block calls it cannot vouch for until a key is set again.",
730
- "info",
731
- );
732
- return;
733
- }
734
-
735
- if (value === "threshold" || value === "threshold list") { ctx.ui.notify(formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed), "info");
736
- return;
737
- }
738
-
739
- if (value === "threshold edit") {
740
- await editThreshold(ctx, state, observed, save, rebuildEngine);
741
- return;
742
- }
743
-
744
- if (value.startsWith("scope")) {
745
- const argument = value.slice("scope".length).trim();
746
- if (argument === "") {
747
- ctx.ui.notify(`gate scope: ${state.settings.gateScope}\n\n${GATE_SCOPE_EXPLANATION}`, "info");
748
- return;
749
- }
750
- if (!isGateScope(argument)) {
751
- ctx.ui.notify(`Expected one of all, matched.\n\n${GATE_SCOPE_EXPLANATION}`, "error");
752
- return;
753
- }
754
-
755
- state.settings = { ...state.settings, gateScope: argument };
756
- await save(gateContext);
757
- ctx.ui.notify(`gate scope now: ${argument}\n\n${GATE_SCOPE_EXPLANATION}`, "info");
758
- return;
759
- }
760
-
761
- if (value.startsWith("display")) {
762
- const argument = value.slice("display".length).trim();
763
- if (argument === "") {
764
- ctx.ui.notify(`display: ${state.settings.display}\n\n${DISPLAY_EXPLANATION}`, "info");
765
- return;
766
- }
767
- if (!isDisplayMode(argument)) {
768
- ctx.ui.notify(`Expected one of full, compact.\n\n${DISPLAY_EXPLANATION}`, "error");
769
- return;
770
- }
771
-
772
- state.settings = { ...state.settings, display: argument };
773
- await save(gateContext);
774
- ctx.ui.notify(`decision records now display as: ${argument}`, "info");
775
- return;
776
- }
777
-
778
- if (value.startsWith("uncertain")) {
779
- const argument = value.slice("uncertain".length).trim();
780
- if (argument === "") {
781
- ctx.ui.notify(`uncertain: ${state.settings.uncertain}\n\n${UNCERTAIN_EXPLANATION}`, "info");
782
- return;
783
- }
784
- if (!isUncertainAction(argument)) {
785
- ctx.ui.notify(`Expected one of deny, ask, allow.\n\n${UNCERTAIN_EXPLANATION}`, "error");
786
- return;
787
- }
788
-
789
- state.settings = { ...state.settings, uncertain: argument };
790
- await save(gateContext);
791
- ctx.ui.notify(`uncertain band now resolves to: ${argument}\n\n${UNCERTAIN_EXPLANATION}`, "info");
792
- return;
793
- }
794
-
795
- const thresholdMatch = /^threshold\s+(\S+)(?:\s+(\S+))?$/.exec(value);
796
- if (thresholdMatch) {
797
- const ruleId = thresholdMatch[1] ?? "";
798
- const argument = thresholdMatch[2];
799
-
800
- if (ruleId === "reset" || argument === "reset") {
801
- const target = ruleId === "reset" ? argument : ruleId;
802
- const thresholds = { ...state.settings.thresholds };
803
- if (target && target !== "reset") {
804
- if (!ruleById(target)) {
805
- ctx.ui.notify(`Unknown rule \`${target}\`.\n\n${formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed)}`, "warning");
806
- return;
807
- }
808
- delete thresholds[target];
809
- } else {
810
- for (const key of Object.keys(thresholds)) delete thresholds[key];
811
- }
812
- state.settings = { ...state.settings, thresholds };
813
- await save(gateContext);
814
- await rebuildEngine();
815
- ctx.ui.notify(
816
- `Threshold overrides cleared${target && target !== "reset" ? ` for \`${target}\`` : ""}.\n\n${formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed)}`,
817
- "info",
818
- );
819
- return;
820
- }
821
-
822
- const rule = ruleById(ruleId);
823
- if (!rule) {
824
- ctx.ui.notify(`Unknown rule \`${ruleId}\`.\n\n${formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed)}`, "warning");
825
- return;
826
- }
827
-
828
- if (argument === undefined) {
829
- ctx.ui.notify(formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed), "info");
830
- return;
831
- }
832
-
833
- const threshold = parseThreshold(Number(argument));
834
- if (threshold === undefined) {
835
- ctx.ui.notify(`A threshold must be greater than 0.5 and at most 1.0 (got \`${argument}\`).`, "error");
836
- return;
837
- }
838
-
839
- state.settings = {
840
- ...state.settings,
841
- thresholds: { ...state.settings.thresholds, [ruleId]: threshold },
842
- };
843
- await save(gateContext);
844
- await rebuildEngine();
845
- ctx.ui.notify(
846
- `\`${ruleId}\` now requires p >= ${formatThreshold(threshold)} (rejecting at p <= ${formatThreshold(1 - threshold)}).\n\n${formatRuleTable(DEFAULT_RULES, state.settings.thresholds, observed)}`,
847
- "info",
848
- );
849
- return;
850
- }
851
-
852
- ctx.ui.notify(USAGE_TEXT, "warning");
853
- },
854
- });
855
-
856
- pi.on("session_start", async (_event, ctx) => {
857
- await refresh(toGateContext(ctx), true);
858
- });
859
-
860
- pi.on("tool_call", async (event, ctx) => {
861
- const gateContext = toGateContext(ctx);
862
- if (!loaded) await refresh(gateContext, false);
863
- return evaluateToolCall(event as ToolCallEventLike, gateContext, state, deps);
864
- });
865
- }
866
-
867
- function toGateContext(ctx: ExtensionContext): GateContext {
868
- return {
869
- cwd: ctx.cwd,
870
- hasUI: ctx.hasUI,
871
- mode: ctx.mode,
872
- sessionManager: ctx.sessionManager,
873
- ui: ctx.ui,
874
- signal: ctx.signal,
875
- isProjectTrusted: () => ctx.isProjectTrusted(),
876
- };
877
- }
878
-
879
- export default function jevAutoMode(pi: ExtensionAPI): void {
880
- register(pi);
881
- }