anycodex 0.0.8 → 0.0.10
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/dist/app/assets/abap-BdImnpbu.js +1 -0
- package/dist/app/assets/actionscript-3-CoDkCxhg.js +1 -0
- package/dist/app/assets/ada-bCR0ucgS.js +1 -0
- package/dist/app/assets/andromeeda-C4gqWexZ.js +1 -0
- package/dist/app/assets/angular-html-DA-rfuFy.js +1 -0
- package/dist/app/assets/angular-ts-BrjP3tb8.js +1 -0
- package/dist/app/assets/apache-Pmp26Uib.js +1 -0
- package/dist/app/assets/apex-D8_7TLub.js +1 -0
- package/dist/app/assets/apl-CORt7UWP.js +1 -0
- package/dist/app/assets/applescript-Co6uUVPk.js +1 -0
- package/dist/app/assets/ara-BRHolxvo.js +1 -0
- package/dist/app/assets/asciidoc-Ve4PFQV2.js +1 -0
- package/dist/app/assets/asm-D_Q5rh1f.js +1 -0
- package/dist/app/assets/astro-HNnZUWAn.js +1 -0
- package/dist/app/assets/aurora-x-D-2ljcwZ.js +1 -0
- package/dist/app/assets/awk-DMzUqQB5.js +1 -0
- package/dist/app/assets/ayu-dark-DYE7WIF3.js +1 -0
- package/dist/app/assets/ayu-light-BA47KaF1.js +1 -0
- package/dist/app/assets/ayu-mirage-32ctXXKs.js +1 -0
- package/dist/app/assets/ballerina-BFfxhgS-.js +1 -0
- package/dist/app/assets/bat-BkioyH1T.js +1 -0
- package/dist/app/assets/beancount-k_qm7-4y.js +1 -0
- package/dist/app/assets/berry-uYugtg8r.js +1 -0
- package/dist/app/assets/bibtex-CHM0blh-.js +1 -0
- package/dist/app/assets/bicep-Bmn6On1c.js +1 -0
- package/dist/app/assets/bird2-BIv1doCn.js +1 -0
- package/dist/app/assets/blade-BjGOyj-B.js +1 -0
- package/dist/app/assets/bsl-BO_Y6i37.js +1 -0
- package/dist/app/assets/c-BIGW1oBm.js +1 -0
- package/dist/app/assets/c3-eo99z4R2.js +1 -0
- package/dist/app/assets/cadence-Bv_4Rxtq.js +1 -0
- package/dist/app/assets/cairo-KRGpt6FW.js +1 -0
- package/dist/app/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- package/dist/app/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- package/dist/app/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- package/dist/app/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- package/dist/app/assets/clarity-D53aC0YG.js +1 -0
- package/dist/app/assets/clojure-P80f7IUj.js +1 -0
- package/dist/app/assets/cmake-D1j8_8rp.js +1 -0
- package/dist/app/assets/cobol-nBiQ_Alo.js +1 -0
- package/dist/app/assets/codeowners-Bp6g37R7.js +1 -0
- package/dist/app/assets/codeql-DsOJ9woJ.js +1 -0
- package/dist/app/assets/coffee-Ch7k5sss.js +1 -0
- package/dist/app/assets/common-lisp-Cg-RD9OK.js +1 -0
- package/dist/app/assets/coq-DkFqJrB1.js +1 -0
- package/dist/app/assets/cpp-CofmeUqb.js +1 -0
- package/dist/app/assets/crystal-DNxU26gB.js +1 -0
- package/dist/app/assets/csharp-COcwbKMJ.js +1 -0
- package/dist/app/assets/css-CLj8gQPS.js +1 -0
- package/dist/app/assets/csv-fuZLfV_i.js +1 -0
- package/dist/app/assets/cue-D82EKSYY.js +1 -0
- package/dist/app/assets/cypher-COkxafJQ.js +1 -0
- package/dist/app/assets/d-85-TOEBH.js +1 -0
- package/dist/app/assets/dark-plus-C3mMm8J8.js +1 -0
- package/dist/app/assets/dart-bE4Kk8sk.js +1 -0
- package/dist/app/assets/dax-CEL-wOlO.js +1 -0
- package/dist/app/assets/desktop-BmXAJ9_W.js +1 -0
- package/dist/app/assets/diff-D97Zzqfu.js +1 -0
- package/dist/app/assets/docker-BcOcwvcX.js +1 -0
- package/dist/app/assets/dotenv-Da5cRb03.js +1 -0
- package/dist/app/assets/dracula-BzJJZx-M.js +1 -0
- package/dist/app/assets/dracula-soft-BXkSAIEj.js +1 -0
- package/dist/app/assets/dream-maker-BtqSS_iP.js +1 -0
- package/dist/app/assets/edge-FbVlp4U3.js +1 -0
- package/dist/app/assets/elixir-CkH2-t6x.js +1 -0
- package/dist/app/assets/elm-DbKCFpqz.js +1 -0
- package/dist/app/assets/emacs-lisp-CXvaQtF9.js +1 -0
- package/dist/app/assets/erb-BYCe7drp.js +1 -0
- package/dist/app/assets/erlang-DsQrWhSR.js +1 -0
- package/dist/app/assets/everforest-dark-BgDCqdQA.js +1 -0
- package/dist/app/assets/everforest-light-C8M2exoo.js +1 -0
- package/dist/app/assets/fennel-BYunw83y.js +1 -0
- package/dist/app/assets/fish-BvzEVeQv.js +1 -0
- package/dist/app/assets/fluent-C4IJs8-o.js +1 -0
- package/dist/app/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
- package/dist/app/assets/fortran-free-form-BxgE0vQu.js +1 -0
- package/dist/app/assets/fsharp-CXgrBDvD.js +1 -0
- package/dist/app/assets/gdresource-BOOCDP_w.js +1 -0
- package/dist/app/assets/gdscript-C5YyOfLZ.js +1 -0
- package/dist/app/assets/gdshader-DkwncUOv.js +1 -0
- package/dist/app/assets/genie-D0YGMca9.js +1 -0
- package/dist/app/assets/gherkin-DyxjwDmM.js +1 -0
- package/dist/app/assets/git-commit-F4YmCXRG.js +1 -0
- package/dist/app/assets/git-rebase-r7XF79zn.js +1 -0
- package/dist/app/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/app/assets/github-dark-default-Cuk6v7N8.js +1 -0
- package/dist/app/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- package/dist/app/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- package/dist/app/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/app/assets/github-light-default-D7oLnXFd.js +1 -0
- package/dist/app/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- package/dist/app/assets/gleam-BspZqrRM.js +1 -0
- package/dist/app/assets/glimmer-js-ByusRIyA.js +1 -0
- package/dist/app/assets/glimmer-ts-BfAWNZQY.js +1 -0
- package/dist/app/assets/glsl-DplSGwfg.js +1 -0
- package/dist/app/assets/gn-n2N0HUVH.js +1 -0
- package/dist/app/assets/gnuplot-DdkO51Og.js +1 -0
- package/dist/app/assets/go-C27-OAKa.js +1 -0
- package/dist/app/assets/graphql-ChdNCCLP.js +1 -0
- package/dist/app/assets/groovy-gcz8RCvz.js +1 -0
- package/dist/app/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- package/dist/app/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- package/dist/app/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- package/dist/app/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- package/dist/app/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- package/dist/app/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- package/dist/app/assets/hack-i7_Ulhet.js +1 -0
- package/dist/app/assets/haml-D5jkg6IW.js +1 -0
- package/dist/app/assets/handlebars-BpdQsYii.js +1 -0
- package/dist/app/assets/haskell-Df6bDoY_.js +1 -0
- package/dist/app/assets/haxe-CzTSHFRz.js +1 -0
- package/dist/app/assets/hcl-BWvSN4gD.js +1 -0
- package/dist/app/assets/hjson-D5-asLiD.js +1 -0
- package/dist/app/assets/hlsl-D3lLCCz7.js +1 -0
- package/dist/app/assets/horizon-BUw7H-hv.js +1 -0
- package/dist/app/assets/horizon-bright-CUuTKBJd.js +1 -0
- package/dist/app/assets/houston-DnULxvSX.js +1 -0
- package/dist/app/assets/html-derivative-DlHx6ybY.js +1 -0
- package/dist/app/assets/html-pp8916En.js +1 -0
- package/dist/app/assets/http-jrhK8wxY.js +1 -0
- package/dist/app/assets/hurl-irOxFIW8.js +1 -0
- package/dist/app/assets/hxml-Bvhsp5Yf.js +1 -0
- package/dist/app/assets/hy-DFXneXwc.js +1 -0
- package/dist/app/assets/imba-DGztddWO.js +1 -0
- package/dist/app/assets/index-BBYiZjoU.js +238 -0
- package/dist/app/assets/index-DU8KNBjo.css +32 -0
- package/dist/app/assets/ini-BEwlwnbL.js +1 -0
- package/dist/app/assets/java-CylS5w8V.js +1 -0
- package/dist/app/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/app/assets/jinja-f2NsQr07.js +1 -0
- package/dist/app/assets/jison-wvAkD_A8.js +1 -0
- package/dist/app/assets/json-Cp-IABpG.js +1 -0
- package/dist/app/assets/json5-C9tS-k6U.js +1 -0
- package/dist/app/assets/jsonc-Des-eS-w.js +1 -0
- package/dist/app/assets/jsonl-DcaNXYhu.js +1 -0
- package/dist/app/assets/jsonnet-DFQXde-d.js +1 -0
- package/dist/app/assets/jssm-C2t-YnRu.js +1 -0
- package/dist/app/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/app/assets/julia-CxzCAyBv.js +1 -0
- package/dist/app/assets/just-VxiPbLrw.js +1 -0
- package/dist/app/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- package/dist/app/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- package/dist/app/assets/kanagawa-wave-DWedfzmr.js +1 -0
- package/dist/app/assets/kdl-DV7GczEv.js +1 -0
- package/dist/app/assets/kotlin-BdnUsdx6.js +1 -0
- package/dist/app/assets/kusto-wEQ09or8.js +1 -0
- package/dist/app/assets/laserwave-DUszq2jm.js +1 -0
- package/dist/app/assets/latex-CWtU0Tv5.js +1 -0
- package/dist/app/assets/lean-BZvkOJ9d.js +1 -0
- package/dist/app/assets/less-B1dDrJ26.js +1 -0
- package/dist/app/assets/light-plus-B7mTdjB0.js +1 -0
- package/dist/app/assets/liquid-C0sCDyMI.js +1 -0
- package/dist/app/assets/llvm-DjAJT7YJ.js +1 -0
- package/dist/app/assets/log-2UxHyX5q.js +1 -0
- package/dist/app/assets/logo-BtOb2qkB.js +1 -0
- package/dist/app/assets/lua-BaeVxFsk.js +1 -0
- package/dist/app/assets/luau-C-HG3fhB.js +1 -0
- package/dist/app/assets/make-CHLpvVh8.js +1 -0
- package/dist/app/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/app/assets/marko-DjSrsDqO.js +1 -0
- package/dist/app/assets/material-theme-D5KoaKCx.js +1 -0
- package/dist/app/assets/material-theme-darker-BfHTSMKl.js +1 -0
- package/dist/app/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- package/dist/app/assets/material-theme-ocean-CyktbL80.js +1 -0
- package/dist/app/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- package/dist/app/assets/matlab-D7o27uSR.js +1 -0
- package/dist/app/assets/mdc-DTYItulj.js +1 -0
- package/dist/app/assets/mdx-Cmh6b_Ma.js +1 -0
- package/dist/app/assets/mermaid-mWjccvbQ.js +1 -0
- package/dist/app/assets/min-dark-CafNBF8u.js +1 -0
- package/dist/app/assets/min-light-CTRr51gU.js +1 -0
- package/dist/app/assets/mipsasm-CKIfxQSi.js +1 -0
- package/dist/app/assets/mojo-rZm6bMo-.js +1 -0
- package/dist/app/assets/monokai-D4h5O-jR.js +1 -0
- package/dist/app/assets/moonbit-_H4v1dQx.js +1 -0
- package/dist/app/assets/move-IF9eRakj.js +1 -0
- package/dist/app/assets/narrat-DRg8JJMk.js +1 -0
- package/dist/app/assets/nextflow-C-mBbutL.js +1 -0
- package/dist/app/assets/nextflow-groovy-vE_lwT2v.js +1 -0
- package/dist/app/assets/nginx-BpAMiNFr.js +1 -0
- package/dist/app/assets/night-owl-C39BiMTA.js +1 -0
- package/dist/app/assets/night-owl-light-CMTm3GFP.js +1 -0
- package/dist/app/assets/nim-BIad80T-.js +1 -0
- package/dist/app/assets/nix-CwoSXNpI.js +1 -0
- package/dist/app/assets/nord-Ddv68eIx.js +1 -0
- package/dist/app/assets/nushell-Cz2AlsmD.js +1 -0
- package/dist/app/assets/objective-c-DXmwc3jG.js +1 -0
- package/dist/app/assets/objective-cpp-CLxacb5B.js +1 -0
- package/dist/app/assets/ocaml-C0hk2d4L.js +1 -0
- package/dist/app/assets/odin-BBf5iR-q.js +1 -0
- package/dist/app/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- package/dist/app/assets/one-light-C3Wv6jpd.js +1 -0
- package/dist/app/assets/openscad-C4EeE6gA.js +1 -0
- package/dist/app/assets/pascal-D93ZcfNL.js +1 -0
- package/dist/app/assets/perl-NvoQZIq0.js +1 -0
- package/dist/app/assets/php-R6g_5hLQ.js +1 -0
- package/dist/app/assets/pkl-u5AG7uiY.js +1 -0
- package/dist/app/assets/plastic-3e1v2bzS.js +1 -0
- package/dist/app/assets/plsql-ChMvpjG-.js +1 -0
- package/dist/app/assets/po-BTJTHyun.js +1 -0
- package/dist/app/assets/poimandres-CS3Unz2-.js +1 -0
- package/dist/app/assets/polar-C0HS_06l.js +1 -0
- package/dist/app/assets/postcss-CXtECtnM.js +1 -0
- package/dist/app/assets/powerquery-CEu0bR-o.js +1 -0
- package/dist/app/assets/powershell-Dpen1YoG.js +1 -0
- package/dist/app/assets/prisma-Dd19v3D-.js +1 -0
- package/dist/app/assets/prolog-CbFg5uaA.js +1 -0
- package/dist/app/assets/proto-C7zT0LnQ.js +1 -0
- package/dist/app/assets/pug-DKIMFp6K.js +1 -0
- package/dist/app/assets/puppet-BMWR74SV.js +1 -0
- package/dist/app/assets/purescript-CklMAg4u.js +1 -0
- package/dist/app/assets/python-B6aJPvgy.js +1 -0
- package/dist/app/assets/qml-3beO22l8.js +1 -0
- package/dist/app/assets/qmldir-C8lEn-DE.js +1 -0
- package/dist/app/assets/qss-IeuSbFQv.js +1 -0
- package/dist/app/assets/r-Dspwwk_N.js +1 -0
- package/dist/app/assets/racket-BqYA7rlc.js +1 -0
- package/dist/app/assets/raku-DXvB9xmW.js +1 -0
- package/dist/app/assets/razor-BDqjjVU7.js +1 -0
- package/dist/app/assets/red-bN70gL4F.js +1 -0
- package/dist/app/assets/reg-C-SQnVFl.js +1 -0
- package/dist/app/assets/regexp-CDVJQ6XC.js +1 -0
- package/dist/app/assets/rel-C3B-1QV4.js +1 -0
- package/dist/app/assets/riscv-BM1_JUlF.js +1 -0
- package/dist/app/assets/ron-D8l8udqQ.js +1 -0
- package/dist/app/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
- package/dist/app/assets/rose-pine-moon-D4_iv3hh.js +1 -0
- package/dist/app/assets/rose-pine-qdsjHGoJ.js +1 -0
- package/dist/app/assets/rosmsg-BJDFO7_C.js +1 -0
- package/dist/app/assets/rst-CRjBmOyv.js +1 -0
- package/dist/app/assets/ruby-Wjq7vjNf.js +1 -0
- package/dist/app/assets/rust-B1yitclQ.js +1 -0
- package/dist/app/assets/sas-cz2c8ADy.js +1 -0
- package/dist/app/assets/sass-Cj5Yp3dK.js +1 -0
- package/dist/app/assets/scala-C151Ov-r.js +1 -0
- package/dist/app/assets/scheme-C98Dy4si.js +1 -0
- package/dist/app/assets/scss-D5BDwBP9.js +1 -0
- package/dist/app/assets/sdbl-DVxCFoDh.js +1 -0
- package/dist/app/assets/shaderlab-Dg9Lc6iA.js +1 -0
- package/dist/app/assets/shellscript-Yzrsuije.js +1 -0
- package/dist/app/assets/shellsession-BADoaaVG.js +1 -0
- package/dist/app/assets/slack-dark-BthQWCQV.js +1 -0
- package/dist/app/assets/slack-ochin-DqwNpetd.js +1 -0
- package/dist/app/assets/smalltalk-BERRCDM3.js +1 -0
- package/dist/app/assets/snazzy-light-Bw305WKR.js +1 -0
- package/dist/app/assets/solarized-dark-DXbdFlpD.js +1 -0
- package/dist/app/assets/solarized-light-L9t79GZl.js +1 -0
- package/dist/app/assets/solidity-rGO070M0.js +1 -0
- package/dist/app/assets/soy-8wufbnw4.js +1 -0
- package/dist/app/assets/sparql-rVzFXLq3.js +1 -0
- package/dist/app/assets/splunk-BtCnVYZw.js +1 -0
- package/dist/app/assets/sql-BLtJtn59.js +1 -0
- package/dist/app/assets/ssh-config-_ykCGR6B.js +1 -0
- package/dist/app/assets/stata-BH5u7GGu.js +1 -0
- package/dist/app/assets/stylus-BEDo0Tqx.js +1 -0
- package/dist/app/assets/surrealql-Bq5Q-fJD.js +1 -0
- package/dist/app/assets/svelte-Cy7k_4gC.js +1 -0
- package/dist/app/assets/swift-D82vCrfD.js +1 -0
- package/dist/app/assets/synthwave-84-CbfX1IO0.js +1 -0
- package/dist/app/assets/system-verilog-CnnmHF94.js +1 -0
- package/dist/app/assets/systemd-4A_iFExJ.js +1 -0
- package/dist/app/assets/talonscript-CkByrt1z.js +1 -0
- package/dist/app/assets/tasl-QIJgUcNo.js +1 -0
- package/dist/app/assets/tcl-dwOrl1Do.js +1 -0
- package/dist/app/assets/templ-DhtptRzy.js +1 -0
- package/dist/app/assets/terraform-BETggiCN.js +1 -0
- package/dist/app/assets/tex-idrVyKtj.js +1 -0
- package/dist/app/assets/tokyo-night-hegEt444.js +1 -0
- package/dist/app/assets/toml-vGWfd6FD.js +1 -0
- package/dist/app/assets/ts-tags-DQrlYJgV.js +1 -0
- package/dist/app/assets/tsv-B_m7g4N7.js +1 -0
- package/dist/app/assets/tsx-COt5Ahok.js +1 -0
- package/dist/app/assets/turtle-BsS91CYL.js +1 -0
- package/dist/app/assets/twig-xg9kU7Mw.js +1 -0
- package/dist/app/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/app/assets/typespec-CAFt9gP4.js +1 -0
- package/dist/app/assets/typst-DHCkPAjA.js +1 -0
- package/dist/app/assets/v-BcVCzyr7.js +1 -0
- package/dist/app/assets/vala-CsfeWuGM.js +1 -0
- package/dist/app/assets/vb-D17OF-Vu.js +1 -0
- package/dist/app/assets/verilog-BQ8w6xss.js +1 -0
- package/dist/app/assets/vesper-DU1UobuO.js +1 -0
- package/dist/app/assets/vhdl-CeAyd5Ju.js +1 -0
- package/dist/app/assets/viml-CJc9bBzg.js +1 -0
- package/dist/app/assets/vitesse-black-Bkuqu6BP.js +1 -0
- package/dist/app/assets/vitesse-dark-D0r3Knsf.js +1 -0
- package/dist/app/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/dist/app/assets/vue-D2xRrEX4.js +1 -0
- package/dist/app/assets/vue-html-AaS7Mt5G.js +1 -0
- package/dist/app/assets/vue-vine-BoDAl6tE.js +1 -0
- package/dist/app/assets/vyper-CDx5xZoG.js +1 -0
- package/dist/app/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/app/assets/wasm-MzD3tlZU.js +1 -0
- package/dist/app/assets/wenyan-BV7otONQ.js +1 -0
- package/dist/app/assets/wgsl-Dx-B1_4e.js +1 -0
- package/dist/app/assets/wikitext-BhOHFoWU.js +1 -0
- package/dist/app/assets/wit-5i3qLPDT.js +1 -0
- package/dist/app/assets/wolfram-lXgVvXCa.js +1 -0
- package/dist/app/assets/xml-sdJ4AIDG.js +1 -0
- package/dist/app/assets/xsl-CtQFsRM5.js +1 -0
- package/dist/app/assets/yaml-Buea-lGh.js +1 -0
- package/dist/app/assets/zenscript-DVFEvuxE.js +1 -0
- package/dist/app/assets/zig-VOosw3JB.js +1 -0
- package/dist/app/index.html +13 -0
- package/dist/bin.js +38 -24
- package/dist/{chunk-BTDDMBCN.js → chunk-LAUSNF7V.js} +1006 -794
- package/dist/{chunk-FSJHVC5R.js → chunk-U6O7ENPZ.js} +317 -3809
- package/dist/{dist-I2W4X7HT.js → dist-KUMFR56P.js} +2 -2
- package/dist/{registry-VQVHAEPP-NMTKW3ID.js → registry-K2RSCRJJ-NU43ZZLZ.js} +1 -1
- package/package.json +5 -2
- package/src/bin.ts +0 -654
- package/tsconfig.json +0 -8
- package/tsup.config.ts +0 -13
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
SchedulerService,
|
|
6
6
|
Skill,
|
|
7
7
|
ToolRegistry
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-U6O7ENPZ.js";
|
|
9
9
|
import {
|
|
10
10
|
AISDKError,
|
|
11
11
|
APICallError,
|
|
@@ -908,12 +908,6 @@ function o(e, r3) {
|
|
|
908
908
|
return a3;
|
|
909
909
|
}
|
|
910
910
|
|
|
911
|
-
// ../agent/dist/index.js
|
|
912
|
-
import { spawn } from "child_process";
|
|
913
|
-
import { pathToFileURL, fileURLToPath } from "url";
|
|
914
|
-
var import_fuzzysort = __toESM(require_fuzzysort(), 1);
|
|
915
|
-
import { createHash } from "crypto";
|
|
916
|
-
|
|
917
911
|
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.21_zod@4.1.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
918
912
|
function combineHeaders2(...headers) {
|
|
919
913
|
return headers.reduce(
|
|
@@ -6264,6 +6258,9 @@ function createAnthropic(options = {}) {
|
|
|
6264
6258
|
}
|
|
6265
6259
|
var anthropic = createAnthropic();
|
|
6266
6260
|
|
|
6261
|
+
// ../agent/dist/index.js
|
|
6262
|
+
import { createHash } from "crypto";
|
|
6263
|
+
|
|
6267
6264
|
// ../../node_modules/.pnpm/@ai-sdk+google@2.0.54_zod@4.1.8/node_modules/@ai-sdk/google/dist/index.mjs
|
|
6268
6265
|
var VERSION3 = true ? "2.0.54" : "0.0.0-test";
|
|
6269
6266
|
var googleErrorDataSchema = lazySchema2(
|
|
@@ -13907,6 +13904,9 @@ function createOpenAICompatible(options) {
|
|
|
13907
13904
|
}
|
|
13908
13905
|
|
|
13909
13906
|
// ../agent/dist/index.js
|
|
13907
|
+
import { spawn } from "child_process";
|
|
13908
|
+
import { pathToFileURL, fileURLToPath } from "url";
|
|
13909
|
+
var import_fuzzysort = __toESM(require_fuzzysort(), 1);
|
|
13910
13910
|
import fs from "fs/promises";
|
|
13911
13911
|
import { existsSync, statSync, readdirSync } from "fs";
|
|
13912
13912
|
import path from "path";
|
|
@@ -13955,440 +13955,190 @@ var Env;
|
|
|
13955
13955
|
}
|
|
13956
13956
|
Env2.remove = remove;
|
|
13957
13957
|
})(Env || (Env = {}));
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
if (mime === "application/pdf") return "pdf";
|
|
13963
|
-
return void 0;
|
|
13964
|
-
}
|
|
13965
|
-
var ProviderTransform;
|
|
13966
|
-
((ProviderTransform2) => {
|
|
13967
|
-
ProviderTransform2.OUTPUT_TOKEN_MAX = Flag.OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX || 32e3;
|
|
13968
|
-
function sdkKey(npm) {
|
|
13969
|
-
switch (npm) {
|
|
13970
|
-
case "@ai-sdk/openai":
|
|
13971
|
-
return "openai";
|
|
13972
|
-
case "@ai-sdk/anthropic":
|
|
13973
|
-
return "anthropic";
|
|
13974
|
-
case "@ai-sdk/google":
|
|
13975
|
-
return "google";
|
|
13976
|
-
}
|
|
13977
|
-
return void 0;
|
|
13958
|
+
var Hash;
|
|
13959
|
+
((Hash2) => {
|
|
13960
|
+
function fast(input) {
|
|
13961
|
+
return createHash("sha1").update(input).digest("hex");
|
|
13978
13962
|
}
|
|
13979
|
-
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13963
|
+
Hash2.fast = fast;
|
|
13964
|
+
function sha256(input) {
|
|
13965
|
+
return createHash("sha256").update(input).digest("hex");
|
|
13966
|
+
}
|
|
13967
|
+
Hash2.sha256 = sha256;
|
|
13968
|
+
function hexToUUID(hex) {
|
|
13969
|
+
return [
|
|
13970
|
+
hex.slice(0, 8),
|
|
13971
|
+
hex.slice(8, 12),
|
|
13972
|
+
hex.slice(12, 16),
|
|
13973
|
+
hex.slice(16, 20),
|
|
13974
|
+
hex.slice(20, 32)
|
|
13975
|
+
].join("-");
|
|
13976
|
+
}
|
|
13977
|
+
Hash2.hexToUUID = hexToUUID;
|
|
13978
|
+
})(Hash || (Hash = {}));
|
|
13979
|
+
var anthropicVendor = {
|
|
13980
|
+
id: "anthropic",
|
|
13981
|
+
npms: ["@ai-sdk/anthropic"],
|
|
13982
|
+
bundled: {
|
|
13983
|
+
"@ai-sdk/anthropic": createAnthropic
|
|
13984
|
+
},
|
|
13985
|
+
sdkKeys: {
|
|
13986
|
+
"@ai-sdk/anthropic": "anthropic"
|
|
13987
|
+
},
|
|
13988
|
+
async customLoader() {
|
|
13989
|
+
return {
|
|
13990
|
+
autoload: false,
|
|
13991
|
+
options: {
|
|
13992
|
+
headers: {
|
|
13993
|
+
"anthropic-beta": "claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
|
|
13994
|
+
"X-App": "cli",
|
|
13995
|
+
"X-Stainless-Lang": "js",
|
|
13996
|
+
"X-Stainless-Package-Version": "0.70.0",
|
|
13997
|
+
"X-Stainless-OS": process.platform === "darwin" ? "MacOS" : process.platform === "win32" ? "Windows" : "Linux",
|
|
13998
|
+
"X-Stainless-Arch": process.arch === "arm64" ? "arm64" : "x64",
|
|
13999
|
+
"X-Stainless-Runtime": "node",
|
|
14000
|
+
"X-Stainless-Runtime-Version": process.version,
|
|
14001
|
+
"X-Stainless-Retry-Count": "0",
|
|
14002
|
+
"X-Stainless-Timeout": "600",
|
|
14003
|
+
"Anthropic-Dangerous-Direct-Browser-Access": "true"
|
|
13985
14004
|
}
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
14005
|
+
}
|
|
14006
|
+
};
|
|
14007
|
+
},
|
|
14008
|
+
patchRequest({ opts, model, provider }) {
|
|
14009
|
+
if (opts.headers) {
|
|
14010
|
+
const headers = new Headers(opts.headers);
|
|
14011
|
+
headers.set("user-agent", "claude-cli/2.1.77");
|
|
14012
|
+
opts.headers = Object.fromEntries(headers.entries());
|
|
14013
|
+
} else {
|
|
14014
|
+
opts.headers = { "user-agent": "claude-cli/2.1.77" };
|
|
13996
14015
|
}
|
|
13997
|
-
if (
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
}
|
|
14007
|
-
return part;
|
|
14008
|
-
});
|
|
14016
|
+
if (opts.body && opts.method === "POST") {
|
|
14017
|
+
try {
|
|
14018
|
+
const body = JSON.parse(opts.body);
|
|
14019
|
+
if (!body.metadata?.user_id) {
|
|
14020
|
+
if (!body.metadata) body.metadata = {};
|
|
14021
|
+
const seed = [model.providerID ?? "", provider.key ?? ""].join(":");
|
|
14022
|
+
const clientId = Hash.sha256(seed + ":claude-code-client");
|
|
14023
|
+
const uuid = Hash.hexToUUID(Hash.sha256(seed + ":session"));
|
|
14024
|
+
body.metadata.user_id = `user_${clientId}_account__session_${uuid}`;
|
|
14009
14025
|
}
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
if (reasoningText) {
|
|
14021
|
-
return {
|
|
14022
|
-
...msg,
|
|
14023
|
-
content: filteredContent,
|
|
14024
|
-
providerOptions: {
|
|
14025
|
-
...msg.providerOptions,
|
|
14026
|
-
openaiCompatible: {
|
|
14027
|
-
...msg.providerOptions?.openaiCompatible,
|
|
14028
|
-
[field]: reasoningText
|
|
14029
|
-
}
|
|
14030
|
-
}
|
|
14031
|
-
};
|
|
14026
|
+
if (Array.isArray(body.system)) {
|
|
14027
|
+
const alreadyPresent = body.system.some(
|
|
14028
|
+
(entry) => typeof entry.text === "string" && entry.text.startsWith(CLAUDE_CODE_SYSTEM)
|
|
14029
|
+
);
|
|
14030
|
+
if (!alreadyPresent) {
|
|
14031
|
+
body.system.unshift({
|
|
14032
|
+
type: "text",
|
|
14033
|
+
text: CLAUDE_CODE_SYSTEM,
|
|
14034
|
+
cache_control: { type: "ephemeral" }
|
|
14035
|
+
});
|
|
14032
14036
|
}
|
|
14033
|
-
return { ...msg, content: filteredContent };
|
|
14034
14037
|
}
|
|
14035
|
-
|
|
14036
|
-
}
|
|
14037
|
-
}
|
|
14038
|
-
return msgs;
|
|
14039
|
-
}
|
|
14040
|
-
function applyCaching(msgs, _model) {
|
|
14041
|
-
const system = msgs.filter((msg) => msg.role === "system").slice(0, 2);
|
|
14042
|
-
const final = msgs.filter((msg) => msg.role !== "system").slice(-2);
|
|
14043
|
-
const providerOptions2 = {
|
|
14044
|
-
anthropic: {
|
|
14045
|
-
cacheControl: { type: "ephemeral" }
|
|
14038
|
+
opts.body = JSON.stringify(body);
|
|
14039
|
+
} catch {
|
|
14046
14040
|
}
|
|
14047
|
-
};
|
|
14048
|
-
for (const msg of i([...system, ...final])) {
|
|
14049
|
-
msg.providerOptions = D(msg.providerOptions ?? {}, providerOptions2);
|
|
14050
14041
|
}
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
if (
|
|
14061
|
-
|
|
14062
|
-
if (
|
|
14063
|
-
return
|
|
14064
|
-
type: "text",
|
|
14065
|
-
text: "ERROR: Image file is empty or corrupted. Please provide a valid image."
|
|
14066
|
-
};
|
|
14042
|
+
},
|
|
14043
|
+
transform: {
|
|
14044
|
+
message(msgs, model) {
|
|
14045
|
+
if (model.api.npm === "@ai-sdk/anthropic") {
|
|
14046
|
+
msgs = msgs.map((msg) => {
|
|
14047
|
+
if (typeof msg.content === "string") {
|
|
14048
|
+
if (msg.content === "") return void 0;
|
|
14049
|
+
return msg;
|
|
14050
|
+
}
|
|
14051
|
+
if (!Array.isArray(msg.content)) return msg;
|
|
14052
|
+
const filtered = msg.content.filter((part) => {
|
|
14053
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
14054
|
+
return part.text !== "";
|
|
14067
14055
|
}
|
|
14056
|
+
return true;
|
|
14057
|
+
});
|
|
14058
|
+
if (filtered.length === 0) return void 0;
|
|
14059
|
+
return { ...msg, content: filtered };
|
|
14060
|
+
}).filter((msg) => msg !== void 0 && msg.content !== "");
|
|
14061
|
+
}
|
|
14062
|
+
if (model.api.id.includes("claude")) {
|
|
14063
|
+
msgs = msgs.map((msg) => {
|
|
14064
|
+
if ((msg.role === "assistant" || msg.role === "tool") && Array.isArray(msg.content)) {
|
|
14065
|
+
msg.content = msg.content.map((part) => {
|
|
14066
|
+
if ((part.type === "tool-call" || part.type === "tool-result") && "toolCallId" in part) {
|
|
14067
|
+
return {
|
|
14068
|
+
...part,
|
|
14069
|
+
toolCallId: part.toolCallId.replace(/[^a-zA-Z0-9_-]/g, "_")
|
|
14070
|
+
};
|
|
14071
|
+
}
|
|
14072
|
+
return part;
|
|
14073
|
+
});
|
|
14074
|
+
}
|
|
14075
|
+
return msg;
|
|
14076
|
+
});
|
|
14077
|
+
}
|
|
14078
|
+
if (model.providerID === "anthropic" || model.api.id.includes("claude") || model.api.npm === "@ai-sdk/anthropic") {
|
|
14079
|
+
const system = msgs.filter((msg) => msg.role === "system").slice(0, 2);
|
|
14080
|
+
const final = msgs.filter((msg) => msg.role !== "system").slice(-2);
|
|
14081
|
+
const providerOptions = {
|
|
14082
|
+
anthropic: {
|
|
14083
|
+
cacheControl: { type: "ephemeral" }
|
|
14068
14084
|
}
|
|
14069
|
-
}
|
|
14070
|
-
const mime = part.type === "image" ? part.image.toString().split(";")[0].replace("data:", "") : part.mediaType;
|
|
14071
|
-
const filename = part.type === "file" ? part.filename : void 0;
|
|
14072
|
-
const modality = mimeToModality(mime);
|
|
14073
|
-
if (!modality) return part;
|
|
14074
|
-
if (model.capabilities.input[modality]) return part;
|
|
14075
|
-
const name2 = filename ? `"${filename}"` : modality;
|
|
14076
|
-
return {
|
|
14077
|
-
type: "text",
|
|
14078
|
-
text: `ERROR: Cannot read ${name2} (this model does not support ${modality} input). Inform the user.`
|
|
14079
|
-
};
|
|
14080
|
-
});
|
|
14081
|
-
return { ...msg, content: filtered };
|
|
14082
|
-
});
|
|
14083
|
-
}
|
|
14084
|
-
function message(msgs, model, options2) {
|
|
14085
|
-
msgs = unsupportedParts(msgs, model);
|
|
14086
|
-
msgs = normalizeMessages(msgs, model, options2);
|
|
14087
|
-
if (model.providerID === "anthropic" || model.api.id.includes("claude") || model.api.npm === "@ai-sdk/anthropic") {
|
|
14088
|
-
msgs = applyCaching(msgs, model);
|
|
14089
|
-
}
|
|
14090
|
-
const key = sdkKey(model.api.npm);
|
|
14091
|
-
if (key && key !== model.providerID) {
|
|
14092
|
-
const remap = (opts) => {
|
|
14093
|
-
if (!opts) return opts;
|
|
14094
|
-
if (!(model.providerID in opts)) return opts;
|
|
14095
|
-
const result = { ...opts };
|
|
14096
|
-
result[key] = result[model.providerID];
|
|
14097
|
-
delete result[model.providerID];
|
|
14098
|
-
return result;
|
|
14099
|
-
};
|
|
14100
|
-
msgs = msgs.map((msg) => {
|
|
14101
|
-
if (!Array.isArray(msg.content)) return { ...msg, providerOptions: remap(msg.providerOptions) };
|
|
14102
|
-
return {
|
|
14103
|
-
...msg,
|
|
14104
|
-
providerOptions: remap(msg.providerOptions),
|
|
14105
|
-
content: msg.content.map((part) => ({ ...part, providerOptions: remap(part.providerOptions) }))
|
|
14106
14085
|
};
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
if (id.includes("gemini")) return 1;
|
|
14116
|
-
return void 0;
|
|
14117
|
-
}
|
|
14118
|
-
ProviderTransform2.temperature = temperature;
|
|
14119
|
-
function topP(_model) {
|
|
14120
|
-
return void 0;
|
|
14121
|
-
}
|
|
14122
|
-
ProviderTransform2.topP = topP;
|
|
14123
|
-
function topK(model) {
|
|
14124
|
-
const id = model.id.toLowerCase();
|
|
14125
|
-
if (id.includes("gemini")) return 64;
|
|
14126
|
-
return void 0;
|
|
14127
|
-
}
|
|
14128
|
-
ProviderTransform2.topK = topK;
|
|
14129
|
-
function options(input) {
|
|
14130
|
-
const result = {};
|
|
14131
|
-
const model = input.model;
|
|
14132
|
-
if (model.providerID === "openai" || model.api.npm === "@ai-sdk/openai") {
|
|
14133
|
-
result["store"] = false;
|
|
14134
|
-
}
|
|
14135
|
-
if (model.providerID === "openai" || input.providerOptions?.setCacheKey) {
|
|
14136
|
-
result["promptCacheKey"] = input.sessionID;
|
|
14137
|
-
}
|
|
14138
|
-
if (model.api.npm === "@ai-sdk/anthropic") {
|
|
14086
|
+
for (const msg of i([...system, ...final])) {
|
|
14087
|
+
msg.providerOptions = D(msg.providerOptions ?? {}, providerOptions);
|
|
14088
|
+
}
|
|
14089
|
+
}
|
|
14090
|
+
return msgs;
|
|
14091
|
+
},
|
|
14092
|
+
options({ model }) {
|
|
14093
|
+
if (model.api.npm !== "@ai-sdk/anthropic") return {};
|
|
14139
14094
|
const isAdaptive = ["opus-4-6", "opus-4.6", "sonnet-4-6", "sonnet-4.6"].some(
|
|
14140
14095
|
(v) => model.api.id.includes(v)
|
|
14141
14096
|
);
|
|
14142
14097
|
if (isAdaptive) {
|
|
14143
|
-
|
|
14144
|
-
}
|
|
14145
|
-
|
|
14098
|
+
return { thinking: { type: "adaptive" } };
|
|
14099
|
+
}
|
|
14100
|
+
return {
|
|
14101
|
+
thinking: {
|
|
14146
14102
|
type: "enabled",
|
|
14147
14103
|
budgetTokens: model.limit.output - 1
|
|
14148
|
-
};
|
|
14149
|
-
}
|
|
14150
|
-
}
|
|
14151
|
-
if (model.api.npm === "@ai-sdk/google") {
|
|
14152
|
-
result["thinkingConfig"] = { includeThoughts: true };
|
|
14153
|
-
if (model.api.id.includes("gemini-3")) {
|
|
14154
|
-
result["thinkingConfig"]["thinkingLevel"] = "high";
|
|
14155
|
-
}
|
|
14156
|
-
}
|
|
14157
|
-
if (model.api.id.includes("gpt-5") && !model.api.id.includes("gpt-5-chat")) {
|
|
14158
|
-
if (!model.api.id.includes("gpt-5-pro")) {
|
|
14159
|
-
result["reasoningEffort"] = "medium";
|
|
14160
|
-
result["reasoningSummary"] = "auto";
|
|
14161
|
-
}
|
|
14162
|
-
if (model.api.id.includes("gpt-5.") && !model.api.id.includes("codex") && !model.api.id.includes("-chat")) {
|
|
14163
|
-
result["textVerbosity"] = "low";
|
|
14164
|
-
}
|
|
14165
|
-
}
|
|
14166
|
-
return result;
|
|
14167
|
-
}
|
|
14168
|
-
ProviderTransform2.options = options;
|
|
14169
|
-
function smallOptions(model) {
|
|
14170
|
-
if (model.providerID === "openai" || model.api.npm === "@ai-sdk/openai") {
|
|
14171
|
-
if (model.api.id.includes("gpt-5")) {
|
|
14172
|
-
if (model.api.id.includes("5.")) return { store: false, reasoningEffort: "low" };
|
|
14173
|
-
return { store: false, reasoningEffort: "minimal" };
|
|
14174
|
-
}
|
|
14175
|
-
return { store: false };
|
|
14176
|
-
}
|
|
14177
|
-
if (model.providerID === "google") {
|
|
14178
|
-
if (model.api.id.includes("gemini-3")) {
|
|
14179
|
-
return { thinkingConfig: { thinkingLevel: "minimal" } };
|
|
14180
|
-
}
|
|
14181
|
-
return { thinkingConfig: { thinkingBudget: 0 } };
|
|
14182
|
-
}
|
|
14183
|
-
return {};
|
|
14184
|
-
}
|
|
14185
|
-
ProviderTransform2.smallOptions = smallOptions;
|
|
14186
|
-
function providerOptions(model, options2) {
|
|
14187
|
-
const key = sdkKey(model.api.npm) ?? model.providerID;
|
|
14188
|
-
return { [key]: options2 };
|
|
14189
|
-
}
|
|
14190
|
-
ProviderTransform2.providerOptions = providerOptions;
|
|
14191
|
-
function maxOutputTokens(model) {
|
|
14192
|
-
return Math.min(model.limit.output, ProviderTransform2.OUTPUT_TOKEN_MAX) || ProviderTransform2.OUTPUT_TOKEN_MAX;
|
|
14193
|
-
}
|
|
14194
|
-
ProviderTransform2.maxOutputTokens = maxOutputTokens;
|
|
14195
|
-
function schema(model, schema2) {
|
|
14196
|
-
if (model.providerID === "google" || model.api.id.includes("gemini")) {
|
|
14197
|
-
const isPlainObject = (node) => typeof node === "object" && node !== null && !Array.isArray(node);
|
|
14198
|
-
const hasCombiner = (node) => isPlainObject(node) && (Array.isArray(node.anyOf) || Array.isArray(node.oneOf) || Array.isArray(node.allOf));
|
|
14199
|
-
const hasSchemaIntent = (node) => {
|
|
14200
|
-
if (!isPlainObject(node)) return false;
|
|
14201
|
-
if (hasCombiner(node)) return true;
|
|
14202
|
-
return [
|
|
14203
|
-
"type",
|
|
14204
|
-
"properties",
|
|
14205
|
-
"items",
|
|
14206
|
-
"prefixItems",
|
|
14207
|
-
"enum",
|
|
14208
|
-
"const",
|
|
14209
|
-
"$ref",
|
|
14210
|
-
"additionalProperties",
|
|
14211
|
-
"patternProperties",
|
|
14212
|
-
"required",
|
|
14213
|
-
"not",
|
|
14214
|
-
"if",
|
|
14215
|
-
"then",
|
|
14216
|
-
"else"
|
|
14217
|
-
].some((key) => key in node);
|
|
14218
|
-
};
|
|
14219
|
-
const sanitizeGemini = (obj) => {
|
|
14220
|
-
if (obj === null || typeof obj !== "object") return obj;
|
|
14221
|
-
if (Array.isArray(obj)) return obj.map(sanitizeGemini);
|
|
14222
|
-
const result = {};
|
|
14223
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
14224
|
-
if (key === "enum" && Array.isArray(value)) {
|
|
14225
|
-
result[key] = value.map((v) => String(v));
|
|
14226
|
-
if (result.type === "integer" || result.type === "number") result.type = "string";
|
|
14227
|
-
} else if (typeof value === "object" && value !== null) {
|
|
14228
|
-
result[key] = sanitizeGemini(value);
|
|
14229
|
-
} else {
|
|
14230
|
-
result[key] = value;
|
|
14231
|
-
}
|
|
14232
|
-
}
|
|
14233
|
-
if (result.type === "object" && result.properties && Array.isArray(result.required)) {
|
|
14234
|
-
result.required = result.required.filter((field) => field in result.properties);
|
|
14235
|
-
}
|
|
14236
|
-
if (result.type === "array" && !hasCombiner(result)) {
|
|
14237
|
-
if (result.items == null) result.items = {};
|
|
14238
|
-
if (isPlainObject(result.items) && !hasSchemaIntent(result.items)) result.items.type = "string";
|
|
14239
|
-
}
|
|
14240
|
-
if (result.type && result.type !== "object" && !hasCombiner(result)) {
|
|
14241
|
-
delete result.properties;
|
|
14242
|
-
delete result.required;
|
|
14243
14104
|
}
|
|
14244
|
-
return result;
|
|
14245
14105
|
};
|
|
14246
|
-
schema2 = sanitizeGemini(schema2);
|
|
14247
14106
|
}
|
|
14248
|
-
|
|
14107
|
+
},
|
|
14108
|
+
prompt: {
|
|
14109
|
+
provider(model) {
|
|
14110
|
+
if (!model.api.id.includes("claude")) return void 0;
|
|
14111
|
+
return [PROMPT_ANTHROPIC];
|
|
14112
|
+
}
|
|
14249
14113
|
}
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
var plan_txt_default = `<system-reminder>
|
|
14253
|
-
# Plan Mode - System Reminder
|
|
14114
|
+
};
|
|
14115
|
+
var PROMPT_ANTHROPIC = `You are AnyCode, the best coding agent on the planet.
|
|
14254
14116
|
|
|
14255
|
-
|
|
14256
|
-
ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,
|
|
14257
|
-
or ANY other bash command to manipulate files - commands may ONLY read/inspect.
|
|
14258
|
-
This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user
|
|
14259
|
-
edit requests. You may ONLY observe, analyze, and plan. Any modification attempt
|
|
14260
|
-
is a critical violation. ZERO exceptions.
|
|
14117
|
+
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
14261
14118
|
|
|
14262
|
-
|
|
14119
|
+
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
14263
14120
|
|
|
14264
|
-
|
|
14121
|
+
If the user asks for help or wants to give feedback inform them of the following:
|
|
14122
|
+
- ctrl+p to list available actions
|
|
14123
|
+
- To give feedback, users should report the issue at
|
|
14124
|
+
https://github.com/wyattzheng/anycode
|
|
14265
14125
|
|
|
14266
|
-
|
|
14126
|
+
When the user directly asks about AnyCode (eg. "can AnyCode do...", "does AnyCode have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific AnyCode feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from AnyCode docs. The list of available docs is available at https://anycode.ai/docs
|
|
14267
14127
|
|
|
14268
|
-
|
|
14128
|
+
# Tone and style
|
|
14129
|
+
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
14130
|
+
- Your output will be displayed on a command line interface. Your responses should be short and concise. You can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
14131
|
+
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
14132
|
+
- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.
|
|
14269
14133
|
|
|
14270
|
-
|
|
14134
|
+
# Professional objectivity
|
|
14135
|
+
Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if AnyCode honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs.
|
|
14271
14136
|
|
|
14272
|
-
|
|
14137
|
+
# Task Management
|
|
14138
|
+
You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
14139
|
+
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
14273
14140
|
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.
|
|
14277
|
-
</system-reminder>
|
|
14278
|
-
`;
|
|
14279
|
-
var build_switch_txt_default = `<system-reminder>
|
|
14280
|
-
Your operational mode has changed from plan to build.
|
|
14281
|
-
You are no longer in read-only mode.
|
|
14282
|
-
You are permitted to make file changes, run shell commands, and utilize your arsenal of tools as needed.
|
|
14283
|
-
</system-reminder>
|
|
14284
|
-
`;
|
|
14285
|
-
var log = Log.create({ module: "hooks" });
|
|
14286
|
-
var Hooks;
|
|
14287
|
-
((Hooks2) => {
|
|
14288
|
-
const DEFAULT_TIMEOUT = 15;
|
|
14289
|
-
function toSnakeCase(key) {
|
|
14290
|
-
return key.replace(/[A-Z]/g, (ch) => "_" + ch.toLowerCase());
|
|
14291
|
-
}
|
|
14292
|
-
function keysToSnakeCase(obj) {
|
|
14293
|
-
if (obj === null || obj === void 0 || typeof obj !== "object") return obj;
|
|
14294
|
-
if (Array.isArray(obj)) return obj.map(keysToSnakeCase);
|
|
14295
|
-
const out = {};
|
|
14296
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
14297
|
-
out[toSnakeCase(key)] = keysToSnakeCase(value);
|
|
14298
|
-
}
|
|
14299
|
-
return out;
|
|
14300
|
-
}
|
|
14301
|
-
function matchTool(rules, toolName, filePath) {
|
|
14302
|
-
const matched = [];
|
|
14303
|
-
for (const rule of rules) {
|
|
14304
|
-
try {
|
|
14305
|
-
if (!new RegExp(rule.matcher, "i").test(toolName)) continue;
|
|
14306
|
-
if (filePath && rule.ignore?.some((pat) => {
|
|
14307
|
-
try {
|
|
14308
|
-
return new RegExp(pat, "i").test(filePath);
|
|
14309
|
-
} catch {
|
|
14310
|
-
return false;
|
|
14311
|
-
}
|
|
14312
|
-
})) continue;
|
|
14313
|
-
matched.push(...rule.hooks);
|
|
14314
|
-
} catch {
|
|
14315
|
-
}
|
|
14316
|
-
}
|
|
14317
|
-
return matched;
|
|
14318
|
-
}
|
|
14319
|
-
Hooks2.matchTool = matchTool;
|
|
14320
|
-
function execute(hook, payload, cwd) {
|
|
14321
|
-
const timeout = (hook.timeout ?? DEFAULT_TIMEOUT) * 1e3;
|
|
14322
|
-
const payloadStr = JSON.stringify(payload);
|
|
14323
|
-
try {
|
|
14324
|
-
const proc = spawn("bash", ["-c", hook.command], {
|
|
14325
|
-
cwd,
|
|
14326
|
-
stdio: ["pipe", "ignore", "ignore"],
|
|
14327
|
-
env: process.env,
|
|
14328
|
-
detached: true
|
|
14329
|
-
});
|
|
14330
|
-
proc.unref();
|
|
14331
|
-
proc.stdin?.write(payloadStr);
|
|
14332
|
-
proc.stdin?.end();
|
|
14333
|
-
const timer = setTimeout(() => {
|
|
14334
|
-
try {
|
|
14335
|
-
proc.kill("SIGTERM");
|
|
14336
|
-
} catch {
|
|
14337
|
-
}
|
|
14338
|
-
}, timeout);
|
|
14339
|
-
proc.on("exit", () => clearTimeout(timer));
|
|
14340
|
-
proc.on("error", () => clearTimeout(timer));
|
|
14341
|
-
} catch (err) {
|
|
14342
|
-
log.info(`Hook execution failed: ${err}`);
|
|
14343
|
-
}
|
|
14344
|
-
}
|
|
14345
|
-
function runPostToolUse(hooksConfig, toolName, toolInput, toolResponse, sessionID, cwd) {
|
|
14346
|
-
const rules = hooksConfig["PostToolUse"];
|
|
14347
|
-
if (!rules || rules.length === 0) return;
|
|
14348
|
-
const filePath = toolInput?.filePath ?? toolInput?.file_path;
|
|
14349
|
-
const hooks = matchTool(rules, toolName, filePath);
|
|
14350
|
-
if (hooks.length === 0) return;
|
|
14351
|
-
const payload = {
|
|
14352
|
-
session_id: sessionID,
|
|
14353
|
-
cwd,
|
|
14354
|
-
hook_event_name: "PostToolUse",
|
|
14355
|
-
tool_name: toolName,
|
|
14356
|
-
tool_input: keysToSnakeCase(toolInput),
|
|
14357
|
-
tool_response: keysToSnakeCase(toolResponse)
|
|
14358
|
-
};
|
|
14359
|
-
for (const hook of hooks) {
|
|
14360
|
-
execute(hook, payload, cwd);
|
|
14361
|
-
}
|
|
14362
|
-
}
|
|
14363
|
-
Hooks2.runPostToolUse = runPostToolUse;
|
|
14364
|
-
})(Hooks || (Hooks = {}));
|
|
14365
|
-
var anthropic_txt_default = `You are AnyCode, the best coding agent on the planet.
|
|
14366
|
-
|
|
14367
|
-
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
14368
|
-
|
|
14369
|
-
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
14370
|
-
|
|
14371
|
-
If the user asks for help or wants to give feedback inform them of the following:
|
|
14372
|
-
- ctrl+p to list available actions
|
|
14373
|
-
- To give feedback, users should report the issue at
|
|
14374
|
-
https://github.com/wyattzheng/anycode
|
|
14375
|
-
|
|
14376
|
-
When the user directly asks about AnyCode (eg. "can AnyCode do...", "does AnyCode have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific AnyCode feature (eg. implement a hook, write a slash command, or install an MCP server), use the WebFetch tool to gather information to answer the question from AnyCode docs. The list of available docs is available at https://anycode.ai/docs
|
|
14377
|
-
|
|
14378
|
-
# Tone and style
|
|
14379
|
-
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
14380
|
-
- Your output will be displayed on a command line interface. Your responses should be short and concise. You can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
14381
|
-
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
14382
|
-
- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. This includes markdown files.
|
|
14383
|
-
|
|
14384
|
-
# Professional objectivity
|
|
14385
|
-
Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if AnyCode honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs.
|
|
14386
|
-
|
|
14387
|
-
# Task Management
|
|
14388
|
-
You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
14389
|
-
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
14390
|
-
|
|
14391
|
-
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
|
|
14141
|
+
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
|
|
14392
14142
|
|
|
14393
14143
|
Examples:
|
|
14394
14144
|
|
|
@@ -14469,117 +14219,401 @@ assistant: Clients are marked as failed in the \`connectToServer\` function in s
|
|
|
14469
14219
|
</example>
|
|
14470
14220
|
`;
|
|
14471
14221
|
var CLAUDE_CODE_SYSTEM = "You are Claude Code, Anthropic's official CLI for Claude.";
|
|
14472
|
-
var
|
|
14222
|
+
var githubCopilotVendor = {
|
|
14223
|
+
id: "github-copilot",
|
|
14224
|
+
matchesRuntime({ model, provider }) {
|
|
14225
|
+
return provider.id?.includes("github-copilot") === true || model.providerID?.includes("github-copilot") === true;
|
|
14226
|
+
},
|
|
14227
|
+
llm: {
|
|
14228
|
+
disableMaxOutputTokens() {
|
|
14229
|
+
return true;
|
|
14230
|
+
}
|
|
14231
|
+
}
|
|
14232
|
+
};
|
|
14233
|
+
var googleVendor = {
|
|
14234
|
+
id: "google",
|
|
14235
|
+
npms: ["@ai-sdk/google"],
|
|
14236
|
+
bundled: {
|
|
14237
|
+
"@ai-sdk/google": createGoogleGenerativeAI
|
|
14238
|
+
},
|
|
14239
|
+
sdkKeys: {
|
|
14240
|
+
"@ai-sdk/google": "google"
|
|
14241
|
+
},
|
|
14242
|
+
transform: {
|
|
14243
|
+
options({ model }) {
|
|
14244
|
+
if (model.api.npm !== "@ai-sdk/google") return {};
|
|
14245
|
+
const thinkingConfig = { includeThoughts: true };
|
|
14246
|
+
if (model.api.id.includes("gemini-3")) {
|
|
14247
|
+
thinkingConfig["thinkingLevel"] = "high";
|
|
14248
|
+
}
|
|
14249
|
+
return { thinkingConfig };
|
|
14250
|
+
},
|
|
14251
|
+
smallOptions(model) {
|
|
14252
|
+
if (model.providerID !== "google") return {};
|
|
14253
|
+
if (model.api.id.includes("gemini-3")) {
|
|
14254
|
+
return { thinkingConfig: { thinkingLevel: "minimal" } };
|
|
14255
|
+
}
|
|
14256
|
+
return { thinkingConfig: { thinkingBudget: 0 } };
|
|
14257
|
+
},
|
|
14258
|
+
temperature(model) {
|
|
14259
|
+
return model.id.toLowerCase().includes("gemini") ? 1 : void 0;
|
|
14260
|
+
},
|
|
14261
|
+
topK(model) {
|
|
14262
|
+
return model.id.toLowerCase().includes("gemini") ? 64 : void 0;
|
|
14263
|
+
},
|
|
14264
|
+
schema(model, schema) {
|
|
14265
|
+
if (!(model.providerID === "google" || model.api.id.includes("gemini"))) return schema;
|
|
14266
|
+
const isPlainObject = (node) => typeof node === "object" && node !== null && !Array.isArray(node);
|
|
14267
|
+
const hasCombiner = (node) => isPlainObject(node) && (Array.isArray(node.anyOf) || Array.isArray(node.oneOf) || Array.isArray(node.allOf));
|
|
14268
|
+
const hasSchemaIntent = (node) => {
|
|
14269
|
+
if (!isPlainObject(node)) return false;
|
|
14270
|
+
if (hasCombiner(node)) return true;
|
|
14271
|
+
return [
|
|
14272
|
+
"type",
|
|
14273
|
+
"properties",
|
|
14274
|
+
"items",
|
|
14275
|
+
"prefixItems",
|
|
14276
|
+
"enum",
|
|
14277
|
+
"const",
|
|
14278
|
+
"$ref",
|
|
14279
|
+
"additionalProperties",
|
|
14280
|
+
"patternProperties",
|
|
14281
|
+
"required",
|
|
14282
|
+
"not",
|
|
14283
|
+
"if",
|
|
14284
|
+
"then",
|
|
14285
|
+
"else"
|
|
14286
|
+
].some((key) => key in node);
|
|
14287
|
+
};
|
|
14288
|
+
const sanitize = (obj) => {
|
|
14289
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
14290
|
+
if (Array.isArray(obj)) return obj.map(sanitize);
|
|
14291
|
+
const result = {};
|
|
14292
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
14293
|
+
if (key === "enum" && Array.isArray(value)) {
|
|
14294
|
+
result[key] = value.map((v) => String(v));
|
|
14295
|
+
if (result.type === "integer" || result.type === "number") result.type = "string";
|
|
14296
|
+
} else if (typeof value === "object" && value !== null) {
|
|
14297
|
+
result[key] = sanitize(value);
|
|
14298
|
+
} else {
|
|
14299
|
+
result[key] = value;
|
|
14300
|
+
}
|
|
14301
|
+
}
|
|
14302
|
+
if (result.type === "object" && result.properties && Array.isArray(result.required)) {
|
|
14303
|
+
result.required = result.required.filter((field) => field in result.properties);
|
|
14304
|
+
}
|
|
14305
|
+
if (result.type === "array" && !hasCombiner(result)) {
|
|
14306
|
+
if (result.items == null) result.items = {};
|
|
14307
|
+
if (isPlainObject(result.items) && !hasSchemaIntent(result.items)) result.items.type = "string";
|
|
14308
|
+
}
|
|
14309
|
+
if (result.type && result.type !== "object" && !hasCombiner(result)) {
|
|
14310
|
+
delete result.properties;
|
|
14311
|
+
delete result.required;
|
|
14312
|
+
}
|
|
14313
|
+
return result;
|
|
14314
|
+
};
|
|
14315
|
+
return sanitize(schema);
|
|
14316
|
+
}
|
|
14317
|
+
},
|
|
14318
|
+
prompt: {
|
|
14319
|
+
provider(model) {
|
|
14320
|
+
if (!model.api.id.includes("gemini-")) return void 0;
|
|
14321
|
+
return [PROMPT_GEMINI];
|
|
14322
|
+
}
|
|
14323
|
+
}
|
|
14324
|
+
};
|
|
14325
|
+
var PROMPT_GEMINI = `You are anycode, an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
|
|
14473
14326
|
|
|
14474
|
-
|
|
14475
|
-
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
14476
|
-
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
14327
|
+
# Core Mandates
|
|
14477
14328
|
|
|
14478
|
-
|
|
14479
|
-
- /
|
|
14480
|
-
-
|
|
14329
|
+
- **Conventions:** Rigorously adhere to existing project conventions when reading or modifying code. Analyze surrounding code, tests, and configuration first.
|
|
14330
|
+
- **Libraries/Frameworks:** NEVER assume a library/framework is available or appropriate. Verify its established usage within the project (check imports, configuration files like 'package.json', 'Cargo.toml', 'requirements.txt', 'build.gradle', etc., or observe neighboring files) before employing it.
|
|
14331
|
+
- **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
|
|
14332
|
+
- **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
|
|
14333
|
+
- **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. *NEVER* talk to the user or describe your changes through comments.
|
|
14334
|
+
- **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
|
|
14335
|
+
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
|
|
14336
|
+
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
14337
|
+
- **Path Construction:** Before using any file system tool (e.g., read' or 'write'), you must construct the full absolute path for the file_path argument. Always combine the absolute path of the project's root directory with the file's path relative to the root. For example, if the project root is /path/to/project/ and the file is foo/bar/baz.txt, the final path you must use is /path/to/project/foo/bar/baz.txt. If the user provides a relative path, you must resolve it against the root directory to create an absolute path.
|
|
14338
|
+
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
|
|
14481
14339
|
|
|
14482
|
-
|
|
14340
|
+
# Primary Workflows
|
|
14483
14341
|
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
IMPORTANT:
|
|
14491
|
-
|
|
14492
|
-
|
|
14342
|
+
## Software Engineering Tasks
|
|
14343
|
+
When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
|
|
14344
|
+
1. **Understand:** Think about the user's request and the relevant codebase context. Use 'grep' and 'glob' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use 'read' to understand context and validate any assumptions you may have.
|
|
14345
|
+
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should try to use a self-verification loop by writing unit tests if relevant to the task. Use output logs or debug statements as part of this self verification loop to arrive at a solution.
|
|
14346
|
+
3. **Implement:** Use the available tools (e.g., 'edit', 'write' 'bash' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core Mandates').
|
|
14347
|
+
4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
|
|
14348
|
+
5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If unsure about these commands, you can ask the user if they'd like you to run them and if so how to.
|
|
14349
|
+
|
|
14350
|
+
## New Applications
|
|
14351
|
+
|
|
14352
|
+
**Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are 'write', 'edit' and 'bash'.
|
|
14353
|
+
|
|
14354
|
+
1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints. If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.
|
|
14355
|
+
2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
|
|
14356
|
+
3. **User Approval:** Obtain user approval for the proposed plan.
|
|
14357
|
+
4. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using 'bash' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
|
|
14358
|
+
5. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.
|
|
14359
|
+
6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.
|
|
14360
|
+
|
|
14361
|
+
# Operational Guidelines
|
|
14362
|
+
|
|
14363
|
+
## Tone and Style (CLI Interaction)
|
|
14364
|
+
- **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
|
|
14365
|
+
- **Minimal Output:** Aim for fewer than 3 lines of text output (excluding tool use/code generation) per response whenever practical. Focus strictly on the user's query.
|
|
14366
|
+
- **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.
|
|
14367
|
+
- **No Chitchat:** Avoid conversational filler, preambles ("Okay, I will now..."), or postambles ("I have finished the changes..."). Get straight to the action or answer.
|
|
14368
|
+
- **Formatting:** Use GitHub-flavored Markdown. Responses will be rendered in monospace.
|
|
14369
|
+
- **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls or code blocks unless specifically part of the required code/command itself.
|
|
14370
|
+
- **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly (1-2 sentences) without excessive justification. Offer alternatives if appropriate.
|
|
14371
|
+
|
|
14372
|
+
## Security and Safety Rules
|
|
14373
|
+
- **Explain Critical Commands:** Before executing commands with 'bash' that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this).
|
|
14374
|
+
- **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
|
|
14375
|
+
|
|
14376
|
+
## Tool Usage
|
|
14377
|
+
- **File Paths:** Always use absolute paths when referring to files with tools like 'read' or 'write'. Relative paths are not supported. You must provide an absolute path.
|
|
14378
|
+
- **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
|
|
14379
|
+
- **Command Execution:** Use the 'bash' tool for running shell commands, remembering the safety rule to explain modifying commands first.
|
|
14380
|
+
- **Background Processes:** Use background processes (via \\\`&\\\`) for commands that are unlikely to stop on their own, e.g. \\\`node server.js &\\\`. If unsure, ask the user.
|
|
14381
|
+
- **Interactive Commands:** Try to avoid shell commands that are likely to require user interaction (e.g. \\\`git rebase -i\\\`). Use non-interactive versions of commands (e.g. \\\`npm init -y\\\` instead of \\\`npm init\\\`) when available, and otherwise remind the user that interactive shell commands are not supported and may cause hangs until canceled by the user.
|
|
14382
|
+
- **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
|
|
14383
|
+
|
|
14384
|
+
## Interaction Details
|
|
14385
|
+
- **Help Command:** The user can use '/help' to display help information.
|
|
14386
|
+
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
|
|
14387
|
+
|
|
14388
|
+
# Examples (Illustrating Tone and Workflow)
|
|
14493
14389
|
<example>
|
|
14494
|
-
user:
|
|
14495
|
-
|
|
14390
|
+
user: 1 + 2
|
|
14391
|
+
model: 3
|
|
14496
14392
|
</example>
|
|
14497
14393
|
|
|
14498
14394
|
<example>
|
|
14499
|
-
user:
|
|
14500
|
-
|
|
14395
|
+
user: is 13 a prime number?
|
|
14396
|
+
model: true
|
|
14501
14397
|
</example>
|
|
14502
14398
|
|
|
14503
14399
|
<example>
|
|
14504
|
-
user:
|
|
14505
|
-
|
|
14400
|
+
user: list files here.
|
|
14401
|
+
model: [tool_call: ls for path '/path/to/project']
|
|
14506
14402
|
</example>
|
|
14507
14403
|
|
|
14508
14404
|
<example>
|
|
14509
|
-
user:
|
|
14510
|
-
|
|
14405
|
+
user: start the server implemented in server.js
|
|
14406
|
+
model: [tool_call: bash for 'node server.js &' because it must run in the background]
|
|
14511
14407
|
</example>
|
|
14512
14408
|
|
|
14513
14409
|
<example>
|
|
14514
|
-
user:
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14410
|
+
user: Refactor the auth logic in src/auth.py to use the requests library instead of urllib.
|
|
14411
|
+
model: Okay, I can refactor 'src/auth.py'.
|
|
14412
|
+
First, I'll analyze the code and check for a test safety net before planning any changes.
|
|
14413
|
+
[tool_call: glob for path 'tests/test_auth.py']
|
|
14414
|
+
[tool_call: read for absolute_path '/path/to/tests/test_auth.py']
|
|
14415
|
+
(After analysis)
|
|
14416
|
+
Great, 'tests/test_auth.py' exists and covers the core authentication logic. With this safety net in place, I can safely plan the refactoring.
|
|
14417
|
+
I'll also confirm 'requests' is a dependency.
|
|
14418
|
+
[tool_call: read for absolute_path '/path/to/requirements.txt']
|
|
14419
|
+
(After analysis)
|
|
14420
|
+
Looks good, 'requests' is available.
|
|
14421
|
+
|
|
14422
|
+
Here's the plan:
|
|
14423
|
+
1. Replace the 'urllib' calls with 'requests'.
|
|
14424
|
+
2. Add proper 'try...except' error handling for the new network calls.
|
|
14425
|
+
3. Remove the old 'urllib' import.
|
|
14426
|
+
4. Run the project's linter and tests to verify the changes.
|
|
14427
|
+
|
|
14428
|
+
Should I proceed?
|
|
14429
|
+
user: Yes
|
|
14430
|
+
model:
|
|
14431
|
+
[tool_call: write or edit to apply the refactoring to 'src/auth.py']
|
|
14432
|
+
Refactoring complete. Running verification...
|
|
14433
|
+
[tool_call: bash for 'ruff check src/auth.py && pytest']
|
|
14434
|
+
(After verification passes)
|
|
14435
|
+
All checks passed. This is a stable checkpoint.
|
|
14518
14436
|
|
|
14519
14437
|
<example>
|
|
14520
|
-
user:
|
|
14521
|
-
|
|
14438
|
+
user: Delete the temp directory.
|
|
14439
|
+
model: I can run \\\`rm -rf /path/to/project/temp\\\`. This will permanently delete the directory and all its contents.
|
|
14522
14440
|
</example>
|
|
14523
14441
|
|
|
14524
14442
|
<example>
|
|
14525
|
-
user:
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14443
|
+
user: Write tests for someFile.ts
|
|
14444
|
+
model:
|
|
14445
|
+
Okay, I can write those tests. First, I'll read \\\`someFile.ts\\\` to understand its functionality.
|
|
14446
|
+
[tool_call: read for absolute_path '/path/to/someFile.ts' or use glob to find \\\`someFile.ts\\\` if its location is unknown]
|
|
14447
|
+
Now I'll look for existing or related test files to understand current testing conventions and dependencies.
|
|
14448
|
+
[tool_call: glob for paths ['**/*.test.ts', 'src/**/*.spec.ts'] assuming someFile.ts is in the src directory]
|
|
14449
|
+
(After reviewing existing tests and the file content)
|
|
14450
|
+
[tool_call: write to create /path/to/someFile.test.ts with the test code]
|
|
14451
|
+
I've written the tests. Now I'll run the project's test command to verify them.
|
|
14452
|
+
[tool_call: bash for 'npm run test']
|
|
14529
14453
|
</example>
|
|
14530
14454
|
|
|
14531
14455
|
<example>
|
|
14532
|
-
user:
|
|
14533
|
-
|
|
14456
|
+
user: How do I update the user's profile information in this system?
|
|
14457
|
+
model:
|
|
14458
|
+
I'm not immediately sure how user profile information is updated. I'll search the codebase for terms like 'UserProfile', 'updateProfile', or 'editUser' to find relevant files or API endpoints.
|
|
14459
|
+
[tool_call: grep for pattern 'UserProfile|updateProfile|editUser']
|
|
14460
|
+
(After reviewing search results, assuming a relevant file like '/path/to/UserProfileService.java' was found)
|
|
14461
|
+
Okay, \\\`/path/to/UserProfileService.java\\\` seems like the most relevant file. I'll read its content to understand how updates are handled.
|
|
14462
|
+
[tool_call: read for absolute_path '/path/to/UserProfileService.java']
|
|
14463
|
+
(After reading the file)
|
|
14464
|
+
It appears the \\\`updateUserProfile\\\` method in \\\`UserProfileService.java\\\` is responsible for this. It expects a user ID and a \\\`UserProfileDTO\\\` object...
|
|
14534
14465
|
</example>
|
|
14535
14466
|
|
|
14536
|
-
# Proactiveness
|
|
14537
|
-
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
|
|
14538
|
-
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
14539
|
-
2. Not surprising the user with actions you take without asking
|
|
14540
|
-
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
14541
|
-
3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
14542
|
-
|
|
14543
|
-
# Following conventions
|
|
14544
|
-
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
|
|
14545
|
-
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
|
|
14546
|
-
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
|
|
14547
|
-
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
|
|
14548
|
-
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
14549
|
-
|
|
14550
|
-
# Code style
|
|
14551
|
-
- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
|
|
14552
|
-
|
|
14553
|
-
# Doing tasks
|
|
14554
|
-
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
14555
|
-
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
14556
|
-
- Implement the solution using all tools available to you
|
|
14557
|
-
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
|
|
14558
|
-
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.
|
|
14559
|
-
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
14560
|
-
|
|
14561
|
-
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
|
|
14562
|
-
|
|
14563
|
-
# Tool usage policy
|
|
14564
|
-
- When doing file search, prefer to use the Task tool in order to reduce context usage.
|
|
14565
|
-
- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
|
|
14566
|
-
|
|
14567
|
-
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
|
|
14568
|
-
|
|
14569
|
-
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
14570
|
-
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
14571
|
-
|
|
14572
|
-
# Code References
|
|
14573
|
-
|
|
14574
|
-
When referencing specific functions or pieces of code include the pattern \`file_path:line_number\` to allow the user to easily navigate to the source code location.
|
|
14575
|
-
|
|
14576
14467
|
<example>
|
|
14577
|
-
user: Where are
|
|
14578
|
-
|
|
14468
|
+
user: Where are all the 'app.config' files in this project? I need to check their settings.
|
|
14469
|
+
model:
|
|
14470
|
+
[tool_call: glob for pattern '**/app.config']
|
|
14471
|
+
(Assuming GlobTool returns a list of paths like ['/path/to/moduleA/app.config', '/path/to/moduleB/app.config'])
|
|
14472
|
+
I found the following 'app.config' files:
|
|
14473
|
+
- /path/to/moduleA/app.config
|
|
14474
|
+
- /path/to/moduleB/app.config
|
|
14475
|
+
To help you check their settings, I can read their contents. Which one would you like to start with, or should I read all of them?
|
|
14579
14476
|
</example>
|
|
14580
14477
|
|
|
14478
|
+
# Final Reminder
|
|
14479
|
+
Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use 'read' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.
|
|
14581
14480
|
`;
|
|
14582
|
-
var
|
|
14481
|
+
var liteLLMVendor = {
|
|
14482
|
+
id: "litellm",
|
|
14483
|
+
matchesRuntime({ model, provider }) {
|
|
14484
|
+
return provider.options?.["litellmProxy"] === true || provider.id?.toLowerCase().includes("litellm") === true || model.providerID?.toLowerCase().includes("litellm") === true || model.api.id.toLowerCase().includes("litellm");
|
|
14485
|
+
},
|
|
14486
|
+
llm: {
|
|
14487
|
+
needsNoopToolFallback() {
|
|
14488
|
+
return true;
|
|
14489
|
+
}
|
|
14490
|
+
}
|
|
14491
|
+
};
|
|
14492
|
+
var openAIVendor = {
|
|
14493
|
+
id: "openai",
|
|
14494
|
+
npms: ["@ai-sdk/openai", "@ai-sdk/openai-compatible"],
|
|
14495
|
+
bundled: {
|
|
14496
|
+
"@ai-sdk/openai": createOpenAI,
|
|
14497
|
+
"@ai-sdk/openai-compatible": createOpenAICompatible
|
|
14498
|
+
},
|
|
14499
|
+
sdkKeys: {
|
|
14500
|
+
"@ai-sdk/openai": "openai",
|
|
14501
|
+
"@ai-sdk/openai-compatible": "openaiCompatible"
|
|
14502
|
+
},
|
|
14503
|
+
async customLoader() {
|
|
14504
|
+
return {
|
|
14505
|
+
autoload: false,
|
|
14506
|
+
async getModel(sdk, modelID, _options) {
|
|
14507
|
+
if (typeof sdk.responses === "function") {
|
|
14508
|
+
return sdk.responses(modelID);
|
|
14509
|
+
}
|
|
14510
|
+
return sdk.languageModel(modelID);
|
|
14511
|
+
},
|
|
14512
|
+
options: {}
|
|
14513
|
+
};
|
|
14514
|
+
},
|
|
14515
|
+
patchRequest({ opts, model }) {
|
|
14516
|
+
if (opts.body && opts.method === "POST") {
|
|
14517
|
+
try {
|
|
14518
|
+
const body = JSON.parse(opts.body);
|
|
14519
|
+
const isAzure = model.providerID?.includes("azure");
|
|
14520
|
+
const keepIds = isAzure && body.store === true;
|
|
14521
|
+
if (!keepIds && Array.isArray(body.input)) {
|
|
14522
|
+
for (const item of body.input) {
|
|
14523
|
+
if ("id" in item) delete item.id;
|
|
14524
|
+
}
|
|
14525
|
+
opts.body = JSON.stringify(body);
|
|
14526
|
+
}
|
|
14527
|
+
} catch {
|
|
14528
|
+
}
|
|
14529
|
+
}
|
|
14530
|
+
},
|
|
14531
|
+
transform: {
|
|
14532
|
+
message(msgs, model) {
|
|
14533
|
+
if (!(model.api.npm === "@ai-sdk/openai-compatible" && typeof model.capabilities.interleaved === "object" && model.capabilities.interleaved.field)) {
|
|
14534
|
+
return msgs;
|
|
14535
|
+
}
|
|
14536
|
+
const field = model.capabilities.interleaved.field;
|
|
14537
|
+
return msgs.map((msg) => {
|
|
14538
|
+
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
14539
|
+
const reasoningParts = msg.content.filter((part) => part.type === "reasoning");
|
|
14540
|
+
const reasoningText = reasoningParts.map((part) => part.text).join("");
|
|
14541
|
+
const filteredContent = msg.content.filter((part) => part.type !== "reasoning");
|
|
14542
|
+
if (reasoningText) {
|
|
14543
|
+
return {
|
|
14544
|
+
...msg,
|
|
14545
|
+
content: filteredContent,
|
|
14546
|
+
providerOptions: {
|
|
14547
|
+
...msg.providerOptions,
|
|
14548
|
+
openaiCompatible: {
|
|
14549
|
+
...msg.providerOptions?.openaiCompatible,
|
|
14550
|
+
[field]: reasoningText
|
|
14551
|
+
}
|
|
14552
|
+
}
|
|
14553
|
+
};
|
|
14554
|
+
}
|
|
14555
|
+
return { ...msg, content: filteredContent };
|
|
14556
|
+
}
|
|
14557
|
+
return msg;
|
|
14558
|
+
});
|
|
14559
|
+
},
|
|
14560
|
+
options({ model, sessionID, providerOptions }) {
|
|
14561
|
+
const result = {};
|
|
14562
|
+
if (model.providerID === "openai" || model.api.npm === "@ai-sdk/openai") {
|
|
14563
|
+
result["store"] = false;
|
|
14564
|
+
}
|
|
14565
|
+
if (model.providerID === "openai" || providerOptions?.setCacheKey) {
|
|
14566
|
+
result["promptCacheKey"] = sessionID;
|
|
14567
|
+
}
|
|
14568
|
+
if (model.api.id.includes("gpt-5") && !model.api.id.includes("gpt-5-chat")) {
|
|
14569
|
+
if (!model.api.id.includes("gpt-5-pro")) {
|
|
14570
|
+
result["reasoningEffort"] = "high";
|
|
14571
|
+
result["reasoningSummary"] = "auto";
|
|
14572
|
+
}
|
|
14573
|
+
if (model.api.id.includes("gpt-5.") && !model.api.id.includes("codex") && !model.api.id.includes("-chat")) {
|
|
14574
|
+
result["textVerbosity"] = "low";
|
|
14575
|
+
}
|
|
14576
|
+
}
|
|
14577
|
+
return result;
|
|
14578
|
+
},
|
|
14579
|
+
smallOptions(model) {
|
|
14580
|
+
if (!(model.providerID === "openai" || model.api.npm === "@ai-sdk/openai")) return {};
|
|
14581
|
+
if (model.api.id.includes("gpt-5")) {
|
|
14582
|
+
if (model.api.id.includes("5.")) return { store: false, reasoningEffort: "low" };
|
|
14583
|
+
return { store: false, reasoningEffort: "minimal" };
|
|
14584
|
+
}
|
|
14585
|
+
return { store: false };
|
|
14586
|
+
}
|
|
14587
|
+
},
|
|
14588
|
+
llm: {
|
|
14589
|
+
useInstructionPrompt({ provider, auth }) {
|
|
14590
|
+
return provider.id === "openai" && auth?.type === "oauth";
|
|
14591
|
+
},
|
|
14592
|
+
includeProviderSystemPrompt({ provider, auth }) {
|
|
14593
|
+
return !(provider.id === "openai" && auth?.type === "oauth");
|
|
14594
|
+
},
|
|
14595
|
+
disableMaxOutputTokens({ provider, auth }) {
|
|
14596
|
+
return provider.id === "openai" && auth?.type === "oauth";
|
|
14597
|
+
}
|
|
14598
|
+
},
|
|
14599
|
+
prompt: {
|
|
14600
|
+
provider(model) {
|
|
14601
|
+
if (model.api.id.toLowerCase().includes("trinity")) return [PROMPT_TRINITY];
|
|
14602
|
+
if (model.api.id.includes("gpt-5")) return [PROMPT_CODEX];
|
|
14603
|
+
if (model.api.id.includes("gpt-") || model.api.id.includes("o1") || model.api.id.includes("o3")) {
|
|
14604
|
+
return [PROMPT_BEAST];
|
|
14605
|
+
}
|
|
14606
|
+
if (model.api.id.includes("gemini-") || model.api.id.includes("claude")) return void 0;
|
|
14607
|
+
if (model.api.npm === "@ai-sdk/openai-compatible") return [PROMPT_ANTHROPIC_WITHOUT_TODO];
|
|
14608
|
+
return void 0;
|
|
14609
|
+
},
|
|
14610
|
+
instructions(model) {
|
|
14611
|
+
if (!model.api.id.includes("gpt-5")) return void 0;
|
|
14612
|
+
return PROMPT_CODEX.trim();
|
|
14613
|
+
}
|
|
14614
|
+
}
|
|
14615
|
+
};
|
|
14616
|
+
var PROMPT_BEAST = `You are anycode, an agent - please keep going until the user\u2019s query is completely resolved, before ending your turn and yielding back to the user.
|
|
14583
14617
|
|
|
14584
14618
|
Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
|
|
14585
14619
|
|
|
@@ -14727,163 +14761,7 @@ If the user tells you to stage and commit, you may do so.
|
|
|
14727
14761
|
|
|
14728
14762
|
You are NEVER allowed to stage and commit files automatically.
|
|
14729
14763
|
`;
|
|
14730
|
-
var
|
|
14731
|
-
|
|
14732
|
-
# Core Mandates
|
|
14733
|
-
|
|
14734
|
-
- **Conventions:** Rigorously adhere to existing project conventions when reading or modifying code. Analyze surrounding code, tests, and configuration first.
|
|
14735
|
-
- **Libraries/Frameworks:** NEVER assume a library/framework is available or appropriate. Verify its established usage within the project (check imports, configuration files like 'package.json', 'Cargo.toml', 'requirements.txt', 'build.gradle', etc., or observe neighboring files) before employing it.
|
|
14736
|
-
- **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
|
|
14737
|
-
- **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
|
|
14738
|
-
- **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. *NEVER* talk to the user or describe your changes through comments.
|
|
14739
|
-
- **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
|
|
14740
|
-
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
|
|
14741
|
-
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
14742
|
-
- **Path Construction:** Before using any file system tool (e.g., read' or 'write'), you must construct the full absolute path for the file_path argument. Always combine the absolute path of the project's root directory with the file's path relative to the root. For example, if the project root is /path/to/project/ and the file is foo/bar/baz.txt, the final path you must use is /path/to/project/foo/bar/baz.txt. If the user provides a relative path, you must resolve it against the root directory to create an absolute path.
|
|
14743
|
-
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
|
|
14744
|
-
|
|
14745
|
-
# Primary Workflows
|
|
14746
|
-
|
|
14747
|
-
## Software Engineering Tasks
|
|
14748
|
-
When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
|
|
14749
|
-
1. **Understand:** Think about the user's request and the relevant codebase context. Use 'grep' and 'glob' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use 'read' to understand context and validate any assumptions you may have.
|
|
14750
|
-
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should try to use a self-verification loop by writing unit tests if relevant to the task. Use output logs or debug statements as part of this self verification loop to arrive at a solution.
|
|
14751
|
-
3. **Implement:** Use the available tools (e.g., 'edit', 'write' 'bash' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core Mandates').
|
|
14752
|
-
4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
|
|
14753
|
-
5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If unsure about these commands, you can ask the user if they'd like you to run them and if so how to.
|
|
14754
|
-
|
|
14755
|
-
## New Applications
|
|
14756
|
-
|
|
14757
|
-
**Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are 'write', 'edit' and 'bash'.
|
|
14758
|
-
|
|
14759
|
-
1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints. If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.
|
|
14760
|
-
2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
|
|
14761
|
-
3. **User Approval:** Obtain user approval for the proposed plan.
|
|
14762
|
-
4. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using 'bash' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
|
|
14763
|
-
5. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.
|
|
14764
|
-
6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.
|
|
14765
|
-
|
|
14766
|
-
# Operational Guidelines
|
|
14767
|
-
|
|
14768
|
-
## Tone and Style (CLI Interaction)
|
|
14769
|
-
- **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
|
|
14770
|
-
- **Minimal Output:** Aim for fewer than 3 lines of text output (excluding tool use/code generation) per response whenever practical. Focus strictly on the user's query.
|
|
14771
|
-
- **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.
|
|
14772
|
-
- **No Chitchat:** Avoid conversational filler, preambles ("Okay, I will now..."), or postambles ("I have finished the changes..."). Get straight to the action or answer.
|
|
14773
|
-
- **Formatting:** Use GitHub-flavored Markdown. Responses will be rendered in monospace.
|
|
14774
|
-
- **Tools vs. Text:** Use tools for actions, text output *only* for communication. Do not add explanatory comments within tool calls or code blocks unless specifically part of the required code/command itself.
|
|
14775
|
-
- **Handling Inability:** If unable/unwilling to fulfill a request, state so briefly (1-2 sentences) without excessive justification. Offer alternatives if appropriate.
|
|
14776
|
-
|
|
14777
|
-
## Security and Safety Rules
|
|
14778
|
-
- **Explain Critical Commands:** Before executing commands with 'bash' that modify the file system, codebase, or system state, you *must* provide a brief explanation of the command's purpose and potential impact. Prioritize user understanding and safety. You should not ask permission to use the tool; the user will be presented with a confirmation dialogue upon use (you do not need to tell them this).
|
|
14779
|
-
- **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
|
|
14780
|
-
|
|
14781
|
-
## Tool Usage
|
|
14782
|
-
- **File Paths:** Always use absolute paths when referring to files with tools like 'read' or 'write'. Relative paths are not supported. You must provide an absolute path.
|
|
14783
|
-
- **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
|
|
14784
|
-
- **Command Execution:** Use the 'bash' tool for running shell commands, remembering the safety rule to explain modifying commands first.
|
|
14785
|
-
- **Background Processes:** Use background processes (via \\\`&\\\`) for commands that are unlikely to stop on their own, e.g. \\\`node server.js &\\\`. If unsure, ask the user.
|
|
14786
|
-
- **Interactive Commands:** Try to avoid shell commands that are likely to require user interaction (e.g. \\\`git rebase -i\\\`). Use non-interactive versions of commands (e.g. \\\`npm init -y\\\` instead of \\\`npm init\\\`) when available, and otherwise remind the user that interactive shell commands are not supported and may cause hangs until canceled by the user.
|
|
14787
|
-
- **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
|
|
14788
|
-
|
|
14789
|
-
## Interaction Details
|
|
14790
|
-
- **Help Command:** The user can use '/help' to display help information.
|
|
14791
|
-
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
|
|
14792
|
-
|
|
14793
|
-
# Examples (Illustrating Tone and Workflow)
|
|
14794
|
-
<example>
|
|
14795
|
-
user: 1 + 2
|
|
14796
|
-
model: 3
|
|
14797
|
-
</example>
|
|
14798
|
-
|
|
14799
|
-
<example>
|
|
14800
|
-
user: is 13 a prime number?
|
|
14801
|
-
model: true
|
|
14802
|
-
</example>
|
|
14803
|
-
|
|
14804
|
-
<example>
|
|
14805
|
-
user: list files here.
|
|
14806
|
-
model: [tool_call: ls for path '/path/to/project']
|
|
14807
|
-
</example>
|
|
14808
|
-
|
|
14809
|
-
<example>
|
|
14810
|
-
user: start the server implemented in server.js
|
|
14811
|
-
model: [tool_call: bash for 'node server.js &' because it must run in the background]
|
|
14812
|
-
</example>
|
|
14813
|
-
|
|
14814
|
-
<example>
|
|
14815
|
-
user: Refactor the auth logic in src/auth.py to use the requests library instead of urllib.
|
|
14816
|
-
model: Okay, I can refactor 'src/auth.py'.
|
|
14817
|
-
First, I'll analyze the code and check for a test safety net before planning any changes.
|
|
14818
|
-
[tool_call: glob for path 'tests/test_auth.py']
|
|
14819
|
-
[tool_call: read for absolute_path '/path/to/tests/test_auth.py']
|
|
14820
|
-
(After analysis)
|
|
14821
|
-
Great, 'tests/test_auth.py' exists and covers the core authentication logic. With this safety net in place, I can safely plan the refactoring.
|
|
14822
|
-
I'll also confirm 'requests' is a dependency.
|
|
14823
|
-
[tool_call: read for absolute_path '/path/to/requirements.txt']
|
|
14824
|
-
(After analysis)
|
|
14825
|
-
Looks good, 'requests' is available.
|
|
14826
|
-
|
|
14827
|
-
Here's the plan:
|
|
14828
|
-
1. Replace the 'urllib' calls with 'requests'.
|
|
14829
|
-
2. Add proper 'try...except' error handling for the new network calls.
|
|
14830
|
-
3. Remove the old 'urllib' import.
|
|
14831
|
-
4. Run the project's linter and tests to verify the changes.
|
|
14832
|
-
|
|
14833
|
-
Should I proceed?
|
|
14834
|
-
user: Yes
|
|
14835
|
-
model:
|
|
14836
|
-
[tool_call: write or edit to apply the refactoring to 'src/auth.py']
|
|
14837
|
-
Refactoring complete. Running verification...
|
|
14838
|
-
[tool_call: bash for 'ruff check src/auth.py && pytest']
|
|
14839
|
-
(After verification passes)
|
|
14840
|
-
All checks passed. This is a stable checkpoint.
|
|
14841
|
-
|
|
14842
|
-
<example>
|
|
14843
|
-
user: Delete the temp directory.
|
|
14844
|
-
model: I can run \\\`rm -rf /path/to/project/temp\\\`. This will permanently delete the directory and all its contents.
|
|
14845
|
-
</example>
|
|
14846
|
-
|
|
14847
|
-
<example>
|
|
14848
|
-
user: Write tests for someFile.ts
|
|
14849
|
-
model:
|
|
14850
|
-
Okay, I can write those tests. First, I'll read \\\`someFile.ts\\\` to understand its functionality.
|
|
14851
|
-
[tool_call: read for absolute_path '/path/to/someFile.ts' or use glob to find \\\`someFile.ts\\\` if its location is unknown]
|
|
14852
|
-
Now I'll look for existing or related test files to understand current testing conventions and dependencies.
|
|
14853
|
-
[tool_call: glob for paths ['**/*.test.ts', 'src/**/*.spec.ts'] assuming someFile.ts is in the src directory]
|
|
14854
|
-
(After reviewing existing tests and the file content)
|
|
14855
|
-
[tool_call: write to create /path/to/someFile.test.ts with the test code]
|
|
14856
|
-
I've written the tests. Now I'll run the project's test command to verify them.
|
|
14857
|
-
[tool_call: bash for 'npm run test']
|
|
14858
|
-
</example>
|
|
14859
|
-
|
|
14860
|
-
<example>
|
|
14861
|
-
user: How do I update the user's profile information in this system?
|
|
14862
|
-
model:
|
|
14863
|
-
I'm not immediately sure how user profile information is updated. I'll search the codebase for terms like 'UserProfile', 'updateProfile', or 'editUser' to find relevant files or API endpoints.
|
|
14864
|
-
[tool_call: grep for pattern 'UserProfile|updateProfile|editUser']
|
|
14865
|
-
(After reviewing search results, assuming a relevant file like '/path/to/UserProfileService.java' was found)
|
|
14866
|
-
Okay, \\\`/path/to/UserProfileService.java\\\` seems like the most relevant file. I'll read its content to understand how updates are handled.
|
|
14867
|
-
[tool_call: read for absolute_path '/path/to/UserProfileService.java']
|
|
14868
|
-
(After reading the file)
|
|
14869
|
-
It appears the \\\`updateUserProfile\\\` method in \\\`UserProfileService.java\\\` is responsible for this. It expects a user ID and a \\\`UserProfileDTO\\\` object...
|
|
14870
|
-
</example>
|
|
14871
|
-
|
|
14872
|
-
<example>
|
|
14873
|
-
user: Where are all the 'app.config' files in this project? I need to check their settings.
|
|
14874
|
-
model:
|
|
14875
|
-
[tool_call: glob for pattern '**/app.config']
|
|
14876
|
-
(Assuming GlobTool returns a list of paths like ['/path/to/moduleA/app.config', '/path/to/moduleB/app.config'])
|
|
14877
|
-
I found the following 'app.config' files:
|
|
14878
|
-
- /path/to/moduleA/app.config
|
|
14879
|
-
- /path/to/moduleB/app.config
|
|
14880
|
-
To help you check their settings, I can read their contents. Which one would you like to start with, or should I read all of them?
|
|
14881
|
-
</example>
|
|
14882
|
-
|
|
14883
|
-
# Final Reminder
|
|
14884
|
-
Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use 'read' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.
|
|
14885
|
-
`;
|
|
14886
|
-
var codex_header_txt_default = `You are AnyCode, the best coding agent on the planet.
|
|
14764
|
+
var PROMPT_CODEX = `You are AnyCode, the best coding agent on the planet.
|
|
14887
14765
|
|
|
14888
14766
|
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
14889
14767
|
|
|
@@ -14963,7 +14841,117 @@ You are producing plain text that will later be styled by the CLI. Follow these
|
|
|
14963
14841
|
* Do not provide range of lines
|
|
14964
14842
|
* Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5
|
|
14965
14843
|
`;
|
|
14966
|
-
var
|
|
14844
|
+
var PROMPT_ANTHROPIC_WITHOUT_TODO = `You are anycode, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
14845
|
+
|
|
14846
|
+
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
14847
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
14848
|
+
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
14849
|
+
|
|
14850
|
+
If the user asks for help or wants to give feedback inform them of the following:
|
|
14851
|
+
- /help: Get help with using anycode
|
|
14852
|
+
- To give feedback, users should report the issue at https://github.com/wyattzheng/anycode/issues
|
|
14853
|
+
|
|
14854
|
+
When the user directly asks about anycode (eg 'can anycode do...', 'does anycode have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from anycode docs at https://anycode.ai
|
|
14855
|
+
|
|
14856
|
+
# Tone and style
|
|
14857
|
+
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
|
14858
|
+
Remember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
14859
|
+
Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
14860
|
+
If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
|
|
14861
|
+
Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
14862
|
+
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
|
|
14863
|
+
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
|
|
14864
|
+
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
|
|
14865
|
+
<example>
|
|
14866
|
+
user: 2 + 2
|
|
14867
|
+
assistant: 4
|
|
14868
|
+
</example>
|
|
14869
|
+
|
|
14870
|
+
<example>
|
|
14871
|
+
user: what is 2+2?
|
|
14872
|
+
assistant: 4
|
|
14873
|
+
</example>
|
|
14874
|
+
|
|
14875
|
+
<example>
|
|
14876
|
+
user: is 11 a prime number?
|
|
14877
|
+
assistant: Yes
|
|
14878
|
+
</example>
|
|
14879
|
+
|
|
14880
|
+
<example>
|
|
14881
|
+
user: what command should I run to list files in the current directory?
|
|
14882
|
+
assistant: ls
|
|
14883
|
+
</example>
|
|
14884
|
+
|
|
14885
|
+
<example>
|
|
14886
|
+
user: what command should I run to watch files in the current directory?
|
|
14887
|
+
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
|
|
14888
|
+
npm run dev
|
|
14889
|
+
</example>
|
|
14890
|
+
|
|
14891
|
+
<example>
|
|
14892
|
+
user: How many golf balls fit inside a jetta?
|
|
14893
|
+
assistant: 150000
|
|
14894
|
+
</example>
|
|
14895
|
+
|
|
14896
|
+
<example>
|
|
14897
|
+
user: what files are in the directory src/?
|
|
14898
|
+
assistant: [runs ls and sees foo.c, bar.c, baz.c]
|
|
14899
|
+
user: which file contains the implementation of foo?
|
|
14900
|
+
assistant: src/foo.c
|
|
14901
|
+
</example>
|
|
14902
|
+
|
|
14903
|
+
<example>
|
|
14904
|
+
user: write tests for new feature
|
|
14905
|
+
assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
|
|
14906
|
+
</example>
|
|
14907
|
+
|
|
14908
|
+
# Proactiveness
|
|
14909
|
+
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
|
|
14910
|
+
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
14911
|
+
2. Not surprising the user with actions you take without asking
|
|
14912
|
+
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
14913
|
+
3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
14914
|
+
|
|
14915
|
+
# Following conventions
|
|
14916
|
+
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
|
|
14917
|
+
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
|
|
14918
|
+
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
|
|
14919
|
+
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
|
|
14920
|
+
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
14921
|
+
|
|
14922
|
+
# Code style
|
|
14923
|
+
- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
|
|
14924
|
+
|
|
14925
|
+
# Doing tasks
|
|
14926
|
+
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
14927
|
+
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
14928
|
+
- Implement the solution using all tools available to you
|
|
14929
|
+
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
|
|
14930
|
+
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.
|
|
14931
|
+
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
14932
|
+
|
|
14933
|
+
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
|
|
14934
|
+
|
|
14935
|
+
# Tool usage policy
|
|
14936
|
+
- When doing file search, prefer to use the Task tool in order to reduce context usage.
|
|
14937
|
+
- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
|
|
14938
|
+
|
|
14939
|
+
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
|
|
14940
|
+
|
|
14941
|
+
IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
|
|
14942
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
|
|
14943
|
+
|
|
14944
|
+
# Code References
|
|
14945
|
+
|
|
14946
|
+
When referencing specific functions or pieces of code include the pattern \`file_path:line_number\` to allow the user to easily navigate to the source code location.
|
|
14947
|
+
|
|
14948
|
+
<example>
|
|
14949
|
+
user: Where are errors from the client handled?
|
|
14950
|
+
assistant: Clients are marked as failed in the \`connectToServer\` function in src/services/process.ts:712.
|
|
14951
|
+
</example>
|
|
14952
|
+
|
|
14953
|
+
`;
|
|
14954
|
+
var PROMPT_TRINITY = `You are anycode, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
14967
14955
|
|
|
14968
14956
|
# Tone and style
|
|
14969
14957
|
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
|
@@ -15061,20 +15049,353 @@ user: Where are errors from the client handled?
|
|
|
15061
15049
|
assistant: Clients are marked as failed in the \`connectToServer\` function in src/services/process.ts:712.
|
|
15062
15050
|
</example>
|
|
15063
15051
|
`;
|
|
15052
|
+
var OUTPUT_TOKEN_MAX = Flag.OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX || 32e3;
|
|
15053
|
+
function mimeToModality(mime) {
|
|
15054
|
+
if (mime.startsWith("image/")) return "image";
|
|
15055
|
+
if (mime.startsWith("audio/")) return "audio";
|
|
15056
|
+
if (mime.startsWith("video/")) return "video";
|
|
15057
|
+
if (mime === "application/pdf") return "pdf";
|
|
15058
|
+
return void 0;
|
|
15059
|
+
}
|
|
15060
|
+
function unsupportedParts(msgs, model) {
|
|
15061
|
+
return msgs.map((msg) => {
|
|
15062
|
+
if (msg.role !== "user" || !Array.isArray(msg.content)) return msg;
|
|
15063
|
+
const filtered = msg.content.map((part) => {
|
|
15064
|
+
if (part.type !== "file" && part.type !== "image") return part;
|
|
15065
|
+
if (part.type === "image") {
|
|
15066
|
+
const imageStr = part.image.toString();
|
|
15067
|
+
if (imageStr.startsWith("data:")) {
|
|
15068
|
+
const match = imageStr.match(/^data:([^;]+);base64,(.*)$/);
|
|
15069
|
+
if (match && (!match[2] || match[2].length === 0)) {
|
|
15070
|
+
return {
|
|
15071
|
+
type: "text",
|
|
15072
|
+
text: "ERROR: Image file is empty or corrupted. Please provide a valid image."
|
|
15073
|
+
};
|
|
15074
|
+
}
|
|
15075
|
+
}
|
|
15076
|
+
}
|
|
15077
|
+
const mime = part.type === "image" ? part.image.toString().split(";")[0].replace("data:", "") : part.mediaType;
|
|
15078
|
+
const filename = part.type === "file" ? part.filename : void 0;
|
|
15079
|
+
const modality = mimeToModality(mime);
|
|
15080
|
+
if (!modality) return part;
|
|
15081
|
+
if (model.capabilities.input[modality]) return part;
|
|
15082
|
+
const name2 = filename ? `"${filename}"` : modality;
|
|
15083
|
+
return {
|
|
15084
|
+
type: "text",
|
|
15085
|
+
text: `ERROR: Cannot read ${name2} (this model does not support ${modality} input). Inform the user.`
|
|
15086
|
+
};
|
|
15087
|
+
});
|
|
15088
|
+
return { ...msg, content: filtered };
|
|
15089
|
+
});
|
|
15090
|
+
}
|
|
15091
|
+
var VENDORS = [
|
|
15092
|
+
anthropicVendor,
|
|
15093
|
+
githubCopilotVendor,
|
|
15094
|
+
googleVendor,
|
|
15095
|
+
liteLLMVendor,
|
|
15096
|
+
openAIVendor
|
|
15097
|
+
];
|
|
15098
|
+
var VENDORS_BY_NPM = new Map(
|
|
15099
|
+
VENDORS.flatMap((vendor) => (vendor.npms ?? []).map((npm) => [npm, vendor]))
|
|
15100
|
+
);
|
|
15101
|
+
function matchesRuntimeVendor(vendor, input) {
|
|
15102
|
+
return vendor.matchesRuntime?.(input) || vendor.id === input.provider.id || vendor.id === input.model.providerID || vendor.npms?.includes(input.model.api.npm) === true;
|
|
15103
|
+
}
|
|
15104
|
+
function getMatchingVendors(input) {
|
|
15105
|
+
if (input.id) return VENDORS.filter((vendor) => vendor.id === input.id);
|
|
15106
|
+
if (input.model && input.provider) {
|
|
15107
|
+
return VENDORS.filter(
|
|
15108
|
+
(vendor) => matchesRuntimeVendor(vendor, {
|
|
15109
|
+
model: input.model,
|
|
15110
|
+
provider: input.provider,
|
|
15111
|
+
auth: input.auth
|
|
15112
|
+
})
|
|
15113
|
+
);
|
|
15114
|
+
}
|
|
15115
|
+
if (input.model) {
|
|
15116
|
+
const runtimeProvider = { id: input.model.providerID, options: {} };
|
|
15117
|
+
return VENDORS.filter(
|
|
15118
|
+
(vendor) => matchesRuntimeVendor(vendor, {
|
|
15119
|
+
model: input.model,
|
|
15120
|
+
provider: runtimeProvider,
|
|
15121
|
+
auth: input.auth
|
|
15122
|
+
})
|
|
15123
|
+
);
|
|
15124
|
+
}
|
|
15125
|
+
if (input.npm) {
|
|
15126
|
+
const vendor = VENDORS_BY_NPM.get(input.npm);
|
|
15127
|
+
return vendor ? [vendor] : [];
|
|
15128
|
+
}
|
|
15129
|
+
return VENDORS;
|
|
15130
|
+
}
|
|
15131
|
+
function getSelectorNpm(input) {
|
|
15132
|
+
return input.npm ?? input.model?.api.npm;
|
|
15133
|
+
}
|
|
15134
|
+
var VendorRegistry = {
|
|
15135
|
+
getModelProvider(input = {}) {
|
|
15136
|
+
const vendors = getMatchingVendors(input);
|
|
15137
|
+
const npm = getSelectorNpm(input);
|
|
15138
|
+
const model = input.model;
|
|
15139
|
+
const runtime = input.model ? {
|
|
15140
|
+
model: input.model,
|
|
15141
|
+
provider: input.provider ?? { id: input.model.providerID, options: {} },
|
|
15142
|
+
auth: input.auth
|
|
15143
|
+
} : void 0;
|
|
15144
|
+
const accessor = {
|
|
15145
|
+
all() {
|
|
15146
|
+
return vendors;
|
|
15147
|
+
},
|
|
15148
|
+
getBundledProvider() {
|
|
15149
|
+
if (!npm) return void 0;
|
|
15150
|
+
return vendors.find((vendor) => vendor.bundled?.[npm])?.bundled?.[npm];
|
|
15151
|
+
},
|
|
15152
|
+
getCustomLoaders() {
|
|
15153
|
+
return Object.fromEntries(vendors.flatMap((vendor) => vendor.customLoader ? [[vendor.id, vendor.customLoader]] : []));
|
|
15154
|
+
},
|
|
15155
|
+
getOptionsKey() {
|
|
15156
|
+
if (!npm) return model?.providerID;
|
|
15157
|
+
return vendors.find((vendor) => vendor.sdkKeys?.[npm])?.sdkKeys?.[npm] ?? model?.providerID;
|
|
15158
|
+
},
|
|
15159
|
+
applyRequestPatch(patchInput) {
|
|
15160
|
+
const targetModel = patchInput.model ?? input.model;
|
|
15161
|
+
if (!targetModel) return;
|
|
15162
|
+
vendors.forEach((vendor) => vendor.patchRequest?.({ ...patchInput, model: targetModel }));
|
|
15163
|
+
},
|
|
15164
|
+
applyMessageTransforms(msgs, options) {
|
|
15165
|
+
if (!model) return msgs;
|
|
15166
|
+
msgs = unsupportedParts(msgs, model);
|
|
15167
|
+
msgs = vendors.reduce((result, vendor) => vendor.transform?.message?.(result, model, options) ?? result, msgs);
|
|
15168
|
+
const key = this.getOptionsKey();
|
|
15169
|
+
if (!key || key === model.providerID) return msgs;
|
|
15170
|
+
const remap = (opts) => {
|
|
15171
|
+
if (!opts) return opts;
|
|
15172
|
+
if (!(model.providerID in opts)) return opts;
|
|
15173
|
+
const result = { ...opts };
|
|
15174
|
+
result[key] = result[model.providerID];
|
|
15175
|
+
delete result[model.providerID];
|
|
15176
|
+
return result;
|
|
15177
|
+
};
|
|
15178
|
+
return msgs.map((msg) => {
|
|
15179
|
+
if (!Array.isArray(msg.content)) return { ...msg, providerOptions: remap(msg.providerOptions) };
|
|
15180
|
+
return {
|
|
15181
|
+
...msg,
|
|
15182
|
+
providerOptions: remap(msg.providerOptions),
|
|
15183
|
+
content: msg.content.map((part) => ({ ...part, providerOptions: remap(part.providerOptions) }))
|
|
15184
|
+
};
|
|
15185
|
+
});
|
|
15186
|
+
},
|
|
15187
|
+
getOptions(transformInput) {
|
|
15188
|
+
const targetInput = {
|
|
15189
|
+
...transformInput,
|
|
15190
|
+
model: transformInput.model ?? model
|
|
15191
|
+
};
|
|
15192
|
+
if (!targetInput.model) return {};
|
|
15193
|
+
return vendors.reduce(
|
|
15194
|
+
(result, vendor) => D(result, vendor.transform?.options?.(targetInput) ?? {}),
|
|
15195
|
+
{}
|
|
15196
|
+
);
|
|
15197
|
+
},
|
|
15198
|
+
getSmallOptions() {
|
|
15199
|
+
if (!model) return {};
|
|
15200
|
+
return vendors.reduce(
|
|
15201
|
+
(result, vendor) => D(result, vendor.transform?.smallOptions?.(model) ?? {}),
|
|
15202
|
+
{}
|
|
15203
|
+
);
|
|
15204
|
+
},
|
|
15205
|
+
getTemperature() {
|
|
15206
|
+
if (!model) return void 0;
|
|
15207
|
+
for (const vendor of vendors) {
|
|
15208
|
+
const value = vendor.transform?.temperature?.(model);
|
|
15209
|
+
if (value !== void 0) return value;
|
|
15210
|
+
}
|
|
15211
|
+
return void 0;
|
|
15212
|
+
},
|
|
15213
|
+
getTopK() {
|
|
15214
|
+
if (!model) return void 0;
|
|
15215
|
+
for (const vendor of vendors) {
|
|
15216
|
+
const value = vendor.transform?.topK?.(model);
|
|
15217
|
+
if (value !== void 0) return value;
|
|
15218
|
+
}
|
|
15219
|
+
return void 0;
|
|
15220
|
+
},
|
|
15221
|
+
getTopP() {
|
|
15222
|
+
return void 0;
|
|
15223
|
+
},
|
|
15224
|
+
getOutputTokenMax() {
|
|
15225
|
+
return OUTPUT_TOKEN_MAX;
|
|
15226
|
+
},
|
|
15227
|
+
getMaxOutputTokens() {
|
|
15228
|
+
if (!model) return OUTPUT_TOKEN_MAX;
|
|
15229
|
+
return Math.min(model.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX;
|
|
15230
|
+
},
|
|
15231
|
+
transformSchema(schema) {
|
|
15232
|
+
if (!model) return schema;
|
|
15233
|
+
return vendors.reduce(
|
|
15234
|
+
(result, vendor) => vendor.transform?.schema?.(model, result) ?? result,
|
|
15235
|
+
schema
|
|
15236
|
+
);
|
|
15237
|
+
},
|
|
15238
|
+
getProviderSystemPrompt() {
|
|
15239
|
+
if (!model) return [];
|
|
15240
|
+
for (const vendor of vendors) {
|
|
15241
|
+
const value = vendor.prompt?.provider?.(model);
|
|
15242
|
+
if (value !== void 0) return value;
|
|
15243
|
+
}
|
|
15244
|
+
return [];
|
|
15245
|
+
},
|
|
15246
|
+
getInstructionPrompt() {
|
|
15247
|
+
if (!model) return "";
|
|
15248
|
+
for (const vendor of vendors) {
|
|
15249
|
+
const value = vendor.prompt?.instructions?.(model);
|
|
15250
|
+
if (value !== void 0) return value;
|
|
15251
|
+
}
|
|
15252
|
+
return "";
|
|
15253
|
+
},
|
|
15254
|
+
wrapProviderOptions(options) {
|
|
15255
|
+
const key = this.getOptionsKey();
|
|
15256
|
+
return { [key]: options };
|
|
15257
|
+
},
|
|
15258
|
+
shouldUseInstructionPrompt() {
|
|
15259
|
+
if (!runtime) return false;
|
|
15260
|
+
return vendors.some((vendor) => vendor.llm?.useInstructionPrompt?.(runtime) === true);
|
|
15261
|
+
},
|
|
15262
|
+
shouldIncludeProviderSystemPrompt() {
|
|
15263
|
+
if (!runtime) return true;
|
|
15264
|
+
return !vendors.some((vendor) => vendor.llm?.includeProviderSystemPrompt?.(runtime) === false);
|
|
15265
|
+
},
|
|
15266
|
+
shouldDisableMaxOutputTokens() {
|
|
15267
|
+
if (!runtime) return false;
|
|
15268
|
+
return vendors.some((vendor) => vendor.llm?.disableMaxOutputTokens?.(runtime) === true);
|
|
15269
|
+
},
|
|
15270
|
+
shouldAddNoopToolFallback() {
|
|
15271
|
+
if (!runtime) return false;
|
|
15272
|
+
return vendors.some((vendor) => vendor.llm?.needsNoopToolFallback?.(runtime) === true);
|
|
15273
|
+
}
|
|
15274
|
+
};
|
|
15275
|
+
return accessor;
|
|
15276
|
+
}
|
|
15277
|
+
};
|
|
15278
|
+
var plan_txt_default = `<system-reminder>
|
|
15279
|
+
# Plan Mode - System Reminder
|
|
15280
|
+
|
|
15281
|
+
CRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:
|
|
15282
|
+
ANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,
|
|
15283
|
+
or ANY other bash command to manipulate files - commands may ONLY read/inspect.
|
|
15284
|
+
This ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user
|
|
15285
|
+
edit requests. You may ONLY observe, analyze, and plan. Any modification attempt
|
|
15286
|
+
is a critical violation. ZERO exceptions.
|
|
15287
|
+
|
|
15288
|
+
---
|
|
15289
|
+
|
|
15290
|
+
## Responsibility
|
|
15291
|
+
|
|
15292
|
+
Your current responsibility is to think, read, search, and delegate explore agents to construct a well-formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.
|
|
15293
|
+
|
|
15294
|
+
Ask the user clarifying questions or ask for their opinion when weighing tradeoffs.
|
|
15295
|
+
|
|
15296
|
+
**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.
|
|
15297
|
+
|
|
15298
|
+
---
|
|
15299
|
+
|
|
15300
|
+
## Important
|
|
15301
|
+
|
|
15302
|
+
The user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.
|
|
15303
|
+
</system-reminder>
|
|
15304
|
+
`;
|
|
15305
|
+
var build_switch_txt_default = `<system-reminder>
|
|
15306
|
+
Your operational mode has changed from plan to build.
|
|
15307
|
+
You are no longer in read-only mode.
|
|
15308
|
+
You are permitted to make file changes, run shell commands, and utilize your arsenal of tools as needed.
|
|
15309
|
+
</system-reminder>
|
|
15310
|
+
`;
|
|
15311
|
+
var log = Log.create({ module: "hooks" });
|
|
15312
|
+
var Hooks;
|
|
15313
|
+
((Hooks2) => {
|
|
15314
|
+
const DEFAULT_TIMEOUT = 15;
|
|
15315
|
+
function toSnakeCase(key) {
|
|
15316
|
+
return key.replace(/[A-Z]/g, (ch) => "_" + ch.toLowerCase());
|
|
15317
|
+
}
|
|
15318
|
+
function keysToSnakeCase(obj) {
|
|
15319
|
+
if (obj === null || obj === void 0 || typeof obj !== "object") return obj;
|
|
15320
|
+
if (Array.isArray(obj)) return obj.map(keysToSnakeCase);
|
|
15321
|
+
const out = {};
|
|
15322
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
15323
|
+
out[toSnakeCase(key)] = keysToSnakeCase(value);
|
|
15324
|
+
}
|
|
15325
|
+
return out;
|
|
15326
|
+
}
|
|
15327
|
+
function matchTool(rules, toolName, filePath) {
|
|
15328
|
+
const matched = [];
|
|
15329
|
+
for (const rule of rules) {
|
|
15330
|
+
try {
|
|
15331
|
+
if (!new RegExp(rule.matcher, "i").test(toolName)) continue;
|
|
15332
|
+
if (filePath && rule.ignore?.some((pat) => {
|
|
15333
|
+
try {
|
|
15334
|
+
return new RegExp(pat, "i").test(filePath);
|
|
15335
|
+
} catch {
|
|
15336
|
+
return false;
|
|
15337
|
+
}
|
|
15338
|
+
})) continue;
|
|
15339
|
+
matched.push(...rule.hooks);
|
|
15340
|
+
} catch {
|
|
15341
|
+
}
|
|
15342
|
+
}
|
|
15343
|
+
return matched;
|
|
15344
|
+
}
|
|
15345
|
+
Hooks2.matchTool = matchTool;
|
|
15346
|
+
function execute(hook, payload, cwd) {
|
|
15347
|
+
const timeout = (hook.timeout ?? DEFAULT_TIMEOUT) * 1e3;
|
|
15348
|
+
const payloadStr = JSON.stringify(payload);
|
|
15349
|
+
try {
|
|
15350
|
+
const proc = spawn("bash", ["-c", hook.command], {
|
|
15351
|
+
cwd,
|
|
15352
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
15353
|
+
env: process.env,
|
|
15354
|
+
detached: true
|
|
15355
|
+
});
|
|
15356
|
+
proc.unref();
|
|
15357
|
+
proc.stdin?.write(payloadStr);
|
|
15358
|
+
proc.stdin?.end();
|
|
15359
|
+
const timer = setTimeout(() => {
|
|
15360
|
+
try {
|
|
15361
|
+
proc.kill("SIGTERM");
|
|
15362
|
+
} catch {
|
|
15363
|
+
}
|
|
15364
|
+
}, timeout);
|
|
15365
|
+
proc.on("exit", () => clearTimeout(timer));
|
|
15366
|
+
proc.on("error", () => clearTimeout(timer));
|
|
15367
|
+
} catch (err) {
|
|
15368
|
+
log.info(`Hook execution failed: ${err}`);
|
|
15369
|
+
}
|
|
15370
|
+
}
|
|
15371
|
+
function runPostToolUse(hooksConfig, toolName, toolInput, toolResponse, sessionID, cwd) {
|
|
15372
|
+
const rules = hooksConfig["PostToolUse"];
|
|
15373
|
+
if (!rules || rules.length === 0) return;
|
|
15374
|
+
const filePath = toolInput?.filePath ?? toolInput?.file_path;
|
|
15375
|
+
const hooks = matchTool(rules, toolName, filePath);
|
|
15376
|
+
if (hooks.length === 0) return;
|
|
15377
|
+
const payload = {
|
|
15378
|
+
session_id: sessionID,
|
|
15379
|
+
cwd,
|
|
15380
|
+
hook_event_name: "PostToolUse",
|
|
15381
|
+
tool_name: toolName,
|
|
15382
|
+
tool_input: keysToSnakeCase(toolInput),
|
|
15383
|
+
tool_response: keysToSnakeCase(toolResponse)
|
|
15384
|
+
};
|
|
15385
|
+
for (const hook of hooks) {
|
|
15386
|
+
execute(hook, payload, cwd);
|
|
15387
|
+
}
|
|
15388
|
+
}
|
|
15389
|
+
Hooks2.runPostToolUse = runPostToolUse;
|
|
15390
|
+
})(Hooks || (Hooks = {}));
|
|
15064
15391
|
var SystemPrompt;
|
|
15065
15392
|
((SystemPrompt2) => {
|
|
15066
|
-
function instructions() {
|
|
15067
|
-
return
|
|
15393
|
+
function instructions(model) {
|
|
15394
|
+
return VendorRegistry.getModelProvider({ model }).getInstructionPrompt();
|
|
15068
15395
|
}
|
|
15069
15396
|
SystemPrompt2.instructions = instructions;
|
|
15070
15397
|
function provider(model) {
|
|
15071
|
-
|
|
15072
|
-
if (model.api.id.includes("gpt-") || model.api.id.includes("o1") || model.api.id.includes("o3"))
|
|
15073
|
-
return [beast_txt_default];
|
|
15074
|
-
if (model.api.id.includes("gemini-")) return [gemini_txt_default];
|
|
15075
|
-
if (model.api.id.includes("claude")) return [anthropic_txt_default];
|
|
15076
|
-
if (model.api.id.toLowerCase().includes("trinity")) return [trinity_txt_default];
|
|
15077
|
-
return [qwen_txt_default];
|
|
15398
|
+
return VendorRegistry.getModelProvider({ model }).getProviderSystemPrompt();
|
|
15078
15399
|
}
|
|
15079
15400
|
SystemPrompt2.provider = provider;
|
|
15080
15401
|
async function environment(model, context) {
|
|
@@ -15134,8 +15455,9 @@ var ContextCompaction;
|
|
|
15134
15455
|
const contextLimit = input.model.limit.context;
|
|
15135
15456
|
if (contextLimit === 0) return false;
|
|
15136
15457
|
const count = input.tokens.total || input.tokens.input + input.tokens.output + input.tokens.cache.read + input.tokens.cache.write;
|
|
15137
|
-
const
|
|
15138
|
-
const
|
|
15458
|
+
const modelProvider = VendorRegistry.getModelProvider({ model: input.model });
|
|
15459
|
+
const reserved = config.compaction?.reserved ?? Math.min(COMPACTION_BUFFER, modelProvider.getMaxOutputTokens());
|
|
15460
|
+
const usable = input.model.limit.input ? input.model.limit.input - reserved : contextLimit - modelProvider.getMaxOutputTokens();
|
|
15139
15461
|
return count >= usable;
|
|
15140
15462
|
}
|
|
15141
15463
|
ContextCompaction2.isOverflow = isOverflow;
|
|
@@ -15465,7 +15787,7 @@ var SessionRetry;
|
|
|
15465
15787
|
var LLM;
|
|
15466
15788
|
((LLM2) => {
|
|
15467
15789
|
const log2 = Log.create({ service: "llm" });
|
|
15468
|
-
LLM2.OUTPUT_TOKEN_MAX =
|
|
15790
|
+
LLM2.OUTPUT_TOKEN_MAX = VendorRegistry.getModelProvider().getOutputTokenMax();
|
|
15469
15791
|
async function stream(context, input) {
|
|
15470
15792
|
const l = log2.clone().tag("providerID", input.model.providerID).tag("modelID", input.model.id).tag("sessionID", input.sessionID).tag("small", (input.small ?? false).toString()).tag("agent", input.agent.name).tag("mode", input.agent.mode);
|
|
15471
15793
|
l.info("stream", {
|
|
@@ -15478,13 +15800,16 @@ var LLM;
|
|
|
15478
15800
|
Auth.get(input.model.providerID)
|
|
15479
15801
|
]);
|
|
15480
15802
|
const cfg = context.config;
|
|
15481
|
-
const
|
|
15803
|
+
const runtime = { model: input.model, provider, auth };
|
|
15804
|
+
const modelProvider = VendorRegistry.getModelProvider(runtime);
|
|
15805
|
+
const useInstructions = modelProvider.shouldUseInstructionPrompt();
|
|
15806
|
+
const includeProviderPrompt = modelProvider.shouldIncludeProviderSystemPrompt();
|
|
15482
15807
|
const system = [];
|
|
15483
15808
|
system.push(
|
|
15484
15809
|
[
|
|
15485
15810
|
// use agent prompt otherwise provider prompt
|
|
15486
|
-
//
|
|
15487
|
-
...input.agent.prompt ? [input.agent.prompt] :
|
|
15811
|
+
// Some providers send their system prompt via vendor-specific instructions.
|
|
15812
|
+
...input.agent.prompt ? [input.agent.prompt] : includeProviderPrompt ? SystemPrompt.provider(input.model) : [],
|
|
15488
15813
|
// any custom prompt passed into this call
|
|
15489
15814
|
...input.system,
|
|
15490
15815
|
// any custom prompt from last user message
|
|
@@ -15497,7 +15822,7 @@ var LLM;
|
|
|
15497
15822
|
system.length = 0;
|
|
15498
15823
|
system.push(header, rest.join("\n"));
|
|
15499
15824
|
}
|
|
15500
|
-
const base = input.small ?
|
|
15825
|
+
const base = input.small ? modelProvider.getSmallOptions() : modelProvider.getOptions({
|
|
15501
15826
|
model: input.model,
|
|
15502
15827
|
sessionID: input.sessionID,
|
|
15503
15828
|
providerOptions: provider.options
|
|
@@ -15507,21 +15832,21 @@ var LLM;
|
|
|
15507
15832
|
D(input.model.options),
|
|
15508
15833
|
D(input.agent.options)
|
|
15509
15834
|
);
|
|
15510
|
-
if (
|
|
15511
|
-
options.instructions = SystemPrompt.instructions();
|
|
15835
|
+
if (useInstructions) {
|
|
15836
|
+
options.instructions = SystemPrompt.instructions(input.model);
|
|
15512
15837
|
}
|
|
15513
15838
|
const params = {
|
|
15514
|
-
temperature: input.model.capabilities.temperature ? input.agent.temperature ??
|
|
15515
|
-
topP: input.agent.topP ??
|
|
15516
|
-
topK:
|
|
15839
|
+
temperature: input.model.capabilities.temperature ? input.agent.temperature ?? modelProvider.getTemperature() : void 0,
|
|
15840
|
+
topP: input.agent.topP ?? modelProvider.getTopP(),
|
|
15841
|
+
topK: modelProvider.getTopK(),
|
|
15517
15842
|
options
|
|
15518
15843
|
};
|
|
15519
15844
|
const { headers } = {
|
|
15520
15845
|
headers: {}
|
|
15521
15846
|
};
|
|
15522
|
-
const maxOutputTokens =
|
|
15847
|
+
const maxOutputTokens = modelProvider.shouldDisableMaxOutputTokens() ? void 0 : modelProvider.getMaxOutputTokens();
|
|
15523
15848
|
const tools = await resolveTools(input);
|
|
15524
|
-
const isLiteLLMProxy =
|
|
15849
|
+
const isLiteLLMProxy = modelProvider.shouldAddNoopToolFallback();
|
|
15525
15850
|
if (isLiteLLMProxy && Object.keys(tools).length === 0 && hasToolCalls(input.messages)) {
|
|
15526
15851
|
tools["_noop"] = tool({
|
|
15527
15852
|
description: "Placeholder for LiteLLM/Anthropic proxy compatibility - required when message history contains tool calls but no active tools are needed",
|
|
@@ -15559,7 +15884,7 @@ var LLM;
|
|
|
15559
15884
|
temperature: params.temperature,
|
|
15560
15885
|
topP: params.topP,
|
|
15561
15886
|
topK: params.topK,
|
|
15562
|
-
providerOptions:
|
|
15887
|
+
providerOptions: modelProvider.wrapProviderOptions(params.options),
|
|
15563
15888
|
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
|
|
15564
15889
|
tools,
|
|
15565
15890
|
toolChoice: input.toolChoice,
|
|
@@ -15585,7 +15910,7 @@ var LLM;
|
|
|
15585
15910
|
{
|
|
15586
15911
|
async transformParams(args) {
|
|
15587
15912
|
if (args.type === "stream") {
|
|
15588
|
-
args.params.prompt =
|
|
15913
|
+
args.params.prompt = modelProvider.applyMessageTransforms(args.params.prompt, options);
|
|
15589
15914
|
}
|
|
15590
15915
|
return args.params;
|
|
15591
15916
|
}
|
|
@@ -16100,7 +16425,7 @@ var SessionPrompt;
|
|
|
16100
16425
|
{ modelID: ModelID.make(input.model.api.id), providerID: input.model.providerID },
|
|
16101
16426
|
input.agent
|
|
16102
16427
|
)) {
|
|
16103
|
-
const schema =
|
|
16428
|
+
const schema = VendorRegistry.getModelProvider({ model: input.model }).transformSchema(zod_default.toJSONSchema(item.parameters));
|
|
16104
16429
|
tools[item.id] = tool({
|
|
16105
16430
|
id: item.id,
|
|
16106
16431
|
description: item.description,
|
|
@@ -16601,27 +16926,6 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|
|
16601
16926
|
}
|
|
16602
16927
|
SessionPrompt2.ensureTitle = ensureTitle;
|
|
16603
16928
|
})(SessionPrompt || (SessionPrompt = {}));
|
|
16604
|
-
var Hash;
|
|
16605
|
-
((Hash2) => {
|
|
16606
|
-
function fast(input) {
|
|
16607
|
-
return createHash("sha1").update(input).digest("hex");
|
|
16608
|
-
}
|
|
16609
|
-
Hash2.fast = fast;
|
|
16610
|
-
function sha256(input) {
|
|
16611
|
-
return createHash("sha256").update(input).digest("hex");
|
|
16612
|
-
}
|
|
16613
|
-
Hash2.sha256 = sha256;
|
|
16614
|
-
function hexToUUID(hex) {
|
|
16615
|
-
return [
|
|
16616
|
-
hex.slice(0, 8),
|
|
16617
|
-
hex.slice(8, 12),
|
|
16618
|
-
hex.slice(12, 16),
|
|
16619
|
-
hex.slice(16, 20),
|
|
16620
|
-
hex.slice(20, 32)
|
|
16621
|
-
].join("-");
|
|
16622
|
-
}
|
|
16623
|
-
Hash2.hexToUUID = hexToUUID;
|
|
16624
|
-
})(Hash || (Hash = {}));
|
|
16625
16929
|
var ModelsDev;
|
|
16626
16930
|
((ModelsDev2) => {
|
|
16627
16931
|
const log2 = Log.create({ service: "models.dev" });
|
|
@@ -16733,55 +17037,6 @@ var ModelsDev;
|
|
|
16733
17037
|
ModelsDev2.refresh = refresh;
|
|
16734
17038
|
})(ModelsDev || (ModelsDev = {}));
|
|
16735
17039
|
var DEFAULT_CHUNK_TIMEOUT = 12e4;
|
|
16736
|
-
function stripOpenAIItemIds(opts, model) {
|
|
16737
|
-
try {
|
|
16738
|
-
const body = JSON.parse(opts.body);
|
|
16739
|
-
const isAzure = model.providerID?.includes("azure");
|
|
16740
|
-
const keepIds = isAzure && body.store === true;
|
|
16741
|
-
if (!keepIds && Array.isArray(body.input)) {
|
|
16742
|
-
for (const item of body.input) {
|
|
16743
|
-
if ("id" in item) delete item.id;
|
|
16744
|
-
}
|
|
16745
|
-
opts.body = JSON.stringify(body);
|
|
16746
|
-
}
|
|
16747
|
-
} catch {
|
|
16748
|
-
}
|
|
16749
|
-
}
|
|
16750
|
-
function injectClaudeCodeIdentity(opts, model, providerKey) {
|
|
16751
|
-
try {
|
|
16752
|
-
const body = JSON.parse(opts.body);
|
|
16753
|
-
if (!body.metadata?.user_id) {
|
|
16754
|
-
if (!body.metadata) body.metadata = {};
|
|
16755
|
-
const seed = [model.providerID ?? "", providerKey ?? ""].join(":");
|
|
16756
|
-
const clientId = Hash.sha256(seed + ":claude-code-client");
|
|
16757
|
-
const uuid = Hash.hexToUUID(Hash.sha256(seed + ":session"));
|
|
16758
|
-
body.metadata.user_id = `user_${clientId}_account__session_${uuid}`;
|
|
16759
|
-
}
|
|
16760
|
-
if (Array.isArray(body.system)) {
|
|
16761
|
-
const alreadyPresent = body.system.some(
|
|
16762
|
-
(entry) => typeof entry.text === "string" && entry.text.startsWith(CLAUDE_CODE_SYSTEM)
|
|
16763
|
-
);
|
|
16764
|
-
if (!alreadyPresent) {
|
|
16765
|
-
body.system.unshift({
|
|
16766
|
-
type: "text",
|
|
16767
|
-
text: CLAUDE_CODE_SYSTEM,
|
|
16768
|
-
cache_control: { type: "ephemeral" }
|
|
16769
|
-
});
|
|
16770
|
-
}
|
|
16771
|
-
}
|
|
16772
|
-
opts.body = JSON.stringify(body);
|
|
16773
|
-
} catch {
|
|
16774
|
-
}
|
|
16775
|
-
}
|
|
16776
|
-
function setClaudeUserAgent(opts) {
|
|
16777
|
-
if (opts.headers) {
|
|
16778
|
-
const headers = new Headers(opts.headers);
|
|
16779
|
-
headers.set("user-agent", "claude-cli/2.1.77");
|
|
16780
|
-
opts.headers = Object.fromEntries(headers.entries());
|
|
16781
|
-
} else {
|
|
16782
|
-
opts.headers = { "user-agent": "claude-cli/2.1.77" };
|
|
16783
|
-
}
|
|
16784
|
-
}
|
|
16785
17040
|
var Provider;
|
|
16786
17041
|
((Provider2) => {
|
|
16787
17042
|
const log2 = Log.create({ service: "provider" });
|
|
@@ -16827,43 +17082,6 @@ var Provider;
|
|
|
16827
17082
|
statusText: res.statusText
|
|
16828
17083
|
});
|
|
16829
17084
|
}
|
|
16830
|
-
const BUNDLED_PROVIDERS = {
|
|
16831
|
-
"@ai-sdk/anthropic": createAnthropic,
|
|
16832
|
-
"@ai-sdk/google": createGoogleGenerativeAI,
|
|
16833
|
-
"@ai-sdk/openai": createOpenAI,
|
|
16834
|
-
"@ai-sdk/openai-compatible": createOpenAICompatible
|
|
16835
|
-
};
|
|
16836
|
-
const CUSTOM_LOADERS = {
|
|
16837
|
-
async anthropic() {
|
|
16838
|
-
return {
|
|
16839
|
-
autoload: false,
|
|
16840
|
-
options: {
|
|
16841
|
-
headers: {
|
|
16842
|
-
"anthropic-beta": "claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
|
|
16843
|
-
"X-App": "cli",
|
|
16844
|
-
"X-Stainless-Lang": "js",
|
|
16845
|
-
"X-Stainless-Package-Version": "0.70.0",
|
|
16846
|
-
"X-Stainless-OS": process.platform === "darwin" ? "MacOS" : process.platform === "win32" ? "Windows" : "Linux",
|
|
16847
|
-
"X-Stainless-Arch": process.arch === "arm64" ? "arm64" : "x64",
|
|
16848
|
-
"X-Stainless-Runtime": "node",
|
|
16849
|
-
"X-Stainless-Runtime-Version": process.version,
|
|
16850
|
-
"X-Stainless-Retry-Count": "0",
|
|
16851
|
-
"X-Stainless-Timeout": "600",
|
|
16852
|
-
"Anthropic-Dangerous-Direct-Browser-Access": "true"
|
|
16853
|
-
}
|
|
16854
|
-
}
|
|
16855
|
-
};
|
|
16856
|
-
},
|
|
16857
|
-
openai: async () => {
|
|
16858
|
-
return {
|
|
16859
|
-
autoload: false,
|
|
16860
|
-
async getModel(sdk, modelID, _options) {
|
|
16861
|
-
return sdk.responses(modelID);
|
|
16862
|
-
},
|
|
16863
|
-
options: {}
|
|
16864
|
-
};
|
|
16865
|
-
}
|
|
16866
|
-
};
|
|
16867
17085
|
Provider2.Model = zod_default.object({
|
|
16868
17086
|
id: ModelID.zod,
|
|
16869
17087
|
providerID: ProviderID.zod,
|
|
@@ -17175,13 +17393,7 @@ var Provider;
|
|
|
17175
17393
|
signals.push(AbortSignal.timeout(options["timeout"]));
|
|
17176
17394
|
const combined = signals.length === 0 ? null : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
17177
17395
|
if (combined) opts.signal = combined;
|
|
17178
|
-
|
|
17179
|
-
stripOpenAIItemIds(opts, model);
|
|
17180
|
-
}
|
|
17181
|
-
if (model.api.npm === "@ai-sdk/anthropic" && opts.body && opts.method === "POST") {
|
|
17182
|
-
injectClaudeCodeIdentity(opts, model, provider.key);
|
|
17183
|
-
}
|
|
17184
|
-
setClaudeUserAgent(opts);
|
|
17396
|
+
VendorRegistry.getModelProvider({ model }).applyRequestPatch({ opts, provider });
|
|
17185
17397
|
const res = await fetchFn(input, {
|
|
17186
17398
|
...opts,
|
|
17187
17399
|
// @ts-ignore see here: https://github.com/oven-sh/bun/issues/16682
|
|
@@ -17190,7 +17402,7 @@ var Provider;
|
|
|
17190
17402
|
if (!chunkAbortCtl) return res;
|
|
17191
17403
|
return wrapSSE(res, chunkTimeout, chunkAbortCtl);
|
|
17192
17404
|
};
|
|
17193
|
-
const bundledFn =
|
|
17405
|
+
const bundledFn = VendorRegistry.getModelProvider({ npm: model.api.npm }).getBundledProvider();
|
|
17194
17406
|
if (bundledFn) {
|
|
17195
17407
|
log2.info("using bundled provider", { providerID: model.providerID, pkg: model.api.npm });
|
|
17196
17408
|
const loaded = bundledFn({
|
|
@@ -17335,7 +17547,7 @@ var Provider;
|
|
|
17335
17547
|
});
|
|
17336
17548
|
}
|
|
17337
17549
|
}
|
|
17338
|
-
for (const [id, fn] of Object.entries(
|
|
17550
|
+
for (const [id, fn] of Object.entries(VendorRegistry.getModelProvider().getCustomLoaders())) {
|
|
17339
17551
|
const providerID = ProviderID.make(id);
|
|
17340
17552
|
if (disabled.has(providerID)) continue;
|
|
17341
17553
|
const data = database[providerID];
|
|
@@ -17698,8 +17910,8 @@ IMPORTANT: The following identifiers already exist and must NOT be used: ${exist
|
|
|
17698
17910
|
if (defaultModel.providerID === "openai" && (await Auth.get(defaultModel.providerID))?.type === "oauth") {
|
|
17699
17911
|
const result2 = streamObject({
|
|
17700
17912
|
...params,
|
|
17701
|
-
providerOptions:
|
|
17702
|
-
instructions: SystemPrompt.instructions(),
|
|
17913
|
+
providerOptions: VendorRegistry.getModelProvider({ model }).wrapProviderOptions({
|
|
17914
|
+
instructions: SystemPrompt.instructions(model),
|
|
17703
17915
|
store: false
|
|
17704
17916
|
}),
|
|
17705
17917
|
onError: () => {
|