anycodex 0.0.3 → 0.0.4
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/bin.js +21 -9
- package/package.json +3 -60
- package/src/bin.ts +663 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +12 -0
- package/dist/app/assets/abap-BdImnpbu.js +0 -1
- package/dist/app/assets/actionscript-3-CoDkCxhg.js +0 -1
- package/dist/app/assets/ada-bCR0ucgS.js +0 -1
- package/dist/app/assets/andromeeda-C4gqWexZ.js +0 -1
- package/dist/app/assets/angular-html-DA-rfuFy.js +0 -1
- package/dist/app/assets/angular-ts-BrjP3tb8.js +0 -1
- package/dist/app/assets/apache-Pmp26Uib.js +0 -1
- package/dist/app/assets/apex-D8_7TLub.js +0 -1
- package/dist/app/assets/apl-CORt7UWP.js +0 -1
- package/dist/app/assets/applescript-Co6uUVPk.js +0 -1
- package/dist/app/assets/ara-BRHolxvo.js +0 -1
- package/dist/app/assets/asciidoc-Ve4PFQV2.js +0 -1
- package/dist/app/assets/asm-D_Q5rh1f.js +0 -1
- package/dist/app/assets/astro-HNnZUWAn.js +0 -1
- package/dist/app/assets/aurora-x-D-2ljcwZ.js +0 -1
- package/dist/app/assets/awk-DMzUqQB5.js +0 -1
- package/dist/app/assets/ayu-dark-DYE7WIF3.js +0 -1
- package/dist/app/assets/ayu-light-BA47KaF1.js +0 -1
- package/dist/app/assets/ayu-mirage-32ctXXKs.js +0 -1
- package/dist/app/assets/ballerina-BFfxhgS-.js +0 -1
- package/dist/app/assets/bat-BkioyH1T.js +0 -1
- package/dist/app/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/app/assets/berry-uYugtg8r.js +0 -1
- package/dist/app/assets/bibtex-CHM0blh-.js +0 -1
- package/dist/app/assets/bicep-Bmn6On1c.js +0 -1
- package/dist/app/assets/bird2-BIv1doCn.js +0 -1
- package/dist/app/assets/blade-BjGOyj-B.js +0 -1
- package/dist/app/assets/bsl-BO_Y6i37.js +0 -1
- package/dist/app/assets/c-BIGW1oBm.js +0 -1
- package/dist/app/assets/c3-eo99z4R2.js +0 -1
- package/dist/app/assets/cadence-Bv_4Rxtq.js +0 -1
- package/dist/app/assets/cairo-KRGpt6FW.js +0 -1
- package/dist/app/assets/catppuccin-frappe-DFWUc33u.js +0 -1
- package/dist/app/assets/catppuccin-latte-C9dUb6Cb.js +0 -1
- package/dist/app/assets/catppuccin-macchiato-DQyhUUbL.js +0 -1
- package/dist/app/assets/catppuccin-mocha-D87Tk5Gz.js +0 -1
- package/dist/app/assets/clarity-D53aC0YG.js +0 -1
- package/dist/app/assets/clojure-P80f7IUj.js +0 -1
- package/dist/app/assets/cmake-D1j8_8rp.js +0 -1
- package/dist/app/assets/cobol-nBiQ_Alo.js +0 -1
- package/dist/app/assets/codeowners-Bp6g37R7.js +0 -1
- package/dist/app/assets/codeql-DsOJ9woJ.js +0 -1
- package/dist/app/assets/coffee-Ch7k5sss.js +0 -1
- package/dist/app/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/dist/app/assets/coq-DkFqJrB1.js +0 -1
- package/dist/app/assets/cpp-CofmeUqb.js +0 -1
- package/dist/app/assets/crystal-DNxU26gB.js +0 -1
- package/dist/app/assets/csharp-COcwbKMJ.js +0 -1
- package/dist/app/assets/css-CLj8gQPS.js +0 -1
- package/dist/app/assets/csv-fuZLfV_i.js +0 -1
- package/dist/app/assets/cue-D82EKSYY.js +0 -1
- package/dist/app/assets/cypher-COkxafJQ.js +0 -1
- package/dist/app/assets/d-85-TOEBH.js +0 -1
- package/dist/app/assets/dark-plus-C3mMm8J8.js +0 -1
- package/dist/app/assets/dart-bE4Kk8sk.js +0 -1
- package/dist/app/assets/dax-CEL-wOlO.js +0 -1
- package/dist/app/assets/desktop-BmXAJ9_W.js +0 -1
- package/dist/app/assets/diff-D97Zzqfu.js +0 -1
- package/dist/app/assets/docker-BcOcwvcX.js +0 -1
- package/dist/app/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/app/assets/dracula-BzJJZx-M.js +0 -1
- package/dist/app/assets/dracula-soft-BXkSAIEj.js +0 -1
- package/dist/app/assets/dream-maker-BtqSS_iP.js +0 -1
- package/dist/app/assets/edge-FbVlp4U3.js +0 -1
- package/dist/app/assets/elixir-CkH2-t6x.js +0 -1
- package/dist/app/assets/elm-DbKCFpqz.js +0 -1
- package/dist/app/assets/emacs-lisp-CXvaQtF9.js +0 -1
- package/dist/app/assets/erb-BYCe7drp.js +0 -1
- package/dist/app/assets/erlang-DsQrWhSR.js +0 -1
- package/dist/app/assets/everforest-dark-BgDCqdQA.js +0 -1
- package/dist/app/assets/everforest-light-C8M2exoo.js +0 -1
- package/dist/app/assets/fennel-BYunw83y.js +0 -1
- package/dist/app/assets/fish-BvzEVeQv.js +0 -1
- package/dist/app/assets/fluent-C4IJs8-o.js +0 -1
- package/dist/app/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/dist/app/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/dist/app/assets/fsharp-CXgrBDvD.js +0 -1
- package/dist/app/assets/gdresource-BOOCDP_w.js +0 -1
- package/dist/app/assets/gdscript-C5YyOfLZ.js +0 -1
- package/dist/app/assets/gdshader-DkwncUOv.js +0 -1
- package/dist/app/assets/genie-D0YGMca9.js +0 -1
- package/dist/app/assets/gherkin-DyxjwDmM.js +0 -1
- package/dist/app/assets/git-commit-F4YmCXRG.js +0 -1
- package/dist/app/assets/git-rebase-r7XF79zn.js +0 -1
- package/dist/app/assets/github-dark-DHJKELXO.js +0 -1
- package/dist/app/assets/github-dark-default-Cuk6v7N8.js +0 -1
- package/dist/app/assets/github-dark-dimmed-DH5Ifo-i.js +0 -1
- package/dist/app/assets/github-dark-high-contrast-E3gJ1_iC.js +0 -1
- package/dist/app/assets/github-light-DAi9KRSo.js +0 -1
- package/dist/app/assets/github-light-default-D7oLnXFd.js +0 -1
- package/dist/app/assets/github-light-high-contrast-BfjtVDDH.js +0 -1
- package/dist/app/assets/gleam-BspZqrRM.js +0 -1
- package/dist/app/assets/glimmer-js-ByusRIyA.js +0 -1
- package/dist/app/assets/glimmer-ts-BfAWNZQY.js +0 -1
- package/dist/app/assets/glsl-DplSGwfg.js +0 -1
- package/dist/app/assets/gn-n2N0HUVH.js +0 -1
- package/dist/app/assets/gnuplot-DdkO51Og.js +0 -1
- package/dist/app/assets/go-C27-OAKa.js +0 -1
- package/dist/app/assets/graphql-ChdNCCLP.js +0 -1
- package/dist/app/assets/groovy-gcz8RCvz.js +0 -1
- package/dist/app/assets/gruvbox-dark-hard-CFHQjOhq.js +0 -1
- package/dist/app/assets/gruvbox-dark-medium-GsRaNv29.js +0 -1
- package/dist/app/assets/gruvbox-dark-soft-CVdnzihN.js +0 -1
- package/dist/app/assets/gruvbox-light-hard-CH1njM8p.js +0 -1
- package/dist/app/assets/gruvbox-light-medium-DRw_LuNl.js +0 -1
- package/dist/app/assets/gruvbox-light-soft-hJgmCMqR.js +0 -1
- package/dist/app/assets/hack-i7_Ulhet.js +0 -1
- package/dist/app/assets/haml-D5jkg6IW.js +0 -1
- package/dist/app/assets/handlebars-BpdQsYii.js +0 -1
- package/dist/app/assets/haskell-Df6bDoY_.js +0 -1
- package/dist/app/assets/haxe-CzTSHFRz.js +0 -1
- package/dist/app/assets/hcl-BWvSN4gD.js +0 -1
- package/dist/app/assets/hjson-D5-asLiD.js +0 -1
- package/dist/app/assets/hlsl-D3lLCCz7.js +0 -1
- package/dist/app/assets/horizon-BUw7H-hv.js +0 -1
- package/dist/app/assets/horizon-bright-CUuTKBJd.js +0 -1
- package/dist/app/assets/houston-DnULxvSX.js +0 -1
- package/dist/app/assets/html-derivative-DlHx6ybY.js +0 -1
- package/dist/app/assets/html-pp8916En.js +0 -1
- package/dist/app/assets/http-jrhK8wxY.js +0 -1
- package/dist/app/assets/hurl-irOxFIW8.js +0 -1
- package/dist/app/assets/hxml-Bvhsp5Yf.js +0 -1
- package/dist/app/assets/hy-DFXneXwc.js +0 -1
- package/dist/app/assets/imba-DGztddWO.js +0 -1
- package/dist/app/assets/index-BBYiZjoU.js +0 -238
- package/dist/app/assets/index-DU8KNBjo.css +0 -32
- package/dist/app/assets/ini-BEwlwnbL.js +0 -1
- package/dist/app/assets/java-CylS5w8V.js +0 -1
- package/dist/app/assets/javascript-wDzz0qaB.js +0 -1
- package/dist/app/assets/jinja-f2NsQr07.js +0 -1
- package/dist/app/assets/jison-wvAkD_A8.js +0 -1
- package/dist/app/assets/json-Cp-IABpG.js +0 -1
- package/dist/app/assets/json5-C9tS-k6U.js +0 -1
- package/dist/app/assets/jsonc-Des-eS-w.js +0 -1
- package/dist/app/assets/jsonl-DcaNXYhu.js +0 -1
- package/dist/app/assets/jsonnet-DFQXde-d.js +0 -1
- package/dist/app/assets/jssm-C2t-YnRu.js +0 -1
- package/dist/app/assets/jsx-g9-lgVsj.js +0 -1
- package/dist/app/assets/julia-CxzCAyBv.js +0 -1
- package/dist/app/assets/just-VxiPbLrw.js +0 -1
- package/dist/app/assets/kanagawa-dragon-CkXjmgJE.js +0 -1
- package/dist/app/assets/kanagawa-lotus-CfQXZHmo.js +0 -1
- package/dist/app/assets/kanagawa-wave-DWedfzmr.js +0 -1
- package/dist/app/assets/kdl-DV7GczEv.js +0 -1
- package/dist/app/assets/kotlin-BdnUsdx6.js +0 -1
- package/dist/app/assets/kusto-wEQ09or8.js +0 -1
- package/dist/app/assets/laserwave-DUszq2jm.js +0 -1
- package/dist/app/assets/latex-CWtU0Tv5.js +0 -1
- package/dist/app/assets/lean-BZvkOJ9d.js +0 -1
- package/dist/app/assets/less-B1dDrJ26.js +0 -1
- package/dist/app/assets/light-plus-B7mTdjB0.js +0 -1
- package/dist/app/assets/liquid-C0sCDyMI.js +0 -1
- package/dist/app/assets/llvm-DjAJT7YJ.js +0 -1
- package/dist/app/assets/log-2UxHyX5q.js +0 -1
- package/dist/app/assets/logo-BtOb2qkB.js +0 -1
- package/dist/app/assets/lua-BaeVxFsk.js +0 -1
- package/dist/app/assets/luau-C-HG3fhB.js +0 -1
- package/dist/app/assets/make-CHLpvVh8.js +0 -1
- package/dist/app/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/app/assets/marko-DjSrsDqO.js +0 -1
- package/dist/app/assets/material-theme-D5KoaKCx.js +0 -1
- package/dist/app/assets/material-theme-darker-BfHTSMKl.js +0 -1
- package/dist/app/assets/material-theme-lighter-B0m2ddpp.js +0 -1
- package/dist/app/assets/material-theme-ocean-CyktbL80.js +0 -1
- package/dist/app/assets/material-theme-palenight-Csfq5Kiy.js +0 -1
- package/dist/app/assets/matlab-D7o27uSR.js +0 -1
- package/dist/app/assets/mdc-DTYItulj.js +0 -1
- package/dist/app/assets/mdx-Cmh6b_Ma.js +0 -1
- package/dist/app/assets/mermaid-mWjccvbQ.js +0 -1
- package/dist/app/assets/min-dark-CafNBF8u.js +0 -1
- package/dist/app/assets/min-light-CTRr51gU.js +0 -1
- package/dist/app/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/app/assets/mojo-rZm6bMo-.js +0 -1
- package/dist/app/assets/monokai-D4h5O-jR.js +0 -1
- package/dist/app/assets/moonbit-_H4v1dQx.js +0 -1
- package/dist/app/assets/move-IF9eRakj.js +0 -1
- package/dist/app/assets/narrat-DRg8JJMk.js +0 -1
- package/dist/app/assets/nextflow-C-mBbutL.js +0 -1
- package/dist/app/assets/nextflow-groovy-vE_lwT2v.js +0 -1
- package/dist/app/assets/nginx-BpAMiNFr.js +0 -1
- package/dist/app/assets/night-owl-C39BiMTA.js +0 -1
- package/dist/app/assets/night-owl-light-CMTm3GFP.js +0 -1
- package/dist/app/assets/nim-BIad80T-.js +0 -1
- package/dist/app/assets/nix-CwoSXNpI.js +0 -1
- package/dist/app/assets/nord-Ddv68eIx.js +0 -1
- package/dist/app/assets/nushell-Cz2AlsmD.js +0 -1
- package/dist/app/assets/objective-c-DXmwc3jG.js +0 -1
- package/dist/app/assets/objective-cpp-CLxacb5B.js +0 -1
- package/dist/app/assets/ocaml-C0hk2d4L.js +0 -1
- package/dist/app/assets/odin-BBf5iR-q.js +0 -1
- package/dist/app/assets/one-dark-pro-DVMEJ2y_.js +0 -1
- package/dist/app/assets/one-light-C3Wv6jpd.js +0 -1
- package/dist/app/assets/openscad-C4EeE6gA.js +0 -1
- package/dist/app/assets/pascal-D93ZcfNL.js +0 -1
- package/dist/app/assets/perl-NvoQZIq0.js +0 -1
- package/dist/app/assets/php-R6g_5hLQ.js +0 -1
- package/dist/app/assets/pkl-u5AG7uiY.js +0 -1
- package/dist/app/assets/plastic-3e1v2bzS.js +0 -1
- package/dist/app/assets/plsql-ChMvpjG-.js +0 -1
- package/dist/app/assets/po-BTJTHyun.js +0 -1
- package/dist/app/assets/poimandres-CS3Unz2-.js +0 -1
- package/dist/app/assets/polar-C0HS_06l.js +0 -1
- package/dist/app/assets/postcss-CXtECtnM.js +0 -1
- package/dist/app/assets/powerquery-CEu0bR-o.js +0 -1
- package/dist/app/assets/powershell-Dpen1YoG.js +0 -1
- package/dist/app/assets/prisma-Dd19v3D-.js +0 -1
- package/dist/app/assets/prolog-CbFg5uaA.js +0 -1
- package/dist/app/assets/proto-C7zT0LnQ.js +0 -1
- package/dist/app/assets/pug-DKIMFp6K.js +0 -1
- package/dist/app/assets/puppet-BMWR74SV.js +0 -1
- package/dist/app/assets/purescript-CklMAg4u.js +0 -1
- package/dist/app/assets/python-B6aJPvgy.js +0 -1
- package/dist/app/assets/qml-3beO22l8.js +0 -1
- package/dist/app/assets/qmldir-C8lEn-DE.js +0 -1
- package/dist/app/assets/qss-IeuSbFQv.js +0 -1
- package/dist/app/assets/r-Dspwwk_N.js +0 -1
- package/dist/app/assets/racket-BqYA7rlc.js +0 -1
- package/dist/app/assets/raku-DXvB9xmW.js +0 -1
- package/dist/app/assets/razor-BDqjjVU7.js +0 -1
- package/dist/app/assets/red-bN70gL4F.js +0 -1
- package/dist/app/assets/reg-C-SQnVFl.js +0 -1
- package/dist/app/assets/regexp-CDVJQ6XC.js +0 -1
- package/dist/app/assets/rel-C3B-1QV4.js +0 -1
- package/dist/app/assets/riscv-BM1_JUlF.js +0 -1
- package/dist/app/assets/ron-D8l8udqQ.js +0 -1
- package/dist/app/assets/rose-pine-dawn-DHQR4-dF.js +0 -1
- package/dist/app/assets/rose-pine-moon-D4_iv3hh.js +0 -1
- package/dist/app/assets/rose-pine-qdsjHGoJ.js +0 -1
- package/dist/app/assets/rosmsg-BJDFO7_C.js +0 -1
- package/dist/app/assets/rst-CRjBmOyv.js +0 -1
- package/dist/app/assets/ruby-Wjq7vjNf.js +0 -1
- package/dist/app/assets/rust-B1yitclQ.js +0 -1
- package/dist/app/assets/sas-cz2c8ADy.js +0 -1
- package/dist/app/assets/sass-Cj5Yp3dK.js +0 -1
- package/dist/app/assets/scala-C151Ov-r.js +0 -1
- package/dist/app/assets/scheme-C98Dy4si.js +0 -1
- package/dist/app/assets/scss-D5BDwBP9.js +0 -1
- package/dist/app/assets/sdbl-DVxCFoDh.js +0 -1
- package/dist/app/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/dist/app/assets/shellscript-Yzrsuije.js +0 -1
- package/dist/app/assets/shellsession-BADoaaVG.js +0 -1
- package/dist/app/assets/slack-dark-BthQWCQV.js +0 -1
- package/dist/app/assets/slack-ochin-DqwNpetd.js +0 -1
- package/dist/app/assets/smalltalk-BERRCDM3.js +0 -1
- package/dist/app/assets/snazzy-light-Bw305WKR.js +0 -1
- package/dist/app/assets/solarized-dark-DXbdFlpD.js +0 -1
- package/dist/app/assets/solarized-light-L9t79GZl.js +0 -1
- package/dist/app/assets/solidity-rGO070M0.js +0 -1
- package/dist/app/assets/soy-8wufbnw4.js +0 -1
- package/dist/app/assets/sparql-rVzFXLq3.js +0 -1
- package/dist/app/assets/splunk-BtCnVYZw.js +0 -1
- package/dist/app/assets/sql-BLtJtn59.js +0 -1
- package/dist/app/assets/ssh-config-_ykCGR6B.js +0 -1
- package/dist/app/assets/stata-BH5u7GGu.js +0 -1
- package/dist/app/assets/stylus-BEDo0Tqx.js +0 -1
- package/dist/app/assets/surrealql-Bq5Q-fJD.js +0 -1
- package/dist/app/assets/svelte-Cy7k_4gC.js +0 -1
- package/dist/app/assets/swift-D82vCrfD.js +0 -1
- package/dist/app/assets/synthwave-84-CbfX1IO0.js +0 -1
- package/dist/app/assets/system-verilog-CnnmHF94.js +0 -1
- package/dist/app/assets/systemd-4A_iFExJ.js +0 -1
- package/dist/app/assets/talonscript-CkByrt1z.js +0 -1
- package/dist/app/assets/tasl-QIJgUcNo.js +0 -1
- package/dist/app/assets/tcl-dwOrl1Do.js +0 -1
- package/dist/app/assets/templ-DhtptRzy.js +0 -1
- package/dist/app/assets/terraform-BETggiCN.js +0 -1
- package/dist/app/assets/tex-idrVyKtj.js +0 -1
- package/dist/app/assets/tokyo-night-hegEt444.js +0 -1
- package/dist/app/assets/toml-vGWfd6FD.js +0 -1
- package/dist/app/assets/ts-tags-DQrlYJgV.js +0 -1
- package/dist/app/assets/tsv-B_m7g4N7.js +0 -1
- package/dist/app/assets/tsx-COt5Ahok.js +0 -1
- package/dist/app/assets/turtle-BsS91CYL.js +0 -1
- package/dist/app/assets/twig-xg9kU7Mw.js +0 -1
- package/dist/app/assets/typescript-BPQ3VLAy.js +0 -1
- package/dist/app/assets/typespec-CAFt9gP4.js +0 -1
- package/dist/app/assets/typst-DHCkPAjA.js +0 -1
- package/dist/app/assets/v-BcVCzyr7.js +0 -1
- package/dist/app/assets/vala-CsfeWuGM.js +0 -1
- package/dist/app/assets/vb-D17OF-Vu.js +0 -1
- package/dist/app/assets/verilog-BQ8w6xss.js +0 -1
- package/dist/app/assets/vesper-DU1UobuO.js +0 -1
- package/dist/app/assets/vhdl-CeAyd5Ju.js +0 -1
- package/dist/app/assets/viml-CJc9bBzg.js +0 -1
- package/dist/app/assets/vitesse-black-Bkuqu6BP.js +0 -1
- package/dist/app/assets/vitesse-dark-D0r3Knsf.js +0 -1
- package/dist/app/assets/vitesse-light-CVO1_9PV.js +0 -1
- package/dist/app/assets/vue-D2xRrEX4.js +0 -1
- package/dist/app/assets/vue-html-AaS7Mt5G.js +0 -1
- package/dist/app/assets/vue-vine-BoDAl6tE.js +0 -1
- package/dist/app/assets/vyper-CDx5xZoG.js +0 -1
- package/dist/app/assets/wasm-CG6Dc4jp.js +0 -1
- package/dist/app/assets/wasm-MzD3tlZU.js +0 -1
- package/dist/app/assets/wenyan-BV7otONQ.js +0 -1
- package/dist/app/assets/wgsl-Dx-B1_4e.js +0 -1
- package/dist/app/assets/wikitext-BhOHFoWU.js +0 -1
- package/dist/app/assets/wit-5i3qLPDT.js +0 -1
- package/dist/app/assets/wolfram-lXgVvXCa.js +0 -1
- package/dist/app/assets/xml-sdJ4AIDG.js +0 -1
- package/dist/app/assets/xsl-CtQFsRM5.js +0 -1
- package/dist/app/assets/yaml-Buea-lGh.js +0 -1
- package/dist/app/assets/zenscript-DVFEvuxE.js +0 -1
- package/dist/app/assets/zig-VOosw3JB.js +0 -1
- package/dist/app/index.html +0 -13
- package/dist/chunk-6DDCZPRP.js +0 -1474
- package/dist/chunk-HULFFF7R.js +0 -25
- package/dist/chunk-KB4MYP36.js +0 -8
- package/dist/chunk-P23NZBHE.js +0 -5130
- package/dist/chunk-TDYQG5PB.js +0 -1621
- package/dist/chunk-XU2SE4LZ.js +0 -3864
- package/dist/chunk-XXVDY7BO.js +0 -53
- package/dist/chunk-ZXPWUU3S.js +0 -110
- package/dist/dist-GBG4FGPZ.js +0 -1806
- package/dist/dist-XGPL3ARQ.js +0 -94
- package/dist/glob-RMMK6FVW-M34I5XTP.js +0 -8
- package/dist/registry-VQVHAEPP-MGYPDXYJ.js +0 -13
- package/dist/schema-SOLWPA3E-CEUVS57H.js +0 -13
- package/dist/session-Q7S3ITUV-CECGQJC5.js +0 -18
- package/dist/storage-YSEEBFV7-N75L4HBF.js +0 -28
package/src/bin.ts
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import { execSync, spawnSync } from "child_process";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import os from "os";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import readline from "readline";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const PROCESS_NAME = "anycode-server";
|
|
11
|
+
const ANYCODE_DIR = path.join(os.homedir(), ".anycode");
|
|
12
|
+
const SETTINGS_PATH = path.join(ANYCODE_DIR, "settings.json");
|
|
13
|
+
const DEFAULT_PORT = 3210;
|
|
14
|
+
|
|
15
|
+
// ── Colors ────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
const c = {
|
|
18
|
+
reset: "\x1b[0m",
|
|
19
|
+
bold: "\x1b[1m",
|
|
20
|
+
dim: "\x1b[2m",
|
|
21
|
+
italic: "\x1b[3m",
|
|
22
|
+
cyan: "\x1b[36m",
|
|
23
|
+
green: "\x1b[32m",
|
|
24
|
+
yellow: "\x1b[33m",
|
|
25
|
+
red: "\x1b[31m",
|
|
26
|
+
magenta: "\x1b[35m",
|
|
27
|
+
blue: "\x1b[34m",
|
|
28
|
+
white: "\x1b[37m",
|
|
29
|
+
gray: "\x1b[90m",
|
|
30
|
+
bgGreen: "\x1b[42m",
|
|
31
|
+
bgRed: "\x1b[41m",
|
|
32
|
+
bgCyan: "\x1b[46m",
|
|
33
|
+
bgBlue: "\x1b[44m",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// ── UI Helpers ────────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
const LOGO = `
|
|
39
|
+
${c.cyan}${c.bold} ╔══════════════════════════════════╗
|
|
40
|
+
║${c.reset}${c.white}${c.bold} ◆ AnyCode ${c.cyan}${c.bold}║
|
|
41
|
+
╚══════════════════════════════════╝${c.reset}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
function banner() {
|
|
45
|
+
console.log(LOGO);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function info(msg: string) {
|
|
49
|
+
console.log(` ${c.cyan}▸${c.reset} ${msg}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function success(msg: string) {
|
|
53
|
+
console.log(` ${c.green}✔${c.reset} ${msg}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function warn(msg: string) {
|
|
57
|
+
console.log(` ${c.yellow}!${c.reset} ${msg}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function fail(msg: string) {
|
|
61
|
+
console.error(` ${c.red}✖${c.reset} ${msg}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function step(label: string) {
|
|
65
|
+
console.log(` ${c.gray}─${c.reset} ${label}${c.gray}...${c.reset}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function blank() {
|
|
69
|
+
console.log();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function divider() {
|
|
73
|
+
console.log(` ${c.gray}${"─".repeat(44)}${c.reset}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function keyValue(key: string, value: string, pad = 12) {
|
|
77
|
+
console.log(` ${c.white}${key.padEnd(pad)}${c.reset} ${c.gray}│${c.reset} ${value}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Settings ──────────────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
interface Settings {
|
|
83
|
+
API_KEY?: string;
|
|
84
|
+
MODEL?: string;
|
|
85
|
+
BASE_URL?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function loadSettings(): Settings {
|
|
89
|
+
try {
|
|
90
|
+
fs.mkdirSync(ANYCODE_DIR, { recursive: true });
|
|
91
|
+
const raw = fs.readFileSync(SETTINGS_PATH, "utf-8");
|
|
92
|
+
return JSON.parse(raw);
|
|
93
|
+
} catch {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function saveSettings(settings: Settings) {
|
|
99
|
+
fs.mkdirSync(ANYCODE_DIR, { recursive: true });
|
|
100
|
+
fs.writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2) + "\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function prompt(question: string): Promise<string> {
|
|
104
|
+
const rl = readline.createInterface({
|
|
105
|
+
input: process.stdin,
|
|
106
|
+
output: process.stdout,
|
|
107
|
+
});
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
rl.question(question, (answer) => {
|
|
110
|
+
rl.close();
|
|
111
|
+
resolve(answer.trim());
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function ensureSettings(): Promise<Settings> {
|
|
117
|
+
const settings = loadSettings();
|
|
118
|
+
let changed = false;
|
|
119
|
+
|
|
120
|
+
if (!settings.API_KEY) {
|
|
121
|
+
blank();
|
|
122
|
+
console.log(` ${c.bold}${c.white}Welcome! Let's configure your LLM provider.${c.reset}`);
|
|
123
|
+
blank();
|
|
124
|
+
divider();
|
|
125
|
+
blank();
|
|
126
|
+
settings.API_KEY = await prompt(` ${c.cyan}?${c.reset} ${c.bold}API Key${c.reset} ${c.gray}(required)${c.reset}: `);
|
|
127
|
+
if (!settings.API_KEY) {
|
|
128
|
+
fail("API Key is required to continue.");
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
changed = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!settings.MODEL) {
|
|
135
|
+
const val = await prompt(` ${c.cyan}?${c.reset} ${c.bold}Model${c.reset} ${c.gray}(claude-opus-4-6)${c.reset}: `);
|
|
136
|
+
settings.MODEL = val || "claude-opus-4-6";
|
|
137
|
+
changed = true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (settings.BASE_URL === undefined) {
|
|
141
|
+
const val = await prompt(` ${c.cyan}?${c.reset} ${c.bold}Base URL${c.reset} ${c.gray}(optional, Enter to skip)${c.reset}: `);
|
|
142
|
+
settings.BASE_URL = val || undefined;
|
|
143
|
+
changed = true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (changed) {
|
|
147
|
+
saveSettings(settings);
|
|
148
|
+
blank();
|
|
149
|
+
divider();
|
|
150
|
+
blank();
|
|
151
|
+
success("Configuration saved!");
|
|
152
|
+
blank();
|
|
153
|
+
console.log(` ${c.gray}Config file: ${c.yellow}${SETTINGS_PATH}${c.reset}`);
|
|
154
|
+
console.log(` ${c.gray}Edit anytime: ${c.green}anycode config${c.reset}`);
|
|
155
|
+
blank();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return settings;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ── PM2 Helpers ───────────────────────────────────────────────────────────
|
|
162
|
+
|
|
163
|
+
function hasPm2(): boolean {
|
|
164
|
+
try {
|
|
165
|
+
execSync("pm2 --version", { stdio: "ignore" });
|
|
166
|
+
return true;
|
|
167
|
+
} catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function ensurePm2() {
|
|
173
|
+
if (hasPm2()) return;
|
|
174
|
+
step("Installing pm2");
|
|
175
|
+
try {
|
|
176
|
+
execSync("npm install -g pm2", { stdio: "pipe" });
|
|
177
|
+
} catch {
|
|
178
|
+
fail("Failed to install pm2.");
|
|
179
|
+
console.log(` ${c.gray}Try manually: ${c.white}npm install -g pm2${c.reset}`);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
if (!hasPm2()) {
|
|
183
|
+
fail("pm2 installed but not found in PATH.");
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
success("pm2 installed.");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function pm2Silent(args: string) {
|
|
190
|
+
return spawnSync("pm2", args.split(" "), {
|
|
191
|
+
stdio: "pipe",
|
|
192
|
+
shell: true,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function getPm2Process(): any | null {
|
|
197
|
+
const list = pm2Silent("jlist");
|
|
198
|
+
if (!list.stdout) return null;
|
|
199
|
+
try {
|
|
200
|
+
const processes = JSON.parse(list.stdout.toString());
|
|
201
|
+
return processes.find((p: any) => p.name === PROCESS_NAME) ?? null;
|
|
202
|
+
} catch {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ── Resolve server entry ──────────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
function getServerScript(): string {
|
|
210
|
+
try {
|
|
211
|
+
const serverPkg = path.dirname(
|
|
212
|
+
fileURLToPath(import.meta.resolve("@any-code/server/package.json"))
|
|
213
|
+
);
|
|
214
|
+
return path.join(serverPkg, "dist", "cli.js");
|
|
215
|
+
} catch {
|
|
216
|
+
const fallback = path.resolve(__dirname, "../../server/dist/cli.js");
|
|
217
|
+
return fallback;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function writeEcosystem(script: string): string {
|
|
222
|
+
const ecosystemPath = path.join(ANYCODE_DIR, "ecosystem.config.cjs");
|
|
223
|
+
const content = `module.exports = {
|
|
224
|
+
apps: [{
|
|
225
|
+
name: ${JSON.stringify(PROCESS_NAME)},
|
|
226
|
+
script: ${JSON.stringify(script)},
|
|
227
|
+
interpreter: "node"
|
|
228
|
+
}]
|
|
229
|
+
};
|
|
230
|
+
`;
|
|
231
|
+
fs.mkdirSync(ANYCODE_DIR, { recursive: true });
|
|
232
|
+
fs.writeFileSync(ecosystemPath, content);
|
|
233
|
+
return ecosystemPath;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function getLocalIP(): string {
|
|
237
|
+
const interfaces = os.networkInterfaces();
|
|
238
|
+
for (const devName in interfaces) {
|
|
239
|
+
for (const iface of interfaces[devName] ?? []) {
|
|
240
|
+
if (iface.family === "IPv4" && !iface.internal) {
|
|
241
|
+
return iface.address;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return "localhost";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function showAccessInfo(settings: Settings) {
|
|
249
|
+
const port = DEFAULT_PORT;
|
|
250
|
+
const ip = getLocalIP();
|
|
251
|
+
|
|
252
|
+
blank();
|
|
253
|
+
console.log(` ${c.bold}${c.green}Server is running!${c.reset}`);
|
|
254
|
+
blank();
|
|
255
|
+
divider();
|
|
256
|
+
blank();
|
|
257
|
+
keyValue("Local", `${c.cyan}${c.bold}http://localhost:${port}${c.reset}`);
|
|
258
|
+
keyValue("Network", `${c.cyan}http://${ip}:${port}${c.reset}`);
|
|
259
|
+
keyValue("Model", `${c.yellow}${settings.MODEL}${c.reset}`);
|
|
260
|
+
blank();
|
|
261
|
+
divider();
|
|
262
|
+
blank();
|
|
263
|
+
console.log(` ${c.gray}Logs${c.reset} ${c.white}anycode logs${c.reset}`);
|
|
264
|
+
console.log(` ${c.gray}Stop${c.reset} ${c.white}anycode stop${c.reset}`);
|
|
265
|
+
console.log(` ${c.gray}Restart${c.reset} ${c.white}anycode restart${c.reset}`);
|
|
266
|
+
blank();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ── Commands ──────────────────────────────────────────────────────────────
|
|
270
|
+
|
|
271
|
+
async function cmdServer() {
|
|
272
|
+
banner();
|
|
273
|
+
await ensureSettings();
|
|
274
|
+
|
|
275
|
+
const script = getServerScript();
|
|
276
|
+
info("Starting server in foreground...");
|
|
277
|
+
blank();
|
|
278
|
+
await import(script);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async function cmdStart() {
|
|
282
|
+
banner();
|
|
283
|
+
|
|
284
|
+
const settings = await ensureSettings();
|
|
285
|
+
|
|
286
|
+
step("Checking pm2");
|
|
287
|
+
ensurePm2();
|
|
288
|
+
|
|
289
|
+
const script = getServerScript();
|
|
290
|
+
const ecosystemPath = writeEcosystem(script);
|
|
291
|
+
|
|
292
|
+
// Register pm2 startup (silent)
|
|
293
|
+
step("Registering auto-start on boot");
|
|
294
|
+
pm2Silent("startup");
|
|
295
|
+
|
|
296
|
+
// Check if already running
|
|
297
|
+
const existing = getPm2Process();
|
|
298
|
+
if (existing) {
|
|
299
|
+
step("Restarting server");
|
|
300
|
+
pm2Silent(`delete ${PROCESS_NAME}`);
|
|
301
|
+
} else {
|
|
302
|
+
step("Starting server");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const result = pm2Silent(`start ${ecosystemPath}`);
|
|
306
|
+
pm2Silent("save");
|
|
307
|
+
|
|
308
|
+
// Check if actually started
|
|
309
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
310
|
+
const proc = getPm2Process();
|
|
311
|
+
if (proc && proc.pm2_env?.status === "online") {
|
|
312
|
+
showAccessInfo(settings);
|
|
313
|
+
} else {
|
|
314
|
+
fail("Server failed to start.");
|
|
315
|
+
blank();
|
|
316
|
+
console.log(` ${c.gray}Check logs: ${c.white}anycode logs${c.reset}`);
|
|
317
|
+
blank();
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function cmdStop() {
|
|
323
|
+
banner();
|
|
324
|
+
ensurePm2();
|
|
325
|
+
|
|
326
|
+
const proc = getPm2Process();
|
|
327
|
+
if (!proc) {
|
|
328
|
+
warn("Server is not running.");
|
|
329
|
+
blank();
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
step("Stopping server");
|
|
334
|
+
pm2Silent(`stop ${PROCESS_NAME}`);
|
|
335
|
+
pm2Silent("save");
|
|
336
|
+
|
|
337
|
+
success("Server stopped.");
|
|
338
|
+
blank();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function cmdRestart() {
|
|
342
|
+
banner();
|
|
343
|
+
ensurePm2();
|
|
344
|
+
|
|
345
|
+
const proc = getPm2Process();
|
|
346
|
+
if (!proc) {
|
|
347
|
+
warn("Server is not running. Use ${c.white}anycode start${c.reset} instead.");
|
|
348
|
+
blank();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
step("Restarting server");
|
|
353
|
+
pm2Silent(`restart ${PROCESS_NAME}`);
|
|
354
|
+
pm2Silent("save");
|
|
355
|
+
|
|
356
|
+
// Check status
|
|
357
|
+
setTimeout(() => {
|
|
358
|
+
const updated = getPm2Process();
|
|
359
|
+
if (updated && updated.pm2_env?.status === "online") {
|
|
360
|
+
success("Server restarted.");
|
|
361
|
+
} else {
|
|
362
|
+
fail("Server failed to restart.");
|
|
363
|
+
console.log(` ${c.gray}Check logs: ${c.white}anycode logs${c.reset}`);
|
|
364
|
+
}
|
|
365
|
+
blank();
|
|
366
|
+
}, 1500);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function cmdStatus() {
|
|
370
|
+
banner();
|
|
371
|
+
ensurePm2();
|
|
372
|
+
|
|
373
|
+
const proc = getPm2Process();
|
|
374
|
+
if (!proc) {
|
|
375
|
+
keyValue("Status", `${c.gray}not running${c.reset}`);
|
|
376
|
+
blank();
|
|
377
|
+
console.log(` ${c.gray}Run ${c.white}anycode start${c.gray} to launch.${c.reset}`);
|
|
378
|
+
blank();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const status = proc.pm2_env?.status ?? "unknown";
|
|
383
|
+
const statusColor = status === "online" ? c.green : status === "stopped" ? c.red : c.yellow;
|
|
384
|
+
const pid = proc.pid ?? "-";
|
|
385
|
+
const uptime = proc.pm2_env?.pm_uptime
|
|
386
|
+
? formatUptime(Date.now() - proc.pm2_env.pm_uptime)
|
|
387
|
+
: "-";
|
|
388
|
+
const restarts = proc.pm2_env?.restart_time ?? 0;
|
|
389
|
+
const memory = proc.monit?.memory
|
|
390
|
+
? `${Math.round(proc.monit.memory / 1024 / 1024)} MB`
|
|
391
|
+
: "-";
|
|
392
|
+
const cpu = proc.monit?.cpu !== undefined ? `${proc.monit.cpu}%` : "-";
|
|
393
|
+
|
|
394
|
+
blank();
|
|
395
|
+
keyValue("Status", `${statusColor}${c.bold}${status}${c.reset}`);
|
|
396
|
+
keyValue("PID", `${c.white}${pid}${c.reset}`);
|
|
397
|
+
keyValue("Uptime", `${c.white}${uptime}${c.reset}`);
|
|
398
|
+
keyValue("Restarts", `${c.white}${restarts}${c.reset}`);
|
|
399
|
+
keyValue("Memory", `${c.white}${memory}${c.reset}`);
|
|
400
|
+
keyValue("CPU", `${c.white}${cpu}${c.reset}`);
|
|
401
|
+
blank();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function formatUptime(ms: number): string {
|
|
405
|
+
const s = Math.floor(ms / 1000);
|
|
406
|
+
if (s < 60) return `${s}s`;
|
|
407
|
+
const m = Math.floor(s / 60);
|
|
408
|
+
if (m < 60) return `${m}m ${s % 60}s`;
|
|
409
|
+
const h = Math.floor(m / 60);
|
|
410
|
+
if (h < 24) return `${h}h ${m % 60}m`;
|
|
411
|
+
const d = Math.floor(h / 24);
|
|
412
|
+
return `${d}d ${h % 24}h`;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function cmdLogs() {
|
|
416
|
+
ensurePm2();
|
|
417
|
+
|
|
418
|
+
const proc = getPm2Process();
|
|
419
|
+
if (!proc) {
|
|
420
|
+
banner();
|
|
421
|
+
warn("Server is not running.");
|
|
422
|
+
blank();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Logs are interactive, let pm2 handle output
|
|
427
|
+
spawnSync("pm2", ["logs", PROCESS_NAME, "--lines", "50"], {
|
|
428
|
+
stdio: "inherit",
|
|
429
|
+
shell: true,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function getMonorepoRoot(): string | null {
|
|
434
|
+
// __dirname is packages/cli/dist, monorepo root is 3 levels up
|
|
435
|
+
const candidate = path.resolve(__dirname, "../../..");
|
|
436
|
+
if (fs.existsSync(path.join(candidate, "pnpm-workspace.yaml"))) {
|
|
437
|
+
return candidate;
|
|
438
|
+
}
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async function cmdUpdate() {
|
|
443
|
+
banner();
|
|
444
|
+
|
|
445
|
+
const monorepoRoot = getMonorepoRoot();
|
|
446
|
+
|
|
447
|
+
if (monorepoRoot) {
|
|
448
|
+
// Development environment — build all packages in the monorepo
|
|
449
|
+
info(`Dev environment detected (${c.yellow}${monorepoRoot}${c.reset})`);
|
|
450
|
+
blank();
|
|
451
|
+
|
|
452
|
+
step("Building all packages");
|
|
453
|
+
try {
|
|
454
|
+
execSync("pnpm -r build", { cwd: monorepoRoot, stdio: "inherit" });
|
|
455
|
+
} catch {
|
|
456
|
+
fail("Build failed.");
|
|
457
|
+
process.exit(1);
|
|
458
|
+
}
|
|
459
|
+
success("All packages built.");
|
|
460
|
+
|
|
461
|
+
// Restart/start via pm2
|
|
462
|
+
ensurePm2();
|
|
463
|
+
const script = getServerScript();
|
|
464
|
+
const ecosystemPath = writeEcosystem(script);
|
|
465
|
+
const existing = hasPm2() ? getPm2Process() : null;
|
|
466
|
+
if (existing) {
|
|
467
|
+
step("Restarting server");
|
|
468
|
+
pm2Silent(`delete ${PROCESS_NAME}`);
|
|
469
|
+
} else {
|
|
470
|
+
step("Starting server");
|
|
471
|
+
}
|
|
472
|
+
pm2Silent(`start ${ecosystemPath}`);
|
|
473
|
+
pm2Silent("save");
|
|
474
|
+
|
|
475
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
476
|
+
const proc = getPm2Process();
|
|
477
|
+
if (proc && proc.pm2_env?.status === "online") {
|
|
478
|
+
const settings = loadSettings();
|
|
479
|
+
showAccessInfo(settings);
|
|
480
|
+
} else {
|
|
481
|
+
fail("Server failed to start.");
|
|
482
|
+
console.log(` ${c.gray}Check logs: ${c.white}anycode logs${c.reset}`);
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
// Production environment — update from npm
|
|
486
|
+
step("Updating anycodex");
|
|
487
|
+
try {
|
|
488
|
+
execSync("npm install -g anycodex@latest", { stdio: "pipe" });
|
|
489
|
+
} catch {
|
|
490
|
+
fail("Failed to update.");
|
|
491
|
+
console.log(` ${c.gray}Try manually: ${c.white}npm install -g anycodex@latest${c.reset}`);
|
|
492
|
+
process.exit(1);
|
|
493
|
+
}
|
|
494
|
+
success("Updated to latest version.");
|
|
495
|
+
|
|
496
|
+
// Restart if pm2 is running
|
|
497
|
+
if (hasPm2()) {
|
|
498
|
+
const existing = getPm2Process();
|
|
499
|
+
if (existing) {
|
|
500
|
+
step("Restarting server");
|
|
501
|
+
const script = getServerScript();
|
|
502
|
+
const ecosystemPath = writeEcosystem(script);
|
|
503
|
+
pm2Silent(`delete ${PROCESS_NAME}`);
|
|
504
|
+
pm2Silent(`start ${ecosystemPath}`);
|
|
505
|
+
pm2Silent("save");
|
|
506
|
+
success("Server restarted with new version.");
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
blank();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const CONFIG_KEYS = ["API_KEY", "MODEL", "BASE_URL"] as const;
|
|
515
|
+
|
|
516
|
+
function cmdConfig() {
|
|
517
|
+
banner();
|
|
518
|
+
|
|
519
|
+
const settings = loadSettings();
|
|
520
|
+
|
|
521
|
+
console.log(` ${c.gray}Config file:${c.reset} ${c.yellow}${SETTINGS_PATH}${c.reset}`);
|
|
522
|
+
blank();
|
|
523
|
+
divider();
|
|
524
|
+
blank();
|
|
525
|
+
|
|
526
|
+
let hasAny = false;
|
|
527
|
+
for (const key of CONFIG_KEYS) {
|
|
528
|
+
const value = settings[key];
|
|
529
|
+
if (value === undefined) {
|
|
530
|
+
keyValue(key, `${c.gray}(not set)${c.reset}`);
|
|
531
|
+
} else if (key === "API_KEY" && value.length > 8) {
|
|
532
|
+
const masked = value.slice(0, 4) + "····" + value.slice(-4);
|
|
533
|
+
keyValue(key, `${c.green}${masked}${c.reset}`);
|
|
534
|
+
hasAny = true;
|
|
535
|
+
} else {
|
|
536
|
+
keyValue(key, `${c.green}${value}${c.reset}`);
|
|
537
|
+
hasAny = true;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
blank();
|
|
542
|
+
|
|
543
|
+
if (!hasAny) {
|
|
544
|
+
console.log(` ${c.gray}Run ${c.green}anycode start${c.gray} to set up.${c.reset}`);
|
|
545
|
+
blank();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
async function cmdUninstall() {
|
|
550
|
+
banner();
|
|
551
|
+
|
|
552
|
+
// 1. Remove from pm2
|
|
553
|
+
if (hasPm2()) {
|
|
554
|
+
const proc = getPm2Process();
|
|
555
|
+
if (proc) {
|
|
556
|
+
step("Stopping and removing daemon");
|
|
557
|
+
pm2Silent(`delete ${PROCESS_NAME}`);
|
|
558
|
+
pm2Silent("save");
|
|
559
|
+
success("Daemon removed.");
|
|
560
|
+
} else {
|
|
561
|
+
info("No daemon running.");
|
|
562
|
+
}
|
|
563
|
+
} else {
|
|
564
|
+
info("No daemon running.");
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// 2. Ask about config
|
|
568
|
+
blank();
|
|
569
|
+
const removeConfig = await prompt(` ${c.yellow}?${c.reset} ${c.bold}Remove config directory?${c.reset} ${c.gray}(${c.yellow}~/.anycode${c.gray})${c.reset} ${c.gray}(y/N)${c.reset}: `);
|
|
570
|
+
if (removeConfig.toLowerCase() === "y") {
|
|
571
|
+
step("Removing config directory");
|
|
572
|
+
try {
|
|
573
|
+
fs.rmSync(ANYCODE_DIR, { recursive: true, force: true });
|
|
574
|
+
success(`Removed ${ANYCODE_DIR}`);
|
|
575
|
+
} catch {
|
|
576
|
+
warn(`Could not remove ${ANYCODE_DIR}, please delete manually.`);
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
info(`Config preserved at ${c.yellow}${ANYCODE_DIR}${c.reset}`);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
blank();
|
|
583
|
+
success("Done.");
|
|
584
|
+
blank();
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function showHelp() {
|
|
588
|
+
banner();
|
|
589
|
+
|
|
590
|
+
console.log(` ${c.bold}${c.white}Usage:${c.reset} ${c.cyan}anycode${c.reset} ${c.gray}<command>${c.reset}`);
|
|
591
|
+
blank();
|
|
592
|
+
divider();
|
|
593
|
+
blank();
|
|
594
|
+
|
|
595
|
+
const commands = [
|
|
596
|
+
["start", "Start server as a background daemon"],
|
|
597
|
+
["stop", "Stop the server"],
|
|
598
|
+
["restart", "Restart the server"],
|
|
599
|
+
["server", "Run server in foreground (blocking)"],
|
|
600
|
+
["status", "Show server status"],
|
|
601
|
+
["logs", "Stream server logs"],
|
|
602
|
+
["config", "View current configuration"],
|
|
603
|
+
["update", "Update to latest version"],
|
|
604
|
+
["uninstall","Stop daemon and clean up"],
|
|
605
|
+
];
|
|
606
|
+
|
|
607
|
+
for (const [cmd, desc] of commands) {
|
|
608
|
+
console.log(` ${c.green}${cmd.padEnd(12)}${c.reset}${c.gray}${desc}${c.reset}`);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
blank();
|
|
612
|
+
divider();
|
|
613
|
+
blank();
|
|
614
|
+
console.log(` ${c.gray}Config:${c.reset} ${c.yellow}~/.anycode/settings.json${c.reset}`);
|
|
615
|
+
blank();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// ── Main ──────────────────────────────────────────────────────────────────
|
|
619
|
+
|
|
620
|
+
const args = process.argv.slice(2);
|
|
621
|
+
const command = args[0];
|
|
622
|
+
|
|
623
|
+
switch (command) {
|
|
624
|
+
case "start":
|
|
625
|
+
cmdStart();
|
|
626
|
+
break;
|
|
627
|
+
case "stop":
|
|
628
|
+
cmdStop();
|
|
629
|
+
break;
|
|
630
|
+
case "restart":
|
|
631
|
+
cmdRestart();
|
|
632
|
+
break;
|
|
633
|
+
case "status":
|
|
634
|
+
cmdStatus();
|
|
635
|
+
break;
|
|
636
|
+
case "logs":
|
|
637
|
+
cmdLogs();
|
|
638
|
+
break;
|
|
639
|
+
case "server":
|
|
640
|
+
cmdServer();
|
|
641
|
+
break;
|
|
642
|
+
case "config":
|
|
643
|
+
cmdConfig();
|
|
644
|
+
break;
|
|
645
|
+
case "update":
|
|
646
|
+
cmdUpdate();
|
|
647
|
+
break;
|
|
648
|
+
case "uninstall":
|
|
649
|
+
cmdUninstall();
|
|
650
|
+
break;
|
|
651
|
+
case "--help":
|
|
652
|
+
case "-h":
|
|
653
|
+
case undefined:
|
|
654
|
+
showHelp();
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
banner();
|
|
658
|
+
fail(`Unknown command: ${c.white}${command}${c.reset}`);
|
|
659
|
+
blank();
|
|
660
|
+
console.log(` ${c.gray}Run ${c.green}anycode --help${c.gray} to see available commands.${c.reset}`);
|
|
661
|
+
blank();
|
|
662
|
+
process.exit(1);
|
|
663
|
+
}
|
package/tsconfig.json
ADDED