@ashx-j/lunr 0.2.17 → 0.2.18
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.
- package/CHANGELOG.md +19 -1
- package/README.md +2 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +44 -19
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +2 -2
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +8 -11
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +2 -1
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +4 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +172 -171
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +50 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +131 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts +7 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +211 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +0 -5
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +0 -202
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +276 -109
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +4 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +10 -3
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +33 -8
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +2 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +68 -15
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +72 -31
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +105 -54
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.js +82 -65
- package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +2 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +259 -168
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts +18 -0
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js +19 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +6 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +17 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -0
- package/dist/cli-runtime.d.ts +3 -0
- package/dist/cli-runtime.d.ts.map +1 -0
- package/dist/cli-runtime.js +72 -0
- package/dist/cli-runtime.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -60
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/host-static.d.ts.map +1 -1
- package/dist/core/extensions/host-static.js +34 -12
- package/dist/core/extensions/host-static.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -2
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -64
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/timings.d.ts +2 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +17 -2
- package/dist/core/timings.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +6 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +23 -6
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +3 -1
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/injected-context.d.ts +2 -0
- package/dist/modes/interactive/injected-context.d.ts.map +1 -0
- package/dist/modes/interactive/injected-context.js +7 -0
- package/dist/modes/interactive/injected-context.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +32 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/thinking-level-slash.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-slash.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-slash.js +23 -0
- package/dist/modes/interactive/thinking-level-slash.js.map +1 -0
- package/dist/node-runtime/agent-session-services-35WNVGMR.js +36 -0
- package/dist/node-runtime/benchmark-request-UC7PD3V3.js +57 -0
- package/dist/node-runtime/brave-UWDA3I22.js +143 -0
- package/dist/node-runtime/builtin-extensions-QATGXENO.js +28 -0
- package/dist/node-runtime/chunk-2SJB2AWP.js +47 -0
- package/dist/node-runtime/chunk-3NMWLTPV.js +64 -0
- package/dist/node-runtime/chunk-3WFAEVKS.js +115 -0
- package/dist/node-runtime/chunk-3X3KZKMI.js +49 -0
- package/dist/node-runtime/chunk-4CSFRBCN.js +7558 -0
- package/dist/node-runtime/chunk-4DJ6HEGH.js +296 -0
- package/dist/node-runtime/chunk-4HXHDDCF.js +16 -0
- package/dist/node-runtime/chunk-4I23VTC4.js +429 -0
- package/dist/node-runtime/chunk-4TLO4PO2.js +3427 -0
- package/dist/node-runtime/chunk-4ZWGEEAS.js +69 -0
- package/dist/node-runtime/chunk-53YJI7JU.js +137 -0
- package/dist/node-runtime/chunk-5EFIU3OM.js +295 -0
- package/dist/node-runtime/chunk-6BEIBLQ3.js +53 -0
- package/dist/node-runtime/chunk-6KDIOJL3.js +72 -0
- package/dist/node-runtime/chunk-7N3YHTYF.js +26 -0
- package/dist/node-runtime/chunk-7NBZ5P7I.js +24 -0
- package/dist/node-runtime/chunk-AD6VXAO7.js +342 -0
- package/dist/node-runtime/chunk-ARC4KOTI.js +11178 -0
- package/dist/node-runtime/chunk-AROOY4BB.js +173 -0
- package/dist/node-runtime/chunk-ATGA2WLC.js +5646 -0
- package/dist/node-runtime/chunk-AUXVGBO4.js +19 -0
- package/dist/node-runtime/chunk-AY6CAJSL.js +30 -0
- package/dist/node-runtime/chunk-BHO7O6E5.js +296 -0
- package/dist/node-runtime/chunk-BI3DHYCN.js +8845 -0
- package/dist/node-runtime/chunk-BOHIDQT4.js +21 -0
- package/dist/node-runtime/chunk-BRJX2PRC.js +53 -0
- package/dist/node-runtime/chunk-CBGB57XT.js +20211 -0
- package/dist/node-runtime/chunk-CCZJ3PYY.js +17 -0
- package/dist/node-runtime/chunk-CGBXPL3E.js +1171 -0
- package/dist/node-runtime/chunk-CJECDQKP.js +19 -0
- package/dist/node-runtime/chunk-CSFI6YXL.js +130 -0
- package/dist/node-runtime/chunk-DAPBPCBP.js +53 -0
- package/dist/node-runtime/chunk-DDWHZ633.js +37 -0
- package/dist/node-runtime/chunk-DMMTJQMQ.js +43 -0
- package/dist/node-runtime/chunk-DVGWF6A2.js +1180 -0
- package/dist/node-runtime/chunk-EBF6COVM.js +1734 -0
- package/dist/node-runtime/chunk-FQMM2EZ2.js +248 -0
- package/dist/node-runtime/chunk-FVDOXRUD.js +96 -0
- package/dist/node-runtime/chunk-G4P75AIS.js +9471 -0
- package/dist/node-runtime/chunk-G6LRAP36.js +105 -0
- package/dist/node-runtime/chunk-GKLEQ3I4.js +860 -0
- package/dist/node-runtime/chunk-H2EOZYMP.js +57 -0
- package/dist/node-runtime/chunk-HQCKFM2O.js +56 -0
- package/dist/node-runtime/chunk-HYHJIRDW.js +19 -0
- package/dist/node-runtime/chunk-I6R76AG7.js +22 -0
- package/dist/node-runtime/chunk-IRPJXI6U.js +1269 -0
- package/dist/node-runtime/chunk-J26TSGDL.js +633 -0
- package/dist/node-runtime/chunk-JZQ7F36T.js +610 -0
- package/dist/node-runtime/chunk-KBKMCJDU.js +126 -0
- package/dist/node-runtime/chunk-KWA4OC2J.js +100 -0
- package/dist/node-runtime/chunk-M3LZLQW2.js +98 -0
- package/dist/node-runtime/chunk-MCUNIRD5.js +8388 -0
- package/dist/node-runtime/chunk-NI6OTSBH.js +966 -0
- package/dist/node-runtime/chunk-NUIFPZWX.js +209 -0
- package/dist/node-runtime/chunk-OBMWP3I5.js +68 -0
- package/dist/node-runtime/chunk-OCVIXVTZ.js +88 -0
- package/dist/node-runtime/chunk-OPEK5RRY.js +466 -0
- package/dist/node-runtime/chunk-OR4L3IB2.js +42 -0
- package/dist/node-runtime/chunk-PL6JKXWI.js +3622 -0
- package/dist/node-runtime/chunk-PNJSG3IZ.js +807 -0
- package/dist/node-runtime/chunk-PVCDKGR6.js +55 -0
- package/dist/node-runtime/chunk-Q4Q6D4IY.js +364 -0
- package/dist/node-runtime/chunk-Q5ZU2VRT.js +83 -0
- package/dist/node-runtime/chunk-QFWG2RVL.js +5477 -0
- package/dist/node-runtime/chunk-QZMODZQ2.js +305 -0
- package/dist/node-runtime/chunk-R5EDISSV.js +375 -0
- package/dist/node-runtime/chunk-RNBHABBA.js +986 -0
- package/dist/node-runtime/chunk-RQ2Q5IYR.js +72 -0
- package/dist/node-runtime/chunk-RRIZE6QQ.js +17 -0
- package/dist/node-runtime/chunk-SN6G4OU6.js +4753 -0
- package/dist/node-runtime/chunk-STERBGUB.js +949 -0
- package/dist/node-runtime/chunk-UWQYRSYQ.js +8973 -0
- package/dist/node-runtime/chunk-VRB2IYGG.js +53 -0
- package/dist/node-runtime/chunk-VSELYKWU.js +772 -0
- package/dist/node-runtime/chunk-W3CVH5RX.js +62 -0
- package/dist/node-runtime/chunk-WJVFOIB5.js +24921 -0
- package/dist/node-runtime/chunk-WKDK4C5P.js +2834 -0
- package/dist/node-runtime/chunk-XATUM2HK.js +46 -0
- package/dist/node-runtime/chunk-XBWPBZBN.js +125 -0
- package/dist/node-runtime/chunk-XTHQ7XR7.js +509 -0
- package/dist/node-runtime/chunk-ZBV7FAHG.js +1345 -0
- package/dist/node-runtime/cli-runtime.js +80 -0
- package/dist/node-runtime/clipboard-OZ63BBC6.js +12 -0
- package/dist/node-runtime/clipboard-image-7QR6GXVA.js +13 -0
- package/dist/node-runtime/command-AAV3YRR5.js +13 -0
- package/dist/node-runtime/commands-MV5KOZ64.js +291 -0
- package/dist/node-runtime/config-QDD5PUE2.js +73 -0
- package/dist/node-runtime/curator-server-XCM43VEF.js +3816 -0
- package/dist/node-runtime/customize-XEXL2DGQ.js +12 -0
- package/dist/node-runtime/direct-tool-executor-BK7CLEBX.js +188 -0
- package/dist/node-runtime/exa-LL64QZR2.js +329 -0
- package/dist/node-runtime/export-html-TEXVV5RP.js +150 -0
- package/dist/node-runtime/extension-input-O4HSAEM4.js +14 -0
- package/dist/node-runtime/extension-selector-X5FCX43D.js +14 -0
- package/dist/node-runtime/extract-XLQSJN4V.js +17 -0
- package/dist/node-runtime/file-sync-HCOP2QVF.js +117 -0
- package/dist/node-runtime/gateway-OAC4OBBL.js +2137 -0
- package/dist/node-runtime/gemini-api-QE7ANVDZ.js +29 -0
- package/dist/node-runtime/gemini-search-U7SUMPQA.js +330 -0
- package/dist/node-runtime/gemini-url-context-PXWCBQHK.js +103 -0
- package/dist/node-runtime/gemini-web-MM446SEH.js +14 -0
- package/dist/node-runtime/github-extract-F64RZOEA.js +619 -0
- package/dist/node-runtime/goal-NJEE5CTU.js +1831 -0
- package/dist/node-runtime/index.js +859 -0
- package/dist/node-runtime/init-3C7Z24OI.js +28 -0
- package/dist/node-runtime/install-cli-EXMJQESX.js +308 -0
- package/dist/node-runtime/interactive-mode-2SZUO53H.js +56 -0
- package/dist/node-runtime/interactive-view-S6J3QHEF.js +247 -0
- package/dist/node-runtime/lsp-manager-3ASUSO4T.js +1104 -0
- package/dist/node-runtime/lunr-cron-AUUYP4N4.js +272 -0
- package/dist/node-runtime/main.js +54 -0
- package/dist/node-runtime/mcp-auth-flow-QIXHW6QN.js +32 -0
- package/dist/node-runtime/mcp-panel-IIGMXQGP.js +501 -0
- package/dist/node-runtime/mcp-setup-panel-FEK7663I.js +355 -0
- package/dist/node-runtime/memory-cap-3S4XRLNP.js +20 -0
- package/dist/node-runtime/model-tiers-NJLHUEGK.js +20 -0
- package/dist/node-runtime/openai-search-B3MSNCQA.js +288 -0
- package/dist/node-runtime/package-manager-cli-7RKSZGEN.js +749 -0
- package/dist/node-runtime/parallel-AI2MNSCU.js +265 -0
- package/dist/node-runtime/parser-manager-TQHWYDH7.js +152 -0
- package/dist/node-runtime/pdf-extract-IPE6H4HP.js +57 -0
- package/dist/node-runtime/perplexity-QVJW3I35.js +12 -0
- package/dist/node-runtime/pi-intercom-EEMBGQID.js +2215 -0
- package/dist/node-runtime/pi-mcp-adapter-GUFZWW54.js +428 -0
- package/dist/node-runtime/pi-ollama-cloud-2F3Y2QNM.js +1440 -0
- package/dist/node-runtime/pi-prompt-template-model-QWTCGLJU.js +3946 -0
- package/dist/node-runtime/pi-subagents-7YJ3I4VE.js +6048 -0
- package/dist/node-runtime/pi-web-access-2CQGFLT2.js +1867 -0
- package/dist/node-runtime/print-mode-XSFM26EL.js +12 -0
- package/dist/node-runtime/proxy-modes-V6YVFH3C.js +685 -0
- package/dist/node-runtime/rpc-entry.js +62 -0
- package/dist/node-runtime/rpc-mode-W5ZTLTMZ.js +13 -0
- package/dist/node-runtime/runtime-bridges-3RKBDLNA.js +14 -0
- package/dist/node-runtime/session-manager-E7AREDTV.js +33 -0
- package/dist/node-runtime/session-selector-FJ7M2AIX.js +14 -0
- package/dist/node-runtime/settings-manager-GHPTUN7R.js +21 -0
- package/dist/node-runtime/src-BPQFJR76.js +2427 -0
- package/dist/node-runtime/subagent-executor-5Q5A4HJ2.js +8499 -0
- package/dist/node-runtime/summary-review-YSMXKITO.js +228 -0
- package/dist/node-runtime/tavily-WEZFVFP7.js +154 -0
- package/dist/node-runtime/timings-UAD5BEAS.js +16 -0
- package/dist/node-runtime/tool-renderer-MV5O452K.js +204 -0
- package/dist/node-runtime/update-cli-L3JIBH2U.js +70 -0
- package/dist/node-runtime/v4-5MNC3H7G.js +424 -0
- package/dist/node-runtime/video-extract-OYT5WKS5.js +304 -0
- package/dist/node-runtime/workspace-index-6DBXSTJ6.js +163 -0
- package/dist/node-runtime/youtube-extract-TQYKGFGS.js +264 -0
- package/dist/rpc.d.ts +3 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -0
- package/dist/startup/benchmark-request.d.ts +3 -0
- package/dist/startup/benchmark-request.d.ts.map +1 -0
- package/dist/startup/benchmark-request.js +65 -0
- package/dist/startup/benchmark-request.js.map +1 -0
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +1 -2
- package/dist/startup/interactive-view.js.map +1 -1
- package/dist/startup/startup-milestones.d.ts +1 -1
- package/dist/startup/startup-milestones.d.ts.map +1 -1
- package/dist/startup/startup-milestones.js.map +1 -1
- package/dist/utils/await-with-abort.d.ts +2 -0
- package/dist/utils/await-with-abort.d.ts.map +1 -0
- package/dist/utils/await-with-abort.js +19 -0
- package/dist/utils/await-with-abort.js.map +1 -0
- package/docs/development.md +5 -1
- package/docs/features.md +2 -2
- package/docs/interactive-startup.md +95 -48
- package/docs/keybindings.md +2 -2
- package/docs/terminal-setup.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
lightBuiltinExtensions,
|
|
4
|
+
loadAllBuiltinExtensions
|
|
5
|
+
} from "./chunk-ZBV7FAHG.js";
|
|
6
|
+
import {
|
|
7
|
+
createProjectTrustContext,
|
|
8
|
+
createStartupTui,
|
|
9
|
+
resolveProjectTrusted,
|
|
10
|
+
shouldRunFirstTimeSetup,
|
|
11
|
+
showFirstTimeSetup,
|
|
12
|
+
showStartupSelector,
|
|
13
|
+
startStartupTui
|
|
14
|
+
} from "./chunk-4DJ6HEGH.js";
|
|
15
|
+
import {
|
|
16
|
+
ProjectTrustStore,
|
|
17
|
+
hasTrustRequiringProjectResources
|
|
18
|
+
} from "./chunk-AROOY4BB.js";
|
|
19
|
+
import {
|
|
20
|
+
applyInheritedSubagentPermissions
|
|
21
|
+
} from "./chunk-XATUM2HK.js";
|
|
22
|
+
import {
|
|
23
|
+
MissingSessionCwdError,
|
|
24
|
+
createAgentSessionFromServices,
|
|
25
|
+
createAgentSessionRuntime,
|
|
26
|
+
createAgentSessionServices,
|
|
27
|
+
formatMissingSessionCwdPrompt,
|
|
28
|
+
formatNoModelsAvailableMessage,
|
|
29
|
+
getMissingSessionCwdIssue
|
|
30
|
+
} from "./chunk-ATGA2WLC.js";
|
|
31
|
+
import {
|
|
32
|
+
resolveCliModel,
|
|
33
|
+
resolveModelScope
|
|
34
|
+
} from "./chunk-STERBGUB.js";
|
|
35
|
+
import {
|
|
36
|
+
restoreStdout,
|
|
37
|
+
takeOverStdout
|
|
38
|
+
} from "./chunk-OBMWP3I5.js";
|
|
39
|
+
import {
|
|
40
|
+
detectSupportedImageMimeTypeFromFile,
|
|
41
|
+
resolveReadPath
|
|
42
|
+
} from "./chunk-WKDK4C5P.js";
|
|
43
|
+
import {
|
|
44
|
+
SettingsManager,
|
|
45
|
+
applyHttpProxySettings,
|
|
46
|
+
configureHttpDispatcher
|
|
47
|
+
} from "./chunk-CBGB57XT.js";
|
|
48
|
+
import {
|
|
49
|
+
SessionManager,
|
|
50
|
+
assertValidSessionId
|
|
51
|
+
} from "./chunk-GKLEQ3I4.js";
|
|
52
|
+
import {
|
|
53
|
+
bindRuntimeBridges
|
|
54
|
+
} from "./chunk-3NMWLTPV.js";
|
|
55
|
+
import {
|
|
56
|
+
registerModelTierBridge
|
|
57
|
+
} from "./chunk-W3CVH5RX.js";
|
|
58
|
+
import {
|
|
59
|
+
processImage
|
|
60
|
+
} from "./chunk-AD6VXAO7.js";
|
|
61
|
+
import {
|
|
62
|
+
migrateLegacyGlobalInstructions
|
|
63
|
+
} from "./chunk-M3LZLQW2.js";
|
|
64
|
+
import {
|
|
65
|
+
printTimings,
|
|
66
|
+
resetTimings,
|
|
67
|
+
time
|
|
68
|
+
} from "./chunk-PVCDKGR6.js";
|
|
69
|
+
import {
|
|
70
|
+
registerCustomizeBridge
|
|
71
|
+
} from "./chunk-HQCKFM2O.js";
|
|
72
|
+
import {
|
|
73
|
+
registerMemoryCapBridge
|
|
74
|
+
} from "./chunk-AY6CAJSL.js";
|
|
75
|
+
import {
|
|
76
|
+
parseArgs,
|
|
77
|
+
printHelp
|
|
78
|
+
} from "./chunk-QZMODZQ2.js";
|
|
79
|
+
import {
|
|
80
|
+
markStartupMilestone
|
|
81
|
+
} from "./chunk-CCZJ3PYY.js";
|
|
82
|
+
import {
|
|
83
|
+
SessionSelectorComponent
|
|
84
|
+
} from "./chunk-JZQ7F36T.js";
|
|
85
|
+
import {
|
|
86
|
+
KeybindingsManager,
|
|
87
|
+
migrateKeybindingsConfig
|
|
88
|
+
} from "./chunk-5EFIU3OM.js";
|
|
89
|
+
import {
|
|
90
|
+
initTheme,
|
|
91
|
+
stopThemeWatcher
|
|
92
|
+
} from "./chunk-RNBHABBA.js";
|
|
93
|
+
import {
|
|
94
|
+
APP_NAME,
|
|
95
|
+
CONFIG_DIR_NAME,
|
|
96
|
+
ENV_SESSION_DIR,
|
|
97
|
+
VERSION,
|
|
98
|
+
appendDebugLog,
|
|
99
|
+
expandTildePath,
|
|
100
|
+
getAgentDir,
|
|
101
|
+
getBinDir,
|
|
102
|
+
getSessionsDir,
|
|
103
|
+
isLocalPath,
|
|
104
|
+
normalizePath,
|
|
105
|
+
resolvePath
|
|
106
|
+
} from "./chunk-FQMM2EZ2.js";
|
|
107
|
+
|
|
108
|
+
// packages/coding-agent/dist/main.js
|
|
109
|
+
import { createInterface } from "node:readline";
|
|
110
|
+
import { modelsAreEqual } from "@ashx-j/lunr-ai";
|
|
111
|
+
import chalk4 from "chalk";
|
|
112
|
+
|
|
113
|
+
// packages/coding-agent/dist/cli/file-processor.js
|
|
114
|
+
import { access, readFile, stat } from "node:fs/promises";
|
|
115
|
+
import chalk from "chalk";
|
|
116
|
+
import { resolve } from "path";
|
|
117
|
+
async function processFileArguments(fileArgs, options) {
|
|
118
|
+
let autoResizeImages = options?.autoResizeImages ?? !0, text = "", images = [];
|
|
119
|
+
for (let fileArg of fileArgs) {
|
|
120
|
+
let absolutePath = resolve(resolveReadPath(fileArg, process.cwd()));
|
|
121
|
+
try {
|
|
122
|
+
await access(absolutePath);
|
|
123
|
+
} catch {
|
|
124
|
+
console.error(chalk.red(`Error: File not found: ${absolutePath}`)), process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
if ((await stat(absolutePath)).size === 0)
|
|
127
|
+
continue;
|
|
128
|
+
let mimeType = await detectSupportedImageMimeTypeFromFile(absolutePath);
|
|
129
|
+
if (mimeType) {
|
|
130
|
+
let content = await readFile(absolutePath), processed = await processImage(content, mimeType, { autoResizeImages });
|
|
131
|
+
if (!processed.ok) {
|
|
132
|
+
text += `<file name="${absolutePath}">${processed.message}</file>
|
|
133
|
+
`;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
let attachment = {
|
|
137
|
+
type: "image",
|
|
138
|
+
mimeType: processed.mimeType,
|
|
139
|
+
data: processed.data
|
|
140
|
+
};
|
|
141
|
+
images.push(attachment), processed.hints.length > 0 ? text += `<file name="${absolutePath}">${processed.hints.join(`
|
|
142
|
+
`)}</file>
|
|
143
|
+
` : text += `<file name="${absolutePath}"></file>
|
|
144
|
+
`;
|
|
145
|
+
} else
|
|
146
|
+
try {
|
|
147
|
+
let content = await readFile(absolutePath, "utf-8");
|
|
148
|
+
text += `<file name="${absolutePath}">
|
|
149
|
+
${content}
|
|
150
|
+
</file>
|
|
151
|
+
`;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
154
|
+
console.error(chalk.red(`Error: Could not read file ${absolutePath}: ${message}`)), process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { text, images };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// packages/coding-agent/dist/cli/initial-message.js
|
|
161
|
+
function buildInitialMessage({ parsed, fileText, fileImages, stdinContent }) {
|
|
162
|
+
let parts = [];
|
|
163
|
+
return stdinContent !== void 0 && parts.push(stdinContent), fileText && parts.push(fileText), parsed.messages.length > 0 && (parts.push(parsed.messages[0]), parsed.messages.shift()), {
|
|
164
|
+
initialMessage: parts.length > 0 ? parts.join("") : void 0,
|
|
165
|
+
initialImages: fileImages && fileImages.length > 0 ? fileImages : void 0
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// packages/coding-agent/dist/cli/list-models.js
|
|
170
|
+
import { fuzzyFilter } from "@ashx-j/lunr-tui";
|
|
171
|
+
import chalk2 from "chalk";
|
|
172
|
+
function formatTokenCount(count) {
|
|
173
|
+
if (count >= 1e6) {
|
|
174
|
+
let millions = count / 1e6;
|
|
175
|
+
return millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;
|
|
176
|
+
}
|
|
177
|
+
if (count >= 1e3) {
|
|
178
|
+
let thousands = count / 1e3;
|
|
179
|
+
return thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;
|
|
180
|
+
}
|
|
181
|
+
return count.toString();
|
|
182
|
+
}
|
|
183
|
+
async function listModels(modelRuntime, searchPattern) {
|
|
184
|
+
await modelRuntime.refreshIfStale();
|
|
185
|
+
let loadError = modelRuntime.getError();
|
|
186
|
+
loadError && console.error(chalk2.yellow(`Warning: errors loading models.json:
|
|
187
|
+
${loadError}`));
|
|
188
|
+
let models = [...await modelRuntime.getAvailable()];
|
|
189
|
+
if (models.length === 0) {
|
|
190
|
+
console.log(formatNoModelsAvailableMessage());
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
let filteredModels = models;
|
|
194
|
+
if (searchPattern && (filteredModels = fuzzyFilter(models, searchPattern, (m) => `${m.provider} ${m.id}`)), filteredModels.length === 0) {
|
|
195
|
+
console.log(`No models matching "${searchPattern}"`);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
filteredModels.sort((a, b) => {
|
|
199
|
+
let providerCmp = a.provider.localeCompare(b.provider);
|
|
200
|
+
return providerCmp !== 0 ? providerCmp : a.id.localeCompare(b.id);
|
|
201
|
+
});
|
|
202
|
+
let rows = filteredModels.map((m) => ({
|
|
203
|
+
provider: m.provider,
|
|
204
|
+
model: m.id,
|
|
205
|
+
context: formatTokenCount(m.contextWindow),
|
|
206
|
+
maxOut: formatTokenCount(m.maxTokens),
|
|
207
|
+
thinking: m.reasoning ? "yes" : "no",
|
|
208
|
+
images: m.input.includes("image") ? "yes" : "no"
|
|
209
|
+
})), headers = {
|
|
210
|
+
provider: "provider",
|
|
211
|
+
model: "model",
|
|
212
|
+
context: "context",
|
|
213
|
+
maxOut: "max-out",
|
|
214
|
+
thinking: "thinking",
|
|
215
|
+
images: "images"
|
|
216
|
+
}, widths = {
|
|
217
|
+
provider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),
|
|
218
|
+
model: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),
|
|
219
|
+
context: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),
|
|
220
|
+
maxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),
|
|
221
|
+
thinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),
|
|
222
|
+
images: Math.max(headers.images.length, ...rows.map((r) => r.images.length))
|
|
223
|
+
}, headerLine = [
|
|
224
|
+
headers.provider.padEnd(widths.provider),
|
|
225
|
+
headers.model.padEnd(widths.model),
|
|
226
|
+
headers.context.padEnd(widths.context),
|
|
227
|
+
headers.maxOut.padEnd(widths.maxOut),
|
|
228
|
+
headers.thinking.padEnd(widths.thinking),
|
|
229
|
+
headers.images.padEnd(widths.images)
|
|
230
|
+
].join(" ");
|
|
231
|
+
console.log(headerLine);
|
|
232
|
+
for (let row of rows) {
|
|
233
|
+
let line = [
|
|
234
|
+
row.provider.padEnd(widths.provider),
|
|
235
|
+
row.model.padEnd(widths.model),
|
|
236
|
+
row.context.padEnd(widths.context),
|
|
237
|
+
row.maxOut.padEnd(widths.maxOut),
|
|
238
|
+
row.thinking.padEnd(widths.thinking),
|
|
239
|
+
row.images.padEnd(widths.images)
|
|
240
|
+
].join(" ");
|
|
241
|
+
console.log(line);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// packages/coding-agent/dist/cli/session-picker.js
|
|
246
|
+
import { setKeybindings } from "@ashx-j/lunr-tui";
|
|
247
|
+
async function selectSession(currentSessionsLoader, allSessionsLoader, settingsManager) {
|
|
248
|
+
let ui = await createStartupTui(settingsManager);
|
|
249
|
+
return new Promise((resolve3) => {
|
|
250
|
+
let keybindings = KeybindingsManager.create();
|
|
251
|
+
setKeybindings(keybindings);
|
|
252
|
+
let resolved = !1, selector = new SessionSelectorComponent(currentSessionsLoader, allSessionsLoader, (path) => {
|
|
253
|
+
resolved || (resolved = !0, ui.stop(), resolve3(path));
|
|
254
|
+
}, () => {
|
|
255
|
+
resolved || (resolved = !0, ui.stop(), resolve3(null));
|
|
256
|
+
}, () => {
|
|
257
|
+
ui.stop(), process.exit(0);
|
|
258
|
+
}, () => ui.requestRender(), { showRenameHint: !1, keybindings });
|
|
259
|
+
ui.addChild(selector), ui.setFocus(selector.getSessionList()), startStartupTui(ui, settingsManager);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// packages/coding-agent/dist/core/session-retention.js
|
|
264
|
+
import { readdir, stat as stat2, unlink } from "node:fs/promises";
|
|
265
|
+
import { join, resolve as resolve2 } from "node:path";
|
|
266
|
+
var DAY_MS = 1440 * 60 * 1e3;
|
|
267
|
+
function sameFile(a, b) {
|
|
268
|
+
let ra = resolve2(a), rb = resolve2(b);
|
|
269
|
+
return process.platform === "win32" ? ra.toLowerCase() === rb.toLowerCase() : ra === rb;
|
|
270
|
+
}
|
|
271
|
+
async function pruneDir(dir, cutoffMs, excludeFile, deleted) {
|
|
272
|
+
let entries;
|
|
273
|
+
try {
|
|
274
|
+
entries = await readdir(dir, { withFileTypes: !0 });
|
|
275
|
+
} catch {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
for (let entry of entries) {
|
|
279
|
+
if (!entry.isFile() || !entry.name.endsWith(".jsonl"))
|
|
280
|
+
continue;
|
|
281
|
+
let filePath = join(dir, entry.name);
|
|
282
|
+
if (!(excludeFile && sameFile(filePath, excludeFile)))
|
|
283
|
+
try {
|
|
284
|
+
(await stat2(filePath)).mtimeMs < cutoffMs && (await unlink(filePath), deleted.push(filePath));
|
|
285
|
+
} catch {
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function pruneOldSessions(sessionsRoot, retentionDays, options = {}) {
|
|
290
|
+
let deleted = [];
|
|
291
|
+
if (!Number.isFinite(retentionDays) || retentionDays <= 0)
|
|
292
|
+
return { deleted };
|
|
293
|
+
let cutoffMs = (options.now ?? Date.now()) - retentionDays * DAY_MS;
|
|
294
|
+
await pruneDir(sessionsRoot, cutoffMs, options.excludeFile, deleted);
|
|
295
|
+
let subdirs;
|
|
296
|
+
try {
|
|
297
|
+
subdirs = await readdir(sessionsRoot, { withFileTypes: !0 });
|
|
298
|
+
} catch {
|
|
299
|
+
return { deleted };
|
|
300
|
+
}
|
|
301
|
+
for (let entry of subdirs)
|
|
302
|
+
entry.isDirectory() && await pruneDir(join(sessionsRoot, entry.name), cutoffMs, options.excludeFile, deleted);
|
|
303
|
+
return { deleted };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// packages/coding-agent/dist/migrations.js
|
|
307
|
+
import chalk3 from "chalk";
|
|
308
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
309
|
+
import { homedir } from "os";
|
|
310
|
+
import { dirname, join as join2 } from "path";
|
|
311
|
+
var MIGRATION_GUIDE_URL = "https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/CHANGELOG.md#extensions-migration", EXTENSIONS_DOC_URL = "https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/extensions.md";
|
|
312
|
+
function migrateAuthToAuthJson() {
|
|
313
|
+
let agentDir = getAgentDir(), authPath = join2(agentDir, "auth.json"), oauthPath = join2(agentDir, "oauth.json"), settingsPath = join2(agentDir, "settings.json");
|
|
314
|
+
if (existsSync(authPath))
|
|
315
|
+
return [];
|
|
316
|
+
let migrated = {}, providers = [];
|
|
317
|
+
if (existsSync(oauthPath))
|
|
318
|
+
try {
|
|
319
|
+
let oauth = JSON.parse(readFileSync(oauthPath, "utf-8"));
|
|
320
|
+
for (let [provider, cred] of Object.entries(oauth))
|
|
321
|
+
migrated[provider] = { type: "oauth", ...cred }, providers.push(provider);
|
|
322
|
+
renameSync(oauthPath, `${oauthPath}.migrated`);
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
if (existsSync(settingsPath))
|
|
326
|
+
try {
|
|
327
|
+
let content = readFileSync(settingsPath, "utf-8"), settings = JSON.parse(content);
|
|
328
|
+
if (settings.apiKeys && typeof settings.apiKeys == "object") {
|
|
329
|
+
for (let [provider, key] of Object.entries(settings.apiKeys))
|
|
330
|
+
!migrated[provider] && typeof key == "string" && (migrated[provider] = { type: "api_key", key }, providers.push(provider));
|
|
331
|
+
delete settings.apiKeys, writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
332
|
+
}
|
|
333
|
+
} catch {
|
|
334
|
+
}
|
|
335
|
+
return Object.keys(migrated).length > 0 && (mkdirSync(dirname(authPath), { recursive: !0 }), writeFileSync(authPath, JSON.stringify(migrated, null, 2), { mode: 384 })), providers;
|
|
336
|
+
}
|
|
337
|
+
function removeRetiredGlobalSettings(keys, agentDir = getAgentDir()) {
|
|
338
|
+
let settingsPath = join2(agentDir, "settings.json");
|
|
339
|
+
if (!existsSync(settingsPath))
|
|
340
|
+
return !1;
|
|
341
|
+
try {
|
|
342
|
+
let parsed = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
343
|
+
if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
|
|
344
|
+
return !1;
|
|
345
|
+
let settings = parsed, retired = keys.filter((key) => key in settings);
|
|
346
|
+
if (retired.length === 0)
|
|
347
|
+
return !1;
|
|
348
|
+
for (let key of retired)
|
|
349
|
+
delete settings[key];
|
|
350
|
+
return writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
|
|
351
|
+
`, "utf-8"), !0;
|
|
352
|
+
} catch {
|
|
353
|
+
return !1;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function removeRetiredBehaviorPresetSetting(agentDir = getAgentDir()) {
|
|
357
|
+
return removeRetiredGlobalSettings(["behaviorPreset"], agentDir);
|
|
358
|
+
}
|
|
359
|
+
function removeRetiredTuiSettings(agentDir = getAgentDir()) {
|
|
360
|
+
return removeRetiredGlobalSettings(["gutterRail", "promptSymbol"], agentDir);
|
|
361
|
+
}
|
|
362
|
+
function migrateSessionsFromAgentRoot() {
|
|
363
|
+
let agentDir = getAgentDir(), files;
|
|
364
|
+
try {
|
|
365
|
+
files = readdirSync(agentDir).filter((f) => f.endsWith(".jsonl")).map((f) => join2(agentDir, f));
|
|
366
|
+
} catch {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (files.length !== 0)
|
|
370
|
+
for (let file of files)
|
|
371
|
+
try {
|
|
372
|
+
let firstLine = readFileSync(file, "utf8").split(`
|
|
373
|
+
`)[0];
|
|
374
|
+
if (!firstLine?.trim())
|
|
375
|
+
continue;
|
|
376
|
+
let header = JSON.parse(firstLine);
|
|
377
|
+
if (header.type !== "session" || !header.cwd)
|
|
378
|
+
continue;
|
|
379
|
+
let safePath = `--${header.cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`, correctDir = join2(agentDir, "sessions", safePath);
|
|
380
|
+
existsSync(correctDir) || mkdirSync(correctDir, { recursive: !0 });
|
|
381
|
+
let fileName = file.split("/").pop() || file.split("\\").pop(), newPath = join2(correctDir, fileName);
|
|
382
|
+
if (existsSync(newPath))
|
|
383
|
+
continue;
|
|
384
|
+
renameSync(file, newPath);
|
|
385
|
+
} catch {
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function migrateCommandsToPrompts(baseDir, label) {
|
|
389
|
+
let commandsDir = join2(baseDir, "commands"), promptsDir = join2(baseDir, "prompts");
|
|
390
|
+
if (existsSync(commandsDir) && !existsSync(promptsDir))
|
|
391
|
+
try {
|
|
392
|
+
return renameSync(commandsDir, promptsDir), console.log(chalk3.green(`Migrated ${label} commands/ \u2192 prompts/`)), !0;
|
|
393
|
+
} catch (err) {
|
|
394
|
+
console.log(chalk3.yellow(`Warning: Could not migrate ${label} commands/ to prompts/: ${err instanceof Error ? err.message : err}`));
|
|
395
|
+
}
|
|
396
|
+
return !1;
|
|
397
|
+
}
|
|
398
|
+
function migrateKeybindingsConfigFile() {
|
|
399
|
+
let configPath = join2(getAgentDir(), "keybindings.json");
|
|
400
|
+
if (existsSync(configPath))
|
|
401
|
+
try {
|
|
402
|
+
let parsed = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
403
|
+
if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
|
|
404
|
+
return;
|
|
405
|
+
let { config, migrated } = migrateKeybindingsConfig(parsed);
|
|
406
|
+
if (!migrated)
|
|
407
|
+
return;
|
|
408
|
+
writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
|
|
409
|
+
`, "utf-8");
|
|
410
|
+
} catch {
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function migrateToolsToBin() {
|
|
414
|
+
let agentDir = getAgentDir(), toolsDir = join2(agentDir, "tools"), binDir = getBinDir();
|
|
415
|
+
if (!existsSync(toolsDir))
|
|
416
|
+
return;
|
|
417
|
+
let binaries = ["fd", "rg", "fd.exe", "rg.exe"], movedAny = !1;
|
|
418
|
+
for (let bin of binaries) {
|
|
419
|
+
let oldPath = join2(toolsDir, bin), newPath = join2(binDir, bin);
|
|
420
|
+
if (existsSync(oldPath))
|
|
421
|
+
if (existsSync(binDir) || mkdirSync(binDir, { recursive: !0 }), existsSync(newPath))
|
|
422
|
+
try {
|
|
423
|
+
rmSync?.(oldPath, { force: !0 });
|
|
424
|
+
} catch {
|
|
425
|
+
}
|
|
426
|
+
else
|
|
427
|
+
try {
|
|
428
|
+
renameSync(oldPath, newPath), movedAny = !0;
|
|
429
|
+
} catch {
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
movedAny && console.log(chalk3.green("Migrated managed binaries tools/ \u2192 bin/"));
|
|
433
|
+
}
|
|
434
|
+
function checkDeprecatedExtensionDirs(baseDir, label) {
|
|
435
|
+
let hooksDir = join2(baseDir, "hooks"), toolsDir = join2(baseDir, "tools"), warnings = [];
|
|
436
|
+
if (existsSync(hooksDir) && warnings.push(`${label} hooks/ directory found. Hooks have been renamed to extensions.`), existsSync(toolsDir))
|
|
437
|
+
try {
|
|
438
|
+
readdirSync(toolsDir).filter((e) => {
|
|
439
|
+
let lower = e.toLowerCase();
|
|
440
|
+
return lower !== "fd" && lower !== "rg" && lower !== "fd.exe" && lower !== "rg.exe" && !e.startsWith(".");
|
|
441
|
+
}).length > 0 && warnings.push(`${label} tools/ directory contains custom tools. Custom tools have been merged into extensions.`);
|
|
442
|
+
} catch {
|
|
443
|
+
}
|
|
444
|
+
return warnings;
|
|
445
|
+
}
|
|
446
|
+
function migrateExtensionSystem(cwd) {
|
|
447
|
+
let agentDir = getAgentDir(), projectDir = join2(cwd, CONFIG_DIR_NAME);
|
|
448
|
+
return migrateCommandsToPrompts(agentDir, "Global"), migrateCommandsToPrompts(projectDir, "Project"), [
|
|
449
|
+
...checkDeprecatedExtensionDirs(agentDir, "Global"),
|
|
450
|
+
...checkDeprecatedExtensionDirs(projectDir, "Project")
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
async function showDeprecationWarnings(warnings) {
|
|
454
|
+
if (warnings.length !== 0) {
|
|
455
|
+
for (let warning of warnings)
|
|
456
|
+
console.log(chalk3.yellow(`Warning: ${warning}`));
|
|
457
|
+
console.log(chalk3.yellow(`
|
|
458
|
+
Move your extensions to the extensions/ directory.`)), console.log(chalk3.yellow(`Migration guide: ${MIGRATION_GUIDE_URL}`)), console.log(chalk3.yellow(`Documentation: ${EXTENSIONS_DOC_URL}`)), process.stdin.isTTY && (console.log(chalk3.dim(`
|
|
459
|
+
Press any key to continue...`)), await new Promise((resolve3) => {
|
|
460
|
+
process.stdin.setRawMode?.(!0), process.stdin.resume(), process.stdin.once("data", () => {
|
|
461
|
+
process.stdin.setRawMode?.(!1), process.stdin.pause(), resolve3();
|
|
462
|
+
});
|
|
463
|
+
}), console.log());
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function migratePiStateToLunr(piHome = join2(homedir(), ".pi"), lunrAgentDir = getAgentDir()) {
|
|
467
|
+
let copied = [], copyFileIfMissing = (src, dest) => {
|
|
468
|
+
try {
|
|
469
|
+
if (!existsSync(src) || existsSync(dest))
|
|
470
|
+
return;
|
|
471
|
+
mkdirSync(dirname(dest), { recursive: !0 }), copyFileSync(src, dest), copied.push(dest);
|
|
472
|
+
} catch {
|
|
473
|
+
}
|
|
474
|
+
}, copyDirIfMissing = (srcDir, destDir) => {
|
|
475
|
+
try {
|
|
476
|
+
if (!existsSync(srcDir))
|
|
477
|
+
return;
|
|
478
|
+
for (let entry of readdirSync(srcDir, { withFileTypes: !0 })) {
|
|
479
|
+
let src = join2(srcDir, entry.name), dest = join2(destDir, entry.name);
|
|
480
|
+
entry.isDirectory() ? copyDirIfMissing(src, dest) : entry.isFile() && copyFileIfMissing(src, dest);
|
|
481
|
+
}
|
|
482
|
+
} catch {
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
try {
|
|
486
|
+
let piAgent = join2(piHome, "agent");
|
|
487
|
+
for (let name of [
|
|
488
|
+
"mcp.json",
|
|
489
|
+
"mcp-cache.json",
|
|
490
|
+
"mcp-npx-cache.json",
|
|
491
|
+
"mcp-onboarding.json",
|
|
492
|
+
"pi-goal-state.json"
|
|
493
|
+
])
|
|
494
|
+
copyFileIfMissing(join2(piAgent, name), join2(lunrAgentDir, name));
|
|
495
|
+
copyDirIfMissing(join2(piAgent, "mcp-oauth"), join2(lunrAgentDir, "mcp-oauth")), copyFileIfMissing(join2(piHome, "web-search.json"), join2(lunrAgentDir, "web-search.json"));
|
|
496
|
+
let lunrMemoryDir = join2(dirname(lunrAgentDir), "simple-memory");
|
|
497
|
+
for (let name of ["memory.md", "config.json"])
|
|
498
|
+
copyFileIfMissing(join2(piHome, "simple-memory", name), join2(lunrMemoryDir, name));
|
|
499
|
+
} catch {
|
|
500
|
+
}
|
|
501
|
+
return copied;
|
|
502
|
+
}
|
|
503
|
+
function runMigrations(cwd) {
|
|
504
|
+
let migratedAuthProviders = migrateAuthToAuthJson();
|
|
505
|
+
removeRetiredBehaviorPresetSetting(), removeRetiredTuiSettings(), migrateSessionsFromAgentRoot(), migrateToolsToBin(), migrateKeybindingsConfigFile(), migratePiStateToLunr();
|
|
506
|
+
let instructionMigration = migrateLegacyGlobalInstructions(getAgentDir());
|
|
507
|
+
instructionMigration.diagnostic && console.warn(chalk3.yellow(`Warning: ${instructionMigration.diagnostic}`));
|
|
508
|
+
let deprecationWarnings = migrateExtensionSystem(cwd);
|
|
509
|
+
return { migratedAuthProviders, deprecationWarnings };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// packages/coding-agent/dist/main.js
|
|
513
|
+
var EXTENSION_LOAD_FAILURE_HINT = `Hint: Start without extensions using "${APP_NAME} -ne".`, PIPED_STDIN_FIRST_CHUNK_MS = 50, PIPED_STDIN_IDLE_MS = 2e3;
|
|
514
|
+
async function readPipedStdin(stream = process.stdin, options = {}) {
|
|
515
|
+
if (stream.isTTY)
|
|
516
|
+
return;
|
|
517
|
+
let firstChunkMs = options.firstChunkMs ?? PIPED_STDIN_FIRST_CHUNK_MS, idleMs = options.idleMs ?? PIPED_STDIN_IDLE_MS;
|
|
518
|
+
return new Promise((resolve3) => {
|
|
519
|
+
let data = "", settled = !1, sawData = !1, idleTimer, firstChunkTimer = setTimeout(() => {
|
|
520
|
+
sawData || finish(void 0);
|
|
521
|
+
}, firstChunkMs), finish = (value) => {
|
|
522
|
+
settled || (settled = !0, clearTimeout(firstChunkTimer), idleTimer && clearTimeout(idleTimer), stream.off("data", onData), stream.off("end", onEnd), stream.off("error", onEnd), resolve3(value));
|
|
523
|
+
}, onEnd = () => finish(data.trim() || void 0), onData = (chunk) => {
|
|
524
|
+
sawData = !0, data += typeof chunk == "string" ? chunk : chunk.toString("utf8"), idleTimer && clearTimeout(idleTimer), idleTimer = setTimeout(onEnd, idleMs);
|
|
525
|
+
};
|
|
526
|
+
stream.setEncoding("utf8"), stream.on("data", onData), stream.on("end", onEnd), stream.on("error", onEnd), stream.resume();
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function collectSettingsDiagnostics(settingsManager, context) {
|
|
530
|
+
return settingsManager.drainErrors().map(({ scope, error }) => ({
|
|
531
|
+
type: "warning",
|
|
532
|
+
message: `(${context}, ${scope} settings) ${error.message}`
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
function reportDiagnostics(diagnostics) {
|
|
536
|
+
for (let diagnostic of diagnostics) {
|
|
537
|
+
let color = diagnostic.type === "error" ? chalk4.red : diagnostic.type === "warning" ? chalk4.yellow : chalk4.dim, prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
|
|
538
|
+
console.error(color(`${prefix}${diagnostic.message}`));
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function isTruthyEnvFlag(value) {
|
|
542
|
+
return value ? value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes" : !1;
|
|
543
|
+
}
|
|
544
|
+
function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
|
|
545
|
+
return parsed.mode === "rpc" ? "rpc" : parsed.mode === "json" ? "json" : isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK) && !parsed.print ? "interactive" : parsed.print || !stdinIsTTY || !stdoutIsTTY ? "print" : "interactive";
|
|
546
|
+
}
|
|
547
|
+
function toPrintOutputMode(appMode) {
|
|
548
|
+
return appMode === "json" ? "json" : "text";
|
|
549
|
+
}
|
|
550
|
+
function isPlainRuntimeMetadataCommand(parsed) {
|
|
551
|
+
return !parsed.print && parsed.mode === void 0 && (parsed.help === !0 || parsed.listModels !== void 0);
|
|
552
|
+
}
|
|
553
|
+
async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
|
|
554
|
+
if (parsed.fileArgs.length === 0)
|
|
555
|
+
return buildInitialMessage({ parsed, stdinContent });
|
|
556
|
+
let { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
|
|
557
|
+
return buildInitialMessage({
|
|
558
|
+
parsed,
|
|
559
|
+
fileText: text,
|
|
560
|
+
fileImages: images,
|
|
561
|
+
stdinContent
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
async function findLocalSessionByExactId(sessionId, cwd, sessionDir) {
|
|
565
|
+
let localMatch = (await SessionManager.list(cwd, sessionDir)).find((s) => s.id === sessionId);
|
|
566
|
+
return localMatch ? { type: "local", path: localMatch.path } : void 0;
|
|
567
|
+
}
|
|
568
|
+
async function resolveSessionPath(sessionArg, cwd, sessionDir) {
|
|
569
|
+
if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl"))
|
|
570
|
+
return { type: "path", path: resolvePath(sessionArg, cwd) };
|
|
571
|
+
let localSessions = await SessionManager.list(cwd, sessionDir), localMatch = localSessions.find((s) => s.id === sessionArg) ?? localSessions.find((s) => s.id.startsWith(sessionArg));
|
|
572
|
+
if (localMatch)
|
|
573
|
+
return { type: "local", path: localMatch.path };
|
|
574
|
+
let allSessions = await SessionManager.listAll(sessionDir), globalMatch = allSessions.find((s) => s.id === sessionArg) ?? allSessions.find((s) => s.id.startsWith(sessionArg));
|
|
575
|
+
return globalMatch ? { type: "global", path: globalMatch.path, cwd: globalMatch.cwd } : { type: "not_found", arg: sessionArg };
|
|
576
|
+
}
|
|
577
|
+
async function promptConfirm(message, startupView) {
|
|
578
|
+
return startupView ? startupView.confirm("Confirm", message) : new Promise((resolve3) => {
|
|
579
|
+
let rl = createInterface({
|
|
580
|
+
input: process.stdin,
|
|
581
|
+
output: process.stdout
|
|
582
|
+
});
|
|
583
|
+
rl.question(`${message} [y/N] `, (answer) => {
|
|
584
|
+
rl.close(), resolve3(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function validateForkFlags(parsed) {
|
|
589
|
+
if (!parsed.fork)
|
|
590
|
+
return;
|
|
591
|
+
let conflictingFlags = [
|
|
592
|
+
parsed.session ? "--session" : void 0,
|
|
593
|
+
parsed.continue ? "--continue" : void 0,
|
|
594
|
+
parsed.resume ? "--resume" : void 0,
|
|
595
|
+
parsed.noSession ? "--no-session" : void 0
|
|
596
|
+
].filter((flag) => flag !== void 0);
|
|
597
|
+
conflictingFlags.length > 0 && (console.error(chalk4.red(`Error: --fork cannot be combined with ${conflictingFlags.join(", ")}`)), process.exit(1));
|
|
598
|
+
}
|
|
599
|
+
function validateSessionIdFlags(parsed) {
|
|
600
|
+
if (parsed.sessionId === void 0)
|
|
601
|
+
return;
|
|
602
|
+
let conflictingFlags = [
|
|
603
|
+
parsed.session ? "--session" : void 0,
|
|
604
|
+
parsed.continue ? "--continue" : void 0,
|
|
605
|
+
parsed.resume ? "--resume" : void 0
|
|
606
|
+
].filter((flag) => flag !== void 0);
|
|
607
|
+
conflictingFlags.length > 0 && (console.error(chalk4.red(`Error: --session-id cannot be combined with ${conflictingFlags.join(", ")}`)), process.exit(1));
|
|
608
|
+
try {
|
|
609
|
+
assertValidSessionId(parsed.sessionId);
|
|
610
|
+
} catch (error) {
|
|
611
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
612
|
+
console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function openSessionOrExit(path, sessionDir) {
|
|
616
|
+
try {
|
|
617
|
+
return SessionManager.open(path, sessionDir);
|
|
618
|
+
} catch (error) {
|
|
619
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
620
|
+
console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function forkSessionOrExit(sourcePath, cwd, sessionDir, sessionId) {
|
|
624
|
+
try {
|
|
625
|
+
return SessionManager.forkFrom(sourcePath, cwd, sessionDir, { id: sessionId });
|
|
626
|
+
} catch (error) {
|
|
627
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
628
|
+
console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
async function createSessionManager(parsed, cwd, sessionDir, settingsManager, startupView) {
|
|
632
|
+
if (parsed.noSession || parsed.help || parsed.listModels !== void 0)
|
|
633
|
+
return SessionManager.inMemory(cwd, parsed.sessionId !== void 0 ? { id: parsed.sessionId } : void 0);
|
|
634
|
+
if (parsed.fork) {
|
|
635
|
+
parsed.sessionId && await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir) && (console.error(chalk4.red(`Session already exists with id '${parsed.sessionId}'`)), process.exit(1));
|
|
636
|
+
let resolved = await resolveSessionPath(parsed.fork, cwd, sessionDir);
|
|
637
|
+
switch (resolved.type) {
|
|
638
|
+
case "path":
|
|
639
|
+
case "local":
|
|
640
|
+
case "global":
|
|
641
|
+
return forkSessionOrExit(resolved.path, cwd, sessionDir, parsed.sessionId);
|
|
642
|
+
case "not_found":
|
|
643
|
+
console.error(chalk4.red(`No session found matching '${resolved.arg}'`)), process.exit(1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (parsed.session) {
|
|
647
|
+
let resolved = await resolveSessionPath(parsed.session, cwd, sessionDir);
|
|
648
|
+
switch (resolved.type) {
|
|
649
|
+
case "path":
|
|
650
|
+
case "local":
|
|
651
|
+
return openSessionOrExit(resolved.path, sessionDir);
|
|
652
|
+
case "global":
|
|
653
|
+
return console.log(chalk4.yellow(`Session found in different project: ${resolved.cwd}`)), await promptConfirm("Fork this session into current directory?", startupView) || (console.log(chalk4.dim("Aborted.")), process.exit(0)), forkSessionOrExit(resolved.path, cwd, sessionDir);
|
|
654
|
+
case "not_found":
|
|
655
|
+
console.error(chalk4.red(`No session found matching '${resolved.arg}'`)), process.exit(1);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (parsed.resume)
|
|
659
|
+
try {
|
|
660
|
+
let currentSessionsLoader = (onProgress) => SessionManager.list(cwd, sessionDir, onProgress), allSessionsLoader = (onProgress) => SessionManager.listAll(sessionDir, onProgress), selectedPath = startupView ? await startupView.selectSession(currentSessionsLoader, allSessionsLoader) : await selectSession(currentSessionsLoader, allSessionsLoader, settingsManager);
|
|
661
|
+
return selectedPath || (console.log(chalk4.dim("No session selected")), process.exit(0)), SessionManager.open(selectedPath, sessionDir);
|
|
662
|
+
} finally {
|
|
663
|
+
stopThemeWatcher();
|
|
664
|
+
}
|
|
665
|
+
if (parsed.continue)
|
|
666
|
+
return SessionManager.continueRecent(cwd, sessionDir);
|
|
667
|
+
if (parsed.sessionId) {
|
|
668
|
+
let existingSession = await findLocalSessionByExactId(parsed.sessionId, cwd, sessionDir);
|
|
669
|
+
if (existingSession)
|
|
670
|
+
return SessionManager.open(existingSession.path, sessionDir);
|
|
671
|
+
console.error(chalk4.yellow(`Warning: No project session found with id '${parsed.sessionId}'; creating a new session with that id.`));
|
|
672
|
+
}
|
|
673
|
+
return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
|
|
674
|
+
}
|
|
675
|
+
function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRuntime, settingsManager) {
|
|
676
|
+
let options = {}, diagnostics = [], cliThinkingFromModel = !1;
|
|
677
|
+
if (parsed.model) {
|
|
678
|
+
let resolved = resolveCliModel({
|
|
679
|
+
cliProvider: parsed.provider,
|
|
680
|
+
cliModel: parsed.model,
|
|
681
|
+
cliThinking: parsed.thinking,
|
|
682
|
+
modelRuntime
|
|
683
|
+
});
|
|
684
|
+
resolved.warning && diagnostics.push({ type: "warning", message: resolved.warning }), resolved.error && diagnostics.push({ type: "error", message: resolved.error }), resolved.model && (options.model = resolved.model, !parsed.thinking && resolved.thinkingLevel && (options.thinkingLevel = resolved.thinkingLevel, cliThinkingFromModel = !0));
|
|
685
|
+
}
|
|
686
|
+
if (!options.model && scopedModels.length > 0 && !hasExistingSession) {
|
|
687
|
+
let savedProvider = settingsManager.getDefaultProvider(), savedModelId = settingsManager.getDefaultModel(), savedModel = savedProvider && savedModelId ? modelRuntime.getModel(savedProvider, savedModelId) : void 0, savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : void 0;
|
|
688
|
+
savedInScope ? (options.model = savedInScope.model, !parsed.thinking && savedInScope.thinkingLevel && (options.thinkingLevel = savedInScope.thinkingLevel)) : (options.model = scopedModels[0].model, !parsed.thinking && scopedModels[0].thinkingLevel && (options.thinkingLevel = scopedModels[0].thinkingLevel));
|
|
689
|
+
}
|
|
690
|
+
return parsed.thinking && (options.thinkingLevel = parsed.thinking), scopedModels.length > 0 && (options.scopedModels = scopedModels.map((sm) => ({
|
|
691
|
+
model: sm.model,
|
|
692
|
+
thinkingLevel: sm.thinkingLevel
|
|
693
|
+
}))), parsed.noTools ? options.noTools = "all" : parsed.noBuiltinTools && (options.noTools = "builtin"), parsed.tools && (options.tools = [...parsed.tools]), parsed.excludeTools && (options.excludeTools = [...parsed.excludeTools]), { options, cliThinkingFromModel, diagnostics };
|
|
694
|
+
}
|
|
695
|
+
function resolveCliPaths(cwd, paths) {
|
|
696
|
+
return paths?.map((value) => isLocalPath(value) ? resolvePath(value, cwd) : value);
|
|
697
|
+
}
|
|
698
|
+
function createStartupViewTrustContext(cwd, startupView) {
|
|
699
|
+
return {
|
|
700
|
+
cwd,
|
|
701
|
+
mode: "tui",
|
|
702
|
+
hasUI: !0,
|
|
703
|
+
ui: {
|
|
704
|
+
select: (title, options) => startupView.select(title, options.map((option) => ({ label: option, value: option }))),
|
|
705
|
+
confirm: (title, message) => startupView.confirm(title, message),
|
|
706
|
+
input: (title, placeholder) => startupView.input(title, placeholder),
|
|
707
|
+
notify: () => {
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
async function promptForMissingSessionCwd(issue, settingsManager, startupView) {
|
|
713
|
+
let options = [
|
|
714
|
+
{ label: "Continue", value: issue.fallbackCwd },
|
|
715
|
+
{ label: "Cancel", value: void 0 }
|
|
716
|
+
];
|
|
717
|
+
return startupView ? startupView.select(formatMissingSessionCwdPrompt(issue), options) : showStartupSelector(settingsManager, formatMissingSessionCwdPrompt(issue), options);
|
|
718
|
+
}
|
|
719
|
+
async function main(args, options) {
|
|
720
|
+
resetTimings(), (args.includes("--offline") || isTruthyEnvFlag(process.env.PI_OFFLINE)) && (process.env.PI_OFFLINE = "1");
|
|
721
|
+
let cwd = process.cwd(), agentDir = getAgentDir(), bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: !1 });
|
|
722
|
+
if (applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy), configureHttpDispatcher(), ["setup", "features", "uninstall"].includes(args[0])) {
|
|
723
|
+
let { handleInstallCli } = await import("./install-cli-EXMJQESX.js");
|
|
724
|
+
if (await handleInstallCli(args))
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (args[0] === "update") {
|
|
728
|
+
let { handleUpdateCli } = await import("./update-cli-L3JIBH2U.js");
|
|
729
|
+
if (await handleUpdateCli(args))
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (["install", "remove", "uninstall", "list", "config"].includes(args[0])) {
|
|
733
|
+
let { handleConfigCommand, handlePackageCommand } = await import("./package-manager-cli-7RKSZGEN.js");
|
|
734
|
+
if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) {
|
|
735
|
+
process.exit(process.exitCode ?? 0);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (await handleConfigCommand(args, { extensionFactories: options?.extensionFactories }))
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (args[0] === "gateway") {
|
|
742
|
+
let { handleGatewayCommand } = await import("./command-AAV3YRR5.js");
|
|
743
|
+
if (await handleGatewayCommand(args))
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
let parsed = parseArgs(args);
|
|
747
|
+
if (parsed.diagnostics.length > 0) {
|
|
748
|
+
for (let d of parsed.diagnostics) {
|
|
749
|
+
let color = d.type === "error" ? chalk4.red : chalk4.yellow;
|
|
750
|
+
console.error(color(`${d.type === "error" ? "Error" : "Warning"}: ${d.message}`));
|
|
751
|
+
}
|
|
752
|
+
parsed.diagnostics.some((d) => d.type === "error") && process.exit(1);
|
|
753
|
+
}
|
|
754
|
+
if (time("parseArgs"), parsed.version && (console.log(VERSION), process.exit(0)), parsed.export) {
|
|
755
|
+
let result;
|
|
756
|
+
try {
|
|
757
|
+
let { exportFromFile } = await import("./export-html-TEXVV5RP.js"), outputPath = parsed.messages.length > 0 ? parsed.messages[0] : void 0;
|
|
758
|
+
result = await exportFromFile(parsed.export, outputPath);
|
|
759
|
+
} catch (error) {
|
|
760
|
+
let message = error instanceof Error ? error.message : "Failed to export session";
|
|
761
|
+
console.error(chalk4.red(`Error: ${message}`)), process.exit(1);
|
|
762
|
+
}
|
|
763
|
+
console.log(`Exported to: ${result}`), process.exit(0);
|
|
764
|
+
}
|
|
765
|
+
let appMode = resolveAppMode(parsed, process.stdin.isTTY, process.stdout.isTTY), interactiveModeImport = appMode === "interactive" ? import("./interactive-mode-2SZUO53H.js") : void 0, startupView = appMode === "interactive" ? options?.startupView : void 0;
|
|
766
|
+
options?.startupView && !startupView && options.startupView.stop(), applyInheritedSubagentPermissions(), appMode !== "interactive" && !isPlainRuntimeMetadataCommand(parsed) && takeOverStdout(), parsed.mode === "rpc" && parsed.fileArgs.length > 0 && (console.error(chalk4.red("Error: @file arguments are not supported in RPC mode")), process.exit(1)), validateForkFlags(parsed), validateSessionIdFlags(parsed);
|
|
767
|
+
let { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(cwd);
|
|
768
|
+
time("runMigrations");
|
|
769
|
+
let startupSettingsManager = SettingsManager.create(cwd, agentDir);
|
|
770
|
+
reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup")), registerModelTierBridge(startupSettingsManager), registerMemoryCapBridge(startupSettingsManager), registerCustomizeBridge(startupSettingsManager), appMode === "interactive" && !parsed.help && parsed.listModels === void 0 && shouldRunFirstTimeSetup() && (startupView?.pause(), await showFirstTimeSetup(startupSettingsManager), startupView?.resume(), time("firstTimeSetup"));
|
|
771
|
+
let envSessionDir = process.env[ENV_SESSION_DIR], sessionDir = (parsed.sessionDir ? normalizePath(parsed.sessionDir) : void 0) ?? (envSessionDir ? expandTildePath(envSessionDir) : void 0) ?? startupSettingsManager.getSessionDir(), sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager, startupView), missingSessionCwdIssue = getMissingSessionCwdIssue(sessionManager, cwd);
|
|
772
|
+
if (missingSessionCwdIssue)
|
|
773
|
+
if (appMode === "interactive") {
|
|
774
|
+
let selectedCwd = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager, startupView);
|
|
775
|
+
selectedCwd || process.exit(0), sessionManager = SessionManager.open(missingSessionCwdIssue.sessionFile, sessionDir, selectedCwd);
|
|
776
|
+
} else
|
|
777
|
+
console.error(chalk4.red(new MissingSessionCwdError(missingSessionCwdIssue).message)), process.exit(1);
|
|
778
|
+
if (parsed.name !== void 0) {
|
|
779
|
+
let name = parsed.name.trim();
|
|
780
|
+
name || (console.error(chalk4.red("Error: --name requires a non-empty value")), process.exit(1)), sessionManager.appendSessionInfo(name);
|
|
781
|
+
}
|
|
782
|
+
time("createSessionManager");
|
|
783
|
+
let runSessionRetention = async () => {
|
|
784
|
+
try {
|
|
785
|
+
let retentionDays = startupSettingsManager.getSessionRetentionDays();
|
|
786
|
+
if (retentionDays <= 0)
|
|
787
|
+
return;
|
|
788
|
+
let activeSessionFile = sessionManager.getSessionFile(), { deleted } = await pruneOldSessions(getSessionsDir(), retentionDays, {
|
|
789
|
+
excludeFile: activeSessionFile
|
|
790
|
+
});
|
|
791
|
+
if (sessionDir) {
|
|
792
|
+
let extra = await pruneOldSessions(sessionDir, retentionDays, { excludeFile: activeSessionFile });
|
|
793
|
+
deleted.push(...extra.deleted);
|
|
794
|
+
}
|
|
795
|
+
deleted.length > 0 && appendDebugLog(`session-retention: deleted ${deleted.length} file(s):
|
|
796
|
+
${deleted.map((path) => ` ${path}`).join(`
|
|
797
|
+
`)}`);
|
|
798
|
+
} catch (error) {
|
|
799
|
+
appendDebugLog(`session-retention: prune failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
800
|
+
}
|
|
801
|
+
}, trustStore = new ProjectTrustStore(agentDir), sessionCwd = sessionManager.getCwd(), autoTrustOnReloadCwd = parsed.projectTrustOverride === void 0 && !hasTrustRequiringProjectResources(sessionCwd) ? sessionCwd : void 0, trustPromptMode = parsed.help || parsed.listModels !== void 0 ? "print" : appMode, projectTrustByCwd = /* @__PURE__ */ new Map(), resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions), resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills), resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates), resolvedThemePaths = resolveCliPaths(cwd, parsed.themes), builtinRoster = appMode === "interactive" ? [...lightBuiltinExtensions] : await loadAllBuiltinExtensions(), rememberAttachedFactories = (factories) => {
|
|
802
|
+
let seen = new Set(builtinRoster.map((entry) => typeof entry == "function" ? void 0 : entry.name).filter(Boolean));
|
|
803
|
+
for (let factory of factories) {
|
|
804
|
+
let name = typeof factory == "function" ? void 0 : factory.name;
|
|
805
|
+
name && seen.has(name) || (name && seen.add(name), builtinRoster.push(factory));
|
|
806
|
+
}
|
|
807
|
+
}, createRuntime = async ({ cwd: cwd2, agentDir: agentDir2, sessionManager: sessionManager2, sessionStartEvent, projectTrustContext }) => {
|
|
808
|
+
let isInitialRuntime = sessionStartEvent === void 0, projectTrustDiagnostics = [], cachedProjectTrust = projectTrustByCwd.get(cwd2), hasTrustRequiringResources = hasTrustRequiringProjectResources(cwd2), shouldResolveProjectTrust = parsed.projectTrustOverride === void 0 && cachedProjectTrust === void 0 && hasTrustRequiringResources, projectTrusted = shouldResolveProjectTrust ? !1 : cachedProjectTrust ?? parsed.projectTrustOverride ?? (!hasTrustRequiringResources || trustStore.get(cwd2) === !0), runtimeSettingsManager = SettingsManager.create(cwd2, agentDir2, { projectTrusted }), skipMissingPackageInstall = isInitialRuntime && appMode === "interactive", services2 = await createAgentSessionServices({
|
|
809
|
+
cwd: cwd2,
|
|
810
|
+
agentDir: agentDir2,
|
|
811
|
+
settingsManager: runtimeSettingsManager,
|
|
812
|
+
extensionFlagValues: parsed.unknownFlags,
|
|
813
|
+
resourceLoaderReloadOptions: shouldResolveProjectTrust ? {
|
|
814
|
+
skipMissingPackageInstall,
|
|
815
|
+
resolveProjectTrust: async ({ extensionsResult }) => {
|
|
816
|
+
let trusted = await resolveProjectTrusted({
|
|
817
|
+
cwd: cwd2,
|
|
818
|
+
trustStore,
|
|
819
|
+
trustOverride: parsed.projectTrustOverride,
|
|
820
|
+
defaultProjectTrust: startupSettingsManager.getDefaultProjectTrust(),
|
|
821
|
+
extensionsResult,
|
|
822
|
+
projectTrustContext: projectTrustContext ?? (isInitialRuntime && startupView ? createStartupViewTrustContext(cwd2, startupView) : createProjectTrustContext({
|
|
823
|
+
cwd: cwd2,
|
|
824
|
+
mode: isInitialRuntime ? trustPromptMode : appMode,
|
|
825
|
+
settingsManager: startupSettingsManager,
|
|
826
|
+
hasUI: isInitialRuntime && trustPromptMode === "interactive"
|
|
827
|
+
})),
|
|
828
|
+
onExtensionError: (message) => projectTrustDiagnostics.push({ type: "warning", message })
|
|
829
|
+
});
|
|
830
|
+
return projectTrustByCwd.set(cwd2, trusted), trusted;
|
|
831
|
+
}
|
|
832
|
+
} : skipMissingPackageInstall ? { skipMissingPackageInstall } : void 0,
|
|
833
|
+
resourceLoaderOptions: {
|
|
834
|
+
additionalExtensionPaths: resolvedExtensionPaths,
|
|
835
|
+
additionalSkillPaths: resolvedSkillPaths,
|
|
836
|
+
additionalPromptTemplatePaths: resolvedPromptTemplatePaths,
|
|
837
|
+
additionalThemePaths: resolvedThemePaths,
|
|
838
|
+
noExtensions: parsed.noExtensions,
|
|
839
|
+
noSkills: parsed.noSkills,
|
|
840
|
+
noPromptTemplates: parsed.noPromptTemplates,
|
|
841
|
+
noThemes: parsed.noThemes,
|
|
842
|
+
noContextFiles: parsed.noContextFiles,
|
|
843
|
+
systemPrompt: parsed.systemPrompt,
|
|
844
|
+
appendSystemPrompt: parsed.appendSystemPrompt,
|
|
845
|
+
extensionFactories: [...builtinRoster, ...options?.extensionFactories ?? []]
|
|
846
|
+
}
|
|
847
|
+
}), { settingsManager: settingsManager2, modelRuntime: modelRuntime2, resourceLoader: resourceLoader2 } = services2;
|
|
848
|
+
parsed.model && !resolveCliModel({
|
|
849
|
+
cliProvider: parsed.provider,
|
|
850
|
+
cliModel: parsed.model,
|
|
851
|
+
cliThinking: parsed.thinking,
|
|
852
|
+
modelRuntime: modelRuntime2
|
|
853
|
+
}).model && await modelRuntime2.refreshIfStale();
|
|
854
|
+
let diagnostics = [
|
|
855
|
+
...projectTrustDiagnostics,
|
|
856
|
+
...services2.diagnostics,
|
|
857
|
+
...collectSettingsDiagnostics(settingsManager2, "runtime creation"),
|
|
858
|
+
...resourceLoader2.getExtensions().errors.map(({ path, error }) => ({
|
|
859
|
+
type: "error",
|
|
860
|
+
message: `Failed to load extension "${path}": ${error}`
|
|
861
|
+
}))
|
|
862
|
+
], modelPatterns = parsed.models ?? settingsManager2.getEnabledModels(), scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRuntime2) : [], { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics } = buildSessionOptions(parsed, scopedModels, sessionManager2.buildSessionContext().messages.length > 0, modelRuntime2, settingsManager2);
|
|
863
|
+
diagnostics.push(...sessionOptionDiagnostics), parsed.apiKey && (sessionOptions.model ? await modelRuntime2.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey, {
|
|
864
|
+
allowNetwork: !1
|
|
865
|
+
}) : diagnostics.push({
|
|
866
|
+
type: "error",
|
|
867
|
+
message: "--api-key requires a model to be specified via --model, --provider/--model, or --models"
|
|
868
|
+
}));
|
|
869
|
+
let created = await createAgentSessionFromServices({
|
|
870
|
+
services: services2,
|
|
871
|
+
sessionManager: sessionManager2,
|
|
872
|
+
sessionStartEvent,
|
|
873
|
+
model: sessionOptions.model,
|
|
874
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
875
|
+
scopedModels: sessionOptions.scopedModels,
|
|
876
|
+
tools: sessionOptions.tools,
|
|
877
|
+
excludeTools: sessionOptions.excludeTools,
|
|
878
|
+
noTools: sessionOptions.noTools,
|
|
879
|
+
customTools: sessionOptions.customTools
|
|
880
|
+
}), cliThinkingOverride = parsed.thinking !== void 0 || cliThinkingFromModel;
|
|
881
|
+
return created.session.model && cliThinkingOverride && created.session.setThinkingLevel(created.session.thinkingLevel), {
|
|
882
|
+
...created,
|
|
883
|
+
services: services2,
|
|
884
|
+
diagnostics
|
|
885
|
+
};
|
|
886
|
+
};
|
|
887
|
+
time("createRuntime");
|
|
888
|
+
let runtime = await createAgentSessionRuntime(createRuntime, {
|
|
889
|
+
cwd: sessionManager.getCwd(),
|
|
890
|
+
agentDir,
|
|
891
|
+
sessionManager,
|
|
892
|
+
onRuntimeApplied: bindRuntimeBridges
|
|
893
|
+
});
|
|
894
|
+
if (startupView?.isExitRequested) {
|
|
895
|
+
await runtime.dispose();
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
markStartupMilestone("runtime_hydrated"), time("createAgentSessionRuntime"), appMode !== "interactive" && await runSessionRetention();
|
|
899
|
+
let { services, session, modelFallbackMessage } = runtime, { settingsManager, modelRuntime, resourceLoader } = services;
|
|
900
|
+
if (applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy), configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs()), parsed.help) {
|
|
901
|
+
let extensionFlags = resourceLoader.getExtensions().extensions.flatMap((extension) => Array.from(extension.flags.values()));
|
|
902
|
+
printHelp(extensionFlags), process.exit(0);
|
|
903
|
+
}
|
|
904
|
+
if (parsed.listModels !== void 0) {
|
|
905
|
+
let searchPattern = typeof parsed.listModels == "string" ? parsed.listModels : void 0;
|
|
906
|
+
await listModels(modelRuntime, searchPattern), process.exit(0);
|
|
907
|
+
}
|
|
908
|
+
let stdinContent, startupBenchmark = isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK);
|
|
909
|
+
appMode !== "rpc" && !startupBenchmark && (stdinContent = await readPipedStdin(), stdinContent !== void 0 && appMode === "interactive" && (appMode = "print")), time("readPipedStdin");
|
|
910
|
+
let { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
|
|
911
|
+
if (time("prepareInitialMessage"), initTheme(settingsManager.getTheme(), appMode === "interactive"), time("initTheme"), appMode === "interactive" && !startupView && deprecationWarnings.length > 0 && await showDeprecationWarnings(deprecationWarnings), time("resolveModelScope"), appMode === "interactive" && startupView || reportDiagnostics(runtime.diagnostics), runtime.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
912
|
+
let extensionHint = runtime.diagnostics.some((diagnostic) => diagnostic.message.includes("Failed to load extension")) ? `
|
|
913
|
+
${EXTENSION_LOAD_FAILURE_HINT}` : "";
|
|
914
|
+
if (startupView) {
|
|
915
|
+
process.exitCode = 1, await startupView.fail(`${runtime.diagnostics.map((diagnostic) => diagnostic.message).join(`
|
|
916
|
+
`)}${extensionHint}`);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
extensionHint && console.error(chalk4.yellow(EXTENSION_LOAD_FAILURE_HINT)), process.exit(1);
|
|
920
|
+
}
|
|
921
|
+
if (time("createAgentSession"), appMode !== "interactive" && !session.model && (console.error(chalk4.red(formatNoModelsAvailableMessage())), process.exit(1)), startupBenchmark && appMode !== "interactive" && (console.error(chalk4.red("Error: PI_STARTUP_BENCHMARK only supports interactive mode")), process.exit(1)), appMode === "rpc") {
|
|
922
|
+
let { runRpcMode } = await import("./rpc-mode-W5ZTLTMZ.js");
|
|
923
|
+
printTimings(), await runRpcMode(runtime);
|
|
924
|
+
} else if (appMode === "interactive") {
|
|
925
|
+
let [{ InteractiveMode }, { loadDeferredBuiltinExtensions }] = await Promise.all([
|
|
926
|
+
interactiveModeImport,
|
|
927
|
+
import("./builtin-extensions-QATGXENO.js")
|
|
928
|
+
]), interactiveMode = new InteractiveMode(runtime, {
|
|
929
|
+
migratedProviders,
|
|
930
|
+
modelFallbackMessage,
|
|
931
|
+
autoTrustOnReloadCwd,
|
|
932
|
+
initialMessage,
|
|
933
|
+
initialImages,
|
|
934
|
+
initialMessages: parsed.messages,
|
|
935
|
+
verbose: parsed.verbose,
|
|
936
|
+
deprecationWarnings: startupView ? deprecationWarnings : void 0,
|
|
937
|
+
startupDiagnostics: startupView ? runtime.diagnostics.filter((diagnostic) => diagnostic.type !== "error") : void 0,
|
|
938
|
+
startupView: startupView?.binding(),
|
|
939
|
+
deferredMaintenance: runSessionRetention,
|
|
940
|
+
deferredBuiltinFactories: parsed.noExtensions ? void 0 : loadDeferredBuiltinExtensions,
|
|
941
|
+
onDeferredBuiltinsAttached: rememberAttachedFactories
|
|
942
|
+
});
|
|
943
|
+
if (startupBenchmark) {
|
|
944
|
+
let { prepareBenchmarkRequest } = await import("./benchmark-request-UC7PD3V3.js"), request = await prepareBenchmarkRequest(session);
|
|
945
|
+
await interactiveMode.init(), time("interactiveMode.init"), await interactiveMode.waitForStartupReady(), time("promptBarrier"), await request(), await new Promise((resolve3) => setTimeout(resolve3, 150)), interactiveMode.stop(), await runtime.dispose(), stopThemeWatcher(), printTimings(), process.stdout.writableLength > 0 && await new Promise((resolve3) => process.stdout.once("drain", resolve3)), process.stderr.writableLength > 0 && await new Promise((resolve3) => process.stderr.once("drain", resolve3));
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
await interactiveMode.init(), time("interactiveMode.init"), printTimings(), await interactiveMode.run();
|
|
949
|
+
} else {
|
|
950
|
+
let { runPrintMode } = await import("./print-mode-XSFM26EL.js");
|
|
951
|
+
printTimings();
|
|
952
|
+
let exitCode = await runPrintMode(runtime, {
|
|
953
|
+
mode: toPrintOutputMode(appMode),
|
|
954
|
+
messages: parsed.messages,
|
|
955
|
+
initialMessage,
|
|
956
|
+
initialImages
|
|
957
|
+
});
|
|
958
|
+
stopThemeWatcher(), restoreStdout(), exitCode !== 0 && (process.exitCode = exitCode);
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
export {
|
|
964
|
+
readPipedStdin,
|
|
965
|
+
main
|
|
966
|
+
};
|