@pasko70/pibo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex/skills/pi-agent-harness/SKILL.md +319 -0
- package/.codex/skills/pi-agent-harness/agents/openai.yaml +4 -0
- package/README.md +318 -0
- package/context/codex-base-prompt.md +144 -0
- package/context/pibo-compaction-prompt.md +100 -0
- package/context/pibo-system-prompt.md +17 -0
- package/dist/apps/chat/agent-profiles.js +26 -0
- package/dist/apps/chat/agent-store.js +336 -0
- package/dist/apps/chat/event-log.js +307 -0
- package/dist/apps/chat/read-model.js +218 -0
- package/dist/apps/chat/rooms.js +321 -0
- package/dist/apps/chat/session-metadata.js +14 -0
- package/dist/apps/chat/stream.js +122 -0
- package/dist/apps/chat/trace.js +1182 -0
- package/dist/apps/chat/web-app.js +2569 -0
- package/dist/apps/chat-ui/assets/apl-BxEMbctQ.js +1 -0
- package/dist/apps/chat-ui/assets/asciiarmor-eFjeGRuZ.js +1 -0
- package/dist/apps/chat-ui/assets/asn1-Cfx-0pt9.js +1 -0
- package/dist/apps/chat-ui/assets/asterisk-B5BHTsBr.js +1 -0
- package/dist/apps/chat-ui/assets/brainfuck-CAA2xofr.js +1 -0
- package/dist/apps/chat-ui/assets/clike-BoDCOLzN.js +1 -0
- package/dist/apps/chat-ui/assets/clojure-kVFSWX0o.js +1 -0
- package/dist/apps/chat-ui/assets/cmake-BUPAhezI.js +1 -0
- package/dist/apps/chat-ui/assets/cobol-BfgHZgup.js +1 -0
- package/dist/apps/chat-ui/assets/coffeescript-G1Pe_1AZ.js +1 -0
- package/dist/apps/chat-ui/assets/commonlisp-B3N0CjHn.js +1 -0
- package/dist/apps/chat-ui/assets/crystal-C15ndaGM.js +1 -0
- package/dist/apps/chat-ui/assets/css-BqOeyZOV.js +1 -0
- package/dist/apps/chat-ui/assets/cypher-KjIKv-wW.js +1 -0
- package/dist/apps/chat-ui/assets/d-BlT5AEC-.js +1 -0
- package/dist/apps/chat-ui/assets/diff-oF98tbqj.js +1 -0
- package/dist/apps/chat-ui/assets/dist--55mTWk3.js +1 -0
- package/dist/apps/chat-ui/assets/dist-B5rcjVCj.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BPv5MdlL.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BZ39rB1W.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BsedZGJo.js +1 -0
- package/dist/apps/chat-ui/assets/dist-BvO6SpaM.js +9 -0
- package/dist/apps/chat-ui/assets/dist-C5YJOwhH.js +1 -0
- package/dist/apps/chat-ui/assets/dist-C5oXtFSP.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CG_gRSwv.js +23 -0
- package/dist/apps/chat-ui/assets/dist-CKM5j-iy.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CUp9us2q.js +1 -0
- package/dist/apps/chat-ui/assets/dist-CZ9T4Cly.js +1 -0
- package/dist/apps/chat-ui/assets/dist-D4HhiFWB.js +6 -0
- package/dist/apps/chat-ui/assets/dist-DHE-yBLH.js +1 -0
- package/dist/apps/chat-ui/assets/dist-DSKQpPaz.js +1 -0
- package/dist/apps/chat-ui/assets/dist-L1B-KWZO.js +1 -0
- package/dist/apps/chat-ui/assets/dist-SVPsM5Oi.js +13 -0
- package/dist/apps/chat-ui/assets/dist-Zqt9kNG9.js +1 -0
- package/dist/apps/chat-ui/assets/dist-_DPv0-QF.js +1 -0
- package/dist/apps/chat-ui/assets/dist-_oM7g0eh.js +11 -0
- package/dist/apps/chat-ui/assets/dist-laadbMWg.js +1 -0
- package/dist/apps/chat-ui/assets/dist-nFui3f-r.js +2 -0
- package/dist/apps/chat-ui/assets/dist-tGfufz3b.js +1 -0
- package/dist/apps/chat-ui/assets/dockerfile-CUaqzcqp.js +1 -0
- package/dist/apps/chat-ui/assets/dtd-VCA9yr61.js +1 -0
- package/dist/apps/chat-ui/assets/dylan-O-V5Dw5W.js +1 -0
- package/dist/apps/chat-ui/assets/ebnf-SPmdBkvT.js +1 -0
- package/dist/apps/chat-ui/assets/ecl-ChfCttfI.js +1 -0
- package/dist/apps/chat-ui/assets/eiffel-cB9EbjeN.js +1 -0
- package/dist/apps/chat-ui/assets/elm-BTiVflBU.js +1 -0
- package/dist/apps/chat-ui/assets/erlang-egf0TXFm.js +1 -0
- package/dist/apps/chat-ui/assets/factor-C2tAxNob.js +1 -0
- package/dist/apps/chat-ui/assets/fcl-BiCjh1tj.js +1 -0
- package/dist/apps/chat-ui/assets/forth-C4kDGW6u.js +1 -0
- package/dist/apps/chat-ui/assets/fortran-DzkLaPnd.js +1 -0
- package/dist/apps/chat-ui/assets/gas-DMOxskQF.js +1 -0
- package/dist/apps/chat-ui/assets/gherkin-BPxBpp-k.js +1 -0
- package/dist/apps/chat-ui/assets/groovy-CkEnc0ZY.js +1 -0
- package/dist/apps/chat-ui/assets/haskell-Dadpo9-w.js +1 -0
- package/dist/apps/chat-ui/assets/haxe-CDNZL9MW.js +1 -0
- package/dist/apps/chat-ui/assets/http-jy9Zxxt3.js +1 -0
- package/dist/apps/chat-ui/assets/idl-CGSB6iiy.js +1 -0
- package/dist/apps/chat-ui/assets/index-BdcqTugD.js +151 -0
- package/dist/apps/chat-ui/assets/index-Dk-opWl3.css +1 -0
- package/dist/apps/chat-ui/assets/javascript-DSlzRUd8.js +1 -0
- package/dist/apps/chat-ui/assets/julia-DTiF9v6R.js +1 -0
- package/dist/apps/chat-ui/assets/livescript-Ci8Xxna6.js +1 -0
- package/dist/apps/chat-ui/assets/lua-eVxIrt9t.js +1 -0
- package/dist/apps/chat-ui/assets/mathematica-Da3grj36.js +1 -0
- package/dist/apps/chat-ui/assets/mbox-BWBMSafM.js +1 -0
- package/dist/apps/chat-ui/assets/mirc-CtHu9S1B.js +1 -0
- package/dist/apps/chat-ui/assets/mllike-wTFlPWXS.js +1 -0
- package/dist/apps/chat-ui/assets/modelica-cKbQ0UXu.js +1 -0
- package/dist/apps/chat-ui/assets/mscgen-C5pXQCMK.js +1 -0
- package/dist/apps/chat-ui/assets/mumps-CKBHkOQq.js +1 -0
- package/dist/apps/chat-ui/assets/nginx-B00AiQel.js +1 -0
- package/dist/apps/chat-ui/assets/nsis-SMDwKltR.js +1 -0
- package/dist/apps/chat-ui/assets/ntriples-B_36EBV0.js +1 -0
- package/dist/apps/chat-ui/assets/octave-BXPjzAif.js +1 -0
- package/dist/apps/chat-ui/assets/oz-Dedpat1M.js +1 -0
- package/dist/apps/chat-ui/assets/pascal-CMcUg72K.js +1 -0
- package/dist/apps/chat-ui/assets/perl-DoVTbnzt.js +1 -0
- package/dist/apps/chat-ui/assets/pig-CULXT1YV.js +1 -0
- package/dist/apps/chat-ui/assets/powershell-Cv5Uhf6b.js +1 -0
- package/dist/apps/chat-ui/assets/properties-CQ1C2P-M.js +1 -0
- package/dist/apps/chat-ui/assets/protobuf-SRlvzrl6.js +1 -0
- package/dist/apps/chat-ui/assets/pug-Bo3wfL-f.js +1 -0
- package/dist/apps/chat-ui/assets/puppet-ClSqCGj6.js +1 -0
- package/dist/apps/chat-ui/assets/python-C2_X1GpX.js +1 -0
- package/dist/apps/chat-ui/assets/q-B_6Gdyzl.js +1 -0
- package/dist/apps/chat-ui/assets/r-BD07NGED.js +1 -0
- package/dist/apps/chat-ui/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/apps/chat-ui/assets/rpm-CRu5Z2Jl.js +1 -0
- package/dist/apps/chat-ui/assets/ruby-dZPnOz8h.js +1 -0
- package/dist/apps/chat-ui/assets/sas-S2t8_sDI.js +1 -0
- package/dist/apps/chat-ui/assets/scheme-WcyFWLW2.js +1 -0
- package/dist/apps/chat-ui/assets/shell-DUelnYSh.js +1 -0
- package/dist/apps/chat-ui/assets/sieve-jDjlVhNh.js +1 -0
- package/dist/apps/chat-ui/assets/simple-mode-CL04yRVp.js +1 -0
- package/dist/apps/chat-ui/assets/smalltalk-ddWDYy10.js +1 -0
- package/dist/apps/chat-ui/assets/solr-C7rQhLuW.js +1 -0
- package/dist/apps/chat-ui/assets/sparql--fPCCgVd.js +1 -0
- package/dist/apps/chat-ui/assets/spreadsheet-DjthqD5G.js +1 -0
- package/dist/apps/chat-ui/assets/sql-D_dieYbr.js +1 -0
- package/dist/apps/chat-ui/assets/stex-rHcFYcA0.js +1 -0
- package/dist/apps/chat-ui/assets/stylus-DxF70RNr.js +1 -0
- package/dist/apps/chat-ui/assets/swift-T0hDoOb-.js +1 -0
- package/dist/apps/chat-ui/assets/tcl-Dlzy1mPk.js +1 -0
- package/dist/apps/chat-ui/assets/textile-Dy5rFZe5.js +1 -0
- package/dist/apps/chat-ui/assets/tiddlywiki-DQP1OymS.js +1 -0
- package/dist/apps/chat-ui/assets/tiki-0vOj3DB2.js +1 -0
- package/dist/apps/chat-ui/assets/toml-DEltN0lI.js +1 -0
- package/dist/apps/chat-ui/assets/troff-CRbBpEqY.js +1 -0
- package/dist/apps/chat-ui/assets/ttcn-M5q1nLKg.js +1 -0
- package/dist/apps/chat-ui/assets/ttcn-cfg-Rmw9NWq9.js +1 -0
- package/dist/apps/chat-ui/assets/turtle-BCDWhJK0.js +1 -0
- package/dist/apps/chat-ui/assets/vb-QQ7LGlOz.js +1 -0
- package/dist/apps/chat-ui/assets/vbscript-BiSEdUzz.js +1 -0
- package/dist/apps/chat-ui/assets/velocity-CzMg5_6w.js +1 -0
- package/dist/apps/chat-ui/assets/verilog-BJOO83gk.js +1 -0
- package/dist/apps/chat-ui/assets/vhdl-ed4zAZAA.js +1 -0
- package/dist/apps/chat-ui/assets/webidl-Ddy6hbV6.js +1 -0
- package/dist/apps/chat-ui/assets/xquery-Bw1zwhh6.js +1 -0
- package/dist/apps/chat-ui/assets/yacas-DZdTXy3s.js +1 -0
- package/dist/apps/chat-ui/assets/z80-DMG02_YV.js +1 -0
- package/dist/apps/chat-ui/index.html +15 -0
- package/dist/apps/context-files-ui/assets/apl-14BqhLYK.js +1 -0
- package/dist/apps/context-files-ui/assets/asciiarmor-WLvjqI7d.js +1 -0
- package/dist/apps/context-files-ui/assets/asn1-Bg4FbdCg.js +1 -0
- package/dist/apps/context-files-ui/assets/asterisk-B2MO-X4d.js +1 -0
- package/dist/apps/context-files-ui/assets/brainfuck-CV9kufud.js +1 -0
- package/dist/apps/context-files-ui/assets/clike-CjmcUpt6.js +1 -0
- package/dist/apps/context-files-ui/assets/clojure-De3QGfx6.js +1 -0
- package/dist/apps/context-files-ui/assets/cmake-i2VDNaRq.js +1 -0
- package/dist/apps/context-files-ui/assets/cobol-BwO6DF08.js +1 -0
- package/dist/apps/context-files-ui/assets/coffeescript-BtivDvRz.js +1 -0
- package/dist/apps/context-files-ui/assets/commonlisp-DFkEQdLP.js +1 -0
- package/dist/apps/context-files-ui/assets/crystal-CU0NkcVL.js +1 -0
- package/dist/apps/context-files-ui/assets/css-CbMZAQ1W.js +1 -0
- package/dist/apps/context-files-ui/assets/cypher-Dke5QOzv.js +1 -0
- package/dist/apps/context-files-ui/assets/d-TPqSVaHM.js +1 -0
- package/dist/apps/context-files-ui/assets/diff-B365LSoZ.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-B5PTVnox.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-B5ZAfwf5.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-BJW3917N.js +11 -0
- package/dist/apps/context-files-ui/assets/dist-BkUONE3N.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CKQF1zEu.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CwbH_3RN.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-CxRLRmMx.js +2 -0
- package/dist/apps/context-files-ui/assets/dist-D1KyNDg5.js +13 -0
- package/dist/apps/context-files-ui/assets/dist-DFi2YGux.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DKoyMSNr.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DLMjd26T.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DQXzt2Ng.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DotDq_kD.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-DyfSeBMu.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-MyZgX9K2.js +9 -0
- package/dist/apps/context-files-ui/assets/dist-QQuDy4KA.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-YwR9dpb-.js +1 -0
- package/dist/apps/context-files-ui/assets/dist-dTBsFYAl.js +1 -0
- package/dist/apps/context-files-ui/assets/dockerfile-CJb2sekW.js +1 -0
- package/dist/apps/context-files-ui/assets/dtd-CBMymJ7O.js +1 -0
- package/dist/apps/context-files-ui/assets/dylan-08Azy1NK.js +1 -0
- package/dist/apps/context-files-ui/assets/ebnf-Dkum_1J8.js +1 -0
- package/dist/apps/context-files-ui/assets/ecl-dhxjHL8y.js +1 -0
- package/dist/apps/context-files-ui/assets/eiffel-C446m6dI.js +1 -0
- package/dist/apps/context-files-ui/assets/elm-po1E9de0.js +1 -0
- package/dist/apps/context-files-ui/assets/erlang-BD5LkVkR.js +1 -0
- package/dist/apps/context-files-ui/assets/factor-B2EMQZkP.js +1 -0
- package/dist/apps/context-files-ui/assets/fcl-DkEOamHd.js +1 -0
- package/dist/apps/context-files-ui/assets/forth-dCg2_HVB.js +1 -0
- package/dist/apps/context-files-ui/assets/fortran-3ZpXLFh1.js +1 -0
- package/dist/apps/context-files-ui/assets/gas-DMmxLZRI.js +1 -0
- package/dist/apps/context-files-ui/assets/gherkin-DUSFg2R6.js +1 -0
- package/dist/apps/context-files-ui/assets/groovy-Cmduloe1.js +1 -0
- package/dist/apps/context-files-ui/assets/haskell-Cyr255R9.js +1 -0
- package/dist/apps/context-files-ui/assets/haxe-BJVKtprM.js +1 -0
- package/dist/apps/context-files-ui/assets/http-DszHFpc-.js +1 -0
- package/dist/apps/context-files-ui/assets/idl-Cati9Nrv.js +1 -0
- package/dist/apps/context-files-ui/assets/index-BwRDoHMC.css +1 -0
- package/dist/apps/context-files-ui/assets/index-GwvjXytt.js +202 -0
- package/dist/apps/context-files-ui/assets/javascript-C5pDVaoP.js +1 -0
- package/dist/apps/context-files-ui/assets/julia-DlqY1cTU.js +1 -0
- package/dist/apps/context-files-ui/assets/livescript-C6p8-2W1.js +1 -0
- package/dist/apps/context-files-ui/assets/lua-BxuTHaF7.js +1 -0
- package/dist/apps/context-files-ui/assets/mathematica-nDHZUMJT.js +1 -0
- package/dist/apps/context-files-ui/assets/mbox-DAaR0Hcz.js +1 -0
- package/dist/apps/context-files-ui/assets/mirc-CCA0FRfl.js +1 -0
- package/dist/apps/context-files-ui/assets/mllike-Cw3Iccsb.js +1 -0
- package/dist/apps/context-files-ui/assets/modelica-Czx80fNR.js +1 -0
- package/dist/apps/context-files-ui/assets/mscgen-BmfuTbzG.js +1 -0
- package/dist/apps/context-files-ui/assets/mumps-Ds_ZaumL.js +1 -0
- package/dist/apps/context-files-ui/assets/nginx-D9M2PQ4U.js +1 -0
- package/dist/apps/context-files-ui/assets/nsis-DOo3SJmd.js +1 -0
- package/dist/apps/context-files-ui/assets/ntriples-DLHGTvHs.js +1 -0
- package/dist/apps/context-files-ui/assets/octave-8jj96JiC.js +1 -0
- package/dist/apps/context-files-ui/assets/oz-BmMq7iC4.js +1 -0
- package/dist/apps/context-files-ui/assets/pascal-BgMr6XpT.js +1 -0
- package/dist/apps/context-files-ui/assets/perl-D6YJObi_.js +1 -0
- package/dist/apps/context-files-ui/assets/pig-nx7uchs8.js +1 -0
- package/dist/apps/context-files-ui/assets/powershell-B4IPkVxR.js +1 -0
- package/dist/apps/context-files-ui/assets/properties-CoavQdLC.js +1 -0
- package/dist/apps/context-files-ui/assets/protobuf-D5EWhcmc.js +1 -0
- package/dist/apps/context-files-ui/assets/pug-QU72BPAa.js +1 -0
- package/dist/apps/context-files-ui/assets/puppet-B_0GFuyD.js +1 -0
- package/dist/apps/context-files-ui/assets/python-Cs7sNzy_.js +1 -0
- package/dist/apps/context-files-ui/assets/q-BIB9pPtI.js +1 -0
- package/dist/apps/context-files-ui/assets/r-CN5s4f3o.js +1 -0
- package/dist/apps/context-files-ui/assets/rpm-Ct_Ck8mQ.js +1 -0
- package/dist/apps/context-files-ui/assets/ruby-BVPradRk.js +1 -0
- package/dist/apps/context-files-ui/assets/sas-DN4j74IF.js +1 -0
- package/dist/apps/context-files-ui/assets/scheme-CvNgHAnh.js +1 -0
- package/dist/apps/context-files-ui/assets/shell-BjiMLAaM.js +1 -0
- package/dist/apps/context-files-ui/assets/sieve-C2U1O5Z4.js +1 -0
- package/dist/apps/context-files-ui/assets/simple-mode-DnMbQuKW.js +1 -0
- package/dist/apps/context-files-ui/assets/smalltalk-DkYwYufV.js +1 -0
- package/dist/apps/context-files-ui/assets/solr-BopnSD-v.js +1 -0
- package/dist/apps/context-files-ui/assets/sparql-Cpg3YQfd.js +1 -0
- package/dist/apps/context-files-ui/assets/spreadsheet-kRxtVt9J.js +1 -0
- package/dist/apps/context-files-ui/assets/sql-DYI2GwJR.js +1 -0
- package/dist/apps/context-files-ui/assets/stex-BCRT8IJ3.js +1 -0
- package/dist/apps/context-files-ui/assets/stylus-CARoeVE9.js +1 -0
- package/dist/apps/context-files-ui/assets/swift-DKNaLAK6.js +1 -0
- package/dist/apps/context-files-ui/assets/tcl-CQyXkgMH.js +1 -0
- package/dist/apps/context-files-ui/assets/textile-Yg_UWn-t.js +1 -0
- package/dist/apps/context-files-ui/assets/tiddlywiki-dqVbkfX4.js +1 -0
- package/dist/apps/context-files-ui/assets/tiki-CC_ic8g0.js +1 -0
- package/dist/apps/context-files-ui/assets/toml-B7gGzVkJ.js +1 -0
- package/dist/apps/context-files-ui/assets/troff-Bq3z6oAu.js +1 -0
- package/dist/apps/context-files-ui/assets/ttcn-GvRgs2AT.js +1 -0
- package/dist/apps/context-files-ui/assets/ttcn-cfg-CGCXz7Vo.js +1 -0
- package/dist/apps/context-files-ui/assets/turtle-CwIpz2yy.js +1 -0
- package/dist/apps/context-files-ui/assets/vb-BmcHUM2C.js +1 -0
- package/dist/apps/context-files-ui/assets/vbscript-Cs9dylre.js +1 -0
- package/dist/apps/context-files-ui/assets/velocity-CBWU0VCy.js +1 -0
- package/dist/apps/context-files-ui/assets/verilog-DVCHmufx.js +1 -0
- package/dist/apps/context-files-ui/assets/vhdl-BGDk4f1d.js +1 -0
- package/dist/apps/context-files-ui/assets/webidl-egXQEWlC.js +1 -0
- package/dist/apps/context-files-ui/assets/xquery-5f0hn7cg.js +1 -0
- package/dist/apps/context-files-ui/assets/yacas-DNs9XkmQ.js +1 -0
- package/dist/apps/context-files-ui/assets/z80-B7Dfb4UO.js +1 -0
- package/dist/apps/context-files-ui/index.html +14 -0
- package/dist/auth/better-auth.js +129 -0
- package/dist/auth/types.js +14 -0
- package/dist/bin/pibo.js +3 -0
- package/dist/channels/types.js +1 -0
- package/dist/cli-errors.js +18 -0
- package/dist/cli.js +264 -0
- package/dist/config/config.js +167 -0
- package/dist/core/base-prompt.js +104 -0
- package/dist/core/codex-compat.js +44 -0
- package/dist/core/compaction-prompt.js +258 -0
- package/dist/core/events.js +1 -0
- package/dist/core/profiles.js +138 -0
- package/dist/core/routed-session.js +538 -0
- package/dist/core/runtime.js +323 -0
- package/dist/core/session-router.js +437 -0
- package/dist/core/system-prompt-template.js +56 -0
- package/dist/core/thinking.js +9 -0
- package/dist/core/workspace.js +5 -0
- package/dist/debug/events.js +92 -0
- package/dist/debug/index.js +631 -0
- package/dist/debug/session.js +200 -0
- package/dist/debug/sql.js +238 -0
- package/dist/debug/stores.js +49 -0
- package/dist/debug/trace.js +245 -0
- package/dist/env.js +32 -0
- package/dist/gateway/client.js +200 -0
- package/dist/gateway/protocol.js +46 -0
- package/dist/gateway/request.js +146 -0
- package/dist/gateway/server.js +221 -0
- package/dist/gateway/tool.js +69 -0
- package/dist/gateway/web.js +80 -0
- package/dist/index.js +23 -0
- package/dist/local/client.js +77 -0
- package/dist/local/extension.js +548 -0
- package/dist/local/tui.js +25 -0
- package/dist/mcp/agent-context.js +123 -0
- package/dist/mcp/client.js +332 -0
- package/dist/mcp/commands/call.js +146 -0
- package/dist/mcp/commands/grep.js +145 -0
- package/dist/mcp/commands/info.js +71 -0
- package/dist/mcp/commands/list.js +94 -0
- package/dist/mcp/config-command.js +217 -0
- package/dist/mcp/config.js +440 -0
- package/dist/mcp/daemon-client.js +266 -0
- package/dist/mcp/daemon.js +327 -0
- package/dist/mcp/errors.js +287 -0
- package/dist/mcp/index.js +431 -0
- package/dist/mcp/output.js +171 -0
- package/dist/mcp/python-runtime.js +131 -0
- package/dist/mcp/registry.js +116 -0
- package/dist/mcp/version.js +5 -0
- package/dist/pi-packages/cli.js +92 -0
- package/dist/pi-packages/installer.js +70 -0
- package/dist/pi-packages/metadata.js +231 -0
- package/dist/pi-packages/runtime.js +61 -0
- package/dist/pi-packages/store.js +175 -0
- package/dist/pi-packages/types.js +1 -0
- package/dist/plugins/better-auth.js +11 -0
- package/dist/plugins/builtin.js +249 -0
- package/dist/plugins/chat-web.js +11 -0
- package/dist/plugins/codex-compat.js +72 -0
- package/dist/plugins/context-files-store.js +354 -0
- package/dist/plugins/context-files.js +999 -0
- package/dist/plugins/core-tools.js +94 -0
- package/dist/plugins/example.js +67 -0
- package/dist/plugins/registry.js +368 -0
- package/dist/plugins/remote-agent.js +9 -0
- package/dist/plugins/types.js +1 -0
- package/dist/plugins/web.js +11 -0
- package/dist/reliability/store.js +759 -0
- package/dist/remote/channel.js +176 -0
- package/dist/remote/client.js +92 -0
- package/dist/remote/examples/tui-controller.js +263 -0
- package/dist/remote/protocol.js +55 -0
- package/dist/remote/session-client.js +189 -0
- package/dist/runs/registry.js +323 -0
- package/dist/runs/tools.js +185 -0
- package/dist/sessions/bindings.js +41 -0
- package/dist/sessions/sqlite-store.js +154 -0
- package/dist/sessions/store.js +125 -0
- package/dist/shared/trace-order.js +83 -0
- package/dist/subagents/tool.js +63 -0
- package/dist/tools/browser-use-cdp.js +207 -0
- package/dist/tools/browser-use-leases.js +338 -0
- package/dist/tools/browser-use-wrapper.js +338 -0
- package/dist/tools/codex-compat.js +85 -0
- package/dist/tools/desktop-env.js +90 -0
- package/dist/tools/guides.js +276 -0
- package/dist/tools/index.js +366 -0
- package/dist/tools/python-runtime.js +154 -0
- package/dist/tools/registry.js +107 -0
- package/dist/tools/web-search.js +137 -0
- package/dist/web/auth.js +10 -0
- package/dist/web/channel.js +151 -0
- package/dist/web/http.js +110 -0
- package/dist/web/types.js +1 -0
- package/package.json +74 -0
- package/src/mcp/LICENSE.mcp-cli +21 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
## 1. Role and Context
|
|
2
|
+
|
|
3
|
+
You are Pibo, a coding agent based on GPT-5. You and the user share the same workspace and collaborate to achieve the user's goals.
|
|
4
|
+
|
|
5
|
+
As an expert coding agent, your primary focus is writing code, answering questions, and helping the user complete their task in the current environment. You build context by examining the codebase first without making assumptions or jumping to conclusions. You think through the nuances of the code you encounter, and embody the mentality of a skilled senior software engineer.
|
|
6
|
+
|
|
7
|
+
## 2. Personality
|
|
8
|
+
|
|
9
|
+
### Core Description
|
|
10
|
+
|
|
11
|
+
You are a deeply pragmatic, effective software engineer. You take engineering quality seriously, and collaboration comes through as direct, factual statements. You communicate efficiently, keeping the user clearly informed about ongoing actions without unnecessary detail.
|
|
12
|
+
|
|
13
|
+
### Values
|
|
14
|
+
|
|
15
|
+
You are guided by these core values:
|
|
16
|
+
|
|
17
|
+
- Clarity: You communicate reasoning explicitly and concretely, so decisions and tradeoffs are easy to evaluate upfront.
|
|
18
|
+
- Pragmatism: You keep the end goal and momentum in mind, focusing on what will actually work and move things forward to achieve the user's goal.
|
|
19
|
+
- Rigor: You expect technical arguments to be coherent and defensible, and you surface gaps or weak assumptions politely with emphasis on creating clarity and moving the task forward.
|
|
20
|
+
|
|
21
|
+
### Interaction Style
|
|
22
|
+
|
|
23
|
+
You communicate concisely and respectfully, focusing on the task at hand. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.
|
|
24
|
+
|
|
25
|
+
You avoid cheerleading, motivational language, or artificial reassurance, or any kind of fluff. You don't comment on user requests, positively or negatively, unless there is reason for escalation. You don't feel like you need to fill the space with words; you stay concise and communicate what is necessary for user collaboration — not more, not less.
|
|
26
|
+
|
|
27
|
+
### Escalation
|
|
28
|
+
|
|
29
|
+
You may challenge the user to raise their technical bar, but you never patronize or dismiss their concerns. When presenting an alternative approach or solution to the user, you explain the reasoning behind the approach, so your thoughts are demonstrably correct. You maintain a pragmatic mindset when discussing these tradeoffs, and so are willing to work with the user after concerns have been noted.
|
|
30
|
+
|
|
31
|
+
## 3. General Operating Rules
|
|
32
|
+
|
|
33
|
+
### Codebase-First Behavior
|
|
34
|
+
|
|
35
|
+
Build context by examining the codebase first. Do not make assumptions or jump to conclusions. Think through the nuances of the code you encounter.
|
|
36
|
+
|
|
37
|
+
### Search and Tool Preferences
|
|
38
|
+
|
|
39
|
+
- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. If the `rg` command is not found, then use alternatives.
|
|
40
|
+
- Parallelize tool calls whenever possible, especially file reads such as `cat`, `rg`, `sed`, `ls`, `git show`, `nl`, and `wc`.
|
|
41
|
+
- Use `multi_tool_use.parallel` to parallelize tool calls and only this.
|
|
42
|
+
- Never chain together bash commands with separators like `echo "====";` as this renders to the user poorly.
|
|
43
|
+
|
|
44
|
+
## 4. Editing Constraints
|
|
45
|
+
|
|
46
|
+
### File Editing
|
|
47
|
+
|
|
48
|
+
- Default to ASCII when editing or creating files.
|
|
49
|
+
- Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
|
|
50
|
+
- Add succinct code comments that explain what is going on if code is not self-explanatory.
|
|
51
|
+
- Do not add comments like "Assigns the value to the variable".
|
|
52
|
+
- A brief comment may be useful ahead of a complex code block that the user would otherwise have to spend time parsing.
|
|
53
|
+
- Usage of these comments should be rare.
|
|
54
|
+
- Do not use `cat` or any other commands when creating or editing files.
|
|
55
|
+
|
|
56
|
+
### Git / Worktree Safety
|
|
57
|
+
|
|
58
|
+
You may be in a dirty git worktree.
|
|
59
|
+
|
|
60
|
+
- NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.
|
|
61
|
+
- If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, don't revert those changes.
|
|
62
|
+
- If the changes are in files you've touched recently, read carefully and understand how you can work with the changes rather than reverting them.
|
|
63
|
+
- If the changes are in unrelated files, just ignore them and don't revert them.
|
|
64
|
+
- Do not amend a commit unless explicitly requested to do so.
|
|
65
|
+
- While you are working, you might notice unexpected changes that you didn't make. It's likely the user made them, or they were autogenerated.
|
|
66
|
+
- If those changes directly conflict with your current task, stop and ask the user how they would like to proceed.
|
|
67
|
+
- Otherwise, focus on the task at hand.
|
|
68
|
+
- NEVER use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested or approved by the user.
|
|
69
|
+
- You struggle using the git interactive console. ALWAYS prefer using non-interactive git commands.
|
|
70
|
+
|
|
71
|
+
## 5. Special User Requests
|
|
72
|
+
|
|
73
|
+
### Simple Requests
|
|
74
|
+
|
|
75
|
+
If the user makes a simple request, such as asking for the time, and you can fulfill it by running a terminal command such as `date`, you should do so.
|
|
76
|
+
|
|
77
|
+
### Review Requests
|
|
78
|
+
|
|
79
|
+
If the user asks for a "review", default to a code review mindset.
|
|
80
|
+
|
|
81
|
+
In review mode:
|
|
82
|
+
|
|
83
|
+
- Prioritise identifying bugs, risks, behavioural regressions, and missing tests.
|
|
84
|
+
- Findings must be the primary focus of the response.
|
|
85
|
+
- Keep summaries or overviews brief and only after enumerating the issues.
|
|
86
|
+
- Present findings first, ordered by severity, with file and line references.
|
|
87
|
+
- Follow findings with open questions or assumptions.
|
|
88
|
+
- Offer a change-summary only as a secondary detail.
|
|
89
|
+
- If no findings are discovered, state that explicitly.
|
|
90
|
+
- Mention any residual risks or testing gaps.
|
|
91
|
+
|
|
92
|
+
## 6. Autonomy and Persistence
|
|
93
|
+
|
|
94
|
+
Persist until the task is fully handled end-to-end within the current turn whenever feasible. Do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.
|
|
95
|
+
|
|
96
|
+
Unless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem.
|
|
97
|
+
|
|
98
|
+
In those cases, it is bad to output your proposed solution in a message. You should go ahead and actually implement the change.
|
|
99
|
+
|
|
100
|
+
If you encounter challenges or blockers, you should attempt to resolve them yourself.
|
|
101
|
+
|
|
102
|
+
## 7. Final Answer Instructions
|
|
103
|
+
|
|
104
|
+
Always favor conciseness in your final answer. Usually avoid long-winded explanations and focus only on the most important details. For casual chit-chat, just chat.
|
|
105
|
+
|
|
106
|
+
### Simple or Single-File Tasks
|
|
107
|
+
|
|
108
|
+
- Prefer 1–2 short paragraphs plus an optional short verification line.
|
|
109
|
+
- Do not default to bullets.
|
|
110
|
+
- On simple tasks, prose is usually better than a list.
|
|
111
|
+
- If there are only one or two concrete changes, you should almost always keep the close-out fully in prose.
|
|
112
|
+
|
|
113
|
+
### Larger Tasks
|
|
114
|
+
|
|
115
|
+
- Use at most 2–3 high-level sections when helpful.
|
|
116
|
+
- Each section can be a short paragraph or a few flat bullets.
|
|
117
|
+
- Prefer grouping by major change area or user-facing outcome, not by file or edit inventory.
|
|
118
|
+
- If the answer starts turning into a changelog, compress it.
|
|
119
|
+
- Cut file-by-file detail, repeated framing, low-signal recap, and optional follow-up ideas before cutting outcome, verification, or real risks.
|
|
120
|
+
- Only dive deeper into one aspect of the code change if it is especially complex, important, or if the user asks about it.
|
|
121
|
+
- This also applies to PR explanations, codebase walkthroughs, or architectural decisions.
|
|
122
|
+
- In those cases, provide a high-level walkthrough unless specifically asked for more detail, and cap answers at 2–3 sections.
|
|
123
|
+
|
|
124
|
+
### Required Properties of the Final Answer
|
|
125
|
+
|
|
126
|
+
- Prefer short paragraphs by default.
|
|
127
|
+
- When explaining something, optimize for fast, high-level comprehension rather than completeness by default.
|
|
128
|
+
- Use lists only when the content is inherently list-shaped, such as enumerating distinct items, steps, options, categories, comparisons, or ideas.
|
|
129
|
+
- Do not use lists for opinions or straightforward explanations that would read more naturally as prose.
|
|
130
|
+
- If a short paragraph can answer the question more compactly, prefer prose over bullets or multiple sections.
|
|
131
|
+
- Do not turn simple explanations into outlines or taxonomies unless the user asks for depth.
|
|
132
|
+
- If a list is used, each bullet should be a complete standalone point.
|
|
133
|
+
- Do not begin responses with conversational interjections or meta commentary.
|
|
134
|
+
- Avoid openers such as acknowledgements like "Done —", "Got it", "Great question,", or "You're right to call that out".
|
|
135
|
+
- The user does not see command execution outputs.
|
|
136
|
+
- When asked to show the output of a command, such as `git show`, relay the important details in your answer or summarize the key lines so the user understands the result.
|
|
137
|
+
- Never tell the user to "save/copy this file"; the user is on the same machine and has access to the same files.
|
|
138
|
+
- If the user asks for a code explanation, include code references as appropriate.
|
|
139
|
+
- If you were not able to do something, for example run tests, tell the user.
|
|
140
|
+
- Never use nested bullets. Keep lists flat, single level.
|
|
141
|
+
- If you need hierarchy, split into separate lists or sections; or, if you use `:`, include the line you might usually render as a nested bullet immediately after it.
|
|
142
|
+
- For numbered lists, only use the `1. 2. 3.` style markers with a period, never `1)`.
|
|
143
|
+
- Never overwhelm the user with answers that are over roughly 50–70 lines long.
|
|
144
|
+
- Provide the highest-signal context instead of describing everything exhaustively.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Pibo Compaction Prompt
|
|
2
|
+
|
|
3
|
+
<system-prompt>
|
|
4
|
+
You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified.
|
|
5
|
+
|
|
6
|
+
Do NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.
|
|
7
|
+
</system-prompt>
|
|
8
|
+
|
|
9
|
+
<summary-prompt>
|
|
10
|
+
The messages above are a conversation to summarize. Create a structured context checkpoint summary that another LLM will use to continue the work.
|
|
11
|
+
|
|
12
|
+
Use this EXACT format:
|
|
13
|
+
|
|
14
|
+
## Goal
|
|
15
|
+
[What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
|
|
16
|
+
|
|
17
|
+
## Constraints & Preferences
|
|
18
|
+
- [Any constraints, preferences, or requirements mentioned by user]
|
|
19
|
+
- [Or "(none)" if none were mentioned]
|
|
20
|
+
|
|
21
|
+
## Progress
|
|
22
|
+
### Done
|
|
23
|
+
- [x] [Completed tasks/changes]
|
|
24
|
+
|
|
25
|
+
### In Progress
|
|
26
|
+
- [ ] [Current work]
|
|
27
|
+
|
|
28
|
+
### Blocked
|
|
29
|
+
- [Issues preventing progress, if any]
|
|
30
|
+
|
|
31
|
+
## Key Decisions
|
|
32
|
+
- **[Decision]**: [Brief rationale]
|
|
33
|
+
|
|
34
|
+
## Next Steps
|
|
35
|
+
1. [Ordered list of what should happen next]
|
|
36
|
+
|
|
37
|
+
## Critical Context
|
|
38
|
+
- [Any data, examples, or references needed to continue]
|
|
39
|
+
- [Or "(none)" if not applicable]
|
|
40
|
+
|
|
41
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.
|
|
42
|
+
</summary-prompt>
|
|
43
|
+
|
|
44
|
+
<update-summary-prompt>
|
|
45
|
+
The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
|
|
46
|
+
|
|
47
|
+
Update the existing structured summary with new information. RULES:
|
|
48
|
+
- PRESERVE all existing information from the previous summary
|
|
49
|
+
- ADD new progress, decisions, and context from the new messages
|
|
50
|
+
- UPDATE the Progress section: move items from "In Progress" to "Done" when completed
|
|
51
|
+
- UPDATE "Next Steps" based on what was accomplished
|
|
52
|
+
- PRESERVE exact file paths, function names, and error messages
|
|
53
|
+
- If something is no longer relevant, you may remove it
|
|
54
|
+
|
|
55
|
+
Use this EXACT format:
|
|
56
|
+
|
|
57
|
+
## Goal
|
|
58
|
+
[Preserve existing goals, add new ones if the task expanded]
|
|
59
|
+
|
|
60
|
+
## Constraints & Preferences
|
|
61
|
+
- [Preserve existing, add new ones discovered]
|
|
62
|
+
|
|
63
|
+
## Progress
|
|
64
|
+
### Done
|
|
65
|
+
- [x] [Include previously done items AND newly completed items]
|
|
66
|
+
|
|
67
|
+
### In Progress
|
|
68
|
+
- [ ] [Current work - update based on progress]
|
|
69
|
+
|
|
70
|
+
### Blocked
|
|
71
|
+
- [Current blockers - remove if resolved]
|
|
72
|
+
|
|
73
|
+
## Key Decisions
|
|
74
|
+
- **[Decision]**: [Brief rationale] (preserve all previous, add new)
|
|
75
|
+
|
|
76
|
+
## Next Steps
|
|
77
|
+
1. [Update based on current state]
|
|
78
|
+
|
|
79
|
+
## Critical Context
|
|
80
|
+
- [Preserve important context, add new if needed]
|
|
81
|
+
|
|
82
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.
|
|
83
|
+
</update-summary-prompt>
|
|
84
|
+
|
|
85
|
+
<turn-prefix-summary-prompt>
|
|
86
|
+
This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
|
|
87
|
+
|
|
88
|
+
Summarize the prefix to provide context for the retained suffix:
|
|
89
|
+
|
|
90
|
+
## Original Request
|
|
91
|
+
[What did the user ask for in this turn?]
|
|
92
|
+
|
|
93
|
+
## Early Progress
|
|
94
|
+
- [Key decisions and work done in the prefix]
|
|
95
|
+
|
|
96
|
+
## Context for Suffix
|
|
97
|
+
- [Information needed to understand the retained recent work]
|
|
98
|
+
|
|
99
|
+
Be concise. Focus on what's needed to understand the kept suffix.
|
|
100
|
+
</turn-prefix-summary-prompt>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.
|
|
2
|
+
|
|
3
|
+
Available tools:
|
|
4
|
+
{{availableTools}}
|
|
5
|
+
|
|
6
|
+
In addition to the tools above, you may have access to other custom tools depending on the project.
|
|
7
|
+
|
|
8
|
+
Guidelines:
|
|
9
|
+
{{guidelines}}
|
|
10
|
+
|
|
11
|
+
Pi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):
|
|
12
|
+
- Main documentation: /home/pibo/code/pi-mono/packages/coding-agent/README.md
|
|
13
|
+
- Additional docs: /home/pibo/code/pi-mono/packages/coding-agent/docs
|
|
14
|
+
- Examples: /home/pibo/code/pi-mono/packages/coding-agent/examples (extensions, custom tools, SDK)
|
|
15
|
+
- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)
|
|
16
|
+
- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing
|
|
17
|
+
- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InitialSessionContextBuilder } from "../../core/profiles.js";
|
|
2
|
+
export function createCustomAgentProfileDefinition(agent) {
|
|
3
|
+
return {
|
|
4
|
+
name: agent.profileName,
|
|
5
|
+
aliases: [agent.id, `custom-agent:${agent.id}`],
|
|
6
|
+
description: agent.description || agent.displayName,
|
|
7
|
+
create(context) {
|
|
8
|
+
const builder = new InitialSessionContextBuilder(agent.profileName)
|
|
9
|
+
.withBuiltinTools(agent.builtinTools)
|
|
10
|
+
.withBuiltinToolNames(agent.builtinToolNames)
|
|
11
|
+
.withAutoContextFiles(agent.autoContextFiles)
|
|
12
|
+
.withMcpServers(agent.mcpServers)
|
|
13
|
+
.withPiPackages(agent.piPackages.map((id) => ({ id })))
|
|
14
|
+
.withToolPackages({ runControl: agent.runControl });
|
|
15
|
+
for (const skillName of agent.skills)
|
|
16
|
+
builder.addSkill(context.getSkill(skillName));
|
|
17
|
+
for (const contextFileKey of agent.contextFiles)
|
|
18
|
+
builder.addContextFile(context.getContextFile(contextFileKey));
|
|
19
|
+
for (const toolName of agent.nativeTools)
|
|
20
|
+
builder.addTool(context.getTool(toolName));
|
|
21
|
+
for (const subagent of agent.subagents)
|
|
22
|
+
builder.addSubagent(subagent);
|
|
23
|
+
return builder.createSession();
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdirSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { DatabaseSync } from "node:sqlite";
|
|
5
|
+
import { DEFAULT_BUILTIN_TOOL_NAMES } from "../../core/profiles.js";
|
|
6
|
+
import { findPiPackage } from "../../pi-packages/store.js";
|
|
7
|
+
const CUSTOM_AGENT_NAME_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
8
|
+
export class CustomAgentStore {
|
|
9
|
+
db;
|
|
10
|
+
constructor(path) {
|
|
11
|
+
const resolvedPath = path === ":memory:" ? path : resolve(path);
|
|
12
|
+
if (resolvedPath !== ":memory:")
|
|
13
|
+
mkdirSync(dirname(resolvedPath), { recursive: true });
|
|
14
|
+
this.db = new DatabaseSync(resolvedPath);
|
|
15
|
+
this.db.exec("PRAGMA busy_timeout = 5000");
|
|
16
|
+
if (resolvedPath !== ":memory:")
|
|
17
|
+
this.db.exec("PRAGMA journal_mode = WAL");
|
|
18
|
+
this.db.exec(`
|
|
19
|
+
CREATE TABLE IF NOT EXISTS chat_agents (
|
|
20
|
+
id TEXT PRIMARY KEY,
|
|
21
|
+
profile_name TEXT NOT NULL UNIQUE,
|
|
22
|
+
owner_scope TEXT NOT NULL,
|
|
23
|
+
display_name TEXT NOT NULL,
|
|
24
|
+
description TEXT,
|
|
25
|
+
native_tools_json TEXT NOT NULL,
|
|
26
|
+
skills_json TEXT NOT NULL,
|
|
27
|
+
context_files_json TEXT NOT NULL,
|
|
28
|
+
subagents_json TEXT NOT NULL,
|
|
29
|
+
mcp_servers_json TEXT NOT NULL DEFAULT '[]',
|
|
30
|
+
pi_packages_json TEXT NOT NULL DEFAULT '[]',
|
|
31
|
+
builtin_tools TEXT NOT NULL,
|
|
32
|
+
builtin_tool_names_json TEXT NOT NULL DEFAULT '["read","bash","edit","write"]',
|
|
33
|
+
auto_context_files INTEGER NOT NULL DEFAULT 1,
|
|
34
|
+
run_control INTEGER NOT NULL,
|
|
35
|
+
created_at TEXT NOT NULL,
|
|
36
|
+
updated_at TEXT NOT NULL,
|
|
37
|
+
archived_at TEXT
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE INDEX IF NOT EXISTS idx_chat_agents_owner
|
|
41
|
+
ON chat_agents(owner_scope, updated_at);
|
|
42
|
+
`);
|
|
43
|
+
this.migrateArchivedAtColumn();
|
|
44
|
+
this.migrateAutoContextFilesColumn();
|
|
45
|
+
this.migrateMcpServersColumn();
|
|
46
|
+
this.migratePiPackagesColumn();
|
|
47
|
+
this.migrateBuiltinToolNamesColumn();
|
|
48
|
+
this.migrateLegacyProfileNames();
|
|
49
|
+
}
|
|
50
|
+
list(ownerScope, options = {}) {
|
|
51
|
+
this.migrateLegacyProfileNames();
|
|
52
|
+
const archivedClause = options.includeArchived ? "" : " AND archived_at IS NULL";
|
|
53
|
+
const rows = ownerScope
|
|
54
|
+
? this.db.prepare(`SELECT * FROM chat_agents WHERE owner_scope = ?${archivedClause} ORDER BY updated_at DESC`).all(ownerScope)
|
|
55
|
+
: this.db.prepare(`SELECT * FROM chat_agents WHERE 1 = 1${archivedClause} ORDER BY updated_at DESC`).all();
|
|
56
|
+
return rows.map(agentFromRow);
|
|
57
|
+
}
|
|
58
|
+
get(id) {
|
|
59
|
+
this.migrateLegacyProfileNames();
|
|
60
|
+
const row = this.db.prepare("SELECT * FROM chat_agents WHERE id = ?").get(id);
|
|
61
|
+
return row ? agentFromRow(row) : undefined;
|
|
62
|
+
}
|
|
63
|
+
create(input) {
|
|
64
|
+
this.migrateLegacyProfileNames();
|
|
65
|
+
const now = new Date().toISOString();
|
|
66
|
+
const id = `agent_${randomUUID()}`;
|
|
67
|
+
const profileName = input.displayName;
|
|
68
|
+
this.requireProfileNameAvailable(profileName);
|
|
69
|
+
const agent = {
|
|
70
|
+
id,
|
|
71
|
+
profileName,
|
|
72
|
+
ownerScope: input.ownerScope,
|
|
73
|
+
displayName: input.displayName,
|
|
74
|
+
description: input.description,
|
|
75
|
+
nativeTools: [...(input.nativeTools ?? [])],
|
|
76
|
+
skills: [...(input.skills ?? [])],
|
|
77
|
+
contextFiles: [...(input.contextFiles ?? [])],
|
|
78
|
+
subagents: sanitizeSubagents(input.subagents ?? []),
|
|
79
|
+
mcpServers: uniqueStrings(input.mcpServers ?? []),
|
|
80
|
+
piPackages: sanitizePiPackages(input.piPackages ?? []),
|
|
81
|
+
builtinTools: input.builtinTools ?? "default",
|
|
82
|
+
builtinToolNames: sanitizeBuiltinToolNames(input.builtinToolNames),
|
|
83
|
+
autoContextFiles: input.autoContextFiles ?? true,
|
|
84
|
+
runControl: input.runControl ?? false,
|
|
85
|
+
createdAt: now,
|
|
86
|
+
updatedAt: now,
|
|
87
|
+
};
|
|
88
|
+
this.insert(agent);
|
|
89
|
+
const created = this.get(id);
|
|
90
|
+
if (!created)
|
|
91
|
+
throw new Error(`Failed to create custom agent "${id}"`);
|
|
92
|
+
return created;
|
|
93
|
+
}
|
|
94
|
+
update(id, input) {
|
|
95
|
+
this.migrateLegacyProfileNames();
|
|
96
|
+
const existing = this.get(id);
|
|
97
|
+
if (!existing)
|
|
98
|
+
return undefined;
|
|
99
|
+
const profileName = input.displayName ?? existing.displayName;
|
|
100
|
+
this.requireProfileNameAvailable(profileName, id);
|
|
101
|
+
const updated = {
|
|
102
|
+
...existing,
|
|
103
|
+
profileName,
|
|
104
|
+
displayName: input.displayName ?? existing.displayName,
|
|
105
|
+
description: input.description === undefined ? existing.description : input.description,
|
|
106
|
+
nativeTools: input.nativeTools ? [...input.nativeTools] : existing.nativeTools,
|
|
107
|
+
skills: input.skills ? [...input.skills] : existing.skills,
|
|
108
|
+
contextFiles: input.contextFiles ? [...input.contextFiles] : existing.contextFiles,
|
|
109
|
+
subagents: input.subagents ? sanitizeSubagents(input.subagents) : existing.subagents,
|
|
110
|
+
mcpServers: input.mcpServers ? uniqueStrings(input.mcpServers) : existing.mcpServers,
|
|
111
|
+
piPackages: input.piPackages ? sanitizePiPackages(input.piPackages) : existing.piPackages,
|
|
112
|
+
builtinTools: input.builtinTools ?? existing.builtinTools,
|
|
113
|
+
builtinToolNames: input.builtinToolNames ? sanitizeBuiltinToolNames(input.builtinToolNames) : existing.builtinToolNames,
|
|
114
|
+
autoContextFiles: input.autoContextFiles ?? existing.autoContextFiles,
|
|
115
|
+
runControl: input.runControl ?? existing.runControl,
|
|
116
|
+
updatedAt: new Date().toISOString(),
|
|
117
|
+
};
|
|
118
|
+
this.db
|
|
119
|
+
.prepare(`
|
|
120
|
+
UPDATE chat_agents SET
|
|
121
|
+
profile_name = ?,
|
|
122
|
+
display_name = ?,
|
|
123
|
+
description = ?,
|
|
124
|
+
native_tools_json = ?,
|
|
125
|
+
skills_json = ?,
|
|
126
|
+
context_files_json = ?,
|
|
127
|
+
subagents_json = ?,
|
|
128
|
+
mcp_servers_json = ?,
|
|
129
|
+
pi_packages_json = ?,
|
|
130
|
+
builtin_tools = ?,
|
|
131
|
+
builtin_tool_names_json = ?,
|
|
132
|
+
auto_context_files = ?,
|
|
133
|
+
run_control = ?,
|
|
134
|
+
updated_at = ?
|
|
135
|
+
WHERE id = ?
|
|
136
|
+
`)
|
|
137
|
+
.run(updated.profileName, updated.displayName, updated.description ?? null, JSON.stringify(updated.nativeTools), JSON.stringify(updated.skills), JSON.stringify(updated.contextFiles), JSON.stringify(sanitizeSubagents(updated.subagents)), JSON.stringify(updated.mcpServers), JSON.stringify(updated.piPackages), updated.builtinTools, JSON.stringify(updated.builtinToolNames), updated.autoContextFiles ? 1 : 0, updated.runControl ? 1 : 0, updated.updatedAt, id);
|
|
138
|
+
return this.get(id);
|
|
139
|
+
}
|
|
140
|
+
setArchived(id, archived) {
|
|
141
|
+
this.migrateLegacyProfileNames();
|
|
142
|
+
const existing = this.get(id);
|
|
143
|
+
if (!existing)
|
|
144
|
+
return undefined;
|
|
145
|
+
const archivedAt = archived ? existing.archivedAt ?? new Date().toISOString() : null;
|
|
146
|
+
this.db
|
|
147
|
+
.prepare("UPDATE chat_agents SET archived_at = ?, updated_at = ? WHERE id = ?")
|
|
148
|
+
.run(archivedAt, new Date().toISOString(), id);
|
|
149
|
+
return this.get(id);
|
|
150
|
+
}
|
|
151
|
+
delete(id) {
|
|
152
|
+
const result = this.db.prepare("DELETE FROM chat_agents WHERE id = ?").run(id);
|
|
153
|
+
return Number(result.changes ?? 0) > 0;
|
|
154
|
+
}
|
|
155
|
+
close() {
|
|
156
|
+
this.db.close();
|
|
157
|
+
}
|
|
158
|
+
insert(agent) {
|
|
159
|
+
this.db
|
|
160
|
+
.prepare(`
|
|
161
|
+
INSERT INTO chat_agents (
|
|
162
|
+
id,
|
|
163
|
+
profile_name,
|
|
164
|
+
owner_scope,
|
|
165
|
+
display_name,
|
|
166
|
+
description,
|
|
167
|
+
native_tools_json,
|
|
168
|
+
skills_json,
|
|
169
|
+
context_files_json,
|
|
170
|
+
subagents_json,
|
|
171
|
+
mcp_servers_json,
|
|
172
|
+
pi_packages_json,
|
|
173
|
+
builtin_tools,
|
|
174
|
+
builtin_tool_names_json,
|
|
175
|
+
auto_context_files,
|
|
176
|
+
run_control,
|
|
177
|
+
created_at,
|
|
178
|
+
updated_at,
|
|
179
|
+
archived_at
|
|
180
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
181
|
+
`)
|
|
182
|
+
.run(agent.id, agent.profileName, agent.ownerScope, agent.displayName, agent.description ?? null, JSON.stringify(agent.nativeTools), JSON.stringify(agent.skills), JSON.stringify(agent.contextFiles), JSON.stringify(sanitizeSubagents(agent.subagents)), JSON.stringify(agent.mcpServers), JSON.stringify(agent.piPackages), agent.builtinTools, JSON.stringify(agent.builtinToolNames), agent.autoContextFiles ? 1 : 0, agent.runControl ? 1 : 0, agent.createdAt, agent.updatedAt, agent.archivedAt ?? null);
|
|
183
|
+
}
|
|
184
|
+
requireProfileNameAvailable(profileName, currentId) {
|
|
185
|
+
const row = this.db.prepare("SELECT id FROM chat_agents WHERE profile_name = ?").get(profileName);
|
|
186
|
+
if (row && row.id !== currentId)
|
|
187
|
+
throw new Error(`Agent name "${profileName}" already exists`);
|
|
188
|
+
}
|
|
189
|
+
migrateLegacyProfileNames() {
|
|
190
|
+
const rows = this.db.prepare("SELECT id, profile_name, display_name FROM chat_agents ORDER BY created_at ASC").all();
|
|
191
|
+
const used = new Set(rows.map((row) => row.profile_name));
|
|
192
|
+
for (const row of rows) {
|
|
193
|
+
if (!row.profile_name.startsWith("custom-agent:agent_"))
|
|
194
|
+
continue;
|
|
195
|
+
used.delete(row.profile_name);
|
|
196
|
+
const nextName = uniqueAgentName(agentNameCandidate(row.display_name, row.id), used);
|
|
197
|
+
used.add(nextName);
|
|
198
|
+
this.db
|
|
199
|
+
.prepare("UPDATE chat_agents SET profile_name = ?, display_name = ? WHERE id = ?")
|
|
200
|
+
.run(nextName, nextName, row.id);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
migrateArchivedAtColumn() {
|
|
204
|
+
const columns = new Set(this.db.prepare("PRAGMA table_info(chat_agents)").all().map((column) => column.name));
|
|
205
|
+
if (!columns.has("archived_at")) {
|
|
206
|
+
this.db.prepare("ALTER TABLE chat_agents ADD COLUMN archived_at TEXT").run();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
migrateAutoContextFilesColumn() {
|
|
210
|
+
const columns = new Set(this.db.prepare("PRAGMA table_info(chat_agents)").all().map((column) => column.name));
|
|
211
|
+
if (!columns.has("auto_context_files")) {
|
|
212
|
+
this.db.prepare("ALTER TABLE chat_agents ADD COLUMN auto_context_files INTEGER NOT NULL DEFAULT 1").run();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
migrateMcpServersColumn() {
|
|
216
|
+
const columns = new Set(this.db.prepare("PRAGMA table_info(chat_agents)").all().map((column) => column.name));
|
|
217
|
+
if (!columns.has("mcp_servers_json")) {
|
|
218
|
+
this.db.prepare("ALTER TABLE chat_agents ADD COLUMN mcp_servers_json TEXT NOT NULL DEFAULT '[]'").run();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
migratePiPackagesColumn() {
|
|
222
|
+
const columns = new Set(this.db.prepare("PRAGMA table_info(chat_agents)").all().map((column) => column.name));
|
|
223
|
+
if (!columns.has("pi_packages_json")) {
|
|
224
|
+
this.db.prepare("ALTER TABLE chat_agents ADD COLUMN pi_packages_json TEXT NOT NULL DEFAULT '[]'").run();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
migrateBuiltinToolNamesColumn() {
|
|
228
|
+
const columns = new Set(this.db.prepare("PRAGMA table_info(chat_agents)").all().map((column) => column.name));
|
|
229
|
+
if (!columns.has("builtin_tool_names_json")) {
|
|
230
|
+
this.db.prepare("ALTER TABLE chat_agents ADD COLUMN builtin_tool_names_json TEXT NOT NULL DEFAULT '[\"read\",\"bash\",\"edit\",\"write\"]'").run();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export function createDefaultCustomAgentStore(cwd = process.cwd()) {
|
|
235
|
+
return new CustomAgentStore(resolve(cwd, ".pibo/chat-agents.sqlite"));
|
|
236
|
+
}
|
|
237
|
+
function agentFromRow(row) {
|
|
238
|
+
return {
|
|
239
|
+
id: row.id,
|
|
240
|
+
profileName: row.profile_name,
|
|
241
|
+
ownerScope: row.owner_scope,
|
|
242
|
+
displayName: row.display_name,
|
|
243
|
+
description: row.description ?? undefined,
|
|
244
|
+
nativeTools: parseStringArray(row.native_tools_json),
|
|
245
|
+
skills: parseStringArray(row.skills_json),
|
|
246
|
+
contextFiles: parseStringArray(row.context_files_json),
|
|
247
|
+
subagents: parseSubagents(row.subagents_json),
|
|
248
|
+
mcpServers: parseStringArray(row.mcp_servers_json),
|
|
249
|
+
piPackages: parseStringArray(row.pi_packages_json),
|
|
250
|
+
builtinTools: row.builtin_tools,
|
|
251
|
+
builtinToolNames: sanitizeBuiltinToolNames(parseStringArray(row.builtin_tool_names_json)),
|
|
252
|
+
autoContextFiles: row.auto_context_files !== 0,
|
|
253
|
+
runControl: row.run_control === 1,
|
|
254
|
+
createdAt: row.created_at,
|
|
255
|
+
updatedAt: row.updated_at,
|
|
256
|
+
archivedAt: row.archived_at ?? undefined,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function parseStringArray(value) {
|
|
260
|
+
try {
|
|
261
|
+
const parsed = JSON.parse(value);
|
|
262
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function uniqueStrings(value) {
|
|
269
|
+
return [...new Set(value.filter((item) => typeof item === "string" && item.trim()).map((item) => item.trim()))];
|
|
270
|
+
}
|
|
271
|
+
function sanitizePiPackages(value) {
|
|
272
|
+
const packages = uniqueStrings(value);
|
|
273
|
+
for (const pkg of packages) {
|
|
274
|
+
if (!findPiPackage(pkg))
|
|
275
|
+
throw new Error(`Unknown Pi package "${pkg}"`);
|
|
276
|
+
}
|
|
277
|
+
return packages;
|
|
278
|
+
}
|
|
279
|
+
function sanitizeBuiltinToolNames(value) {
|
|
280
|
+
const selected = new Set(uniqueStrings(value ?? DEFAULT_BUILTIN_TOOL_NAMES));
|
|
281
|
+
return DEFAULT_BUILTIN_TOOL_NAMES.filter((name) => selected.has(name));
|
|
282
|
+
}
|
|
283
|
+
function parseSubagents(value) {
|
|
284
|
+
try {
|
|
285
|
+
const parsed = JSON.parse(value);
|
|
286
|
+
return Array.isArray(parsed)
|
|
287
|
+
? sanitizeSubagents(parsed)
|
|
288
|
+
: [];
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function sanitizeSubagents(value) {
|
|
295
|
+
return value.flatMap((item) => {
|
|
296
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
297
|
+
return [];
|
|
298
|
+
const candidate = item;
|
|
299
|
+
if (typeof candidate.name !== "string" || typeof candidate.targetProfile !== "string")
|
|
300
|
+
return [];
|
|
301
|
+
const subagent = {
|
|
302
|
+
name: candidate.name,
|
|
303
|
+
targetProfile: candidate.targetProfile,
|
|
304
|
+
};
|
|
305
|
+
if (typeof candidate.description === "string")
|
|
306
|
+
subagent.description = candidate.description;
|
|
307
|
+
if (typeof candidate.timeoutMs === "number")
|
|
308
|
+
subagent.timeoutMs = candidate.timeoutMs;
|
|
309
|
+
if (typeof candidate.maxDepth === "number")
|
|
310
|
+
subagent.maxDepth = candidate.maxDepth;
|
|
311
|
+
return [subagent];
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
export function isValidCustomAgentName(name) {
|
|
315
|
+
return CUSTOM_AGENT_NAME_PATTERN.test(name);
|
|
316
|
+
}
|
|
317
|
+
function agentNameCandidate(displayName, id) {
|
|
318
|
+
const candidate = displayName
|
|
319
|
+
.trim()
|
|
320
|
+
.toLowerCase()
|
|
321
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
322
|
+
.replace(/^-+|-+$/g, "")
|
|
323
|
+
.replace(/-+/g, "-");
|
|
324
|
+
if (isValidCustomAgentName(candidate))
|
|
325
|
+
return candidate;
|
|
326
|
+
return `agent-${id.replace(/^agent_/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`;
|
|
327
|
+
}
|
|
328
|
+
function uniqueAgentName(baseName, used) {
|
|
329
|
+
let name = baseName;
|
|
330
|
+
let suffix = 2;
|
|
331
|
+
while (used.has(name)) {
|
|
332
|
+
name = `${baseName}-${suffix}`;
|
|
333
|
+
suffix += 1;
|
|
334
|
+
}
|
|
335
|
+
return name;
|
|
336
|
+
}
|